Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1546955rdh; Mon, 25 Sep 2023 16:55:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGURmYJ5ewJCs9mHYlSEBU69ie4zsDD0uVUqRuWfRzcrJz7s/Mn7RDMNGlse+2Hn+eDYNCh X-Received: by 2002:a05:6808:130f:b0:3a8:1906:6a80 with SMTP id y15-20020a056808130f00b003a819066a80mr13417556oiv.10.1695686155236; Mon, 25 Sep 2023 16:55:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695686155; cv=none; d=google.com; s=arc-20160816; b=lgzmGHZ0VO/dt9zlOk8F+ZNd/lCpe//EzfVEkRPFu2lMEScbHEsTSPrbUGx8jD5eYY mhfBTYflcUHnC+LfNqKyT7QejCkn0UhBWWlPtU5Obn/OIkZ6dFNLtUPTFAxgTsIB2L52 wmu7yJmH3MQGjfQluA0e7K/7GW5XEJS6KgSMdVahZNTEenuit0UzlQ1zl9T3SNIeVLA2 0MVfB1o47QrARHU/KXphpQ71Jy5RbPgtvyfJY0CqvSEcMM7EZDNRPuPDua5IpUHQIph4 EWl93/vZy9DAoTCqtVd2gOE08GMkfG1oMxu9cjo+FYpEQCIa26vMKGO2jRcLcA68rKSU U7QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=q4/VvgJsZhmZcNt+Jb9cwBm667cAz2SsHu7xD+9HLQQ=; fh=wpu+hN7hsUQUE3GYO1rg6lcTtVMkj/k3t1uGdUpf5Mo=; b=aBmJvw4oKAhGYZiX5nOX4vF9x8PegkTVrxXo6T//LmHEajHg3EA3t4A/NZ6oQs+dv3 wInf19H7OELBga5U6Bu4hIEMWLBiCprY+6d5jzNJyY+uyd+jhMGdSrmChalFD+5J5J0z 1r3FgIojvE05b59wvQjAIPV33iPEb1hkzdkGd0/WaGwpRpxqZxplORx0Y9WzfR2Wop0t nJuRf1NV9+7Kh2icJ1dlr3aEyvNl5ijR/JEOrMO3JWMSqShhq2fji4yQrejTdz87hHN+ YMOX7A11wI40epSGk3ERcbcDwP2jIJW3DtRezcf/cphFgrY0+MpE4HqdXUBVw7NjCFb1 MBIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=OJ9R9y7x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id v17-20020a62c311000000b0068fb9c0bb07si10821786pfg.13.2023.09.25.16.55.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 16:55:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=OJ9R9y7x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id B746C8233645; Mon, 25 Sep 2023 11:30:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232431AbjIYSaU (ORCPT + 99 others); Mon, 25 Sep 2023 14:30:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231450AbjIYSaT (ORCPT ); Mon, 25 Sep 2023 14:30:19 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 945ABFB for ; Mon, 25 Sep 2023 11:30:12 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-59f61a639b9so74302467b3.1 for ; Mon, 25 Sep 2023 11:30:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695666612; x=1696271412; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=q4/VvgJsZhmZcNt+Jb9cwBm667cAz2SsHu7xD+9HLQQ=; b=OJ9R9y7xDnvgRJqaaBJDz+6kvUORYJqSKGqM7ypDOZwbK/XVoPLv+rDdqtJ4zZ2TUw vH0xbchsGY4NbEXuRnBUISwQrHIKnW4n+TrDiohlkma4sm4x1drUMva029FoJomrB9bP m+nLklpxUuWFTlTn3fviPbAx1Egtm+rJjTvBNegCuY/unGyKfbjlpouhJh/R9Bil7WE0 DExTs+YeJuSQuoKewYcgrrZvK7E0e9notJYXuqh6te+VUihdiUuBIvwlFN7981jbOiMg Ly7uCWRpmg7PnhZOCi3yBitkgallqkyojXKNOIyQQJe/m9qjKLHB1L9iBiGfAsn2K/4i xLng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695666612; x=1696271412; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=q4/VvgJsZhmZcNt+Jb9cwBm667cAz2SsHu7xD+9HLQQ=; b=jrro+SflVVpMvTGDrDaZHXO9DNlFz5UA/sZNwR4qu7/tMApEMZ50EzAcs7I4B4jAuK 1ccPLrGgDxt7Drl3oxb3iHVP2QJed/RKkgUl4bw/Lp2eGLAs3UD4YUQpO6KyhAX1lEM5 GgumW1j0UrVMo3Std4eb8ozoNfz6GABJWYEbkBNkddBSZdVhDVsbOA3WD6QGbFgPbQQu bVy4FSyAzGmtJRmNiEOebdVLtEHlLhn4YcbvnulVFw5DX9S6P5MgLQT9pStJG5T18mEP 95EKtAUpFfl4B2vroyHQ+p9Og3Vlzbk8Ti3XzfpgziRRd4uIcP/VuSECLqXxs59nLjZh +bOw== X-Gm-Message-State: AOJu0YyNsce0TbVIbfSsCFjeFomVejRJqkcGl5a8trckkwnxu+oLt80B FtEI46PtnZh86e8Ao/yQc9L8zfr+LQU= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:cacd:0:b0:d7f:2cb6:7d8a with SMTP id a196-20020a25cacd000000b00d7f2cb67d8amr74861ybg.11.1695666611883; Mon, 25 Sep 2023 11:30:11 -0700 (PDT) Date: Mon, 25 Sep 2023 11:30:10 -0700 In-Reply-To: <0ffde769702c6cdf6b6c18e1dcb28b25309af7f7.1695659717.git.maciej.szmigiero@oracle.com> Mime-Version: 1.0 References: <0ffde769702c6cdf6b6c18e1dcb28b25309af7f7.1695659717.git.maciej.szmigiero@oracle.com> Message-ID: Subject: Re: [PATCH] KVM: x86: Ignore MSR_AMD64_BU_CFG access From: Sean Christopherson To: "Maciej S. Szmigiero" Cc: Paolo Bonzini , Borislav Petkov , kvm@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Mon, 25 Sep 2023 11:30:19 -0700 (PDT) On Mon, Sep 25, 2023, Maciej S. Szmigiero wrote: > 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. Any idea why? > 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. Ugh, that commit set a terrible example. The kernel change should have been conditioned on !X86_FEATURE_HYPERVISOR if the MSR only has meaning for bare metal. > 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). This seems like it needs to be tagged for stable? > 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 What document actually defines this MSR? All of the PPRs I can find for Family 17h list it as: MSRC001_1023 [Table Walker Configuration] (Core::X86::Msr::TW_CFG) > #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: I am sorely tempted to say that this should be solved in userspace via MSR filtering. IIUC, the MSR truly is model specific, and I don't love the idea of effectively ignoring accesses to unknown MSRs. And I really, really don't want KVM to pivot on FMS. Paolo, is punting to userspace reasonable, or should we just bite the bullet in KVM and commit to ignoring MSRs like this? > 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: