[RFC PATCH v2 07/10] x86/hvm: Don't count XSS bits in XSAVE size

Tu Dinh posted 10 patches 10 months ago
[RFC PATCH v2 07/10] x86/hvm: Don't count XSS bits in XSAVE size
Posted by Tu Dinh 10 months ago
HVM vCPU state images are uncompressed and therefore can't contain XSS
states.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 xen/arch/x86/hvm/hvm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 922c9b3af6..c7b93c7d91 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -1208,7 +1208,8 @@ HVM_REGISTER_SAVE_RESTORE(CPU, hvm_save_cpu_ctxt, NULL, hvm_load_cpu_ctxt, 1,
 
 #define HVM_CPU_XSAVE_SIZE(xcr0) (offsetof(struct hvm_hw_cpu_xsave, \
                                            save_area) + \
-                                  xstate_uncompressed_size(xcr0))
+                                  xstate_uncompressed_size(xcr0 & \
+                                                           ~X86_XSS_STATES))
 
 static int cf_check hvm_save_cpu_xsave_states(
     struct vcpu *v, hvm_domain_context_t *h)
-- 
2.43.0



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech
Re: [RFC PATCH v2 07/10] x86/hvm: Don't count XSS bits in XSAVE size
Posted by Jan Beulich 9 months, 2 weeks ago
On 02.01.2025 09:45, Tu Dinh wrote:
> HVM vCPU state images are uncompressed and therefore can't contain XSS
> states.

Then again ...

> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -1208,7 +1208,8 @@ HVM_REGISTER_SAVE_RESTORE(CPU, hvm_save_cpu_ctxt, NULL, hvm_load_cpu_ctxt, 1,
>  
>  #define HVM_CPU_XSAVE_SIZE(xcr0) (offsetof(struct hvm_hw_cpu_xsave, \
>                                             save_area) + \
> -                                  xstate_uncompressed_size(xcr0))
> +                                  xstate_uncompressed_size(xcr0 & \
> +                                                           ~X86_XSS_STATES))

... a variable / parameter named "xcr0" shouldn't include any XSS bits
anyway. IOW this perhaps needs sorting at the use sites of the macros.

Jan