Skip to contentSkip to conversation

x86: random smattering of changes

GIT PULL Sean Christopherson 3 participants 8 messages May 27 – May 30 KVM

lore
Share & tools
lore

Sean Christopherson

author reviewer
#0 lore raw

Please pull a rather random set of changes that have been accumulating over the last few months.

Note, the SKINIT nSVM intercept test fails on some Turin CPUs, but allegedly only on pre-production hardware? I assume/hope such hardware isn't commonly available, and so didn't bother trying to handle it in upstream KUT.

The following changes since commit 9eb6c57313060d34f7e5b2ac6f90bb5873bbe2ff:

Merge branch 'mbec' into HEAD (2026-05-12 13:03:25 +0200)

are available in the Git repository at:

https://github.com/kvm-x86/kvm-unit-tests.git tags/kvm-x86-2026.05.27

for you to fetch changes up to c10d4616e2ad5d95553b2f0c389b4546dfacd76f:

x86/vmx: Remove the superfluous vmx_cet config entry (2026-05-27 08:59:46 -0700)

----------------------------------------------------------------
KVM-Unit-Tests x86 changes:

- Track SVM's EXIT_CODE as a 64-bit value, to verify KVM does the same.

- Add nSVM tests for unsupported instruction intercepts.

- Serialize the (v)CPU after WRMSR(TSCDEADLINE) to prepare for APIC timer virtualization.

- Disable PKU in the vCPU model when running the nVMX access tests to make the runtime somewhat reasonable.

- Extended the VMOVDQA test to cover VMOVNTDQA as well.

- Add test coverage for ENTER + emulated MMIO.

- Misc fixes, cleanups, and minor coverage enhancements.

----------------------------------------------------------------
Isaku Yamahata (2):
x86: Replace NOP with CPUID after WRMSR(TSCDEADLINE) to serialize deadline timer
x86: tscdeadline_latency: Remove unnecessary nop

Jim Mattson (1):
x86: nVMX: Add retry loop to advanced RTM debugging subtest

Kevin Cheng (2):
x86/svm: Add missing svm intercepts x86/svm: Add unsupported instruction intercept test

Maxim Levitsky (1):
Skip PMU portion of vmware_backdoors test if PMU is not enabled.

Sean Christopherson (9):
x86/cstart: Delete "local" version of save_id() to fix x2APIC SMP bug x86/debug: Fix macro definitions for DR7 local/global enable bits x86/svm: Track and handle exit code as an unsigned 64-bit value
x86: Disable PKU in vCPU model for vmx_pf_{vpid/no_vpid/invvpid}_test x86/xsave: Extend VMOVDQA testing to also cover VMOVNTDQA x86/debug: Verify DR6 is always empty on an INT1/ICEBP #DB x86/apic: Verify LVT timer register mode reads back what was written x86/emulator: Add testcases for ENTER + emulated MMIO x86/vmx: Remove the superfluous vmx_cet config entry

 lib/x86/asm/debugreg.h    |   5 +-
 lib/x86/msr.h             |   1 +
 lib/x86/processor.h       |  11 ++
 x86/apic.c                |   8 +-
 x86/cstart.S              |   7 --
 x86/debug.c               |  34 +++---
 x86/emulator.c            |  66 ++++++-----
 x86/emulator64.c          |  64 ++++++++++
 x86/svm.c                 |  22 +++-
 x86/svm.h                 |  98 +++++++++++++---
 x86/svm_npt.c             |   4 +-
 x86/svm_tests.c           | 290 ++++++++++++++++++++++++++++++----------------
 x86/tscdeadline_latency.c |   1 -
 x86/unittests.cfg         |  31 ++---
 x86/vmexit.c              |   3 +-
 x86/vmware_backdoors.c    |  18 ++-
 x86/vmx_tests.c           |  76 +++++++++---
 x86/xsave.c               |  36 +++++-
 18 files changed, 559 insertions(+), 216 deletions(-)
#1 lore raw
Quoted 44 lines · Sean Christopherson

