From efd5ac48144b79d761662e522742b75cc0b8ec0a Mon Sep 17 00:00:00 2001 From: "Li, Fei1" Date: Thu, 26 Jul 2018 09:04:49 +0800 Subject: [PATCH] hv: mmu: fix wrong to modify a large page attributes If try to modify a memory region which will cross a large page and the first page virtual address in it would not align to the large page size, it would modify the whole large page attributes which is fatal wrong. Signed-off-by: Li, Fei1 --- hypervisor/arch/x86/pagetable.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hypervisor/arch/x86/pagetable.c b/hypervisor/arch/x86/pagetable.c index 6f52a2a96..babe6099f 100644 --- a/hypervisor/arch/x86/pagetable.c +++ b/hypervisor/arch/x86/pagetable.c @@ -123,7 +123,8 @@ static int modify_pde(uint64_t *pdpte, return -EFAULT; } if (pde_large(*pde) != 0UL) { - if (vaddr_next > vaddr_end) { + if (vaddr_next > vaddr_end || + !MEM_ALIGNED_CHECK(vaddr, PDE_SIZE)) { ret = split_large_page(pde, IA32E_PD, ptt); if (ret != 0) { return ret; @@ -173,7 +174,8 @@ static int modify_pdpte(uint64_t *pml4e, return -EFAULT; } if (pdpte_large(*pdpte) != 0UL) { - if (vaddr_next > vaddr_end) { + if (vaddr_next > vaddr_end || + !MEM_ALIGNED_CHECK(vaddr, PDPTE_SIZE)) { ret = split_large_page(pdpte, IA32E_PDPT, ptt); if (ret != 0) { return ret;