[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] x86/CPUID: surface suitable value in EBX of XSTATE subleaf 1


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 23 Aug 2022 08:42:06 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PeyNdVHIMsRcEMFZol+09wsslgm7WcGos5XT+veVb0o=; b=CiH7lgUwgy0vHYm/u4/jMkWBAfRsmw3v1Ndyt46PqRIvwwHkB3yxqyYGx5Si+q8RpExY4CGkbM1Av5Fq037T0WjE1Y2/VEBguqcTO3BllENuE+xawcYkZQHBngv/DDXt+pNRPiZXXfxLLRn7k/O6Nst5bHqCh+Q5lCGnpJGlpxIwRmQFH6heXD/SyR7chs3El3CHkguetoMkZx98GYkBlgeRIAjHEpt3lVP/LhNM/0uNbd9GXtTuecU8/f6OO2Mf22insspCg1kxsoC7s1Y7K9Yoy1wyJdiZOImcEEZ/28K3TD/0AyCNMxZO9NmBSLqYCAXWnEgHiDXbP6mHjHq8ug==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f1hnIrpIsINeEBB+Rorp4W4bnWuwXX/UGxmY7WLvulgYTezmglfUnlmqmfxhcIyeqDws8MSugwVNHjiaB178Iw6bIHqaGKAUtRRTauNt3dgM11QHNR7Jz/4Glmp7AR7845gJTkZz6rFhhxBbbmUqGDqmmtJMCZ1ysR2NqggW5Pp19gQEwraCIdZ/itI23MU/z7HcPtG3FD9WYBSuheqAHwiwnYu/i2goVTjJofnoob09N4gkOMR75q0a9Ik6mHX5AKWfl73TeQVKbjqXqV5ZZLmjIcqc8b2mrOOV/9TgEhwOhsMu42pla762M3jAj0kW8fm/fVPwt2zOrJZsXh5XdQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Tue, 23 Aug 2022 06:42:22 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

While the SDM isn't very clear about this, our present behavior make
Linux 5.19 unhappy. As of commit 8ad7e8f69695 ("x86/fpu/xsave: Support
XSAVEC in the kernel") they're using this CPUID output also to size
the compacted area used by XSAVEC. Getting back zero there isn't really
liked, yet fpr PV that's the default on capable hardware: XSAVES isn't
exposed to PV domains.

Considering that the size reported is that of the compacted save area,
I view Linux'es assumption as appropriate (short of the SDM properly
considering the case). Therefore we need to populate the field also when
only XSAVEC is supported for a guest.

Fixes: 460b9a4b3630 ("x86/xsaves: enable xsaves/xrstors for hvm guest")
Fixes: 8d050ed1097c ("x86: don't expose XSAVES capability to PV guests")
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
I actually wonder why we surface the XSAVES feature bit to HVM domains,
when we don't support any of the features. It's solely because of this
that by default only PV domains are affected by the issue (HVM would be
affected only when XSAVES was hidden via guest config settings).
Wouldn't we better mask the bit (e.g. in recalculate_xstate()) when we
find that no features requiring XSAVES are visible to the domain? That
would likely come closer to real hardware, which pretty certainly won't
offer XSAVES without also offering at least one dependent feature.

--- a/xen/arch/x86/cpuid.c
+++ b/xen/arch/x86/cpuid.c
@@ -1142,7 +1142,7 @@ void guest_cpuid(const struct vcpu *v, u
         switch ( subleaf )
         {
         case 1:
-            if ( p->xstate.xsaves )
+            if ( p->xstate.xsavec || p->xstate.xsaves )
             {
                 /*
                  * TODO: Figure out what to do for XSS state.  VT-x manages



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.