Skip to content

Commit f9dcf08

Browse files
committed
Revert "kvm: x86: optimize dr6 restore"
This reverts commit 0e0a53c. As Christian Ehrhardt noted: The most common case is that vcpu->arch.dr6 and the host's %dr6 value are not related at all because ->switch_db_regs is zero. To do this all correctly, we must handle the case where the guest leaves an arbitrary unused value in vcpu->arch.dr6 before disabling breakpoints again. However, this means that vcpu->arch.dr6 is not suitable to detect the need for a %dr6 clear. Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
1 parent 574c0cf commit f9dcf08

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

arch/x86/kvm/x86.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3271,16 +3271,11 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
32713271
kvm_x86_ops->vcpu_put(vcpu);
32723272
vcpu->arch.last_host_tsc = rdtsc();
32733273
/*
3274-
* Here dr6 is either zero or, if the guest has run and userspace
3275-
* has not set any breakpoints or watchpoints, it can be set to
3276-
* the guest dr6 (stored in vcpu->arch.dr6). do_debug expects dr6
3277-
* to be cleared after it runs, so clear the host register. However,
3278-
* MOV to DR can be expensive when running nested, omit it if
3279-
* vcpu->arch.dr6 is already zero: in that case, the host dr6 cannot
3280-
* currently be nonzero.
3274+
* If userspace has set any breakpoints or watchpoints, dr6 is restored
3275+
* on every vmexit, but if not, we might have a stale dr6 from the
3276+
* guest. do_debug expects dr6 to be cleared after it runs, do the same.
32813277
*/
3282-
if (vcpu->arch.dr6)
3283-
set_debugreg(0, 6);
3278+
set_debugreg(0, 6);
32843279
}
32853280

32863281
static int kvm_vcpu_ioctl_get_lapic(struct kvm_vcpu *vcpu,

0 commit comments

Comments
 (0)