Please pull a rather random set of changes that have been accumulating over the last few months.

Note, the SKINIT nSVM intercept test fails on some Turin CPUs, but allegedly only on pre-production hardware? I assume/hope such hardware isn't commonly available, and so didn't bother trying to handle it in upstream KUT.

The following changes since commit 9eb6c57313060d34f7e5b2ac6f90bb5873bbe2ff:

Merge branch 'mbec' into HEAD (2026-05-12 13:03:25 +0200)

are available in the Git repository at:

https://github.com/kvm-x86/kvm-unit-tests.git tags/kvm-x86-2026.05.27

for you to fetch changes up to c10d4616e2ad5d95553b2f0c389b4546dfacd76f:

x86/vmx: Remove the superfluous vmx_cet config entry (2026-05-27 08:59:46 -0700)

----------------------------------------------------------------
KVM-Unit-Tests x86 changes:

- Track SVM's EXIT_CODE as a 64-bit value, to verify KVM does the same.

- Add nSVM tests for unsupported instruction intercepts.

- Serialize the (v)CPU after WRMSR(TSCDEADLINE) to prepare for APIC timer virtualization.

- Disable PKU in the vCPU model when running the nVMX access tests to make the runtime somewhat reasonable.

- Extended the VMOVDQA test to cover VMOVNTDQA as well.

- Add test coverage for ENTER + emulated MMIO.

- Misc fixes, cleanups, and minor coverage enhancements.

----------------------------------------------------------------
Isaku Yamahata (2):
x86: Replace NOP with CPUID after WRMSR(TSCDEADLINE) to serialize deadline timer
x86: tscdeadline_latency: Remove unnecessary nop

Quoted 6 lines

Jim Mattson (1):
x86: nVMX: Add retry loop to advanced RTM debugging subtest

Kevin Cheng (2):
x86/svm: Add missing svm intercepts x86/svm: Add unsupported instruction intercept test

Any reason not to include this series:
https://lore.kernel.org/kvm/[email protected]/?

#2 lore raw
Quoted 8 lines
Quoted 8 lines

----------------------------------------------------------------
Isaku Yamahata (2):
x86: Replace NOP with CPUID after WRMSR(TSCDEADLINE) to serialize deadline timer
x86: tscdeadline_latency: Remove unnecessary nop

Jim Mattson (1):
x86: nVMX: Add retry loop to advanced RTM debugging subtest

Quoted 6 lines
Quoted 3 lines

Kevin Cheng (2):
x86/svm: Add missing svm intercepts x86/svm: Add unsupported instruction intercept test

Any reason not to include this series:
https://lore.kernel.org/kvm/[email protected]/?

Also this (but less importantly):
https://lore.kernel.org/kvm/[email protected]/.

author reviewer
#3 lore raw
Quoted 8 lines · Yosry Ahmed
Quoted 8 lines
Quoted 8 lines

----------------------------------------------------------------
Isaku Yamahata (2):
x86: Replace NOP with CPUID after WRMSR(TSCDEADLINE) to serialize deadline timer
x86: tscdeadline_latency: Remove unnecessary nop

Jim Mattson (1):
x86: nVMX: Add retry loop to advanced RTM debugging subtest

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

Kevin Cheng (2):
x86/svm: Add missing svm intercepts x86/svm: Add unsupported instruction intercept test

Any reason not to include this series:
https://lore.kernel.org/kvm/[email protected]/?

I ran out of steam (and time), and I don't want to merge like this without a high level of confidence that it's the least awful option.

