Skip to contentSkip to conversation

libxc/restore: Fix REC_TYPE_X86_PV_VCPU_XSAVE data auditing (take 2)

PATCH In review Andrew Cooper 2 participants 2 messages Feb 4, 2020 – Feb 5, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxc/restore: Fix REC_TYPE_X86_PV_VCPU_XSAVE data auditing (take 2)

It turns out that a bug (since forever) in Xen causes XSAVE records to have non-architectural behaviour on xsave-capable hardware, when a PV guest has not touched the state.

In such a case, the data record returned from Xen is 2*uint64_t, both claiming the (illegitimate) state of %xcr0 and %xcr0_accum being 0.

Adjust the bound in handle_x86_pv_vcpu_blob() to cope with this.

Fixes 2a62c22715b "libxc/restore: Fix data auditing in handle_x86_pv_vcpu_blob()"

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Igor Druzhinin <[email protected]>

I'll see about fixing Xen at some other point. A second bug is that we have two copies of part of the vCPU's FPU state.

---
 tools/libxc/xc_sr_restore_x86_pv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/libxc/xc_sr_restore_x86_pv.c +2 -2
index 16e738884e..904ccc462a 100644
@@ -827,10 +827,10 @@ static int handle_x86_pv_vcpu_blob(struct xc_sr_context *ctx,
         break;
 
     case REC_TYPE_X86_PV_VCPU_XSAVE:
-        if ( blobsz < 128 )
+        if ( blobsz < 16 )
         {
             ERROR("%s record too short: min %zu, got %u",
-                  rec_name, sizeof(*vhdr) + 128, rec->length);
+                  rec_name, sizeof(*vhdr) + 16, rec->length);
             goto out;
         }
         blob = &vcpu->xsave;
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Andrew Cooper

It turns out that a bug (since forever) in Xen causes XSAVE records to have non-architectural behaviour on xsave-capable hardware, when a PV guest has not touched the state.

Quoted 8 lines

In such a case, the data record returned from Xen is 2*uint64_t, both claiming the (illegitimate) state of %xcr0 and %xcr0_accum being 0.

Adjust the bound in handle_x86_pv_vcpu_blob() to cope with this.

Fixes 2a62c22715b "libxc/restore: Fix data auditing in handle_x86_pv_vcpu_blob()"

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel