Add support for memory alignment requirements and adjust a candidate address to it before checking whether the block is large enough since the alignment adjustment can make a block smaller than what was requested.
Signed-off-by: stefan Berger <[email protected]> Cc: Hari Bathini <[email protected]> Cc: Pavithra Prakash <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Carolyn Scherrer <[email protected]> Cc: Mahesh Salgaonkar <[email protected]> Cc: Sourabh Jain <[email protected]> --- grub-core/kern/ieee1275/init.c | 10 ++++++++++ include/grub/powerpc/ieee1275/alloc.h | 1 + 2 files changed, 11 insertions(+) diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c index a0ce9d55e..5414f659c 100644 --- a/grub-core/kern/ieee1275/init.c +++ b/grub-core/kern/ieee1275/init.c @@ -506,6 +506,16 @@ regions_claim (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type, } } } + + /* Honor alignment restrictions on candidate addr */ + if (rcr->align) + { + grub_uint64_t align_addr = ALIGN_UP (addr, rcr->align); + + len = len - (align_addr - addr); + addr = align_addr; + } + if (rcr->flags & GRUB_MM_ADD_REGION_CONSECUTIVE && len < rcr->total) return 0; diff --git a/include/grub/powerpc/ieee1275/alloc.h b/include/grub/powerpc/ieee1275/alloc.h index 136e1df0b..b3d14f095 100644 --- a/include/grub/powerpc/ieee1275/alloc.h +++ b/include/grub/powerpc/ieee1275/alloc.h @@ -11,6 +11,7 @@ struct regions_claim_request { bool init_region; /* whether to init the region */ grub_uint64_t addr; /* result address */ grub_uint64_t len; /* number of bytes allocated */ + grub_size_t align; /* alignment restrictions */ }; #endif /* GRUB_POWERPC_IEEE1275_ALLOC_HEADER */ -- 2.25.1 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
