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 <yuanyuan.zhao@linux.intel.com>
Reviewed-by: Wang, Yu1 <yu1.wang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Yuanyuan Zhao 2021-11-04 10:42:53 +08:00 committed by wenlingz
parent 4f6aa38ea5
commit c111dd2e2c

View File

@ -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;