Skip to content
This repository was archived by the owner on Jan 28, 2023. It is now read-only.

Commit ecd359f

Browse files
neviladraphaelning
authored andcommitted
page_walker: Fix PAE PDPT pointer calculation
Signed-off-by: Alexey Romko <nevilad@yahoo.com>
1 parent 9060aa0 commit ecd359f

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

core/page_walker.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,8 @@ uint32_t pw_perform_page_walk(
616616
first_table = pw_retrieve_table_from_cr3(cr3, is_pae, is_lme);
617617

618618
if (is_pae) {
619+
uint8_t *pdpt_page_hva;
620+
619621
if (is_lme) {
620622
pml4t_gpa = first_table;
621623
#ifdef CONFIG_HAX_EPT2
@@ -655,21 +657,24 @@ uint32_t pw_perform_page_walk(
655657
}
656658

657659
#ifdef CONFIG_HAX_EPT2
658-
pdpt_hva = gpa_space_map_page(&vcpu->vm->gpa_space,
659-
pdpt_gpa >> PG_ORDER_4K,
660-
&pdpt_kmap, NULL);
660+
pdpt_page_hva = gpa_space_map_page(&vcpu->vm->gpa_space,
661+
pdpt_gpa >> PG_ORDER_4K,
662+
&pdpt_kmap, NULL);
661663
#else // !CONFIG_HAX_EPT2
662664
#ifdef HAX_ARCH_X86_32
663-
pdpt_hva = hax_map_gpfn(vcpu->vm, pdpt_gpa >> 12, is_kernel, cr3, 1);
665+
pdpt_page_hva = hax_map_gpfn(vcpu->vm, pdpt_gpa >> 12, is_kernel, cr3, 1);
664666
#else
665-
pdpt_hva = hax_map_gpfn(vcpu->vm, pdpt_gpa >> 12);
667+
pdpt_page_hva = hax_map_gpfn(vcpu->vm, pdpt_gpa >> 12);
666668
#endif
667669
#endif // CONFIG_HAX_EPT2
668-
if (pdpt_hva == NULL) {
670+
if (pdpt_page_hva == NULL) {
669671
retval = TF_FAILED;
670672
goto out;
671673
}
672674

675+
// In PAE paging mode, pdpt_gpa is 32-byte aligned, not 4KB-aligned
676+
pdpt_hva = pdpt_page_hva + (uint)(pdpt_gpa & (PAGE_SIZE_4K - 1));
677+
673678
pdpte_ptr = pw_retrieve_table_entry(vcpu, pdpt_hva, pdpte_index,
674679
is_pae);
675680
pw_read_entry_value(&pdpte_val, pdpte_ptr, is_pae);

0 commit comments

Comments
 (0)