From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753033AbcAVKFg (ORCPT ); Fri, 22 Jan 2016 05:05:36 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34333 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750978AbcAVKF1 (ORCPT ); Fri, 22 Jan 2016 05:05:27 -0500 Subject: Re: [PATCH 26/33] x86/kvm: Add stack frame dependency to test_cc() inline asm To: Josh Poimboeuf , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org References: Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Michal Marek , Peter Zijlstra , Andy Lutomirski , Borislav Petkov , Linus Torvalds , Andi Kleen , Pedro Alves , Namhyung Kim , Bernd Petrovitsch , Chris J Arges , Andrew Morton , Jiri Slaby , Arnaldo Carvalho de Melo , Gleb Natapov , kvm@vger.kernel.org From: Paolo Bonzini Message-ID: <56A1FED2.50700@redhat.com> Date: Fri, 22 Jan 2016 11:05:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21/01/2016 23:49, Josh Poimboeuf wrote: > With some configs, gcc doesn't inline test_cc(). When that happens, it > doesn't create a stack frame before inserting the call instruction. > This breaks frame pointer convention if CONFIG_FRAME_POINTER is enabled > and can result in a bad stack trace. > > Force a stack frame to be created if CONFIG_FRAME_POINTER is enabled by > listing the stack pointer as an output operand for the inline asm > statement. If an __always_inline allocation works, that would be better. Paolo > Signed-off-by: Josh Poimboeuf > Cc: Gleb Natapov > Cc: Paolo Bonzini > Cc: kvm@vger.kernel.org > --- > arch/x86/kvm/emulate.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c > index aa4d726..7dba65a 100644 > --- a/arch/x86/kvm/emulate.c > +++ b/arch/x86/kvm/emulate.c > @@ -972,11 +972,13 @@ static int em_bsr_c(struct x86_emulate_ctxt *ctxt) > static u8 test_cc(unsigned int condition, unsigned long flags) > { > u8 rc; > + register void *__sp asm(_ASM_SP); > void (*fop)(void) = (void *)em_setcc + 4 * (condition & 0xf); > > flags = (flags & EFLAGS_MASK) | X86_EFLAGS_IF; > asm("push %[flags]; popf; call *%[fastop]" > - : "=a"(rc) : [fastop]"r"(fop), [flags]"r"(flags)); > + : "=a"(rc), "+r"(__sp) > + : [fastop]"r"(fop), [flags]"r"(flags)); > return rc; > } > >