Skip to contentSkip to conversation

x86: Disable PIT re-injection for all tests to play nice with (x2)AVIC

PATCH Applied Sean Christopherson 2 participants 3 messages Jun 3, 2025 – Jun 11, 2025 KVM

lore
Share & tools
lore

Sean Christopherson

author reviewer
#0 lore raw

PATCH 1/1 x86: Disable PIT re-injection for all tests to play nice with (x2)AVIC

Disable PIT re-injection via "-global kvm-pit.lost_tick_policy=discard" for all x86 tests, as KVM inhibits (x2)AVIC when the PIT is in re-injection mode (AVIC doesn't allow KVM to intercept EOIs to do re-injection). Drop the various unittests.cfg hacks which disable the PIT entirely to effect the same outcome.

Disable re-injection instead of killing off the PIT entirely as the realmode test uses the PIT (but doesn't rely on re-injection).

---
 x86/run           |  7 ++++++-
 x86/unittests.cfg | 10 +++-------
 2 files changed, 9 insertions(+), 8 deletions(-)
x86/run +6 -1
index a3d3e7db..dc4759b4 100755
@@ -36,7 +36,12 @@ else
 	pc_testdev="-device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out"
 fi
 
-command="${qemu} --no-reboot -nodefaults $pc_testdev -vnc none -serial stdio $pci_testdev"
+# Discard lost ticks from the Programmable Interval Timer (PIT, a.k.a 8254), as
+# enabling KVM's re-injection mode inhibits (x2)AVIC, i.e. prevents validating
+# (x2)AVIC.  Note, the realmode test relies on the PIT, but not re-injection.
+pit="-global kvm-pit.lost_tick_policy=discard"
+
+command="${qemu} --no-reboot -nodefaults $pit $pc_testdev -vnc none -serial stdio $pci_testdev"
 command+=" -machine accel=$ACCEL$ACCEL_PROPS"
 if [ "${CONFIG_EFI}" != y ]; then
 	command+=" -kernel"
x86/unittests.cfg +3 -7
index 6e69c50b..6b33a643 100644
@@ -28,12 +28,11 @@ arch = x86_64
 timeout = 30
 groups = apic
 
-# Hide x2APIC and don't create a Programmable Interval Timer (PIT, a.k.a 8254)
-# to allow testing SVM's AVIC, which is disabled if either is exposed to the guest.
+# Hide x2APIC to allow testing AVIC on non-x2AVIC systems
 [xapic]
 file = apic.flat
 smp = 2
-extra_params = -cpu qemu64,-x2apic,+tsc-deadline -machine pit=off
+extra_params = -cpu qemu64,-x2apic,+tsc-deadline
 arch = x86_64
 timeout = 60
 groups = apic
@@ -81,13 +80,10 @@ file = vmexit.flat
 extra_params = -append 'inl_from_pmtimer'
 groups = vmexit
 
-# To allow IPIs to be accelerated by SVM AVIC when the feature is available and
-# enabled, do not create a Programmable Interval Timer (PIT, a.k.a 8254), since
-# such device will disable/inhibit AVIC if exposed to the guest.
 [vmexit_ipi]
 file = vmexit.flat
 smp = 2
-extra_params = -machine pit=off -append 'ipi'
+extra_params = -append 'ipi'
 groups = vmexit
 
 [vmexit_ipi_halt]

base-commit: 72d110d8286baf1b355301cc8c8bdb42be2663fb

Signature · 1 line
2.49.0.1204.g71687c7c1d-goog
author reviewer Applied
#1 lore raw
Quoted 10 lines · Sean Christopherson

Disable PIT re-injection via "-global kvm-pit.lost_tick_policy=discard" for all x86 tests, as KVM inhibits (x2)AVIC when the PIT is in re-injection mode (AVIC doesn't allow KVM to intercept EOIs to do re-injection). Drop the various unittests.cfg hacks which disable the PIT entirely to effect the same outcome.

Disable re-injection instead of killing off the PIT entirely as the realmode test uses the PIT (but doesn't rely on re-injection).

[...]

Applied to kvm-x86 next, thanks!

[1/1] x86: Disable PIT re-injection for all tests to play nice with (x2)AVIC

      https://github.com/kvm-x86/kvm-unit-tests/commit/3dab6993cdc5

--
https://github.com/kvm-x86/kvm-unit-tests/tree/next

Acked-by on v1 1/1
#2 lore raw
In reply to Sean Christopherson
Quoted 9 lines · Sean Christopherson

Disable PIT re-injection via "-global kvm-pit.lost_tick_policy=discard" for all x86 tests, as KVM inhibits (x2)AVIC when the PIT is in re-injection mode (AVIC doesn't allow KVM to intercept EOIs to do re-injection). Drop the various unittests.cfg hacks which disable the PIT entirely to effect the same outcome.

Disable re-injection instead of killing off the PIT entirely as the realmode test uses the PIT (but doesn't rely on re-injection).

Quoted 6 lines
---
 x86/run           |  7 ++++++-
 x86/unittests.cfg | 10 +++-------
 2 files changed, 9 insertions(+), 8 deletions(-)

This is indeed much better, thanks!

- Naveen