From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967636AbdEXOUE (ORCPT ); Wed, 24 May 2017 10:20:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18442 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965193AbdEXOUC (ORCPT ); Wed, 24 May 2017 10:20:02 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8153EC056782 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=rkrcmar@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8153EC056782 Date: Wed, 24 May 2017 16:19:57 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Nick Desaulniers Cc: Paolo Bonzini , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: x86: dynamically allocate large struct in em_fxrstor Message-ID: <20170524141957.GA8174@potion> References: <20170524062433.20680-1-nick.desaulniers@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170524062433.20680-1-nick.desaulniers@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 24 May 2017 14:20:01 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2017-05-23 23:24-0700, Nick Desaulniers: > Fixes the warning: > > arch/x86/kvm/emulate.c:4018:12: warning: stack frame size of 1080 bytes in > function > 'em_fxrstor' [-Wframe-larger-than=] > static int em_fxrstor(struct x86_emulate_ctxt *ctxt) > ^ > > Found with CONFIG_FRAME_WARN set to 1024. > > Signed-off-by: Nick Desaulniers > --- > diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c > @@ -4017,30 +4017,38 @@ static int fxrstor_fixup(struct x86_emulate_ctxt *ctxt, > > static int em_fxrstor(struct x86_emulate_ctxt *ctxt) > { > - struct fxregs_state fx_state; > + struct fxregs_state *fx_state; > int rc; > > rc = check_fxsr(ctxt); > if (rc != X86EMUL_CONTINUE) > return rc; > > - rc = segmented_read_std(ctxt, ctxt->memop.addr.mem, &fx_state, 512); > + fx_state = kmalloc(sizeof(*fx_state), GFP_KERNEL); > + fx_state = kmalloc(sizeof(*fx_state), GFP_KERNEL); fx_state must be 16 byte aligned and x86 ARCH_KMALLOC_MINALIGN is 8, so this needs manual correction. Also, please kmalloc also fxregs_state in fxrstor_fixup and em_fxsave so we again have only one storage type. > + if (!fx_state) > + return -ENOMEM; The caller does not understand -ENOMEM. The appropriate return value is X86EMUL_UNHANDLEABLE. > 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. Thanks.