Skip to content

Commit 8125043

Browse files
committed
Merge tag 'stable/for-linus-3.14-rc8-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull Xen bugfixes from David Vrabel: "Fix two bugs that cause x86 PV guest crashes. 1. Ballooning a 32-bit guest would eventually crash it. 2. Revert a broken fix for a regression with NUMA_BALACING. The bad fix caused PV guests to crash after migration. This is not ideal but unpicking the madness that is _PAGE_NUMA == _PAGE_PROTNONE will take a while longer" * tag 'stable/for-linus-3.14-rc8-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: Revert "xen: properly account for _PAGE_NUMA during xen pte translations" xen/balloon: flush persistent kmaps in correct position
2 parents 75c5a52 + 5926f87 commit 8125043

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

arch/x86/include/asm/pgtable.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -445,20 +445,10 @@ static inline int pte_same(pte_t a, pte_t b)
445445
return a.pte == b.pte;
446446
}
447447

448-
static inline int pteval_present(pteval_t pteval)
449-
{
450-
/*
451-
* Yes Linus, _PAGE_PROTNONE == _PAGE_NUMA. Expressing it this
452-
* way clearly states that the intent is that protnone and numa
453-
* hinting ptes are considered present for the purposes of
454-
* pagetable operations like zapping, protection changes, gup etc.
455-
*/
456-
return pteval & (_PAGE_PRESENT | _PAGE_PROTNONE | _PAGE_NUMA);
457-
}
458-
459448
static inline int pte_present(pte_t a)
460449
{
461-
return pteval_present(pte_flags(a));
450+
return pte_flags(a) & (_PAGE_PRESENT | _PAGE_PROTNONE |
451+
_PAGE_NUMA);
462452
}
463453

464454
#define pte_accessible pte_accessible

arch/x86/xen/mmu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ void xen_ptep_modify_prot_commit(struct mm_struct *mm, unsigned long addr,
365365
/* Assume pteval_t is equivalent to all the other *val_t types. */
366366
static pteval_t pte_mfn_to_pfn(pteval_t val)
367367
{
368-
if (pteval_present(val)) {
368+
if (val & _PAGE_PRESENT) {
369369
unsigned long mfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT;
370370
unsigned long pfn = mfn_to_pfn(mfn);
371371

@@ -381,7 +381,7 @@ static pteval_t pte_mfn_to_pfn(pteval_t val)
381381

382382
static pteval_t pte_pfn_to_mfn(pteval_t val)
383383
{
384-
if (pteval_present(val)) {
384+
if (val & _PAGE_PRESENT) {
385385
unsigned long pfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT;
386386
pteval_t flags = val & PTE_FLAGS_MASK;
387387
unsigned long mfn;

drivers/xen/balloon.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -399,11 +399,25 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp)
399399
state = BP_EAGAIN;
400400
break;
401401
}
402+
scrub_page(page);
402403

403-
pfn = page_to_pfn(page);
404-
frame_list[i] = pfn_to_mfn(pfn);
404+
frame_list[i] = page_to_pfn(page);
405+
}
405406

406-
scrub_page(page);
407+
/*
408+
* Ensure that ballooned highmem pages don't have kmaps.
409+
*
410+
* Do this before changing the p2m as kmap_flush_unused()
411+
* reads PTEs to obtain pages (and hence needs the original
412+
* p2m entry).
413+
*/
414+
kmap_flush_unused();
415+
416+
/* Update direct mapping, invalidate P2M, and add to balloon. */
417+
for (i = 0; i < nr_pages; i++) {
418+
pfn = frame_list[i];
419+
frame_list[i] = pfn_to_mfn(pfn);
420+
page = pfn_to_page(pfn);
407421

408422
#ifdef CONFIG_XEN_HAVE_PVMMU
409423
/*
@@ -429,11 +443,9 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp)
429443
}
430444
#endif
431445

432-
balloon_append(pfn_to_page(pfn));
446+
balloon_append(page);
433447
}
434448

435-
/* Ensure that ballooned highmem pages don't have kmaps. */
436-
kmap_flush_unused();
437449
flush_tlb_all();
438450

439451
set_xen_guest_handle(reservation.extent_start, frame_list);

0 commit comments

Comments
 (0)