From patchwork Tue Mar 21 18:17:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 9637265 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 B207360216 for ; Tue, 21 Mar 2017 18:19:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8BF92041F for ; Tue, 21 Mar 2017 18:19:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D85C2830A; Tue, 21 Mar 2017 18:19:40 +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 4E5332041F for ; Tue, 21 Mar 2017 18:19:40 +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 1cqOLZ-0000V2-MG; Tue, 21 Mar 2017 18:17:29 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cqOLY-0000UF-7X for xen-devel@lists.xenproject.org; Tue, 21 Mar 2017 18:17:28 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id F3/C4-27751-73E61D85; Tue, 21 Mar 2017 18:17:27 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkkeJIrShJLcpLzFFi42JxWrrBXtc872K EwYaLPBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bT5ykFswUrlsz5wt7AuIivi5GTQ0LAX2LX t+eMIDabgI7E1KeXWLsYOThEBFQkbu81ADGZBcolOibUglQIC4RKtH78zgxiswioSnw//IEdx OYVcJPY+vg8I8REOYnzx3+C1XAKuEt827QJLC4EVNPdeZAJwlaRWD91FhtEr6DEyZlPWEBsZg EJiYMvXjBPYOSdhSQ1C0lqASPTKkb14tSistQiXUO9pKLM9IyS3MTMHF1DAzO93NTi4sT01Jz EpGK95PzcTYzAoGEAgh2MO587HWKU5GBSEuVNdLoYIcSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mC 92UOUE6wKDU9tSItMwcYvjBpCQ4eJRHeNyBp3uKCxNzizHSI1ClGRSlx3tkgCQGQREZpHlwbL GYuMcpKCfMyAh0ixFOQWpSbWYIq/4pRnINRSZj3LMgUnsy8Erjpr4AWMwEtLttzAWRxSSJCSq qB0ce3dkrLnmmRr/OUsw5UHFSJ6ftpNM1jetexyuIb37b8v1XVo6p2k+Xqj8D/hec7vDfX6Lz +d64vtbSd+dRihlkRptNeJK6p/Z4gaFgid2y6Kb/7m5Tkvmzvz79OB2SXxu/Ov7LS851QwcxH Tw7bXODI7m5aHq/5037L0Qdf1rJWzJq7a/NyVyWW4oxEQy3mouJEAJJJAl+UAgAA X-Env-Sender: prvs=246d8669f=Paul.Durrant@citrix.com X-Msg-Ref: server-9.tower-21.messagelabs.com!1490120244!63374732!2 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8105 invoked from network); 21 Mar 2017 18:17:26 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-9.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 21 Mar 2017 18:17:26 -0000 X-IronPort-AV: E=Sophos;i="5.36,200,1486425600"; d="scan'208";a="424078514" From: Paul Durrant To: Date: Tue, 21 Mar 2017 18:17:17 +0000 Message-ID: <1490120242-3587-2-git-send-email-paul.durrant@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1490120242-3587-1-git-send-email-paul.durrant@citrix.com> References: <1490120242-3587-1-git-send-email-paul.durrant@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Paul Durrant , Jan Beulich Subject: [Xen-devel] [PATCH v3 1/6] x86/viridian: fix xen-hvmcrash when vp_assist page is present 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently use of xen-hvmcrash will cause an immediate domain_crash() in initialize_vp_assist() because it is called from viridian_load_vcpu_ctxt() without having first cleared any previous mapping. This patch addes a check into viridian_load_vcpu_ctxt() to avoid re- initialization and turned the domain_crash() in initialize_vp_assist() into an ASSERT() since neither codepath into that function should allow it to be hit. Signed-off-by: Paul Durrant Reviewed-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper v3: - Slightly too much simplification in v2... missing hunk re-instated v2: - Patch significantly simplified --- xen/arch/x86/hvm/viridian.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/hvm/viridian.c b/xen/arch/x86/hvm/viridian.c index f2c9613..a71f928 100644 --- a/xen/arch/x86/hvm/viridian.c +++ b/xen/arch/x86/hvm/viridian.c @@ -283,6 +283,8 @@ static void initialize_vp_assist(struct vcpu *v) struct page_info *page = get_page_from_gfn(d, gmfn, NULL, P2M_ALLOC); void *va; + ASSERT(!v->arch.hvm_vcpu.viridian.vp_assist.va); + /* * See section 7.8.7 of the specification for details of this * enlightenment. @@ -306,14 +308,6 @@ static void initialize_vp_assist(struct vcpu *v) clear_page(va); - /* - * If we overwrite an existing address here then something has - * gone wrong and a domain page will leak. Instead crash the - * domain to make the problem obvious. - */ - if ( v->arch.hvm_vcpu.viridian.vp_assist.va ) - domain_crash(d); - v->arch.hvm_vcpu.viridian.vp_assist.va = va; return; @@ -904,7 +898,8 @@ static int viridian_load_vcpu_ctxt(struct domain *d, hvm_domain_context_t *h) return -EINVAL; v->arch.hvm_vcpu.viridian.vp_assist.msr.raw = ctxt.vp_assist_msr; - if ( v->arch.hvm_vcpu.viridian.vp_assist.msr.fields.enabled ) + if ( v->arch.hvm_vcpu.viridian.vp_assist.msr.fields.enabled && + !v->arch.hvm_vcpu.viridian.vp_assist.va ) initialize_vp_assist(v); v->arch.hvm_vcpu.viridian.vp_assist.vector = ctxt.vp_assist_vector;