[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 2/2] x86/mm: tidy XENMEM_{get,set}_pod_target handling
- To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Jan Beulich <jbeulich@xxxxxxxx>
- Date: Wed, 1 Dec 2021 12:21:01 +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=2biUIJpAqJ0eyN1ne/XaQldxN2vM6fcaq9kRJNDcVj8=; b=S/fM81DCcv4tL6hY2UdVbXqxB4sWhiX/kn6fwUCypjJWF93Zix5iL05DECDZUXKTBYjUYqZu+pWZ6LXvvrUbBMc9HBy/3JzNy005EJN6Siv4GBvT/wjoEWNZDYqCRdPfyisO/Rp3tS3/Rk/DzaqbB/DNnqHrKyEeXJiyJRcrBbZY3x/KO0PNJlV6D9b0N1a3+dEu/3VPSDkvLEAi/5mHgXEQ1/mRhdL+3ezUVVEWfbXP1+VN+WzKuOVLB5pN0nnHS/rq7wRdjhc7JHPO8UGYIxTPCRZ7NeY/NJ9yLnh+1g+SugqQTAjHurDM4P7H60nguAadbHrOGCiObqz35pJooA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZgPRG/PTYx512xwVOnUvSJSr1jOQV9oFPtG0qyF3LcDp6+rhSEXmHSRSCxuELW+JBZIKu2NNJLbzKXDB31tklRpFErxJYbKrc5yqBP9smDQ5T8F+zIZskN7QPTDVhej35dYhDzpRVNJKVEbpyJjUnSg1TBe+mfKmqFiMt3TWiH1bMRmNe9UxHhKuaHJ74bkU+RI3qE6Jh/ZChpOr8zrh4hdDYnNUAAZHoPIVnzhljqg4aCGKuHDwR1tKBIDD76NYRRx7zxEhWLwCpPPxiVzrFw7PAxUHiAsQi0h8V42f2ZytpF/fIwjcy/LOzUCpSJe1EaP8WTz6SrWGlrh7q9xMCQ==
- 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: Wed, 01 Dec 2021 11:21:11 +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
@@ -4788,23 +4788,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 )
{
@@ -4816,13 +4810,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;
}
|