+asm(
+ "insn_sidt: sidt idt_descr;ret\n\t"
+ "insn_sgdt: sgdt gdt_descr;ret\n\t"
+ "insn_sldt: sldt %ax;ret\n\t"
+ "insn_str: str %ax;ret\n\t"
+ "insn_ltr: ltr %ax;ret\n\t"
+ "insn_pushf: pushf;ret\n\t"
+ "insn_popf: popf;ret\n\t"
+ "insn_intn: int $0x22; vmmcall; ret\n\t"
+ "insn_int_handler: iretq\n\t"
+ "insn_stgi: stgi;ret\n\t"
+ "insn_clgi: clgi;ret\n\t"
+ "insn_rdtscp: rdtscp;ret\n\t"
+ "insn_wbinvd: wbinvd;ret\n\t"
+ "insn_lidt: lidt idt_descr;ret\n\t"
+ "insn_lgdt: lgdt gdt_descr;ret\n\t"
+ "insn_lldt: xor %eax, %eax; lldt %ax;ret\n\t"
+ "insn_rdpmc: xor %ecx, %ecx; rdpmc;ret\n\t"
+ "insn_cpuid: mov $10, %eax; cpuid;ret\n\t"
+ "insn_invd: invd;ret\n\t"
+ "insn_pause: pause;ret\n\t"
+ "insn_hlt: hlt;ret\n\t"
+ "insn_invlpg: invlpg 0x12345678;ret\n\t"
+ "insn_rdtsc: rdtsc;ret\n\t"
+ "insn_monitor: xor %eax, %eax; xor %ecx, %ecx; xor %edx, %edx; monitor;ret\n\t"
+ "insn_mwait: xor %eax, %eax; xor %ecx, %ecx; mwait;ret\n\t"
+ "insn_skinit: skinit;ret\n\t"
+ "insn_icebp: .byte 0xf1; ret\n\t"
+ "insn_xsetbv: mov $0, %ecx; xor %edx, %edx; xor %eax, %eax; xgetbv; xsetbv;ret\n\t"
+ "insn_rdpru: xor %ecx, %ecx; .byte 0x0f,0x01,0xfd;ret\n\t"
+);
+
+extern void insn_sidt(struct svm_test *test); +extern void insn_sgdt(struct svm_test *test); +extern void insn_sldt(struct svm_test *test); +extern void insn_str(struct svm_test *test); +extern void insn_ltr(struct svm_test *test); +extern void insn_pushf(struct svm_test *test); +extern void insn_popf(struct svm_test *test); +extern void insn_intn(struct svm_test *test); +extern void insn_int_handler(struct svm_test *test); +extern void insn_stgi(struct svm_test *test); +extern void insn_clgi(struct svm_test *test); +extern void insn_rdtscp(struct svm_test *test); +extern void insn_wbinvd(struct svm_test *test); +extern void insn_lidt(struct svm_test *test); +extern void insn_lgdt(struct svm_test *test); +extern void insn_lldt(struct svm_test *test); +extern void insn_rdpmc(struct svm_test *test); +extern void insn_cpuid(struct svm_test *test); +extern void insn_invd(struct svm_test *test); +extern void insn_pause(struct svm_test *test); +extern void insn_hlt(struct svm_test *test); +extern void insn_invlpg(struct svm_test *test); +extern void insn_rdtsc(struct svm_test *test); +extern void insn_monitor(struct svm_test *test); +extern void insn_mwait(struct svm_test *test); +extern void insn_skinit(struct svm_test *test); +extern void insn_icebp(struct svm_test *test); +extern void insn_xsetbv(struct svm_test *test); +extern void insn_rdpru(struct svm_test *test);

Quoted 2 lines

Also this (but less importantly):
https://lore.kernel.org/kvm/[email protected]/.

Because I hate bumping the timeouts. It's a losing game of whack-a-mole. For now, it's easier to bury my head in the sand.

#4 lore raw
Quoted 14 lines · Sean Christopherson
Quoted 12 lines · Yosry Ahmed
Quoted 12 lines
Quoted 11 lines

----------------------------------------------------------------
Isaku Yamahata (2):
x86: Replace NOP with CPUID after WRMSR(TSCDEADLINE) to serialize deadline timer
x86: tscdeadline_latency: Remove unnecessary nop

Jim Mattson (1):
x86: nVMX: Add retry loop to advanced RTM debugging subtest

Kevin Cheng (2):
x86/svm: Add missing svm intercepts x86/svm: Add unsupported instruction intercept test

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

