From patchwork Thu Apr 4 16:25:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Druzhinin X-Patchwork-Id: 10885907 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A0BEB1575 for ; Thu, 4 Apr 2019 16:28:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8884528ABF for ; Thu, 4 Apr 2019 16:28:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A2F328A97; Thu, 4 Apr 2019 16:28: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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 01F7C28A97 for ; Thu, 4 Apr 2019 16:27:58 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hC5BY-0007ai-KR; Thu, 04 Apr 2019 16:25:52 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hC5BX-0007ad-AY for xen-devel@lists.xenproject.org; Thu, 04 Apr 2019 16:25:51 +0000 X-Inumbo-ID: 4d9f0fd0-56f6-11e9-8532-0b6f12bc888f Received: from SMTP03.CITRIX.COM (unknown [162.221.156.55]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 4d9f0fd0-56f6-11e9-8532-0b6f12bc888f; Thu, 04 Apr 2019 16:25:48 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.60,308,1549929600"; d="scan'208";a="82766863" From: Igor Druzhinin To: Date: Thu, 4 Apr 2019 17:25:10 +0100 Message-ID: <1554395110-22095-1-git-send-email-igor.druzhinin@citrix.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2] x86/vmx: Fixup removals of MSR load/save list entries X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Igor Druzhinin , kevin.tian@intel.com, wei.liu2@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, jun.nakajima@intel.com, roger.pau@citrix.com Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Commit 540d5422 ("x86/vmx: Support removing MSRs from the host/guest load/save lists") introduced infrastructure finally exposed by commit fd32dcfe ("x86/vmx: Don't leak EFER.NXE into guest context") that led to a functional regression on Harpertown and earlier cores (Gen 1 VT-x) due to MSR count being incorrectly set in VMCS. As the result, as soon as guest EFER becomes equal to Xen EFER (which eventually happens in almost every 64-bit VM) and its MSR entry is supposed to be removed, a stale version of EFER is loaded into a guest instead causing almost immediate guest failure. Reviewed-by: Andrew Cooper Reviewed-by: Jan Beulich Signed-off-by: Igor Druzhinin --- Changes in v2: * better commit description as suggested --- xen/arch/x86/hvm/vmx/vmcs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c index 74f2a08..45d1849 100644 --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -1490,15 +1490,15 @@ int vmx_del_msr(struct vcpu *v, uint32_t msr, enum vmx_msr_list_type type) switch ( type ) { case VMX_MSR_HOST: - __vmwrite(VM_EXIT_MSR_LOAD_COUNT, vmx->host_msr_count--); + __vmwrite(VM_EXIT_MSR_LOAD_COUNT, --vmx->host_msr_count); break; case VMX_MSR_GUEST: - __vmwrite(VM_EXIT_MSR_STORE_COUNT, vmx->msr_save_count--); + __vmwrite(VM_EXIT_MSR_STORE_COUNT, --vmx->msr_save_count); /* Fallthrough */ case VMX_MSR_GUEST_LOADONLY: - __vmwrite(VM_ENTRY_MSR_LOAD_COUNT, vmx->msr_load_count--); + __vmwrite(VM_ENTRY_MSR_LOAD_COUNT, --vmx->msr_load_count); break; }