public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Xiaoyao Li <xiaoyao.li@intel.com>
Cc: Hao Xiang <hao.xiang@linux.alibaba.com>,
	Chao Gao <chao.gao@intel.com>,
	kvm@vger.kernel.org, shannon.zhao@linux.alibaba.com,
	pbonzini@redhat.com, linux-kernel@vger.kernel.org,
	Aaron Lewis <aaronlewis@google.com>
Subject: Re: [PATCH] kvm: x86: emulate MSR_PLATFORM_INFO msr bits
Date: Wed, 23 Aug 2023 14:31:54 +0000	[thread overview]
Message-ID: <ZOYYFPrQSPUjS7kk@google.com> (raw)
In-Reply-To: <498ee0c4-4736-68a7-7cbf-12e54f6a0d22@intel.com>

On Wed, Aug 23, 2023, Xiaoyao Li wrote:
> On 8/22/2023 12:11 AM, Sean Christopherson wrote:
> > > Set these msr bits (needed by turbostat on intel platform) in KVM by
> > > default.  Of cource, QEMU can also set MSR value by need. It does not
> > > conflict.
> > 
> > It doesn't conflict per se, but it's still problematic.  By stuffing a default
> > value, KVM _forces_ userspace to override the MSR to align with the topology and
> > CPUID defined by userspace.
> 
> I don't understand how this MSR is related to topology and CPUID?

Heh, looked at the SDM to double check myself, and the first hit when searching
for MSR_PLATFORM_INFO says:

  When TSC scaling is enabled for a guest using Intel PT, the VMM should ensure
  that the value of Maximum Non-Turbo Ratio[15:8] in MSR_PLATFORM_INFO (MSR 0CEH)
  and the TSC/”core crystal clock” ratio (EBX/EAX) in CPUID leaf 15H are set in
  a manner consistent with the resulting TSC rate that will be visible to the VM.

As Chao pointed out, the MSR is technically per package, so a weird setup could
have sockets with different frequencies, or enumerate a virtual topology to the
guest with such a configuration.  I doubt/hope no one actually does something
like that, but it's theoretically possible, and one of the many reasons why KVM
needs to stay out of the way and let userspace define the vCPU model.

> > And if userspace uses KVM's "default" CPUID, or lack thereof, using the
> > underlying values from hardware are all but guaranteed to be wrong.
> 
> Could you please elaborate?

I guess an empty CPUID would probably be ok?  If there's no CPUID.0x15, it can't
be wrong.  It's largely a moot point though, I highly doubt anyone runs a "real"
VM without populating _something_ in guest CPUID.

  reply	other threads:[~2023-08-23 14:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-21  3:26 [PATCH] kvm: x86: emulate MSR_PLATFORM_INFO msr bits Hao Xiang
2023-08-21  7:52 ` Chao Gao
2023-08-21  9:11   ` Hao Xiang
2023-08-21 10:44     ` Chao Gao
2023-08-21 11:44       ` Hao Xiang
2023-08-21 16:11         ` Sean Christopherson
2023-08-23  6:24           ` Xiaoyao Li
2023-08-23 14:31             ` Sean Christopherson [this message]
2023-08-25  3:27               ` Xiaoyao Li
  -- strict thread matches above, loose matches on Subject: below --
2023-08-21  3:22 Hao Xiang
2023-08-22 16:50 ` kernel test robot
2023-08-23  0:26 ` kernel test robot
2023-08-23  3:41 ` Xiaoyao Li

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=ZOYYFPrQSPUjS7kk@google.com \
    --to=seanjc@google.com \
    --cc=aaronlewis@google.com \
    --cc=chao.gao@intel.com \
    --cc=hao.xiang@linux.alibaba.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=shannon.zhao@linux.alibaba.com \
    --cc=xiaoyao.li@intel.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