Re: [RFC PATCH 1/3] kvm: x86: Rename KVM_DEBUGREG_RELOAD to KVM_DEBUGREG_NEED_RELOAD

From: Peter Xu
Date: Fri Apr 24 2020 - 16:59:54 EST


On Fri, Apr 24, 2020 at 01:29:22PM -0700, Sean Christopherson wrote:
> On Fri, Apr 24, 2020 at 04:21:03PM -0400, Peter Xu wrote:
> > On Thu, Apr 23, 2020 at 12:09:42PM -0700, Sean Christopherson wrote:
> > > On Thu, Apr 16, 2020 at 06:15:07PM +0800, Xiaoyao Li wrote:
> > > > To make it more clear that the flag means DRn (except DR7) need to be
> > > > reloaded before vm entry.
> > > >
> > > > Signed-off-by: Xiaoyao Li <xiaoyao.li@xxxxxxxxx>
> > > > ---
> > > > arch/x86/include/asm/kvm_host.h | 2 +-
> > > > arch/x86/kvm/x86.c | 6 +++---
> > > > 2 files changed, 4 insertions(+), 4 deletions(-)
> > > >
> > > > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> > > > index c7da23aed79a..f465c76e6e5a 100644
> > > > --- a/arch/x86/include/asm/kvm_host.h
> > > > +++ b/arch/x86/include/asm/kvm_host.h
> > > > @@ -511,7 +511,7 @@ struct kvm_pmu_ops;
> > > > enum {
> > > > KVM_DEBUGREG_BP_ENABLED = 1,
> > > > KVM_DEBUGREG_WONT_EXIT = 2,
> > > > - KVM_DEBUGREG_RELOAD = 4,
> > > > + KVM_DEBUGREG_NEED_RELOAD = 4,
> > >
> > > My vote would be for KVM_DEBUGREG_DIRTY Any bit that is set switch_db_regs
> > > triggers a reload, whereas I would expect a RELOAD flag to be set _every_
> > > time a load is needed and thus be the only bit that's checked
> >
> > But then shouldn't DIRTY be set as long as KVM_DEBUGREG_BP_ENABLED is set every
> > time before vmenter? Then it'll somehow go back to switch_db_regs, iiuc...
> >
> > IIUC RELOAD actually wants to say "reload only for this iteration", that's why
> > it's cleared after each reload. So maybe... RELOAD_ONCE?
>
> Or FORCE_LOAD, or FORCE_RELOAD? Those crossed my mind as well.

Yep, FORCE_RELOAD sounds better than DIRTY.

>
> > (Btw, do we have debug regs tests somewhere no matter inside guest or with
> > KVM_SET_GUEST_DEBUG?)
>
> I don't think so?

OK, I'll see whether I can write some up. Thanks,

--
Peter Xu