From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796061779; b=sfaN0RkTgGkklydNVjwVjKRNVweaaOikyv5aepivdlj/+vj5PVYLAa1ulqIHP/NVzT/k aqmjNe46VaKYD6xCtKC/iN4MeEID/5oKWe9vabU5ygqOBaI+YYiYFT/sdeRT7kDLO6veS w8h2jK73tzlfn6xmvlBliTa1YP85nzM0v13fUbS2tOZoYK2Og/qH0/+w25bYHeDHVtia4 gu8XDPyMlacJuiJap9Nyt9QtpavkmbjMXZK0vXwiyW+q65JB+Q1DqPANhbNUKz9u7VBar kR2PW+tlspsgB5a4+ov5Y855wZUVashOHaqHHfrgQhseLlsWaE+gdXeM2rXO9ChilIw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796061779; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:From:To:Cc:Subject:Date: Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Scanned-By; bh=HdGSQn6L5zGvS/ySwhj3cjJYAKBOmxO3u9/fjiaAqkA=; b=ON6mxwJPVNTy6GpqsYZUp8N2CXgb9QqPAPew7QmGoZYzeRvXPbk+z71VgXPV3XvkFYDY Gu2HeskPtq0iQqkAKTvEOJ2bsssgciEHRltxYvAdM7G2lO8aA6MRx1MDrZ9pg7vIysdhT spbd8nKOpl3VEC0Kb+D8Px2YwRZKV4Meyz57lGf9UON+XvenoJ6ue85aTA5JFZwdlPw3i AMSDHSmhyOfwfKM5ToCGbXL6BSJl3rFLZpV+sdgxNYucd1UXijANWUfkTuektDhjDpjxy x9efyMZ2V0uAp8Z+UEVO1gLMdqj+8Lk1rNy9WpqUKiC6fWypZXt/EsilZousgSo791g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=H4PPBP50; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8FBB8606A320 for ; Mon, 30 Nov 2026 18:02:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8FBB8606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=H4PPBP50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796061778; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HdGSQn6L5zGvS/ySwhj3cjJYAKBOmxO3u9/fjiaAqkA=; b=H4PPBP50iG+4wtBSETAdzKHqtAe/NyKTMO1XJ67PkfHkpVNxTpmp9PMIMjRdPDHr3HuF90 49FkfYaSOhP74e6RQj+hcd564lw4t7siX93fJ4FSRdIrIgxtE91wBHwUjcKlRnldK/XziX Z5qgNz3KYWRZ7Ji58kSyUr0JS0k3wzk= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-693-BumLsu1hMOex0IRs5T6RWg-1; Mon, 30 Nov 2026 18:02:51 +0000 X-MC-Unique: BumLsu1hMOex0IRs5T6RWg-1 X-Mimecast-MFC-AGG-ID: BumLsu1hMOex0IRs5T6RWg_1796061769 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 41656193FAA7; Mon, 30 Nov 2026 18:02:48 +0000 (UTC) Received: from pbonzini-thinkpadx1carbon6th.rmtit.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4E1F1180056E; Mon, 30 Nov 2026 18:02:44 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Borislav Petkov Cc: Sean Christopherson , Thomas Gleixner , Ingo Molnar , Dave Hansen , Jim Mattson , Stefan Teodorescu , Chris Mason , Josef Bacik , David Woodhouse , stable@vger.kernel.org Subject: Re: [*** OFF-LIST *** PATCH v2 1/3] x86/fpu: Bail early from guest XFD update if XFD isn't supported Date: Mon, 30 Nov 2026 19:02:42 +0100 Message-ID: <20261130180242.201450-1-pbonzini@redhat.com> In-Reply-To: <20261120193052.GCawCf7LBmUxT2plv6@fat_crate.local> References: <20261119001506.64568-1-seanjc@google.com> <20261119001506.64568-2-seanjc@google.com> <20261120193052.GCawCf7LBmUxT2plv6@fat_crate.local> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 On Fri, 20 Nov 2026 11:30:52 -0800, Borislav Petkov wrote: > On Wed, Nov 18, 2026 at 04:15:04PM -0800, Sean Christopherson wrote: >> Ignore KVM-requested guest XFD updates if the kernel doesn't support XFD, > >> to allow an upcoming fix to modify xsave.header.xfeatures even when the >> incoming XFD value is '0'. > > Drop that. I agree with Dave and the sentiment to "not even go there" and > not support non-sensical configurations. Agreed, the real justification for bailing out early should be "allow XFD == 0 as that is anyway the initial value of fpstate->xfd, but detect XFD != 0 and WARN as that's a clear bug in KVM". Then subsequent patches are free to do whatever they want. > I appreciate your musings, Sean, but to me that commit message ended after the > first sentence. All is perfectly clear. :) Here is my take on both the patch and the commit message: ----------------------- 8< ----------------- >From c720a41b6df014f95ef7246777db6f066d6396e3 Mon Sep 17 00:00:00 2001 From: Sean Christopherson Date: Wed, 18 Nov 2026 16:15:04 -0800 Subject: [PATCH 1/1] x86/fpu: Bail early from guest XFD update if XFD isn't supported KVM generally allows userspace to set MSRs to their inactive values even if they aren't supported by the guest, as that simplifies userspace code noticeably, and XFD is no exception. Arguably, it should then not try to update XFD in struct fpu_guest* if the kernel doesn't support XFD or even XSAVE. However, fixing that flaw could potentially impact KVM's uABI; thus, simply ignore KVM-requested guest XFD updates if the kernel doesn't support XFD. The current code is subtly fine and does not corrupt guest_fpu->fpstate by interpreting it as an xstate structure; xsave.header.xfeatures is modified if and only if xfd != 0, which KVM does reject. Still, returning early is clearer, provides fewer opportunities for bugs, and provides a place for WARNing in the indefensible case of xfd != 0. Cc: stable@vger.kernel.org Reported-by: Jim Mattson Signed-off-by: Sean Christopherson Link: https://patch.msgid.link/20261119001506.64568-2-seanjc@google.com Signed-off-by: Paolo Bonzini --- arch/x86/kernel/fpu/core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 80a7f41cf3ad..2739264b9cf3 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -334,6 +334,11 @@ void fpu_update_guest_xfd(struct fpu_guest *guest_fpu, u64 xfd) { struct fpstate *fpstate = guest_fpu->fpstate; + if (!cpu_feature_enabled(X86_FEATURE_XFD)) { + WARN_ON_ONCE(xfd); + return; + } + fpregs_lock(); /* -- 2.56.1