提交 f9dcf08e 编写于 作者: R Radim Krčmář

Revert "kvm: x86: optimize dr6 restore"

This reverts commit 0e0a53c5.

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: NRadim Krčmář <rkrcmar@redhat.com>
上级 574c0cfb
...@@ -3271,15 +3271,10 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) ...@@ -3271,15 +3271,10 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
kvm_x86_ops->vcpu_put(vcpu); kvm_x86_ops->vcpu_put(vcpu);
vcpu->arch.last_host_tsc = rdtsc(); vcpu->arch.last_host_tsc = rdtsc();
/* /*
* Here dr6 is either zero or, if the guest has run and userspace * If userspace has set any breakpoints or watchpoints, dr6 is restored
* has not set any breakpoints or watchpoints, it can be set to * on every vmexit, but if not, we might have a stale dr6 from the
* the guest dr6 (stored in vcpu->arch.dr6). do_debug expects dr6 * guest. do_debug expects dr6 to be cleared after it runs, do the same.
* 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 (vcpu->arch.dr6)
set_debugreg(0, 6); set_debugreg(0, 6);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册