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

[Xen-devel] [PATCH 21/23] xen: sysctl XSM hook removal



A number of the sysctl XSM hooks have no parameters or only pass the
operation ID, making them redundant with the xsm_sysctl hook. Remove
these redundant hooks.

Signed-off-by: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
Cc: Keir Fraser <keir@xxxxxxx>
Cc: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/sysctl.c   |  13 -----
 xen/common/sysctl.c     |  44 -----------------
 xen/include/xsm/dummy.h |  45 -----------------
 xen/include/xsm/xsm.h   |  56 +---------------------
 xen/xsm/dummy.c         |   9 ----
 xen/xsm/flask/hooks.c   | 125 +++++++++++++++---------------------------------
 6 files changed, 39 insertions(+), 253 deletions(-)

diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c
index b84dd34..5b0c4b7 100644
--- a/xen/arch/x86/sysctl.c
+++ b/xen/arch/x86/sysctl.c
@@ -69,11 +69,6 @@ long arch_do_sysctl(
     {
         xen_sysctl_physinfo_t *pi = &sysctl->u.physinfo;
 
-        ret = xsm_physinfo();
-        if ( ret )
-            break;
-
-
         memset(pi, 0, sizeof(*pi));
         pi->threads_per_core =
             cpumask_weight(per_cpu(cpu_sibling_mask, 0));
@@ -103,10 +98,6 @@ long arch_do_sysctl(
         uint32_t i, max_cpu_index, last_online_cpu;
         xen_sysctl_topologyinfo_t *ti = &sysctl->u.topologyinfo;
 
-        ret = xsm_physinfo();
-        if ( ret )
-            break;
-
         last_online_cpu = cpumask_last(&cpu_online_map);
         max_cpu_index = min_t(uint32_t, ti->max_cpu_index, last_online_cpu);
         ti->max_cpu_index = last_online_cpu;
@@ -143,10 +134,6 @@ long arch_do_sysctl(
         uint32_t i, j, max_node_index, last_online_node;
         xen_sysctl_numainfo_t *ni = &sysctl->u.numainfo;
 
-        ret = xsm_physinfo();
-        if ( ret )
-            break;
-
         last_online_node = last_node(node_online_map);
         max_node_index = min_t(uint32_t, ni->max_node_index, last_online_node);
         ni->max_node_index = last_online_node;
diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
index 599430e..cbefb0e 100644
--- a/xen/common/sysctl.c
+++ b/xen/common/sysctl.c
@@ -69,10 +69,6 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
 
     case XEN_SYSCTL_tbuf_op:
     {
-        ret = xsm_tbufcontrol();
-        if ( ret )
-            break;
-
         ret = tb_control(&op->u.tbuf_op);
         if ( copy_to_guest(u_sysctl, op, 1) )
             ret = -EFAULT;
@@ -81,10 +77,6 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
     
     case XEN_SYSCTL_sched_id:
     {
-        ret = xsm_sched_id();
-        if ( ret )
-            break;
-
         op->u.sched_id.sched_id = sched_id();
         if ( copy_to_guest(u_sysctl, op, 1) )
             ret = -EFAULT;
@@ -139,10 +131,6 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) 
u_sysctl)
 #ifdef PERF_COUNTERS
     case XEN_SYSCTL_perfc_op:
     {
-        ret = xsm_perfcontrol();
-        if ( ret )
-            break;
-
         ret = perfc_control(&op->u.perfc_op);
         if ( copy_to_guest(u_sysctl, op, 1) )
             ret = -EFAULT;
@@ -153,10 +141,6 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) 
u_sysctl)
 #ifdef LOCK_PROFILE
     case XEN_SYSCTL_lockprof_op:
     {
-        ret = xsm_lockprof();
-        if ( ret )
-            break;
-
         ret = spinlock_profile_control(&op->u.lockprof_op);
         if ( copy_to_guest(u_sysctl, op, 1) )
             ret = -EFAULT;
@@ -168,10 +152,6 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) 
u_sysctl)
         char c;
         uint32_t i;
 
-        ret = xsm_debug_keys();
-        if ( ret )
-            break;
-
         ret = -EFAULT;
         for ( i = 0; i < op->u.debug_keys.nr_keys; i++ )
         {
@@ -190,10 +170,6 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) 
u_sysctl)
 
         nr_cpus = min(op->u.getcpuinfo.max_cpus, nr_cpu_ids);
 
-        ret = xsm_getcpuinfo();
-        if ( ret )
-            break;
-
         for ( i = 0; i < nr_cpus; i++ )
         {
             cpuinfo.idletime = get_cpu_idle_time(i);
@@ -210,10 +186,6 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) 
u_sysctl)
 
     case XEN_SYSCTL_availheap:
     { 
-        ret = xsm_availheap();
-        if ( ret )
-            break;
-
         op->u.availheap.avail_bytes = avail_domheap_pages_region(
             op->u.availheap.node,
             op->u.availheap.min_bitwidth,
@@ -227,10 +199,6 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) 
u_sysctl)
 #ifdef HAS_ACPI
     case XEN_SYSCTL_get_pmstat:
     {
-        ret = xsm_get_pmstat();
-        if ( ret )
-            break;
-
         ret = do_get_pm_info(&op->u.get_pmstat);
         if ( ret )
             break;
@@ -245,10 +213,6 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) 
u_sysctl)
 
     case XEN_SYSCTL_pm_op:
     {
-        ret = xsm_pm_op();
-        if ( ret )
-            break;
-
         ret = do_pm_op(&op->u.pm_op);
         if ( ret && (ret != -EAGAIN) )
             break;
@@ -323,10 +287,6 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) 
u_sysctl)
 
     case XEN_SYSCTL_cpupool_op:
     {
-        ret = xsm_cpupool_op();
-        if ( ret )
-            break;
-
         ret = cpupool_do_sysctl(&op->u.cpupool_op);
         if ( (ret == 0) && copy_to_guest(u_sysctl, op, 1) )
             ret = -EFAULT;
@@ -335,10 +295,6 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) 
u_sysctl)
 
     case XEN_SYSCTL_scheduler_op:
     {
-        ret = xsm_sched_op();
-        if ( ret )
-            break;
-
         ret = sched_adjust_global(&op->u.scheduler_op);
         if ( (ret == 0) && copy_to_guest(u_sysctl, op, 1) )
             ret = -EFAULT;
diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h
index 9a5b34f..b680d61 100644
--- a/xen/include/xsm/dummy.h
+++ b/xen/include/xsm/dummy.h
@@ -58,41 +58,16 @@ static XSM_INLINE int xsm_sysctl(int cmd)
     return 0;
 }
 
