From: Gleb Natapov <gleb@redhat.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
Linus Torvalds <torvalds@linux-foundation.org>,
KVM list <kvm@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Peter Anvin <hpa@zytor.com>
Subject: Re: [PATCH, RFC] x86-64: properly handle FPU code/data selectors
Date: Thu, 17 Oct 2013 13:39:56 +0300 [thread overview]
Message-ID: <20131017103956.GA25942@redhat.com> (raw)
In-Reply-To: <525FDA1C02000078000FBCC0@nat28.tlf.novell.com>
On Thu, Oct 17, 2013 at 11:37:48AM +0100, Jan Beulich wrote:
> >>> On 17.10.13 at 12:23, Gleb Natapov <gleb@redhat.com> wrote:
> > On Thu, Oct 17, 2013 at 10:51:52AM +0100, Jan Beulich wrote:
> >> >>> On 17.10.13 at 11:41, Gleb Natapov <gleb@redhat.com> wrote:
> >> > KVM obviously knows the complete state of virtual CPU. It can figure the
> >> > situation above by looking at CS descriptor, not need to check
> >> > is_long_mode() at all. Here is how emulator does it:
> >>
> >> And again - no: The last floating point operation may have
> >> happened in 32-bit user mode context, while the state saving
> >> may happen when the guest is already back in 64-bit kernel
> >> mode.
> >>
> > Hmm, OK so the scenarios you are talking about is:
> > 1. Guest's 32bit process uses FPU
> > 2. Guest switch to 64bit kernel.
> > 3. Before guest's kernel saves 32bit process's FPU state VMEXIT happens
> > 4. KVM need to save FPU but it does not know what mode it is in
> > Correct?
>
> Yes.
>
> > KVM gives FPU to a guest lazily, meaning that on a first FPU use #NM
> > (intercepted by KVM) happens at which point FPU is granted to a guest.
> > KVM can check what mode CPU was in at this point and use this info
> > while saving FPU. But there is additional optimization that will prevent
> > this from working for all cases: when FPU is granted to a guest KVM
> > disabled CR0.TS/#NM intercepts, so guest is free to switch FPU from
> > 32bit to 64bit mode without KVM knowing. Disabling this optimization
> > will make FP intensive workload slow in a guest.
>
> Not sure what you're trying to tell me with this explanation.
>
Trying to think aloud how it can be fixed.
--
Gleb.
next prev parent reply other threads:[~2013-10-17 10:40 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-16 12:00 [PATCH, RFC] x86-64: properly handle FPU code/data selectors Jan Beulich
2013-10-16 15:19 ` Linus Torvalds
2013-10-16 15:36 ` Jan Beulich
2013-10-16 15:50 ` Linus Torvalds
2013-10-16 16:13 ` Jan Beulich
2013-10-16 18:43 ` Linus Torvalds
2013-10-17 7:09 ` Jan Beulich
2013-10-17 9:27 ` Gleb Natapov
2013-10-17 9:33 ` Jan Beulich
2013-10-17 9:41 ` Gleb Natapov
2013-10-17 9:51 ` Jan Beulich
2013-10-17 10:23 ` Gleb Natapov
2013-10-17 10:37 ` Jan Beulich
2013-10-17 10:39 ` Gleb Natapov [this message]
2013-10-16 15:39 ` H. Peter Anvin
2013-10-16 16:07 ` Jan Beulich
2013-10-16 17:13 ` H. Peter Anvin
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=20131017103956.GA25942@redhat.com \
--to=gleb@redhat.com \
--cc=JBeulich@suse.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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