[kvm-unit-tests PATCH 00/16] x86: Add CPUID properties, clean up related code

Sean Christopherson seanjc at google.com
Thu May 29 15:19:13 PDT 2025


Copy KVM selftests' X86_PROPERTY_* infrastructure (multi-bit CPUID
fields), and use the properties to clean up various warts.  The SEV code
is particular makes things much harder than they need to be (I went down
this rabbit hole purely because the stupid MSR_SEV_STATUS definition was
buried behind CONFIG_EFI=y, *sigh*).

The first patch is a common change to add static_assert() as a wrapper
to _Static_assert().  Forcing code to provide an error message just leads
to useless error messages.

Compile tested on arm64, riscv64, and s390x.

Sean Christopherson (16):
  lib: Add and use static_assert() convenience wrappers
  x86: Encode X86_FEATURE_* definitions using a structure
  x86: Add X86_PROPERTY_* framework to retrieve CPUID values
  x86: Use X86_PROPERTY_MAX_VIRT_ADDR in is_canonical()
  x86: Implement get_supported_xcr0() using
    X86_PROPERTY_SUPPORTED_XCR0_{LO,HI}
  x86: Add and use X86_PROPERTY_INTEL_PT_NR_RANGES
  x86/pmu: Rename pmu_gp_counter_is_available() to
    pmu_arch_event_is_available()
  x86/pmu: Rename gp_counter_mask_length to arch_event_mask_length
  x86/pmu: Mark all arch events as available on AMD
  x86/pmu: Use X86_PROPERTY_PMU_* macros to retrieve PMU information
  x86/sev: Use VC_VECTOR from processor.h
  x86/sev: Skip the AMD SEV test if SEV is unsupported/disabled
  x86/sev: Define and use X86_FEATURE_* flags for CPUID 0x8000001F
  x86/sev: Use X86_PROPERTY_SEV_C_BIT to get the AMD SEV C-bit location
  x86/sev: Use amd_sev_es_enabled() to detect if SEV-ES is enabled
  x86: Move SEV MSR definitions to msr.h

 lib/riscv/asm/isa.h      |   4 +-
 lib/s390x/asm/arch_def.h |   6 +-
 lib/s390x/fault.c        |   3 +-
 lib/util.h               |   3 +
 lib/x86/amd_sev.c        |  48 ++----
 lib/x86/amd_sev.h        |  29 ----
 lib/x86/msr.h            |   6 +
 lib/x86/pmu.c            |  22 ++-
 lib/x86/pmu.h            |   8 +-
 lib/x86/processor.h      | 312 ++++++++++++++++++++++++++++-----------
 x86/amd_sev.c            |  63 ++------
 x86/la57.c               |   2 +-
 x86/lam.c                |   4 +-
 x86/pmu.c                |   8 +-
 x86/xsave.c              |  11 +-
 15 files changed, 284 insertions(+), 245 deletions(-)


base-commit: 72d110d8286baf1b355301cc8c8bdb42be2663fb
-- 
2.49.0.1204.g71687c7c1d-goog




More information about the kvm-riscv mailing list