From: "Jan Beulich" Subject: Re: [PATCH][RFC] FPU LWP 2/5: add mask option to xsave/xrstor Date: Fri, 15 Apr 2011 10:11:58 +0100 Message-ID: <4DA827FE020000780003C9C2@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Wei Huang Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org >>> On 14.04.11 at 22:38, Wei Huang wrote: > This patch adds a mask option to xsave/xrstor. This mask is used by=20 > xsave and xrstor instructions to selectively save/restore memory area. >=20 > Signed-off-by: Wei Huang This >-static void xsave(struct vcpu *v) >+static void xsave(struct vcpu *v, uint64_t mask) > { > struct xsave_struct *ptr =3D v->arch.xsave_area; >+ uint32_t hmask =3D mask >> 32; >+ uint32_t lmask =3D mask; >=20 > asm volatile ( > ".byte " REX_PREFIX "0x0f,0xae,0x27" > : >- : "a" (-1), "d" (-1), "D"(ptr) >+ : "a" (lmask), "d" (hmask), "D"(ptr) > : "memory" ); > } >...=20 >@@ -185,7 +191,7 @@ > * we set all supported feature mask before doing save/restore. > */ > set_xcr0(v->arch.xcr0_accum); >- xrstor(v); >+ xrstor(v, XCNTXT_MASK); > set_xcr0(v->arch.xcr0); > } >=20 (and similarly in other functions) isn't forward compatible anymore. The mask had all bits set previously, but now only is >+#define XCNTXT_MASK (XSTATE_FP | XSTATE_SSE | XSTATE_YMM | = XSTATE_LWP) My understanding of xsave and its cpuid leaf is that it is meant to be possible to have new hardware features added without OSes constantly needing modification to make them available to user mode software. LWP not fitting into the lazy restore picture is rather unfortunate here, and I wonder whether it was a good decision to have its save/restore done via xsave... Does native Linux already have LWP support (can't seem to spot it in 3.6.39-rc3)? If so, how is this being addressed there? Jan