From patchwork Sat Apr 9 05:54:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Razvan Cojocaru X-Patchwork-Id: 8787661 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 39677C0553 for ; Sat, 9 Apr 2016 05:57:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 593A320328 for ; Sat, 9 Apr 2016 05:57:24 +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 68217202FF for ; Sat, 9 Apr 2016 05:57:23 +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 1aolqr-0003rf-Eg; Sat, 09 Apr 2016 05:54:33 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aolqp-0003rZ-UK for xen-devel@lists.xen.org; Sat, 09 Apr 2016 05:54:32 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id A3/49-03814-71998075; Sat, 09 Apr 2016 05:54:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMIsWRWlGSWpSXmKPExsUSfTxjoa7YTI5 wgyU/FSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1ozulvmsBX94Kp79usPWwLiEq4uRk0NIwF3i +qszzF2MXED2GkaJszf7mSCck4wS226+ZoSpmta0ixEisY9RYsGxa2AJNgFDidUbW9hAbBEBa Ylrny+DxZkF8iQOnAQZy8khLJAssaNxOZjNIqAq0bB8IxOIzSvgKbHn0D12EFtCQE7i5LHJrB B2jsSEXc+AZnIA2VIS/1uVQPZKCHSxSBxZuo8NokZG4tHEm2wTGAUWMDKsYlQvTi0qSy3SNdF LKspMzyjJTczM0TU0MNbLTS0uTkxPzUlMKtZLzs/dxAgMLAYg2MHY+MXpEKMkB5OSKO+xEo5w Ib6k/JTKjMTijPii0pzU4kOMMhwcShK8B6cD5QSLUtNTK9Iyc4AhDpOW4OBREuENBEnzFhck5 hZnpkOkTjEqSonzfgRJCIAkMkrz4NpgcXWJUVZKmJcR6BAhnoLUotzMElT5V4ziHIxKwrwzQK bwZOaVwE1/BbSYCWjxBX42kMUliQgpqQZGvVObZ5ZuX87X/KszvV1CTkfmnIX8q9sL3mi0usY 0XBT5/jReMVQ4/Iyzv+WZKyLRzz8Uckx5FHz3fleBXMI/+eW/stIsavd0cwvKu14MmCh9o6Z8 gcIu57k7LObvd75ZfGBtQt1k/1qju8UTH5btPsEfdepDk1e6wdwv3kIdq7bvX/Zlat1EJZbij ERDLeai4kQAwnxWiaYCAAA= X-Env-Sender: rcojocaru@bitdefender.com X-Msg-Ref: server-6.tower-31.messagelabs.com!1460181270!7629355!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 57498 invoked from network); 9 Apr 2016 05:54:30 -0000 Received: from mx01.bbu.dsd.mx.bitdefender.com (HELO mx01.bbu.dsd.mx.bitdefender.com) (91.199.104.161) by server-6.tower-31.messagelabs.com with DHE-RSA-AES128-GCM-SHA256 encrypted SMTP; 9 Apr 2016 05:54:30 -0000 Received: (qmail 25425 invoked from network); 9 Apr 2016 08:54:29 +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; 9 Apr 2016 08:54:29 +0300 Received: from smtp02.buh.bitdefender.net (unknown [10.17.80.76]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id 517007FBF5 for ; Sat, 9 Apr 2016 08:54:29 +0300 (EEST) Received: (qmail 15000 invoked from network); 9 Apr 2016 08:54:29 +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; 9 Apr 2016 08:54:29 +0300 From: Razvan Cojocaru To: xen-devel@lists.xen.org Date: Sat, 9 Apr 2016 08:54:09 +0300 Message-Id: <1460181249-13651-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.65080 X-BitDefender-Spam: No (0) X-BitDefender-SpamStamp: Build: [Engines: 2.15.6.911, Dats: 419434, Stamp: 3], Multi: [Enabled, t: (0.000008, 0.001854)], BW: [Enabled, t: (0.000007,0.000001)], RBL DNSBL: [Disabled], APM: [Enabled, Score: 500, t: (0.002392), 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.007719)], URL: [Enabled, t: (0.000005)], RTDA: [Enabled, t: (0.013791), Hit: No, Details: v2.3.6; Id: 2m1ghaq.1afqfv9ok.m52e], 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 V3] 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 Reviewed-by: Andrew Cooper Acked-by: Tamas K Lengyel --- Changes since V2: - Updated the if() condition as recommended by Andrew Cooper. - Added Andrew Cooper's Reviewed-by. --- 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..d367099 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->max_vcpus && d->vcpu[0] && 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,