Commit 69861e0a authored by Juergen Gross's avatar Juergen Gross

xen: adjust early dom0 p2m handling to xen hypervisor behavior

When booted as pv-guest the p2m list presented by the Xen is already
mapped to virtual addresses. In dom0 case the hypervisor might make use
of 2M- or 1G-pages for this mapping. Unfortunately while being properly
aligned in virtual and machine address space, those pages might not be
aligned properly in guest physical address space.

So when trying to obtain the guest physical address of such a page
pud_pfn() and pmd_pfn() must be avoided as those will mask away guest
physical address bits not being zero in this special case.
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
Reviewed-by: default avatarJan Beulich <jbeulich@suse.com>
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
parent def9331a
...@@ -2025,7 +2025,8 @@ static unsigned long __init xen_read_phys_ulong(phys_addr_t addr) ...@@ -2025,7 +2025,8 @@ static unsigned long __init xen_read_phys_ulong(phys_addr_t addr)
/* /*
* Translate a virtual address to a physical one without relying on mapped * Translate a virtual address to a physical one without relying on mapped
* page tables. * page tables. Don't rely on big pages being aligned in (guest) physical
* space!
*/ */
static phys_addr_t __init xen_early_virt_to_phys(unsigned long vaddr) static phys_addr_t __init xen_early_virt_to_phys(unsigned long vaddr)
{ {
...@@ -2046,7 +2047,7 @@ static phys_addr_t __init xen_early_virt_to_phys(unsigned long vaddr) ...@@ -2046,7 +2047,7 @@ static phys_addr_t __init xen_early_virt_to_phys(unsigned long vaddr)
sizeof(pud))); sizeof(pud)));
if (!pud_present(pud)) if (!pud_present(pud))
return 0; return 0;
pa = pud_pfn(pud) << PAGE_SHIFT; pa = pud_val(pud) & PTE_PFN_MASK;
if (pud_large(pud)) if (pud_large(pud))
return pa + (vaddr & ~PUD_MASK); return pa + (vaddr & ~PUD_MASK);
...@@ -2054,7 +2055,7 @@ static phys_addr_t __init xen_early_virt_to_phys(unsigned long vaddr) ...@@ -2054,7 +2055,7 @@ static phys_addr_t __init xen_early_virt_to_phys(unsigned long vaddr)
sizeof(pmd))); sizeof(pmd)));
if (!pmd_present(pmd)) if (!pmd_present(pmd))
return 0; return 0;
pa = pmd_pfn(pmd) << PAGE_SHIFT; pa = pmd_val(pmd) & PTE_PFN_MASK;
if (pmd_large(pmd)) if (pmd_large(pmd))
return pa + (vaddr & ~PMD_MASK); return pa + (vaddr & ~PMD_MASK);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment