From patchwork Mon Aug 8 08:06:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Razvan Cojocaru X-Patchwork-Id: 9266905 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 7B6B860839 for ; Mon, 8 Aug 2016 08:10:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B16C27F8C for ; Mon, 8 Aug 2016 08:10:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B39F27F99; Mon, 8 Aug 2016 08:10:23 +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 C6C3027F8C for ; Mon, 8 Aug 2016 08:10:22 +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 1bWfa6-0007Ms-Mj; Mon, 08 Aug 2016 08:06:42 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWfa6-0007Mm-8O for xen-devel@lists.xen.org; Mon, 08 Aug 2016 08:06:42 +0000 Received: from [193.109.254.147] by server-1.bemta-6.messagelabs.com id 16/F2-21406-19D38A75; Mon, 08 Aug 2016 08:06:41 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEIsWRWlGSWpSXmKPExsUSfTxjoe5E2xX hBo19LBZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8ajkydZCpZyV6xfHtfAOJeji5GTQ0jAXeLV 75nMXYxcQPYaRolZh59AOdcYJX7OXMsGUeUmsXbhfajEPkaJNVfeMoMk2AQMJVZvbAErEhGQl rj2+TIjiM0skCfxYsVkJhBbWCBAYv2Uw2A1LAKqEjPmvWEFsXkFPCVm7f8LNkdCQE7i5LHJrB B2jsSc1s8sXYwcQLaUxP9WJYjwchaJ+T/iIGwZiUcTb7JNYBRYwMiwilGjOLWoLLVI18hQL6k oMz2jJDcxM0fX0MBMLze1uDgxPTUnMalYLzk/dxMjMKwYgGAH459lAYcYJTmYlER5pZRWhAvx JeWnVGYkFmfEF5XmpBYfYpTh4FCS4JWwAcoJFqWmp1akZeYAAxwmLcHBoyTCu8YaKM1bXJCYW 5yZDpE6xagoJc7rCtInAJLIKM2Da4NF1SVGWSlhXkagQ4R4ClKLcjNLUOVfMYpzMCoJ8yaDTO HJzCuBm/4KaDET0OIkVbDFJYkIKakGRotLE0TvGd/d3M9na31xwhW5WyESn6703Aj9xD2/MHv b7fIlvyIKbXp8Zjv8a5tW7D6xOcJ3c+tr+yNs5ywNfk048ZzjiLDfIafChxE/ulO2VsqqWGfW 3GQpNlo4KfHMuiXPwqb+drPj2RDk2H29sm3DI/tnNzZWBpeH9CmzNlx72Oxg7GjWqcRSnJFoq MVcVJwIAJSJ9OilAgAA X-Env-Sender: rcojocaru@bitdefender.com X-Msg-Ref: server-8.tower-27.messagelabs.com!1470643600!42379548!1 X-Originating-IP: [91.199.104.161] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 40236 invoked from network); 8 Aug 2016 08:06:40 -0000 Received: from mx01.bbu.dsd.mx.bitdefender.com (HELO mx01.bbu.dsd.mx.bitdefender.com) (91.199.104.161) by server-8.tower-27.messagelabs.com with DHE-RSA-AES128-GCM-SHA256 encrypted SMTP; 8 Aug 2016 08:06:40 -0000 Received: (qmail 22565 invoked from network); 8 Aug 2016 11:06:39 +0300 Received: from unknown (HELO mx-sr.buh.bitdefender.com) (10.17.80.103) by mx01.bbu.dsd.mx.bitdefender.com with AES256-GCM-SHA384 encrypted SMTP; 8 Aug 2016 11:06:39 +0300 Received: from smtp02.buh.bitdefender.net (smtp.bitdefender.biz [10.17.80.76]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id 029197FBF0 for ; Mon, 8 Aug 2016 11:06:39 +0300 (EEST) Received: (qmail 3924 invoked from network); 8 Aug 2016 11:06:38 +0300 Received: from xen.dsd.ro (HELO xen.dsd.bitdefender.biz) (rcojocaru@bitdefender.com@10.10.14.109) by smtp02.buh.bitdefender.net with AES128-SHA256 encrypted SMTP; 8 Aug 2016 11:06:38 +0300 From: Razvan Cojocaru To: xen-devel@lists.xen.org Date: Mon, 8 Aug 2016 11:06:22 +0300 Message-Id: <1470643582-27641-1-git-send-email-rcojocaru@bitdefender.com> X-Mailer: git-send-email 1.9.1 X-BitDefender-Scanner: Clean, Agent: BitDefender qmail 3.1.6 on smtp02.buh.bitdefender.net, sigver: 7.66740 X-BitDefender-Spam: No (0) X-BitDefender-SpamStamp: Build: [Engines: 2.15.6.911, Dats: 430007, Stamp: 3], Multi: [Enabled, t: (0.000008, 0.001598)], BW: [Enabled, t: (0.000007,0.000002)], RBL DNSBL: [Disabled], APM: [Enabled, Score: 500, t: (0.002313), Flags: 85D2ED72; NN_NO_CONTENT_TYPE; NN_NO_LINK_NMD; NN_LEGIT_BITDEFENDER; NN_LEGIT_S_SQARE_BRACKETS; NN_LEGIT_MAILING_LIST_TO; NN_LEGIT_ML_MAIL_LIST_ADN], SGN: [Enabled, t: (0.016774)], URL: [Enabled, t: (0.000006)], RTDA: [Enabled, t: (0.022639), Hit: No, Details: v2.3.10; Id: 2m1ghhc.1apanp415.k38h], total: 0(775) X-BitDefender-CF-Stamp: none Cc: andrew.cooper3@citrix.com, keir@xen.org, Razvan Cojocaru , jbeulich@suse.com Subject: [Xen-devel] [PATCH V2] x86/hvm: Allow guest_request vm_events coming from userspace 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Allow guest userspace code to request that a vm_event be sent out via VMCALL. This functionality seems to be handy for a number of Xen developers, as stated on the mailing list (thread "[Xen-devel] HVMOP_guest_request_vm_event only works from guest in ring0"). Signed-off-by: Razvan Cojocaru --- Changes since V1: - No longer repeating the check when mode == 8. - Added /* Fallthrough */ tags for Coverity. --- xen/arch/x86/hvm/hvm.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 893eff6..cb546e4 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4146,15 +4146,25 @@ int hvm_do_hypercall(struct cpu_user_regs *regs) switch ( mode ) { case 8: + if ( eax == __HYPERVISOR_hvm_op && + regs->rdi == HVMOP_guest_request_vm_event ) + break; + /* Fallthrough */ case 4: + /* Fallthrough */ case 2: + if ( mode != 8 && eax == __HYPERVISOR_hvm_op && + regs->_ebx == HVMOP_guest_request_vm_event ) + break; hvm_get_segment_register(curr, x86_seg_ss, &sreg); if ( unlikely(sreg.attr.fields.dpl) ) { + /* Fallthrough */ default: regs->eax = -EPERM; return HVM_HCALL_completed; } + /* Fallthrough */ case 0: break; }