linux/arch/riscv
Vivian Wang b69bcb13ed riscv: misaligned: Make enabling delegation depend on NONPORTABLE
The unaligned access emulation code in Linux has various deficiencies.
For example, it doesn't emulate vector instructions [1] [2], and doesn't
emulate KVM guest accesses. Therefore, requesting misaligned exception
delegation with SBI FWFT actually regresses vector instructions' and KVM
guests' behavior.

Until Linux can handle it properly, guard these sbi_fwft_set() calls
behind RISCV_SBI_FWFT_DELEGATE_MISALIGNED, which in turn depends on
NONPORTABLE. Those who are sure that this wouldn't be a problem can
enable this option, perhaps getting better performance.

The rest of the existing code proceeds as before, except as if
SBI_FWFT_MISALIGNED_EXC_DELEG is not available, to handle any remaining
address misaligned exceptions on a best-effort basis. The KVM SBI FWFT
implementation is also not touched, but it is disabled if the firmware
emulates unaligned accesses.

Cc: stable@vger.kernel.org
Fixes: cf5a8abc65 ("riscv: misaligned: request misaligned exception from SBI")
Reported-by: Songsong Zhang <U2FsdGVkX1@gmail.com> # KVM
Link: https://lore.kernel.org/linux-riscv/38ce44c1-08cf-4e3f-8ade-20da224f529c@iscas.ac.cn/ [1]
Link: https://lore.kernel.org/linux-riscv/b3cfcdac-0337-4db0-a611-258f2868855f@iscas.ac.cn/ [2]
Signed-off-by: Vivian Wang <wangruikang@iscas.ac.cn>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://patch.msgid.link/20260401-riscv-misaligned-dont-delegate-v2-1-5014a288c097@iscas.ac.cn
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2026-05-13 22:26:32 -06:00
..
boot RISC-V updates for v7.1 2026-04-24 10:00:37 -07:00
configs RISC-V updates for v7.0 2026-02-12 19:17:44 -08:00
crypto lib/crypto: riscv/sm3: Migrate optimized code into library 2026-03-23 17:50:59 -07:00
errata riscv: errata: Fix bitwise vs logical AND in MIPS errata patching 2026-04-30 20:00:14 -06:00
include RISC-V updates for v7.1 2026-04-24 10:00:37 -07:00
kernel riscv: misaligned: Make enabling delegation depend on NONPORTABLE 2026-05-13 22:26:32 -06:00
kvm RISC-V updates for v7.1 2026-04-24 10:00:37 -07:00
lib RISC-V updates for v7.1 2026-04-24 10:00:37 -07:00
mm riscv: mm: Fixup no5lvl failure when vaddr is invalid 2026-05-01 21:18:58 -06:00
net bpf: Pass bpf_verifier_env to JIT 2026-04-16 07:03:40 -07:00
purgatory riscv: lib: add strrchr() implementation 2026-04-04 18:42:44 -06:00
tools riscv: Stop considering R_RISCV_NONE as bad relocations 2025-07-16 08:13:55 -07:00
Kbuild riscv: migrate to the generic rule for built-in DTB 2025-03-18 13:30:13 +00:00
Kconfig riscv: misaligned: Make enabling delegation depend on NONPORTABLE 2026-05-13 22:26:32 -06:00
Kconfig.debug riscv: Add tests for riscv module loading 2023-11-07 14:59:32 -08:00
Kconfig.errata riscv: ERRATA_STARFIVE_JH7100: Fix missing dependency on new CONFIG_CACHEMAINT_FOR_DMA 2026-01-15 18:13:04 -07:00
Kconfig.socs riscv: Remove support for XIP kernel 2026-04-04 18:42:44 -06:00
Kconfig.vendor riscv: Add xmipsexectl as a vendor extension 2025-09-18 20:36:00 -06:00
Makefile riscv: Remove support for XIP kernel 2026-04-04 18:42:44 -06:00
Makefile.postlink kbuild: Create intermediate vmlinux build with relocations preserved 2025-03-17 00:29:50 +09:00