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

[Xen-devel] [PATCH 22/23] xen: platform_hypercall XSM hook removal



A number of the platform_hypercall XSM hooks have no parameters or only
pass the operation ID, making them redundant with the xsm_platform_op
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/platform_hypercall.c |  60 ---------------------
 xen/include/xsm/dummy.h           |  67 ------------------------
 xen/include/xsm/xsm.h             |  72 -------------------------
 xen/xsm/dummy.c                   |  13 -----
 xen/xsm/flask/hooks.c             | 107 +++++++++++---------------------------
 5 files changed, 30 insertions(+), 289 deletions(-)

diff --git a/xen/arch/x86/platform_hypercall.c 
b/xen/arch/x86/platform_hypercall.c
index 738bed0..e17d64f 100644
--- a/xen/arch/x86/platform_hypercall.c
+++ b/xen/arch/x86/platform_hypercall.c
@@ -90,10 +90,6 @@ ret_t 
do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)
     {
     case XENPF_settime:
     {
-        ret = xsm_xen_settime();
-        if ( ret )
-            break;
-
         do_settime(op->u.settime.secs, 
                    op->u.settime.nsecs, 
                    op->u.settime.system_time);
@@ -103,10 +99,6 @@ ret_t 
do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)
 
     case XENPF_add_memtype:
     {
-        ret = xsm_memtype(op->cmd);
-        if ( ret )
-            break;
-
         ret = mtrr_add_page(
             op->u.add_memtype.mfn,
             op->u.add_memtype.nr_mfns,
@@ -125,10 +117,6 @@ ret_t 
do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)
 
     case XENPF_del_memtype:
     {
-        ret = xsm_memtype(op->cmd);
-        if ( ret )
-            break;
-
         if (op->u.del_memtype.handle == 0
             /* mtrr/main.c otherwise does a lookup */
             && (int)op->u.del_memtype.reg >= 0)
@@ -147,10 +135,6 @@ ret_t 
do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)
         unsigned long mfn, nr_mfns;
         mtrr_type     type;
 
-        ret = xsm_memtype(op->cmd);
-        if ( ret )
-            break;
-
         ret = -EINVAL;
         if ( op->u.read_memtype.reg < num_var_ranges )
         {
@@ -167,10 +151,6 @@ ret_t 
do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)
     {
         XEN_GUEST_HANDLE(const_void) data;
 
-        ret = xsm_microcode();
-        if ( ret )
-            break;
-
         guest_from_compat_handle(data, op->u.microcode.data);
 
         /*
@@ -198,10 +178,6 @@ ret_t 
do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)
     {
         int quirk_id = op->u.platform_quirk.quirk_id;
 
-        ret = xsm_platform_quirk(quirk_id);
-        if ( ret )
-            break;
-
         switch ( quirk_id )
         {
         case QUIRK_NOIRQBALANCING:
@@ -223,10 +199,6 @@ ret_t 
do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)
     break;
 
     case XENPF_firmware_info:
-        ret = xsm_firmware_info();
-        if ( ret )
-            break;
-
         switch ( op->u.firmware_info.type )
         {
         case XEN_FW_DISK_INFO: {
@@ -335,10 +307,6 @@ ret_t 
do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)
         break;
 
     case XENPF_efi_runtime_call:
-        ret = xsm_efi_call();
-        if ( ret )
-            break;
-
         ret = efi_runtime_call(&op->u.efi_runtime_call);
         if ( ret == 0 &&
              copy_field_to_guest(u_xenpf_op, op, u.efi_runtime_call) )
@@ -346,18 +314,10 @@ ret_t 
do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)
         break;
 
     case XENPF_enter_acpi_sleep:
-        ret = xsm_acpi_sleep();
-        if ( ret )
-            break;
-
         ret = acpi_enter_sleep(&op->u.enter_acpi_sleep);
         break;
 
     case XENPF_change_freq:
-        ret = xsm_change_freq();
-        if ( ret )
-            break;
-
         ret = -ENOSYS;
         if ( cpufreq_controller != FREQCTL_dom0_kernel )
             break;
@@ -379,10 +339,6 @@ ret_t 
do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)
         XEN_GUEST_HANDLE(uint8) cpumap_bitmap;
         XEN_GUEST_HANDLE(uint64) idletimes;
 
-        ret = xsm_getidletime();
-        if ( ret )
-            break;
-
         ret = -ENOSYS;
         if ( cpufreq_controller != FREQCTL_dom0_kernel )
             break;
@@ -419,10 +375,6 @@ ret_t 
do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)
     break;
 
     case XENPF_set_processor_pminfo:
-        ret = xsm_setpminfo();
-        if ( ret )
-            break;
-
         switch ( op->u.set_pminfo.type )
         {
         case XEN_PM_PX:
@@ -475,10 +427,6 @@ ret_t 
do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)
 
         g_info = &op->u.pcpu_info;
 
-        ret = xsm_getcpuinfo();
-        if ( ret )
-            break;
-
         if ( !get_cpu_maps() )
         {
             ret = -EBUSY;
@@ -512,10 +460,6 @@ ret_t 
do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)
     {
         struct xenpf_pcpu_version *ver = &op->u.pcpu_version;
 
-        ret = xsm_getcpuinfo();
-        if ( ret )
-            break;
-
         if ( !get_cpu_maps() )
         {
             ret = -EBUSY;
@@ -568,10 +512,6 @@ ret_t 
do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)
             break;
         }
 
-        ret = xsm_resource_plug_core();
-        if ( ret )
-            break;
-
         ret = continue_hypercall_on_cpu(
             0, cpu_up_helper, (void *)(unsigned long)cpu);
         break;
diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h
index b680d61..019183e 100644
--- a/xen/include/xsm/dummy.h
+++ b/xen/include/xsm/dummy.h
@@ -63,21 +63,6 @@ static XSM_INLINE int xsm_readconsole(uint32_t clear)
     return 0;
 }
 
-static XSM_INLINE int xsm_getcpuinfo(void)
-{
-    return 0;
-}
-
-static XSM_INLINE int xsm_setpminfo(void)
-{
-    return 0;
-}
-
-static XSM_INLINE int xsm_pm_op(void)
-{
-    return 0;
-}
-
 static XSM_INLINE int xsm_do_mca(void)
 {
     if ( !IS_PRIV(current->domain) )
@@ -323,11 +308,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_tmem_op(void)
 {
     return 0;
@@ -453,26 +433,6 @@ static XSM_INLINE int xsm_apic(struct domain *d, int cmd)
     return 0;
 }
 
-static XSM_INLINE int xsm_xen_settime(void)
-{
-    return 0;
-}
-
-static XSM_INLINE int xsm_memtype(uint32_t access)
-{
-    return 0;
-}
-
-static XSM_INLINE int xsm_microcode(void)
-{
-    return 0;
-}
-
-static XSM_INLINE int xsm_platform_quirk(uint32_t quirk)
-{
-    return 0;
-}
-
 static XSM_INLINE int xsm_platform_op(uint32_t op)
 {
     if ( !IS_PRIV(current->domain) )
@@ -480,33 +440,6 @@ static XSM_INLINE int xsm_platform_op(uint32_t op)
     return 0;
 }
 
-static XSM_INLINE int xsm_firmware_info(void)
-{
-    return 0;
-}
-
-static XSM_INLINE int xsm_efi_call(void)
-{
-    return 0;
-}
-
-static XSM_INLINE int xsm_acpi_sleep(void)
-{
-    if ( !IS_PRIV(current->domain) )
-        return -EPERM;
-    return 0;
-}
-
-static XSM_INLINE int xsm_change_freq(void)
-{
-    return 0;
-}
-
-static XSM_INLINE int xsm_getidletime(void)
-{
-    return 0;
-}
-
 static XSM_INLINE int xsm_machine_memory_map(void)
 {
     if ( !IS_PRIV(current->domain) )
diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h
index f054dae..105201e 100644
--- a/xen/include/xsm/xsm.h
+++ b/xen/include/xsm/xsm.h
@@ -47,9 +47,6 @@ struct xsm_operations {
     int (*domctl) (struct domain *d, int cmd);
     int (*sysctl) (int cmd);
     int (*readconsole) (uint32_t clear);
-    int (*getcpuinfo) (void);
-    int (*setpminfo) (void);
-    int (*pm_op) (void);
     int (*do_mca) (void);
 
     int (*evtchn_unbound) (struct domain *d, struct evtchn *chn, domid_t id2);
@@ -110,7 +107,6 @@ struct xsm_operations {
     int (*resource_setup_misc) (void);
 
     int (*page_offline)(uint32_t cmd);
-    int (*lockprof)(void);
     int (*tmem_op)(void);
     int (*tmem_control)(void);
 
@@ -127,16 +123,8 @@ struct xsm_operations {
     int (*mem_event_op) (struct domain *d, int op);
     int (*mem_sharing_op) (struct domain *d, struct domain *cd, int op);
     int (*apic) (struct domain *d, int cmd);
-    int (*xen_settime) (void);
     int (*memtype) (uint32_t access);
-    int (*microcode) (void);
-    int (*platform_quirk) (uint32_t);
     int (*platform_op) (uint32_t cmd);
-    int (*firmware_info) (void);
-    int (*efi_call) (void);
-    int (*acpi_sleep) (void);
-    int (*change_freq) (void);
-    int (*getidletime) (void);
     int (*machine_memory_map) (void);
     int (*domain_memory_map) (struct domain *d);
 #define XSM_MMU_UPDATE_READ      1
@@ -197,21 +185,6 @@ static inline int xsm_readconsole (uint32_t clear)
     return xsm_ops->readconsole(clear);
 }
 
-static inline int xsm_getcpuinfo(void)
-{
-    return xsm_ops->getcpuinfo();
-}
-
-static inline int xsm_setpminfo(void)
-{
-    return xsm_ops->setpminfo();
-}
-
-static inline int xsm_pm_op(void)
-{
-    return xsm_ops->pm_op();
-}
-
 static inline int xsm_do_mca(void)
 {
     return xsm_ops->do_mca();
@@ -458,11 +431,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_tmem_op(void)
 {
     return xsm_ops->tmem_op();
@@ -529,56 +497,16 @@ static inline int xsm_apic (struct domain *d, int cmd)
     return xsm_ops->apic(d, cmd);
 }
 
-static inline int xsm_xen_settime (void)
-{
-    return xsm_ops->xen_settime();
-}
-
 static inline int xsm_memtype (uint32_t access)
 {
     return xsm_ops->memtype(access);
 }
 
-static inline int xsm_microcode (void)
-{
-    return xsm_ops->microcode();
-}
-
-static inline int xsm_platform_quirk (uint32_t quirk)
-{
-    return xsm_ops->platform_quirk(quirk);
-}
-
 static inline int xsm_platform_op (uint32_t op)
 {
     return xsm_ops->platform_op(op);
 }
 
-static inline int xsm_firmware_info (void)
-{
-    return xsm_ops->firmware_info();
-}
-
-static inline int xsm_efi_call (void)
-{
-    return xsm_ops->efi_call();
-}
-
-static inline int xsm_acpi_sleep (void)
-{
-    return xsm_ops->acpi_sleep();
-}
-
-static inline int xsm_change_freq (void)
-{
-    return xsm_ops->change_freq();
-}
-
-static inline int xsm_getidletime (void)
-{
-    return xsm_ops->getidletime();
-}
-
 static inline int xsm_machine_memory_map(void)
 {
     return xsm_ops->machine_memory_map();
diff --git a/xen/xsm/dummy.c b/xen/xsm/dummy.c
index 0216b62..22c66e5 100644
--- a/xen/xsm/dummy.c
+++ b/xen/xsm/dummy.c
@@ -36,9 +36,6 @@ void xsm_fixup_ops (struct xsm_operations *ops)
     set_to_dummy_if_null(ops, domctl);
     set_to_dummy_if_null(ops, sysctl);
     set_to_dummy_if_null(ops, readconsole);
-    set_to_dummy_if_null(ops, getcpuinfo);
-    set_to_dummy_if_null(ops, setpminfo);
-    set_to_dummy_if_null(ops, pm_op);
     set_to_dummy_if_null(ops, do_mca);
 
     set_to_dummy_if_null(ops, evtchn_unbound);
@@ -97,7 +94,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, tmem_op);
     set_to_dummy_if_null(ops, tmem_control);
 
@@ -114,16 +110,7 @@ void xsm_fixup_ops (struct xsm_operations *ops)
     set_to_dummy_if_null(ops, mem_event_op);
     set_to_dummy_if_null(ops, mem_sharing_op);
     set_to_dummy_if_null(ops, apic);
-    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, platform_quirk);
     set_to_dummy_if_null(ops, platform_op);
-    set_to_dummy_if_null(ops, firmware_info);
-    set_to_dummy_if_null(ops, efi_call);
-    set_to_dummy_if_null(ops, acpi_sleep);
-    set_to_dummy_if_null(ops, change_freq);
-    set_to_dummy_if_null(ops, getidletime);
     set_to_dummy_if_null(ops, machine_memory_map);
     set_to_dummy_if_null(ops, domain_memory_map);
     set_to_dummy_if_null(ops, mmu_update);
diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c
index d72a807..03ea675 100644
--- a/xen/xsm/flask/hooks.c
+++ b/xen/xsm/flask/hooks.c
@@ -1186,64 +1186,51 @@ static int flask_apic(struct domain *d, int cmd)
     return domain_has_xen(d, perm);
 }
 
-static int flask_xen_settime(void)
-{
-    return domain_has_xen(current->domain, XEN__SETTIME);
-}
-
-static int flask_memtype(uint32_t access)
-{
-    u32 perm;
-
-    switch ( access )
-    {
-    case XENPF_add_memtype:
-        perm = XEN__MTRR_ADD;
-        break;
-    case XENPF_del_memtype:
-        perm = XEN__MTRR_DEL;
-        break;
-    case XENPF_read_memtype:
-        perm = XEN__MTRR_READ;
-        break;
-    default:
-        return -EPERM;
-    }
-
-    return domain_has_xen(current->domain, perm);
-}
-
-static int flask_microcode(void)
-{
-    return domain_has_xen(current->domain, XEN__MICROCODE);
-}
-
-static int flask_platform_quirk(uint32_t quirk)
-{
-    return avc_current_has_perm(SECINITSID_XEN, SECCLASS_XEN, XEN__QUIRK, 
NULL);
-}
-
 static int flask_platform_op(uint32_t op)
 {
     switch ( op )
     {
+#ifdef CONFIG_X86
+    /* These operations have their own XSM hooks */
+    case XENPF_cpu_online:
+    case XENPF_cpu_offline:
+    case XENPF_cpu_hotadd:
+    case XENPF_mem_hotadd:
+        return 0;
+#endif
+
     case XENPF_settime:
+        return domain_has_xen(current->domain, XEN__SETTIME);
+
     case XENPF_add_memtype:
+        return domain_has_xen(current->domain, XEN__MTRR_ADD);
+
     case XENPF_del_memtype:
+        return domain_has_xen(current->domain, XEN__MTRR_DEL);
+
     case XENPF_read_memtype:
+        return domain_has_xen(current->domain, XEN__MTRR_READ);
+
     case XENPF_microcode_update:
+        return domain_has_xen(current->domain, XEN__MICROCODE);
+
     case XENPF_platform_quirk:
+        return domain_has_xen(current->domain, XEN__QUIRK);
+
     case XENPF_firmware_info:
+        return domain_has_xen(current->domain, XEN__FIRMWARE);
+
     case XENPF_efi_runtime_call:
+        return domain_has_xen(current->domain, XEN__FIRMWARE);
+
     case XENPF_enter_acpi_sleep:
+        return domain_has_xen(current->domain, XEN__SLEEP);
+
     case XENPF_change_freq:
+        return domain_has_xen(current->domain, XEN__FREQUENCY);
+
     case XENPF_getidletime:
-    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;
+        return domain_has_xen(current->domain, XEN__GETIDLE);
 
     case XENPF_set_processor_pminfo:
     case XENPF_core_parking:
@@ -1259,31 +1246,6 @@ static int flask_platform_op(uint32_t op)
     }
 }
 
-static int flask_firmware_info(void)
-{
-    return domain_has_xen(current->domain, XEN__FIRMWARE);
-}
-
-static int flask_efi_call(void)
-{
-    return domain_has_xen(current->domain, XEN__FIRMWARE);
-}
-
-static int flask_acpi_sleep(void)
-{
-    return domain_has_xen(current->domain, XEN__SLEEP);
-}
-
-static int flask_change_freq(void)
-{
-    return domain_has_xen(current->domain, XEN__FREQUENCY);
-}
-
-static int flask_getidletime(void)
-{
-    return domain_has_xen(current->domain, XEN__GETIDLE);
-}
-
 static int flask_machine_memory_map(void)
 {
     return avc_current_has_perm(SECINITSID_XEN, SECCLASS_MMU, MMU__MEMORYMAP, 
NULL);
@@ -1519,16 +1481,7 @@ static struct xsm_operations flask_ops = {
     .mem_event_op = flask_mem_event_op,
     .mem_sharing_op = flask_mem_sharing_op,
     .apic = flask_apic,
-    .xen_settime = flask_xen_settime,
-    .memtype = flask_memtype,
-    .microcode = flask_microcode,
-    .platform_quirk = flask_platform_quirk,
     .platform_op = flask_platform_op,
-    .firmware_info = flask_firmware_info,
-    .efi_call = flask_efi_call,
-    .acpi_sleep = flask_acpi_sleep,
-    .change_freq = flask_change_freq,
-    .getidletime = flask_getidletime,
     .machine_memory_map = flask_machine_memory_map,
     .domain_memory_map = flask_domain_memory_map,
     .mmu_update = flask_mmu_update,
-- 
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®.