-static XSM_INLINE int xsm_tbufcontrol(void)
-{
-    return 0;
-}
-
 static XSM_INLINE int xsm_readconsole(uint32_t clear)
 {
     return 0;
 }
 
-static XSM_INLINE int xsm_sched_id(void)
-{
-    return 0;
-}
-
-static XSM_INLINE int xsm_perfcontrol(void)
-{
-    return 0;
-}
-
-static XSM_INLINE int xsm_debug_keys(void)
-{
-    return 0;
-}
-
 static XSM_INLINE int xsm_getcpuinfo(void)
 {
     return 0;
 }
 
-static XSM_INLINE int xsm_get_pmstat(void)
-{
-    return 0;
-}
-
 static XSM_INLINE int xsm_setpminfo(void)
 {
     return 0;
@@ -110,11 +85,6 @@ static XSM_INLINE int xsm_do_mca(void)
     return 0;
 }
 
-static XSM_INLINE int xsm_availheap(void)
-{
-    return 0;
-}
-
 static XSM_INLINE int xsm_alloc_security_domain(struct domain *d)
 {
     return 0;
@@ -358,16 +328,6 @@ static XSM_INLINE int xsm_lockprof(void)
     return 0;
 }
 
-static XSM_INLINE int xsm_cpupool_op(void)
-{
-    return 0;
-}
-
-static XSM_INLINE int xsm_sched_op(void)
-{
-    return 0;
-}
-
 static XSM_INLINE int xsm_tmem_op(void)
 {
     return 0;
@@ -508,11 +468,6 @@ static XSM_INLINE int xsm_microcode(void)
     return 0;
 }
 
