Skip to content

Commit efd5ac4

Browse files
lifeixlijinxia
authored andcommitted
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>
1 parent 5189bcd commit efd5ac4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

hypervisor/arch/x86/pagetable.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ static int modify_pde(uint64_t *pdpte,
123123
return -EFAULT;
124124
}
125125
if (pde_large(*pde) != 0UL) {
126-
if (vaddr_next > vaddr_end) {
126+
if (vaddr_next > vaddr_end ||
127+
!MEM_ALIGNED_CHECK(vaddr, PDE_SIZE)) {
127128
ret = split_large_page(pde, IA32E_PD, ptt);
128129
if (ret != 0) {
129130
return ret;
@@ -173,7 +174,8 @@ static int modify_pdpte(uint64_t *pml4e,
173174
return -EFAULT;
174175
}
175176
if (pdpte_large(*pdpte) != 0UL) {
176-
if (vaddr_next > vaddr_end) {
177+
if (vaddr_next > vaddr_end ||
178+
!MEM_ALIGNED_CHECK(vaddr, PDPTE_SIZE)) {
177179
ret = split_large_page(pdpte, IA32E_PDPT, ptt);
178180
if (ret != 0) {
179181
return ret;

0 commit comments

Comments
 (0)