All of lore.kernel.org
 help / color / mirror / Atom feed
* P2M superpages fixes
@ 2008-07-08 21:29 Gianluca Guida
  0 siblings, 0 replies; only message in thread
From: Gianluca Guida @ 2008-07-08 21:29 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 479 bytes --]

Hello,

This patch addresses three issues in the p2m superpages:

- return -EINVAL if the guest is trying to request a page_order not 
supported by current implementation (0 or 9).

- check for error (as it used to be) on guest_pyshmap_add_page in 
populate_physmap()

- Re-insert missing shadow code from the original patch that was 
submitted to xen-devel, to remove mappings when we're removing a p2m 2mb 
page.


Signed-off-by: Gianluca Guida <gianluca.guida@eu.citrix.com>


[-- Attachment #2: p2m_fix.patch --]
[-- Type: text/x-patch, Size: 2215 bytes --]

diff -r 5cd4fe68b6c2 xen/arch/x86/mm/p2m.c
--- a/xen/arch/x86/mm/p2m.c	Tue Jul 08 17:25:04 2008 +0100
+++ b/xen/arch/x86/mm/p2m.c	Tue Jul 08 22:22:10 2008 +0100
@@ -939,6 +939,14 @@ guest_physmap_add_entry(struct domain *d
 
     P2M_DEBUG("adding gfn=%#lx mfn=%#lx\n", gfn, mfn);
 
+    if ( page_order && (page_order != 9) )
+    {
+        /* Current implementation supports only 4kb and 2Mb pages. */
+        gdprintk(XENLOG_ERR, "request of P2M %d page order not supported.\n",
+                 page_order);
+        return -EINVAL;
+    }
+
     omfn = gfn_to_mfn(d, gfn, &ot);
     if ( p2m_is_ram(ot) )
     {
diff -r 5cd4fe68b6c2 xen/arch/x86/mm/shadow/common.c
--- a/xen/arch/x86/mm/shadow/common.c	Tue Jul 08 17:25:04 2008 +0100
+++ b/xen/arch/x86/mm/shadow/common.c	Tue Jul 08 22:22:10 2008 +0100
@@ -3354,6 +3354,26 @@ shadow_write_p2m_entry(struct vcpu *v, u
         }
     }
 
+    /* If we're removing a superpage mapping from the p2m, remove all the
+     * MFNs covered by it from the shadows too. */
+    if ( level == 2 && (l1e_get_flags(*p) & _PAGE_PRESENT) &&
+         (l1e_get_flags(*p) & _PAGE_PSE) )
+    {
+        unsigned int i;
+        mfn_t mfn = _mfn(l1e_get_pfn(*p));
+        p2m_type_t p2mt = p2m_flags_to_type(l1e_get_flags(*p));
+        if ( p2m_is_valid(p2mt) && mfn_valid(mfn) )
+        {
+            for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ )
+            {
+                sh_remove_all_shadows_and_parents(v, mfn);
+                if ( sh_remove_all_mappings(v, mfn) )
+                    flush_tlb_mask(d->domain_dirty_cpumask);
+                mfn = _mfn(mfn_x(mfn) + 1);
+            }
+        }
+    }
+
     /* Update the entry with new content */
     safe_write_pte(p, new);
 
diff -r 5cd4fe68b6c2 xen/common/memory.c
--- a/xen/common/memory.c	Tue Jul 08 17:25:04 2008 +0100
+++ b/xen/common/memory.c	Tue Jul 08 22:22:10 2008 +0100
@@ -122,7 +122,8 @@ static void populate_physmap(struct memo
         }
 
         mfn = page_to_mfn(page);
-        guest_physmap_add_page(d, gpfn, mfn, a->extent_order);
+        if ( guest_physmap_add_page(d, gpfn, mfn, a->extent_order) )
+            goto out;
 
         if ( !paging_mode_translate(d) )
         {

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-07-08 21:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-08 21:29 P2M superpages fixes Gianluca Guida

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.