-static XSM_INLINE int xsm_physinfo(void)
-{
-    return 0;
-}
-
 static XSM_INLINE int xsm_platform_quirk(uint32_t quirk)
 {
     return 0;
diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h
index 903c7cb..f054dae 100644
--- a/xen/include/xsm/xsm.h
+++ b/xen/include/xsm/xsm.h
@@ -46,14 +46,8 @@ struct xsm_operations {
     int (*set_target) (struct domain *d, struct domain *e);
     int (*domctl) (struct domain *d, int cmd);
     int (*sysctl) (int cmd);
-    int (*tbufcontrol) (void);
     int (*readconsole) (uint32_t clear);
-    int (*sched_id) (void);
-    int (*perfcontrol) (void);
-    int (*debug_keys) (void);
     int (*getcpuinfo) (void);
-    int (*availheap) (void);
-    int (*get_pmstat) (void);
     int (*setpminfo) (void);
     int (*pm_op) (void);
     int (*do_mca) (void);
@@ -117,8 +111,6 @@ struct xsm_operations {
 
     int (*page_offline)(uint32_t cmd);
     int (*lockprof)(void);
-    int (*cpupool_op)(void);
-    int (*sched_op)(void);
     int (*tmem_op)(void);
     int (*tmem_control)(void);
 
@@ -138,7 +130,6 @@ struct xsm_operations {
     int (*xen_settime) (void);
     int (*memtype) (uint32_t access);
     int (*microcode) (void);
-    int (*physinfo) (void);
     int (*platform_quirk) (uint32_t);
     int (*platform_op) (uint32_t cmd);
     int (*firmware_info) (void);
@@ -201,46 +192,16 @@ static inline int xsm_sysctl (int cmd)
     return xsm_ops->sysctl(cmd);
 }
 
-static inline int xsm_tbufcontrol (void)
-{
-    return xsm_ops->tbufcontrol();
-}
-
 static inline int xsm_readconsole (uint32_t clear)
 {
     return xsm_ops->readconsole(clear);
 }
 
-static inline int xsm_sched_id (void)
-{
-    return xsm_ops->sched_id();
-}
-
-static inline int xsm_perfcontrol (void)
-{
-    return xsm_ops->perfcontrol();
-}
-
-static inline int xsm_debug_keys (void)
-{
-    return xsm_ops->debug_keys();
-}
-
-static inline int xsm_availheap (void)
-{
-    return xsm_ops->availheap();
-}
-
-static inline int xsm_getcpuinfo (void)
+static inline int xsm_getcpuinfo(void)
 {
     return xsm_ops->getcpuinfo();
 }
 
-static inline int xsm_get_pmstat(void)
-{
-    return xsm_ops->get_pmstat();
-}
-
 static inline int xsm_setpminfo(void)
 {
     return xsm_ops->setpminfo();
@@ -502,16 +463,6 @@ static inline int xsm_lockprof(void)
     return xsm_ops->lockprof();
 }
 
-static inline int xsm_cpupool_op(void)
-{
-    return xsm_ops->cpupool_op();
-}
-
-static inline int xsm_sched_op(void)
-{
-    return xsm_ops->sched_op();
-}
-
 static inline int xsm_tmem_op(void)
 {
     return xsm_ops->tmem_op();
@@ -593,11 +544,6 @@ static inline int xsm_microcode (void)
     return xsm_ops->microcode();
 }
 
-static inline int xsm_physinfo (void)
-{
-    return xsm_ops->physinfo();
-}
-
 static inline int xsm_platform_quirk (uint32_t quirk)
 {
     return xsm_ops->platform_quirk(quirk);
diff --git a/xen/xsm/dummy.c b/xen/xsm/dummy.c
index 9bb86ef..0216b62 100644
--- a/xen/xsm/dummy.c
+++ b/xen/xsm/dummy.c
@@ -35,14 +35,8 @@ void xsm_fixup_ops (struct xsm_operations *ops)
     set_to_dummy_if_null(ops, set_target);
     set_to_dummy_if_null(ops, domctl);
     set_to_dummy_if_null(ops, sysctl);
-    set_to_dummy_if_null(ops, tbufcontrol);
     set_to_dummy_if_null(ops, readconsole);
-    set_to_dummy_if_null(ops, sched_id);
-    set_to_dummy_if_null(ops, perfcontrol);
-    set_to_dummy_if_null(ops, debug_keys);
     set_to_dummy_if_null(ops, getcpuinfo);
-    set_to_dummy_if_null(ops, availheap);
-    set_to_dummy_if_null(ops, get_pmstat);
     set_to_dummy_if_null(ops, setpminfo);
     set_to_dummy_if_null(ops, pm_op);
     set_to_dummy_if_null(ops, do_mca);
@@ -104,8 +98,6 @@ void xsm_fixup_ops (struct xsm_operations *ops)
 
     set_to_dummy_if_null(ops, page_offline);
     set_to_dummy_if_null(ops, lockprof);
-    set_to_dummy_if_null(ops, cpupool_op);
-    set_to_dummy_if_null(ops, sched_op);
     set_to_dummy_if_null(ops, tmem_op);
     set_to_dummy_if_null(ops, tmem_control);
 
@@ -125,7 +117,6 @@ void xsm_fixup_ops (struct xsm_operations *ops)
     set_to_dummy_if_null(ops, xen_settime);
     set_to_dummy_if_null(ops, memtype);
     set_to_dummy_if_null(ops, microcode);
-    set_to_dummy_if_null(ops, physinfo);
     set_to_dummy_if_null(ops, platform_quirk);
     set_to_dummy_if_null(ops, platform_op);
     set_to_dummy_if_null(ops, firmware_info);
diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c
index f0216e0..d72a807 100644
--- a/xen/xsm/flask/hooks.c
+++ b/xen/xsm/flask/hooks.c
@@ -702,37 +702,57 @@ static int flask_sysctl(int cmd)
     {
     /* These have individual XSM hooks */
     case XEN_SYSCTL_readconsole:
+    case XEN_SYSCTL_getdomaininfolist:
+    case XEN_SYSCTL_page_offline_op:
+#ifdef CONFIG_X86
+    case XEN_SYSCTL_cpu_hotplug:
+#endif
+        return 0;
+
     case XEN_SYSCTL_tbuf_op:
+        return domain_has_xen(current->domain, XEN__TBUFCONTROL);
+
     case XEN_SYSCTL_sched_id:
+        return domain_has_xen(current->domain, XEN__SCHEDULER);
+
     case XEN_SYSCTL_perfc_op:
-    case XEN_SYSCTL_getdomaininfolist:
+        return domain_has_xen(current->domain, XEN__PERFCONTROL);
+
     case XEN_SYSCTL_debug_keys:
+        return domain_has_xen(current->domain, XEN__DEBUG);
+
     case XEN_SYSCTL_getcpuinfo:
+        return domain_has_xen(current->domain, XEN__GETCPUINFO);
+
     case XEN_SYSCTL_availheap:
+        return domain_has_xen(current->domain, XEN__HEAP);
+
     case XEN_SYSCTL_get_pmstat:
+        return domain_has_xen(current->domain, XEN__PM_OP);
+
     case XEN_SYSCTL_pm_op:
-    case XEN_SYSCTL_page_offline_op:
+        return domain_has_xen(current->domain, XEN__PM_OP);
+
     case XEN_SYSCTL_lockprof_op:
+        return domain_has_xen(current->domain, XEN__LOCKPROF);
+
     case XEN_SYSCTL_cpupool_op:
+        return domain_has_xen(current->domain, XEN__CPUPOOL_OP);
+
     case XEN_SYSCTL_scheduler_op:
-#ifdef CONFIG_X86
+        return domain_has_xen(current->domain, XEN__SCHED_OP);
+
     case XEN_SYSCTL_physinfo:
-    case XEN_SYSCTL_cpu_hotplug:
     case XEN_SYSCTL_topologyinfo:
     case XEN_SYSCTL_numainfo:
-#endif
-        return 0;
+        return domain_has_xen(current->domain, XEN__PHYSINFO);
+
     default:
         printk("flask_sysctl: Unknown op %d\n", cmd);
         return -EPERM;
     }
 }
 
-static int flask_tbufcontrol(void)
-{
-    return domain_has_xen(current->domain, XEN__TBUFCONTROL);
-}
-
 static int flask_readconsole(uint32_t clear)
 {
     u32 perms = XEN__READCONSOLE;
@@ -743,41 +763,6 @@ static int flask_readconsole(uint32_t clear)
     return domain_has_xen(current->domain, perms);
 }
 
-static int flask_sched_id(void)
-{
-    return domain_has_xen(current->domain, XEN__SCHEDULER);
-}
-
-static int flask_debug_keys(void)
-{
-    return domain_has_xen(current->domain, XEN__DEBUG);
-}
-
-static int flask_getcpuinfo(void)
-{
-    return domain_has_xen(current->domain, XEN__GETCPUINFO);
-}
-
-static int flask_availheap(void)
-{
-    return domain_has_xen(current->domain, XEN__HEAP);
-}
-
-static int flask_get_pmstat(void)
-{
-    return domain_has_xen(current->domain, XEN__PM_OP);
-}
-
-static int flask_setpminfo(void)
-{
-    return domain_has_xen(current->domain, XEN__PM_OP);
-}
-
-static int flask_pm_op(void)
-{
-    return domain_has_xen(current->domain, XEN__PM_OP);
-}
-
 static int flask_do_mca(void)
 {
     return domain_has_xen(current->domain, XEN__MCA_OP);
@@ -1031,21 +1016,6 @@ static inline int flask_page_offline(uint32_t cmd)
     }
 }
 
-static inline int flask_lockprof(void)
-{
-    return domain_has_xen(current->domain, XEN__LOCKPROF);
-}
-
-static inline int flask_cpupool_op(void)
-{
-    return domain_has_xen(current->domain, XEN__CPUPOOL_OP);
-}
-
-static inline int flask_sched_op(void)
-{
-    return domain_has_xen(current->domain, XEN__SCHED_OP);
-}
-
 static inline int flask_tmem_op(void)
 {
     return domain_has_xen(current->domain, XEN__TMEM_OP);
@@ -1056,11 +1026,6 @@ static inline int flask_tmem_control(void)
     return domain_has_xen(current->domain, XEN__TMEM_CONTROL);
 }
 
-static int flask_perfcontrol(void)
-{
-    return domain_has_xen(current->domain, XEN__PERFCONTROL);
-}
-
 #ifdef CONFIG_X86
 static int flask_shadow_control(struct domain *d, uint32_t op)
 {
@@ -1253,11 +1218,6 @@ static int flask_microcode(void)
     return domain_has_xen(current->domain, XEN__MICROCODE);
 }
 
-static int flask_physinfo(void)
-{
-    return domain_has_xen(current->domain, XEN__PHYSINFO);
-}
-
 static int flask_platform_quirk(uint32_t quirk)
 {
     return avc_current_has_perm(SECINITSID_XEN, SECCLASS_XEN, XEN__QUIRK, 
NULL);
@@ -1278,17 +1238,21 @@ static int flask_platform_op(uint32_t op)
     case XENPF_enter_acpi_sleep:
     case XENPF_change_freq:
     case XENPF_getidletime:
-    case XENPF_set_processor_pminfo:
-    case XENPF_get_cpuinfo:
-    case XENPF_get_cpu_version:
     case XENPF_cpu_online:
     case XENPF_cpu_offline:
     case XENPF_cpu_hotadd:
     case XENPF_mem_hotadd:
         /* These operations have their own XSM hooks */
         return 0;
+
+    case XENPF_set_processor_pminfo:
     case XENPF_core_parking:
         return domain_has_xen(current->domain, XEN__PM_OP);
+
+    case XENPF_get_cpu_version:
+    case XENPF_get_cpuinfo:
+        return domain_has_xen(current->domain, XEN__GETCPUINFO);
+
     default:
         printk("flask_platform_op: Unknown op %d\n", op);
         return -EPERM;
@@ -1484,16 +1448,7 @@ static struct xsm_operations flask_ops = {
     .set_target = flask_set_target,
     .domctl = flask_domctl,
     .sysctl = flask_sysctl,
-    .tbufcontrol = flask_tbufcontrol,
     .readconsole = flask_readconsole,
-    .sched_id = flask_sched_id,
-    .perfcontrol = flask_perfcontrol,
-    .debug_keys = flask_debug_keys,
-    .getcpuinfo = flask_getcpuinfo,
-    .availheap = flask_availheap,
-    .get_pmstat = flask_get_pmstat,
-    .setpminfo = flask_setpminfo,
-    .pm_op = flask_pm_op,
     .do_mca = flask_do_mca,
 
     .evtchn_unbound = flask_evtchn_unbound,
@@ -1548,9 +1503,6 @@ static struct xsm_operations flask_ops = {
     .resource_setup_misc = flask_resource_setup_misc,
 
     .page_offline = flask_page_offline,
-    .lockprof = flask_lockprof,
-    .cpupool_op = flask_cpupool_op,
-    .sched_op = flask_sched_op,
     .tmem_op = flask_tmem_op,
     .tmem_control = flask_tmem_control,
 
@@ -1570,7 +1522,6 @@ static struct xsm_operations flask_ops = {
     .xen_settime = flask_xen_settime,
     .memtype = flask_memtype,
     .microcode = flask_microcode,
-    .physinfo = flask_physinfo,
     .platform_quirk = flask_platform_quirk,
     .platform_op = flask_platform_op,
     .firmware_info = flask_firmware_info,
-- 
1.7.11.7


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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