xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Hongyan Xia <hongyxia@amazon.com>
To: <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Wei Liu" <wl@xen.org>, "Jan Beulich" <jbeulich@suse.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [Xen-devel] [PATCH v4 7/9] x86/mm: make sure there is one exit path for modify_xen_mappings
Date: Wed, 4 Dec 2019 17:10:59 +0000	[thread overview]
Message-ID: <8d396401c9cf40b8b593d2cf49b07f7bd5d422cf.1575477921.git.hongyxia@amazon.com> (raw)
In-Reply-To: <cover.1575477921.git.hongyxia@amazon.com>

From: Wei Liu <wei.liu2@citrix.com>

We will soon need to handle dynamically mapping / unmapping page
tables in the said function.

No functional change.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Hongyan Xia <hongyxia@amazon.com>

---
Changed since v3:
- remove asserts on rc since it never gets changed to anything else.
---
 xen/arch/x86/mm.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index f530dd391c..4c659c28d8 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -5584,6 +5584,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf)
     l1_pgentry_t *pl1e;
     unsigned int  i;
     unsigned long v = s;
+    int rc = -ENOMEM;
 
     /* Set of valid PTE bits which may be altered. */
 #define FLAGS_MASK (_PAGE_NX|_PAGE_RW|_PAGE_PRESENT)
@@ -5627,7 +5628,8 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf)
             /* PAGE1GB: shatter the superpage and fall through. */
             l2t = alloc_xen_pagetable();
             if ( !l2t )
-                return -ENOMEM;
+                goto out;
+
             for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ )
                 l2e_write(l2t + i,
                           l2e_from_pfn(l3e_get_pfn(*pl3e) +
@@ -5684,7 +5686,8 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf)
                 /* PSE: shatter the superpage and try again. */
                 l1t = alloc_xen_pagetable();
                 if ( !l1t )
-                    return -ENOMEM;
+                    goto out;
+
                 for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ )
                     l1e_write(&l1t[i],
                               l1e_from_pfn(l2e_get_pfn(*pl2e) + i,
@@ -5817,7 +5820,10 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf)
     flush_area(NULL, FLUSH_TLB_GLOBAL);
 
 #undef FLAGS_MASK
-    return 0;
+    rc = 0;
+
+ out:
+    return rc;
 }
 
 #undef flush_area
-- 
2.17.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2019-12-04 17:11 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-04 17:10 [Xen-devel] [PATCH v4 0/9] Add alternative API for Xen PTEs Hongyan Xia
2019-12-04 17:10 ` [Xen-devel] [PATCH v4 1/9] x86: move some xen mm function declarations Hongyan Xia
2019-12-04 17:10 ` [Xen-devel] [PATCH v4 2/9] x86: introduce a new set of APIs to manage Xen page tables Hongyan Xia
2019-12-04 17:54   ` Xia, Hongyan
2019-12-05  7:20     ` Jan Beulich
2019-12-11 16:33   ` Julien Grall
2019-12-04 17:10 ` [Xen-devel] [PATCH v4 3/9] x86/mm: introduce l{1, 2}t local variables to map_pages_to_xen Hongyan Xia
2019-12-04 18:01   ` Xia, Hongyan
2019-12-05  8:38     ` Jan Beulich
2019-12-04 17:10 ` [Xen-devel] [PATCH v4 4/9] x86/mm: introduce l{1, 2}t local variables to modify_xen_mappings Hongyan Xia
2019-12-12 14:34   ` Julien Grall
2019-12-04 17:10 ` [Xen-devel] [PATCH v4 5/9] x86/mm: map_pages_to_xen would better have one exit path Hongyan Xia
2019-12-04 17:10 ` [Xen-devel] [PATCH v4 6/9] x86/mm: add an end_of_loop label in map_pages_to_xen Hongyan Xia
2019-12-05 10:21   ` Xia, Hongyan
2019-12-05 10:25     ` Jan Beulich
2019-12-05 11:02       ` Durrant, Paul
2019-12-05 11:12         ` Jan Beulich
2019-12-05 13:22           ` Xia, Hongyan
2019-12-06 15:58           ` Xia, Hongyan
2019-12-04 17:10 ` Hongyan Xia [this message]
2019-12-04 17:11 ` [Xen-devel] [PATCH v4 8/9] x86/mm: add an end_of_loop label in modify_xen_mappings Hongyan Xia
2019-12-04 17:11 ` [Xen-devel] [PATCH v4 9/9] x86/mm: change pl*e to l*t in virt_to_xen_l*e Hongyan Xia
2019-12-05  9:14 ` [Xen-devel] [PATCH v4 0/9] Add alternative API for Xen PTEs Jan Beulich
2019-12-05  9:41   ` Xia, Hongyan
2019-12-05  9:51     ` Jan Beulich
2019-12-05 10:45       ` Xia, Hongyan

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=8d396401c9cf40b8b593d2cf49b07f7bd5d422cf.1575477921.git.hongyxia@amazon.com \
    --to=hongyxia@amazon.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).