Re: [RFC PATCH v6 05/35] KVM: arm64: Add KVM_CAP_ARM_SPE capability

Leo Yan
2025-12-14T12:18:49Z

On Fri, Nov 14, 2025 at 04:06:46PM +0000, Alexandru Elisei wrote:

[...]

> +void kvm_host_spe_init(struct arm_spe_pmu *arm_spu)
> +{
> + struct arm_spu_entry *entry;
> +
> + guard(mutex)(&arm_spus_lock);
> +
> + entry = kmalloc(sizeof(*entry), GFP_KERNEL);
> + if (!entry)
> + return;
> +
> + entry->arm_spu = arm_spu;
> + list_add_tail(&entry->link, &arm_spus);
> +
> + if (list_is_singular(&arm_spus))
> + static_branch_enable(&kvm_spe_available);

We can simply check if list_empty(&arm_spus) in kvm_supports_spe(), thus
the static key kvm_spe_available is not needed. Another benefit is this
is consistent with CPU PMU's virt implementation.

Thanks,
Leo