[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <52f0d4a8-aacf-dc64-8117-2ba33bbfd928@redhat.com>
Date: Thu, 25 May 2017 16:07:08 +0200
From: Paolo Bonzini <pbonzini@...hat.com>
To: Nick Desaulniers <nick.desaulniers@...il.com>,
Radim Krčmář <rkrcmar@...hat.com>
Cc: Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] KVM: x86: dynamically allocate large struct in em_fxrstor
On 25/05/2017 03:36, Nick Desaulniers wrote:
>>> if (ctxt->mode < X86EMUL_MODE_PROT64)
>>> - rc = fxrstor_fixup(ctxt, &fx_state);
>>> + rc = fxrstor_fixup(ctxt, fx_state);
>> Ah, fxrstor_fixup most likely got inlined and both of them put ~512 byte
>> fxregs_state on the stack ... noinline attribute should solve the
>> warning too.
> While that would change fewer lines, doesn't the problem still exist in
> the case of `ctxt->mode < X86EMUL_MODE_PROT64`, just split across two
> stack frames? As in shouldn't we still dynamically allocate fx_state?
I think we should do the fixup backwards.
That is:
- first do get_fpu
- if the fixup is necessary, i.e. ctxt->mode < X86EMUL_MODE_PROT64, do
fxsave into &fxstate.
- then do segmented_read_std with the correct size, which is
- offsetof(struct fxregs_state, xmm_space[16]), i.e. 416
if ctxt->mode == X86EMUL_MODE_PROT64
- offsetof(struct fxregs_state, xmm_space[8]), i.e. 288
if ctxt->mode < X86EMUL_MODE_PROT64 and CR4.OSFXSR=1
- offsetof(struct fxregs_state, xmm_space[0]), i.e. 160
if ctxt->mode < X86EMUL_MODE_PROT64 and CR4.OSFXSR=0
- then check fx_state.mxcsr
- then do fxrstor
- finally do put_fpu
This will remove one of the two fxregs_state structs.
Paolo
Powered by blists - more mailing lists