forked from QubesOS/qubes-vmm-xen
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpatch-0001-xen-move-domain-lookup-for-getdomaininfo-to-the-same.patch
97 lines (90 loc) · 2.91 KB
/
patch-0001-xen-move-domain-lookup-for-getdomaininfo-to-the-same.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
From ebddda4de8c95412f4d722d341540ae54d998a94 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?=
Date: Thu, 23 Jun 2016 14:14:06 +0200
Subject: [PATCH 1/2] xen: move domain lookup for getdomaininfo to the same
place as others
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Organization: Invisible Things Lab
Cc: Marek Marczykowski-Górecki <[email protected]>
XEN_DOMCTL_getdomaininfo have different semantics than most of others
domctls - it returns information about first valid domain with ID >=
argument. But that's no excuse for having the lookup code in a different
place, which made handling different corner cases unnecessary complex.
Move the lookup to the first switch clause. And adjust locking to be the
same as for other cases.
Signed-off-by: Marek Marczykowski-Górecki <[email protected]>
---
xen/common/domctl.c | 41 ++++++++++++++++++++---------------------
1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/xen/common/domctl.c b/xen/common/domctl.c
index e43904e..6ae1fe0 100644
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -442,11 +442,29 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
switch ( op->cmd )
{
case XEN_DOMCTL_createdomain:
- case XEN_DOMCTL_getdomaininfo:
case XEN_DOMCTL_test_assign_device:
case XEN_DOMCTL_gdbsx_guestmemio:
d = NULL;
break;
+ case XEN_DOMCTL_getdomaininfo:
+ d = rcu_lock_domain_by_id(op->domain);
+ if ( d == NULL )
+ {
+ /* search for the next valid domain */
+ rcu_read_lock(&domlist_read_lock);
+
+ for_each_domain ( d )
+ if ( d->domain_id >= op->domain )
+ {
+ rcu_lock_domain(d);
+ break;
+ }
+
+ rcu_read_unlock(&domlist_read_lock);
+ if ( d == NULL )
+ return -ESRCH;
+ }
+ break;
default:
d = rcu_lock_domain_by_id(op->domain);
if ( d == NULL )
@@ -862,33 +880,14 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
break;
case XEN_DOMCTL_getdomaininfo:
- {
- domid_t dom = op->domain;
-
- rcu_read_lock(&domlist_read_lock);
-
- for_each_domain ( d )
- if ( d->domain_id >= dom )
- break;
-
- ret = -ESRCH;
- if ( d == NULL )
- goto getdomaininfo_out;
-
ret = xsm_getdomaininfo(XSM_HOOK, d);
if ( ret )
- goto getdomaininfo_out;
+ break;
getdomaininfo(d, &op->u.getdomaininfo);
-
op->domain = op->u.getdomaininfo.domain;
copyback = 1;
-
- getdomaininfo_out:
- rcu_read_unlock(&domlist_read_lock);
- d = NULL;
break;
- }
case XEN_DOMCTL_getvcpucontext:
{
--
2.5.5