From patchwork Wed Jul 6 15:52:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corneliu ZUZU X-Patchwork-Id: 9216577 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 72AC360467 for ; Wed, 6 Jul 2016 15:55:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6481626E8A for ; Wed, 6 Jul 2016 15:55:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5919C2715B; Wed, 6 Jul 2016 15:55:24 +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 D260326E8A for ; Wed, 6 Jul 2016 15:55: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 1bKp8c-0001lf-CM; Wed, 06 Jul 2016 15:53:22 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKp8b-0001lK-5s for xen-devel@lists.xen.org; Wed, 06 Jul 2016 15:53:21 +0000 Received: from [193.109.254.147] by server-2.bemta-14.messagelabs.com id A0/87-29243-0792D775; Wed, 06 Jul 2016 15:53:20 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrFIsWRWlGSWpSXmKPExsUSfTxjoW6+Zm2 4wYe7lhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0bnt2UsBQv5Kl43NjI3MK7n7mLk5BAScJP4 17SPtYuRC8hewyhx+fNvNgjnJKNEe+dSFogqd4nu9p0sEIlVjBIfnq9iA0mwCWhLnDt0jwnEF hGQlrj2+TIjSBGzwFJGidlfXrKDJIQFIiR2nnoDNolFQFViftMMsAZeAVeJu8ueA9VwcEgIyE ksuJAOYnICnXTncTXEXleJRQsvMoPYEgI5EltPPWCEqJaS+N+qBLJJQqCbRWLzl1usEDUyEo8 m3mSbwCi0gJFhFaN6cWpRWWqRrqVeUlFmekZJbmJmjq6hoYlebmpxcWJ6ak5iUrFecn7uJkZg GDIAwQ7G/inOhxglOZiURHlZvlWHC/El5adUZiQWZ8QXleakFh9ilOHgUJLgtdaoDRcSLEpNT 61Iy8wBRgRMWoKDR0mENwQkzVtckJhbnJkOkTrFqCglzlsJkhAASWSU5sG1waLwEqOslDAvI9 AhQjwFqUW5mSWo8q8YxTkYlYR514NM4cnMK4Gb/gpoMRPQ4p8u1SCLSxIRUlINjHP50yQC+Lj Ofz4k1ai416/pgSPHw5vrOFbrPvLRfPIlgMO1fJWfDK/pZZXDjBebnu59+NZV6tiKfz9ML0vJ xcqypN3dVGUfwNaZ0Cm0Y1HcB2e95Qn9j++ZW0y/ku99J3bPJu0l0TVyy2WkXunc1BFUMf9sY L2r+cn9yhb+gnfhOxVfbbgXqcRSnJFoqMVcVJwIANQAlRO9AgAA X-Env-Sender: czuzu@bitdefender.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1467820399!50290156!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 28690 invoked from network); 6 Jul 2016 15:53:19 -0000 Received: from mx01.bbu.dsd.mx.bitdefender.com (HELO mx01.bbu.dsd.mx.bitdefender.com) (91.199.104.161) by server-2.tower-27.messagelabs.com with DHE-RSA-AES128-GCM-SHA256 encrypted SMTP; 6 Jul 2016 15:53:19 -0000 Received: (qmail 3480 invoked from network); 6 Jul 2016 18:53:18 +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; 6 Jul 2016 18:53:18 +0300 Received: from smtp03.buh.bitdefender.org (unknown [10.17.80.77]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id BA7DC7FC00 for ; Wed, 6 Jul 2016 18:53:18 +0300 (EEST) Received: (qmail 22261 invoked from network); 6 Jul 2016 18:53:18 +0300 Received: from unknown (HELO czuzu-dev-vm.clj.bitdefender.biz) (czuzu@bitdefender.com@91.199.104.243) by smtp03.buh.bitdefender.org with SMTP; 6 Jul 2016 18:53:18 +0300 From: Corneliu ZUZU To: xen-devel@lists.xen.org Date: Wed, 6 Jul 2016 18:52:58 +0300 Message-Id: <1467820378-13448-1-git-send-email-czuzu@bitdefender.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1467820154-13256-1-git-send-email-czuzu@bitdefender.com> References: <1467820154-13256-1-git-send-email-czuzu@bitdefender.com> X-BitDefender-Scanner: Clean, Agent: BitDefender qmail 3.1.6 on smtp03.buh.bitdefender.org, sigver: 7.66204 X-BitDefender-Spam: No (0) X-BitDefender-SpamStamp: Build: [Engines: 2.15.6.911, Dats: 425554, Stamp: 3], Multi: [Enabled, t: (0.000008, 0.002411)], BW: [Enabled, t: (0.000006,0.000001)], RBL DNSBL: [Disabled], APM: [Enabled, Score: 500, t: (0.002650), Flags: BB9BAF5C; 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.007451)], URL: [Enabled, t: (0.000005)], RTDA: [Enabled, t: (0.017679), Hit: No, Details: v2.3.10; Id: 2m1ghhc.1amgks2k3.q8vm], total: 0(775) X-BitDefender-CF-Stamp: none Cc: Andrew Cooper , Tamas K Lengyel , Jan Beulich , Razvan Cojocaru Subject: [Xen-devel] [PATCH v3 4/8] x86/vm_event/monitor/cr: check for vm-event subscriber on domctl 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(v->arch.vm_event) @ 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 -ENOSYS (XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP). Signed-off-by: Corneliu ZUZU --- xen/arch/x86/monitor.c | 7 +++++++ xen/include/asm-x86/monitor.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/monitor.c b/xen/arch/x86/monitor.c index 42f31bf..4d4db33 100644 --- a/xen/arch/x86/monitor.c +++ b/xen/arch/x86/monitor.c @@ -188,6 +188,13 @@ int arch_monitor_domctl_event(struct domain *d, unsigned int ctrlreg_bitmask; bool_t old_status; + /* + * Enabling cr-write vm-events without a vm_event subscriber is + * meaningless. + */ + if ( !vm_event_domain_initialised(d) ) + return -ENOSYS; + /* 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 9238ec8..2213124 100644 --- a/xen/include/asm-x86/monitor.h +++ b/xen/include/asm-x86/monitor.h @@ -52,7 +52,7 @@ int arch_monitor_domctl_op(struct domain *d, struct xen_domctl_monitor_op *mop) if ( vm_event_domain_initialised(d) ) d->arch.mem_access_emulate_each_rep = !!mop->event; else - rc = -EINVAL; + rc = -ENOSYS; domain_unpause(d); break;