@@ -688,27 +688,61 @@ config THREAD_SIZE_ORDER
688688 affects irq stack size, which is equal to thread stack size.
689689
690690config RISCV_MISALIGNED
691- bool "Support misaligned load/store traps for kernel and userspace"
691+ bool
692692 select SYSCTL_ARCH_UNALIGN_ALLOW
693- default y
694693 help
695- Say Y here if you want the kernel to embed support for misaligned
696- load/store for both kernel and userspace. When disable, misaligned
697- accesses will generate SIGBUS in userspace and panic in kernel.
694+ Embed support for emulating misaligned loads and stores.
695+
696+ choice
697+ prompt "Unaligned Accesses Support"
698+ default RISCV_PROBE_UNALIGNED_ACCESS
699+ help
700+ This determines the level of support for unaligned accesses. This
701+ information is used by the kernel to perform optimizations. It is also
702+ exposed to user space via the hwprobe syscall. The hardware will be
703+ probed at boot by default.
704+
705+ config RISCV_PROBE_UNALIGNED_ACCESS
706+ bool "Probe for hardware unaligned access support"
707+ select RISCV_MISALIGNED
708+ help
709+ During boot, the kernel will run a series of tests to determine the
710+ speed of unaligned accesses. This probing will dynamically determine
711+ the speed of unaligned accesses on the underlying system. If unaligned
712+ memory accesses trap into the kernel as they are not supported by the
713+ system, the kernel will emulate the unaligned accesses to preserve the
714+ UABI.
715+
716+ config RISCV_EMULATED_UNALIGNED_ACCESS
717+ bool "Emulate unaligned access where system support is missing"
718+ select RISCV_MISALIGNED
719+ help
720+ If unaligned memory accesses trap into the kernel as they are not
721+ supported by the system, the kernel will emulate the unaligned
722+ accesses to preserve the UABI. When the underlying system does support
723+ unaligned accesses, the unaligned accesses are assumed to be slow.
724+
725+ config RISCV_SLOW_UNALIGNED_ACCESS
726+ bool "Assume the system supports slow unaligned memory accesses"
727+ depends on NONPORTABLE
728+ help
729+ Assume that the system supports slow unaligned memory accesses. The
730+ kernel and userspace programs may not be able to run at all on systems
731+ that do not support unaligned memory accesses.
698732
699733config RISCV_EFFICIENT_UNALIGNED_ACCESS
700- bool "Assume the CPU supports fast unaligned memory accesses"
734+ bool "Assume the system supports fast unaligned memory accesses"
701735 depends on NONPORTABLE
702736 select DCACHE_WORD_ACCESS if MMU
703737 select HAVE_EFFICIENT_UNALIGNED_ACCESS
704738 help
705- Say Y here if you want the kernel to assume that the CPU supports
706- efficient unaligned memory accesses. When enabled, this option
707- improves the performance of the kernel on such CPUs. However, the
708- kernel will run much more slowly, or will not be able to run at all,
709- on CPUs that do not support efficient unaligned memory accesses.
739+ Assume that the system supports fast unaligned memory accesses. When
740+ enabled, this option improves the performance of the kernel on such
741+ systems. However, the kernel and userspace programs will run much more
742+ slowly, or will not be able to run at all, on systems that do not
743+ support efficient unaligned memory accesses.
710744
711- If unsure what to do here, say N.
745+ endchoice
712746
713747endmenu # "Platform type"
714748
0 commit comments