From f4780c0cd41f4c8058c4485c8778f74c9454bb96 Mon Sep 17 00:00:00 2001 From: Mingqiang Chi Date: Thu, 15 Mar 2018 16:43:05 +0800 Subject: [PATCH] Remove unnecessary variable in map_mem the variable 'table_present' is redundant in function(map_mem_region) Signed-off-by: Mingqiang Chi --- hypervisor/arch/x86/mmu.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/hypervisor/arch/x86/mmu.c b/hypervisor/arch/x86/mmu.c index 11f375eb5..4b0ab2644 100644 --- a/hypervisor/arch/x86/mmu.c +++ b/hypervisor/arch/x86/mmu.c @@ -166,7 +166,6 @@ static uint32_t map_mem_region(void *vaddr, void *paddr, int ept_entry, enum mem_map_request_type request_type) { uint64_t table_entry; - uint64_t table_present; uint32_t table_offset; uint32_t mapped_size; @@ -237,21 +236,6 @@ static uint32_t map_mem_region(void *vaddr, void *paddr, /* Check to see if mapping should occur */ if (mapped_size != 0) { - /* Get current table entry */ - uint64_t tmp = MEM_READ64(table_base + table_offset); - - /* Check if EPT entry */ - if (ept_entry) { - /* Use read/write/execute bits to determine presence of - * entry - */ - table_present = (IA32E_EPT_R_BIT | - IA32E_EPT_W_BIT | IA32E_EPT_X_BIT); - } else { - /* Use the P bit to determine if an entry is present */ - table_present = IA32E_COMM_P_BIT; - } - switch (request_type) { case PAGING_REQUEST_TYPE_MAP: { @@ -271,7 +255,10 @@ static uint32_t map_mem_region(void *vaddr, void *paddr, } case PAGING_REQUEST_TYPE_UNMAP: { - if (tmp & table_present) { + /* Get current table entry */ + uint64_t entry = MEM_READ64(table_base + table_offset); + + if (entry) { /* Table is present. * Write the table entry to map this memory */