Re: [PATCH 3/3] kvm: mmu: Separate pte generation from set_spte

From: Paolo Bonzini
Date: Wed Feb 05 2020 - 09:53:54 EST


On 05/02/20 14:52, Vitaly Kuznetsov wrote:
>> + spte = make_spte(vcpu, pte_access, level, gfn, pfn, *sptep, speculative,
>> + can_unsync, host_writable, sp_ad_disabled(sp), &ret);
> I'm probably missing something, but in make_spte() I see just one place
> which writes to '*ret' so at the end, this is either
> SET_SPTE_WRITE_PROTECTED_PT or 0 (which we got only because we
> initialize it to 0 in set_spte()). Unless this is preparation to some
> other change, I don't see much value in the complication.
>
> Can we actually reverse the logic, pass 'spte' by reference and return
> 'ret'?
>

It gives a similar calling convention between make_spte and
make_mmio_spte. It's not the most beautiful thing but I think I prefer it.

But the overwhelming function parameters are quite ugly, especially
old_spte. I don't think it's an improvement, let's consider it together
with the rest of your changes instead.

Paolo