aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorJuergen Gross <jgross@suse.com>2017-05-10 00:08:44 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-05-20 08:28:34 -0400
commitf2b8de98f737a1c9a1a1c58b4cbbcc139f917a35 (patch)
tree2acceaeba33dc06b63150134d55573b03b98eda4 /arch/x86
parent58cd97ff374b7c6c39c9a78595a5eb75a56a08ac (diff)
xen: adjust early dom0 p2m handling to xen hypervisor behavior
commit 69861e0a52f8733355ce246f0db15e1b240ad667 upstream. 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: Juergen Gross <jgross@suse.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> Signed-off-by: Juergen Gross <jgross@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/xen/mmu.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 7d5afdb417cc..418f1b8576cf 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -2028,7 +2028,8 @@ static unsigned long __init xen_read_phys_ulong(phys_addr_t addr)
2028 2028
2029/* 2029/*
2030 * Translate a virtual address to a physical one without relying on mapped 2030 * Translate a virtual address to a physical one without relying on mapped
2031 * page tables. 2031 * page tables. Don't rely on big pages being aligned in (guest) physical
2032 * space!
2032 */ 2033 */
2033static phys_addr_t __init xen_early_virt_to_phys(unsigned long vaddr) 2034static phys_addr_t __init xen_early_virt_to_phys(unsigned long vaddr)
2034{ 2035{
@@ -2049,7 +2050,7 @@ static phys_addr_t __init xen_early_virt_to_phys(unsigned long vaddr)
2049 sizeof(pud))); 2050 sizeof(pud)));
2050 if (!pud_present(pud)) 2051 if (!pud_present(pud))
2051 return 0; 2052 return 0;
2052 pa = pud_pfn(pud) << PAGE_SHIFT; 2053 pa = pud_val(pud) & PTE_PFN_MASK;
2053 if (pud_large(pud)) 2054 if (pud_large(pud))
2054 return pa + (vaddr & ~PUD_MASK); 2055 return pa + (vaddr & ~PUD_MASK);
2055 2056
@@ -2057,7 +2058,7 @@ static phys_addr_t __init xen_early_virt_to_phys(unsigned long vaddr)
2057 sizeof(pmd))); 2058 sizeof(pmd)));
2058 if (!pmd_present(pmd)) 2059 if (!pmd_present(pmd))
2059 return 0; 2060 return 0;
2060 pa = pmd_pfn(pmd) << PAGE_SHIFT; 2061 pa = pmd_val(pmd) & PTE_PFN_MASK;
2061 if (pmd_large(pmd)) 2062 if (pmd_large(pmd))
2062 return pa + (vaddr & ~PMD_MASK); 2063 return pa + (vaddr & ~PMD_MASK);
2063 2064