Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp460242rdb; Thu, 19 Oct 2023 09:07:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHuziO50BuHCCBN2OtP8ZSD27i/dtHUUtz/CoM3FKR/G9vKpyOnuLOLplP1GJK3x2iaRHrP X-Received: by 2002:a17:90b:288c:b0:27d:5562:7e13 with SMTP id qc12-20020a17090b288c00b0027d55627e13mr2454787pjb.39.1697731670002; Thu, 19 Oct 2023 09:07:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697731669; cv=none; d=google.com; s=arc-20160816; b=sope3pt/7+5oRkVZhXZp8iY0ILzP1T+mVJrrafPawqwMgBwOdRVh6SKNS4JrPTqfmx yx7OcsxY3KfhEtbGeTRpMOaGTQxOhmTJWIpyYfcmN3leZjdOZWNqVnJdju+3/lw+m/P7 RR7TKriXKNNiRJHZV3g+NNrKzXGCS/rKtSOzasjm7RUb4Sv4HDGfAxIlJIIHE2Gx9drU hJw1pgy0Kq+bsa4RyhvFIQK5yQ1Avfk47W/h03NrhZ0n37mZ45bkYU+CJSy8xd3XE/cq E9mjHG+GUUA9Rekzn8v5hDEUql9Dq8zGW6eDl1+Z8Bi3yFQ/JBuqGSPkgmBPiL5eoFzk 4eZQ== 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=JmfvUKea1w+riK+e5GvSW6G20IOyeXAMbdwCSKCP7o0=; fh=atMFuU+94Y/5/FRMHclDVlsbwaiZpf8Wjrnv4ryjx5c=; b=bF2CbajGXGogzDnHoS7kfvrdnmc7eC91e94XIfIB8bw9kk4BuJ+RsxqL7+qSvN9qCr z828/mdStfEN+xnErK/gEDT3Flz/TLruO+jZO9Z8SiqmfDZvM8+xjBQ3mE3oGQJ7hyKb eJpKEVLLFvwbUBRz7nENL6UTtYv1HVLclyWf+5oUID9i1Hb1lTG2TbUgT19+3pMgtHYj 8hooCYYvLi7ruK1JTqv6DsFbs9YI1zqk/1uaMz923M2e0mPmbBaOYFp8JL2mD4BqPn0S tvpXM0W9y7JMJEZ4VRKrPyLIj7CwBCWSA2wD27L5HeI4LYXlugKr6H+YRLUr5vmicawh GM8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id mi11-20020a17090b4b4b00b0027ced8e1837si2435611pjb.180.2023.10.19.09.07.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 09:07:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id BF747833939C; Thu, 19 Oct 2023 09:07:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346120AbjJSQHc (ORCPT + 99 others); Thu, 19 Oct 2023 12:07:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230297AbjJSQHb (ORCPT ); Thu, 19 Oct 2023 12:07:31 -0400 Received: from vps-vb.mhejs.net (vps-vb.mhejs.net [37.28.154.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A2C6112; Thu, 19 Oct 2023 09:07:28 -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 1qtVY7-0001kb-9C; Thu, 19 Oct 2023 18:07:03 +0200 From: "Maciej S. Szmigiero" To: Paolo Bonzini , Sean Christopherson Cc: Tom Lendacky , Borislav Petkov , Thomas Gleixner , Ingo Molnar , Dave Hansen , "H. Peter Anvin" , kvm@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] KVM: x86: Ignore MSR_AMD64_TW_CFG access Date: Thu, 19 Oct 2023 18:06:57 +0200 Message-ID: <1ce85d9c7c9e9632393816cf19c902e0a3f411f1.1697731406.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 morse.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 (morse.vger.email [0.0.0.0]); Thu, 19 Oct 2023 09:07:47 -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_TW_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 --- Changes from v1: Rename MSR_AMD64_BU_CFG to MSR_AMD64_TW_CFG since Tom says that's the proper name of that MSR for Zen. 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..8bcbebb56b8f 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_TW_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..fd1b099b0964 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3641,6 +3641,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) case MSR_AMD64_PATCH_LOADER: case MSR_AMD64_BU_CFG2: case MSR_AMD64_DC_CFG: + case MSR_AMD64_TW_CFG: case MSR_F15H_EX_CFG: break; @@ -4065,6 +4066,7 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) case MSR_AMD64_BU_CFG2: case MSR_IA32_PERF_CTL: case MSR_AMD64_DC_CFG: + case MSR_AMD64_TW_CFG: case MSR_F15H_EX_CFG: /* * Intel Sandy Bridge CPUs must support the RAPL (running average power