[PATCH 13/23] xsm/dummy: Allow XS_PRIV XEN_SYSCTL_getdomaininfolist

Jason Andryuk posted 23 patches 3 days ago
[PATCH 13/23] xsm/dummy: Allow XS_PRIV XEN_SYSCTL_getdomaininfolist
Posted by Jason Andryuk 3 days ago
To hyperlaunch xenstore, we want it to automatically introduce all
domains it finds while initializing.  To do that, change xsm_sysctl to
allow XS_PRIV to call XEN_SYSCTL_getdomaininfolist.

Xenstore can already call XEN_DOMCTL_getdomaininfo for the same
information, but it requires knowing the domid.
XEN_SYSCTL_getdomaininfolist eliminates the need to guess domains.

init-dom0less also calls XEN_SYSCTL_getdomaininfolist to determine
running domains to initalize.

Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
---
 xen/common/sysctl.c     |  2 +-
 xen/include/xsm/dummy.h | 10 ++++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
index c2d99ae12e..89d5176f4d 100644
--- a/xen/common/sysctl.c
+++ b/xen/common/sysctl.c
@@ -42,7 +42,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
     if ( op->interface_version != XEN_SYSCTL_INTERFACE_VERSION )
         return -EACCES;
 
-    ret = xsm_sysctl(XSM_PRIV, op->cmd);
+    ret = xsm_sysctl(XSM_OTHER, op->cmd);
     if ( ret )
         return ret;
 
diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h
index 6a2fc33c3b..f2d6662a9d 100644
--- a/xen/include/xsm/dummy.h
+++ b/xen/include/xsm/dummy.h
@@ -181,8 +181,14 @@ static XSM_INLINE int cf_check xsm_domctl(
 
 static XSM_INLINE int cf_check xsm_sysctl(XSM_DEFAULT_ARG int cmd)
 {
-    XSM_ASSERT_ACTION(XSM_PRIV);
-    return xsm_default_action(action, current->domain, NULL);
+    XSM_ASSERT_ACTION(XSM_OTHER);
+    switch ( cmd )
+    {
+    case XEN_SYSCTL_getdomaininfolist:
+        return xsm_default_action(XSM_XS_PRIV, current->domain, NULL);
+    default:
+        return xsm_default_action(XSM_PRIV, current->domain, NULL);
+    }
 }
 
 static XSM_INLINE int cf_check xsm_readconsole(XSM_DEFAULT_ARG uint32_t clear)
-- 
2.48.1