Any reason not to include this series:
https://lore.kernel.org/kvm/[email protected]/?

I ran out of steam (and time), and I don't want to merge like this without a high level of confidence that it's the least awful option.

We're already doing this for vmx:
https://gitlab.com/kvm-unit-tests/kvm-unit-tests/-/blob/master/x86/vmx_tests.c?ref_type=heads#L806.

If this is the only thing holding that series, I think cleaning it up should be done separately for both VMX and SVM.

Quoted 63 lines
(quoted diff) +61 -0
+asm(
+       "insn_sidt: sidt idt_descr;ret\n\t"
+       "insn_sgdt: sgdt gdt_descr;ret\n\t"
+       "insn_sldt: sldt %ax;ret\n\t"
+       "insn_str: str %ax;ret\n\t"
+       "insn_ltr: ltr %ax;ret\n\t"
+       "insn_pushf: pushf;ret\n\t"
+       "insn_popf: popf;ret\n\t"
+       "insn_intn: int $0x22; vmmcall; ret\n\t"
+       "insn_int_handler: iretq\n\t"
+       "insn_stgi: stgi;ret\n\t"
+       "insn_clgi: clgi;ret\n\t"
+       "insn_rdtscp: rdtscp;ret\n\t"
+       "insn_wbinvd: wbinvd;ret\n\t"
+       "insn_lidt: lidt idt_descr;ret\n\t"
+       "insn_lgdt: lgdt gdt_descr;ret\n\t"
+       "insn_lldt: xor %eax, %eax; lldt %ax;ret\n\t"
+       "insn_rdpmc: xor %ecx, %ecx; rdpmc;ret\n\t"
+       "insn_cpuid: mov $10, %eax; cpuid;ret\n\t"
+       "insn_invd: invd;ret\n\t"
+       "insn_pause: pause;ret\n\t"
+       "insn_hlt: hlt;ret\n\t"
+       "insn_invlpg: invlpg 0x12345678;ret\n\t"
+       "insn_rdtsc: rdtsc;ret\n\t"
+       "insn_monitor: xor %eax, %eax; xor %ecx, %ecx; xor %edx, %edx; monitor;ret\n\t"
+       "insn_mwait: xor %eax, %eax; xor %ecx, %ecx; mwait;ret\n\t"
+       "insn_skinit: skinit;ret\n\t"
+       "insn_icebp: .byte 0xf1; ret\n\t"
+       "insn_xsetbv: mov $0, %ecx; xor %edx, %edx; xor %eax, %eax; xgetbv; xsetbv;ret\n\t"
+       "insn_rdpru: xor %ecx, %ecx; .byte 0x0f,0x01,0xfd;ret\n\t"
+);
+
+extern void insn_sidt(struct svm_test *test);
+extern void insn_sgdt(struct svm_test *test);
+extern void insn_sldt(struct svm_test *test);
+extern void insn_str(struct svm_test *test);
+extern void insn_ltr(struct svm_test *test);
+extern void insn_pushf(struct svm_test *test);
+extern void insn_popf(struct svm_test *test);
+extern void insn_intn(struct svm_test *test);
+extern void insn_int_handler(struct svm_test *test);
+extern void insn_stgi(struct svm_test *test);
+extern void insn_clgi(struct svm_test *test);
+extern void insn_rdtscp(struct svm_test *test);
+extern void insn_wbinvd(struct svm_test *test);
+extern void insn_lidt(struct svm_test *test);
+extern void insn_lgdt(struct svm_test *test);
+extern void insn_lldt(struct svm_test *test);
+extern void insn_rdpmc(struct svm_test *test);
+extern void insn_cpuid(struct svm_test *test);
+extern void insn_invd(struct svm_test *test);
+extern void insn_pause(struct svm_test *test);
+extern void insn_hlt(struct svm_test *test);
+extern void insn_invlpg(struct svm_test *test);
+extern void insn_rdtsc(struct svm_test *test);
+extern void insn_monitor(struct svm_test *test);
+extern void insn_mwait(struct svm_test *test);
+extern void insn_skinit(struct svm_test *test);
+extern void insn_icebp(struct svm_test *test);
+extern void insn_xsetbv(struct svm_test *test);
+extern void insn_rdpru(struct svm_test *test);
Quoted 5 lines
Quoted 2 lines

