Skip to content

KVM: x86: Fix DR6.BLD regression in guests

Baoli Zhang kvm stable 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4KVM: x86: Rename kvm_dr6_fixed() => kvm_get_dr6_fixed_1()arch/x86/kvm/regs.c+2 -20 replies
2/4KVM: Return an "unsigned long", not "u64" for the fixed-1 DR6 bitsarch/x86/kvm/regs.c+3 -20 replies
3/4KVM: x86: Force fixed-1 bits in DR6 after synchronizing with hardwarearch/x86/include/asm/kvm_host.h arch/x86/kvm/regs.c arch/x86/kvm/x86.c+3 -10 replies
4/4KVM: x86: Set guest's fixed-1 DR6 bits when delivering #DB payloadarch/x86/kvm/x86.c+1 -10 replies

Reviews trailers per patch

None of the 4 patches has a Reviewed-by or Acked-by.

PatchYanx L Liu
1/4T-b
2/4T-b
3/4T-b
4/4T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 6.18.y 0/4] KVM: x86: Fix DR6.BLD regression in guests

Hi,

a58917a271cb ("KVM: x86: Preserve DR6.BLD (Bus Lock Detect) when delivering #DB payload"), upstream 719a1d58bf43, went into 6.18.61 without the rest of its upstream series. Since then kvm-unit-tests x86/debug fails on hosts with Bus Lock Detect when the guest CPU model doesn't have it, e.g. the default qemu64:

FAIL: Wanted #DB on 0x400da7 w/ DR6 = 0xffff0ff4, got 1 #DBs, addr[0] = 0x400da7, DR6 = 0xffff07f4
...
SUMMARY: 25 tests, 17 unexpected failures

Once KVM stops intercepting DR accesses, the guest's write of 0 to DR6 goes to hardware and clears BLD. sync_dirty_debug_regs() copies that into vcpu->arch.dr6, and since a58917a271cb the #DB payload path no longer sets BLD back, so the guest sees it cleared.

Later patches in the same series fix this upstream (v7.4-rc1). This backports those two fixes and the two cleanups they depend on. Patch 3 needed a small change: 6.18 has no arch/x86/kvm/regs.h, so the new declaration goes in asm/kvm_host.h.

Tested on an Intel host with bus_lock_detect with a 6.18.64-based kernel whose DR6 handling matches v6.18.64: x86/debug goes from 17 failures to all 25 passing.

7.3.y, 6.12.y, 6.6.y and 6.1.y picked up the same commit (in 7.3.2, 6.12.117, 6.6.163 and 6.1.193) and probably need these too. I haven't tested those, but can send backports if wanted.

Thanks,
Baoli

Sean Christopherson (4):
KVM: x86: Rename kvm_dr6_fixed() => kvm_get_dr6_fixed_1()
KVM: Return an "unsigned long", not "u64" for the fixed-1 DR6 bits
KVM: x86: Force fixed-1 bits in DR6 after synchronizing with hardware
KVM: x86: Set guest's fixed-1 DR6 bits when delivering #DB payload

 arch/x86/include/asm/kvm_host.h | 1 +
 arch/x86/kvm/regs.c             | 7 ++++---
 arch/x86/kvm/x86.c              | 3 ++-
 3 files changed, 7 insertions(+), 4 deletions(-)
Signature · 1 line
2.43.0