zephyr/arch
Daniel Leung d344a6bc85 xtensa: make arch_user_string_nlen actually work
arch_user_string_nlen() did not exactly work correctly as any
invalid pointers being passed are de-referenced naively, which
results in DTLB misses (MMU) or access errors (MPU). However,
arch_user_string_nlen() should always return to the caller
with appropriate error code set, and should never result in
thread termination. Since we are usually going through syscalls
when arch_user_string_nlen() is called, for MMU, the DTLB miss
goes through double exception. Since the pointer is invalid,
there is a high chance there is not even a L2 page table
associated with that bad address. So the DTLB miss cannot be
handled and it just keeps looping in double exception until
there is another exception type where we get to the C handler.
However, the stack frame is no longer the frame associated
with the call to arch_user_string_nlen(), and the call return
address would be incorrect. Forcing this incorrect address as
the next PC would result in some other exceptions, e.g.
illegal instruction, which would go to the C handler again.
This time it will go to the end of handler and would result
in thread termination. For MPU systems, access errors would
simply result in thread terminal in the C handler. Because of
these reasons, change the arch_user_string_nlen() to check if
the memory region can be accessed under kernel mode first
before feeding it to strnlen().

Also remove the exception fixup arrays as there is nothing
there anymore.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-06-15 04:44:48 -04:00
..
arc ARC: enable barriers for HS 2024-06-14 15:38:39 +02:00
arm arch: arm: cortex_m: update inline comment pointing to isr_wrapper.* 2024-06-12 18:29:12 -04:00
arm64 arm64: move simple memcpy/memset alternatives to assembly 2024-06-14 17:11:40 -04:00
common arch: common: Removed unnecessary cast 2024-06-07 19:05:08 -04:00
mips arch: remove the use of z_arch_esf_t completely from internal 2024-06-04 14:02:51 -05:00
nios2 arch: remove the use of z_arch_esf_t completely from internal 2024-06-04 14:02:51 -05:00
posix build: namespace the generated headers with zephyr/ 2024-05-28 22:03:55 +02:00
riscv arch: riscv: stacktrace: conditionally check stack_info 2024-06-14 05:22:59 -04:00
sparc arch: remove the use of z_arch_esf_t completely from internal 2024-06-04 14:02:51 -05:00
x86 kernel: mm: rename z_page_fault() to k_mem_page_fault() 2024-06-12 21:13:26 -04:00
xtensa xtensa: make arch_user_string_nlen actually work 2024-06-15 04:44:48 -04:00
archs.yml hwmv2: Introduce Hardware model version 2 and convert devices 2024-03-02 16:56:33 -05:00
CMakeLists.txt cmake: enable -Wshadow partially for in-tree code 2023-08-22 11:39:58 +02:00
Kconfig soc: esp32c6: Kconfig and .ld updates, DTS and comments fix 2024-06-14 18:51:46 -04:00
Kconfig.v1 hwmv2: Introduce Hardware model version 2 and convert devices 2024-03-02 16:56:33 -05:00
Kconfig.v2 hwmv2: Introduce Hardware model version 2 and convert devices 2024-03-02 16:56:33 -05:00