Re: [PATCH 2/4] kvm, vmx: move register clearing out of assembly path

From: Jim Mattson
Date: Fri Oct 26 2018 - 12:30:27 EST


On Fri, Oct 26, 2018 at 8:46 AM, Sean Christopherson
<sean.j.christopherson@xxxxxxxxx> wrote:

> Since clearing the GPRs exists to mitigate speculation junk, I think
> we should keep the explicit XOR zeroing instead of deferring to the
> compiler. Explicit XORs will ensure the resulting assembly is the
> same regardless of compiler, version, target arch, etc..., whereas the
> compiler could theoretically use different zeroing methods[1], e.g. on
> my system it generates "mov r32,r32" for EBX, ESI and EDI (loading
> from EAX after EAX is zeroed).
>
> And FWIW, I find the original code to be more readable since all GRPs
> are zeroed with the same method.

I concur. I really do prefer the explicit xors to the input arguments.