From patchwork Sat Jul 9 04:23:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corneliu ZUZU X-Patchwork-Id: 9222001 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 6627D60572 for ; Sat, 9 Jul 2016 04:27:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 580AF28622 for ; Sat, 9 Jul 2016 04:27:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C3CC2862F; Sat, 9 Jul 2016 04:27:01 +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 CE90F28622 for ; Sat, 9 Jul 2016 04:27:00 +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 1bLjp1-0003bF-Bh; Sat, 09 Jul 2016 04:24:55 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bLjoz-0003at-Qj for xen-devel@lists.xen.org; Sat, 09 Jul 2016 04:24:53 +0000 Received: from [85.158.137.68] by server-5.bemta-3.messagelabs.com id 99/E0-02783-59C70875; Sat, 09 Jul 2016 04:24:53 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDIsWRWlGSWpSXmKPExsUSfTxjoe6UmoZ wg9YVahZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aXRUvYCybxVSy++ZC5gfEAdxcjJ4eQgLvE zct32boYuYDsNYwS99+8ZoVwTjJK7Dz0lh2iyk3i8osGqKp1jBK/pq1gAUmwCWhLnDt0jwnEF hGQlrj2+TIjSBGzwFJGidlfXoJ1CwskSnx/vIAVxGYRUJVo2PsbrJlXwEXi+P9FQDYHh4SAnM SCC+kgYU4BV4lzb1+zQix2kbixbxLYfAmBHImVz2axQ5RLSfxvVQJZJSHQzSLxYkoDK0SNjMS jiTfZJjAKLWBkWMWoUZxaVJZapGtkppdUlJmeUZKbmJmja2hgrJebWlycmJ6ak5hUrJecn7uJ ERiK9QwMjDsYG/b6HWKU5GBSEuW9YNsQLsSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mCt7IaKCdYl JqeWpGWmQOMCpi0BAePkgjvZJA0b3FBYm5xZjpE6hSjopQ4bwNIQgAkkVGaB9cGi8RLjLJSwr yMDAwMQjwFqUW5mSWo8q8YxTkYlYR5F4BM4cnMK4Gb/gpoMRPQYoOAepDFJYkIKakGxv4X0mc P9V9Tql0inpbXdK1amvHo4kWs2UrfDrY/1zDzW6M8N+T62q5XTa3ra7JMl8lVWjxK2rx6l8y7 LfwyrR9Phei3vGly85b/v6GJReP/LUUn5xdS1ZYSNxierjnFUrPCr+ikloLrbO6v1S1REj0X1 xWI7i9tWLgs/xmT5I1XSy8cO6D+SomlOCPRUIu5qDgRADu6eqq/AgAA X-Env-Sender: czuzu@bitdefender.com X-Msg-Ref: server-14.tower-31.messagelabs.com!1468038292!49628685!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.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 1822 invoked from network); 9 Jul 2016 04:24:52 -0000 Received: from mx01.bbu.dsd.mx.bitdefender.com (HELO mx01.bbu.dsd.mx.bitdefender.com) (91.199.104.161) by server-14.tower-31.messagelabs.com with DHE-RSA-AES128-GCM-SHA256 encrypted SMTP; 9 Jul 2016 04:24:52 -0000 Received: (qmail 12254 invoked from network); 9 Jul 2016 07:24:51 +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 Jul 2016 07:24:51 +0300 Received: from smtp03.buh.bitdefender.org (unknown [10.17.80.77]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id CAD877FC00 for ; Sat, 9 Jul 2016 07:24:51 +0300 (EEST) Received: (qmail 4681 invoked from network); 9 Jul 2016 07:24:51 +0300 Received: from 188-24-34-246.rdsnet.ro (HELO localhost.localdomain) (czuzu@bitdefender.com@188.24.34.246) by smtp03.buh.bitdefender.org with SMTP; 9 Jul 2016 07:24:51 +0300 From: Corneliu ZUZU To: xen-devel@lists.xen.org Date: Sat, 9 Jul 2016 07:23:56 +0300 Message-Id: <1468038236-7172-1-git-send-email-czuzu@bitdefender.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1468037509-6428-1-git-send-email-czuzu@bitdefender.com> References: <1468037509-6428-1-git-send-email-czuzu@bitdefender.com> X-BitDefender-Scanner: Clean, Agent: BitDefender qmail 3.1.6 on smtp03.buh.bitdefender.org, sigver: 7.66242 X-BitDefender-Spam: No (0) X-BitDefender-SpamStamp: Build: [Engines: 2.15.6.911, Dats: 425852, Stamp: 3], Multi: [Enabled, t: (0.000008, 0.002414)], BW: [Enabled, t: (0.000007,0.000001)], RBL DNSBL: [Disabled], APM: [Enabled, Score: 500, t: (0.002493), Flags: 85D2ED72; 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.008591)], URL: [Enabled, t: (0.000006)], RTDA: [Enabled, t: (0.016111), Hit: No, Details: v2.3.10; Id: 2m1ghic.1aml0sh1c.u9mj], total: 0(775) X-BitDefender-CF-Stamp: none Cc: Andrew Cooper , Tamas K Lengyel , Jan Beulich , Razvan Cojocaru Subject: [Xen-devel] [PATCH 16/16] x86/monitor: fix: xc_monitor _write_ctrlreg w/o previous _enable must fail 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 Enforce presence of a monitor vm-event subscriber when the toolstack user calls xc_monitor_write_ctrlreg() (XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG domctl). Without this change, "ASSERT(monitor_domain_initialised(v->domain));" @ hvm_set_cr0() and such would fail if the toolstack user calls xc_monitor_write_ctrlreg(...) w/ enable = true, without first calling xc_monitor_enable(). Also adjust returned error code for similar check from -EINVAL to more descriptive -ENODEV (XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP). Signed-off-by: Corneliu ZUZU --- xen/arch/x86/monitor.c | 4 ++++ xen/include/asm-x86/monitor.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/monitor.c b/xen/arch/x86/monitor.c index 05a2f0d..4cf018a 100644 --- a/xen/arch/x86/monitor.c +++ b/xen/arch/x86/monitor.c @@ -324,6 +324,10 @@ int arch_monitor_domctl_event(struct domain *d, unsigned int ctrlreg_bitmask; bool_t old_status; + /* Meaningless without a monitor vm-events subscriber. */ + if ( unlikely(!monitor_domain_initialised(d)) ) + return -ENODEV; + /* sanity check: avoid left-shift undefined behavior */ if ( unlikely(mop->u.mov_to_cr.index > 31) ) return -EINVAL; diff --git a/xen/include/asm-x86/monitor.h b/xen/include/asm-x86/monitor.h index 11497ef..a6022db 100644 --- a/xen/include/asm-x86/monitor.h +++ b/xen/include/asm-x86/monitor.h @@ -47,7 +47,7 @@ int arch_monitor_domctl_op(struct domain *d, struct xen_domctl_monitor_op *mop) if ( likely(monitor_domain_initialised(d)) ) d->arch.mem_access_emulate_each_rep = !!mop->event; else - rc = -EINVAL; + rc = -ENODEV; domain_unpause(d); break;