lib: utils: Mark only the largest region as reserved in FDT
authorHimanshu Chauhan <hchauhan@ventanamicro.com>
Fri, 27 Jan 2023 04:19:23 +0000 (09:49 +0530)
committerAnup Patel <anup@brainfault.org>
Wed, 8 Feb 2023 05:43:19 +0000 (11:13 +0530)
commit199189bd1c172aab5a9733c0ffaaa14bbebb3323
treeeca49deaec8101b78eb44e784c76d634c0cf865f
parent84d15f4f529c92d3f32fbc570c02f7d40e9e70cb
lib: utils: Mark only the largest region as reserved in FDT

In commit 230278dcf, RX and RW regions were marked separately.
When the RW region grows (e.g. with more harts) and it isn't a
power-of-two, sbi_domain_memregion_init will upgrade the region
to the next power-of-two. This will make RX and RW both start
at the same base address, like so (with 64 harts):
Domain0 Region01 : 0x0000000080000000-0x000000008001ffff M: (R,X) S/U: ()
Domain0 Region02 : 0x0000000080000000-0x00000000800fffff M: (R,W) S/U: ()

This doesn't break the permission enforcement because of static
priorities in PMP but makes the kernel complain about the regions
overlapping each other. Like so:
[    0.000000] OF: reserved mem: OVERLAP DETECTED!
[    0.000000] mmode_resv0@80000000 (0x0000000080000000--0x0000000080020000) \
overlaps with mmode_resv1@80000000 (0x0000000080000000--0x0000000080100000)

To fix this warning, among the multiple regions having same base
address but different sizes, add only the largest region as reserved
region during fdt fixup.

Fixes: 230278dcf (lib: sbi: Add separate entries for firmware RX and RW regions)
Signed-off-by: Himanshu Chauhan <hchauhan@ventanamicro.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
lib/utils/fdt/fdt_fixup.c