On Mon, May 06, 2024 at 11:30:52AM +0800, Binbin Wu <binbin.wu@xxxxxxxxxxxxxxx> wrote: > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > > index 1b189e86a1f1..fb7597c22f31 100644 > > --- a/arch/x86/kvm/x86.c > > +++ b/arch/x86/kvm/x86.c > > @@ -11013,7 +11013,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) > > if (vcpu->arch.guest_fpu.xfd_err) > > wrmsrl(MSR_IA32_XFD_ERR, vcpu->arch.guest_fpu.xfd_err); > > - if (unlikely(vcpu->arch.switch_db_regs)) { > > + if (unlikely(vcpu->arch.switch_db_regs & ~KVM_DEBUGREG_AUTO_SWITCH)) { > > As pointed by Paolo in > https://lore.kernel.org/lkml/ea136ac6-53cf-cdc5-a741-acfb437819b1@xxxxxxxxxx/ > KVM_DEBUGREG_BP_ENABLED could be set in vcpu->arch.switch_db_regs, by > userspace > kvm_vcpu_ioctl_x86_set_debugregs() --> kvm_update_dr7() > > So it should be fixed as: > > - if (unlikely(vcpu->arch.switch_db_regs)) { > + if (unlikely(vcpu->arch.switch_db_regs && > + !(vcpu->arch.switch_db_regs & > KVM_DEBUGREG_AUTO_SWITCH))) { Yes, that's true. Thanks for catching this. -- Isaku Yamahata <isaku.yamahata@xxxxxxxxx>