xen: correct several bugs in new p2m list setup
Subsystems (2)
Juergen Gross
maintainerv2 cover xen: correct several bugs in new p2m list setup
In the setup code of the linear mapped p2m list several bugs have been found, especially for 32 bit dom0. These patches correct the errors and make 32 bit dom0 bootable again.
Changes since V1:
- split up patch 3 as requested by David Vrabel
- use phys_addr_t instead of u64 as requested by Jan Beulich
- compare pfns instead physical addresses as suggested by Jan Beulich
Juergen Gross (4):
xen: correct error for building p2m list on 32 bits
xen: correct race in alloc_p2m_pmd()
xen: use correct type for physical addresses
xen: check for zero sized area when invalidating memory
arch/x86/xen/p2m.c | 11 ++++------- arch/x86/xen/setup.c | 6 ++++-- 2 files changed, 8 insertions(+), 9 deletions(-)
Signature · 1 line
2.1.2
Juergen Gross
maintainerPATCH v2 1/4 xen: correct error for building p2m list on 32 bits
In xen_rebuild_p2m_list() for large areas of invalid or identity mapped memory the pmd entries on 32 bit systems are initialized wrong. Correct this error.
--- arch/x86/xen/p2m.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/xen/p2m.c +1 -1
@@ -379,7 +379,7 @@ static void __init xen_rebuild_p2m_list(unsigned long *p2m) p2m_missing_pte : p2m_identity_pte;for (i =0 ; i <PMDS_PER_MID_PAGE ; i++) { pmdp =populate_extra_pmd ( - (unsigned long )(p2m + pfn + i *PTRS_PER_PTE )); + (unsigned long )(p2m + pfn) + i *PMD_SIZE );set_pmd (pmdp,__pmd (__pa (ptep) | _KERNPG_TABLE)); } }
Signature · 1 line
2.1.2
Juergen Gross
maintainerPATCH v2 2/4 xen: correct race in alloc_p2m_pmd()
In reply to Juergen GrossWhen allocating a new pmd for the linear mapped p2m list a check is done for not introducing another pmd when this just happened on another cpu. In this case the old pte pointer was returned which points to the p2m_missing or p2m_identity page. The correct value would be the pointer to the found new page.
--- arch/x86/xen/p2m.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
arch/x86/xen/p2m.c +3 -6
@@ -440,10 +440,9 @@ EXPORT_SYMBOL_GPL(get_phys_to_machine);* a new pmd is to replace p2m_missing_pte or p2m_identity_pte by a individual * pmd. In case of PAE/x86-32 there are multiple pmds to allocate! */ -static pte_t *alloc_p2m_pmd (unsigned long addr,pte_t *ptep,pte_t *pte_pg) +static pte_t *alloc_p2m_pmd (unsigned long addr,pte_t *pte_pg) {pte_t *ptechk; -pte_t *pteret = ptep;pte_t *pte_newpg[PMDS_PER_MID_PAGE ];pmd_t *pmdp;unsigned int level;
@@ -477,8 +476,6 @@ static pte_t *alloc_p2m_pmd(unsigned long addr, pte_t *ptep, pte_t *pte_pg)if (ptechk == pte_pg) {set_pmd (pmdp,__pmd (__pa (pte_newpg[i]) | _KERNPG_TABLE)); -if (vaddr == (addr & ~(PMD_SIZE -1 ))) - pteret =pte_offset_kernel (pmdp, addr); pte_newpg[i] =NULL ; }
@@ -492,7 +489,7 @@ static pte_t *alloc_p2m_pmd(unsigned long addr, pte_t *ptep, pte_t *pte_pg) vaddr +=PMD_SIZE ; } -return pteret; +return lookup_address (addr, &level); }/*
@@ -521,7 +518,7 @@ static bool alloc_p2m(unsigned long pfn)if (pte_pg == p2m_missing_pte || pte_pg == p2m_identity_pte) {/* PMD level is missing, allocate a new one */ - ptep =alloc_p2m_pmd (addr, ptep, pte_pg); + ptep =alloc_p2m_pmd (addr, pte_pg);if (!ptep)return false; }
Signature · 1 line
2.1.2
Juergen Gross
maintainerPATCH v2 3/4 xen: use correct type for physical addresses
In reply to Juergen GrossWhen converting a pfn to a physical address be sure to use 64 bit wide types or convert the physical address to a pfn if possible.
--- arch/x86/xen/setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/xen/setup.c +2 -2
@@ -140,7 +140,7 @@ static void __init xen_del_extra_mem(u64 start, u64 size)unsigned long __ref xen_chk_extra_mem (unsigned long pfn) {int i; -unsigned long addr =PFN_PHYS (pfn); +phys_addr_t addr =PFN_PHYS (pfn);for (i =0 ; i <XEN_EXTRA_MEM_MAX_REGIONS ; i++) { if (addr >= xen_extra_mem[i].start &&
@@ -284,7 +284,7 @@ static void __init xen_update_mem_tables(unsigned long pfn, unsigned long mfn) }/* Update kernel mapping, but not for highmem. */ -if ((pfn <<PAGE_SHIFT ) >=__pa (high_memory)) +if (pfn >=PFN_UP (__pa (high_memory -1 )))return ; if (HYPERVISOR_update_va_mapping((unsigned long)__va(pfn << PAGE_SHIFT),
Signature · 1 line
2.1.2
Juergen Gross
maintainerPATCH v2 4/4 xen: check for zero sized area when invalidating memory
In reply to Juergen GrossWith the introduction of the linear mapped p2m list setting memory areas to "invalid" had to be delayed. When doing the invalidation make sure no zero sized areas are processed.
--- arch/x86/xen/setup.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/xen/setup.c +2 -0
@@ -160,6 +160,8 @@ void __init xen_inv_extra_mem(void)int i;for (i =0 ; i <XEN_EXTRA_MEM_MAX_REGIONS ; i++) { +if (!xen_extra_mem[i].size) +continue ; pfn_s =PFN_DOWN (xen_extra_mem[i].start); pfn_e =PFN_UP (xen_extra_mem[i].start + xen_extra_mem[i].size);for (pfn = pfn_s; pfn < pfn_e; pfn++)
Signature · 1 line
2.1.2
David Vrabel
AppliedQuoted 3 lines · Juergen Gross
In the setup code of the linear mapped p2m list several bugs have been found, especially for 32 bit dom0. These patches correct the errors and make 32 bit dom0 bootable again.
Applied to stable/for-linus-3.19, thanks.
David