Skip to content

Commit 0d66091

Browse files
f0rget-the-sadnashif
authored andcommitted
riscv: pmp: don't reconfigure modes
Previously PMP was avaible only with Multithreading, since it's now available without MT - add extra checks to prevent user/kernel mode reconfiguration. Signed-off-by: Volodymyr Fialko <[email protected]> Signed-off-by: Anas Nashif <[email protected]>
1 parent 850d471 commit 0d66091

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

arch/riscv/core/isr.S

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ no_fp: /* increment _current->arch.exception_depth */
356356
li t1, RISCV_EXC_ECALLU
357357
beq t0, t1, is_user_syscall
358358

359-
#ifdef CONFIG_PMP_STACK_GUARD
359+
#if defined(CONFIG_PMP_STACK_GUARD) && defined(CONFIG_MULTITHREADING)
360360
/*
361361
* Determine if we come from user space. If so, reconfigure the PMP for
362362
* kernel mode stack guard.
@@ -397,7 +397,7 @@ is_kernel_syscall:
397397
addi t0, t0, 4
398398
sr t0, __struct_arch_esf_mepc_OFFSET(sp)
399399

400-
#ifdef CONFIG_PMP_STACK_GUARD
400+
#if defined(CONFIG_PMP_STACK_GUARD) && defined(CONFIG_MULTITHREADING)
401401
/* Re-activate PMP for m-mode */
402402
li t1, MSTATUS_MPP
403403
csrc mstatus, t1
@@ -508,7 +508,7 @@ do_irq_offload:
508508
#ifdef CONFIG_USERSPACE
509509
is_user_syscall:
510510

511-
#ifdef CONFIG_PMP_STACK_GUARD
511+
#if defined(CONFIG_PMP_STACK_GUARD) && defined(CONFIG_MULTITHREADING)
512512
/*
513513
* We came from userspace and need to reconfigure the
514514
* PMP for kernel mode stack guard.
@@ -578,7 +578,7 @@ valid_syscall_id:
578578

579579
is_interrupt:
580580

581-
#ifdef CONFIG_PMP_STACK_GUARD
581+
#if defined(CONFIG_PMP_STACK_GUARD) && defined(CONFIG_MULTITHREADING)
582582
#ifdef CONFIG_USERSPACE
583583
/*
584584
* If we came from userspace then we need to reconfigure the
@@ -748,7 +748,7 @@ fp_trap_exit:
748748
and t0, t2, t1
749749
bnez t0, 1f
750750

751-
#ifdef CONFIG_PMP_STACK_GUARD
751+
#if defined(CONFIG_PMP_STACK_GUARD) && defined(CONFIG_MULTITHREADING)
752752
/* Remove kernel stack guard and Reconfigure PMP for user mode */
753753
lr a0, ___cpu_t_current_OFFSET(s0)
754754
call z_riscv_pmp_usermode_enable

0 commit comments

Comments
 (0)