From: Gleb Natapov <gleb@redhat.com>
To: Borislav Petkov <bp@alien8.de>
Cc: "Andre Przywara" <andre@andrep.de>,
kvm@vger.kernel.org, "Jörg Rödel" <joro@8bytes.org>,
"H. Peter Anvin" <hpa@zytor.com>, x86-ml <x86@kernel.org>
Subject: Re: [PATCH -v2] kvm: Emulate MOVBE
Date: Sun, 21 Apr 2013 15:51:16 +0300 [thread overview]
Message-ID: <20130421125115.GD8997@redhat.com> (raw)
In-Reply-To: <20130421113051.GB4594@pd.tnic>
On Sun, Apr 21, 2013 at 01:30:51PM +0200, Borislav Petkov wrote:
> On Sun, Apr 21, 2013 at 12:46:51PM +0300, Gleb Natapov wrote:
> > There may be userspaces that set ->function to 0xffffffff (just
> > because they do not init the buffer before calling into the kernel)
> > and this will break them.
>
> You don't mean 0xffffffff here but rather something random which is not
> properly initialized and by chance is a valid CPUID leaf. Then, if some
> of the bits in the register variables e[abcd]x are also set, we return
> with emulated bits set.
>
Yes.
> > > For each set bit, we check whether we emulate the respective feature
> > > and if so, we leave it untouched before returning it to userspace.
> > > Otherwise, we clear it before OR-ing in the host bits and the
> > > good-emulated bits like x2apic.
> > >
> > > Yeah, semantics need to be handled carefully, but it has this
> > > knock-on-door aspect where kvm says that it actually emulates a feature
> > > only if asked, i.e. with the -cpu ...,+<feature> syntax.
> > >
> > > * new ioctl KVM_GET_EMULATED_CPUID
> > >
> > > Might be overkill and might be used only in a limited fashion since we
> > > don't want to emulate *every* feature in kvm.
> > >
> > > Hmmm. I kinda like the first one more while the second one is cleaner.
> > >
> > The first one needs explicit userspace support to work correctly. This
> > should be other way around: old userspace should do the right thing, but may
> > not support new features, new userspace should be able to support new
> > feature.
>
> Crap, not even qemu is handing in cleared buffers with that g_malloc0()
> thing, AFAICT.
>
> > We may extend KVM_GET_SUPPORTED_CPUID instead of adding new one. There
> > is a padding field in kvm_cpuid2 that we could have reused as flags,
>
> That would've been lovely.
>
> > but unfortunately current implementation does not error if the field is
> > not zero, so if there is a userspace that does not zero the padding it may
> > break. Another options is to reuse high bits of nent as flags (not very
> > nice, but will work).
>
> Not nice?! It is a very nasty hack - that's what it is. :-)
>
Agree, but not nastier than expecting ->function to have special value :)
> Frankly speaking, I'd rather prefer adding a new ioctl. Since old
> userspace won't support the new features, then we just as well can
> simply add the new ioctl.
>
> In all the cases we need to touch userspace - be it to OR in the flags
> into ->nent or to implement the new ioctl. So why not do it in a clean
> manner from the get-go?
>
Agree here too.
--
Gleb.
next prev parent reply other threads:[~2013-04-21 12:51 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-09 23:46 [RFC PATCH] Emulate MOVBE Borislav Petkov
2013-04-10 0:03 ` Borislav Petkov
2013-04-10 0:04 ` H. Peter Anvin
2013-04-10 9:53 ` Borislav Petkov
2013-04-10 9:29 ` Andre Przywara
2013-04-10 10:08 ` Gleb Natapov
2013-04-10 10:17 ` Borislav Petkov
2013-04-10 10:21 ` Gleb Natapov
2013-04-10 10:39 ` Andre Przywara
2013-04-10 12:16 ` Gleb Natapov
2013-04-11 0:18 ` [PATCH -v2] kvm: " Borislav Petkov
2013-04-11 14:28 ` Gleb Natapov
2013-04-11 15:37 ` Borislav Petkov
2013-04-14 7:41 ` Gleb Natapov
2013-04-14 17:32 ` Borislav Petkov
2013-04-14 18:36 ` H. Peter Anvin
2013-04-14 19:09 ` Borislav Petkov
2013-04-14 19:40 ` H. Peter Anvin
2013-04-16 17:42 ` Gleb Natapov
2013-04-17 11:04 ` Borislav Petkov
2013-04-17 13:38 ` Gleb Natapov
2013-04-17 14:02 ` Borislav Petkov
2013-04-18 22:48 ` Borislav Petkov
2013-04-21 9:46 ` Gleb Natapov
2013-04-21 11:30 ` Borislav Petkov
2013-04-21 12:51 ` Gleb Natapov [this message]
2013-04-23 23:41 ` Borislav Petkov
2013-04-23 23:50 ` H. Peter Anvin
2013-04-24 8:42 ` Gleb Natapov
2013-04-24 8:47 ` Borislav Petkov
2013-04-14 8:43 ` Gleb Natapov
2013-04-14 21:02 ` Borislav Petkov
2013-04-16 11:36 ` Paolo Bonzini
2013-04-21 11:46 ` Borislav Petkov
2013-04-21 12:23 ` Borislav Petkov
2013-04-22 8:53 ` Paolo Bonzini
2013-04-22 9:38 ` Borislav Petkov
2013-04-22 9:42 ` Gleb Natapov
2013-04-22 9:52 ` Borislav Petkov
2013-04-22 9:58 ` Gleb Natapov
2013-04-22 13:49 ` Borislav Petkov
2013-04-26 16:08 ` Borislav Petkov
2013-04-16 11:47 ` [RFC PATCH] " Paolo Bonzini
2013-04-16 12:08 ` Borislav Petkov
2013-04-16 12:13 ` H. Peter Anvin
2013-04-16 17:28 ` Gleb Natapov
2013-04-17 10:42 ` Paolo Bonzini
2013-04-17 13:33 ` Gleb Natapov
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=20130421125115.GD8997@redhat.com \
--to=gleb@redhat.com \
--cc=andre@andrep.de \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=x86@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.