From c111dd2e2cf8fd70ce374884412d7f872fd593e7 Mon Sep 17 00:00:00 2001 From: Yuanyuan Zhao Date: Thu, 4 Nov 2021 10:42:53 +0800 Subject: [PATCH] hv : encapsulate page align in e820_alloc_memory e820_alloc_memory requires 4k alignment, so conversion to size is encapsulated in the function. And then the pre-condition of `size_arg` is removed. Tracked-On: #6805 Signed-off-by: Yuanyuan Zhao Reviewed-by: Wang, Yu1 Acked-by: Eddie Dong --- hypervisor/arch/x86/e820.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hypervisor/arch/x86/e820.c b/hypervisor/arch/x86/e820.c index a68ca6a13..52b7e7012 100644 --- a/hypervisor/arch/x86/e820.c +++ b/hypervisor/arch/x86/e820.c @@ -27,17 +27,20 @@ static struct e820_entry hv_e820[E820_MAX_ENTRIES]; /* * @brief reserve some RAM, hide it from Service VM, return its start address + * + * e820_alloc_memory requires 4k alignment, so size_arg will be converted + * in the function. + * * @param size_arg Amount of memory to be found and marked reserved * @param max_addr Maximum address below which memory is to be identified * * @pre hv_e820_entries_nr > 0U - * @pre (size_arg & 0xFFFU) == 0U * @return base address of the memory region */ uint64_t e820_alloc_memory(uint64_t size_arg, uint64_t max_addr) { int32_t i; - uint64_t size = size_arg; + uint64_t size = round_page_up(size_arg); uint64_t ret = INVALID_HPA; struct e820_entry *entry, *new_entry;