Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arch/riscv/core/fatal.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ void z_riscv_fault(struct arch_esf *esf)
* Remove the thread's PMP setting to prevent triggering a stack
* overflow error again due to the previous configuration.
*/
z_riscv_pmp_stackguard_disable();
z_riscv_pmp_kernelmode_disable();
#endif /* CONFIG_PMP_STACK_GUARD */
reason = K_ERR_STACK_CHK_FAIL;
}
Expand Down
6 changes: 3 additions & 3 deletions arch/riscv/core/isr.S
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ no_fp: /* increment _current->arch.exception_depth */
and t0, t0, t1
bnez t0, 1f
lr a0, ___cpu_t_current_OFFSET(s0)
call z_riscv_pmp_stackguard_enable
call z_riscv_pmp_kernelmode_enable
1:
#endif /* CONFIG_PMP_STACK_GUARD */

Expand Down Expand Up @@ -524,7 +524,7 @@ is_user_syscall:
* PMP for kernel mode stack guard.
*/
lr a0, ___cpu_t_current_OFFSET(s0)
call z_riscv_pmp_stackguard_enable
call z_riscv_pmp_kernelmode_enable
#endif

/* It is safe to re-enable IRQs now */
Expand Down Expand Up @@ -599,7 +599,7 @@ is_interrupt:
and t0, t0, t1
bnez t0, 1f
lr a0, ___cpu_t_current_OFFSET(s0)
call z_riscv_pmp_stackguard_enable
call z_riscv_pmp_kernelmode_enable
j 2f
#endif /* CONFIG_USERSPACE */
1: /* Re-activate PMP for m-mode */
Expand Down
8 changes: 4 additions & 4 deletions arch/riscv/core/pmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ void z_riscv_pmp_init(void)
* This early, the kernel init code uses the IRQ stack and we want to
* safeguard it as soon as possible. But we need a temporary default
* "catch all" PMP entry for MPRV to work. Later on, this entry will
* be set for each thread by z_riscv_pmp_stackguard_prepare().
* be set for each thread by z_riscv_pmp_kernelmode_prepare().
*/
set_pmp_mprv_catchall(&index, pmp_addr, pmp_cfg, ARRAY_SIZE(pmp_addr));

Expand Down Expand Up @@ -501,7 +501,7 @@ static inline unsigned int z_riscv_pmp_thread_init(unsigned long *pmp_addr,
*
* This is called once during new thread creation.
*/
void z_riscv_pmp_stackguard_prepare(struct k_thread *thread)
void z_riscv_pmp_kernelmode_prepare(struct k_thread *thread)
{
unsigned int index = z_riscv_pmp_thread_init(PMP_M_MODE(thread));
uintptr_t stack_bottom;
Expand Down Expand Up @@ -529,7 +529,7 @@ void z_riscv_pmp_stackguard_prepare(struct k_thread *thread)
*
* This is called on every context switch.
*/
void z_riscv_pmp_stackguard_enable(struct k_thread *thread)
void z_riscv_pmp_kernelmode_enable(struct k_thread *thread)
{
LOG_DBG("pmp_stackguard_enable for thread %p", thread);

Expand Down Expand Up @@ -558,7 +558,7 @@ void z_riscv_pmp_stackguard_enable(struct k_thread *thread)
/**
* @brief Remove PMP stackguard content to actual PMP registers
*/
void z_riscv_pmp_stackguard_disable(void)
void z_riscv_pmp_kernelmode_disable(void)
{

unsigned long pmp_addr[CONFIG_PMP_SLOTS];
Expand Down
2 changes: 1 addition & 1 deletion arch/riscv/core/switch.S
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ SECTION_FUNC(TEXT, z_riscv_switch)
#if defined(CONFIG_PMP_STACK_GUARD)
/* Stack guard has priority over user space for PMP usage. */
mv s0, a0
call z_riscv_pmp_stackguard_enable
call z_riscv_pmp_kernelmode_enable
mv a0, s0
#elif defined(CONFIG_USERSPACE)
/*
Expand Down
4 changes: 2 additions & 2 deletions arch/riscv/core/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,

#if defined(CONFIG_PMP_STACK_GUARD)
/* Setup PMP regions of PMP stack guard of thread. */
z_riscv_pmp_stackguard_prepare(thread);
z_riscv_pmp_kernelmode_prepare(thread);
#endif /* CONFIG_PMP_STACK_GUARD */

#ifdef CONFIG_RISCV_SOC_CONTEXT_SAVE
Expand Down Expand Up @@ -178,7 +178,7 @@ FUNC_NORETURN void arch_user_mode_enter(k_thread_entry_t user_entry,

#ifdef CONFIG_PMP_STACK_GUARD
/* reconfigure as the kernel mode stack will be different */
z_riscv_pmp_stackguard_prepare(_current);
z_riscv_pmp_kernelmode_prepare(_current);
#endif

/* Set up Physical Memory Protection */
Expand Down
6 changes: 3 additions & 3 deletions arch/riscv/include/pmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#define PMP_H_

void z_riscv_pmp_init(void);
void z_riscv_pmp_stackguard_prepare(struct k_thread *thread);
void z_riscv_pmp_stackguard_enable(struct k_thread *thread);
void z_riscv_pmp_stackguard_disable(void);
void z_riscv_pmp_kernelmode_prepare(struct k_thread *thread);
void z_riscv_pmp_kernelmode_enable(struct k_thread *thread);
void z_riscv_pmp_kernelmode_disable(void);
void z_riscv_pmp_usermode_init(struct k_thread *thread);
void z_riscv_pmp_usermode_prepare(struct k_thread *thread);
void z_riscv_pmp_usermode_enable(struct k_thread *thread);
Expand Down