diff mbox series

[RFC,v3,20/22] arm64: Define HAVE_DYNAMIC_FTRACE_WITH_ARGS

Message ID 20230202074036.507249-21-madvenka@linux.microsoft.com (mailing list archive)
State New, archived
Headers show
Series arm64: livepatch: Use ORC for dynamic frame pointer validation | expand

Commit Message

Madhavan T. Venkataraman Feb. 2, 2023, 7:40 a.m. UTC
From: "Madhavan T. Venkataraman" <madvenka@linux.microsoft.com>

	- Define HAVE_DYNAMIC_FTRACE_WITH_ARGS to support livepatch.

	- Supply the arch code for HAVE_DYNAMIC_FTRACE_WITH_ARGS.

Signed-off-by: Madhavan T. Venkataraman <madvenka@linux.microsoft.com>
---
 arch/arm64/Kconfig.debug        |  1 +
 arch/arm64/include/asm/ftrace.h | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)
diff mbox series

Patch

diff --git a/arch/arm64/Kconfig.debug b/arch/arm64/Kconfig.debug
index a50caabdb18e..6d5dc90a0a52 100644
--- a/arch/arm64/Kconfig.debug
+++ b/arch/arm64/Kconfig.debug
@@ -45,6 +45,7 @@  config FRAME_POINTER_VALIDATION
 	bool "Dynamic Frame pointer validation"
 	select UNWINDER_FRAME_POINTER
 	select UNWINDER_ORC
+	select HAVE_DYNAMIC_FTRACE_WITH_ARGS
 	help
 		This invokes objtool on every object file causing it to
 		generate ORC data for the object file. ORC data is in a custom
diff --git a/arch/arm64/include/asm/ftrace.h b/arch/arm64/include/asm/ftrace.h
index 329dbbd4d50b..0bc03ecfb257 100644
--- a/arch/arm64/include/asm/ftrace.h
+++ b/arch/arm64/include/asm/ftrace.h
@@ -78,6 +78,26 @@  static inline unsigned long ftrace_call_adjust(unsigned long addr)
 	return addr;
 }
 
+#ifdef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS
+
+struct ftrace_regs {
+	struct pt_regs		regs;
+};
+
+static __always_inline struct pt_regs *
+arch_ftrace_get_regs(struct ftrace_regs *fregs)
+{
+	return &fregs->regs;
+}
+
+static __always_inline void ftrace_instruction_pointer_set(
+				struct ftrace_regs *fregs, unsigned long pc)
+{
+	fregs->regs.pc = pc;
+}
+
+#endif
+
 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
 struct dyn_ftrace;
 struct ftrace_ops;