From patchwork Fri Jun 24 10:28:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9197265 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 519016077D for ; Fri, 24 Jun 2016 10:30:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CA8E1FF15 for ; Fri, 24 Jun 2016 10:30:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D49E2847B; Fri, 24 Jun 2016 10:30:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 086FE1FF15 for ; Fri, 24 Jun 2016 10:30:35 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bGOLl-0002ax-Qn; Fri, 24 Jun 2016 10:28:37 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bGOLk-0002aj-Sg for xen-devel@lists.xenproject.org; Fri, 24 Jun 2016 10:28:37 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id 51/AB-22092-45B0D675; Fri, 24 Jun 2016 10:28:36 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrBIsWRWlGSWpSXmKPExsXS6fjDSzeIOzf coHuvmcX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmvFy4UuWgo9TGStmnr7I1sA4vaKLkZNDSCBP 4sP9PmYQm1fATuLxzG/sILaEgKHEvvmr2EBsFgFViQe/djGC2GwC6hJtz7azdjFycIgIGEicO 5oEEmYWmMQkseWaJogtLOAkcetYAzvEeDuJRd/Xs4GUcwrYS+x/LQ5i8goISvzdIQzRaSfx/N 0HxgmMPLMQMrOQZCBsLYmHv26xQNjaEssWvmYGKWcWkJZY/o8DImws8fPXETZUJRBjdnzpY1/ AyLGKUb04tagstUjXWC+pKDM9oyQ3MTNH19DATC83tbg4MT01JzGpWC85P3cTIzBUGYBgB2PH P6dDjJIcTEqivNMW5YQL8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuAN4coNFxIsSk1PrUjLzAFGD UxagoNHSYTXGyTNW1yQmFucmQ6ROsWoy3Fs7o21TEIsefl5qVLivMIgRQIgRRmleXAjYBF8iV FWSpiXEegoIZ6C1KLczBJU+VeM4hyMSsK84SBTeDLzSuA2vQI6ggnoiLv92SBHlCQipKQaGMs Mzx6uOzpxpt/koNM2sm9XiLz7s2rx1rKUR5f6puzfd0NreYxfFj/DGQa+mVY3RBSPqVVvetXN 6nRX0i9Cc5v47+9vFjaG+jhFx23/E9131z0wcvOtcrcWoe0lm3eY7DhX5OYVu8tq/zMBJ3nHy d/fd5R3LWFrLi7c+shPuvWYVNpMvcZIGyWW4oxEQy3mouJEADMzZFLbAgAA X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1466764112!20659559!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 18103 invoked from network); 24 Jun 2016 10:28:34 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-5.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 24 Jun 2016 10:28:34 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Fri, 24 Jun 2016 04:28:32 -0600 Message-Id: <576D276F02000078000F86DA@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Fri, 24 Jun 2016 04:28:31 -0600 From: "Jan Beulich" To: "xen-devel" References: <576D25DA02000078000F86C2@prv-mh.provo.novell.com> In-Reply-To: <576D25DA02000078000F86C2@prv-mh.provo.novell.com> Mime-Version: 1.0 Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , dgdegra@tycho.nsa.gov Subject: [Xen-devel] [PATCH v2 01/11] public / x86: introduce hvmctl hypercall X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP ... as a means to replace all HVMOP_* which a domain can't issue on itself (i.e. intended for use by only the control domain or device model). Signed-off-by: Jan Beulich Reviewed-by: Wei Liu Acked-by: Daniel De Graaf --- v2: Widen cmd field to 32 bits and opaque one to 64. Drop HVMCTL_iter_*. public / x86: introduce hvmctl hypercall ... as a means to replace all HVMOP_* which a domain can't issue on itself (i.e. intended for use by only the control domain or device model). Signed-off-by: Jan Beulich Reviewed-by: Wei Liu --- v2: Widen cmd field to 32 bits and opaque one to 64. Drop HVMCTL_iter_*. --- a/xen/arch/x86/hvm/Makefile +++ b/xen/arch/x86/hvm/Makefile @@ -2,6 +2,7 @@ subdir-y += svm subdir-y += vmx obj-y += asid.o +obj-y += control.o obj-y += emulate.o obj-y += event.o obj-y += hpet.o --- /dev/null +++ b/xen/arch/x86/hvm/control.c @@ -0,0 +1,82 @@ +/* + * control.c: Hardware virtual machine control operations. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; If not, see . + */ + +#include +#include +#include +#include + +long do_hvmctl(XEN_GUEST_HANDLE_PARAM(xen_hvmctl_t) u_hvmctl) +{ + xen_hvmctl_t op; + struct domain *d; + int rc; + + BUILD_BUG_ON(sizeof(op.u) > sizeof(op.u.pad)); + + if ( copy_from_guest(&op, u_hvmctl, 1) ) + return -EFAULT; + + if ( op.interface_version != XEN_HVMCTL_INTERFACE_VERSION ) + return -EACCES; + + rc = rcu_lock_remote_domain_by_id(op.domain, &d); + if ( rc ) + return rc; + + if ( !has_hvm_container_domain(d) ) + { + rcu_unlock_domain(d); + return -EINVAL; + } + + rc = xsm_hvm_control(XSM_DM_PRIV, d, op.cmd); + if ( rc ) + { + rcu_unlock_domain(d); + return rc; + } + + switch ( op.cmd ) + { + default: + rc = -EOPNOTSUPP; + break; + } + + rcu_unlock_domain(d); + + if ( rc == -ERESTART ) + { + if ( unlikely(copy_field_to_guest(u_hvmctl, &op, opaque)) ) + rc = -EFAULT; + else + rc = hypercall_create_continuation(__HYPERVISOR_hvmctl, "h", + u_hvmctl); + } + + return rc; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4111,6 +4111,7 @@ static const struct { COMPAT_CALL(platform_op), COMPAT_CALL(mmuext_op), HYPERCALL(xenpmu_op), + HYPERCALL(hvmctl), HYPERCALL(arch_1) }; --- a/xen/arch/x86/x86_64/compat/entry.S +++ b/xen/arch/x86/x86_64/compat/entry.S @@ -469,6 +469,7 @@ ENTRY(compat_hypercall_table) .quad do_tmem_op .quad do_ni_hypercall /* reserved for XenClient */ .quad do_xenpmu_op /* 40 */ + .quad do_hvmctl .rept __HYPERVISOR_arch_0-((.-compat_hypercall_table)/8) .quad compat_ni_hypercall .endr @@ -520,6 +521,7 @@ ENTRY(compat_hypercall_args_table) .byte 1 /* do_tmem_op */ .byte 0 /* reserved for XenClient */ .byte 2 /* do_xenpmu_op */ /* 40 */ + .byte 1 /* do_hvmctl */ .rept __HYPERVISOR_arch_0-(.-compat_hypercall_args_table) .byte 0 /* compat_ni_hypercall */ .endr --- a/xen/arch/x86/x86_64/entry.S +++ b/xen/arch/x86/x86_64/entry.S @@ -792,6 +792,7 @@ ENTRY(hypercall_table) .quad do_tmem_op .quad do_ni_hypercall /* reserved for XenClient */ .quad do_xenpmu_op /* 40 */ + .quad do_hvmctl .rept __HYPERVISOR_arch_0-((.-hypercall_table)/8) .quad do_ni_hypercall .endr @@ -843,6 +844,7 @@ ENTRY(hypercall_args_table) .byte 1 /* do_tmem_op */ .byte 0 /* reserved for XenClient */ .byte 2 /* do_xenpmu_op */ /* 40 */ + .byte 1 /* do_hvmctl */ .rept __HYPERVISOR_arch_0-(.-hypercall_args_table) .byte 0 /* do_ni_hypercall */ .endr --- a/xen/include/Makefile +++ b/xen/include/Makefile @@ -93,7 +93,7 @@ all: headers.chk headers++.chk PUBLIC_HEADERS := $(filter-out public/arch-% public/dom0_ops.h, $(wildcard public/*.h public/*/*.h) $(public-y)) -PUBLIC_ANSI_HEADERS := $(filter-out public/%ctl.h public/xsm/% public/%hvm/save.h, $(PUBLIC_HEADERS)) +PUBLIC_ANSI_HEADERS := $(filter-out public/%ctl.h public/hvm/control.h public/xsm/% public/%hvm/save.h,$(PUBLIC_HEADERS)) headers.chk: $(PUBLIC_ANSI_HEADERS) Makefile for i in $(filter %.h,$^); do \ --- /dev/null +++ b/xen/include/public/hvm/control.h @@ -0,0 +1,54 @@ +/* + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef __XEN_PUBLIC_HVM_CONTROL_H__ +#define __XEN_PUBLIC_HVM_CONTROL_H__ + +#if !defined(__XEN__) && !defined(__XEN_TOOLS__) +#error "HVM control operations are intended for use by control tools only" +#endif + +#include "../xen.h" + +#define XEN_HVMCTL_INTERFACE_VERSION 0x00000001 + +struct xen_hvmctl { + uint16_t interface_version; /* XEN_HVMCTL_INTERFACE_VERSION */ + domid_t domain; + uint32_t cmd; + uint64_t opaque; /* Must be zero on initial invocation. */ + union { + uint8_t pad[120]; + } u; +}; +typedef struct xen_hvmctl xen_hvmctl_t; +DEFINE_XEN_GUEST_HANDLE(xen_hvmctl_t); + +#endif /* __XEN_PUBLIC_HVM_CONTROL_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ --- a/xen/include/public/xen.h +++ b/xen/include/public/xen.h @@ -115,6 +115,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_ulong_t); #define __HYPERVISOR_tmem_op 38 #define __HYPERVISOR_xc_reserved_op 39 /* reserved for XenClient */ #define __HYPERVISOR_xenpmu_op 40 +#define __HYPERVISOR_hvmctl 41 /* Architecture-specific hypercall definitions. */ #define __HYPERVISOR_arch_0 48 --- a/xen/include/xen/hypercall.h +++ b/xen/include/xen/hypercall.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -46,6 +47,10 @@ arch_do_sysctl( XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl); extern long +do_hvmctl( + XEN_GUEST_HANDLE_PARAM(xen_hvmctl_t) u_hvmctl); + +extern long do_platform_op( XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op); --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -1183,6 +1183,20 @@ static int flask_hvm_param(struct domain return current_has_perm(d, SECCLASS_HVM, perm); } +static int flask_hvm_control(struct domain *d, unsigned long op) +{ + u32 perm; + + switch ( op ) + { + default: + perm = HVM__HVMCTL; + break; + } + + return current_has_perm(d, SECCLASS_HVM, perm); +} + static int flask_hvm_param_nested(struct domain *d) { return current_has_perm(d, SECCLASS_HVM, HVM__NESTED); @@ -1745,7 +1759,7 @@ static struct xsm_operations flask_ops = .page_offline = flask_page_offline, .tmem_op = flask_tmem_op, .hvm_param = flask_hvm_param, - .hvm_control = flask_hvm_param, + .hvm_control = flask_hvm_control, .hvm_param_nested = flask_hvm_param_nested, .hvm_param_altp2mhvm = flask_hvm_param_altp2mhvm, .hvm_altp2mhvm_op = flask_hvm_altp2mhvm_op, --- a/xen/arch/x86/hvm/Makefile +++ b/xen/arch/x86/hvm/Makefile @@ -2,6 +2,7 @@ subdir-y += svm subdir-y += vmx obj-y += asid.o +obj-y += control.o obj-y += emulate.o obj-y += event.o obj-y += hpet.o --- /dev/null +++ b/xen/arch/x86/hvm/control.c @@ -0,0 +1,82 @@ +/* + * control.c: Hardware virtual machine control operations. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; If not, see . + */ + +#include +#include +#include +#include + +long do_hvmctl(XEN_GUEST_HANDLE_PARAM(xen_hvmctl_t) u_hvmctl) +{ + xen_hvmctl_t op; + struct domain *d; + int rc; + + BUILD_BUG_ON(sizeof(op.u) > sizeof(op.u.pad)); + + if ( copy_from_guest(&op, u_hvmctl, 1) ) + return -EFAULT; + + if ( op.interface_version != XEN_HVMCTL_INTERFACE_VERSION ) + return -EACCES; + + rc = rcu_lock_remote_domain_by_id(op.domain, &d); + if ( rc ) + return rc; + + if ( !has_hvm_container_domain(d) ) + { + rcu_unlock_domain(d); + return -EINVAL; + } + + rc = xsm_hvm_control(XSM_DM_PRIV, d, op.cmd); + if ( rc ) + { + rcu_unlock_domain(d); + return rc; + } + + switch ( op.cmd ) + { + default: + rc = -EOPNOTSUPP; + break; + } + + rcu_unlock_domain(d); + + if ( rc == -ERESTART ) + { + if ( unlikely(copy_field_to_guest(u_hvmctl, &op, opaque)) ) + rc = -EFAULT; + else + rc = hypercall_create_continuation(__HYPERVISOR_hvmctl, "h", + u_hvmctl); + } + + return rc; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4111,6 +4111,7 @@ static const struct { COMPAT_CALL(platform_op), COMPAT_CALL(mmuext_op), HYPERCALL(xenpmu_op), + HYPERCALL(hvmctl), HYPERCALL(arch_1) }; --- a/xen/arch/x86/x86_64/compat/entry.S +++ b/xen/arch/x86/x86_64/compat/entry.S @@ -469,6 +469,7 @@ ENTRY(compat_hypercall_table) .quad do_tmem_op .quad do_ni_hypercall /* reserved for XenClient */ .quad do_xenpmu_op /* 40 */ + .quad do_hvmctl .rept __HYPERVISOR_arch_0-((.-compat_hypercall_table)/8) .quad compat_ni_hypercall .endr @@ -520,6 +521,7 @@ ENTRY(compat_hypercall_args_table) .byte 1 /* do_tmem_op */ .byte 0 /* reserved for XenClient */ .byte 2 /* do_xenpmu_op */ /* 40 */ + .byte 1 /* do_hvmctl */ .rept __HYPERVISOR_arch_0-(.-compat_hypercall_args_table) .byte 0 /* compat_ni_hypercall */ .endr --- a/xen/arch/x86/x86_64/entry.S +++ b/xen/arch/x86/x86_64/entry.S @@ -792,6 +792,7 @@ ENTRY(hypercall_table) .quad do_tmem_op .quad do_ni_hypercall /* reserved for XenClient */ .quad do_xenpmu_op /* 40 */ + .quad do_hvmctl .rept __HYPERVISOR_arch_0-((.-hypercall_table)/8) .quad do_ni_hypercall .endr @@ -843,6 +844,7 @@ ENTRY(hypercall_args_table) .byte 1 /* do_tmem_op */ .byte 0 /* reserved for XenClient */ .byte 2 /* do_xenpmu_op */ /* 40 */ + .byte 1 /* do_hvmctl */ .rept __HYPERVISOR_arch_0-(.-hypercall_args_table) .byte 0 /* do_ni_hypercall */ .endr --- a/xen/include/Makefile +++ b/xen/include/Makefile @@ -93,7 +93,7 @@ all: headers.chk headers++.chk PUBLIC_HEADERS := $(filter-out public/arch-% public/dom0_ops.h, $(wildcard public/*.h public/*/*.h) $(public-y)) -PUBLIC_ANSI_HEADERS := $(filter-out public/%ctl.h public/xsm/% public/%hvm/save.h, $(PUBLIC_HEADERS)) +PUBLIC_ANSI_HEADERS := $(filter-out public/%ctl.h public/hvm/control.h public/xsm/% public/%hvm/save.h,$(PUBLIC_HEADERS)) headers.chk: $(PUBLIC_ANSI_HEADERS) Makefile for i in $(filter %.h,$^); do \ --- /dev/null +++ b/xen/include/public/hvm/control.h @@ -0,0 +1,54 @@ +/* + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef __XEN_PUBLIC_HVM_CONTROL_H__ +#define __XEN_PUBLIC_HVM_CONTROL_H__ + +#if !defined(__XEN__) && !defined(__XEN_TOOLS__) +#error "HVM control operations are intended for use by control tools only" +#endif + +#include "../xen.h" + +#define XEN_HVMCTL_INTERFACE_VERSION 0x00000001 + +struct xen_hvmctl { + uint16_t interface_version; /* XEN_HVMCTL_INTERFACE_VERSION */ + domid_t domain; + uint32_t cmd; + uint64_t opaque; /* Must be zero on initial invocation. */ + union { + uint8_t pad[120]; + } u; +}; +typedef struct xen_hvmctl xen_hvmctl_t; +DEFINE_XEN_GUEST_HANDLE(xen_hvmctl_t); + +#endif /* __XEN_PUBLIC_HVM_CONTROL_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ --- a/xen/include/public/xen.h +++ b/xen/include/public/xen.h @@ -115,6 +115,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_ulong_t); #define __HYPERVISOR_tmem_op 38 #define __HYPERVISOR_xc_reserved_op 39 /* reserved for XenClient */ #define __HYPERVISOR_xenpmu_op 40 +#define __HYPERVISOR_hvmctl 41 /* Architecture-specific hypercall definitions. */ #define __HYPERVISOR_arch_0 48 --- a/xen/include/xen/hypercall.h +++ b/xen/include/xen/hypercall.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -46,6 +47,10 @@ arch_do_sysctl( XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl); extern long +do_hvmctl( + XEN_GUEST_HANDLE_PARAM(xen_hvmctl_t) u_hvmctl); + +extern long do_platform_op( XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op); --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -1183,6 +1183,20 @@ static int flask_hvm_param(struct domain return current_has_perm(d, SECCLASS_HVM, perm); } +static int flask_hvm_control(struct domain *d, unsigned long op) +{ + u32 perm; + + switch ( op ) + { + default: + perm = HVM__HVMCTL; + break; + } + + return current_has_perm(d, SECCLASS_HVM, perm); +} + static int flask_hvm_param_nested(struct domain *d) { return current_has_perm(d, SECCLASS_HVM, HVM__NESTED); @@ -1745,7 +1759,7 @@ static struct xsm_operations flask_ops = .page_offline = flask_page_offline, .tmem_op = flask_tmem_op, .hvm_param = flask_hvm_param, - .hvm_control = flask_hvm_param, + .hvm_control = flask_hvm_control, .hvm_param_nested = flask_hvm_param_nested, .hvm_param_altp2mhvm = flask_hvm_param_altp2mhvm, .hvm_altp2mhvm_op = flask_hvm_altp2mhvm_op,