aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@redhat.com>2016-01-21 17:49:29 -0500
committerIngo Molnar <mingo@kernel.org>2016-02-24 02:35:44 -0500
commit1482a0825bdf82dab4074bd3c824f4c87cbdf848 (patch)
treee0df350d22c701915b3ce277e7de1c4d7fa00b53
parentc1c355ce14c037666fbcb9453d9067c86bbdda5c (diff)
x86/kvm: Set ELF function type for fastop functions
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 <jpoimboe@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Andy Lutomirski <luto@kernel.org> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Bernd Petrovitsch <bernd@petrovitsch.priv.at> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Chris J Arges <chris.j.arges@canonical.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: Gleb Natapov <gleb@kernel.org> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Jiri Slaby <jslaby@suse.cz> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Michal Marek <mmarek@suse.cz> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Pedro Alves <palves@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: kvm@vger.kernel.org Cc: live-patching@vger.kernel.org Link: http://lkml.kernel.org/r/e399651c89ace54906c203c0557f66ed6ea3ce8d.1453405861.git.jpoimboe@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/kvm/emulate.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 1505587d06e9..aa4d72667878 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)
309 309
310static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *)); 310static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *));
311 311
312#define FOP_ALIGN ".align " __stringify(FASTOP_SIZE) " \n\t" 312#define FOP_FUNC(name) \
313 ".align " __stringify(FASTOP_SIZE) " \n\t" \
314 ".type " name ", @function \n\t" \
315 name ":\n\t"
316
313#define FOP_RET "ret \n\t" 317#define FOP_RET "ret \n\t"
314 318
315#define FOP_START(op) \ 319#define FOP_START(op) \
316 extern void em_##op(struct fastop *fake); \ 320 extern void em_##op(struct fastop *fake); \
317 asm(".pushsection .text, \"ax\" \n\t" \ 321 asm(".pushsection .text, \"ax\" \n\t" \
318 ".global em_" #op " \n\t" \ 322 ".global em_" #op " \n\t" \
319 FOP_ALIGN \ 323 FOP_FUNC("em_" #op)
320 "em_" #op ": \n\t"
321 324
322#define FOP_END \ 325#define FOP_END \
323 ".popsection") 326 ".popsection")
324 327
325#define FOPNOP() FOP_ALIGN FOP_RET 328#define FOPNOP() \
329 FOP_FUNC(__stringify(__UNIQUE_ID(nop))) \
330 FOP_RET
326 331
327#define FOP1E(op, dst) \ 332#define FOP1E(op, dst) \
328 FOP_ALIGN "10: " #op " %" #dst " \n\t" FOP_RET 333 FOP_FUNC(#op "_" #dst) \
334 "10: " #op " %" #dst " \n\t" FOP_RET
329 335
330#define FOP1EEX(op, dst) \ 336#define FOP1EEX(op, dst) \
331 FOP1E(op, dst) _ASM_EXTABLE(10b, kvm_fastop_exception) 337 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 *));
357 FOP_END 363 FOP_END
358 364
359#define FOP2E(op, dst, src) \ 365#define FOP2E(op, dst, src) \
360 FOP_ALIGN #op " %" #src ", %" #dst " \n\t" FOP_RET 366 FOP_FUNC(#op "_" #dst "_" #src) \
367 #op " %" #src ", %" #dst " \n\t" FOP_RET
361 368
362#define FASTOP2(op) \ 369#define FASTOP2(op) \
363 FOP_START(op) \ 370 FOP_START(op) \
@@ -395,7 +402,8 @@ static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *));
395 FOP_END 402 FOP_END
396 403
397#define FOP3E(op, dst, src, src2) \ 404#define FOP3E(op, dst, src, src2) \
398 FOP_ALIGN #op " %" #src2 ", %" #src ", %" #dst " \n\t" FOP_RET 405 FOP_FUNC(#op "_" #dst "_" #src "_" #src2) \
406 #op " %" #src2 ", %" #src ", %" #dst " \n\t" FOP_RET
399 407
400/* 3-operand, word-only, src2=cl */ 408/* 3-operand, word-only, src2=cl */
401#define FASTOP3WCL(op) \ 409#define FASTOP3WCL(op) \
@@ -407,7 +415,12 @@ static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *));
407 FOP_END 415 FOP_END
408 416
409/* Special case for SETcc - 1 instruction per cc */ 417/* Special case for SETcc - 1 instruction per cc */
410#define FOP_SETCC(op) ".align 4; " #op " %al; ret \n\t" 418#define FOP_SETCC(op) \
419 ".align 4 \n\t" \
420 ".type " #op ", @function \n\t" \
421 #op ": \n\t" \
422 #op " %al \n\t" \
423 FOP_RET
411 424
412asm(".global kvm_fastop_exception \n" 425asm(".global kvm_fastop_exception \n"
413 "kvm_fastop_exception: xor %esi, %esi; ret"); 426 "kvm_fastop_exception: xor %esi, %esi; ret");