aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorJuergen Gross <jgross@suse.com>2015-01-12 00:05:08 -0500
committerDavid Vrabel <david.vrabel@citrix.com>2015-01-12 05:09:40 -0500
commitf241b0b891c903da2465b7a98eaf650784e666da (patch)
treeff0134e6a0dd55e5066719de73dac85d8ea972fe /arch
parent82c92ed1357bca22a5d637fbb93dab3eb18a8e8c (diff)
xen: correct race in alloc_p2m_pmd()
When 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. Signed-off-by: Juergen Gross <jgross@suse.com> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/xen/p2m.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
index ff4ebd820603..70fb5075c901 100644
--- a/arch/x86/xen/p2m.c
+++ b/arch/x86/xen/p2m.c
@@ -439,10 +439,9 @@ EXPORT_SYMBOL_GPL(get_phys_to_machine);
439 * a new pmd is to replace p2m_missing_pte or p2m_identity_pte by a individual 439 * a new pmd is to replace p2m_missing_pte or p2m_identity_pte by a individual
440 * pmd. In case of PAE/x86-32 there are multiple pmds to allocate! 440 * pmd. In case of PAE/x86-32 there are multiple pmds to allocate!
441 */ 441 */
442static pte_t *alloc_p2m_pmd(unsigned long addr, pte_t *ptep, pte_t *pte_pg) 442static pte_t *alloc_p2m_pmd(unsigned long addr, pte_t *pte_pg)
443{ 443{
444 pte_t *ptechk; 444 pte_t *ptechk;
445 pte_t *pteret = ptep;
446 pte_t *pte_newpg[PMDS_PER_MID_PAGE]; 445 pte_t *pte_newpg[PMDS_PER_MID_PAGE];
447 pmd_t *pmdp; 446 pmd_t *pmdp;
448 unsigned int level; 447 unsigned int level;
@@ -476,8 +475,6 @@ static pte_t *alloc_p2m_pmd(unsigned long addr, pte_t *ptep, pte_t *pte_pg)
476 if (ptechk == pte_pg) { 475 if (ptechk == pte_pg) {
477 set_pmd(pmdp, 476 set_pmd(pmdp,
478 __pmd(__pa(pte_newpg[i]) | _KERNPG_TABLE)); 477 __pmd(__pa(pte_newpg[i]) | _KERNPG_TABLE));
479 if (vaddr == (addr & ~(PMD_SIZE - 1)))
480 pteret = pte_offset_kernel(pmdp, addr);
481 pte_newpg[i] = NULL; 478 pte_newpg[i] = NULL;
482 } 479 }
483 480
@@ -491,7 +488,7 @@ static pte_t *alloc_p2m_pmd(unsigned long addr, pte_t *ptep, pte_t *pte_pg)
491 vaddr += PMD_SIZE; 488 vaddr += PMD_SIZE;
492 } 489 }
493 490
494 return pteret; 491 return lookup_address(addr, &level);
495} 492}
496 493
497/* 494/*
@@ -520,7 +517,7 @@ static bool alloc_p2m(unsigned long pfn)
520 517
521 if (pte_pg == p2m_missing_pte || pte_pg == p2m_identity_pte) { 518 if (pte_pg == p2m_missing_pte || pte_pg == p2m_identity_pte) {
522 /* PMD level is missing, allocate a new one */ 519 /* PMD level is missing, allocate a new one */
523 ptep = alloc_p2m_pmd(addr, ptep, pte_pg); 520 ptep = alloc_p2m_pmd(addr, pte_pg);
524 if (!ptep) 521 if (!ptep)
525 return false; 522 return false;
526 } 523 }