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). Reported-by: Aaron Lewis Signed-off-by: Sean Christopherson --- lib/x86/processor.h | 1 + x86/emulator.c | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/x86/processor.h b/lib/x86/processor.h index 62f3d578..8a73af5e 100644 --- a/lib/x86/processor.h +++ b/lib/x86/processor.h @@ -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) diff --git a/x86/emulator.c b/x86/emulator.c index 4e1ba12a..102e5efc 100644 --- a/x86/emulator.c +++ b/x86/emulator.c @@ -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 -- 2.52.0.rc1.455.g30608eb744-goog