Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1452778rdb; Mon, 2 Oct 2023 09:52:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGHo7gB5JLMGGfdHxUZ+3m6X/BK5saDr/X9yRNstXx8ALZ29wVNB8wy3HqFEANPxOwmEYMx X-Received: by 2002:a17:902:e54f:b0:1c7:5f03:8562 with SMTP id n15-20020a170902e54f00b001c75f038562mr6937430plf.30.1696265578356; Mon, 02 Oct 2023 09:52:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696265578; cv=none; d=google.com; s=arc-20160816; b=VdpEDoLfqWBL1Lad81xDs0dyzmCuwwf4hcLfRoM0kOAc9stM24SRMTtSIY4J+eOkej i/tYA/kH6M3YWhH8Vp+jxRhaR7o5/f1indoOKuM1dc+zw93wXo+3CU3aamqwQV3ESxxd Tj7h1JEpnZrwat73exoaKdIQIdp5Dbd0Q2jNpFt8jgDmGEVMgTseEwpMquXVvwDGEG9j qgLBfhFdAJH9VWwenv6QtL+od16foTREm1F6QR/EB+X5ZwRXi+XNyLMnCFR5l6eSJFYD hCzcK1I5TKRT4FTCwbPhYsAqWVORiHWxhF4Xjzt55UjxavUf3OqsYzOSUgMcy1eqgA19 /mMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id; bh=v+UOBwNlhWtcvvyWudt4iamQI/54w9ozezqKHGnHbNw=; fh=VrPhBHX/9U1rqPMhiuFglE2G5SoQlkd1WSAx8iRfuAA=; b=06vU8JfQVACcT0SxRWdDyTTHFop5Sum6BnlBh94CcvUO83pFBeLVMPODOOs1yblm02 FYOLGD5JXJackaMY+XLUFf8ksGIGgYatobGu02gCSi+XtLOTIbUSLiFHnDpJtFXpn1rR +XJZYajMxwtvQqdwP89UOr1vh0XMw8bf9GLhHwdZtL39tu9lhx02LR9S010on6pnuYYd wu2TUm+KcWnMxuVvKU/lg0kueAX76ElM1nI0sHyTjDlDeoKjrdUXhKrNlDkerlt4Iw9A PSFu5YLJnY3umSMiVTYzF9hRP+v7Z6yfTaalMRL+/02Tc2hjt/iQLPzxfG3N3S0vm6eX kq3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id b14-20020a170902d50e00b001c432da203asi14517972plg.270.2023.10.02.09.52.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 09:52:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id C1C9080AE81B; Mon, 2 Oct 2023 09:33:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238201AbjJBQdS (ORCPT + 99 others); Mon, 2 Oct 2023 12:33:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230137AbjJBQdR (ORCPT ); Mon, 2 Oct 2023 12:33:17 -0400 Received: from vps-vb.mhejs.net (vps-vb.mhejs.net [37.28.154.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B54B19B; Mon, 2 Oct 2023 09:33:11 -0700 (PDT) Received: from MUA by vps-vb.mhejs.net with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qnLqu-0003gY-Cc; Mon, 02 Oct 2023 18:33:00 +0200 Message-ID: Date: Mon, 2 Oct 2023 18:32:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] KVM: x86: Ignore MSR_AMD64_BU_CFG access Content-Language: en-US, pl-PL To: Sean Christopherson Cc: Paolo Bonzini , Borislav Petkov , kvm@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, Tom Lendacky References: <0ffde769702c6cdf6b6c18e1dcb28b25309af7f7.1695659717.git.maciej.szmigiero@oracle.com> <8c6a1fc8-2ac5-4767-8b02-9ef56434724e@maciej.szmigiero.name> From: "Maciej S. Szmigiero" Autocrypt: addr=mail@maciej.szmigiero.name; keydata= xsFNBFpGusUBEADXUMM2t7y9sHhI79+2QUnDdpauIBjZDukPZArwD+sDlx5P+jxaZ13XjUQc 6oJdk+jpvKiyzlbKqlDtw/Y2Ob24tg1g/zvkHn8AVUwX+ZWWewSZ0vcwp7u/LvA+w2nJbIL1 N0/QUUdmxfkWTHhNqgkNX5hEmYqhwUPozFR0zblfD/6+XFR7VM9yT0fZPLqYLNOmGfqAXlxY m8nWmi+lxkd/PYqQQwOq6GQwxjRFEvSc09m/YPYo9hxh7a6s8hAP88YOf2PD8oBB1r5E7KGb Fv10Qss4CU/3zaiyRTExWwOJnTQdzSbtnM3S8/ZO/sL0FY/b4VLtlZzERAraxHdnPn8GgxYk oPtAqoyf52RkCabL9dsXPWYQjkwG8WEUPScHDy8Uoo6imQujshG23A99iPuXcWc/5ld9mIo/ Ee7kN50MOXwS4vCJSv0cMkVhh77CmGUv5++E/rPcbXPLTPeRVy6SHgdDhIj7elmx2Lgo0cyh uyxyBKSuzPvb61nh5EKAGL7kPqflNw7LJkInzHqKHDNu57rVuCHEx4yxcKNB4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Wy1ajKn7rOB7udmTmYb8nnlQb 0fpPzYGBzK7zWIzFotuS5x1PzLYhZQFkfegyAaxys2joryhI6YNFo+BHYTfamOVfFi8QFQL5 5ZSOo27q/Ox95rwuC/n+PoJxBfqU36XBi886VV4LxuGZ8kfy0qDpL5neYtkC9w== In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 02 Oct 2023 09:33:36 -0700 (PDT) On 26.09.2023 00:25, Tom Lendacky wrote: > On 9/25/23 14:16, Sean Christopherson wrote: >> +Tom >> >> On Mon, Sep 25, 2023, Maciej S. Szmigiero wrote: >>> On 25.09.2023 20:30, Sean Christopherson wrote: >>>>> >>>>> 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? >>> >>> I guess it is trying to set some chicken bit? >>> >>> By the way, I tested Windows Server 2019 now - it has the same problem. >>> >>> So likely Windows 11 and newer version of Windows 10 have it, too. >> >> ... >> >>>>> 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) >>> >>> It's partially documented in various AMD BKDGs, however I couldn't find >>> any definition for this particular bit (8) - other than that it is reserved. >> >> I found it as MSR_AMD64_BU_CFG for Model 16h, but that's Jaguar/Puma, not Zen1. >> My guess is that Windows is trying to write this thing: >> >>    MSRC001_1023 [Table Walker Configuration] (Core::X86::Msr::TW_CFG) >>    Read-write. Reset: 0000_0000_0000_0000h. >>    _lthree0_core[3,1]; MSRC001_1023 >> >>    Bits   Description >>    63:50  Reserved. >>    49     TwCfgCombineCr0Cd: combine CR0_CD for both threads of a core. Read-write. Reset: 0. Init: BIOS,1. >>           1=The host Cr0_Cd values from the two threads are OR'd together and used by both threads. >>    48:0   Reserved. >> >> Though that still doesn't explain bit 8...  Perhaps a chicken-bit related to yet >> another speculation bug? >> >> Boris or Tom, any idea what Windows is doing?  I doubt it changes our options in >> terms of "fixing" this in KVM, but having a somewhat accurate/helpful changelog >> would be nice. > > It's definitely not related to a speculation bug, but I'm unsure what was told to Microsoft that has them performing that WRMSR. The patch does the proper thing, though, as a guest shouldn't be updating that setting. > > And TW_CFG is the proper name of that MSR for Zen. So, should I prepare v2 with MSR_AMD64_BU_CFG -> MSR_AMD64_TW_CFG change? Thanks, Maciej