[PATCH v2 0/9] KVM: selftests: Add Zhaoxin CPU support

Ewan Hai-oc posted 9 patches 2 weeks, 1 day ago
.../testing/selftests/kvm/include/x86/processor.h | 10 +++++++++-
tools/testing/selftests/kvm/include/x86/vmx.h     |  1 +
tools/testing/selftests/kvm/lib/x86/processor.c   |  8 +++++++-
tools/testing/selftests/kvm/lib/x86/vmx.c         | 15 +++++++++++++++
.../testing/selftests/kvm/x86/feature_msrs_test.c | 15 ++++++++++++++-
.../selftests/kvm/x86/fix_hypercall_test.c        |  2 +-
.../selftests/kvm/x86/nested_exceptions_test.c    |  4 +++-
.../selftests/kvm/x86/vmx_apic_access_test.c      |  1 +
.../x86/vmx_exception_with_invalid_guest_state.c  |  2 +-
9 files changed, 52 insertions(+), 6 deletions(-)
[PATCH v2 0/9] KVM: selftests: Add Zhaoxin CPU support
Posted by Ewan Hai-oc 2 weeks, 1 day ago
From: Frank Zhu <frankzhu@zhaoxin.com>

This series adds Zhaoxin CPU support to the KVM x86 selftests.

Zhaoxin CPUs use the "CentaurHauls" and "  Shanghai  " vendor strings
and implement VMX-compatible virtualization, so KVM handles them via
its VMX backend.  Several selftests currently assume a CPU is either
Intel or AMD, which makes them misbehave or skip on Zhaoxin hosts.

Patch 1 adds Zhaoxin detection and the compatibility flag. Patch 2
updates the mediated PMU parameter lookup. Patches 3-5 and 7 apply the
compatibility flag to VMX-backed paths. Patch 6 handles feature MSR
testing without PDCM, patch 8 handles Zhaoxin's #GP error-code behavior,
and patch 9 checks APIC-access virtualization support.

Frank Zhu (9):
  KVM: selftests: Add Zhaoxin CPU detection support
  KVM: selftests: Use host_cpu_is_intel_compatible for mediated PMU
  KVM: selftests: nx_huge_pages_test: Add TDP detection for Zhaoxin CPUs
  KVM: selftests: vmx_exception_with_invalid_guest_state: Support
    Zhaoxin CPUs
  KVM: selftests: fix_hypercall_test: Add Zhaoxin CPU support
  KVM: selftests: Skip PERF_CAPABILITIES vCPU checks without PDCM
  KVM: selftests: feature_msrs_test: Extend MSR_IA32_UCODE_REV quirk to
    Zhaoxin
  KVM: selftests: nested_exceptions_test: Add Zhaoxin CPU support
  KVM: selftests: vmx_apic_access_test: Check APIC virtualization
    support

 .../testing/selftests/kvm/include/x86/processor.h | 10 +++++++++-
 tools/testing/selftests/kvm/include/x86/vmx.h     |  1 +
 tools/testing/selftests/kvm/lib/x86/processor.c   |  8 +++++++-
 tools/testing/selftests/kvm/lib/x86/vmx.c         | 15 +++++++++++++++
 .../testing/selftests/kvm/x86/feature_msrs_test.c | 15 ++++++++++++++-
 .../selftests/kvm/x86/fix_hypercall_test.c        |  2 +-
 .../selftests/kvm/x86/nested_exceptions_test.c    |  4 +++-
 .../selftests/kvm/x86/vmx_apic_access_test.c      |  1 +
 .../x86/vmx_exception_with_invalid_guest_state.c  |  2 +-
 9 files changed, 52 insertions(+), 6 deletions(-)

Changes since v1:
- Rebase the series onto kvm-x86/next.
- Spell out Zhaoxin in helper, macro, and patch names.
- Add a new patch (2/9) to use host_cpu_is_intel_compatible in
  kvm_is_mediated_pmu_enabled() so Zhaoxin CPUs look up the mediated
  PMU parameter from kvm_intel.
- Reword the Zhaoxin CPU detection commit message to document the new
  host_cpu_is_intel_compatible flag.
- Expand the nested_exceptions_test commit message to explain why
  Zhaoxin CPUs leave EXT clear for the #GP generated when vectoring
  an injected #SS.

base-commit: 76671054f9a1ff6abb976583cd8da37650acdc97
-- 
2.34.1
Re: [PATCH v2 0/9] KVM: selftests: Add Zhaoxin CPU support
Posted by Sean Christopherson 4 days, 1 hour ago
On Thu, 10 Sep 2026 19:54:05 +0800, Ewan Hai-oc wrote:
> From: Frank Zhu <frankzhu@zhaoxin.com>
> 
> This series adds Zhaoxin CPU support to the KVM x86 selftests.
> 
> Zhaoxin CPUs use the "CentaurHauls" and "  Shanghai  " vendor strings
> and implement VMX-compatible virtualization, so KVM handles them via
> its VMX backend.  Several selftests currently assume a CPU is either
> Intel or AMD, which makes them misbehave or skip on Zhaoxin hosts.
> 
> [...]

Applied to kvm-x86 selftests, thanks!

[1/9] KVM: selftests: Add Zhaoxin CPU detection support
      https://github.com/kvm-x86/linux/commit/d80ddf303f3a
[2/9] KVM: selftests: Use host_cpu_is_intel_compatible for mediated PMU
      https://github.com/kvm-x86/linux/commit/9bb23b9e85ea
[3/9] KVM: selftests: nx_huge_pages_test: Add TDP detection for Zhaoxin CPUs
      https://github.com/kvm-x86/linux/commit/54edcc375a46
[4/9] KVM: selftests: vmx_exception_with_invalid_guest_state: Support Zhaoxin CPUs
      https://github.com/kvm-x86/linux/commit/7610139e1ab7
[5/9] KVM: selftests: fix_hypercall_test: Add Zhaoxin CPU support
      https://github.com/kvm-x86/linux/commit/2625a21954c4
[6/9] KVM: selftests: Skip PERF_CAPABILITIES vCPU checks without PDCM
      SKIP: (this is a KVM bug)
[7/9] KVM: selftests: feature_msrs_test: Extend MSR_IA32_UCODE_REV quirk to Zhaoxin
      https://github.com/kvm-x86/linux/commit/658d82c07e78
[8/9] KVM: selftests: nested_exceptions_test: Add Zhaoxin CPU support
      https://github.com/kvm-x86/linux/commit/1a0abfad6c80
[9/9] KVM: selftests: vmx_apic_access_test: Check APIC virtualization support
      https://github.com/kvm-x86/linux/commit/0d5c14800de0

--
https://github.com/kvm-x86/linux/tree/next