From patchwork Fri Apr 8 12:35:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Razvan Cojocaru X-Patchwork-Id: 8783191 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 15D4BC0553 for ; Fri, 8 Apr 2016 12:37:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4B78D20295 for ; Fri, 8 Apr 2016 12:37:54 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 6E5752027D for ; Fri, 8 Apr 2016 12:37:53 +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 1aoVdJ-000636-TB; Fri, 08 Apr 2016 12:35:29 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoVdI-00062X-Em for xen-devel@lists.xen.org; Fri, 08 Apr 2016 12:35:28 +0000 Received: from [193.109.254.147] by server-14.bemta-14.messagelabs.com id 0F/C9-02987-F85A7075; Fri, 08 Apr 2016 12:35:27 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEIsWRWlGSWpSXmKPExsUSfTxjoW7/UvZ wgxVbOS2WfFzM4sDocXT3b6YAxijWzLyk/IoE1ozmk90sBUt4KrYuXMHWwHiJs4uRg0NIwF2i fal5FyMXkLmGUeLq89VMEM5JRon/d0+ydjFyghXtn9rBDJHYxyhx8uBfJpAEm4ChxOqNLWwgt oiAtMS1z5cZQWxmgTyJAyfPMIPYwgLJEj+3LAOrYRFQlXh65Ro7iM0r4CHR8vMX2AIJATmJk8 cmQ9k5Eu9a9zKCXCchICXxv1UJZK+EQBeLxImbM6BqZCQeTbzJNoFRYAEjwypG9eLUorLUIl0 TvaSizPSMktzEzBxdQ0MTvdzU4uLE9NScxKRiveT83E2MwLBiAIIdjCsWOh9ilORgUhLlZehl DxfiS8pPqcxILM6ILyrNSS0+xCjDwaEkwTttCVBOsCg1PbUiLTMHGOAwaQkOHiUR3i0gad7ig sTc4sx0iNQpRkUpcd54kIQASCKjNA+uDRZVlxhlpYR5GYEOEeIpSC3KzSxBlX/FKM7BqCTMmw QyhSczrwRu+iugxUxAiy/ws4EsLklESEk1MDYE2r96u05xi+HTwP+rHghyp3rdDXrgtu7iwx+ 84js/N9+ccLpb72dy3f4WNybRu6c22RatrRKsmiy54YDA0xi565em6ItHHZplVhyUrZigF7Ky +oL3vQf3ujh4WhZujTntOZ370gTutHs5rndP28YdWfvYqPSW7bf5vs/DVM5tWfWo0iKtvkuJp Tgj0VCLuag4EQDeXu9npQIAAA== X-Env-Sender: rcojocaru@bitdefender.com X-Msg-Ref: server-4.tower-27.messagelabs.com!1460118926!35514349!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.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 37231 invoked from network); 8 Apr 2016 12:35:26 -0000 Received: from mx01.bbu.dsd.mx.bitdefender.com (HELO mx01.bbu.dsd.mx.bitdefender.com) (91.199.104.161) by server-4.tower-27.messagelabs.com with DHE-RSA-AES128-GCM-SHA256 encrypted SMTP; 8 Apr 2016 12:35:26 -0000 Received: (qmail 21259 invoked from network); 8 Apr 2016 15:35:25 +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 Apr 2016 15:35:25 +0300 Received: from smtp01.buh.bitdefender.com (unknown [10.17.80.75]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id 8B9BC7FBB9 for ; Fri, 8 Apr 2016 15:35:25 +0300 (EEST) Received: (qmail 13957 invoked from network); 8 Apr 2016 15:35:25 +0300 Received: from xen.dsd.ro (HELO xen.dsd.bitdefender.biz) (rcojocaru@bitdefender.com@10.10.14.109) by smtp01.buh.bitdefender.com with AES128-SHA256 encrypted SMTP; 8 Apr 2016 15:35:25 +0300 From: Razvan Cojocaru To: xen-devel@lists.xen.org Date: Fri, 8 Apr 2016 15:35:13 +0300 Message-Id: <1460118913-5321-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 smtp01.buh.bitdefender.com, sigver: 7.65071 X-BitDefender-Spam: No (0) X-BitDefender-SpamStamp: Build: [Engines: 2.15.6.911, Dats: 419409, Stamp: 3], Multi: [Enabled, t: (0.000008, 0.001946)], BW: [Enabled, t: (0.000007,0.000001)], RBL DNSBL: [Disabled], APM: [Enabled, Score: 500, t: (0.002440), Flags: BDD9BED7; NN_NO_CONTENT_TYPE; NN_NO_LINK_NMD; NN_LEGIT_BITDEFENDER; NN_LEGIT_S_SQARE_BRACKETS; NN_LEGIT_MAILING_LIST_TO], SGN: [Enabled, t: (0.008133)], URL: [Enabled, t: (0.000005)], RTDA: [Enabled, t: (0.022979), Hit: No, Details: v2.3.6; Id: 2m1ghak.1afqfusd1.54en], 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/monitor: Disallow setting mem_access_emulate_each_rep when vm_event is NULL 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It is meaningless (and potentially dangerous - see hvmemul_virtual_to_linear()) to set mem_access_emulate_each_rep before xc_monitor_enable() (which allocates vcpu->arch.vm_event) has been called, so return an error from the XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP hypercall when that is the case. Signed-off-by: Razvan Cojocaru --- Changes since V1: - Fixed the if() condition. - Introduced an rc return variable to simplify the code. --- xen/include/asm-x86/monitor.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/xen/include/asm-x86/monitor.h b/xen/include/asm-x86/monitor.h index 0954b59..a66760d 100644 --- a/xen/include/asm-x86/monitor.h +++ b/xen/include/asm-x86/monitor.h @@ -32,19 +32,29 @@ static inline int arch_monitor_domctl_op(struct domain *d, struct xen_domctl_monitor_op *mop) { + int rc = 0; + switch ( mop->op ) { case XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP: domain_pause(d); - d->arch.mem_access_emulate_each_rep = !!mop->event; + /* + * Enabling mem_access_emulate_each_rep without a vm_event subscriber + * is meaningless. + */ + if ( d->vcpu && d->vcpu[0]->arch.vm_event ) + d->arch.mem_access_emulate_each_rep = !!mop->event; + else + rc = -EINVAL; + domain_unpause(d); break; default: - return -EOPNOTSUPP; + rc = -EOPNOTSUPP; } - return 0; + return rc; } int arch_monitor_domctl_event(struct domain *d,