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

[Xen-devel] [PATCH 16/22] 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 |  50 -------------------
 xen/include/xsm/xsm.h   |  62 +-----------------------
 xen/xsm/dummy.c         |  10 ----
 xen/xsm/flask/hooks.c   | 125 +++++++++++++++---------------------------------
 6 files changed, 39 insertions(+), 265 deletions(-)

diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c
index 8f1c4be..59e8100 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;
@@ -144,10 +135,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 61e7a29..2ebf5e6 100644
--- a/xen/common/sysctl.c
+++ b/xen/common/sysctl.c
@@ -65,18 +65,10 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) 
u_sysctl)
         break;
 
     case XEN_SYSCTL_tbuf_op:
-        ret = xsm_tbufcontrol();
-        if ( ret )
-            break;
-
         ret = tb_control(&op->u.tbuf_op);
         break;
     
     case XEN_SYSCTL_sched_id:
-        ret = xsm_sched_id();
-        if ( ret )
-            break;
-
         op->u.sched_id.sched_id = sched_id();
         break;
 
@@ -122,20 +114,12 @@ 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);
         break;
 #endif
 
 #ifdef LOCK_PROFILE
     case XEN_SYSCTL_lockprof_op:
-        ret = xsm_lockprof();
-        if ( ret )
-            break;
-
         ret = spinlock_profile_control(&op->u.lockprof_op);
         break;
 #endif
@@ -144,10 +128,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++ )
         {
@@ -167,10 +147,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;
-
         ret = -EFAULT;
         for ( i = 0; i < nr_cpus; i++ )
         {
@@ -186,10 +162,6 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) 
u_sysctl)
     break;
 
     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,
@@ -199,18 +171,10 @@ 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);
         break;
 
     case XEN_SYSCTL_pm_op:
-        ret = xsm_pm_op();
-        if ( ret )
-            break;
-
         ret = do_pm_op(&op->u.pm_op);
         if ( ret == -EAGAIN )
             copyback = 1;
@@ -278,18 +242,10 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) 
u_sysctl)
     break;
 
     case XEN_SYSCTL_cpupool_op:
-        ret = xsm_cpupool_op();
-        if ( ret )
-            break;
-
         ret = cpupool_do_sysctl(&op->u.cpupool_op);
         break;
 
     case XEN_SYSCTL_scheduler_op:
-        ret = xsm_sched_op();
-        if ( ret )
-            break;
-
         ret = sched_adjust_global(&op->u.scheduler_op);
         break;
 
diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h
index 2b18f51..64124a8 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;
@@ -353,21 +323,6 @@ static XSM_INLINE int xsm_page_offline(uint32_t cmd)
     return 0;
 }
 
-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 long xsm_do_xsm_op(XEN_GUEST_HANDLE_PARAM(xsm_op_t) op)
 {
     return -ENOSYS;
@@ -496,11 +451,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 4676c75..5eeaced 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);
@@ -116,9 +110,6 @@ struct xsm_operations {
     int (*resource_setup_misc) (void);
 
     int (*page_offline)(uint32_t cmd);
-    int (*lockprof)(void);
-    int (*cpupool_op)(void);
-    int (*sched_op)(void);
 
     long (*do_xsm_op) (XEN_GUEST_HANDLE_PARAM(xsm_op_t) op);
 
@@ -136,7 +127,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);
@@ -199,46 +189,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();
@@ -495,21 +455,6 @@ static inline int xsm_page_offline(uint32_t cmd)
     return xsm_ops->page_offline(cmd);
 }
 
-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 long xsm_do_xsm_op (XEN_GUEST_HANDLE_PARAM(xsm_op_t) op)
 {
     return xsm_ops->do_xsm_op(op);
@@ -581,11 +526,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 a14a755..131a230 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);
@@ -103,9 +97,6 @@ void xsm_fixup_ops (struct xsm_operations *ops)
     set_to_dummy_if_null(ops, resource_setup_misc);
 
     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, do_xsm_op);
 
@@ -123,7 +114,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 d137146..a8bfddd 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);
@@ -1032,26 +1017,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 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)
 {
@@ -1244,11 +1209,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);
@@ -1269,17 +1229,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;
@@ -1475,16 +1439,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,
@@ -1539,9 +1494,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,
 
     .do_xsm_op = do_flask_op,
 
@@ -1559,7 +1511,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®.