On dinsdag 27 september 2022 14:57:02 CEST Diederik de Haas wrote:
> > > http://xenbits.xen.org/gitweb/?p=xen.git;a=commit;
> > > h=c3bd0b83ea5b7c0da6542687436042eeea1e7909 is where it's committed
> > > in Xen's master branch. I haven't seen a backport to 4.16 (yet?)
> 
> This would be the patch, but it needs to be backported.

While we're at it, might as well attach the actual patch.

And this is the code change of that patch:

diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
index a4a366ad84..822f9ace10 100644
--- a/xen/arch/x86/cpuid.c
+++ b/xen/arch/x86/cpuid.c
@@ -1142,7 +1142,7 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf,
         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
>From c3bd0b83ea5b7c0da6542687436042eeea1e7909 Mon Sep 17 00:00:00 2001
From: Jan Beulich <jbeul...@suse.com>
Date: Wed, 24 Aug 2022 14:23:59 +0200
Subject: [PATCH] x86/CPUID: surface suitable value in EBX of XSTATE subleaf 1

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 for 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 <jbeul...@suse.com>
Acked-by: Andrew Cooper <andrew.coop...@citrix.com>
---
 xen/arch/x86/cpuid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
index a4a366ad84..822f9ace10 100644
--- a/xen/arch/x86/cpuid.c
+++ b/xen/arch/x86/cpuid.c
@@ -1142,7 +1142,7 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf,
         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
-- 
2.30.2

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to