From: Sean Christopherson <seanjc@google.com>
To: Vishal Annapurve <vannapurve@google.com>
Cc: Kai Huang <kai.huang@intel.com>,
"jmattson@google.com" <jmattson@google.com>,
"mizhang@google.com" <mizhang@google.com>,
Rick P Edgecombe <rick.p.edgecombe@intel.com>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"dapeng1.mi@linux.intel.com" <dapeng1.mi@linux.intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"pbonzini@redhat.com" <pbonzini@redhat.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: [PATCH 2/2] KVM: TDX: Disable pmu virtualization for TDX VMs
Date: Thu, 7 May 2026 07:24:59 -0700 [thread overview]
Message-ID: <afygu67KZuyRql_M@google.com> (raw)
In-Reply-To: <CAGtprH8kn_mOQuwpoTBgg6WQC==cKh8fuYOpNOih_PjUgcUeGQ@mail.gmail.com>
On Wed, May 06, 2026, Vishal Annapurve wrote:
> On Wed, May 6, 2026 at 4:56 PM Huang, Kai <kai.huang@intel.com> wrote:
> >
> > On Wed, 2026-05-06 at 16:03 -0700, Sean Christopherson wrote:
> > > The question then becomes, do we keep patch 1 and also clear enable_pmu in tdx.c,
> > > or do we keep the ordering and have kvm_arch_init_vm() consume has_protected_pmu?
> > > Neither one is particularly awesome :-/
> >
> > Maybe keeping patch 1 is slightly better? This allows the vm_init() to toggle
> > all the values and flags that the default ones don't fit. If we go with latter,
> > when there's similar cases where we need more flags, then kvm_arch_init_vm()
> > needs to consume more flags.
>
> For now I have sent a v2 without moving around the default flags. It's
> definitely better to move them up as done in patch1,
Yes and no. No matter what we do, we're subtly relying on ordering between
initialization in kvm_arch_init_vm() and kvm_x86_ops.vm_init(). I don't see an
easy way around that.
For these fields:
kvm->arch.default_tsc_khz = max_tsc_khz ? : tsc_khz;
kvm->arch.apic_bus_cycle_ns = APIC_BUS_CYCLE_NS_DEFAULT;
kvm->arch.guest_can_read_msr_platform_info = true;
and any other fields that KVM initializes with hardcoded values, from globals, or
from local variables (including @type), I 100% agree that they should be initialized
before calling kvm_x86_ops.vm_init().
But with the proposed has_protected_pmu, I'm leaning towards keeping this:
kvm->arch.enable_pmu = enable_pmu && !kvm->arch.has_protected_pmu;
which obviously means keeping it after kvm_x86_ops.vm_init(). Because if we make
vendor code responsible for clearing kvm->arch.enable_pmu, then (a) we may end
up with duplicate code for SEV-ES+ (does SEV-ES/SNP allow for a virtual/emulated
PMU?), and (b) the x86 code _looks_ wrong, because kvm_arch_init_vm() will ignore
kvm->arch.has_protected_pmu, while the KVM_CAP_PMU_CAPABILITY case-statement does
not.
next prev parent reply other threads:[~2026-05-07 14:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-05 1:41 [PATCH 0/2] KVM: TDX: Disable PMU virtualization for TDX VMs FirstName LastName
2026-05-05 1:41 ` [PATCH 1/2] KVM: x86: Move the default arch state init before vm_init() call FirstName LastName
2026-05-05 1:41 ` [PATCH 2/2] KVM: TDX: Disable pmu virtualization for TDX VMs FirstName LastName
2026-05-06 23:03 ` Sean Christopherson
2026-05-06 23:39 ` Vishal Annapurve
2026-05-06 23:56 ` Huang, Kai
2026-05-07 0:40 ` Vishal Annapurve
2026-05-07 14:24 ` Sean Christopherson [this message]
2026-05-13 18:25 ` Vishal Annapurve
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=afygu67KZuyRql_M@google.com \
--to=seanjc@google.com \
--cc=dapeng1.mi@linux.intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=jmattson@google.com \
--cc=kai.huang@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mizhang@google.com \
--cc=pbonzini@redhat.com \
--cc=rick.p.edgecombe@intel.com \
--cc=vannapurve@google.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.