[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211122170805.025419814@infradead.org>
Date: Mon, 22 Nov 2021 18:03:02 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: x86@...nel.org, joao@...rdrivepizza.com, hjl.tools@...il.com,
jpoimboe@...hat.com, andrew.cooper3@...rix.com
Cc: linux-kernel@...r.kernel.org, peterz@...radead.org,
ndesaulniers@...gle.com, keescook@...omium.org,
samitolvanen@...gle.com
Subject: [RFC][PATCH 1/6] x86: Annotate _THIS_IP_
In order to find _THIS_IP_ code references in objtool, annotate them.
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
---
arch/x86/include/asm/linkage.h | 11 +++++++++++
include/linux/instruction_pointer.h | 5 +++++
2 files changed, 16 insertions(+)
--- a/arch/x86/include/asm/linkage.h
+++ b/arch/x86/include/asm/linkage.h
@@ -3,10 +3,21 @@
#define _ASM_X86_LINKAGE_H
#include <linux/stringify.h>
+#include <asm/asm.h>
#undef notrace
#define notrace __attribute__((no_instrument_function))
+#define _THIS_IP_ \
+ ({ __label__ __here; \
+ __here: \
+ asm_volatile_goto ( \
+ ".pushsection .discard.this_ip\n\t" \
+ _ASM_PTR " %l[__here]\n\t" \
+ ".popsection\n\t" \
+ : : : : __here); \
+ (unsigned long)&&__here; })
+
#ifdef CONFIG_X86_32
#define asmlinkage CPP_ASMLINKAGE __attribute__((regparm(0)))
#endif /* CONFIG_X86_32 */
--- a/include/linux/instruction_pointer.h
+++ b/include/linux/instruction_pointer.h
@@ -2,7 +2,12 @@
#ifndef _LINUX_INSTRUCTION_POINTER_H
#define _LINUX_INSTRUCTION_POINTER_H
+#include <asm/linkage.h>
+
#define _RET_IP_ (unsigned long)__builtin_return_address(0)
+
+#ifndef _THIS_IP_
#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
+#endif
#endif /* _LINUX_INSTRUCTION_POINTER_H */
Powered by blists - more mailing lists