Also this (but less importantly):
https://lore.kernel.org/kvm/[email protected]/.

Because I hate bumping the timeouts. It's a losing game of whack-a-mole. For now, it's easier to bury my head in the sand.

LOL

author reviewer
#5 lore raw
Quoted 18 lines · Yosry Ahmed
Quoted 17 lines · Sean Christopherson
Quoted 14 lines · Yosry Ahmed
Quoted 14 lines
Quoted 11 lines

----------------------------------------------------------------
Isaku Yamahata (2):
x86: Replace NOP with CPUID after WRMSR(TSCDEADLINE) to serialize deadline timer
x86: tscdeadline_latency: Remove unnecessary nop

Jim Mattson (1):
x86: nVMX: Add retry loop to advanced RTM debugging subtest

Kevin Cheng (2):
x86/svm: Add missing svm intercepts x86/svm: Add unsupported instruction intercept test

Any reason not to include this series:
https://lore.kernel.org/kvm/[email protected]/?

Quoted 8 lines
Quoted 2 lines

I ran out of steam (and time), and I don't want to merge like this without a high level of confidence that it's the least awful option.

We're already doing this for vmx:
https://gitlab.com/kvm-unit-tests/kvm-unit-tests/-/blob/master/x86/vmx_tests.c?ref_type=heads#L806.

If this is the only thing holding that series, I think cleaning it up should be done separately for both VMX and SVM.

I don't buy that argument. Taking it to the extreme, that's like saying it's ok to use bare "unsigned" because there exists such code in the kernel. It's very difficult to make progress if we don't raise the bar.

I'm not saying "no" to the series, nor am saying you (or Kevin) needs to clean up the nVMX code in order to land the nSVM code. I'm simply explaining why I didn't grab the series: it's got some fugly code I want to look at more closely, but I ran out of time and brainpower.

#6 lore raw
Quoted 26 lines · Sean Christopherson
Quoted 24 lines · Yosry Ahmed
Quoted 14 lines · Sean Christopherson
Quoted 12 lines · Yosry Ahmed
Quoted 12 lines
Quoted 11 lines

----------------------------------------------------------------
Isaku Yamahata (2):
x86: Replace NOP with CPUID after WRMSR(TSCDEADLINE) to serialize deadline timer
x86: tscdeadline_latency: Remove unnecessary nop

Jim Mattson (1):
x86: nVMX: Add retry loop to advanced RTM debugging subtest

Kevin Cheng (2):
x86/svm: Add missing svm intercepts x86/svm: Add unsupported instruction intercept test

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

Any reason not to include this series:
https://lore.kernel.org/kvm/[email protected]/?

I ran out of steam (and time), and I don't want to merge like this without a high level of confidence that it's the least awful option.

We're already doing this for vmx:
https://gitlab.com/kvm-unit-tests/kvm-unit-tests/-/blob/master/x86/vmx_tests.c?ref_type=heads#L806.

Quoted 6 lines
Quoted 2 lines

If this is the only thing holding that series, I think cleaning it up should be done separately for both VMX and SVM.

I don't buy that argument. Taking it to the extreme, that's like saying it's ok to use bare "unsigned" because there exists such code in the kernel. It's very difficult to make progress if we don't raise the bar.

That's fair.

Quoted 4 lines

I'm not saying "no" to the series, nor am saying you (or Kevin) needs to clean up the nVMX code in order to land the nSVM code. I'm simply explaining why I didn't grab the series: it's got some fugly code I want to look at more closely, but I ran out of time and brainpower.

Understandable, sorry if I came off too pushy. Thank you for taking the time to shepherd x86 KUT changes.

