Re: [PATCH v5] KVM: x86: avoid large stack allocations in em_fxrstor

2017-06-01 Thread Nick Desaulniers
On Thu, Jun 01, 2017 at 09:36:18AM +0200, Paolo Bonzini wrote: > On 01/06/2017 03:05, Nick Desaulniers wrote: > > On Wed, May 31, 2017 at 07:01:29AM -0400, Paolo Bonzini wrote: > >>> + size = offsetof(struct fxregs_state, xmm_space[16]); > >> This still has the same issue (it should be mult

Re: [PATCH v5] KVM: x86: avoid large stack allocations in em_fxrstor

2017-06-01 Thread Paolo Bonzini
On 01/06/2017 03:05, Nick Desaulniers wrote: > On Wed, May 31, 2017 at 07:01:29AM -0400, Paolo Bonzini wrote: >>> + size = offsetof(struct fxregs_state, xmm_space[16]); >> This still has the same issue (it should be multiplied by 4). > > I'm still misunderstanding the math here. > > W

Re: [PATCH v5] KVM: x86: avoid large stack allocations in em_fxrstor

2017-05-31 Thread Nick Desaulniers
On Wed, May 31, 2017 at 07:01:29AM -0400, Paolo Bonzini wrote: > > + size = offsetof(struct fxregs_state, xmm_space[16]); > This still has the same issue (it should be multiplied by 4). I'm still misunderstanding the math here. Why multiplied by four, in this case? 8 * 16 / 4 is used in

Re: [PATCH v5] KVM: x86: avoid large stack allocations in em_fxrstor

2017-05-31 Thread Paolo Bonzini
> + size = offsetof(struct fxregs_state, xmm_space[16]); This still has the same issue (it should be multiplied by 4). Here's my take on it; I checked the compiled code and it's pretty good too (the compiler knows to do the fxsave if and only if ctxt->mode < X86EMUL_MODE_PROT64, beca