From 1a8ca37379e532a140e87a77aed12b1eed9aa585 Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Thu, 9 Aug 2018 19:33:33 +0900 Subject: [PATCH] arch/x86: Add NOP pattern for dynamic tracing It seems recent GCC changed NOP pattern used in -mnop-mcount. It makes test cases failed so fix it. Signed-off-by: Namhyung Kim --- arch/x86_64/mcount-dynamic.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/x86_64/mcount-dynamic.c b/arch/x86_64/mcount-dynamic.c index 29fcdc86d..b45378710 100644 --- a/arch/x86_64/mcount-dynamic.c +++ b/arch/x86_64/mcount-dynamic.c @@ -175,13 +175,15 @@ static unsigned long get_target_addr(struct mcount_dynamic_info *mdi, unsigned l static int patch_fentry_func(struct mcount_dynamic_info *mdi, struct sym *sym) { - unsigned char nop[] = { 0x67, 0x0f, 0x1f, 0x04, 0x00 }; + unsigned char nop1[] = { 0x67, 0x0f, 0x1f, 0x04, 0x00 }; + unsigned char nop2[] = { 0x0f, 0x1f, 0x44, 0x00, 0x00 }; unsigned char *insn = (void *)sym->addr; unsigned int target_addr; /* only support calls to __fentry__ at the beginning */ - if (memcmp(insn, nop, sizeof(nop))) { - pr_dbg2("skip non-applicable functions: %s\n", sym->name); + if (memcmp(insn, nop1, sizeof(nop1)) && /* old pattern */ + memcmp(insn, nop2, sizeof(nop2))) { /* new pattern */ + pr_dbg("skip non-applicable functions: %s\n", sym->name); return -2; }