maintainer
#7 lore raw
In reply to Sean Christopherson
Quoted 7 lines · Sean Christopherson

Please pull a rather random set of changes that have been accumulating over the last few months.

Note, the SKINIT nSVM intercept test fails on some Turin CPUs, but allegedly only on pre-production hardware? I assume/hope such hardware isn't commonly available, and so didn't bother trying to handle it in upstream KUT.

Quoted 7 lines

The following changes since commit 9eb6c57313060d34f7e5b2ac6f90bb5873bbe2ff:

Merge branch 'mbec' into HEAD (2026-05-12 13:03:25 +0200)

are available in the Git repository at:

   https://github.com/kvm-x86/kvm-unit-tests.git tags/kvm-x86-2026.05.27

Pulled, thanks.

(I haven't pushed my 32-bit tests yet, especially since you preferred to leave out the new nSVM test).

Paolo

Quoted 70 lines

for you to fetch changes up to c10d4616e2ad5d95553b2f0c389b4546dfacd76f:

   x86/vmx: Remove the superfluous vmx_cet config entry (2026-05-27 08:59:46 -0700)

----------------------------------------------------------------
KVM-Unit-Tests x86 changes:

- Track SVM's EXIT_CODE as a 64-bit value, to verify KVM does the same.

- Add nSVM tests for unsupported instruction intercepts.

- Serialize the (v)CPU after WRMSR(TSCDEADLINE) to prepare for APIC timer virtualization.

- Disable PKU in the vCPU model when running the nVMX access tests to make the runtime somewhat reasonable.

- Extended the VMOVDQA test to cover VMOVNTDQA as well.

- Add test coverage for ENTER + emulated MMIO.

- Misc fixes, cleanups, and minor coverage enhancements.

----------------------------------------------------------------
Isaku Yamahata (2):
x86: Replace NOP with CPUID after WRMSR(TSCDEADLINE) to serialize deadline timer
x86: tscdeadline_latency: Remove unnecessary nop

Jim Mattson (1):
x86: nVMX: Add retry loop to advanced RTM debugging subtest

Kevin Cheng (2):
x86/svm: Add missing svm intercepts x86/svm: Add unsupported instruction intercept test

Maxim Levitsky (1):
Skip PMU portion of vmware_backdoors test if PMU is not enabled.

Sean Christopherson (9):
x86/cstart: Delete "local" version of save_id() to fix x2APIC SMP bug x86/debug: Fix macro definitions for DR7 local/global enable bits x86/svm: Track and handle exit code as an unsigned 64-bit value
x86: Disable PKU in vCPU model for vmx_pf_{vpid/no_vpid/invvpid}_test x86/xsave: Extend VMOVDQA testing to also cover VMOVNTDQA x86/debug: Verify DR6 is always empty on an INT1/ICEBP #DB x86/apic: Verify LVT timer register mode reads back what was written x86/emulator: Add testcases for ENTER + emulated MMIO x86/vmx: Remove the superfluous vmx_cet config entry

  lib/x86/asm/debugreg.h    |   5 +-
  lib/x86/msr.h             |   1 +
  lib/x86/processor.h       |  11 ++
  x86/apic.c                |   8 +-
  x86/cstart.S              |   7 --
  x86/debug.c               |  34 +++---
  x86/emulator.c            |  66 ++++++-----
  x86/emulator64.c          |  64 ++++++++++
  x86/svm.c                 |  22 +++-
  x86/svm.h                 |  98 +++++++++++++---
  x86/svm_npt.c             |   4 +-
  x86/svm_tests.c           | 290 ++++++++++++++++++++++++++++++----------------
  x86/tscdeadline_latency.c |   1 -
  x86/unittests.cfg         |  31 ++---
  x86/vmexit.c              |   3 +-
  x86/vmware_backdoors.c    |  18 ++-
  x86/vmx_tests.c           |  76 +++++++++---
  x86/xsave.c               |  36 +++++-
  18 files changed, 559 insertions(+), 216 deletions(-)