x86/emulator: Treat DR6_BUS_LOCK as writable if CPU has BUS_LOCK_DETECT
Sean Christopherson
reviewerPATCH 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
@@ -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
@@ -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
Quoted 4 lines · Sean Christopherson
Mark
DR6_BUS_LOCKas writable, i.e. not reserved, if the CPU supportsBUS_LOCK_DETECTto 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 enableBUS_LOCK_DETECTby 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