This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


Re: [Xen-devel] [Patch] Allowing PV-OPS kernel to detect whether XSAVE i

To: Haitao Shan <maillists.shan@xxxxxxxxx>
Subject: Re: [Xen-devel] [Patch] Allowing PV-OPS kernel to detect whether XSAVE is supported
From: Jeremy Fitzhardinge <jeremy@xxxxxxxx>
Date: Tue, 09 Nov 2010 16:41:50 -0800
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx, Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>, Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Delivery-date: Tue, 09 Nov 2010 16:42:44 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <AANLkTimeXpoC08=RLGxsQZSrf4EjR2vvCFHtuhjr+eNb@xxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <AANLkTi=dR3b7N5xUa2E=gLnVFdVWYX=S0fXN-g8OaJtP@xxxxxxxxxxxxxx> <4CD9A73B.2070909@xxxxxxxx> <AANLkTimeXpoC08=RLGxsQZSrf4EjR2vvCFHtuhjr+eNb@xxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20101027 Fedora/3.1.6-1.fc13 Lightning/1.0b3pre Thunderbird/3.1.6
On 11/09/2010 04:15 PM, Haitao Shan wrote:
> I think that is not possible. If usermode does not use native CPUID
> instruction, or CPUID can be virtualized any way, this won't happen.
> Otherwise, usermode will either see both are set or unset. Since on a
> NON-XSAVE processor, you can not set CR4.OSXSAVE and won't be
> reflected to CPUID.

I see.

> If user mode sees both are set, they can use it actually. So we
> initially set FP and SSE in XCR0 for guest. If user mode wants to use
> it, guest kernel still can manage the state using traditional FPU
> save/restore mechanism. If user mode wants to access more extended
> states, it has to acquire kernel's support for turning on related bit
> in XCR0, which is finally controlled by Xen now.

Are you saying that usermode can use XSAVE, AVX and other instruction
set extensions successfully if Xen supports them, even if the guest OS
doesn't?  That sounds unlikely - what happens when, for example, an old
Linux wants to context switch from one Linux task to another on a VCPU? 
How will the task's context get saved/reloaded properly?

Your kernel changes seem fine, and should allow a modern kernel to
support XSAVE and all the CPU features that go along with it.  But I'm
really concerned that your Xen changes will cause previously working
usermode programs to start erroneously using XSAVE when the guest kernel
cannot support it.

> I have a few AVX test programs running both inside PV guest and HVM.
> However, I have to admit that my aim is to test Xen's fpu context
> switching using Xsave and guest save/restore.

Could you make them available for testing?

IanJ: It looks like it would be useful to add some tests to the suite to
make sure all this extended context is save/restored properly...


Xen-devel mailing list