OSDN Git Service

kvm: x86: optimize dr6 restore
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 22 Aug 2018 17:59:33 +0000 (19:59 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 16 Oct 2018 22:30:02 +0000 (00:30 +0200)
commit0e0a53c551317654e2d7885fdfd23299fee99b6b
treee7c3d7c079231e99dacb2d303f44243b704fb3ea
parentf21dd494506ad002a5b6b32e50a5d4ccac6929fe
kvm: x86: optimize dr6 restore

The quote from the comment almost says it all: we are currently zeroing
the guest dr6 in kvm_arch_vcpu_put, because do_debug expects it.  However,
the host %dr6 is either:

- zero because the guest hasn't run after kvm_arch_vcpu_load

- written from vcpu->arch.dr6 by vcpu_enter_guest

- written by the guest and copied to vcpu->arch.dr6 by ->sync_dirty_debug_regs().

Therefore, we can skip the write if vcpu->arch.dr6 is already zero.  We
may do extra useless writes if vcpu->arch.dr6 is nonzero but the guest
hasn't run; however that is less important for performance.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c