mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-25 07:41:42 +01:00
lib: utils: Disallow non-root domains from adding M-mode regions
The M-mode regions can only be added to the root domain. The non-root domains shouldn't be able to add them from FDT. Signed-off-by: Himanshu Chauhan <hchauhan@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org> Tested-by: Anup Patel <anup@brainfault.org>
This commit is contained in:

committed by
Anup Patel

parent
20646e0184
commit
3e2f573e70
@@ -239,6 +239,20 @@ static int __fdt_parse_region(void *fdt, int domain_offset,
|
||||
u32 *region_count = opaque;
|
||||
struct sbi_domain_memregion *region;
|
||||
|
||||
/*
|
||||
* Non-root domains cannot add a region with only M-mode
|
||||
* access permissions. M-mode regions can only be part of
|
||||
* root domain.
|
||||
*
|
||||
* SU permission bits can't be all zeroes and M-mode permission
|
||||
* bits must be all set.
|
||||
*/
|
||||
if (!((region_access & SBI_DOMAIN_MEMREGION_SU_ACCESS_MASK)
|
||||
& SBI_DOMAIN_MEMREGION_SU_RWX)
|
||||
&& ((region_access & SBI_DOMAIN_MEMREGION_M_ACCESS_MASK)
|
||||
& SBI_DOMAIN_MEMREGION_M_RWX))
|
||||
return SBI_EINVAL;
|
||||
|
||||
/* Find next region of the domain */
|
||||
if (FDT_DOMAIN_REGION_MAX_COUNT <= *region_count)
|
||||
return SBI_EINVAL;
|
||||
|
Reference in New Issue
Block a user