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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux