Re: [PATCH 4/7] KVM: x86: Add wrapper APIs to reset dirty/available register masks

From: Sean Christopherson

Date: Thu Mar 12 2026 - 20:38:52 EST


On Wed, Mar 11, 2026, Paolo Bonzini wrote:
> On 3/11/26 14:31, Sean Christopherson wrote:
> > > Not closely following this series and don't know this code well, but
> > > this API is very confusing for me tbh. Especially in comparison with
> > > kvm_reset_dirty_registers().
> > >
> > > Maybe rename this to kvm_clear_available_registers(), and pass in a
> > > "clear_mask", then reverse the polarity:
> > >
> > > vcpu->arch.regs_avail &= ~clear_mask;
> > Oh, yeah, I can do something like that. I originally misread the TDX code and
> > thought it was explicitly setting regs_avail, and so came up with a roundabout
> > name. I didn't revisit the naming or the polarity of the param once I realized
> > all callers could use the same scheme.
> >
> > No small part of me is tempted to turn it into a straigh "set" though, unless I'm
> > missing something, the whole &= business is an implementation quirk.
>
> I like kvm_clear_available_registers() for this + removing the second
> argument completely for kvm_reset_dirty_registers().

Ya, me too. I almost dropped the param for kvm_reset_dirty_registers(), but
wanted symmetry since the names were the same. But I like this a lot more.