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

[PATCH v3 2/2] x86/mm: tidy XENMEM_{get,set}_pod_target handling


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 4 Jan 2022 10:41:53 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aeDXmUgr7Jm5ejsZq/eCve7xIAm3hniBKsi3UcJSYpA=; b=aX57rMtB6Q7tD9IZ+y1OcLzjroveQlY6gdAzcWgl05HAK72CM742ZzKGWGUeflfnXSFEDC0N3DoIlLxaSvLxLirYAnVSt0qJrHHUoVXgNsKAq2aafmgy3oomwtwgQAqRpcue/jFQ4Is5/edj/pfBS1JbuyqX8FGxEqHSroE28Poep3WSGoBDshtPaNmu2W34QARsK0B3JV/4TnTarh0ckAxk+lFC1L2KoKnbq1VkVixRbXGWpaA5P/SfgoWs+VdR5WhkD6NAn7CN4EnSOHGbS2XFh8TvS30gLmqN4nCOWLiDtPI+JQtLeM3gK7fCRnmnrVRwyuvc8noQNcWtHxlQ8Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DSpDjzDLCjEf94FDKhPgW7btVfwOp9yYGf3yvNu/GvjtSC4C/9CF4ZKMexPUnWBqwsrrBmjG+rWY1qgp/K62i4bmIL5BeKyzGe10WWUxLZwrmDvFN01wYB+In3dhUISoBaTJclssXGRHlqNzjJz7Px18LukWLQhv50Uld/V7Q/lAlQZFBKogVxt8N9AafZdBHvE2eE97ilySOmZx0gQgSxT4iLEfNDjPkrscl/kMao4pilGpISejL0YHrJAfh3nFCq2B5z6pmAg1tDGfEI8wWS3cPvGaaqwy6X9mwz36gKEJTdw/3xHoyZKqOuzkve894CGBdxURJbmSABqDzOXGYA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>
  • Delivery-date: Tue, 04 Jan 2022 09:41:49 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Do away with the "pod_target_out_unlock" label. In particular by folding
if()-s, the logic can be expressed with less code (and no goto-s) this
way.

Limit scope of "p2m", constifying it at the same time.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v2: Re-base over new earlier patch.

--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -4789,23 +4789,17 @@ long arch_memory_op(unsigned long cmd, X
         if ( !is_hvm_domain(d) )
             rc = -EINVAL;
         else if ( cmd == XENMEM_set_pod_target )
-            rc = xsm_set_pod_target(XSM_PRIV, d);
-        else
-            rc = xsm_get_pod_target(XSM_PRIV, d);
-
-        if ( rc != 0 )
-            goto pod_target_out_unlock;
-
-        if ( cmd == XENMEM_set_pod_target )
         {
-            if ( target.target_pages > d->max_pages )
-            {
+            rc = xsm_set_pod_target(XSM_PRIV, d);
+            if ( rc )
+                ASSERT(rc < 0);
+            else if ( target.target_pages > d->max_pages )
                 rc = -EINVAL;
-                goto pod_target_out_unlock;
-            }
-
-            rc = p2m_pod_set_mem_target(d, target.target_pages);
+            else
+                rc = p2m_pod_set_mem_target(d, target.target_pages);
         }
+        else
+            rc = xsm_get_pod_target(XSM_PRIV, d);
 
         if ( rc == -ERESTART )
         {
@@ -4817,13 +4811,9 @@ long arch_memory_op(unsigned long cmd, X
             p2m_pod_get_mem_target(d, &target);
 
             if ( __copy_to_guest(arg, &target, 1) )
-            {
-                rc= -EFAULT;
-                goto pod_target_out_unlock;
-            }
+                rc = -EFAULT;
         }
 
-    pod_target_out_unlock:
         rcu_unlock_domain(d);
         return rc;
     }




 


Rackspace

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