All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"George Dunlap" <george.dunlap@citrix.com>,
	"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>
Subject: [PATCH v2 1/6] x86/mem-paging: fold p2m_mem_paging_prep()'s main if()-s
Date: Thu, 23 Apr 2020 10:37:06 +0200	[thread overview]
Message-ID: <cea2307f-1aae-51cb-20ac-fbaf4b945771@suse.com> (raw)
In-Reply-To: <b8437b1f-af58-70df-91d2-bd875912e57b@suse.com>

The condition of the second can be true only if the condition of the
first was met; the second half of the condition of the second then also
is redundant with an earlier check. Combine them, drop a pointless
local variable, and re-flow the affected gdprintk().

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -1808,6 +1808,8 @@ int p2m_mem_paging_prep(struct domain *d
     /* Allocate a page if the gfn does not have one yet */
     if ( !mfn_valid(mfn) )
     {
+        void *guest_map;
+
         /* If the user did not provide a buffer, we disallow */
         ret = -EINVAL;
         if ( unlikely(user_ptr == NULL) )
@@ -1819,22 +1821,16 @@ int p2m_mem_paging_prep(struct domain *d
             goto out;
         mfn = page_to_mfn(page);
         page_extant = 0;
-    }
-
-    /* If we were given a buffer, now is the time to use it */
-    if ( !page_extant && user_ptr )
-    {
-        void *guest_map;
-        int rc;
 
         ASSERT( mfn_valid(mfn) );
         guest_map = map_domain_page(mfn);
-        rc = copy_from_user(guest_map, user_ptr, PAGE_SIZE);
+        ret = copy_from_user(guest_map, user_ptr, PAGE_SIZE);
         unmap_domain_page(guest_map);
-        if ( rc )
+        if ( ret )
         {
-            gdprintk(XENLOG_ERR, "Failed to load paging-in gfn %lx domain %u "
-                                 "bytes left %d\n", gfn_l, d->domain_id, rc);
+            gdprintk(XENLOG_ERR,
+                     "Failed to load paging-in gfn %lx Dom%d bytes left %d\n",
+                     gfn_l, d->domain_id, ret);
             ret = -EFAULT;
             put_page(page); /* Don't leak pages */
             goto out;            



  reply	other threads:[~2020-04-23  8:37 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-23  8:34 [PATCH v2 0/6] x86/mem-paging: misc cleanup Jan Beulich
2020-04-23  8:37 ` Jan Beulich [this message]
2020-05-14 15:45   ` [PATCH v2 1/6] x86/mem-paging: fold p2m_mem_paging_prep()'s main if()-s Roger Pau Monné
2020-05-14 15:51     ` Jan Beulich
2020-05-15 12:02   ` Andrew Cooper
2020-04-23  8:37 ` [PATCH v2 2/6] x86/mem-paging: correct p2m_mem_paging_prep()'s error handling Jan Beulich
2020-05-14 15:57   ` Roger Pau Monné
2020-05-15 14:40   ` Andrew Cooper
2020-05-15 15:15     ` Jan Beulich
2020-05-15 20:02       ` Andrew Cooper
2020-04-23  8:38 ` [PATCH v2 3/6] x86/mem-paging: use guest handle for XENMEM_paging_op_prep Jan Beulich
2020-05-14 16:13   ` Roger Pau Monné
2020-05-15 14:14   ` Ping: " Jan Beulich
2020-05-15 14:46   ` Andrew Cooper
2020-05-15 16:40   ` Wei Liu
2020-04-23  8:38 ` [PATCH v2 4/6] x86/mem-paging: add minimal lock order enforcement to p2m_mem_paging_prep() Jan Beulich
2020-05-14 16:25   ` Roger Pau Monné
2020-05-15  9:46     ` Jan Beulich
2020-05-15 10:21       ` Roger Pau Monné
2020-04-23  8:39 ` [PATCH v2 5/6] x86/mem-paging: move code to its dedicated source file Jan Beulich
2020-05-14 16:29   ` Roger Pau Monné
2020-05-15 15:45   ` Andrew Cooper
2020-04-23  8:39 ` [PATCH v2 6/6] x86/mem-paging: consistently use gfn_t Jan Beulich
2020-05-14 16:36   ` Roger Pau Monné
2020-05-15 15:49   ` Andrew Cooper
2020-05-15 15:52     ` Andrew Cooper

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=cea2307f-1aae-51cb-20ac-fbaf4b945771@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.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 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.