WARNING - OLD ARCHIVES

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/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [Patch 4/4] Refining Xsave/Xrestore support

To: Tim Deegan <Tim.Deegan@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxxxx>
Subject: Re: [Xen-devel] [Patch 4/4] Refining Xsave/Xrestore support
From: Haitao Shan <maillists.shan@xxxxxxxxx>
Date: Thu, 28 Oct 2010 12:57:20 +0800
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>, "Han, Weidong" <weidong.han@xxxxxxxxx>, Keir Fraser <Keir.Fraser@xxxxxxxxxxxxx>
Delivery-date: Wed, 27 Oct 2010 21:58:34 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=YHo7k+3N/pMeJ9h3U/SkZpCHlMXxrzDYYO1GRMwrvIU=; b=VmorJiZKfsoUw08CyUPrZR9z6CyAu0art/lOMio+wx1mmH1WQwRu/VOXUiOgV9lGlY NIPOhuF22F/9LCAkCm1u0gsb9/2VwrE28LgnqRdyYGpt0Rx73XSL1Jy/ZNMu1n3cIvUg zommF30N8JR+yHDs9a8oWoYsfZ1uhUZBgMDdw=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=SZN7yCZUEiTd0cv0R+jGqqC0wzTrvl27jITSzQzjz0G0hogboDnAkyAr9fieLou8Jz vGUP2ogrTPzXTzzpJf9F8EPRZEWdPl5Qlwjq5rKE9vBBIwTROnkSYVO+xKjLS71RXOtn vzN2R482NwD6V/xP22E2E22cPqGSdT2KQVz8Q=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20101027102530.GY4007@xxxxxxxxxxxxxxxxxxxxxxx>
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=ppSKUtJNEmpqUtCHZDqG8zfkLVKZf_1QWNhBM@xxxxxxxxxxxxxx> <20101027102530.GY4007@xxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
This is updated patch. Thanks!

Shan Haitao

2010/10/27 Tim Deegan <Tim.Deegan@xxxxxxxxxx>:
> Hi,
>
> Thanks for this - good to see XSAVE save/restore working.  I've no
> comments on the tools part of this patch; it looks plausible but I
> haven't reviewed it closely.
>
> On the Xen HVM side:
>
>> diff -r 9bf6b4030d70 xen/arch/x86/hvm/hvm.c
>> --- a/xen/arch/x86/hvm/hvm.c  Wed Oct 27 21:55:45 2010 +0800
>> +++ b/xen/arch/x86/hvm/hvm.c  Wed Oct 27 22:17:24 2010 +0800
>> @@ -575,8 +575,13 @@ static int hvm_save_cpu_ctxt(struct doma
>>          vc = &v->arch.guest_context;
>>
>>          if ( v->fpu_initialised )
>> -            memcpy(ctxt.fpu_regs, &vc->fpu_ctxt, sizeof(ctxt.fpu_regs));
>> -        else
>> +            if ( cpu_has_xsave )
>> +                /* to restore guest img saved on xsave-incapable host */
>> +                memcpy(v->arch.xsave_area, ctxt.fpu_regs,
>> +                       sizeof(ctxt.fpu_regs));
>> +            else
>> +                memcpy(&vc->fpu_ctxt, ctxt.fpu_regs, sizeof(ctxt.fpu_regs));
>
> I think this hunk belongs in hvm_LOAD_cpu_ctxt()!
>
>> +        else
>>              memset(ctxt.fpu_regs, 0, sizeof(ctxt.fpu_regs));
>>
>>          ctxt.rax = vc->user_regs.eax;
>
> [...]
>
>> +    ctxt = (struct hvm_hw_cpu_xsave *)&h->data[h->cur];
>> +    h->cur += desc->length;
>> +
>> +    _xfeature_mask = ctxt->xfeature_mask;
>> +    if ( (_xfeature_mask & xfeature_mask) != xfeature_mask )
>> +        return -EINVAL;
>
> This allows XSAVE records to be loaded on machines with fewer features.
> Is that safe?
>
>> +    v->arch.xcr0 = ctxt->xcr0;
>> +    v->arch.xcr0_accum = ctxt->xcr0_accum;
>> +    memcpy(v->arch.xsave_area, &ctxt->save_area, xsave_cntxt_size);
>> +
>> +    return 0;
>> +}
>
> Also, have you tested this on CPUs that don't support XSAVE?  The PV
> hypercall looks like it will return -EFAULT after trying to
> copy_from_user into a null pointer on the Xen side, but something more
> explicit would be better.
>
> Cheers,
>
> Tim.
>
> --
> Tim Deegan <Tim.Deegan@xxxxxxxxxx>
> Principal Software Engineer, XenServer Engineering
> Citrix Systems UK Ltd.  (Company #02937203, SL9 0BG)
>

Attachment: xsave-migration.patch
Description: Binary data

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel