From cdebae2cc9539e2e0553b9c68eab22997c734cbb Mon Sep 17 00:00:00 2001 From: Anup Patel Date: Mon, 11 Dec 2023 14:07:56 +0530 Subject: lib: utils/irqchip: Add shared MMIO region for PLIC in root domain On platforms with Smepmp, the MMIO regions accessed by M-mode need to be explicitly marked with M-mode only read/write or shared (both (M-mode and S-mode) read/write permission. If the above is not done then runtime PLIC access from M-mode on platforms with Smepmp will result in access fault when further results in CPU hotplug not working. Signed-off-by: Anup Patel --- lib/utils/fdt/fdt_helper.c | 1 + lib/utils/irqchip/plic.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/utils') diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c index 4ed6bbc1..e50f4d84 100644 --- a/lib/utils/fdt/fdt_helper.c +++ b/lib/utils/fdt/fdt_helper.c @@ -880,6 +880,7 @@ int fdt_parse_plic_node(void *fdt, int nodeoffset, struct plic_data *plic) if (rc < 0 || !reg_addr || !reg_size) return SBI_ENODEV; plic->addr = reg_addr; + plic->size = reg_size; val = fdt_getprop(fdt, nodeoffset, "riscv,ndev", &len); if (len > 0) diff --git a/lib/utils/irqchip/plic.c b/lib/utils/irqchip/plic.c index d6335148..193e3201 100644 --- a/lib/utils/irqchip/plic.c +++ b/lib/utils/irqchip/plic.c @@ -10,7 +10,9 @@ #include #include +#include #include +#include #include #include #include @@ -171,5 +173,7 @@ int plic_cold_irqchip_init(const struct plic_data *plic) for (i = 1; i <= plic->num_src; i++) plic_set_priority(plic, i, 0); - return 0; + return sbi_domain_root_add_memrange(plic->addr, plic->size, BIT(20), + (SBI_DOMAIN_MEMREGION_MMIO | + SBI_DOMAIN_MEMREGION_SHARED_SURW_MRW)); } -- cgit v1.3.1