From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753136AbcAVKGG (ORCPT ); Fri, 22 Jan 2016 05:06:06 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35090 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752767AbcAVKFf (ORCPT ); Fri, 22 Jan 2016 05:05:35 -0500 Subject: Re: [PATCH 25/33] x86/kvm: Set ELF function type for fastop functions 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: <56A1FEE2.3020605@redhat.com> Date: Fri, 22 Jan 2016 11:05:22 +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: > The callable functions created with the FOP* and FASTOP* macros are > missing ELF function annotations, which confuses tools like stacktool. > Properly annotate them. > > This adds some additional labels to the assembly, but the generated > binary code is unchanged (with the exception of instructions which have > embedded references to __LINE__). > > Signed-off-by: Josh Poimboeuf > Cc: Gleb Natapov > Cc: Paolo Bonzini > Cc: kvm@vger.kernel.org > --- > arch/x86/kvm/emulate.c | 29 +++++++++++++++++++++-------- > 1 file changed, 21 insertions(+), 8 deletions(-) > > diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c > index 1505587..aa4d726 100644 > --- a/arch/x86/kvm/emulate.c > +++ b/arch/x86/kvm/emulate.c > @@ -309,23 +309,29 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt) > > static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *)); > > -#define FOP_ALIGN ".align " __stringify(FASTOP_SIZE) " \n\t" > +#define FOP_FUNC(name) \ > + ".align " __stringify(FASTOP_SIZE) " \n\t" \ > + ".type " name ", @function \n\t" \ > + name ":\n\t" > + > #define FOP_RET "ret \n\t" > > #define FOP_START(op) \ > extern void em_##op(struct fastop *fake); \ > asm(".pushsection .text, \"ax\" \n\t" \ > ".global em_" #op " \n\t" \ > - FOP_ALIGN \ > - "em_" #op ": \n\t" > + FOP_FUNC("em_" #op) > > #define FOP_END \ > ".popsection") > > -#define FOPNOP() FOP_ALIGN FOP_RET > +#define FOPNOP() \ > + FOP_FUNC(__stringify(__UNIQUE_ID(nop))) \ > + FOP_RET > > #define FOP1E(op, dst) \ > - FOP_ALIGN "10: " #op " %" #dst " \n\t" FOP_RET > + FOP_FUNC(#op "_" #dst) \ > + "10: " #op " %" #dst " \n\t" FOP_RET > > #define FOP1EEX(op, dst) \ > FOP1E(op, dst) _ASM_EXTABLE(10b, kvm_fastop_exception) > @@ -357,7 +363,8 @@ static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *)); > FOP_END > > #define FOP2E(op, dst, src) \ > - FOP_ALIGN #op " %" #src ", %" #dst " \n\t" FOP_RET > + FOP_FUNC(#op "_" #dst "_" #src) \ > + #op " %" #src ", %" #dst " \n\t" FOP_RET > > #define FASTOP2(op) \ > FOP_START(op) \ > @@ -395,7 +402,8 @@ static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *)); > FOP_END > > #define FOP3E(op, dst, src, src2) \ > - FOP_ALIGN #op " %" #src2 ", %" #src ", %" #dst " \n\t" FOP_RET > + FOP_FUNC(#op "_" #dst "_" #src "_" #src2) \ > + #op " %" #src2 ", %" #src ", %" #dst " \n\t" FOP_RET > > /* 3-operand, word-only, src2=cl */ > #define FASTOP3WCL(op) \ > @@ -407,7 +415,12 @@ static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *)); > FOP_END > > /* Special case for SETcc - 1 instruction per cc */ > -#define FOP_SETCC(op) ".align 4; " #op " %al; ret \n\t" > +#define FOP_SETCC(op) \ > + ".align 4 \n\t" \ > + ".type " #op ", @function \n\t" \ > + #op ": \n\t" \ > + #op " %al \n\t" \ > + FOP_RET > > asm(".global kvm_fastop_exception \n" > "kvm_fastop_exception: xor %esi, %esi; ret"); > Acked-by: Paolo Bonzini