Skip to contentSkip to conversation

x86/apic: Verify LVT timer register mode reads back what was written

PATCH Applied Sean Christopherson 1 participant 2 messages May 14 – May 27 KVM

lore
Share & tools
lore

Sean Christopherson

author reviewer
#0 lore raw

PATCH 1/1 x86/apic: Verify LVT timer register mode reads back what was written

Report a failure (but not a pass, for brevity) if an APIC timer mode change reads back a different mode than was written, e.g. to verify that LVTT reads via x2APIC MSR are accelerated by hardware and access the backing page when APICv/x2AVIC is enabled.

---
 x86/apic.c | 5 +++++
 1 file changed, 5 insertions(+)
x86/apic.c +5 -0
index 0a52e9a4..fab15946 100644
@@ -569,6 +569,11 @@ static inline void apic_change_mode(unsigned long new_mode)
 
 	lvtt = apic_read(APIC_LVTT);
 	apic_write(APIC_LVTT, (lvtt & ~APIC_LVT_TIMER_MASK) | new_mode);
+
+	lvtt = apic_read(APIC_LVTT);
+	if ((lvtt & APIC_LVT_TIMER_MASK) != new_mode)
+		report_fail("LVTT mode '0x%x' doesn't match written mode '0x%lx'",
+			    lvtt & APIC_LVT_TIMER_MASK, new_mode);
 }
 
 static void test_apic_change_mode(void)

base-commit: 9eb6c57313060d34f7e5b2ac6f90bb5873bbe2ff

Signature · 1 line
2.54.0.563.g4f69b47b94-goog
author reviewer Applied
#1 lore raw
Quoted 4 lines · Sean Christopherson

Report a failure (but not a pass, for brevity) if an APIC timer mode change reads back a different mode than was written, e.g. to verify that LVTT reads via x2APIC MSR are accelerated by hardware and access the backing page when APICv/x2AVIC is enabled.

Applied to kvm-x86 next, thanks!

[1/1] x86/apic: Verify LVT timer register mode reads back what was written

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

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