[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] x86/mm/p2m-pt: Clip mfn to allowable width when building a PTE


  • To: xen-devel@xxxxxxxxxxxxx
  • From: Andres Lagar-Cavilla <andres@xxxxxxxxxxxxxxxx>
  • Date: Thu, 22 Mar 2012 14:17:43 -0400
  • Cc: keir@xxxxxxx, andres@xxxxxxxxxxxxxx, tim@xxxxxxx, JBeulich@xxxxxxxx
  • Delivery-date: Thu, 22 Mar 2012 18:15:09 +0000
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=lagarcavilla.org; h=content-type :mime-version:content-transfer-encoding:subject:message-id:date :from:to:cc; q=dns; s=lagarcavilla.org; b=N37t2poiGtbHl/c+B5G9QO 1rWAn2FlhefSkX7Jbn2kE/HXB8kDPSKIx7lvF0txrS+5SKqmUrPXACE8IhMaXTxZ Y7HCqSde6GWtaOsjC0eb8xlbI6rgYpSQE+OxvGf8WEvs1K5RBHdzRdWSK2nj0lYz f9yIy8cbK0Byx0mzWDDQw=
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>

 xen/arch/x86/mm/p2m-pt.c |  13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)


Otherwise, INVALID_MFN tramples over high order bits used for additional flags.

Signed-off-by: Andres Lagar-Cavilla <andres@xxxxxxxxxxxxxxxx>

diff -r 642c0e6a01c2 -r d07ac807db6d xen/arch/x86/mm/p2m-pt.c
--- a/xen/arch/x86/mm/p2m-pt.c
+++ b/xen/arch/x86/mm/p2m-pt.c
@@ -48,6 +48,13 @@
 #undef page_to_mfn
 #define page_to_mfn(_pg) _mfn(__page_to_mfn(_pg))
 
+/* We may store INVALID_MFN in l1 PTEs. We need to clip this
+ * to avoid trampling over higher-order bits (NX, p2m type, IOMMU flags).  We
+ * seem to not need to unclip on the return path, as callers are concerned only
+ * with p2m type in such cases. 
+ */
+#define p2m_l1e_from_pfn(pfn, flags)    \
+    l1e_from_pfn((pfn) & (PADDR_MASK >> PAGE_SHIFT), (flags))
 
 /* PTE flags for the various types of p2m entry */
 #define P2M_BASE_FLAGS \
@@ -385,8 +392,8 @@ p2m_set_entry(struct p2m_domain *p2m, un
         ASSERT(p2m_entry);
         
         if ( mfn_valid(mfn) || (p2mt == p2m_mmio_direct) )
-            entry_content = l1e_from_pfn(mfn_x(mfn),
-                                         p2m_type_to_flags(p2mt, mfn));
+            entry_content = p2m_l1e_from_pfn(mfn_x(mfn),
+                                             p2m_type_to_flags(p2mt, mfn));
         else
             entry_content = l1e_empty();
 
@@ -923,7 +930,7 @@ static void p2m_change_type_global(struc
                            * L2_PAGETABLE_ENTRIES) * L1_PAGETABLE_ENTRIES; 
                     /* create a new 1le entry with the new type */
                     flags = p2m_type_to_flags(nt, _mfn(mfn));
-                    l1e_content = l1e_from_pfn(mfn, flags);
+                    l1e_content = p2m_l1e_from_pfn(mfn, flags);
                     p2m->write_p2m_entry(p2m, gfn, &l1e[i1],
                                          l1mfn, l1e_content, 1);
                 }

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.