Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1299103rdb; Wed, 6 Dec 2023 14:45:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IHcJGFS4PdGjIrMMoxt9EudDFGdYYRaCY1v7hL1JGtOGqtpuCsvL+h8wi3uhMt4KhPZESTy X-Received: by 2002:a17:903:238c:b0:1d0:6ffd:8353 with SMTP id v12-20020a170903238c00b001d06ffd8353mr1110424plh.94.1701902758507; Wed, 06 Dec 2023 14:45:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701902758; cv=none; d=google.com; s=arc-20160816; b=z7m9BUSdDb0DCxrDPPQdg0aznADwcstjxJRBcRl/Wye+AP7tOnjDy5f3sF5vf68hC0 0Yh+L9ZT6JcTt4Dqk0Y6dDi+T4SMt/YvUPuRb/EwvzaLqxSGGLDptieM3+RJXbIcacEI kDZSJGjPwMwVDKI21aOzF/JXz4kOrbwKAGdU7HzYKRFjYG7dCYYbxYeraaSyD/eBB7Bs dFGrDDbLNvOplbyplM2GOUGhzjmM0sW5lqB8i1BbaNLH8onFN1xpdnFycaqvAadsQlRi MBPYT9UpsrRJcHJjyqzHASJfBd57lcEGJ+vA8nn7O4JxQtTcHU4OX7+wGd8uOPISfoFv 4FLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=IZn1S9TK1RDCj7RxM/b8SSbDoPqt7weXZUABUV6sUMI=; fh=20Sz1CzDkosZQoX1uKSVZOGYqdpl2zJNK5lu7Vegxug=; b=pTkWKFxGamzMx7Y68i2P0MjgXKiF/d1lQWuyODr85Xz4fnjBZSIz2QlBfpXslkWJKf w73a2JTCsAC9UiCRlm8kopDnGX1poA+iJ59pnNDrx8L35t6gGO+oTl/xf6OOdiBAhQXV /vv1jPkpTTE4XpbjCJAAc9THhCP3Bkl5DzPAxA/3R2AISc/ccdGB/+JzmHMoKmpf9jS5 WVWroOkuasyRcc6PXkMo9j4WQe22YKvrDl3nQlAWn5EdPjYwlrUvUi98j6tna0Er3IDQ e75J921NnV4xaKzNGZ8qgRDsb0yAaRFdFBMipDsM8g0Tua8orUbzi0+F4r6w4N+RYqar CNTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WFld93N9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id x7-20020a170902ec8700b001d08fadf1b4si492136plg.338.2023.12.06.14.45.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 14:45:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WFld93N9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 70C7980874E2; Wed, 6 Dec 2023 14:45:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377430AbjLFWpO (ORCPT + 99 others); Wed, 6 Dec 2023 17:45:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229642AbjLFWpN (ORCPT ); Wed, 6 Dec 2023 17:45:13 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36160D5B for ; Wed, 6 Dec 2023 14:45:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701902718; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IZn1S9TK1RDCj7RxM/b8SSbDoPqt7weXZUABUV6sUMI=; b=WFld93N9K5z6wyBcqpg0qJN0WX7tCbgmv95pPON2ocdUeZCmLKIyic3EzoJ/koU9WBiP5O /fmadk46Xur/UbmfPq7m/FgTxG7vIr8An4ZM5TwZ+cVMJvoAjGw7o4ncczPY3q0T+plgcp NmN4/X68mYarkjpOR3zp4Jr8LGPmSl4= Received: from mail-ua1-f71.google.com (mail-ua1-f71.google.com [209.85.222.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-693-Vbb0H26-PBOvPvM1mqKO5Q-1; Wed, 06 Dec 2023 17:45:16 -0500 X-MC-Unique: Vbb0H26-PBOvPvM1mqKO5Q-1 Received: by mail-ua1-f71.google.com with SMTP id a1e0cc1a2514c-7c5f24e2b06so17744241.1 for ; Wed, 06 Dec 2023 14:45:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701902716; x=1702507516; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IZn1S9TK1RDCj7RxM/b8SSbDoPqt7weXZUABUV6sUMI=; b=oOFb706k4r1xcagnV7D7W/FnJMcJ91Aq4tj+SHlXUThQHCdhwoIdghHzWO/WzH5rsy Ajycp1OZSLTtAkf5h2WGGplY+Th0MPY5VFIjTEx6Brh/uA3LmmcXYyd3tKbZqBPxZy+7 siKhAHJ5ZjSM86j8yZw78RXBZ+wkErfUmnewzXSNqT6NCZ0T39ZLBpvdN0SESVT8VGSm 5Ka8dTPSGPe63GePHIgXgRof1hCK9+WaNBQXJprxyat637v5jmS/V88C3dQkju6gl6zw Hd1BolcA5N63Y7OE2LGUJPndyTQF25hjKfRobwwU66cE5JP2ei9Pl/xxU5ai7FnoxzqP b51A== X-Gm-Message-State: AOJu0YwV7tjtVSkwEmEv3iY297QXcoj0Ji9PYqQIEE7ppjkegr/6KL7o GeUcdXLt5oIimBTaQYqQxeQgdFYdrHMFYnCqiXUvXRXVeXjDoJ2uyRnaRwmV7IfrwR1/IyittAl +d93FkVfQRV29uy3GYeBopeLbn2Oz+dTeCwJsAzlF X-Received: by 2002:a05:6102:6d1:b0:464:cac8:a03e with SMTP id m17-20020a05610206d100b00464cac8a03emr1957067vsg.1.1701902716171; Wed, 06 Dec 2023 14:45:16 -0800 (PST) X-Received: by 2002:a05:6102:6d1:b0:464:cac8:a03e with SMTP id m17-20020a05610206d100b00464cac8a03emr1957051vsg.1.1701902715890; Wed, 06 Dec 2023 14:45:15 -0800 (PST) MIME-Version: 1.0 References: <9a8e3cb95f3e1a69092746668f9643a25723c522.camel@redhat.com> <00fa768e-eceb-48c3-ae23-1966f110ec49@maciej.szmigiero.name> In-Reply-To: <00fa768e-eceb-48c3-ae23-1966f110ec49@maciej.szmigiero.name> From: Paolo Bonzini Date: Wed, 6 Dec 2023 23:45:02 +0100 Message-ID: Subject: Re: [PATCH] KVM: x86: Allow XSAVES on CPUs where host doesn't use it due to an errata To: "Maciej S. Szmigiero" Cc: Jim Mattson , Maxim Levitsky , Sean Christopherson , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Wed, 06 Dec 2023 14:45:35 -0800 (PST) On Fri, Dec 1, 2023 at 5:05=E2=80=AFPM Maciej S. Szmigiero wrote: > > On 1.12.2023 00:57, Jim Mattson wrote: > > On Thu, Nov 30, 2023 at 2:00=E2=80=AFPM Maciej S. Szmigiero > > wrote: > >> I think that if particular guest would work on bare metal it should > >> work on "-cpu host" too - no tinkering should be required for such > >> basic functionality as being able to successfully finish booting. > > > > I disagree. Let's not focus on one particular erratum. If, for > > whatever reason, the host kernel is booted with "noxsaves," I don't > > think KVM should allow a guest to bypass that directive. > > This could be achieved by either adding special "noxsaves" flag > or by setting X86_BUG_XSAVES_AVOID instead of clearing > X86_FEATURE_XSAVES on these CPUs. > > Then the core kernel XSAVES code would check for lack of > X86_BUG_XSAVES_AVOID (in addition to checking for > presence of X86_FEATURE_XSAVES) while KVM would keep using > only X86_FEATURE_XSAVES. This is feasible, on the other hand the erratum is pretty bad. Since the workaround is easy (just disable XSAVEC; and maybe XGETBV1 as well?), you could just do a printk_ratelimited() on the write to HV_X64_MSR_GUEST_OS_ID, in particular if: 1) guest CPUID has XSAVEC and SVM 2) host CPUID does not have XSAVES 3) guest OS id indicates Windows Server 10.x (which is 2016 to 2022), which should be 0x0001040A00??????. Paolo