arch: riscv: pmp: Fix 64-bit compatibility of pointer size

Fix 64-bit compatibility of pointer size of RISC-V PMP/userspace code.

Signed-off-by: Jim Shu <cwshu09@gmail.com>
This commit is contained in:
Jim Shu 2022-01-15 18:38:39 +08:00 committed by Anas Nashif
commit 595b01fc1d
3 changed files with 6 additions and 6 deletions

View file

@ -94,11 +94,11 @@ void _Fault(z_arch_esf_t *esf)
* treated as recoverable. * treated as recoverable.
*/ */
for (int i = 0; i < ARRAY_SIZE(exceptions); i++) { for (int i = 0; i < ARRAY_SIZE(exceptions); i++) {
uint32_t start = (uint32_t)exceptions[i].start; ulong_t start = (ulong_t)exceptions[i].start;
uint32_t end = (uint32_t)exceptions[i].end; ulong_t end = (ulong_t)exceptions[i].end;
if (esf->mepc >= start && esf->mepc < end) { if (esf->mepc >= start && esf->mepc < end) {
esf->mepc = (uint32_t)exceptions[i].fixup; esf->mepc = (ulong_t)exceptions[i].fixup;
return; return;
} }
} }

View file

@ -789,7 +789,7 @@ static inline int is_in_region(uint32_t index, uint32_t start, uint32_t size)
size = size == 0U ? 0U : size - 1U; size = size == 0U ? 0U : size - 1U;
#ifdef CONFIG_64BIT #ifdef CONFIG_64BIT
if (u64_add_overflow(start, size, &end)) { if (u64_add_overflow(start, size, (uint64_t *)&end)) {
return 0; return 0;
} }
#else #else

View file

@ -225,10 +225,10 @@ FUNC_NORETURN void z_riscv_user_mode_enter_syscall(k_thread_entry_t user_entry,
/* Set up privileged stack */ /* Set up privileged stack */
#ifdef CONFIG_GEN_PRIV_STACKS #ifdef CONFIG_GEN_PRIV_STACKS
_current->arch.priv_stack_start = _current->arch.priv_stack_start =
(uint32_t)z_priv_stack_find(_current->stack_obj); (ulong_t)z_priv_stack_find(_current->stack_obj);
#else #else
_current->arch.priv_stack_start = _current->arch.priv_stack_start =
(uint32_t)(_current->stack_obj) + (ulong_t)(_current->stack_obj) +
Z_RISCV_STACK_GUARD_SIZE; Z_RISCV_STACK_GUARD_SIZE;
#endif /* CONFIG_GEN_PRIV_STACKS */ #endif /* CONFIG_GEN_PRIV_STACKS */