Re: [PATCH] KVM: X86: Don't reset dr6 unconditionally when the vcpu being scheduled out

From: Paolo Bonzini
Date: Tue Aug 10 2021 - 05:59:49 EST


On 09/08/21 18:54, Sean Christopherson wrote:
Not directly related to this patch, but why does KVM_DEBUGREG_RELOAD exist?
Commit ae561edeb421 ("KVM: x86: DR0-DR3 are not clear on reset") added it to
ensure DR0-3 are fresh when they're modified through non-standard paths, but I
don't see any reason why the new values_must_ be loaded into hardware. eff_db
needs to be updated, but I don't see why hardware DRs need to be updated unless
hardware breakpoints are active or DR exiting is disabled, and in those cases
updating hardware is handled by KVM_DEBUGREG_WONT_EXIT and KVM_DEBUGREG_BP_ENABLED.

The original implementation of KVM_DEBUGREG_WONT_EXIT (by yours truly) had a bug where it did not call kvm_update_dr7 and thus KVM_DEBUGREG_BP_ENABLED was not set correctly. I agree that commit 70e4da7a8ff6 ("KVM: x86: fix root cause for missed hardware breakpoints") should have gotten rid of KVM_DEBUGREG_RELOAD altogether.


Paolo