Re: [PATCH v7 17/17] KVM: selftests: Add svm_pmu_host_guest_test for Host-Only/Guest-Only bits
From: Yosry Ahmed
Date: Thu May 28 2026 - 14:01:45 EST
On Wed, May 27, 2026 at 7:25 PM Sean Christopherson <seanjc@xxxxxxxxxx> wrote:
>
> On Wed, May 27, 2026, Yosry Ahmed wrote:
> > +int main(int argc, char *argv[])
> > +{
> > + struct kvm_pmu_event_filter *filter;
> > + struct kvm_vcpu *vcpu;
> > + struct kvm_vm *vm;
> > + struct ucall uc;
> > + gva_t svm_gva;
> > +
> > + TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_SVM));
> > + TEST_REQUIRE(kvm_is_pmu_enabled());
> > + TEST_REQUIRE(get_kvm_amd_param_bool("enable_mediated_pmu"));
>
> This can and should be handled in a helper, using either host_cpu_is_intel or
> host_cpu_is_amd_compatible to choose while vendor to query.
>
> > + TEST_REQUIRE(host_cpu_is_amd && kvm_cpu_family() >= 0x17);
>
> Why the family check? Actually, why check host_cpu_is_amd at all?
I assume you mean that we don't need host_cpu_is_amd because we
require X86_FEATURE_SVM above? Unless H/G emulation doesn't really
work for cross-vendor emulation? I honestly don't know.
I will defer to Jim for the family check, I took this as-is. My guess
is that maybe older families did not support H/G bits or some of the
other PMU features used by the test.