linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jim Mattson <jmattson@google.com>
To: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Joerg Roedel <joro@8bytes.org>, kvm list <kvm@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>, Pu Wen <puwen@hygon.cn>
Subject: Re: [PATCH v2 4/7] KVM: x86: Fix CPUID range checks for Hypervisor and Centaur classes
Date: Thu, 5 Mar 2020 13:10:57 -0800	[thread overview]
Message-ID: <CALMp9eRxdGj0DL0_g-an0YC+gTMcWcSk7=md=k4-8S0Zcankbg@mail.gmail.com> (raw)
In-Reply-To: <20200305192532.GN11500@linux.intel.com>

On Thu, Mar 5, 2020 at 11:25 AM Sean Christopherson
<sean.j.christopherson@intel.com> wrote:
>
> On Thu, Mar 05, 2020 at 10:43:51AM -0800, Jim Mattson wrote:
> > On Wed, Mar 4, 2020 at 5:34 PM Sean Christopherson
> > <sean.j.christopherson@intel.com> wrote:
> > >
> > > Rework the masking in the out-of-range CPUID logic to handle the
> > > Hypervisor sub-classes, as well as the Centaur class if the guest
> > > virtual CPU vendor is Centaur.
> > >
> > > Masking against 0x80000000 only handles basic and extended leafs, which
> > > results in Hypervisor range checks being performed against the basic
> > > CPUID class, and Centuar range checks being performed against the
> > > Extended class.  E.g. if CPUID.0x40000000.EAX returns 0x4000000A and
> > > there is no entry for CPUID.0x40000006, then function 0x40000006 would
> > > be incorrectly reported as out of bounds.
> > >
> > > While there is no official definition of what constitutes a class, the
> > > convention established for Hypervisor classes effectively uses bits 31:8
> > > as the mask by virtue of checking for different bases in increments of
> > > 0x100, e.g. KVM advertises its CPUID functions starting at 0x40000100
> > > when HyperV features are advertised at the default base of 0x40000000.
> > >
> > > The bad range check doesn't cause functional problems for any known VMM
> > > because out-of-range semantics only come into play if the exact entry
> > > isn't found, and VMMs either support a very limited Hypervisor range,
> > > e.g. the official KVM range is 0x40000000-0x40000001 (effectively no
> > > room for undefined leafs) or explicitly defines gaps to be zero, e.g.
> > > Qemu explicitly creates zeroed entries up to the Cenatur and Hypervisor
> > > limits (the latter comes into play when providing HyperV features).
> > >
> > > The bad behavior can be visually confirmed by dumping CPUID output in
> > > the guest when running Qemu with a stable TSC, as Qemu extends the limit
> > > of range 0x40000000 to 0x40000010 to advertise VMware's cpuid_freq,
> > > without defining zeroed entries for 0x40000002 - 0x4000000f.
> > >
> > > Note, documentation of Centaur/VIA CPUs is hard to come by.  Designating
> > > 0xc0000000 - 0xcfffffff as the Centaur class is a best guess as to the
> > > behavior of a real Centaur/VIA CPU.
> >
> > Don't forget Transmeta's CPUID range at 0x80860000 through 0x8086FFFF!
>
> Hmm, is it actually needed here?  KVM doesn't advertise support for that
> range in KVM_GET_SUPPORTED_CPUID.  That's also why I limited the Centaur
> range to vendor==CENTAUR, as KVM_GET_SUPPORTED_CPUID enumerates the
> Centaur range if and only if the host CPU is Centaur.

Ah. So cross-vendor CPUID specifications are not supported?

  reply	other threads:[~2020-03-05 21:11 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-05  1:34 [PATCH v2 0/7] KVM: x86: CPUID emulation and tracing fixes Sean Christopherson
2020-03-05  1:34 ` [PATCH v2 1/7] KVM: x86: Trace the original requested CPUID function in kvm_cpuid() Sean Christopherson
2020-03-05 17:50   ` Jim Mattson
2020-03-05  1:34 ` [PATCH v2 2/7] KVM: x86: Add helpers to perform CPUID-based guest vendor check Sean Christopherson
2020-03-05  3:48   ` Xiaoyao Li
2020-03-05 19:58     ` Sean Christopherson
2020-03-05 18:07   ` Jim Mattson
2020-03-05  1:34 ` [PATCH v2 3/7] KVM x86: Extend AMD specific guest behavior to Hygon virtual CPUs Sean Christopherson
2020-03-05  1:34 ` [PATCH v2 4/7] KVM: x86: Fix CPUID range checks for Hypervisor and Centaur classes Sean Christopherson
2020-03-05 18:43   ` Jim Mattson
2020-03-05 19:25     ` Sean Christopherson
2020-03-05 21:10       ` Jim Mattson [this message]
2020-03-05 21:51         ` Sean Christopherson
2020-03-06  9:03           ` Paolo Bonzini
2020-03-10 17:10             ` Sean Christopherson
2020-03-10 17:23               ` Jim Mattson
2020-03-05  1:34 ` [PATCH v2 5/7] KVM: x86: Add build-time assertions on validity of vendor strings Sean Christopherson
2020-03-05  1:34 ` [PATCH v2 6/7] KVM: x86: Refactor out-of-range logic to contain the madness Sean Christopherson
2020-03-05  1:34 ` [PATCH v2 7/7] KVM: x86: Refactor kvm_cpuid() param that controls out-of-range logic Sean Christopherson
2020-03-05 16:42 ` [PATCH v2 0/7] KVM: x86: CPUID emulation and tracing fixes Paolo Bonzini
2020-03-05 17:12   ` Sean Christopherson
2020-03-06  8:45     ` Paolo Bonzini

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='CALMp9eRxdGj0DL0_g-an0YC+gTMcWcSk7=md=k4-8S0Zcankbg@mail.gmail.com' \
    --to=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=puwen@hygon.cn \
    --cc=sean.j.christopherson@intel.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.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;
as well as URLs for NNTP newsgroup(s).