Skip to content

Commit 2ed84b1

Browse files
Suraj Jitindar Singhpuranjaymohan
authored andcommitted
kpatch-build: Add sym->has_func_profiling support for aarch64
The "has_function_profiling" support field in the symbol struct is used to show that a function symbol is able to be patched. This is necessary to check that functions which need to be patched are able to be. On arm64 this means the presence of 2 NOP instructions at function entry which are patched by ftrace to call the ftrace handling code. These 2 NOPs are inserted by the compiler and the location of them is recorded in a section called "__patchable_function_entries". Check whether a symbol has a corresponding entry in the "__patchable_function_entries" section and if so mark it as "has_func_profiling". Signed-off-by: Suraj Jitindar Singh <surajjs@amazon.com> [Modify to use __patchable_function_entries support added upstream] Signed-off-by: Puranjay Mohan <pjy@amazon.com>
1 parent 6bea1dd commit 2ed84b1

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

kpatch-build/create-diff-object.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,8 +1700,8 @@ static void kpatch_check_func_profiling_calls(struct kpatch_elf *kelf)
17001700
(sym->parent && sym->parent->status == CHANGED))
17011701
continue;
17021702
if (!sym->twin->has_func_profiling) {
1703-
log_error("function %s has no fentry/mcount call, unable to patch\n",
1704-
sym->name);
1703+
log_error("function %s doesn't have patchable function entry, unable to patch\n",
1704+
sym->name);
17051705
errs++;
17061706
}
17071707
}
@@ -4180,6 +4180,10 @@ static void kpatch_find_func_profiling_calls(struct kpatch_elf *kelf)
41804180
insn[4] == 0x00 && insn[5] == 0x00)
41814181
sym->has_func_profiling = 1;
41824182
break;
4183+
case AARCH64:
4184+
if (kpatch_symbol_has_pfe_entry(kelf, sym))
4185+
sym->has_func_profiling = 1;
4186+
break;
41834187
default:
41844188
ERROR("unsupported arch");
41854189
}

kpatch-build/kpatch-elf.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,9 @@ struct kpatch_elf *kpatch_elf_open(const char *name)
594594
case EM_S390:
595595
kelf->arch = S390;
596596
break;
597+
case EM_AARCH64:
598+
kelf->arch = ARM64;
599+
break;
597600
default:
598601
ERROR("Unsupported target architecture");
599602
}

kpatch-build/kpatch-elf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ enum architecture {
116116
PPC64 = 0x1 << 0,
117117
X86_64 = 0x1 << 1,
118118
S390 = 0x1 << 2,
119+
AARCH64 = 0x1 << 3,
119120
};
120121

121122
struct kpatch_elf {

0 commit comments

Comments
 (0)