On Thu, Jul 13, 2023 at 09:34:24AM +0000, Huang, Kai wrote: > On Thu, 2023-07-13 at 10:46 +0200, Peter Zijlstra wrote: > > 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... > > Then should I keep those registers that are "pop"ed immediately afterwards? Yeah, I suppose so.