From patchwork Wed Nov 15 13:47:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Pop X-Patchwork-Id: 10059417 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 701E16019D for ; Wed, 15 Nov 2017 13:51:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60E5C2A019 for ; Wed, 15 Nov 2017 13:51:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55D522A01F; Wed, 15 Nov 2017 13:51:00 +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 2F36D2A01E for ; Wed, 15 Nov 2017 13:50:58 +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 1eEy30-0004we-43; Wed, 15 Nov 2017 13:48:10 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eEy2z-0004wY-53 for xen-devel@lists.xen.org; Wed, 15 Nov 2017 13:48:09 +0000 Received: from [193.109.254.147] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-4.bemta-6.messagelabs.com id 2E/0F-30895-8954C0A5; Wed, 15 Nov 2017 13:48:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsUSfTxjoe50V54 og0W/zS2WfFzM4sDocXT3b6YAxijWzLyk/IoE1owrl66zFVzgrtg49yNTA+Mvji5GTg4hAQ+J o8s+MkPYaxklruxU7mLkArKvMkrsOdTLDlN0a8MqNojEbkaJhdOeMYIk2ATUJTbv3cIKYosIS Etc+3yZEaSIWWAmo0Tvkn4WkISwgKfE9MYdYDaLgKrEydY1YDavgKXExZebwVZLCMhLLP6+E2 gDB5CdI3FkXSaEKSXxv1UJZKSEQD+LxMZvDSwQ5TISjybeZJvAKLCAkWEVo0ZxalFZapGusaF eUlFmekZJbmJmjq6hgZlebmpxcWJ6ak5iUrFecn7uJkZgYDEAwQ7GpkWBhxglOZiURHmdf3NH CfEl5adUZiQWZ8QXleakFh9ilOHgUJLgLXbhiRISLEpNT61Iy8wBhjhMWoKDR0mEtxAkzVtck JhbnJkOkTrFaMzxbObrBmaOaVdbm5iFWPLy81KlxHldQEoFQEozSvPgBsFi7xKjrJQwLyPQaU I8BalFuZklqPKvGMU5GJWEeetApvBk5pXA7XsFdAoT0Ck2N7hBTilJREhJNTBq+culB6dUf/9 481v3zqWKCb9fLtB7PvkC40WDiZuOZ5ntZbuU9XvvjrJL1x4+PDxD2LH3Cd9ec063y+seLDKK fGg7zfKw+cHnCYelPi6P8VnFGO+3/T/zlx3/Py5K8s7l9ZsWf36N4bSmJYc8l8fN2RcnOm2yc Vjm9si2PK7NUtG2qir+0n+uKLEUZyQaajEXFScCAB0ZzJm4AgAA X-Env-Sender: apop@bitdefender.com X-Msg-Ref: server-9.tower-27.messagelabs.com!1510753687!116722985!1 X-Originating-IP: [91.199.104.161] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33831 invoked from network); 15 Nov 2017 13:48:07 -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; 15 Nov 2017 13:48:07 -0000 Received: (qmail 31783 invoked from network); 15 Nov 2017 15:48:05 +0200 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; 15 Nov 2017 15:48:05 +0200 Received: from smtp02.buh.bitdefender.net (smtp.bitdefender.biz [10.17.80.76]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id C952B7FBFF for ; Wed, 15 Nov 2017 15:48:05 +0200 (EET) Received: (qmail 25241 invoked from network); 15 Nov 2017 15:48:05 +0200 Received: from unknown (HELO hel.clj.bitdefender.biz) (apop@bitdefender.com@10.220.12.75) by smtp02.buh.bitdefender.net with AES128-GCM-SHA256 encrypted SMTP; 15 Nov 2017 15:48:05 +0200 From: Adrian Pop To: xen-devel@lists.xen.org Date: Wed, 15 Nov 2017 15:47:59 +0200 Message-Id: <20171115134759.14398-1-apop@bitdefender.com> X-Mailer: git-send-email 2.15.0 X-BitDefender-Scanner: Clean, Agent: BitDefender qmail 3.1.6 on smtp02.buh.bitdefender.net, sigver: 7.73821 X-BitDefender-Spam: No (0) X-BitDefender-SpamStamp: Build: [Engines: 2.15.8.1074, Dats: 466835, Stamp: 3], Multi: [Enabled, t: (0.000008, 0.004694)], BW: [Enabled, t: (0.000007)], RBL DNSBL: [Disabled], APM: [Enabled, Score: 500, t: (0.002588), 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.007855,0.000063)], URL: [Enabled, t: (0.000005)], RTDA: [Enabled, t: (0.093593), Hit: No, Details: v2.6.15; Id: 15.5f4pg8.1btospqtr.g423j], total: 0(775) X-BitDefender-CF-Stamp: none Cc: Andrew Cooper , Julien Grall , Jan Beulich , Adrian Pop Subject: [Xen-devel] [PATCH v2] x86/hvm: Fix altp2m_vcpu_enable_notify error handling 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 The altp2m_vcpu_enable_notify subop handler might skip calling rcu_unlock_domain() after rcu_lock_current_domain(). Albeit since both rcu functions are no-ops when run on the current domain, this doesn't really have repercussions. The second change is adding a missing break that would have potentially enabled #VE for the current domain even if it had intended to enable it for another one (not a supported functionality). Signed-off-by: Adrian Pop Reviewed-by: Andrew Cooper Reviewed-by: Jan Beulich --- changes in v2: - reword the commit message --- xen/arch/x86/hvm/hvm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 205b4cb685..0af498a312 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4534,12 +4534,18 @@ static int do_altp2m_op( if ( a.u.enable_notify.pad || a.domain != DOMID_SELF || a.u.enable_notify.vcpu_id != curr->vcpu_id ) + { rc = -EINVAL; + break; + } if ( !gfn_eq(vcpu_altp2m(curr).veinfo_gfn, INVALID_GFN) || mfn_eq(get_gfn_query_unlocked(curr->domain, a.u.enable_notify.gfn, &p2mt), INVALID_MFN) ) - return -EINVAL; + { + rc = -EINVAL; + break; + } vcpu_altp2m(curr).veinfo_gfn = _gfn(a.u.enable_notify.gfn); altp2m_vcpu_update_vmfunc_ve(curr);