kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH] x86: Disable PIT re-injection for all tests to play nice with (x2)AVIC
@ 2025-06-03 23:54 Sean Christopherson
  2025-06-10 19:42 ` Sean Christopherson
  2025-06-11 15:34 ` Naveen N Rao
  0 siblings, 2 replies; 3+ messages in thread
From: Sean Christopherson @ 2025-06-03 23:54 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm, Naveen N Rao, 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).

Cc: Naveen N Rao <naveen@kernel.org>
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 x86/run           |  7 ++++++-
 x86/unittests.cfg | 10 +++-------
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/x86/run b/x86/run
index a3d3e7db..dc4759b4 100755
--- a/x86/run
+++ b/x86/run
@@ -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"
diff --git a/x86/unittests.cfg b/x86/unittests.cfg
index 6e69c50b..6b33a643 100644
--- a/x86/unittests.cfg
+++ b/x86/unittests.cfg
@@ -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
-- 
2.49.0.1204.g71687c7c1d-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [kvm-unit-tests PATCH] x86: Disable PIT re-injection for all tests to play nice with (x2)AVIC
  2025-06-03 23:54 [kvm-unit-tests PATCH] x86: Disable PIT re-injection for all tests to play nice with (x2)AVIC Sean Christopherson
@ 2025-06-10 19:42 ` Sean Christopherson
  2025-06-11 15:34 ` Naveen N Rao
  1 sibling, 0 replies; 3+ messages in thread
From: Sean Christopherson @ 2025-06-10 19:42 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini; +Cc: kvm, Naveen N Rao

On Tue, 03 Jun 2025 16:54:33 -0700, Sean Christopherson wrote:
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [kvm-unit-tests PATCH] x86: Disable PIT re-injection for all tests to play nice with (x2)AVIC
  2025-06-03 23:54 [kvm-unit-tests PATCH] x86: Disable PIT re-injection for all tests to play nice with (x2)AVIC Sean Christopherson
  2025-06-10 19:42 ` Sean Christopherson
@ 2025-06-11 15:34 ` Naveen N Rao
  1 sibling, 0 replies; 3+ messages in thread
From: Naveen N Rao @ 2025-06-11 15:34 UTC (permalink / raw)
  To: Sean Christopherson; +Cc: Paolo Bonzini, kvm

On Tue, Jun 03, 2025 at 04:54:33PM -0700, Sean Christopherson wrote:
> 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).
> 
> Cc: Naveen N Rao <naveen@kernel.org>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
>  x86/run           |  7 ++++++-
>  x86/unittests.cfg | 10 +++-------
>  2 files changed, 9 insertions(+), 8 deletions(-)

This is indeed much better, thanks!
Acked-by: Naveen N Rao (AMD) <naveen@kernel.org>

- Naveen


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-11 15:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-03 23:54 [kvm-unit-tests PATCH] x86: Disable PIT re-injection for all tests to play nice with (x2)AVIC Sean Christopherson
2025-06-10 19:42 ` Sean Christopherson
2025-06-11 15:34 ` Naveen N Rao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).