public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Rik van Riel <riel@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	David Hildenbrand <david@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	tglx@linutronix.de, rkrcmar@redhat.com, borntraeger@de.ibm.com
Subject: Re: [PATCH] x86,kvm: move qemu/guest FPU switching out to vcpu_run
Date: Wed, 15 Nov 2017 09:50:32 -0500	[thread overview]
Message-ID: <1510757432.21121.294.camel@redhat.com> (raw)
In-Reply-To: <d1aa3e79-7538-6671-dbff-04a3b000bfe5@redhat.com>

On Wed, 2017-11-15 at 09:34 +0100, Paolo Bonzini wrote:
> On 14/11/2017 20:40, David Hildenbrand wrote:
> > I think we should check all get/put_fpu callers if they need
> > preempt_disable().
> > 
> > E.g. em_fxrstor() needs disabled preemption as we temporarily
> > save + restore some host register (via fxsave + fxrstor) under some
> > circumstances that are not saved/restored when switching to/back
> > from
> > another process. We should double check.
> 
> Rik may correct me, but I believe that you don't need
> preempt_disable/enable because preempt notifiers do this for you.

We no longer even need the preempt notifiers to save and
restore the guest FPU state.

The context switch code itself will save the FPU state
from the registers, into current->thread.fpu.state, when
the VCPU thread gets scheduled out.

When the VCPU thread gets scheduled in, the scheduler
will restore the guest FPU state from current->thread.fpu.state.

At this point, vcpu->arch.guest_fpu may be OUT OF DATE.

However, this is just fine, because we will save the guest
FPU state into vcpu->arch.guest_fpu in kvm_put_guest_fpu,
before we leave the KVM_RUN ioctl, and before we release
the vcpu->mutex.

In other words, by the time anybody else can examine the
VCPU FPU state (after they obtain the vcpu->mutex), the
vcpu->arch.guest_fpu area will contain the correct FPU
state.

  parent reply	other threads:[~2017-11-15 14:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-14  5:12 [PATCH] x86,kvm: move qemu/guest FPU switching out to vcpu_run Rik van Riel
2017-11-14 16:57 ` David Hildenbrand
2017-11-14 18:07   ` Rik van Riel
2017-11-14 18:09     ` Paolo Bonzini
2017-11-14 19:40     ` David Hildenbrand
2017-11-14 21:11       ` Rik van Riel
2017-11-15  8:34       ` Paolo Bonzini
2017-11-15  9:23         ` David Hildenbrand
2017-11-15 14:50         ` Rik van Riel [this message]
2017-11-15 15:20           ` David Hildenbrand
2017-12-04  2:15 ` Wanpeng Li
2017-12-05 17:09   ` Radim Krcmar
2017-12-06  2:48     ` Wanpeng Li

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=1510757432.21121.294.camel@redhat.com \
    --to=riel@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=david@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=tglx@linutronix.de \
    /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