Skip to content
Merged
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
4 changes: 1 addition & 3 deletions arch/riscv/core/pmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ LOG_MODULE_REGISTER(mpu);
#define PMP_NA4_SUPPORTED !IS_ENABLED(CONFIG_PMP_NO_NA4)
#define PMP_NAPOT_SUPPORTED !IS_ENABLED(CONFIG_PMP_NO_NAPOT)

#define PMPCFG_STRIDE sizeof(unsigned long)

#define PMP_ADDR(addr) ((addr) >> 2)
#define NAPOT_RANGE(size) (((size) - 1) >> 1)
#define PMP_ADDR_NAPOT(addr, size) PMP_ADDR(addr | NAPOT_RANGE(size))
Expand Down Expand Up @@ -562,7 +560,7 @@ void z_riscv_pmp_stackguard_disable(void)
{

unsigned long pmp_addr[CONFIG_PMP_SLOTS];
unsigned long pmp_cfg[CONFIG_PMP_SLOTS / sizeof(unsigned long)];
unsigned long pmp_cfg[CONFIG_PMP_SLOTS / PMPCFG_STRIDE];
unsigned int index = global_pmp_end_index;

/* Retrieve the pmpaddr value matching the last global PMP slot. */
Expand Down
2 changes: 2 additions & 0 deletions arch/riscv/include/pmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#ifndef PMP_H_
#define PMP_H_

#define PMPCFG_STRIDE (__riscv_xlen / 8)

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);
Expand Down
4 changes: 2 additions & 2 deletions include/zephyr/arch/riscv/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ struct _thread_arch {
#ifdef CONFIG_USERSPACE
unsigned long priv_stack_start;
unsigned long u_mode_pmpaddr_regs[CONFIG_PMP_SLOTS];
unsigned long u_mode_pmpcfg_regs[CONFIG_PMP_SLOTS / sizeof(unsigned long)];
unsigned long u_mode_pmpcfg_regs[CONFIG_PMP_SLOTS / (__riscv_xlen / 8)];
unsigned int u_mode_pmp_domain_offset;
unsigned int u_mode_pmp_end_index;
unsigned int u_mode_pmp_update_nr;
#endif
#ifdef CONFIG_PMP_STACK_GUARD
unsigned int m_mode_pmp_end_index;
unsigned long m_mode_pmpaddr_regs[CONFIG_PMP_SLOTS];
unsigned long m_mode_pmpcfg_regs[CONFIG_PMP_SLOTS / sizeof(unsigned long)];
unsigned long m_mode_pmpcfg_regs[CONFIG_PMP_SLOTS / (__riscv_xlen / 8)];
#endif
};

Expand Down