lib: sbi: Grant SU R/W/X permissions to whole memory
authorHimanshu Chauhan <hchauhan@ventanamicro.com>
Wed, 12 Jul 2023 04:34:32 +0000 (10:04 +0530)
committerAnup Patel <anup@brainfault.org>
Thu, 13 Jul 2023 06:57:50 +0000 (12:27 +0530)
Since pmp entries have implicit priority on index, previous entries will
deny access to SU on M-mode region. Also, M-mode will not have access to
SU region while previous entries will allow access to M-mode regions.

Signed-off-by: Himanshu Chauhan <hchauhan@ventanamicro.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
lib/sbi/sbi_domain.c

index 38a5902ff470eb52eab642aecd2ca1fa589fc86a..acd0f74c301c087dd596da4cb076500beed10445 100644 (file)
@@ -772,11 +772,17 @@ int sbi_domain_init(struct sbi_scratch *scratch, u32 cold_hartid)
 
        root.fw_region_inited = true;
 
-       /* Root domain allow everything memory region */
+       /*
+        * Allow SU RWX on rest of the memory region. Since pmp entries
+        * have implicit priority on index, previous entries will
+        * deny access to SU on M-mode region. Also, M-mode will not
+        * have access to SU region while previous entries will allow
+        * access to M-mode regions.
+        */
        sbi_domain_memregion_init(0, ~0UL,
-                                 (SBI_DOMAIN_MEMREGION_READABLE |
-                                  SBI_DOMAIN_MEMREGION_WRITEABLE |
-                                  SBI_DOMAIN_MEMREGION_EXECUTABLE),
+                                 (SBI_DOMAIN_MEMREGION_SU_READABLE |
+                                  SBI_DOMAIN_MEMREGION_SU_WRITABLE |
+                                  SBI_DOMAIN_MEMREGION_SU_EXECUTABLE),
                                  &root_memregs[root_memregs_count++]);
 
        /* Root domain memory region end */