Re: [PATCH 07/10] x86/tdx: Extend TDX_MODULE_CALL to support more TDCALL/SEAMCALL leafs

From: Peter Zijlstra
Date: Thu Jul 13 2023 - 04:47:19 EST


On Thu, Jul 13, 2023 at 07:48:20AM +0000, Huang, Kai wrote:

> I found below comment in KVM code:
>
> > + * See arch/x86/kvm/vmx/vmenter.S:
> > + *
> > + * In theory, a L1 cache miss when restoring register from stack
> > + * could lead to speculative execution with guest's values.
>
> And KVM explicitly does XOR for the registers that gets "pop"ed almost
> instantly, so I followed.
>
> But to be honest I don't quite understand this. :-)

Urgh, I suppose that actually makes sense. Since pop is a load it might
continue speculation with the previous value. Whereas the xor-clear
idiom is impossible to speculate through.

Oh well...