From patchwork Fri Apr 8 07:10:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Razvan Cojocaru X-Patchwork-Id: 8781491 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 09EF8C0553 for ; Fri, 8 Apr 2016 07:13:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 35E5B2026D for ; Fri, 8 Apr 2016 07:13:34 +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 4F6EC20222 for ; Fri, 8 Apr 2016 07:13:33 +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 1aoQZg-0006iD-9k; Fri, 08 Apr 2016 07:11:24 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoQZe-0006i7-Bx for xen-devel@lists.xen.org; Fri, 08 Apr 2016 07:11:22 +0000 Received: from [193.109.254.147] by server-1.bemta-14.messagelabs.com id 1D/F2-30565-99957075; Fri, 08 Apr 2016 07:11:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMIsWRWlGSWpSXmKPExsUSfTxjoe7MSPZ wg/lLuCyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oyO3dtZC55yVRzYeJ6tgXELRxcjJ4eQgJvE pk2XmbsYuYDsNYwSN99MZYVwTjJKfPq0iAmiyl2i480JqKp9jBLzHm9jAUmwCRhKrN7YwgZii whIS1z7fJkRxGYWyJM4cPIMM4gtLJAgsXbxNrA4i4CqxNIvq9lBbF4BT4kt5w+CzZEQkJM4eW wyK4SdI7Gq8y2QzQFkS0n8b1UC2Ssh0MUiMenrGmaIGhmJRxNvsk1gFFjAyLCKUb04tagstUj XWC+pKDM9oyQ3MTNH19DQRC83tbg4MT01JzGpWC85P3cTIzCwGIBgB+PdPudDjJIcTEqivJLh 7OFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHgTI4BygkWp6akVaZk5wBCHSUtw8CiJ8KaCpHmLC xJzizPTIVKnGBWlxHlDQRICIImM0jy4NlhcXWKUlRLmZQQ6RIinILUoN7MEVf4VozgHo5Iwbw HIFJ7MvBK46a+AFjMBLb7AzwayuCQRISXVwCi7pfi4CPOx4JLzr2Kv1+/bONW69OwV8esFrrF nA64ueML276Kn6dIEwzVKIusPNX/Ydcfed9kab4dlW05UME29WGoTvinnoICfyAy90q66yy6b dV3bl6TpPwg+/jmvfOa678oxexjKy7c8DlbZ9K18vVFh4KGrS/hbLwp8vPriWMHlX0Wbel4rs RRnJBpqMRcVJwIAagaR4qYCAAA= X-Env-Sender: rcojocaru@bitdefender.com X-Msg-Ref: server-9.tower-27.messagelabs.com!1460099480!36269706!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 20751 invoked from network); 8 Apr 2016 07:11:21 -0000 Received: from mx01.bbu.dsd.mx.bitdefender.com (HELO mx01.bbu.dsd.mx.bitdefender.com) (91.199.104.161) by server-9.tower-27.messagelabs.com with DHE-RSA-AES128-GCM-SHA256 encrypted SMTP; 8 Apr 2016 07:11:21 -0000 Received: (qmail 5976 invoked from network); 8 Apr 2016 10:11:19 +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 10:11:19 +0300 Received: from smtp02.buh.bitdefender.net (unknown [10.17.80.76]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id 0020F7FBF5 for ; Fri, 8 Apr 2016 10:11:19 +0300 (EEST) Received: (qmail 17346 invoked from network); 8 Apr 2016 10:11:18 +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 Apr 2016 10:11:18 +0300 From: Razvan Cojocaru To: xen-devel@lists.xen.org Date: Fri, 8 Apr 2016 10:10:59 +0300 Message-Id: <1460099459-25694-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.65069 X-BitDefender-Spam: No (0) X-BitDefender-SpamStamp: Build: [Engines: 2.15.6.911, Dats: 419362, Stamp: 3], Multi: [Enabled, t: (0.000008, 0.001673)], BW: [Enabled, t: (0.000007,0.000001)], RBL DNSBL: [Disabled], APM: [Enabled, Score: 500, t: (0.002254), 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.007602)], URL: [Enabled, t: (0.000004)], RTDA: [Enabled, t: (0.097534), Hit: No, Details: v2.3.6; Id: 2m1ghar.1afo9e3rj.j8pp], 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] 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 --- xen/include/asm-x86/monitor.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/xen/include/asm-x86/monitor.h b/xen/include/asm-x86/monitor.h index 0954b59..0544836 100644 --- a/xen/include/asm-x86/monitor.h +++ b/xen/include/asm-x86/monitor.h @@ -35,11 +35,22 @@ int arch_monitor_domctl_op(struct domain *d, struct xen_domctl_monitor_op *mop) switch ( mop->op ) { case XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP: + { + bool_t value = !!mop->event; domain_pause(d); - d->arch.mem_access_emulate_each_rep = !!mop->event; + /* + * Enabling emulate_each_rep without a vm_event subscriber + * is meaningless. + */ + if ( !d->vcpu || !d->vcpu[0]->arch.vm_event ) + { + domain_unpause(d); + return -EINVAL; + } + d->arch.mem_access_emulate_each_rep = value; domain_unpause(d); break; - + } default: return -EOPNOTSUPP; }