Browse Source

lib: utils/fdt/fdt_domain: Simplify region access permission check

The region access permission check in __fdt_parse_region() can be
simplified as masking SBI_DOMAIN_MEMREGION_{M,SU}_ACCESS_MASK is
enough.

While we are here, update the confusing comments to match the codes.

Signed-off-by: Bin Meng <bmeng@tinylab.org>
Reviewed-by: Anup Patel <anup@brainfault.org>
Bin Meng 1 year ago
parent
commit
bc06ff65bf
1 changed files with 4 additions and 6 deletions
  1. 4 6
      lib/utils/fdt/fdt_domain.c

+ 4 - 6
lib/utils/fdt/fdt_domain.c

@@ -244,13 +244,11 @@ static int __fdt_parse_region(void *fdt, int domain_offset,
 	 * 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.
+	 * SU permission bits can't be all zeroes when M-mode permission
+	 * bits have at least one bit 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))
+	if (!(region_access & SBI_DOMAIN_MEMREGION_SU_ACCESS_MASK)
+	    && (region_access & SBI_DOMAIN_MEMREGION_M_ACCESS_MASK))
 		return SBI_EINVAL;
 
 	/* Find next region of the domain */