arch/risc-v/qemu-rv: Configure PMP before booting secondary harts.

Export qemu_rv_configure_mpu() and invoke it on the secondary-hart
boot path before riscv_cpu_boot().

This keeps protected SMP builds from faulting on !CPU0 when userspace
work is first scheduled there.

Signed-off-by: Shunchao Hu <ankohuu@gmail.com>
This commit is contained in:
Shunchao Hu
2026-03-28 21:58:21 +08:00
committed by Alan C. Assis
parent 9028fe72c7
commit fc6fd3f24d
3 changed files with 7 additions and 3 deletions
+3
View File
@@ -227,6 +227,9 @@ void qemu_rv_start(int mhartid, const char *dtb)
cpux:
#ifdef CONFIG_SMP
# ifdef CONFIG_BUILD_PROTECTED
qemu_rv_configure_mpu();
# endif
riscv_cpu_boot(mhartid);
#endif
+3 -3
View File
@@ -55,7 +55,7 @@
****************************************************************************/
/****************************************************************************
* Name: configure_mpu
* Name: qemu_rv_configure_mpu
*
* Description:
* This function configures the MPU for for kernel- / userspace separation.
@@ -63,7 +63,7 @@
*
****************************************************************************/
static void configure_mpu(void)
void qemu_rv_configure_mpu(void)
{
int ret;
ret = riscv_append_pmp_region(UFLASH_F, UFLASH_START, UFLASH_SIZE);
@@ -123,7 +123,7 @@ void qemu_rv_userspace(void)
/* Configure MPU / PMP to grant access to the userspace */
configure_mpu();
qemu_rv_configure_mpu();
}
#endif /* CONFIG_BUILD_PROTECTED */
@@ -45,6 +45,7 @@
****************************************************************************/
#ifdef CONFIG_BUILD_PROTECTED
void qemu_rv_configure_mpu(void);
void qemu_rv_userspace(void);
#endif