2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-17 09:43:59 +08:00

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.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.10 (GNU/Linux)
 
 iQEcBAABAgAGBQJTMXIFAAoJEFxbo/MsZsTR+9EH/jRBJIF1hWhBEH9DCbnlMA7x
 yQD30pcI/CjhaOp+5bJhfk/8IUqGX9ODgEt54kauzDuapkERMncUrlLaOz3nay3p
 BrD3yoaSSwgHTATbVFiqHhu2/Qrwb0RgmdaXrwpeF//5wN9/+OvTQhcJdYMv1I6u
 ajDl28LH26tBCswz9a6sFMNqIplU3qKuUhC6n/oBLjF+ZQe8g3AUQtkQX0Jg9MPH
 cyn9s6BxwtDptcMwYoaeIIFXiMC5onwZvO0vn9U4SOk45xHyruu3/F76M/zHE/zO
 Mv+8iotAEEEp8sgntXeldaXfh0xG9ikmf32eIfOq7KR3ecMT8JSa9Q7jPurKaWo=
 =YQuC
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2014-03-28 10:52:05 -07:00
commit 81250437a5
3 changed files with 23 additions and 21 deletions

View File

@ -445,20 +445,10 @@ static inline int pte_same(pte_t a, pte_t b)
return a.pte == b.pte; return a.pte == b.pte;
} }
static inline int pteval_present(pteval_t pteval)
{
/*
* Yes Linus, _PAGE_PROTNONE == _PAGE_NUMA. Expressing it this
* way clearly states that the intent is that protnone and numa
* hinting ptes are considered present for the purposes of
* pagetable operations like zapping, protection changes, gup etc.
*/
return pteval & (_PAGE_PRESENT | _PAGE_PROTNONE | _PAGE_NUMA);
}
static inline int pte_present(pte_t a) static inline int pte_present(pte_t a)
{ {
return pteval_present(pte_flags(a)); return pte_flags(a) & (_PAGE_PRESENT | _PAGE_PROTNONE |
_PAGE_NUMA);
} }
#define pte_accessible pte_accessible #define pte_accessible pte_accessible

View File

@ -365,7 +365,7 @@ void xen_ptep_modify_prot_commit(struct mm_struct *mm, unsigned long addr,
/* Assume pteval_t is equivalent to all the other *val_t types. */ /* Assume pteval_t is equivalent to all the other *val_t types. */
static pteval_t pte_mfn_to_pfn(pteval_t val) static pteval_t pte_mfn_to_pfn(pteval_t val)
{ {
if (pteval_present(val)) { if (val & _PAGE_PRESENT) {
unsigned long mfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT; unsigned long mfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT;
unsigned long pfn = mfn_to_pfn(mfn); unsigned long pfn = mfn_to_pfn(mfn);
@ -381,7 +381,7 @@ static pteval_t pte_mfn_to_pfn(pteval_t val)
static pteval_t pte_pfn_to_mfn(pteval_t val) static pteval_t pte_pfn_to_mfn(pteval_t val)
{ {
if (pteval_present(val)) { if (val & _PAGE_PRESENT) {
unsigned long pfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT; unsigned long pfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT;
pteval_t flags = val & PTE_FLAGS_MASK; pteval_t flags = val & PTE_FLAGS_MASK;
unsigned long mfn; unsigned long mfn;

View File

@ -399,12 +399,26 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp)
state = BP_EAGAIN; state = BP_EAGAIN;
break; break;
} }
pfn = page_to_pfn(page);
frame_list[i] = pfn_to_mfn(pfn);
scrub_page(page); scrub_page(page);
frame_list[i] = page_to_pfn(page);
}
/*
* Ensure that ballooned highmem pages don't have kmaps.
*
* Do this before changing the p2m as kmap_flush_unused()
* reads PTEs to obtain pages (and hence needs the original
* p2m entry).
*/
kmap_flush_unused();
/* Update direct mapping, invalidate P2M, and add to balloon. */
for (i = 0; i < nr_pages; i++) {
pfn = frame_list[i];
frame_list[i] = pfn_to_mfn(pfn);
page = pfn_to_page(pfn);
#ifdef CONFIG_XEN_HAVE_PVMMU #ifdef CONFIG_XEN_HAVE_PVMMU
/* /*
* Ballooned out frames are effectively replaced with * Ballooned out frames are effectively replaced with
@ -429,11 +443,9 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp)
} }
#endif #endif
balloon_append(pfn_to_page(pfn)); balloon_append(page);
} }
/* Ensure that ballooned highmem pages don't have kmaps. */
kmap_flush_unused();
flush_tlb_all(); flush_tlb_all();
set_xen_guest_handle(reservation.extent_start, frame_list); set_xen_guest_handle(reservation.extent_start, frame_list);