summaryrefslogtreecommitdiff
path: root/arch/powerpc/include/asm/code-patching-asm.h
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2018-07-24 01:07:52 +1000
committerMichael Ellerman <mpe@ellerman.id.au>2018-08-08 00:32:25 +1000
commit06d0bbc6d0f56dacac3a79900e9a9a0d5972d818 (patch)
treec5a1e7711581553f63c1f382945248ce1b1120ab /arch/powerpc/include/asm/code-patching-asm.h
parent26cb1f36c43ee6e89d2a9f48a5a7500d5248f836 (diff)
powerpc/asm: Add a patch_site macro & helpers for patching instructions
Add a macro and some helper C functions for patching single asm instructions. The gas macro means we can do something like: 1: nop patch_site 1b, patch__foo Which is less visually distracting than defining a GLOBAL symbol at 1, and also doesn't pollute the symbol table which can confuse eg. perf. These are obviously similar to our existing feature sections, but are not automatically patched based on CPU/MMU features, rather they are designed to be manually patched by C code at some arbitrary point. Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/include/asm/code-patching-asm.h')
-rw-r--r--arch/powerpc/include/asm/code-patching-asm.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/arch/powerpc/include/asm/code-patching-asm.h b/arch/powerpc/include/asm/code-patching-asm.h
new file mode 100644
index 000000000000..ed7b1448493a
--- /dev/null
+++ b/arch/powerpc/include/asm/code-patching-asm.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2018, Michael Ellerman, IBM Corporation.
+ */
+#ifndef _ASM_POWERPC_CODE_PATCHING_ASM_H
+#define _ASM_POWERPC_CODE_PATCHING_ASM_H
+
+/* Define a "site" that can be patched */
+.macro patch_site label name
+ .pushsection ".rodata"
+ .balign 4
+ .global \name
+\name:
+ .4byte \label - .
+ .popsection
+.endm
+
+#endif /* _ASM_POWERPC_CODE_PATCHING_ASM_H */