public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: "Hao, Xudong" <xudong.hao@intel.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"Zhang, Xiantao" <xiantao.zhang@intel.com>,
	"Joerg.Roedel@amd.com" <Joerg.Roedel@amd.com>
Subject: Re: [PATCH v2] kvm/fpu: Enable fully eager restore kvm FPU
Date: Mon, 10 Sep 2012 11:07:07 +0300	[thread overview]
Message-ID: <504D9FAB.7020708@redhat.com> (raw)
In-Reply-To: <403610A45A2B5242BD291EDAE8B37D300FEBECEB@SHSMSX102.ccr.corp.intel.com>

On 09/10/2012 06:29 AM, Hao, Xudong wrote:
>> 
>> Doesn't help.  We can have:
>> 
>> host: deactivate fpu for some reason
>> guest: set cr4.osxsave, xcr0.bit3
>> host: enter guest with deactivated fpu
>> guest: touch fpu
>> 
>> result: host fpu corrupted.
> 
> Avi, I'm not sure if I fully understand of you. Do you mean enter guest with a fpu_active=0 and then fpu does not restore? 

Yes.

> If so, I will add fpu_active=1 in the no-lazy case.
> 
> -   kvm_make_request(KVM_REQ_DEACTIVATE_FPU, vcpu);
> +   if (kvm_read_cr4_bits(vcpu, X86_CR4_OSXSAVE) &&
> +       (vcpu->arch.xcr0 & ~((u64)KVM_XSTATE_LAZY))) {
> +       kvm_x86_ops->fpu_activate(vcpu);
> +       vcpu->fpu_active=1;
> +   }
> +   else
> +       kvm_make_request(KVM_REQ_DEACTIVATE_FPU, vcpu);
> 

It doesn't help here.

  1 guest boot
  2 kvm_userspace_exit (deactivates fpu)
  3 XSETBV exit that sets xcr0.new_bit
  4 kvm_enter

There is no call to kvm_put_guest_fpu() between 3 and 4, you need
something in __kvm_set_xcr() to activate the fpu.

kvm_put_guest_fpu() doesn't need to activate the fpu then, just to avoid
deactivating it.

Note you also need to consider writes to xcr0 and cr4 that happen in the
reverse order due to live migration.


-- 
error compiling committee.c: too many arguments to function

  reply	other threads:[~2012-09-10  8:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-05  1:26 [PATCH v2] kvm/fpu: Enable fully eager restore kvm FPU Xudong Hao
2012-09-05 13:12 ` Avi Kivity
2012-09-06  2:13   ` Hao, Xudong
2012-09-06  8:16     ` Avi Kivity
2012-09-10  3:29       ` Hao, Xudong
2012-09-10  8:07         ` Avi Kivity [this message]
2012-09-11  6:43           ` Hao, Xudong
2012-09-11  7:54             ` Avi Kivity
2012-09-11  9:20               ` Hao, Xudong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=504D9FAB.7020708@redhat.com \
    --to=avi@redhat.com \
    --cc=Joerg.Roedel@amd.com \
    --cc=kvm@vger.kernel.org \
    --cc=xiantao.zhang@intel.com \
    --cc=xudong.hao@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox