On Tue, Sep 01, 2026 at 05:19:10PM -0700, Sean Christopherson wrote:
> On Thu, Jul 30, 2026, Ewan Hai-oc wrote:
> > From: Frank Zhu <[email protected]>
> >
> > Add infrastructure to detect Zhaoxin CPUs in KVM selftests. Zhaoxin
> > CPUs use vendor strings "CentaurHauls" or " Shanghai " and implement
> > VMX-compatible virtualization technology.
> >
> > Signed-off-by: Frank Zhu <[email protected]>
> > Signed-off-by: Ewan Hai <[email protected]>
> > ---
> > tools/testing/selftests/kvm/include/x86/processor.h | 7 +++++++
> > tools/testing/selftests/kvm/lib/x86/processor.c | 3 +++
> > 2 files changed, 10 insertions(+)
> >
> > diff --git a/tools/testing/selftests/kvm/include/x86/processor.h
> > b/tools/testing/selftests/kvm/include/x86/processor.h
> > index b161174ece45..9840b583877c 100644
> > --- a/tools/testing/selftests/kvm/include/x86/processor.h
> > +++ b/tools/testing/selftests/kvm/include/x86/processor.h
> > @@ -23,6 +23,7 @@ extern bool host_cpu_is_intel;
> > extern bool host_cpu_is_amd;
> > extern bool host_cpu_is_hygon;
> > extern bool host_cpu_is_amd_compatible;
> > +extern bool host_cpu_is_zx;
>
> Please spell out "zhaoxin", "zx" isn't intuitive for most of us (I keep
> thinking
> it's a compression feature).
>
> And do the same thing we did in commit 53b2869231d3 ("KVM: selftests: Add a
> flag
> to identify AMD compatible test cases"), and add host_cpu_is_intel_compatible.
> That should cut down on the number of checks on is_zhaoxin, and should help
> avoid
> issues like the ones Sashiko pointed out.
>
Agreed. In v2, I added host_cpu_is_intel_compatible
(host_cpu_is_intel || host_cpu_is_zhaoxin) and used it where host_cpu_is_intel
serves as a proxy for KVM's VMX backend:
- kvm_is_tdp_enabled() now queries kvm_intel's ept parameter.
- vmx_exception_with_invalid_guest_state now runs on Zhaoxin CPUs.
- fix_hypercall_test now selects VMCALL on Zhaoxin CPUs.
- kvm_is_mediated_pmu_enabled() now queries kvm_intel's
enable_mediated_pmu parameter on Zhaoxin CPUs.
- feature_msrs_test now uses the VMX initial value for
MSR_IA32_UCODE_REV on Zhaoxin CPUs.
I left kvm_buslock_test unchanged. KVM does not currently advertise
KVM_CAP_X86_BUS_LOCK_EXIT on Zhaoxin systems, so the test skips before
reaching the vendor-specific assertion. That assertion distinguishes
trap-like from fault-like behavior, so changing it without Zhaoxin
bus-lock exit support would be untested.
The PMU tests are intentionally unchanged. pmu_counters_test explicitly
requires an Intel host, while pmu_event_filter_test requires either
use_intel_pmu() or use_amd_pmu(); neither is true on Zhaoxin. Some
Zhaoxin PMU registers and MSRs differ from Intel's, so Zhaoxin-specific
PMU coverage is outside the scope of this series.