From: madvenka@linux.microsoft.com
To: broonie@kernel.org, jpoimboe@redhat.com, mark.rutland@arm.com,
jthierry@redhat.com, catalin.marinas@arm.com, will@kernel.org,
jmorris@namei.org, pasha.tatashin@soleen.com,
linux-arm-kernel@lists.infradead.org,
live-patching@vger.kernel.org, linux-kernel@vger.kernel.org,
madvenka@linux.microsoft.com
Subject: [RFC PATCH v3 3/4] arm64: Handle miscellaneous functions in .text and .init.text
Date: Mon, 3 May 2021 12:36:14 -0500 [thread overview]
Message-ID: <20210503173615.21576-4-madvenka@linux.microsoft.com> (raw)
In-Reply-To: <20210503173615.21576-1-madvenka@linux.microsoft.com>
From: "Madhavan T. Venkataraman" <madvenka@linux.microsoft.com>
There are some SYM_CODE functions that are currently in ".text" or
".init.text" sections. Some of these are functions that the unwinder
does not care about as they are not "interesting" to livepatch. These
will remain in their current sections. The rest I have moved into a
new section called ".code.text".
Include .code.text in sym_code_ranges[] so the unwinder can check it.
I have listed the names of the functions along with the name of their
existing section.
Don't care functions
====================
efi-entry.S:
efi_enter_kernel .init.text
relocate_kernel.S:
arm64_relocate_new_kernel .text
sigreturn.S:
__kernel_rt_sigreturn .text
arch/arm64/kvm/hyp/hyp-entry.S:
el2t_sync_invalid .text
el2t_irq_invalid .text
el2t_fiq_invalid .text
el2t_error_invalid .text
el2h_irq_invalid .text
el2h_fiq_invalid .text
el1_fiq_invalid .text
__kvm_hyp_vector .text
__bp_harden_hyp_vecs .text
arch/arm64/kvm/hyp/nvhe/host.S:
__kvm_hyp_host_vector .text
__kvm_hyp_host_forward_smc .text
Rest of the functions (moved to .code.text)
=====================
entry.S:
__swpan_entry_el1 .text
__swpan_exit_el1 .text
__swpan_entry_el0 .text
__swpan_exit_el0 .text
ret_from_fork .text
__sdei_asm_handler .text
head.S:
primary_entry .init.text
preserve_boot_args .init.text
entry-ftrace.S:
ftrace_regs_caller .text
ftrace_caller .text
ftrace_common .text
ftrace_graph_caller .text
return_to_handler .text
kprobes_trampoline.S:
kretprobe_trampoline .text
Signed-off-by: Madhavan T. Venkataraman <madvenka@linux.microsoft.com>
---
arch/arm64/include/asm/sections.h | 1 +
arch/arm64/kernel/entry-ftrace.S | 5 +++++
arch/arm64/kernel/entry.S | 6 ++++++
arch/arm64/kernel/head.S | 3 ++-
arch/arm64/kernel/probes/kprobes_trampoline.S | 2 ++
arch/arm64/kernel/stacktrace.c | 2 ++
arch/arm64/kernel/vmlinux.lds.S | 7 +++++++
7 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/sections.h b/arch/arm64/include/asm/sections.h
index 2f36b16a5b5d..bceda68aaa79 100644
--- a/arch/arm64/include/asm/sections.h
+++ b/arch/arm64/include/asm/sections.h
@@ -20,5 +20,6 @@ extern char __exittext_begin[], __exittext_end[];
extern char __irqentry_text_start[], __irqentry_text_end[];
extern char __mmuoff_data_start[], __mmuoff_data_end[];
extern char __entry_tramp_text_start[], __entry_tramp_text_end[];
+extern char __code_text_start[], __code_text_end[];
#endif /* __ASM_SECTIONS_H */
diff --git a/arch/arm64/kernel/entry-ftrace.S b/arch/arm64/kernel/entry-ftrace.S
index b3e4f9a088b1..c0831a49c290 100644
--- a/arch/arm64/kernel/entry-ftrace.S
+++ b/arch/arm64/kernel/entry-ftrace.S
@@ -12,7 +12,9 @@
#include <asm/ftrace.h>
#include <asm/insn.h>
+ .text
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
+ .pushsection ".code.text", "ax"
/*
* Due to -fpatchable-function-entry=2, the compiler has placed two NOPs before
* the regular function prologue. For an enabled callsite, ftrace_init_nop() and
@@ -135,6 +137,7 @@ SYM_CODE_START(ftrace_graph_caller)
b ftrace_common_return
SYM_CODE_END(ftrace_graph_caller)
#endif
+ .popsection
#else /* CONFIG_DYNAMIC_FTRACE_WITH_REGS */
@@ -315,6 +318,7 @@ SYM_FUNC_START(ftrace_stub)
SYM_FUNC_END(ftrace_stub)
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+ .pushsection ".code.text", "ax"
/*
* void return_to_handler(void)
*
@@ -342,4 +346,5 @@ SYM_CODE_START(return_to_handler)
ret
SYM_CODE_END(return_to_handler)
+ .popsection
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
index 6acfc5e6b5e0..3f9f7f80cd65 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -402,6 +402,7 @@ alternative_insn eret, nop, ARM64_UNMAP_KERNEL_AT_EL0
.endm
#ifdef CONFIG_ARM64_SW_TTBR0_PAN
+ .pushsection ".code.text", "ax"
/*
* Set the TTBR0 PAN bit in SPSR. When the exception is taken from
* EL0, there is no need to check the state of TTBR0_EL1 since
@@ -442,6 +443,7 @@ SYM_CODE_START_LOCAL(__swpan_exit_el0)
*/
b post_ttbr_update_workaround
SYM_CODE_END(__swpan_exit_el0)
+ .popsection
#endif
.macro irq_stack_entry
@@ -950,6 +952,7 @@ SYM_FUNC_START(cpu_switch_to)
SYM_FUNC_END(cpu_switch_to)
NOKPROBE(cpu_switch_to)
+ .pushsection ".code.text", "ax"
/*
* This is how we return from a fork.
*/
@@ -962,6 +965,7 @@ SYM_CODE_START(ret_from_fork)
b ret_to_user
SYM_CODE_END(ret_from_fork)
NOKPROBE(ret_from_fork)
+ .popsection
#ifdef CONFIG_ARM_SDE_INTERFACE
@@ -1040,6 +1044,7 @@ SYM_DATA_END(__sdei_asm_trampoline_next_handler)
#endif /* CONFIG_RANDOMIZE_BASE */
#endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */
+ .pushsection ".code.text", "ax"
/*
* Software Delegated Exception entry point.
*
@@ -1150,4 +1155,5 @@ alternative_else_nop_endif
#endif
SYM_CODE_END(__sdei_asm_handler)
NOKPROBE(__sdei_asm_handler)
+ .popsection
#endif /* CONFIG_ARM_SDE_INTERFACE */
diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index 840bda1869e9..4ce96dfac2b8 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -75,7 +75,7 @@
__EFI_PE_HEADER
__INIT
-
+ .pushsection ".code.text", "ax"
/*
* The following callee saved general purpose registers are used on the
* primary lowlevel boot path:
@@ -120,6 +120,7 @@ SYM_CODE_START_LOCAL(preserve_boot_args)
mov x1, #0x20 // 4 x 8 bytes
b __inval_dcache_area // tail call
SYM_CODE_END(preserve_boot_args)
+ .popsection
/*
* Macro to create a table entry to the next page.
diff --git a/arch/arm64/kernel/probes/kprobes_trampoline.S b/arch/arm64/kernel/probes/kprobes_trampoline.S
index 288a84e253cc..9244e119af3e 100644
--- a/arch/arm64/kernel/probes/kprobes_trampoline.S
+++ b/arch/arm64/kernel/probes/kprobes_trampoline.S
@@ -8,6 +8,7 @@
#include <asm/assembler.h>
.text
+ .pushsection ".code.text", "ax"
.macro save_all_base_regs
stp x0, x1, [sp, #S_X0]
@@ -80,3 +81,4 @@ SYM_CODE_START(kretprobe_trampoline)
ret
SYM_CODE_END(kretprobe_trampoline)
+ .popsection
diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c
index 1ff14615a55a..33e174160f9b 100644
--- a/arch/arm64/kernel/stacktrace.c
+++ b/arch/arm64/kernel/stacktrace.c
@@ -43,6 +43,8 @@ struct code_range sym_code_ranges[] =
{ (unsigned long)__entry_tramp_text_start,
(unsigned long)__entry_tramp_text_end },
#endif
+ { (unsigned long)__code_text_start,
+ (unsigned long)__code_text_end },
{ /* sentinel */ }
};
diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
index 7eea7888bb02..c00b3232e6dc 100644
--- a/arch/arm64/kernel/vmlinux.lds.S
+++ b/arch/arm64/kernel/vmlinux.lds.S
@@ -103,6 +103,12 @@ jiffies = jiffies_64;
#define TRAMP_TEXT
#endif
+#define CODE_TEXT \
+ . = ALIGN(SZ_4K); \
+ __code_text_start = .; \
+ *(.code.text) \
+ __code_text_end = .;
+
/*
* The size of the PE/COFF section that covers the kernel image, which
* runs from _stext to _edata, must be a round multiple of the PE/COFF
@@ -145,6 +151,7 @@ SECTIONS
SOFTIRQENTRY_TEXT
ENTRY_TEXT
TEXT_TEXT
+ CODE_TEXT
SCHED_TEXT
CPUIDLE_TEXT
LOCK_TEXT
--
2.25.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-05-03 17:38 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <65cf4dfbc439b010b50a0c46ec500432acde86d6>
2021-05-03 17:36 ` [RFC PATCH v3 0/4] arm64: Stack trace reliability checks in the unwinder madvenka
2021-05-03 17:36 ` [RFC PATCH v3 1/4] arm64: Introduce stack " madvenka
2021-05-04 15:50 ` Mark Brown
2021-05-04 19:14 ` Madhavan T. Venkataraman
2021-05-04 21:52 ` Josh Poimboeuf
2021-05-04 23:13 ` Madhavan T. Venkataraman
2021-05-05 0:07 ` Josh Poimboeuf
2021-05-05 0:21 ` Madhavan T. Venkataraman
2021-05-03 17:36 ` [RFC PATCH v3 2/4] arm64: Check the return PC against unreliable code sections madvenka
2021-05-04 16:05 ` Mark Brown
2021-05-04 19:03 ` Madhavan T. Venkataraman
2021-05-04 19:32 ` Madhavan T. Venkataraman
2021-05-05 16:46 ` Mark Brown
2021-05-05 18:48 ` Madhavan T. Venkataraman
2021-05-05 18:50 ` Madhavan T. Venkataraman
2021-05-06 13:45 ` Mark Brown
2021-05-06 15:21 ` Madhavan T. Venkataraman
2021-05-05 16:34 ` Mark Brown
2021-05-05 17:51 ` Madhavan T. Venkataraman
2021-05-05 19:30 ` Ard Biesheuvel
2021-05-05 20:00 ` Madhavan T. Venkataraman
2021-05-03 17:36 ` madvenka [this message]
2021-05-06 14:12 ` [RFC PATCH v3 3/4] arm64: Handle miscellaneous functions in .text and .init.text Mark Brown
2021-05-06 15:30 ` Madhavan T. Venkataraman
2021-05-06 15:32 ` Madhavan T. Venkataraman
2021-05-06 15:44 ` Mark Brown
2021-05-06 15:56 ` Madhavan T. Venkataraman
2021-05-06 15:37 ` Mark Brown
2021-05-06 15:57 ` Madhavan T. Venkataraman
2021-05-03 17:36 ` [RFC PATCH v3 4/4] arm64: Handle funtion graph tracer better in the unwinder madvenka
2021-05-06 14:43 ` Mark Brown
2021-05-06 15:20 ` Madhavan T. Venkataraman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210503173615.21576-4-madvenka@linux.microsoft.com \
--to=madvenka@linux.microsoft.com \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=jmorris@namei.org \
--cc=jpoimboe@redhat.com \
--cc=jthierry@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=pasha.tatashin@soleen.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).