Skip to content

x86/vmx: align with Linux kernel VMX definitions

Jon Kohler kvm 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest17 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/17lib: add linux vmx.h clone from 6.16lib/linux/vmx.h+672 -00 replies
2/17lib: add linux trapnr.h clone from 6.16lib/linux/trapnr.h+44 -00 replies
3/17lib: add vmxfeatures.h clone from 6.16lib/linux/vmxfeatures.h+93 -00 replies
4/17lib: define __aligned() in compiler.hlib/linux/compiler.h+1 -00 replies
5/17x86/vmx: basic integration for new vmx.hlib/linux/vmx.h x86/vmx.c x86/vmx.h +1 more+17 -1020 replies
6/17x86/vmx: switch to new vmx.h EPT violation defsx86/vmx.h x86/vmx_tests.c+77 -610 replies
7/17x86/vmx: switch to new vmx.h EPT RWX defsx86/vmx.c x86/vmx.h x86/vmx_tests.c+165 -980 replies
8/17x86/vmx: switch to new vmx.h EPT access and dirty defsx86/vmx.c x86/vmx.h x86/vmx_tests.c+35 -310 replies
9/17x86/vmx: switch to new vmx.h EPT capability and memory type defslib/x86/msr.h x86/vmx.c x86/vmx.h +1 more+40 -390 replies
10/17x86/vmx: switch to new vmx.h primary processor-based VM-execution controlslib/linux/vmx.h x86/vmx.c x86/vmx.h +1 more+87 -920 replies
11/17x86/vmx: switch to new vmx.h secondary execution control bitx86/vmx.c x86/vmx.h x86/vmx_tests.c+63 -490 replies
12/17x86/vmx: switch to new vmx.h secondary execution controlsx86/vmx.c x86/vmx.h x86/vmx_tests.c+136 -1100 replies
13/17x86/vmx: switch to new vmx.h pin based VM-execution controlsx86/vmx.c x86/vmx.h x86/vmx_tests.c+74 -630 replies
14/17x86/vmx: switch to new vmx.h exit controlsx86/vmx.c x86/vmx.h x86/vmx_tests.c+52 -520 replies
15/17x86/vmx: switch to new vmx.h entry controlsx86/vmx.c x86/vmx.h x86/vmx_tests.c+55 -570 replies
16/17x86/vmx: switch to new vmx.h interrupt defsx86/vmx.h x86/vmx_tests.c+6 -280 replies
17/17x86/vmx: align exit reasons with Linux uapix86/vmx.c x86/vmx.h x86/vmx_tests.c+280 -2620 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [kvm-unit-tests PATCH 00/17] x86/vmx: align with Linux kernel VMX definitions

This series modernizes VMX definitions to align with the canonical ones within Linux kernel source. Currently, kvm-unit-tests uses custom VMX constant definitions that have grown organically and have diverged from the kernel, increasing the overhead to grok from one code base to another.

This alignment provides several benefits:
- Reduces maintenance overhead by using authoritative definitions
- Eliminates potential bugs from definition mismatches
- Makes the test suite more consistent with kernel code
- Simplifies future updates when new VMX features are added

Given the lines touched, I've broken this up into two groups within the series:

Group 1: Import various headers from Linux kernel 6.16 (P01-04)

Headers were brought in with minimal adaptation outside of minor tweaks for includes, etc.

Group 2: Mechanically replace existing constants with equivalents (P05-17)

Replace custom VMX constant definitions in x86/vmx.h with Linux kernel equivalents from lib/linux/vmx.h. This systematic replacement covers:

- Pin-based VM-execution controls (PIN_* -> PIN_BASED_*)
- CPU-based VM-execution controls (CPU_* -> CPU_BASED_*, SECONDARY_EXEC_*)
- VM-exit controls (EXI_* -> VM_EXIT_*)
- VM-entry controls (ENT_* -> VM_ENTRY_*)
- VMCS field names (custom enum -> standard Linux enum)
- VMX exit reasons (VMX_* -> EXIT_REASON_*)
- Interrupt/exception type definitions

All functional behavior is preserved - only the constant names and values change to match Linux kernel definitions. All existing VMX tests pass with no functional changes.

There is still a bit of bulk in x86/vmx.h, which can be addressed in future patches as needed.

Jon Kohler (17):
lib: add linux vmx.h clone from 6.16
lib: add linux trapnr.h clone from 6.16
lib: add vmxfeatures.h clone from 6.16
lib: define __aligned() in compiler.h
x86/vmx: basic integration for new vmx.h
x86/vmx: switch to new vmx.h EPT violation defs x86/vmx: switch to new vmx.h EPT RWX defs
x86/vmx: switch to new vmx.h EPT access and dirty defs x86/vmx: switch to new vmx.h EPT capability and memory type defs x86/vmx: switch to new vmx.h primary processor-based VM-execution
controls
x86/vmx: switch to new vmx.h secondary execution control bit x86/vmx: switch to new vmx.h secondary execution controls x86/vmx: switch to new vmx.h pin based VM-execution controls x86/vmx: switch to new vmx.h exit controls
x86/vmx: switch to new vmx.h entry controls
x86/vmx: switch to new vmx.h interrupt defs
x86/vmx: align exit reasons with Linux uapi

 lib/linux/compiler.h    |    1 +
 lib/linux/trapnr.h      |   44 ++
 lib/linux/vmx.h         |  672 ++++++++++++++++++
 lib/linux/vmxfeatures.h |   93 +++
 lib/x86/msr.h           |   14 +
 x86/vmx.c               |  230 +++---
 x86/vmx.h               |  356 ++--------
 x86/vmx_tests.c         | 1489 ++++++++++++++++++++++-----------------
 8 files changed, 1876 insertions(+), 1023 deletions(-)
 create mode 100644 lib/linux/trapnr.h
 create mode 100644 lib/linux/vmx.h
 create mode 100644 lib/linux/vmxfeatures.h

base-commit: 890498d834b68104e79b57a801fa11fc6ce82846

Signature · 1 line
2.43.0