[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 17/22] 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 | 62 ---------------------- xen/include/xsm/xsm.h | 66 ----------------------- xen/xsm/dummy.c | 12 ----- xen/xsm/flask/hooks.c | 107 +++++++++++--------------------------- 5 files changed, 30 insertions(+), 277 deletions(-) diff --git a/xen/arch/x86/platform_hypercall.c b/xen/arch/x86/platform_hypercall.c index 570b3db..a67aff4 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, @@ -126,10 +118,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) @@ -148,10 +136,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 ) { @@ -169,10 +153,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); /* @@ -200,10 +180,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: @@ -225,10 +201,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: { @@ -337,10 +309,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) ) @@ -348,18 +316,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; @@ -381,10 +341,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; @@ -421,10 +377,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: @@ -477,10 +429,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; @@ -514,10 +462,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; @@ -570,10 +514,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 64124a8..721fcb4 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) ) @@ -436,26 +421,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) ) @@ -463,33 +428,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 5eeaced..7b62d78 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); @@ -124,16 +121,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 @@ -194,21 +183,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(); @@ -511,56 +485,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 131a230..e254251 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); @@ -111,16 +108,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 a8bfddd..f7309fd 100644 --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -1177,64 +1177,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: @@ -1250,31 +1237,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); @@ -1508,16 +1470,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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |