Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1375346rdh; Mon, 25 Sep 2023 10:44:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGeJkgpDmNzvlFTISLBKaP7JAYdsE+9FD00wV2nFcBehaHApQj+OBF+LDvXdEXSU3s7WciO X-Received: by 2002:a05:6359:b9d:b0:143:4d08:b9d7 with SMTP id gf29-20020a0563590b9d00b001434d08b9d7mr4689058rwb.3.1695663842056; Mon, 25 Sep 2023 10:44:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695663842; cv=none; d=google.com; s=arc-20160816; b=JwbqUU4raY5yYrKOnMfrx97exiW70BhoFXBZSGEWqSLmjWLT1XVGV+8HAhBAHCMbuI ITN1J1PeQyleBdyvPXtkoPlcgvaTJzKEWyKqUTCttDeWGitfyfEvz1VS8YjXI14zaP9Q soJtUUg72934WiL0449VRNcLnDlPOlM65p8iZ3Jh1RY/UG/ju2f2q1B7Zqgj6ArplUfv b15FCbBf8dkqZHaWimTM9gQBdq74G2elj+OtmjiEAHuNG//n6Xx8OG8VOGWbYdzI7m7Y xPHMGk8+dKhMDwzpWUxImliMNR4VIMm5lh5EJVorx7q3KAdgTiozFh3CXQ8IbgYdY3Gh gwBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Ulz5jqoozPNB/Dflyt3YbONzTFybvz9l0rgb9t+tTVg=; fh=Gzo+TLrcol0cjj/at0ul+RicjnRduX6P0/Jh30jtQto=; b=cWfLjcJ94FFFd3z+zQ0mkQCzB8bNipqcYlqo2M+8K+StFwzg094PqmzTAJyqDWg4Tn 64qQv1x0w4H9f1200pJC3kXw6BL4veIUJ3k7qHywTdVpGi3YaD3G1bJ9WhlrQxANMWz8 IRiNbOf6HfxbB0FLVS6XV9DgJgilI1Wu12cDCXBRV3HDa4gt1G0NYRFX1a/lMBs5AFQd I7/t23chk9j/re/PXqfyn36Q/NG1uR6PgH0RCQw2wPJM4U2nVSmSuGgUo8V2tZBRri1X j5+1sR0iCMYAMnt0kN4Rgy7kEpX0Tvqp222mKU3ImwExhTXZ+s4Iwg/LPCNgJ3gPgeFy cUQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id w1-20020a63c101000000b005653316de6fsi10627354pgf.271.2023.09.25.10.44.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 10:44:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 62052807529B; Mon, 25 Sep 2023 09:37:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230184AbjIYQhC (ORCPT + 99 others); Mon, 25 Sep 2023 12:37:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229522AbjIYQhB (ORCPT ); Mon, 25 Sep 2023 12:37:01 -0400 Received: from vps-vb.mhejs.net (vps-vb.mhejs.net [37.28.154.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F343BE; Mon, 25 Sep 2023 09:36:53 -0700 (PDT) Received: from MUA by vps-vb.mhejs.net with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qkoZi-0000e3-OE; Mon, 25 Sep 2023 18:36:46 +0200 From: "Maciej S. Szmigiero" To: Paolo Bonzini , Sean Christopherson Cc: Borislav Petkov , kvm@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] KVM: x86: Ignore MSR_AMD64_BU_CFG access Date: Mon, 25 Sep 2023 18:36:40 +0200 Message-ID: <0ffde769702c6cdf6b6c18e1dcb28b25309af7f7.1695659717.git.maciej.szmigiero@oracle.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 25 Sep 2023 09:37:07 -0700 (PDT) From: "Maciej S. Szmigiero" Hyper-V enabled Windows Server 2022 KVM VM cannot be started on Zen1 Ryzen since it crashes at boot with SYSTEM_THREAD_EXCEPTION_NOT_HANDLED + STATUS_PRIVILEGED_INSTRUCTION (in other words, because of an unexpected #GP in the guest kernel). This is because Windows tries to set bit 8 in MSR_AMD64_BU_CFG and can't handle receiving a #GP when doing so. Give this MSR the same treatment that commit 2e32b7190641 ("x86, kvm: Add MSR_AMD64_BU_CFG2 to the list of ignored MSRs") gave MSR_AMD64_BU_CFG2 under justification that this MSR is baremetal-relevant only. Although apparently it was then needed for Linux guests, not Windows as in this case. With this change, the aforementioned guest setup is able to finish booting successfully. This issue can be reproduced either on a Summit Ridge Ryzen (with just "-cpu host") or on a Naples EPYC (with "-cpu host,stepping=1" since EPYC is ordinarily stepping 2). Signed-off-by: Maciej S. Szmigiero --- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kvm/x86.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index 1d111350197f..c80a5cea80c4 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -553,6 +553,7 @@ #define MSR_AMD64_CPUID_FN_1 0xc0011004 #define MSR_AMD64_LS_CFG 0xc0011020 #define MSR_AMD64_DC_CFG 0xc0011022 +#define MSR_AMD64_BU_CFG 0xc0011023 #define MSR_AMD64_DE_CFG 0xc0011029 #define MSR_AMD64_DE_CFG_LFENCE_SERIALIZE_BIT 1 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 9f18b06bbda6..2f3cdd798185 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3639,6 +3639,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) case MSR_IA32_UCODE_WRITE: case MSR_VM_HSAVE_PA: case MSR_AMD64_PATCH_LOADER: + case MSR_AMD64_BU_CFG: case MSR_AMD64_BU_CFG2: case MSR_AMD64_DC_CFG: case MSR_F15H_EX_CFG: @@ -4062,6 +4063,7 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) case MSR_K8_INT_PENDING_MSG: case MSR_AMD64_NB_CFG: case MSR_FAM10H_MMIO_CONF_BASE: + case MSR_AMD64_BU_CFG: case MSR_AMD64_BU_CFG2: case MSR_IA32_PERF_CTL: case MSR_AMD64_DC_CFG: