Skip to contentSkip to conversation

x86/emulator: Treat DR6_BUS_LOCK as writable if CPU has BUS_LOCK_DETECT

PATCH Applied Sean Christopherson 1 participant 2 messages Nov 13, 2025 – Nov 18, 2025 KVM

lore
Share & tools
lore

Sean Christopherson

author reviewer
#0 lore raw

PATCH 1/1 x86/emulator: Treat DR6_BUS_LOCK as writable if CPU has BUS_LOCK_DETECT

Mark DR6_BUS_LOCK as writable, i.e. not reserved, if the CPU supports BUS_LOCK_DETECT to fix a false failure that is largely hidden by x86/unittests.cfg running the test with the VMM's default virtual CPU model (i.e. because QEMU doesn't enable BUS_LOCK_DETECT by default).

---
 lib/x86/processor.h | 1 +
 x86/emulator.c      | 9 ++++++---
 2 files changed, 7 insertions(+), 3 deletions(-)
lib/x86/processor.h +1 -0
index 62f3d578..8a73af5e 100644
@@ -288,6 +288,7 @@ struct x86_cpu_feature {
 #define X86_FEATURE_LA57		X86_CPU_FEATURE(0x7, 0, ECX, 16)
 #define X86_FEATURE_RDPID		X86_CPU_FEATURE(0x7, 0, ECX, 22)
 #define X86_FEATURE_SHSTK		X86_CPU_FEATURE(0x7, 0, ECX, 7)
+#define X86_FEATURE_BUS_LOCK_DETECT	X86_CPU_FEATURE(0x7, 0, ECX, 24)
 #define X86_FEATURE_PKS			X86_CPU_FEATURE(0x7, 0, ECX, 31)
 #define X86_FEATURE_IBT			X86_CPU_FEATURE(0x7, 0, EDX, 20)
 #define X86_FEATURE_SPEC_CTRL		X86_CPU_FEATURE(0x7, 0, EDX, 26)
x86/emulator.c +6 -3
index 4e1ba12a..102e5efc 100644
@@ -532,15 +532,18 @@ static void test_nop(uint64_t *mem)
 
 static void test_mov_dr(uint64_t *mem)
 {
+	unsigned long active_low = DR6_ACTIVE_LOW;
 	unsigned long rax;
 
 	asm(KVM_FEP "mov %0, %%dr6\n\t"
 	    KVM_FEP "mov %%dr6, %0\n\t" : "=a" (rax) : "a" (0));
 
 	if (this_cpu_has(X86_FEATURE_RTM))
-		report(rax == (DR6_ACTIVE_LOW & ~DR6_RTM), "mov_dr6");
-	else
-		report(rax == DR6_ACTIVE_LOW, "mov_dr6");
+		active_low &= ~DR6_RTM;
+	if (this_cpu_has(X86_FEATURE_BUS_LOCK_DETECT))
+		active_low &= ~DR6_BUS_LOCK;
+
+	report(rax == active_low, "mov_dr6");
 }
 
 static void test_illegal_lea(void)

base-commit: af582a4ebaf7828c200dc7150aa0dbccb60b08a7

Signature · 1 line
2.52.0.rc1.455.g30608eb744-goog
author reviewer Applied
#1 lore raw
Quoted 4 lines · Sean Christopherson

Mark DR6_BUS_LOCK as writable, i.e. not reserved, if the CPU supports BUS_LOCK_DETECT to fix a false failure that is largely hidden by x86/unittests.cfg running the test with the VMM's default virtual CPU model (i.e. because QEMU doesn't enable BUS_LOCK_DETECT by default).

Applied to kvm-x86 next, thanks!

[1/1] x86/emulator: Treat DR6_BUS_LOCK as writable if CPU has BUS_LOCK_DETECT

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

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