Re: [PATCH 15/25] KVM: TDX: Make pmu_intel.c ignore guest TD case
From: Tony Lindgren
Date: Tue Oct 01 2024 - 06:24:08 EST
On Tue, Sep 10, 2024 at 07:23:10PM +0200, Paolo Bonzini wrote:
> On 8/13/24 00:48, Rick Edgecombe wrote:
> > From: Isaku Yamahata<isaku.yamahata@xxxxxxxxx>
> >
> > Because TDX KVM doesn't support PMU yet (it's future work of TDX KVM
> > support as another patch series) and pmu_intel.c touches vmx specific
> > structure in vcpu initialization, as workaround add dummy structure to
> > struct vcpu_tdx and pmu_intel.c can ignore TDX case.
> >
> > Signed-off-by: Isaku Yamahata<isaku.yamahata@xxxxxxxxx>
> > Signed-off-by: Rick Edgecombe<rick.p.edgecombe@xxxxxxxxx>
>
> Would be nicer not to have this dummy member at all if possible.
>
> Could vcpu_to_lbr_desc() return NULL, and then lbr_desc can be checked in
> intel_pmu_init() and intel_pmu_refresh()? Then the checks for
> is_td_vcpu(vcpu), both inside WARN_ON_ONCE() and outside, can also be
> changed to check NULL-ness of vcpu_to_lbr_desc().
Just catching up on this one, returning NULL works nice. Also for
vcpu_to_lbr_records() we need to return NULL.
Also the ifdefs around the is_td_vcpu() checks should not be needed as
is_td_vcpu() returns false unless CONFIG_INTEL_TDX_HOST is set.
> Also please add a WARN_ON_ONCE(is_td_vcpu(vcpu)), or WARN_ON_ONCE(!lbr_desc)
> given the above suggestion, to return early from vmx_passthrough_lbr_msrs().
Yes will add.
Regards,
Tony