Re: [PATCH v2 2/2] KVM: TDX: Set the has_protected_pmu flag for TDX VMs
From: Sean Christopherson
Date: Thu May 07 2026 - 09:23:37 EST
On Thu, May 07, 2026, Vishal Annapurve wrote:
> TDX module virtualizes PMU for TDX VMs[1]. Host has following
> toggles to control the PMU functionality exposed to TDX VMs:
> 1) Configure TD_PARAMS to allow guests to use performance monitoring.
> 2) Restrict the TD to a subset of the PEBS counters if supported.
> 3) Limit the TD to setup a certain perfmon events using basic/enhanced
> event filtering.
>
> KVM will need to be enlightened to support these toggles.
>
> Explicitly set the hast_protected_pmu flag to avoid KVM trying to manage
> PMU state for TDX VMs using existing PMU virtualization framework.
>
> [1] Section 15.2: https://cdrdv2.intel.com/v1/dl/getContent/733575
>
> Suggested-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> Signed-off-by: Vishal Annapurve <vannapurve@xxxxxxxxxx>
> ---
> arch/x86/kvm/vmx/tdx.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
> index 1e47c194af53..eb4b4518e6f0 100644
> --- a/arch/x86/kvm/vmx/tdx.c
> +++ b/arch/x86/kvm/vmx/tdx.c
> @@ -638,6 +638,12 @@ int tdx_vm_init(struct kvm *kvm)
> kvm->arch.has_private_mem = true;
> kvm->arch.disabled_quirks |= KVM_X86_QUIRK_IGNORE_GUEST_PAT;
>
> + /*
> + * PMU support is provided by the TDX-Module (if enabled for the VM).
> + * From KVM's perspective, the VM doesn't have a virtual PMU.
> + */
> + kvm->arch.has_protected_pmu = true;
Eh, squash this with patch 1. It's not really possible to review patch 1 without
seeing the usage here.
> +
> /*
> * Because guest TD is protected, VMM can't parse the instruction in TD.
> * Instead, guest uses MMIO hypercall. For unmodified device driver,
> --
> 2.54.0.563.g4f69b47b94-goog
>