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 <fei1.li@intel.com>
This commit is contained in:
Li, Fei1 2018-07-26 09:04:49 +08:00 committed by lijinxia
parent 5189bcd272
commit efd5ac4814

View File

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