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

[Xen-devel] Getting the XSAVE size from userspace


  • To: "xen-devel@xxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxx>
  • From: Razvan Cojocaru <rcojocaru@xxxxxxxxxxxxxxx>
  • Date: Thu, 5 Nov 2015 11:52:34 +0200
  • Comment: DomainKeys? See http://domainkeys.sourceforge.net/
  • Delivery-date: Thu, 05 Nov 2015 09:52:37 +0000
  • Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=bitdefender.com; b=EhgW1pYlnwRDKY+00KZLAcocwae5mCrVGAtY6jlnQtnPyQexTFi6RxCWEoZJNV19vKLd51pHU4n7FqJSjuYFp9HMWu2bQ/dsCJ3YP/DxnNn0EsQXpBbWcqZ7GL0AjxMb+ckzOY+g3Sau4WGVxFzA0vALi72yO1oYhgCZTx3FtI48y91ie1TSg6WRoVLEKbDoq4/0iy+8Ii3xgHlyXj5gG5L5s/+zfTh03gt7zlz51Nb3Bc0G+UcUeAi89ZxGf+FIZyMh94lxvSSoLSkU38ynnuO+6gS5YRZkBCM1MKpNt+uzMLL1khJtPQNHDQwDd9cbJavJ+6CborMDJrtELe+TVQ==; h=Received:Received:Received:Received:Received:To:From:Subject:X-Enigmail-Draft-Status:Message-ID:Date:User-Agent:MIME-Version:Content-Type:Content-Transfer-Encoding:X-BitDefender-Scanner:X-BitDefender-Spam:X-BitDefender-SpamStamp:X-BitDefender-CF-Stamp;
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>

Hello,

I need to get the XSAVE size from userspace. The easiest way seems to be
to use the XEN_DOMCTL_getvcpuextstate hypercall, but that hypercall is
not public / there's no xenctrl.h wrapper for it.

There's also struct hvm_hw_cpu_xsave, which I can get to, but it doesn't
have a size member:

542 /*
543  * The save area of XSAVE/XRSTOR.
544  */
545
546 struct hvm_hw_cpu_xsave {
547     uint64_t xfeature_mask;        /* Ignored */
548     uint64_t xcr0;                 /* Updated by XSETBV */
549     uint64_t xcr0_accum;           /* Updated by XSETBV */
550     struct {
551         struct { char x[512]; } fpu_sse;
552
553         struct {
554             uint64_t xstate_bv;         /* Updated by XRSTOR */
555             uint64_t reserved[7];
556         } xsave_hdr;                    /* The 64-byte header */
557
558         struct { char x[0]; } ymm;    /* YMM */
559     } save_area;
560 };

I see that in the hypervisor code the length is computed by using the
HVM_CPU_XSAVE_SIZE() macro:

2126 #define HVM_CPU_XSAVE_SIZE(xcr0) (offsetof(struct hvm_hw_cpu_xsave, \
2127                                            save_area) + \
2128                                   xstate_ctxt_size(xcr0))

where:

256 static unsigned int _xstate_ctxt_size(u64 xcr0)
257 {
258     u64 act_xcr0 = get_xcr0();
259     u32 eax, ebx = 0, ecx, edx;
260     bool_t ok = set_xcr0(xcr0);
261
262     ASSERT(ok);
263     cpuid_count(XSTATE_CPUID, 0, &eax, &ebx, &ecx, &edx);
264     ASSERT(ebx <= ecx);
265     ok = set_xcr0(act_xcr0);
266     ASSERT(ok);
267
268     return ebx;
269 }
270
271 /* Fastpath for common xstate size requests, avoiding reloads of
xcr0. */
272 unsigned int xstate_ctxt_size(u64 xcr0)
273 {
274     if ( xcr0 == xfeature_mask )
275         return xsave_cntxt_size;
276
277     if ( xcr0 == 0 )
278         return 0;
279
280     return _xstate_ctxt_size(xcr0);
281 }

But that doesn't seem to translate cleanly to userspace code.

I had hoped that I would be able to get this with no custom Xen patches,
is there a simpler way I'm not aware of to get to this information? And
if there isn't, would you prefer a libxc patch that exposes
XEN_DOMCTL_getvcpuextstate, or one that adds a size member to struct
hvm_hw_cpu_xsave (I'd guess the latter)?


Thanks,
Razvan

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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