All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, jmattson@google.com
Subject: Re: [PATCH] KVM: x86: Do not expose the host value of CPUID.8000001EH
Date: Tue, 25 Oct 2022 21:25:57 +0000	[thread overview]
Message-ID: <Y1hUZYs7kz7JXmr7@google.com> (raw)
In-Reply-To: <e906030e-a77d-468f-2c68-d6c643a768c4@redhat.com>

On Tue, Oct 25, 2022, Paolo Bonzini wrote:
> On 10/25/22 18:46, Sean Christopherson wrote:
> > On Sat, Oct 22, 2022, Paolo Bonzini wrote:
> > > Several fields of CPUID.8000001EH (ExtendedApicId in EAX[31:0],
> > > CoreId in EBX[7:0], NodeId in ECX[7:0]) vary on each processor,
> > > and it is simply impossible to fit the right values in the
> > > KVM_GET_SUPPORTED_CPUID API, in such a way that they can be
> > > passed to KVM_SET_CPUID2.
> > 
> > The same is true for 0xb and 0x1f, why delete 0x8000001e but keep those? I agree
> > that KVM_GET_SUPPORTED_CPUID can't get this right, but KVM can at least be
> > consistent with itself.
> 
> 0xb and 0x1f are already special cased because EDX is set to the X2APIC id.
> KVM knows how to do that unlike the NodeId and CoreId.

But KVM doesn't properly support 0xB/0x1F.  E.g. if usersepace regurgitates
KVM_GET_SUPPORTED_CPUID back into KVM_SET_CPUID2, all vCPUs will observe the same
x2APIC ID in EDX, and it will be a host x2APIC ID to boot.

KVM only handles the where userspace provides 0xB.1 (or 0x1F.1), the guest performs
CPUID with ECX>1, _and_ userspace doesn't provide the exact CPUID entry. 

I suppose one could argue that KVM needs to communicate to userspace that KVM
emulates the edge case behavior of CPUID 0xB and 0x1F, but I would argue that KVM
communicates that by announcing a max basic leaf >= 0xB/0x1F.

  reply	other threads:[~2022-10-25 21:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-22  8:26 [PATCH] KVM: x86: Do not expose the host value of CPUID.8000001EH Paolo Bonzini
2022-10-24 13:06 ` Xiaoyao Li
2022-10-25 16:46 ` Sean Christopherson
2022-10-25 21:09   ` Paolo Bonzini
2022-10-25 21:25     ` Sean Christopherson [this message]
2022-10-25 21:31       ` 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=Y1hUZYs7kz7JXmr7@google.com \
    --to=seanjc@google.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.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 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.