From fd2c07682efb309de8454f5d485df74159c87d39 Mon Sep 17 00:00:00 2001 From: Jim Shu Date: Sat, 15 Jan 2022 18:48:36 +0800 Subject: [PATCH] arch: riscv: pmp: Fix is_user_mode in RV64 Currently, is_user_mode is 8-byte in riscv64 and it breaks a 4-byte PMP region protecting it. Because is_user_mode is a single flag, we could just fix it's size to 4-byte in both riscv32 and riscv64. Signed-off-by: Jim Shu --- arch/riscv/core/pmp/core_pmp.c | 2 +- arch/riscv/core/thread.c | 2 +- include/arch/riscv/syscall.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/riscv/core/pmp/core_pmp.c b/arch/riscv/core/pmp/core_pmp.c index 776799150a0..f1879991880 100644 --- a/arch/riscv/core/pmp/core_pmp.c +++ b/arch/riscv/core/pmp/core_pmp.c @@ -68,7 +68,7 @@ struct riscv_pmp_region { }; #ifdef CONFIG_USERSPACE -extern ulong_t is_user_mode; +extern uint32_t is_user_mode; #endif /* diff --git a/arch/riscv/core/thread.c b/arch/riscv/core/thread.c index 05ed4d586cc..f744c6ef1f5 100644 --- a/arch/riscv/core/thread.c +++ b/arch/riscv/core/thread.c @@ -17,7 +17,7 @@ * Glogal variable used to know the current mode running. * Is not boolean because it must match the PMP granularity of the arch. */ -ulong_t is_user_mode; +uint32_t is_user_mode; bool irq_flag; #endif diff --git a/include/arch/riscv/syscall.h b/include/arch/riscv/syscall.h index 55f767a9209..15ccc3c1ea7 100644 --- a/include/arch/riscv/syscall.h +++ b/include/arch/riscv/syscall.h @@ -151,7 +151,7 @@ static inline uintptr_t arch_syscall_invoke0(uintptr_t call_id) static inline bool arch_is_user_context(void) { /* Defined in arch/riscv/core/thread.c */ - extern ulong_t is_user_mode; + extern uint32_t is_user_mode; return is_user_mode; }