All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gianluca Guida <gianluca.guida@eu.citrix.com>
To: xen-devel@lists.xensource.com
Subject: P2M superpages fixes
Date: Tue, 08 Jul 2008 22:29:34 +0100	[thread overview]
Message-ID: <4873DC3E.3070602@eu.citrix.com> (raw)

[-- 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

                 reply	other threads:[~2008-07-08 21:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4873DC3E.3070602@eu.citrix.com \
    --to=gianluca.guida@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.