qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jamie Lokier <jamie@shareable.org>
To: Andrea Arcangeli <aarcange@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] allow sysenter on 32bit guests running on vmx host
Date: Wed, 24 Jun 2009 18:29:34 +0100	[thread overview]
Message-ID: <20090624172934.GG14121@shareable.org> (raw)
In-Reply-To: <20090623162140.GB4379@random.random>

Andrea Arcangeli wrote:
> From: Andrea Arcangeli <aarcange@redhat.com>
> 
> model=2 is not existent when vendor is intel and an errata of P6 says
> that any model <= 2 when family is 6 lack sap feature, so windows and
> linux 32bit guests disable sap in software and slowdown for no good
> reason when running inside kvm on intel CPU.

That's right.  Actually the errata applies when model == 3 and
stepping < 3 too.  Good job that structure has stepping == 3 :-)

(I believe some/all of the chips do have the sep feature, but it's
broken and should't be used.)

> Fix is to set model = 3 so it'll be the duron cpu when kvm runs on
> amd bare metal (not anymore athlon but userland doesn't see the
> difference) and it'll be PII that has sysenter functional like all
> cpus that run KVM have too when on intel bare metal.

But the vendor id is AMD not Intel in this structure, and the PPro
workaround is Intel-only.

I've checked Linux kernel code, and it only disables the sep feature
if the vendor is GenuineIntel, on old and current kernels.

So your patch should make no difference to Linux guests.  Did you
check Linux behaviour?  Does Windows ignore the vendor id?

> Patch will follow, workaround without this fix is -cpu qemu64,model=3.

Only on 64-bit host, of course.

I see the "qemu32" version has model=3, stepping =3 already :-)

> There is a bug in skype that it checks if the sep feature is set to
> run sysenter on intel chip inside its binary without passing through
> ntdll, without verifying the model was <= 2 like windows does, so
> windows forbids sysenter but skype calls it anyway and crashes (this
> is why recent skype stopped working on KVM). This is skype bug and it
> would trigger on real P6 hardware too (but nobody tests skype on
> P6). qemu64,-sep fixed skype too. But because every time we have an
> intel cpu running kvm, we also have sysenter functioning, we boots the
> model to 3 so windows 32bit (and linux32bit) gets a performance boost
> with sysenter too.

Linux checks the vendor id first, so this change should make no
difference to Linux guests.

Are you saying Windows doesn't check the vendor id properly?

It makes sense to change the model number for AMD anyway, as AMD
Athlons don't have the sep feature, even though this isn't a real CPU id.

> diff --git a/target-i386/helper.c b/target-i386/helper.c
> index 8a76abd..636e113 100644
> --- a/target-i386/helper.c
> +++ b/target-i386/helper.c
> @@ -139,7 +139,8 @@ static x86_def_t x86_defs[] = {
>          .vendor2 = CPUID_VENDOR_AMD_2,
>          .vendor3 = CPUID_VENDOR_AMD_3,
>          .family = 6,
> -        .model = 2,
> +        /* AMD Duron || PII Intel with sep capbility - P6 has no sep */
> +        .model = 3,
>          .stepping = 3,
>          .features = PPRO_FEATURES | 
>          /* these features are needed for Win64 and aren't fully implemented */

The code comment could be a lot clearer.
I propose this one, to go immediately before ".family = 6,":

    /* Intel sep feature is broken before family/model/stepping 6/3/3,
       and Windows guests wrongly ignore AMD vendor id when checking. */

-- Jamie

  reply	other threads:[~2009-06-24 17:29 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-23 16:21 [Qemu-devel] allow sysenter on 32bit guests running on vmx host Andrea Arcangeli
2009-06-24 17:29 ` Jamie Lokier [this message]
2009-06-24 17:48   ` Filip Navara
2009-06-24 21:13     ` Andrea Arcangeli
2009-06-24 21:12   ` Andrea Arcangeli
2009-06-24 21:39     ` Jamie Lokier
2009-06-24 22:32       ` Andrea Arcangeli
2009-06-25  8:11       ` [Qemu-devel] KVMs default CPU type (was: allow sysenter on 32bit guests running on vmx host) Andre Przywara
2009-06-25  8:29         ` [Qemu-devel] KVMs default CPU type Avi Kivity
2009-06-26  0:42         ` [Qemu-devel] KVMs default CPU type (was: allow sysenter on 32bit guests running on vmx host) Andrea Arcangeli
2009-06-26  1:06           ` Andrea Arcangeli
2009-06-25 17:39       ` [Qemu-devel] allow sysenter on 32bit guests running on vmx host Paul Brook
2009-06-25 21:02         ` Andrea Arcangeli
2009-06-25 22:12           ` Paul Brook
2009-06-25 23:27             ` Andrea Arcangeli
2009-06-25 23:49               ` Paul Brook
2009-06-26  0:06                 ` Andrea Arcangeli

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=20090624172934.GG14121@shareable.org \
    --to=jamie@shareable.org \
    --cc=aarcange@redhat.com \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).