From cbcc7c0db334df171e270d197e1e34b5b7427eb6 Mon Sep 17 00:00:00 2001 From: Jason Chen CJ Date: Thu, 5 Apr 2018 08:16:38 +0800 Subject: [PATCH] mmu: refine function break_page_table function break_page_table should return next_level_page_size, if something wrong, it return 0. the change is valid for release version, as at that time ASSERT() in break_page_table is empty. Signed-off-by: Jason Chen CJ Acked-by: Eddie Dong --- hypervisor/arch/x86/mmu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hypervisor/arch/x86/mmu.c b/hypervisor/arch/x86/mmu.c index e13517f30..a9e2070e5 100644 --- a/hypervisor/arch/x86/mmu.c +++ b/hypervisor/arch/x86/mmu.c @@ -787,12 +787,12 @@ static uint64_t break_page_table(struct map_params *map_params, void *paddr, /* New entry present - need to allocate a new table */ sub_tab_addr = alloc_paging_struct(); /* Check to ensure memory available for this structure */ - if (sub_tab_addr == 0) { + if (sub_tab_addr == NULL) { /* Error: * Unable to find table memory necessary to map memory */ pr_err("Fail to find table memory for map memory"); - ASSERT(sub_tab_addr == 0, ""); + ASSERT(0, "fail to alloc table memory for map memory"); return 0; } @@ -900,6 +900,8 @@ static int modify_paging(struct map_params *map_params, void *paddr, */ page_size = break_page_table(map_params, paddr, vaddr, page_size, direct); + if (page_size == 0) + return -EINVAL; } } else { page_size = ((uint64_t)remaining_size < page_size)