summaryrefslogtreecommitdiff
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
authorRadim Krčmář <rkrcmar@redhat.com>2018-10-23 16:31:38 +0200
committerRadim Krčmář <rkrcmar@redhat.com>2018-10-23 16:34:59 +0200
commitf9dcf08e2017cad12d771cdd862c8c314b885615 (patch)
tree1f84c5fe04a1dd5ca9bd0b9ed64f29d532d71e09 /arch/x86/kvm/x86.c
parent574c0cfbc7159c5a5a59d5608e422c95917a9b7c (diff)
Revert "kvm: x86: optimize dr6 restore"
This reverts commit 0e0a53c551317654e2d7885fdfd23299fee99b6b. 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>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index bdcb5babfb68..66d66d77caee 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3271,16 +3271,11 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
kvm_x86_ops->vcpu_put(vcpu);
vcpu->arch.last_host_tsc = rdtsc();
/*
- * Here dr6 is either zero or, if the guest has run and userspace
- * has not set any breakpoints or watchpoints, it can be set to
- * the guest dr6 (stored in vcpu->arch.dr6). do_debug expects dr6
- * to be cleared after it runs, so clear the host register. However,
- * MOV to DR can be expensive when running nested, omit it if
- * vcpu->arch.dr6 is already zero: in that case, the host dr6 cannot
- * currently be nonzero.
+ * If userspace has set any breakpoints or watchpoints, dr6 is restored
+ * on every vmexit, but if not, we might have a stale dr6 from the
+ * guest. do_debug expects dr6 to be cleared after it runs, do the same.
*/
- if (vcpu->arch.dr6)
- set_debugreg(0, 6);
+ set_debugreg(0, 6);
}
static int kvm_vcpu_ioctl_get_lapic(struct kvm_vcpu *vcpu,