diff options
-rw-r--r-- | arch/x86/xen/p2m.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c index 9f5983b01ed9..4534320e66e4 100644 --- a/arch/x86/xen/p2m.c +++ b/arch/x86/xen/p2m.c | |||
@@ -566,6 +566,7 @@ static bool alloc_p2m(unsigned long pfn) | |||
566 | /* Separately check the mid mfn level */ | 566 | /* Separately check the mid mfn level */ |
567 | unsigned long missing_mfn; | 567 | unsigned long missing_mfn; |
568 | unsigned long mid_mfn_mfn; | 568 | unsigned long mid_mfn_mfn; |
569 | unsigned long old_mfn; | ||
569 | 570 | ||
570 | mid_mfn = alloc_p2m_page(); | 571 | mid_mfn = alloc_p2m_page(); |
571 | if (!mid_mfn) | 572 | if (!mid_mfn) |
@@ -575,10 +576,13 @@ static bool alloc_p2m(unsigned long pfn) | |||
575 | 576 | ||
576 | missing_mfn = virt_to_mfn(p2m_mid_missing_mfn); | 577 | missing_mfn = virt_to_mfn(p2m_mid_missing_mfn); |
577 | mid_mfn_mfn = virt_to_mfn(mid_mfn); | 578 | mid_mfn_mfn = virt_to_mfn(mid_mfn); |
578 | if (cmpxchg(top_mfn_p, missing_mfn, mid_mfn_mfn) != missing_mfn) | 579 | old_mfn = cmpxchg(top_mfn_p, missing_mfn, mid_mfn_mfn); |
580 | if (old_mfn != missing_mfn) { | ||
579 | free_p2m_page(mid_mfn); | 581 | free_p2m_page(mid_mfn); |
580 | else | 582 | mid_mfn = mfn_to_virt(old_mfn); |
583 | } else { | ||
581 | p2m_top_mfn_p[topidx] = mid_mfn; | 584 | p2m_top_mfn_p[topidx] = mid_mfn; |
585 | } | ||
582 | } | 586 | } |
583 | 587 | ||
584 | if (p2m_top[topidx][mididx] == p2m_identity || | 588 | if (p2m_top[topidx][mididx] == p2m_identity || |