lkml.org 
[lkml]   [2017]   [May]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3] KVM: x86: avoid large stack allocations in em_fxrstor
On Mon, May 29, 2017 at 01:39:08PM -0700, Nick Desaulniers wrote:
> + if (ctxt->mode < X86EMUL_MODE_PROT64) {
> + rc = asm_safe("fxsave %[fx]", , [fx] "+m"(fx_state));
> + if (rc != X86EMUL_CONTINUE)
> + return rc;
> + /*
> + * Hardware doesn't save and restore XMM 0-7 without
> + * CR4.OSFXSR, but does save and restore MXCSR.
> + */
> + if (ctxt->ops->get_cr(ctxt, 4) & X86_CR4_OSFXSR)
> + size = offsetof(struct fxregs_state, xmm_space[8]);
> + else
> + size = offsetof(struct fxregs_state, xmm_space[0]);
> + } else if (ctxt->mode == X86EMUL_MODE_PROT64)
> + size = offsetof(struct fxregs_state, xmm_space[16]);
> +
> + if (size == 0)
> + return X86EMUL_UNHANDLEABLE;
> +
> + rc = segmented_read_std(ctxt, ctxt->memop.addr.mem, &fx_state, size);
> if (rc != X86EMUL_CONTINUE)
> return rc;

Thinking more about this, I think it may be more elegant to move the
segmented_read_std into the then/else branches above, remove
initialization of size, and remove the size == 0 check. Thoughts?

\
 
 \ /
  Last update: 2017-05-30 00:40    [W:0.103 / U:0.144 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site