* [PATCH v2 00/16] objtool: Rewrite annotations
@ 2024-11-28 9:38 Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 01/16] objtool: Generic annotation infrastructure Peter Zijlstra
` (16 more replies)
0 siblings, 17 replies; 36+ messages in thread
From: Peter Zijlstra @ 2024-11-28 9:38 UTC (permalink / raw)
To: jpoimboe; +Cc: chenhuacai, kernel, x86, peterz, loongarch, linux-kernel
Rewrite/unify the objtool instruction based annotations.
Changes since last time:
- removed unreachable annotation
- included reachable annotation
- various smaller things
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 01/16] objtool: Generic annotation infrastructure
2024-11-28 9:38 [PATCH v2 00/16] objtool: Rewrite annotations Peter Zijlstra
@ 2024-11-28 9:38 ` Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 02/16] objtool: Convert ANNOTATE_NOENDBR to ANNOTATE Peter Zijlstra
` (15 subsequent siblings)
16 siblings, 1 reply; 36+ messages in thread
From: Peter Zijlstra @ 2024-11-28 9:38 UTC (permalink / raw)
To: jpoimboe; +Cc: chenhuacai, kernel, x86, peterz, loongarch, linux-kernel
Avoid endless .discard.foo sections for each annotation, create a
single .discard.annotate_insn section that takes an annotation type along
with the instruction.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
include/linux/objtool.h | 18 ++++++++++++++++++
tools/objtool/check.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+)
--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -57,6 +57,13 @@
".long 998b\n\t" \
".popsection\n\t"
+#define ASM_ANNOTATE(type) \
+ "911:\n\t" \
+ ".pushsection .discard.annotate_insn,\"M\",@progbits,8\n\t" \
+ ".long 911b - .\n\t" \
+ ".long " __stringify(type) "\n\t" \
+ ".popsection\n\t"
+
#else /* __ASSEMBLY__ */
/*
@@ -146,6 +153,14 @@
.popsection
.endm
+.macro ANNOTATE type:req
+.Lhere_\@:
+ .pushsection .discard.annotate_insn,"M",@progbits,8
+ .long .Lhere_\@ - .
+ .long \type
+ .popsection
+.endm
+
#endif /* __ASSEMBLY__ */
#else /* !CONFIG_OBJTOOL */
@@ -155,6 +170,7 @@
#define UNWIND_HINT(type, sp_reg, sp_offset, signal) "\n\t"
#define STACK_FRAME_NON_STANDARD(func)
#define STACK_FRAME_NON_STANDARD_FP(func)
+#define ASM_ANNOTATE(type)
#define ANNOTATE_NOENDBR
#define ASM_REACHABLE
#else
@@ -167,6 +183,8 @@
.endm
.macro REACHABLE
.endm
+.macro ANNOTATE type:req
+.endm
#endif
#endif /* CONFIG_OBJTOOL */
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2373,6 +2373,49 @@ static int read_unwind_hints(struct objt
return 0;
}
+static int read_annotate(struct objtool_file *file, void (*func)(int type, struct instruction *insn))
+{
+ struct section *sec;
+ struct instruction *insn;
+ struct reloc *reloc;
+ int type;
+
+ sec = find_section_by_name(file->elf, ".discard.annotate_insn");
+ if (!sec)
+ return 0;
+
+ if (!sec->rsec)
+ return 0;
+
+ if (sec->sh.sh_entsize != 8) {
+ static bool warned = false;
+ if (!warned) {
+ WARN("%s: dodgy linker, sh_entsize != 8", sec->name);
+ warned = true;
+ }
+ sec->sh.sh_entsize = 8;
+ }
+
+ for_each_reloc(sec->rsec, reloc) {
+ type = *(u32 *)(sec->data->d_buf + (reloc_idx(reloc) * sec->sh.sh_entsize) + 4);
+
+ insn = find_insn(file, reloc->sym->sec,
+ reloc->sym->offset + reloc_addend(reloc));
+ if (!insn) {
+ WARN("bad .discard.annotate_insn entry: %d of type %d", reloc_idx(reloc), type);
+ return -1;
+ }
+
+ func(type, insn);
+ }
+
+ return 0;
+}
+
+static void __annotate_nop(int type, struct instruction *insn)
+{
+}
+
static int read_noendbr_hints(struct objtool_file *file)
{
struct instruction *insn;
@@ -2670,6 +2713,8 @@ static int decode_sections(struct objtoo
if (ret)
return ret;
+ read_annotate(file, __annotate_nop);
+
/*
* Must be before read_unwind_hints() since that needs insn->noendbr.
*/
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 02/16] objtool: Convert ANNOTATE_NOENDBR to ANNOTATE
2024-11-28 9:38 [PATCH v2 00/16] objtool: Rewrite annotations Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 01/16] objtool: Generic annotation infrastructure Peter Zijlstra
@ 2024-11-28 9:38 ` Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 03/16] objtool: Convert ANNOTATE_RETPOLINE_SAFE " Peter Zijlstra
` (14 subsequent siblings)
16 siblings, 1 reply; 36+ messages in thread
From: Peter Zijlstra @ 2024-11-28 9:38 UTC (permalink / raw)
To: jpoimboe; +Cc: chenhuacai, kernel, x86, peterz, loongarch, linux-kernel
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
include/linux/objtool.h | 17 ++++-------------
include/linux/objtool_types.h | 5 +++++
tools/include/linux/objtool_types.h | 5 +++++
tools/objtool/check.c | 32 +++++---------------------------
4 files changed, 19 insertions(+), 40 deletions(-)
--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -45,12 +45,6 @@
#define STACK_FRAME_NON_STANDARD_FP(func)
#endif
-#define ANNOTATE_NOENDBR \
- "986: \n\t" \
- ".pushsection .discard.noendbr\n\t" \
- ".long 986b\n\t" \
- ".popsection\n\t"
-
#define ASM_REACHABLE \
"998:\n\t" \
".pushsection .discard.reachable\n\t" \
@@ -64,6 +58,8 @@
".long " __stringify(type) "\n\t" \
".popsection\n\t"
+#define ANNOTATE_NOENDBR ASM_ANNOTATE(ANNOTYPE_NOENDBR)
+
#else /* __ASSEMBLY__ */
/*
@@ -122,13 +118,6 @@
#endif
.endm
-.macro ANNOTATE_NOENDBR
-.Lhere_\@:
- .pushsection .discard.noendbr
- .long .Lhere_\@
- .popsection
-.endm
-
/*
* Use objtool to validate the entry requirement that all code paths do
* VALIDATE_UNRET_END before RET.
@@ -161,6 +150,8 @@
.popsection
.endm
+#define ANNOTATE_NOENDBR ANNOTATE type=ANNOTYPE_NOENDBR
+
#endif /* __ASSEMBLY__ */
#else /* !CONFIG_OBJTOOL */
--- a/include/linux/objtool_types.h
+++ b/include/linux/objtool_types.h
@@ -54,4 +54,9 @@ struct unwind_hint {
#define UNWIND_HINT_TYPE_SAVE 6
#define UNWIND_HINT_TYPE_RESTORE 7
+/*
+ * Annotate types
+ */
+#define ANNOTYPE_NOENDBR 1
+
#endif /* _LINUX_OBJTOOL_TYPES_H */
--- a/tools/include/linux/objtool_types.h
+++ b/tools/include/linux/objtool_types.h
@@ -54,4 +54,9 @@ struct unwind_hint {
#define UNWIND_HINT_TYPE_SAVE 6
#define UNWIND_HINT_TYPE_RESTORE 7
+/*
+ * Annotate types
+ */
+#define ANNOTYPE_NOENDBR 1
+
#endif /* _LINUX_OBJTOOL_TYPES_H */
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2412,32 +2412,12 @@ static int read_annotate(struct objtool_
return 0;
}
-static void __annotate_nop(int type, struct instruction *insn)
+static void __annotate_noendbr(int type, struct instruction *insn)
{
-}
-
-static int read_noendbr_hints(struct objtool_file *file)
-{
- struct instruction *insn;
- struct section *rsec;
- struct reloc *reloc;
-
- rsec = find_section_by_name(file->elf, ".rela.discard.noendbr");
- if (!rsec)
- return 0;
+ if (type != ANNOTYPE_NOENDBR)
+ return;
- for_each_reloc(rsec, reloc) {
- insn = find_insn(file, reloc->sym->sec,
- reloc->sym->offset + reloc_addend(reloc));
- if (!insn) {
- WARN("bad .discard.noendbr entry");
- return -1;
- }
-
- insn->noendbr = 1;
- }
-
- return 0;
+ insn->noendbr = 1;
}
static int read_retpoline_hints(struct objtool_file *file)
@@ -2713,12 +2693,10 @@ static int decode_sections(struct objtoo
if (ret)
return ret;
- read_annotate(file, __annotate_nop);
-
/*
* Must be before read_unwind_hints() since that needs insn->noendbr.
*/
- ret = read_noendbr_hints(file);
+ ret = read_annotate(file, __annotate_noendbr);
if (ret)
return ret;
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 03/16] objtool: Convert ANNOTATE_RETPOLINE_SAFE to ANNOTATE
2024-11-28 9:38 [PATCH v2 00/16] objtool: Rewrite annotations Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 01/16] objtool: Generic annotation infrastructure Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 02/16] objtool: Convert ANNOTATE_NOENDBR to ANNOTATE Peter Zijlstra
@ 2024-11-28 9:38 ` Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 04/16] objtool: Convert instrumentation_{begin,end}() " Peter Zijlstra
` (13 subsequent siblings)
16 siblings, 1 reply; 36+ messages in thread
From: Peter Zijlstra @ 2024-11-28 9:38 UTC (permalink / raw)
To: jpoimboe; +Cc: chenhuacai, kernel, x86, peterz, loongarch, linux-kernel
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/x86/include/asm/nospec-branch.h | 13 +-------
include/linux/objtool_types.h | 1
tools/include/linux/objtool_types.h | 1
tools/objtool/check.c | 52 ++++++++++++-----------------------
4 files changed, 22 insertions(+), 45 deletions(-)
--- a/arch/x86/include/asm/nospec-branch.h
+++ b/arch/x86/include/asm/nospec-branch.h
@@ -184,12 +184,7 @@
* objtool the subsequent indirect jump/call is vouched safe for retpoline
* builds.
*/
-.macro ANNOTATE_RETPOLINE_SAFE
-.Lhere_\@:
- .pushsection .discard.retpoline_safe
- .long .Lhere_\@
- .popsection
-.endm
+#define ANNOTATE_RETPOLINE_SAFE ANNOTATE type=ANNOTYPE_RETPOLINE_SAFE
/*
* (ab)use RETPOLINE_SAFE on RET to annotate away 'bare' RET instructions
@@ -350,11 +345,7 @@
#else /* __ASSEMBLY__ */
-#define ANNOTATE_RETPOLINE_SAFE \
- "999:\n\t" \
- ".pushsection .discard.retpoline_safe\n\t" \
- ".long 999b\n\t" \
- ".popsection\n\t"
+#define ANNOTATE_RETPOLINE_SAFE ASM_ANNOTATE(ANNOTYPE_RETPOLINE_SAFE)
typedef u8 retpoline_thunk_t[RETPOLINE_THUNK_SIZE];
extern retpoline_thunk_t __x86_indirect_thunk_array[];
--- a/include/linux/objtool_types.h
+++ b/include/linux/objtool_types.h
@@ -58,5 +58,6 @@ struct unwind_hint {
* Annotate types
*/
#define ANNOTYPE_NOENDBR 1
+#define ANNOTYPE_RETPOLINE_SAFE 2
#endif /* _LINUX_OBJTOOL_TYPES_H */
--- a/tools/include/linux/objtool_types.h
+++ b/tools/include/linux/objtool_types.h
@@ -58,5 +58,6 @@ struct unwind_hint {
* Annotate types
*/
#define ANNOTYPE_NOENDBR 1
+#define ANNOTYPE_RETPOLINE_SAFE 2
#endif /* _LINUX_OBJTOOL_TYPES_H */
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2373,12 +2373,12 @@ static int read_unwind_hints(struct objt
return 0;
}
-static int read_annotate(struct objtool_file *file, void (*func)(int type, struct instruction *insn))
+static int read_annotate(struct objtool_file *file, int (*func)(int type, struct instruction *insn))
{
struct section *sec;
struct instruction *insn;
struct reloc *reloc;
- int type;
+ int type, ret;
sec = find_section_by_name(file->elf, ".discard.annotate_insn");
if (!sec)
@@ -2406,53 +2406,37 @@ static int read_annotate(struct objtool_
return -1;
}
- func(type, insn);
+ ret = func(type, insn);
+ if (ret < 0)
+ return ret;
}
return 0;
}
-static void __annotate_noendbr(int type, struct instruction *insn)
+static int __annotate_noendbr(int type, struct instruction *insn)
{
if (type != ANNOTYPE_NOENDBR)
- return;
+ return 0;
insn->noendbr = 1;
+ return 0;
}
-static int read_retpoline_hints(struct objtool_file *file)
+static int __annotate_retpoline_safe(int type, struct instruction *insn)
{
- struct section *rsec;
- struct instruction *insn;
- struct reloc *reloc;
-
- rsec = find_section_by_name(file->elf, ".rela.discard.retpoline_safe");
- if (!rsec)
+ if (type != ANNOTYPE_RETPOLINE_SAFE)
return 0;
- for_each_reloc(rsec, reloc) {
- if (reloc->sym->type != STT_SECTION) {
- WARN("unexpected relocation symbol type in %s", rsec->name);
- return -1;
- }
-
- insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
- if (!insn) {
- WARN("bad .discard.retpoline_safe entry");
- return -1;
- }
-
- if (insn->type != INSN_JUMP_DYNAMIC &&
- insn->type != INSN_CALL_DYNAMIC &&
- insn->type != INSN_RETURN &&
- insn->type != INSN_NOP) {
- WARN_INSN(insn, "retpoline_safe hint not an indirect jump/call/ret/nop");
- return -1;
- }
-
- insn->retpoline_safe = true;
+ if (insn->type != INSN_JUMP_DYNAMIC &&
+ insn->type != INSN_CALL_DYNAMIC &&
+ insn->type != INSN_RETURN &&
+ insn->type != INSN_NOP) {
+ WARN_INSN(insn, "retpoline_safe hint not an indirect jump/call/ret/nop");
+ return -1;
}
+ insn->retpoline_safe = true;
return 0;
}
@@ -2742,7 +2726,7 @@ static int decode_sections(struct objtoo
if (ret)
return ret;
- ret = read_retpoline_hints(file);
+ ret = read_annotate(file, __annotate_retpoline_safe);
if (ret)
return ret;
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 04/16] objtool: Convert instrumentation_{begin,end}() to ANNOTATE
2024-11-28 9:38 [PATCH v2 00/16] objtool: Rewrite annotations Peter Zijlstra
` (2 preceding siblings ...)
2024-11-28 9:38 ` [PATCH v2 03/16] objtool: Convert ANNOTATE_RETPOLINE_SAFE " Peter Zijlstra
@ 2024-11-28 9:38 ` Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 05/16] objtool: Convert VALIDATE_UNRET_BEGIN " Peter Zijlstra
` (12 subsequent siblings)
16 siblings, 1 reply; 36+ messages in thread
From: Peter Zijlstra @ 2024-11-28 9:38 UTC (permalink / raw)
To: jpoimboe; +Cc: chenhuacai, kernel, x86, peterz, loongarch, linux-kernel
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
include/linux/instrumentation.h | 11 +++-----
include/linux/objtool.h | 12 ++++++--
include/linux/objtool_types.h | 2 +
tools/include/linux/objtool_types.h | 2 +
tools/objtool/check.c | 49 +++++++-----------------------------
5 files changed, 28 insertions(+), 48 deletions(-)
--- a/include/linux/instrumentation.h
+++ b/include/linux/instrumentation.h
@@ -4,14 +4,14 @@
#ifdef CONFIG_NOINSTR_VALIDATION
+#include <linux/objtool.h>
#include <linux/stringify.h>
/* Begin/end of an instrumentation safe region */
#define __instrumentation_begin(c) ({ \
asm volatile(__stringify(c) ": nop\n\t" \
- ".pushsection .discard.instr_begin\n\t" \
- ".long " __stringify(c) "b - .\n\t" \
- ".popsection\n\t" : : "i" (c)); \
+ __ASM_ANNOTATE(__ASM_BREF(c), ANNOTYPE_INSTR_BEGIN)\
+ : : "i" (c)); \
})
#define instrumentation_begin() __instrumentation_begin(__COUNTER__)
@@ -48,9 +48,8 @@
*/
#define __instrumentation_end(c) ({ \
asm volatile(__stringify(c) ": nop\n\t" \
- ".pushsection .discard.instr_end\n\t" \
- ".long " __stringify(c) "b - .\n\t" \
- ".popsection\n\t" : : "i" (c)); \
+ __ASM_ANNOTATE(__ASM_BREF(c), ANNOTYPE_INSTR_END) \
+ : : "i" (c)); \
})
#define instrumentation_end() __instrumentation_end(__COUNTER__)
#else /* !CONFIG_NOINSTR_VALIDATION */
--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -51,13 +51,18 @@
".long 998b\n\t" \
".popsection\n\t"
-#define ASM_ANNOTATE(type) \
- "911:\n\t" \
+#define __ASM_BREF(label) label ## b
+
+#define __ASM_ANNOTATE(label, type) \
".pushsection .discard.annotate_insn,\"M\",@progbits,8\n\t" \
- ".long 911b - .\n\t" \
+ ".long " __stringify(label) " - .\n\t" \
".long " __stringify(type) "\n\t" \
".popsection\n\t"
+#define ASM_ANNOTATE(type) \
+ "911:\n\t" \
+ __ASM_ANNOTATE(911b, type)
+
#define ANNOTATE_NOENDBR ASM_ANNOTATE(ANNOTYPE_NOENDBR)
#else /* __ASSEMBLY__ */
@@ -161,6 +166,7 @@
#define UNWIND_HINT(type, sp_reg, sp_offset, signal) "\n\t"
#define STACK_FRAME_NON_STANDARD(func)
#define STACK_FRAME_NON_STANDARD_FP(func)
+#define __ASM_ANNOTATE(label, type)
#define ASM_ANNOTATE(type)
#define ANNOTATE_NOENDBR
#define ASM_REACHABLE
--- a/include/linux/objtool_types.h
+++ b/include/linux/objtool_types.h
@@ -59,5 +59,7 @@ struct unwind_hint {
*/
#define ANNOTYPE_NOENDBR 1
#define ANNOTYPE_RETPOLINE_SAFE 2
+#define ANNOTYPE_INSTR_BEGIN 3
+#define ANNOTYPE_INSTR_END 4
#endif /* _LINUX_OBJTOOL_TYPES_H */
--- a/tools/include/linux/objtool_types.h
+++ b/tools/include/linux/objtool_types.h
@@ -59,5 +59,7 @@ struct unwind_hint {
*/
#define ANNOTYPE_NOENDBR 1
#define ANNOTYPE_RETPOLINE_SAFE 2
+#define ANNOTYPE_INSTR_BEGIN 3
+#define ANNOTYPE_INSTR_END 4
#endif /* _LINUX_OBJTOOL_TYPES_H */
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2440,48 +2440,19 @@ static int __annotate_retpoline_safe(int
return 0;
}
-static int read_instr_hints(struct objtool_file *file)
+static int __annotate_instr(int type, struct instruction *insn)
{
- struct section *rsec;
- struct instruction *insn;
- struct reloc *reloc;
-
- rsec = find_section_by_name(file->elf, ".rela.discard.instr_end");
- if (!rsec)
- return 0;
-
- for_each_reloc(rsec, reloc) {
- if (reloc->sym->type != STT_SECTION) {
- WARN("unexpected relocation symbol type in %s", rsec->name);
- return -1;
- }
-
- insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
- if (!insn) {
- WARN("bad .discard.instr_end entry");
- return -1;
- }
+ switch (type) {
+ case ANNOTYPE_INSTR_BEGIN:
+ insn->instr++;
+ break;
+ case ANNOTYPE_INSTR_END:
insn->instr--;
- }
-
- rsec = find_section_by_name(file->elf, ".rela.discard.instr_begin");
- if (!rsec)
- return 0;
+ break;
- for_each_reloc(rsec, reloc) {
- if (reloc->sym->type != STT_SECTION) {
- WARN("unexpected relocation symbol type in %s", rsec->name);
- return -1;
- }
-
- insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
- if (!insn) {
- WARN("bad .discard.instr_begin entry");
- return -1;
- }
-
- insn->instr++;
+ default:
+ break;
}
return 0;
@@ -2730,7 +2701,7 @@ static int decode_sections(struct objtoo
if (ret)
return ret;
- ret = read_instr_hints(file);
+ ret = read_annotate(file, __annotate_instr);
if (ret)
return ret;
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 05/16] objtool: Convert VALIDATE_UNRET_BEGIN to ANNOTATE
2024-11-28 9:38 [PATCH v2 00/16] objtool: Rewrite annotations Peter Zijlstra
` (3 preceding siblings ...)
2024-11-28 9:38 ` [PATCH v2 04/16] objtool: Convert instrumentation_{begin,end}() " Peter Zijlstra
@ 2024-11-28 9:38 ` Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 06/16] objtool: Convert ANNOTATE_IGNORE_ALTERNATIVE " Peter Zijlstra
` (11 subsequent siblings)
16 siblings, 1 reply; 36+ messages in thread
From: Peter Zijlstra @ 2024-11-28 9:38 UTC (permalink / raw)
To: jpoimboe; +Cc: chenhuacai, kernel, x86, peterz, loongarch, linux-kernel
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
include/linux/objtool.h | 9 +++------
include/linux/objtool_types.h | 1 +
tools/include/linux/objtool_types.h | 1 +
tools/objtool/check.c | 28 +++++-----------------------
4 files changed, 10 insertions(+), 29 deletions(-)
--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -130,15 +130,12 @@
* NOTE: The macro must be used at the beginning of a global symbol, otherwise
* it will be ignored.
*/
-.macro VALIDATE_UNRET_BEGIN
#if defined(CONFIG_NOINSTR_VALIDATION) && \
(defined(CONFIG_MITIGATION_UNRET_ENTRY) || defined(CONFIG_MITIGATION_SRSO))
-.Lhere_\@:
- .pushsection .discard.validate_unret
- .long .Lhere_\@ - .
- .popsection
+#define VALIDATE_UNRET_BEGIN ANNOTATE type=ANNOTYPE_UNRET_BEGIN
+#else
+#define VALIDATE_UNRET_BEGIN
#endif
-.endm
.macro REACHABLE
.Lhere_\@:
--- a/include/linux/objtool_types.h
+++ b/include/linux/objtool_types.h
@@ -61,5 +61,6 @@ struct unwind_hint {
#define ANNOTYPE_RETPOLINE_SAFE 2
#define ANNOTYPE_INSTR_BEGIN 3
#define ANNOTYPE_INSTR_END 4
+#define ANNOTYPE_UNRET_BEGIN 5
#endif /* _LINUX_OBJTOOL_TYPES_H */
--- a/tools/include/linux/objtool_types.h
+++ b/tools/include/linux/objtool_types.h
@@ -61,5 +61,6 @@ struct unwind_hint {
#define ANNOTYPE_RETPOLINE_SAFE 2
#define ANNOTYPE_INSTR_BEGIN 3
#define ANNOTYPE_INSTR_END 4
+#define ANNOTYPE_UNRET_BEGIN 5
#endif /* _LINUX_OBJTOOL_TYPES_H */
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2458,33 +2458,15 @@ static int __annotate_instr(int type, st
return 0;
}
-static int read_validate_unret_hints(struct objtool_file *file)
+static int __annotate_unret(int type, struct instruction *insn)
{
- struct section *rsec;
- struct instruction *insn;
- struct reloc *reloc;
-
- rsec = find_section_by_name(file->elf, ".rela.discard.validate_unret");
- if (!rsec)
+ if (type != ANNOTYPE_UNRET_BEGIN)
return 0;
- for_each_reloc(rsec, reloc) {
- if (reloc->sym->type != STT_SECTION) {
- WARN("unexpected relocation symbol type in %s", rsec->name);
- return -1;
- }
-
- insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
- if (!insn) {
- WARN("bad .discard.instr_end entry");
- return -1;
- }
- insn->unret = 1;
- }
-
+ insn->unret = 1;
return 0;
-}
+}
static int read_intra_function_calls(struct objtool_file *file)
{
@@ -2705,7 +2687,7 @@ static int decode_sections(struct objtoo
if (ret)
return ret;
- ret = read_validate_unret_hints(file);
+ ret = read_annotate(file, __annotate_unret);
if (ret)
return ret;
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 06/16] objtool: Convert ANNOTATE_IGNORE_ALTERNATIVE to ANNOTATE
2024-11-28 9:38 [PATCH v2 00/16] objtool: Rewrite annotations Peter Zijlstra
` (4 preceding siblings ...)
2024-11-28 9:38 ` [PATCH v2 05/16] objtool: Convert VALIDATE_UNRET_BEGIN " Peter Zijlstra
@ 2024-11-28 9:38 ` Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 07/16] objtool: Convert ANNOTATE_INTRA_FUNCTION_CALL " Peter Zijlstra
` (10 subsequent siblings)
16 siblings, 1 reply; 36+ messages in thread
From: Peter Zijlstra @ 2024-11-28 9:38 UTC (permalink / raw)
To: jpoimboe; +Cc: chenhuacai, kernel, x86, peterz, loongarch, linux-kernel
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/x86/include/asm/alternative.h | 14 ++---------
include/linux/objtool_types.h | 1
tools/include/linux/objtool_types.h | 1
tools/objtool/check.c | 45 ++++++++----------------------------
4 files changed, 15 insertions(+), 46 deletions(-)
--- a/arch/x86/include/asm/alternative.h
+++ b/arch/x86/include/asm/alternative.h
@@ -4,6 +4,7 @@
#include <linux/types.h>
#include <linux/stringify.h>
+#include <linux/objtool.h>
#include <asm/asm.h>
#define ALT_FLAGS_SHIFT 16
@@ -58,11 +59,7 @@
* objtool annotation to ignore the alternatives and only consider the original
* instruction(s).
*/
-#define ANNOTATE_IGNORE_ALTERNATIVE \
- "999:\n\t" \
- ".pushsection .discard.ignore_alts\n\t" \
- ".long 999b\n\t" \
- ".popsection\n\t"
+#define ANNOTATE_IGNORE_ALTERNATIVE ASM_ANNOTATE(ANNOTYPE_IGNORE_ALTS)
/*
* The patching flags are part of the upper bits of the @ft_flags parameter when
@@ -314,12 +311,7 @@ void nop_func(void);
* objtool annotation to ignore the alternatives and only consider the original
* instruction(s).
*/
-.macro ANNOTATE_IGNORE_ALTERNATIVE
- .Lannotate_\@:
- .pushsection .discard.ignore_alts
- .long .Lannotate_\@
- .popsection
-.endm
+#define ANNOTATE_IGNORE_ALTERNATIVE ANNOTATE type=ANNOTYPE_IGNORE_ALTS
/*
* Issue one struct alt_instr descriptor entry (need to put it into
--- a/include/linux/objtool_types.h
+++ b/include/linux/objtool_types.h
@@ -62,5 +62,6 @@ struct unwind_hint {
#define ANNOTYPE_INSTR_BEGIN 3
#define ANNOTYPE_INSTR_END 4
#define ANNOTYPE_UNRET_BEGIN 5
+#define ANNOTYPE_IGNORE_ALTS 6
#endif /* _LINUX_OBJTOOL_TYPES_H */
--- a/tools/include/linux/objtool_types.h
+++ b/tools/include/linux/objtool_types.h
@@ -62,5 +62,6 @@ struct unwind_hint {
#define ANNOTYPE_INSTR_BEGIN 3
#define ANNOTYPE_INSTR_END 4
#define ANNOTYPE_UNRET_BEGIN 5
+#define ANNOTYPE_IGNORE_ALTS 6
#endif /* _LINUX_OBJTOOL_TYPES_H */
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1310,40 +1310,6 @@ static void add_uaccess_safe(struct objt
}
/*
- * FIXME: For now, just ignore any alternatives which add retpolines. This is
- * a temporary hack, as it doesn't allow ORC to unwind from inside a retpoline.
- * But it at least allows objtool to understand the control flow *around* the
- * retpoline.
- */
-static int add_ignore_alternatives(struct objtool_file *file)
-{
- struct section *rsec;
- struct reloc *reloc;
- struct instruction *insn;
-
- rsec = find_section_by_name(file->elf, ".rela.discard.ignore_alts");
- if (!rsec)
- return 0;
-
- for_each_reloc(rsec, reloc) {
- if (reloc->sym->type != STT_SECTION) {
- WARN("unexpected relocation symbol type in %s", rsec->name);
- return -1;
- }
-
- insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
- if (!insn) {
- WARN("bad .discard.ignore_alts entry");
- return -1;
- }
-
- insn->ignore_alts = true;
- }
-
- return 0;
-}
-
-/*
* Symbols that replace INSN_CALL_DYNAMIC, every (tail) call to such a symbol
* will be added to the .retpoline_sites section.
*/
@@ -2414,6 +2380,15 @@ static int read_annotate(struct objtool_
return 0;
}
+static int __annotate_ignore_alts(int type, struct instruction *insn)
+{
+ if (type != ANNOTYPE_IGNORE_ALTS)
+ return 0;
+
+ insn->ignore_alts = true;
+ return 0;
+}
+
static int __annotate_noendbr(int type, struct instruction *insn)
{
if (type != ANNOTYPE_NOENDBR)
@@ -2626,7 +2601,7 @@ static int decode_sections(struct objtoo
add_ignores(file);
add_uaccess_safe(file);
- ret = add_ignore_alternatives(file);
+ ret = read_annotate(file, __annotate_ignore_alts);
if (ret)
return ret;
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 07/16] objtool: Convert ANNOTATE_INTRA_FUNCTION_CALL to ANNOTATE
2024-11-28 9:38 [PATCH v2 00/16] objtool: Rewrite annotations Peter Zijlstra
` (5 preceding siblings ...)
2024-11-28 9:38 ` [PATCH v2 06/16] objtool: Convert ANNOTATE_IGNORE_ALTERNATIVE " Peter Zijlstra
@ 2024-11-28 9:38 ` Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 08/16] objtool: Collapse annotate sequences Peter Zijlstra
` (9 subsequent siblings)
16 siblings, 1 reply; 36+ messages in thread
From: Peter Zijlstra @ 2024-11-28 9:38 UTC (permalink / raw)
To: jpoimboe; +Cc: chenhuacai, kernel, x86, peterz, loongarch, linux-kernel
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
include/linux/objtool.h | 16 ++----
include/linux/objtool_types.h | 1
tools/include/linux/objtool_types.h | 1
tools/objtool/check.c | 96 ++++++++++++++----------------------
4 files changed, 47 insertions(+), 67 deletions(-)
--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -68,16 +68,6 @@
#else /* __ASSEMBLY__ */
/*
- * This macro indicates that the following intra-function call is valid.
- * Any non-annotated intra-function call will cause objtool to issue a warning.
- */
-#define ANNOTATE_INTRA_FUNCTION_CALL \
- 999: \
- .pushsection .discard.intra_function_calls; \
- .long 999b; \
- .popsection;
-
-/*
* In asm, there are two kinds of code: normal C-type callable functions and
* the rest. The normal callable functions can be called by other code, and
* don't do anything unusual with the stack. Such normal callable functions
@@ -154,6 +144,12 @@
#define ANNOTATE_NOENDBR ANNOTATE type=ANNOTYPE_NOENDBR
+/*
+ * This macro indicates that the following intra-function call is valid.
+ * Any non-annotated intra-function call will cause objtool to issue a warning.
+ */
+#define ANNOTATE_INTRA_FUNCTION_CALL ANNOTATE type=ANNOTYPE_INTRA_FUNCTION_CALL
+
#endif /* __ASSEMBLY__ */
#else /* !CONFIG_OBJTOOL */
--- a/include/linux/objtool_types.h
+++ b/include/linux/objtool_types.h
@@ -63,5 +63,6 @@ struct unwind_hint {
#define ANNOTYPE_INSTR_END 4
#define ANNOTYPE_UNRET_BEGIN 5
#define ANNOTYPE_IGNORE_ALTS 6
+#define ANNOTYPE_INTRA_FUNCTION_CALL 7
#endif /* _LINUX_OBJTOOL_TYPES_H */
--- a/tools/include/linux/objtool_types.h
+++ b/tools/include/linux/objtool_types.h
@@ -63,5 +63,6 @@ struct unwind_hint {
#define ANNOTYPE_INSTR_END 4
#define ANNOTYPE_UNRET_BEGIN 5
#define ANNOTYPE_IGNORE_ALTS 6
+#define ANNOTYPE_INTRA_FUNCTION_CALL 7
#endif /* _LINUX_OBJTOOL_TYPES_H */
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2339,7 +2339,8 @@ static int read_unwind_hints(struct objt
return 0;
}
-static int read_annotate(struct objtool_file *file, int (*func)(int type, struct instruction *insn))
+static int read_annotate(struct objtool_file *file,
+ int (*func)(struct objtool_file *file, int type, struct instruction *insn))
{
struct section *sec;
struct instruction *insn;
@@ -2372,7 +2373,7 @@ static int read_annotate(struct objtool_
return -1;
}
- ret = func(type, insn);
+ ret = func(file, type, insn);
if (ret < 0)
return ret;
}
@@ -2380,7 +2381,7 @@ static int read_annotate(struct objtool_
return 0;
}
-static int __annotate_ignore_alts(int type, struct instruction *insn)
+static int __annotate_ignore_alts(struct objtool_file *file, int type, struct instruction *insn)
{
if (type != ANNOTYPE_IGNORE_ALTS)
return 0;
@@ -2389,7 +2390,7 @@ static int __annotate_ignore_alts(int ty
return 0;
}
-static int __annotate_noendbr(int type, struct instruction *insn)
+static int __annotate_noendbr(struct objtool_file *file, int type, struct instruction *insn)
{
if (type != ANNOTYPE_NOENDBR)
return 0;
@@ -2398,7 +2399,37 @@ static int __annotate_noendbr(int type,
return 0;
}
-static int __annotate_retpoline_safe(int type, struct instruction *insn)
+static int __annotate_ifc(struct objtool_file *file, int type, struct instruction *insn)
+{
+ unsigned long dest_off;
+
+ if (type != ANNOTYPE_INTRA_FUNCTION_CALL)
+ return 0;
+
+ if (insn->type != INSN_CALL) {
+ WARN_INSN(insn, "intra_function_call not a direct call");
+ return -1;
+ }
+
+ /*
+ * Treat intra-function CALLs as JMPs, but with a stack_op.
+ * See add_call_destinations(), which strips stack_ops from
+ * normal CALLs.
+ */
+ insn->type = INSN_JUMP_UNCONDITIONAL;
+
+ dest_off = arch_jump_destination(insn);
+ insn->jump_dest = find_insn(file, insn->sec, dest_off);
+ if (!insn->jump_dest) {
+ WARN_INSN(insn, "can't find call dest at %s+0x%lx",
+ insn->sec->name, dest_off);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int __annotate_retpoline_safe(struct objtool_file *file, int type, struct instruction *insn)
{
if (type != ANNOTYPE_RETPOLINE_SAFE)
return 0;
@@ -2415,7 +2446,7 @@ static int __annotate_retpoline_safe(int
return 0;
}
-static int __annotate_instr(int type, struct instruction *insn)
+static int __annotate_instr(struct objtool_file *file, int type, struct instruction *insn)
{
switch (type) {
case ANNOTYPE_INSTR_BEGIN:
@@ -2433,7 +2464,7 @@ static int __annotate_instr(int type, st
return 0;
}
-static int __annotate_unret(int type, struct instruction *insn)
+static int __annotate_unret(struct objtool_file *file, int type, struct instruction *insn)
{
if (type != ANNOTYPE_UNRET_BEGIN)
return 0;
@@ -2443,55 +2474,6 @@ static int __annotate_unret(int type, st
}
-static int read_intra_function_calls(struct objtool_file *file)
-{
- struct instruction *insn;
- struct section *rsec;
- struct reloc *reloc;
-
- rsec = find_section_by_name(file->elf, ".rela.discard.intra_function_calls");
- if (!rsec)
- return 0;
-
- for_each_reloc(rsec, reloc) {
- unsigned long dest_off;
-
- if (reloc->sym->type != STT_SECTION) {
- WARN("unexpected relocation symbol type in %s",
- rsec->name);
- return -1;
- }
-
- insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
- if (!insn) {
- WARN("bad .discard.intra_function_call entry");
- return -1;
- }
-
- if (insn->type != INSN_CALL) {
- WARN_INSN(insn, "intra_function_call not a direct call");
- return -1;
- }
-
- /*
- * Treat intra-function CALLs as JMPs, but with a stack_op.
- * See add_call_destinations(), which strips stack_ops from
- * normal CALLs.
- */
- insn->type = INSN_JUMP_UNCONDITIONAL;
-
- dest_off = arch_jump_destination(insn);
- insn->jump_dest = find_insn(file, insn->sec, dest_off);
- if (!insn->jump_dest) {
- WARN_INSN(insn, "can't find call dest at %s+0x%lx",
- insn->sec->name, dest_off);
- return -1;
- }
- }
-
- return 0;
-}
-
/*
* Return true if name matches an instrumentation function, where calls to that
* function from noinstr code can safely be removed, but compilers won't do so.
@@ -2630,7 +2612,7 @@ static int decode_sections(struct objtoo
* Must be before add_call_destination(); it changes INSN_CALL to
* INSN_JUMP.
*/
- ret = read_intra_function_calls(file);
+ ret = read_annotate(file, __annotate_ifc);
if (ret)
return ret;
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 08/16] objtool: Collapse annotate sequences
2024-11-28 9:38 [PATCH v2 00/16] objtool: Rewrite annotations Peter Zijlstra
` (6 preceding siblings ...)
2024-11-28 9:38 ` [PATCH v2 07/16] objtool: Convert ANNOTATE_INTRA_FUNCTION_CALL " Peter Zijlstra
@ 2024-11-28 9:38 ` Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 09/16] objtool: Collect more annotations in objtool.h Peter Zijlstra
` (8 subsequent siblings)
16 siblings, 1 reply; 36+ messages in thread
From: Peter Zijlstra @ 2024-11-28 9:38 UTC (permalink / raw)
To: jpoimboe; +Cc: chenhuacai, kernel, x86, peterz, loongarch, linux-kernel
Reduce read_annotate() runs by collapsing subsequent runs into a
single call.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
tools/objtool/check.c | 87 ++++++++++++++++++--------------------------------
1 file changed, 32 insertions(+), 55 deletions(-)
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2381,21 +2381,24 @@ static int read_annotate(struct objtool_
return 0;
}
-static int __annotate_ignore_alts(struct objtool_file *file, int type, struct instruction *insn)
+static int __annotate_early(struct objtool_file *file, int type, struct instruction *insn)
{
- if (type != ANNOTYPE_IGNORE_ALTS)
- return 0;
+ switch (type) {
+ case ANNOTYPE_IGNORE_ALTS:
+ insn->ignore_alts = true;
+ break;
- insn->ignore_alts = true;
- return 0;
-}
+ /*
+ * Must be before read_unwind_hints() since that needs insn->noendbr.
+ */
+ case ANNOTYPE_NOENDBR:
+ insn->noendbr = 1;
+ break;
-static int __annotate_noendbr(struct objtool_file *file, int type, struct instruction *insn)
-{
- if (type != ANNOTYPE_NOENDBR)
- return 0;
+ default:
+ break;
+ }
- insn->noendbr = 1;
return 0;
}
@@ -2429,26 +2432,21 @@ static int __annotate_ifc(struct objtool
return 0;
}
-static int __annotate_retpoline_safe(struct objtool_file *file, int type, struct instruction *insn)
+static int __annotate_late(struct objtool_file *file, int type, struct instruction *insn)
{
- if (type != ANNOTYPE_RETPOLINE_SAFE)
- return 0;
-
- if (insn->type != INSN_JUMP_DYNAMIC &&
- insn->type != INSN_CALL_DYNAMIC &&
- insn->type != INSN_RETURN &&
- insn->type != INSN_NOP) {
- WARN_INSN(insn, "retpoline_safe hint not an indirect jump/call/ret/nop");
- return -1;
- }
+ switch (type) {
+ case ANNOTYPE_RETPOLINE_SAFE:
+ if (insn->type != INSN_JUMP_DYNAMIC &&
+ insn->type != INSN_CALL_DYNAMIC &&
+ insn->type != INSN_RETURN &&
+ insn->type != INSN_NOP) {
+ WARN_INSN(insn, "retpoline_safe hint not an indirect jump/call/ret/nop");
+ return -1;
+ }
- insn->retpoline_safe = true;
- return 0;
-}
+ insn->retpoline_safe = true;
+ break;
-static int __annotate_instr(struct objtool_file *file, int type, struct instruction *insn)
-{
- switch (type) {
case ANNOTYPE_INSTR_BEGIN:
insn->instr++;
break;
@@ -2457,6 +2455,10 @@ static int __annotate_instr(struct objto
insn->instr--;
break;
+ case ANNOTYPE_UNRET_BEGIN:
+ insn->unret = 1;
+ break;
+
default:
break;
}
@@ -2464,16 +2466,6 @@ static int __annotate_instr(struct objto
return 0;
}
-static int __annotate_unret(struct objtool_file *file, int type, struct instruction *insn)
-{
- if (type != ANNOTYPE_UNRET_BEGIN)
- return 0;
-
- insn->unret = 1;
- return 0;
-
-}
-
/*
* Return true if name matches an instrumentation function, where calls to that
* function from noinstr code can safely be removed, but compilers won't do so.
@@ -2583,14 +2575,7 @@ static int decode_sections(struct objtoo
add_ignores(file);
add_uaccess_safe(file);
- ret = read_annotate(file, __annotate_ignore_alts);
- if (ret)
- return ret;
-
- /*
- * Must be before read_unwind_hints() since that needs insn->noendbr.
- */
- ret = read_annotate(file, __annotate_noendbr);
+ ret = read_annotate(file, __annotate_early);
if (ret)
return ret;
@@ -2636,15 +2621,7 @@ static int decode_sections(struct objtoo
if (ret)
return ret;
- ret = read_annotate(file, __annotate_retpoline_safe);
- if (ret)
- return ret;
-
- ret = read_annotate(file, __annotate_instr);
- if (ret)
- return ret;
-
- ret = read_annotate(file, __annotate_unret);
+ ret = read_annotate(file, __annotate_late);
if (ret)
return ret;
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 09/16] objtool: Collect more annotations in objtool.h
2024-11-28 9:38 [PATCH v2 00/16] objtool: Rewrite annotations Peter Zijlstra
` (7 preceding siblings ...)
2024-11-28 9:38 ` [PATCH v2 08/16] objtool: Collapse annotate sequences Peter Zijlstra
@ 2024-11-28 9:39 ` Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 10/16] unreachable: Unify Peter Zijlstra
` (7 subsequent siblings)
16 siblings, 1 reply; 36+ messages in thread
From: Peter Zijlstra @ 2024-11-28 9:39 UTC (permalink / raw)
To: jpoimboe
Cc: chenhuacai, kernel, x86, peterz, loongarch, linux-kernel,
Josh Poimboeuf
Suggested-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/x86/include/asm/alternative.h | 12 -----
arch/x86/include/asm/nospec-branch.h | 9 ---
include/linux/instrumentation.h | 4 -
include/linux/objtool.h | 80 +++++++++++++++++++++++------------
4 files changed, 55 insertions(+), 50 deletions(-)
--- a/arch/x86/include/asm/alternative.h
+++ b/arch/x86/include/asm/alternative.h
@@ -56,12 +56,6 @@
#endif
/*
- * objtool annotation to ignore the alternatives and only consider the original
- * instruction(s).
- */
-#define ANNOTATE_IGNORE_ALTERNATIVE ASM_ANNOTATE(ANNOTYPE_IGNORE_ALTS)
-
-/*
* The patching flags are part of the upper bits of the @ft_flags parameter when
* specifying them. The split is currently like this:
*
@@ -308,12 +302,6 @@ void nop_func(void);
#endif
/*
- * objtool annotation to ignore the alternatives and only consider the original
- * instruction(s).
- */
-#define ANNOTATE_IGNORE_ALTERNATIVE ANNOTATE type=ANNOTYPE_IGNORE_ALTS
-
-/*
* Issue one struct alt_instr descriptor entry (need to put it into
* the section .altinstructions, see below). This entry contains
* enough information for the alternatives patching code to patch an
--- a/arch/x86/include/asm/nospec-branch.h
+++ b/arch/x86/include/asm/nospec-branch.h
@@ -180,13 +180,6 @@
#ifdef __ASSEMBLY__
/*
- * This should be used immediately before an indirect jump/call. It tells
- * objtool the subsequent indirect jump/call is vouched safe for retpoline
- * builds.
- */
-#define ANNOTATE_RETPOLINE_SAFE ANNOTATE type=ANNOTYPE_RETPOLINE_SAFE
-
-/*
* (ab)use RETPOLINE_SAFE on RET to annotate away 'bare' RET instructions
* vs RETBleed validation.
*/
@@ -345,8 +338,6 @@
#else /* __ASSEMBLY__ */
-#define ANNOTATE_RETPOLINE_SAFE ASM_ANNOTATE(ANNOTYPE_RETPOLINE_SAFE)
-
typedef u8 retpoline_thunk_t[RETPOLINE_THUNK_SIZE];
extern retpoline_thunk_t __x86_indirect_thunk_array[];
extern retpoline_thunk_t __x86_indirect_call_thunk_array[];
--- a/include/linux/instrumentation.h
+++ b/include/linux/instrumentation.h
@@ -10,7 +10,7 @@
/* Begin/end of an instrumentation safe region */
#define __instrumentation_begin(c) ({ \
asm volatile(__stringify(c) ": nop\n\t" \
- __ASM_ANNOTATE(__ASM_BREF(c), ANNOTYPE_INSTR_BEGIN)\
+ ANNOTATE_INSTR_BEGIN(__ASM_BREF(c)) \
: : "i" (c)); \
})
#define instrumentation_begin() __instrumentation_begin(__COUNTER__)
@@ -48,7 +48,7 @@
*/
#define __instrumentation_end(c) ({ \
asm volatile(__stringify(c) ": nop\n\t" \
- __ASM_ANNOTATE(__ASM_BREF(c), ANNOTYPE_INSTR_END) \
+ ANNOTATE_INSTR_END(__ASM_BREF(c)) \
: : "i" (c)); \
})
#define instrumentation_end() __instrumentation_end(__COUNTER__)
--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -63,8 +63,6 @@
"911:\n\t" \
__ASM_ANNOTATE(911b, type)
-#define ANNOTATE_NOENDBR ASM_ANNOTATE(ANNOTYPE_NOENDBR)
-
#else /* __ASSEMBLY__ */
/*
@@ -113,19 +111,6 @@
#endif
.endm
-/*
- * Use objtool to validate the entry requirement that all code paths do
- * VALIDATE_UNRET_END before RET.
- *
- * NOTE: The macro must be used at the beginning of a global symbol, otherwise
- * it will be ignored.
- */
-#if defined(CONFIG_NOINSTR_VALIDATION) && \
- (defined(CONFIG_MITIGATION_UNRET_ENTRY) || defined(CONFIG_MITIGATION_SRSO))
-#define VALIDATE_UNRET_BEGIN ANNOTATE type=ANNOTYPE_UNRET_BEGIN
-#else
-#define VALIDATE_UNRET_BEGIN
-#endif
.macro REACHABLE
.Lhere_\@:
@@ -142,14 +127,6 @@
.popsection
.endm
-#define ANNOTATE_NOENDBR ANNOTATE type=ANNOTYPE_NOENDBR
-
-/*
- * This macro indicates that the following intra-function call is valid.
- * Any non-annotated intra-function call will cause objtool to issue a warning.
- */
-#define ANNOTATE_INTRA_FUNCTION_CALL ANNOTATE type=ANNOTYPE_INTRA_FUNCTION_CALL
-
#endif /* __ASSEMBLY__ */
#else /* !CONFIG_OBJTOOL */
@@ -161,16 +138,12 @@
#define STACK_FRAME_NON_STANDARD_FP(func)
#define __ASM_ANNOTATE(label, type)
#define ASM_ANNOTATE(type)
-#define ANNOTATE_NOENDBR
#define ASM_REACHABLE
#else
-#define ANNOTATE_INTRA_FUNCTION_CALL
.macro UNWIND_HINT type:req sp_reg=0 sp_offset=0 signal=0
.endm
.macro STACK_FRAME_NON_STANDARD func:req
.endm
-.macro ANNOTATE_NOENDBR
-.endm
.macro REACHABLE
.endm
.macro ANNOTATE type:req
@@ -179,4 +152,57 @@
#endif /* CONFIG_OBJTOOL */
+#ifndef __ASSEMBLY__
+/*
+ * Annotate away the various 'relocation to !ENDBR` complaints; knowing that
+ * these relocations will never be used for indirect calls.
+ */
+#define ANNOTATE_NOENDBR ASM_ANNOTATE(ANNOTYPE_NOENDBR)
+/*
+ * This should be used immediately before an indirect jump/call. It tells
+ * objtool the subsequent indirect jump/call is vouched safe for retpoline
+ * builds.
+ */
+#define ANNOTATE_RETPOLINE_SAFE ASM_ANNOTATE(ANNOTYPE_RETPOLINE_SAFE)
+/*
+ * See linux/instrumentation.h
+ */
+#define ANNOTATE_INSTR_BEGIN(label) __ASM_ANNOTATE(label, ANNOTYPE_INSTR_BEGIN)
+#define ANNOTATE_INSTR_END(label) __ASM_ANNOTATE(label, ANNOTYPE_INSTR_END)
+/*
+ * objtool annotation to ignore the alternatives and only consider the original
+ * instruction(s).
+ */
+#define ANNOTATE_IGNORE_ALTERNATIVE ASM_ANNOTATE(ANNOTYPE_IGNORE_ALTS)
+/*
+ * This macro indicates that the following intra-function call is valid.
+ * Any non-annotated intra-function call will cause objtool to issue a warning.
+ */
+#define ANNOTATE_INTRA_FUNCTION_CALL ASM_ANNOTATE(ANNOTYPE_INTRA_FUNCTION_CALL)
+/*
+ * Use objtool to validate the entry requirement that all code paths do
+ * VALIDATE_UNRET_END before RET.
+ *
+ * NOTE: The macro must be used at the beginning of a global symbol, otherwise
+ * it will be ignored.
+ */
+#define ANNOTATE_UNRET_BEGIN ASM_ANNOTATE(ANNOTYPE_UNRET_BEGIN)
+
+#else
+#define ANNOTATE_NOENDBR ANNOTATE type=ANNOTYPE_NOENDBR
+#define ANNOTATE_RETPOLINE_SAFE ANNOTATE type=ANNOTYPE_RETPOLINE_SAFE
+/* ANNOTATE_INSTR_BEGIN ANNOTATE type=ANNOTYPE_INSTR_BEGIN */
+/* ANNOTATE_INSTR_END ANNOTATE type=ANNOTYPE_INSTR_END */
+#define ANNOTATE_IGNORE_ALTERNATIVE ANNOTATE type=ANNOTYPE_IGNORE_ALTS
+#define ANNOTATE_INTRA_FUNCTION_CALL ANNOTATE type=ANNOTYPE_INTRA_FUNCTION_CALL
+#define ANNOTATE_UNRET_BEGIN ANNOTATE type=ANNOTYPE_UNRET_BEGIN
+#endif
+
+#if defined(CONFIG_NOINSTR_VALIDATION) && \
+ (defined(CONFIG_MITIGATION_UNRET_ENTRY) || defined(CONFIG_MITIGATION_SRSO))
+#define VALIDATE_UNRET_BEGIN ANNOTATE_UNRET_BEGIN
+#else
+#define VALIDATE_UNRET_BEGIN
+#endif
+
#endif /* _LINUX_OBJTOOL_H */
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 10/16] unreachable: Unify
2024-11-28 9:38 [PATCH v2 00/16] objtool: Rewrite annotations Peter Zijlstra
` (8 preceding siblings ...)
2024-11-28 9:39 ` [PATCH v2 09/16] objtool: Collect more annotations in objtool.h Peter Zijlstra
@ 2024-11-28 9:39 ` Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 11/16] x86: Convert unreachable() to BUG() Peter Zijlstra
` (6 subsequent siblings)
16 siblings, 1 reply; 36+ messages in thread
From: Peter Zijlstra @ 2024-11-28 9:39 UTC (permalink / raw)
To: jpoimboe; +Cc: chenhuacai, kernel, x86, peterz, loongarch, linux-kernel
Since barrier_before_unreachable() is empty for !GCC it is trivial to
unify the two definitions. Less is more.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
include/linux/compiler-gcc.h | 12 ------------
include/linux/compiler.h | 10 +++++++---
2 files changed, 7 insertions(+), 15 deletions(-)
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -52,18 +52,6 @@
*/
#define barrier_before_unreachable() asm volatile("")
-/*
- * Mark a position in code as unreachable. This can be used to
- * suppress control flow warnings after asm blocks that transfer
- * control elsewhere.
- */
-#define unreachable() \
- do { \
- annotate_unreachable(); \
- barrier_before_unreachable(); \
- __builtin_unreachable(); \
- } while (0)
-
#if defined(CONFIG_ARCH_USE_BUILTIN_BSWAP)
#define __HAVE_BUILTIN_BSWAP32__
#define __HAVE_BUILTIN_BSWAP64__
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -141,12 +141,16 @@ void ftrace_likely_update(struct ftrace_
#define __annotate_jump_table
#endif /* CONFIG_OBJTOOL */
-#ifndef unreachable
-# define unreachable() do { \
+/*
+ * Mark a position in code as unreachable. This can be used to
+ * suppress control flow warnings after asm blocks that transfer
+ * control elsewhere.
+ */
+#define unreachable() do { \
annotate_unreachable(); \
+ barrier_before_unreachable(); \
__builtin_unreachable(); \
} while (0)
-#endif
/*
* KENTRY - kernel entry point
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 11/16] x86: Convert unreachable() to BUG()
2024-11-28 9:38 [PATCH v2 00/16] objtool: Rewrite annotations Peter Zijlstra
` (9 preceding siblings ...)
2024-11-28 9:39 ` [PATCH v2 10/16] unreachable: Unify Peter Zijlstra
@ 2024-11-28 9:39 ` Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 12/16] loongarch: Use ASM_REACHABLE Peter Zijlstra
` (5 subsequent siblings)
16 siblings, 1 reply; 36+ messages in thread
From: Peter Zijlstra @ 2024-11-28 9:39 UTC (permalink / raw)
To: jpoimboe; +Cc: chenhuacai, kernel, x86, peterz, loongarch, linux-kernel
Avoid unreachable() as it can (and will in the absence of UBSAN)
generate fallthrough code. Use BUG() so we get a UD2 trap (with
unreachable annotation).
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/x86/kernel/process.c | 2 +-
arch/x86/kernel/reboot.c | 2 +-
arch/x86/kvm/svm/sev.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -838,7 +838,7 @@ void __noreturn stop_this_cpu(void *dumm
#ifdef CONFIG_SMP
if (smp_ops.stop_this_cpu) {
smp_ops.stop_this_cpu();
- unreachable();
+ BUG();
}
#endif
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -883,7 +883,7 @@ static int crash_nmi_callback(unsigned i
if (smp_ops.stop_this_cpu) {
smp_ops.stop_this_cpu();
- unreachable();
+ BUG();
}
/* Assume hlt works */
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -3820,7 +3820,7 @@ static int snp_begin_psc(struct vcpu_svm
goto next_range;
}
- unreachable();
+ BUG();
}
static int __sev_snp_update_protected_guest_state(struct kvm_vcpu *vcpu)
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 12/16] loongarch: Use ASM_REACHABLE
2024-11-28 9:38 [PATCH v2 00/16] objtool: Rewrite annotations Peter Zijlstra
` (10 preceding siblings ...)
2024-11-28 9:39 ` [PATCH v2 11/16] x86: Convert unreachable() to BUG() Peter Zijlstra
@ 2024-11-28 9:39 ` Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 13/16] objtool: Remove annotate_{,un}reachable() Peter Zijlstra
` (4 subsequent siblings)
16 siblings, 1 reply; 36+ messages in thread
From: Peter Zijlstra @ 2024-11-28 9:39 UTC (permalink / raw)
To: jpoimboe; +Cc: chenhuacai, kernel, x86, peterz, loongarch, linux-kernel
annotate_reachable() is unreliable since the compiler is free to place
random code inbetween two consecutive asm() statements.
This removes the last and only annotate_reachable() user.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/loongarch/include/asm/bug.h | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
--- a/arch/loongarch/include/asm/bug.h
+++ b/arch/loongarch/include/asm/bug.h
@@ -4,6 +4,7 @@
#include <asm/break.h>
#include <linux/stringify.h>
+#include <linux/objtool.h>
#ifndef CONFIG_DEBUG_BUGVERBOSE
#define _BUGVERBOSE_LOCATION(file, line)
@@ -33,25 +34,25 @@
#define ASM_BUG_FLAGS(flags) \
__BUG_ENTRY(flags) \
- break BRK_BUG
+ break BRK_BUG;
#define ASM_BUG() ASM_BUG_FLAGS(0)
-#define __BUG_FLAGS(flags) \
- asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags)));
+#define __BUG_FLAGS(flags, extra) \
+ asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags)) \
+ extra);
#define __WARN_FLAGS(flags) \
do { \
instrumentation_begin(); \
- __BUG_FLAGS(BUGFLAG_WARNING|(flags)); \
- annotate_reachable(); \
+ __BUG_FLAGS(BUGFLAG_WARNING|(flags), ASM_REACHABLE); \
instrumentation_end(); \
} while (0)
#define BUG() \
do { \
instrumentation_begin(); \
- __BUG_FLAGS(0); \
+ __BUG_FLAGS(0, ""); \
unreachable(); \
} while (0)
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 13/16] objtool: Remove annotate_{,un}reachable()
2024-11-28 9:38 [PATCH v2 00/16] objtool: Rewrite annotations Peter Zijlstra
` (11 preceding siblings ...)
2024-11-28 9:39 ` [PATCH v2 12/16] loongarch: Use ASM_REACHABLE Peter Zijlstra
@ 2024-11-28 9:39 ` Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 14/16] objtool: Convert {.UN}REACHABLE to ANNOTATE Peter Zijlstra
` (3 subsequent siblings)
16 siblings, 1 reply; 36+ messages in thread
From: Peter Zijlstra @ 2024-11-28 9:39 UTC (permalink / raw)
To: jpoimboe; +Cc: chenhuacai, kernel, x86, peterz, loongarch, linux-kernel
There are no users of annotate_reachable() left.
And the annotate_unreachable() usage in unreachable() is plain wrong;
it will hide dangerous fall-through code-gen.
Remove both.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
include/linux/compiler.h | 27 ---------------------------
tools/objtool/check.c | 43 ++-----------------------------------------
2 files changed, 2 insertions(+), 68 deletions(-)
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -109,35 +109,9 @@ void ftrace_likely_update(struct ftrace_
/* Unreachable code */
#ifdef CONFIG_OBJTOOL
-/*
- * These macros help objtool understand GCC code flow for unreachable code.
- * The __COUNTER__ based labels are a hack to make each instance of the macros
- * unique, to convince GCC not to merge duplicate inline asm statements.
- */
-#define __stringify_label(n) #n
-
-#define __annotate_reachable(c) ({ \
- asm volatile(__stringify_label(c) ":\n\t" \
- ".pushsection .discard.reachable\n\t" \
- ".long " __stringify_label(c) "b - .\n\t" \
- ".popsection\n\t"); \
-})
-#define annotate_reachable() __annotate_reachable(__COUNTER__)
-
-#define __annotate_unreachable(c) ({ \
- asm volatile(__stringify_label(c) ":\n\t" \
- ".pushsection .discard.unreachable\n\t" \
- ".long " __stringify_label(c) "b - .\n\t" \
- ".popsection\n\t" : : "i" (c)); \
-})
-#define annotate_unreachable() __annotate_unreachable(__COUNTER__)
-
/* Annotate a C jump table to allow objtool to follow the code flow */
#define __annotate_jump_table __section(".rodata..c_jump_table,\"a\",@progbits #")
-
#else /* !CONFIG_OBJTOOL */
-#define annotate_reachable()
-#define annotate_unreachable()
#define __annotate_jump_table
#endif /* CONFIG_OBJTOOL */
@@ -147,7 +121,6 @@ void ftrace_likely_update(struct ftrace_
* control elsewhere.
*/
#define unreachable() do { \
- annotate_unreachable(); \
barrier_before_unreachable(); \
__builtin_unreachable(); \
} while (0)
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -638,47 +638,8 @@ static int add_dead_ends(struct objtool_
uint64_t offset;
/*
- * Check for manually annotated dead ends.
- */
- rsec = find_section_by_name(file->elf, ".rela.discard.unreachable");
- if (!rsec)
- goto reachable;
-
- for_each_reloc(rsec, reloc) {
- if (reloc->sym->type == STT_SECTION) {
- offset = reloc_addend(reloc);
- } else if (reloc->sym->local_label) {
- offset = reloc->sym->offset;
- } else {
- WARN("unexpected relocation symbol type in %s", rsec->name);
- return -1;
- }
-
- insn = find_insn(file, reloc->sym->sec, offset);
- if (insn)
- insn = prev_insn_same_sec(file, insn);
- else if (offset == reloc->sym->sec->sh.sh_size) {
- insn = find_last_insn(file, reloc->sym->sec);
- if (!insn) {
- WARN("can't find unreachable insn at %s+0x%" PRIx64,
- reloc->sym->sec->name, offset);
- return -1;
- }
- } else {
- WARN("can't find unreachable insn at %s+0x%" PRIx64,
- reloc->sym->sec->name, offset);
- return -1;
- }
-
- insn->dead_end = true;
- }
-
-reachable:
- /*
- * These manually annotated reachable checks are needed for GCC 4.4,
- * where the Linux unreachable() macro isn't supported. In that case
- * GCC doesn't know the "ud2" is fatal, so it generates code as if it's
- * not a dead end.
+ * UD2 defaults to being a dead-end, allow them to be annotated for
+ * non-fatal, eg WARN.
*/
rsec = find_section_by_name(file->elf, ".rela.discard.reachable");
if (!rsec)
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 14/16] objtool: Convert {.UN}REACHABLE to ANNOTATE
2024-11-28 9:38 [PATCH v2 00/16] objtool: Rewrite annotations Peter Zijlstra
` (12 preceding siblings ...)
2024-11-28 9:39 ` [PATCH v2 13/16] objtool: Remove annotate_{,un}reachable() Peter Zijlstra
@ 2024-11-28 9:39 ` Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 15/16] objtool: Fix ANNOTATE_REACHABLE to be a normal annotation Peter Zijlstra
` (2 subsequent siblings)
16 siblings, 1 reply; 36+ messages in thread
From: Peter Zijlstra @ 2024-11-28 9:39 UTC (permalink / raw)
To: jpoimboe
Cc: chenhuacai, kernel, x86, peterz, loongarch, linux-kernel,
Josh Poimboeuf
Suggested-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/loongarch/include/asm/bug.h | 2
arch/x86/entry/entry_64.S | 4 -
arch/x86/include/asm/bug.h | 2
arch/x86/include/asm/irq_stack.h | 2
include/linux/objtool.h | 18 +++----
include/linux/objtool_types.h | 1
tools/include/linux/objtool_types.h | 1
tools/objtool/check.c | 82 +++++++++---------------------------
8 files changed, 36 insertions(+), 76 deletions(-)
--- a/arch/loongarch/include/asm/bug.h
+++ b/arch/loongarch/include/asm/bug.h
@@ -45,7 +45,7 @@
#define __WARN_FLAGS(flags) \
do { \
instrumentation_begin(); \
- __BUG_FLAGS(BUGFLAG_WARNING|(flags), ASM_REACHABLE); \
+ __BUG_FLAGS(BUGFLAG_WARNING|(flags), ANNOTATE_REACHABLE);\
instrumentation_end(); \
} while (0)
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -311,7 +311,7 @@ SYM_CODE_END(xen_error_entry)
call \cfunc
/* For some configurations \cfunc ends up being a noreturn. */
- REACHABLE
+ ANNOTATE_REACHABLE
jmp error_return
.endm
@@ -532,7 +532,7 @@ SYM_CODE_START(\asmsym)
call \cfunc
/* For some configurations \cfunc ends up being a noreturn. */
- REACHABLE
+ ANNOTATE_REACHABLE
jmp paranoid_exit
--- a/arch/x86/include/asm/bug.h
+++ b/arch/x86/include/asm/bug.h
@@ -92,7 +92,7 @@ do { \
do { \
__auto_type __flags = BUGFLAG_WARNING|(flags); \
instrumentation_begin(); \
- _BUG_FLAGS(ASM_UD2, __flags, ASM_REACHABLE); \
+ _BUG_FLAGS(ASM_UD2, __flags, ANNOTATE_REACHABLE); \
instrumentation_end(); \
} while (0)
--- a/arch/x86/include/asm/irq_stack.h
+++ b/arch/x86/include/asm/irq_stack.h
@@ -101,7 +101,7 @@
#define ASM_CALL_ARG0 \
"call %c[__func] \n" \
- ASM_REACHABLE
+ ANNOTATE_REACHABLE
#define ASM_CALL_ARG1 \
"movq %[arg1], %%rdi \n" \
--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -111,14 +111,6 @@
#endif
.endm
-
-.macro REACHABLE
-.Lhere_\@:
- .pushsection .discard.reachable
- .long .Lhere_\@
- .popsection
-.endm
-
.macro ANNOTATE type:req
.Lhere_\@:
.pushsection .discard.annotate_insn,"M",@progbits,8
@@ -138,14 +130,11 @@
#define STACK_FRAME_NON_STANDARD_FP(func)
#define __ASM_ANNOTATE(label, type)
#define ASM_ANNOTATE(type)
-#define ASM_REACHABLE
#else
.macro UNWIND_HINT type:req sp_reg=0 sp_offset=0 signal=0
.endm
.macro STACK_FRAME_NON_STANDARD func:req
.endm
-.macro REACHABLE
-.endm
.macro ANNOTATE type:req
.endm
#endif
@@ -187,6 +176,12 @@
* it will be ignored.
*/
#define ANNOTATE_UNRET_BEGIN ASM_ANNOTATE(ANNOTYPE_UNRET_BEGIN)
+/*
+ * This should be used directly after an instruction that is considered
+ * terminating, like a noreturn CALL or UD2 when we know they are not -- eg
+ * WARN using UD2.
+ */
+#define ANNOTATE_REACHABLE ASM_ANNOTATE(ANNOTYPE_REACHABLE)
#else
#define ANNOTATE_NOENDBR ANNOTATE type=ANNOTYPE_NOENDBR
@@ -196,6 +191,7 @@
#define ANNOTATE_IGNORE_ALTERNATIVE ANNOTATE type=ANNOTYPE_IGNORE_ALTS
#define ANNOTATE_INTRA_FUNCTION_CALL ANNOTATE type=ANNOTYPE_INTRA_FUNCTION_CALL
#define ANNOTATE_UNRET_BEGIN ANNOTATE type=ANNOTYPE_UNRET_BEGIN
+#define ANNOTATE_REACHABLE ANNOTATE type=ANNOTYPE_REACHABLE
#endif
#if defined(CONFIG_NOINSTR_VALIDATION) && \
--- a/include/linux/objtool_types.h
+++ b/include/linux/objtool_types.h
@@ -64,5 +64,6 @@ struct unwind_hint {
#define ANNOTYPE_UNRET_BEGIN 5
#define ANNOTYPE_IGNORE_ALTS 6
#define ANNOTYPE_INTRA_FUNCTION_CALL 7
+#define ANNOTYPE_REACHABLE 8
#endif /* _LINUX_OBJTOOL_TYPES_H */
--- a/tools/include/linux/objtool_types.h
+++ b/tools/include/linux/objtool_types.h
@@ -64,5 +64,6 @@ struct unwind_hint {
#define ANNOTYPE_UNRET_BEGIN 5
#define ANNOTYPE_IGNORE_ALTS 6
#define ANNOTYPE_INTRA_FUNCTION_CALL 7
+#define ANNOTYPE_REACHABLE 8
#endif /* _LINUX_OBJTOOL_TYPES_H */
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -627,56 +627,6 @@ static struct instruction *find_last_ins
return insn;
}
-/*
- * Mark "ud2" instructions and manually annotated dead ends.
- */
-static int add_dead_ends(struct objtool_file *file)
-{
- struct section *rsec;
- struct reloc *reloc;
- struct instruction *insn;
- uint64_t offset;
-
- /*
- * UD2 defaults to being a dead-end, allow them to be annotated for
- * non-fatal, eg WARN.
- */
- rsec = find_section_by_name(file->elf, ".rela.discard.reachable");
- if (!rsec)
- return 0;
-
- for_each_reloc(rsec, reloc) {
- if (reloc->sym->type == STT_SECTION) {
- offset = reloc_addend(reloc);
- } else if (reloc->sym->local_label) {
- offset = reloc->sym->offset;
- } else {
- WARN("unexpected relocation symbol type in %s", rsec->name);
- return -1;
- }
-
- insn = find_insn(file, reloc->sym->sec, offset);
- if (insn)
- insn = prev_insn_same_sec(file, insn);
- else if (offset == reloc->sym->sec->sh.sh_size) {
- insn = find_last_insn(file, reloc->sym->sec);
- if (!insn) {
- WARN("can't find reachable insn at %s+0x%" PRIx64,
- reloc->sym->sec->name, offset);
- return -1;
- }
- } else {
- WARN("can't find reachable insn at %s+0x%" PRIx64,
- reloc->sym->sec->name, offset);
- return -1;
- }
-
- insn->dead_end = false;
- }
-
- return 0;
-}
-
static int create_static_call_sections(struct objtool_file *file)
{
struct static_call_site *site;
@@ -2306,6 +2256,7 @@ static int read_annotate(struct objtool_
struct section *sec;
struct instruction *insn;
struct reloc *reloc;
+ uint64_t offset;
int type, ret;
sec = find_section_by_name(file->elf, ".discard.annotate_insn");
@@ -2327,8 +2278,19 @@ static int read_annotate(struct objtool_
for_each_reloc(sec->rsec, reloc) {
type = *(u32 *)(sec->data->d_buf + (reloc_idx(reloc) * sec->sh.sh_entsize) + 4);
- insn = find_insn(file, reloc->sym->sec,
- reloc->sym->offset + reloc_addend(reloc));
+ offset = reloc->sym->offset + reloc_addend(reloc);
+ insn = find_insn(file, reloc->sym->sec, offset);
+
+ /*
+ * Reachable annotations are 'funneh' and act on the previous instruction :/
+ */
+ if (type == ANNOTYPE_REACHABLE) {
+ if (insn)
+ insn = prev_insn_same_sec(file, insn);
+ else if (offset == reloc->sym->sec->sh.sh_size)
+ insn = find_last_insn(file, reloc->sym->sec);
+ }
+
if (!insn) {
WARN("bad .discard.annotate_insn entry: %d of type %d", reloc_idx(reloc), type);
return -1;
@@ -2420,6 +2382,10 @@ static int __annotate_late(struct objtoo
insn->unret = 1;
break;
+ case ANNOTYPE_REACHABLE:
+ insn->dead_end = false;
+ break;
+
default:
break;
}
@@ -2566,14 +2532,6 @@ static int decode_sections(struct objtoo
if (ret)
return ret;
- /*
- * Must be after add_call_destinations() such that it can override
- * dead_end_function() marks.
- */
- ret = add_dead_ends(file);
- if (ret)
- return ret;
-
ret = add_jump_table_alts(file);
if (ret)
return ret;
@@ -2582,6 +2540,10 @@ static int decode_sections(struct objtoo
if (ret)
return ret;
+ /*
+ * Must be after add_call_destinations() such that it can override
+ * dead_end_function() marks.
+ */
ret = read_annotate(file, __annotate_late);
if (ret)
return ret;
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 15/16] objtool: Fix ANNOTATE_REACHABLE to be a normal annotation
2024-11-28 9:38 [PATCH v2 00/16] objtool: Rewrite annotations Peter Zijlstra
` (13 preceding siblings ...)
2024-11-28 9:39 ` [PATCH v2 14/16] objtool: Convert {.UN}REACHABLE to ANNOTATE Peter Zijlstra
@ 2024-11-28 9:39 ` Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 16/16] objtool: Warn about unknown annotation types Peter Zijlstra
2024-11-28 18:44 ` [PATCH v2 00/16] objtool: Rewrite annotations Josh Poimboeuf
16 siblings, 1 reply; 36+ messages in thread
From: Peter Zijlstra @ 2024-11-28 9:39 UTC (permalink / raw)
To: jpoimboe; +Cc: chenhuacai, kernel, x86, peterz, loongarch, linux-kernel
Currently REACHABLE is weird for being on the instruction after the
instruction it modifies.
Since all REACHABLE annotations have an explicit instruction, flip
them around.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/loongarch/include/asm/bug.h | 2 +-
arch/x86/entry/entry_64.S | 5 ++---
arch/x86/include/asm/bug.h | 2 +-
arch/x86/include/asm/irq_stack.h | 4 ++--
include/linux/objtool.h | 4 ++--
tools/objtool/check.c | 23 -----------------------
6 files changed, 8 insertions(+), 32 deletions(-)
--- a/arch/loongarch/include/asm/bug.h
+++ b/arch/loongarch/include/asm/bug.h
@@ -45,7 +45,7 @@
#define __WARN_FLAGS(flags) \
do { \
instrumentation_begin(); \
- __BUG_FLAGS(BUGFLAG_WARNING|(flags), ANNOTATE_REACHABLE);\
+ __BUG_FLAGS(BUGFLAG_WARNING|(flags), ANNOTATE_REACHABLE(10001b));\
instrumentation_end(); \
} while (0)
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -308,10 +308,9 @@ SYM_CODE_END(xen_error_entry)
movq $-1, ORIG_RAX(%rsp) /* no syscall to restart */
.endif
- call \cfunc
-
/* For some configurations \cfunc ends up being a noreturn. */
ANNOTATE_REACHABLE
+ call \cfunc
jmp error_return
.endm
@@ -529,10 +528,10 @@ SYM_CODE_START(\asmsym)
movq %rsp, %rdi /* pt_regs pointer into first argument */
movq ORIG_RAX(%rsp), %rsi /* get error code into 2nd argument*/
movq $-1, ORIG_RAX(%rsp) /* no syscall to restart */
- call \cfunc
/* For some configurations \cfunc ends up being a noreturn. */
ANNOTATE_REACHABLE
+ call \cfunc
jmp paranoid_exit
--- a/arch/x86/include/asm/bug.h
+++ b/arch/x86/include/asm/bug.h
@@ -92,7 +92,7 @@ do { \
do { \
__auto_type __flags = BUGFLAG_WARNING|(flags); \
instrumentation_begin(); \
- _BUG_FLAGS(ASM_UD2, __flags, ANNOTATE_REACHABLE); \
+ _BUG_FLAGS(ASM_UD2, __flags, ANNOTATE_REACHABLE(1b)); \
instrumentation_end(); \
} while (0)
--- a/arch/x86/include/asm/irq_stack.h
+++ b/arch/x86/include/asm/irq_stack.h
@@ -100,8 +100,8 @@
}
#define ASM_CALL_ARG0 \
- "call %c[__func] \n" \
- ANNOTATE_REACHABLE
+ "1: call %c[__func] \n" \
+ ANNOTATE_REACHABLE(1b)
#define ASM_CALL_ARG1 \
"movq %[arg1], %%rdi \n" \
--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -177,11 +177,11 @@
*/
#define ANNOTATE_UNRET_BEGIN ASM_ANNOTATE(ANNOTYPE_UNRET_BEGIN)
/*
- * This should be used directly after an instruction that is considered
+ * This should be used to refer to an instruction that is considered
* terminating, like a noreturn CALL or UD2 when we know they are not -- eg
* WARN using UD2.
*/
-#define ANNOTATE_REACHABLE ASM_ANNOTATE(ANNOTYPE_REACHABLE)
+#define ANNOTATE_REACHABLE(label) __ASM_ANNOTATE(label, ANNOTYPE_REACHABLE)
#else
#define ANNOTATE_NOENDBR ANNOTATE type=ANNOTYPE_NOENDBR
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -614,19 +614,6 @@ static int init_pv_ops(struct objtool_fi
return 0;
}
-static struct instruction *find_last_insn(struct objtool_file *file,
- struct section *sec)
-{
- struct instruction *insn = NULL;
- unsigned int offset;
- unsigned int end = (sec->sh.sh_size > 10) ? sec->sh.sh_size - 10 : 0;
-
- for (offset = sec->sh.sh_size - 1; offset >= end && !insn; offset--)
- insn = find_insn(file, sec, offset);
-
- return insn;
-}
-
static int create_static_call_sections(struct objtool_file *file)
{
struct static_call_site *site;
@@ -2281,16 +2268,6 @@ static int read_annotate(struct objtool_
offset = reloc->sym->offset + reloc_addend(reloc);
insn = find_insn(file, reloc->sym->sec, offset);
- /*
- * Reachable annotations are 'funneh' and act on the previous instruction :/
- */
- if (type == ANNOTYPE_REACHABLE) {
- if (insn)
- insn = prev_insn_same_sec(file, insn);
- else if (offset == reloc->sym->sec->sh.sh_size)
- insn = find_last_insn(file, reloc->sym->sec);
- }
-
if (!insn) {
WARN("bad .discard.annotate_insn entry: %d of type %d", reloc_idx(reloc), type);
return -1;
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 16/16] objtool: Warn about unknown annotation types
2024-11-28 9:38 [PATCH v2 00/16] objtool: Rewrite annotations Peter Zijlstra
` (14 preceding siblings ...)
2024-11-28 9:39 ` [PATCH v2 15/16] objtool: Fix ANNOTATE_REACHABLE to be a normal annotation Peter Zijlstra
@ 2024-11-28 9:39 ` Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 18:44 ` [PATCH v2 00/16] objtool: Rewrite annotations Josh Poimboeuf
16 siblings, 1 reply; 36+ messages in thread
From: Peter Zijlstra @ 2024-11-28 9:39 UTC (permalink / raw)
To: jpoimboe; +Cc: chenhuacai, kernel, x86, peterz, loongarch, linux-kernel
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
tools/objtool/check.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2335,6 +2335,10 @@ static int __annotate_ifc(struct objtool
static int __annotate_late(struct objtool_file *file, int type, struct instruction *insn)
{
switch (type) {
+ case ANNOTYPE_NOENDBR:
+ /* early */
+ break;
+
case ANNOTYPE_RETPOLINE_SAFE:
if (insn->type != INSN_JUMP_DYNAMIC &&
insn->type != INSN_CALL_DYNAMIC &&
@@ -2359,11 +2363,20 @@ static int __annotate_late(struct objtoo
insn->unret = 1;
break;
+ case ANNOTYPE_IGNORE_ALTS:
+ /* early */
+ break;
+
+ case ANNOTYPE_INTRA_FUNCTION_CALL:
+ /* ifc */
+ break;
+
case ANNOTYPE_REACHABLE:
insn->dead_end = false;
break;
default:
+ WARN_INSN(insn, "Unknown annotation type: %d", type);
break;
}
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 00/16] objtool: Rewrite annotations
2024-11-28 9:38 [PATCH v2 00/16] objtool: Rewrite annotations Peter Zijlstra
` (15 preceding siblings ...)
2024-11-28 9:39 ` [PATCH v2 16/16] objtool: Warn about unknown annotation types Peter Zijlstra
@ 2024-11-28 18:44 ` Josh Poimboeuf
16 siblings, 0 replies; 36+ messages in thread
From: Josh Poimboeuf @ 2024-11-28 18:44 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: chenhuacai, kernel, x86, loongarch, linux-kernel
On Thu, Nov 28, 2024 at 10:38:51AM +0100, Peter Zijlstra wrote:
> Rewrite/unify the objtool instruction based annotations.
>
> Changes since last time:
>
> - removed unreachable annotation
> - included reachable annotation
> - various smaller things
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
--
Josh
^ permalink raw reply [flat|nested] 36+ messages in thread
* [tip: objtool/core] objtool: Warn about unknown annotation types
2024-11-28 9:39 ` [PATCH v2 16/16] objtool: Warn about unknown annotation types Peter Zijlstra
@ 2024-12-02 11:15 ` tip-bot2 for Peter Zijlstra
0 siblings, 0 replies; 36+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2024-12-02 11:15 UTC (permalink / raw)
To: linux-tip-commits
Cc: Peter Zijlstra (Intel), Josh Poimboeuf, x86, linux-kernel
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: e7e0eb53c2f0f68fe2577472ce2802a4efd9d7ce
Gitweb: https://git.kernel.org/tip/e7e0eb53c2f0f68fe2577472ce2802a4efd9d7ce
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Thu, 28 Nov 2024 10:39:07 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 02 Dec 2024 12:01:45 +01:00
objtool: Warn about unknown annotation types
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/20241128094312.611961175@infradead.org
---
tools/objtool/check.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 26bdd3e..bfb407f 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2335,6 +2335,10 @@ static int __annotate_ifc(struct objtool_file *file, int type, struct instructio
static int __annotate_late(struct objtool_file *file, int type, struct instruction *insn)
{
switch (type) {
+ case ANNOTYPE_NOENDBR:
+ /* early */
+ break;
+
case ANNOTYPE_RETPOLINE_SAFE:
if (insn->type != INSN_JUMP_DYNAMIC &&
insn->type != INSN_CALL_DYNAMIC &&
@@ -2359,11 +2363,20 @@ static int __annotate_late(struct objtool_file *file, int type, struct instructi
insn->unret = 1;
break;
+ case ANNOTYPE_IGNORE_ALTS:
+ /* early */
+ break;
+
+ case ANNOTYPE_INTRA_FUNCTION_CALL:
+ /* ifc */
+ break;
+
case ANNOTYPE_REACHABLE:
insn->dead_end = false;
break;
default:
+ WARN_INSN(insn, "Unknown annotation type: %d", type);
break;
}
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [tip: objtool/core] objtool: Fix ANNOTATE_REACHABLE to be a normal annotation
2024-11-28 9:39 ` [PATCH v2 15/16] objtool: Fix ANNOTATE_REACHABLE to be a normal annotation Peter Zijlstra
@ 2024-12-02 11:15 ` tip-bot2 for Peter Zijlstra
0 siblings, 0 replies; 36+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2024-12-02 11:15 UTC (permalink / raw)
To: linux-tip-commits
Cc: Peter Zijlstra (Intel), Josh Poimboeuf, x86, linux-kernel
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 87116ae6da034242baf06e799f9f0e2a8ee6a796
Gitweb: https://git.kernel.org/tip/87116ae6da034242baf06e799f9f0e2a8ee6a796
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Thu, 28 Nov 2024 10:39:06 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 02 Dec 2024 12:01:44 +01:00
objtool: Fix ANNOTATE_REACHABLE to be a normal annotation
Currently REACHABLE is weird for being on the instruction after the
instruction it modifies.
Since all REACHABLE annotations have an explicit instruction, flip
them around.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/20241128094312.494176035@infradead.org
---
arch/loongarch/include/asm/bug.h | 2 +-
arch/x86/entry/entry_64.S | 5 ++---
arch/x86/include/asm/bug.h | 2 +-
arch/x86/include/asm/irq_stack.h | 4 ++--
include/linux/objtool.h | 4 ++--
tools/objtool/check.c | 23 -----------------------
6 files changed, 8 insertions(+), 32 deletions(-)
diff --git a/arch/loongarch/include/asm/bug.h b/arch/loongarch/include/asm/bug.h
index e25404a..f6f254f 100644
--- a/arch/loongarch/include/asm/bug.h
+++ b/arch/loongarch/include/asm/bug.h
@@ -45,7 +45,7 @@
#define __WARN_FLAGS(flags) \
do { \
instrumentation_begin(); \
- __BUG_FLAGS(BUGFLAG_WARNING|(flags), ANNOTATE_REACHABLE);\
+ __BUG_FLAGS(BUGFLAG_WARNING|(flags), ANNOTATE_REACHABLE(10001b));\
instrumentation_end(); \
} while (0)
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 9248660..f52dbe0 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -308,10 +308,9 @@ SYM_CODE_END(xen_error_entry)
movq $-1, ORIG_RAX(%rsp) /* no syscall to restart */
.endif
- call \cfunc
-
/* For some configurations \cfunc ends up being a noreturn. */
ANNOTATE_REACHABLE
+ call \cfunc
jmp error_return
.endm
@@ -529,10 +528,10 @@ SYM_CODE_START(\asmsym)
movq %rsp, %rdi /* pt_regs pointer into first argument */
movq ORIG_RAX(%rsp), %rsi /* get error code into 2nd argument*/
movq $-1, ORIG_RAX(%rsp) /* no syscall to restart */
- call \cfunc
/* For some configurations \cfunc ends up being a noreturn. */
ANNOTATE_REACHABLE
+ call \cfunc
jmp paranoid_exit
diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h
index dd8fb17..e85ac0c 100644
--- a/arch/x86/include/asm/bug.h
+++ b/arch/x86/include/asm/bug.h
@@ -92,7 +92,7 @@ do { \
do { \
__auto_type __flags = BUGFLAG_WARNING|(flags); \
instrumentation_begin(); \
- _BUG_FLAGS(ASM_UD2, __flags, ANNOTATE_REACHABLE); \
+ _BUG_FLAGS(ASM_UD2, __flags, ANNOTATE_REACHABLE(1b)); \
instrumentation_end(); \
} while (0)
diff --git a/arch/x86/include/asm/irq_stack.h b/arch/x86/include/asm/irq_stack.h
index 5455747..562a547 100644
--- a/arch/x86/include/asm/irq_stack.h
+++ b/arch/x86/include/asm/irq_stack.h
@@ -100,8 +100,8 @@
}
#define ASM_CALL_ARG0 \
- "call %c[__func] \n" \
- ANNOTATE_REACHABLE
+ "1: call %c[__func] \n" \
+ ANNOTATE_REACHABLE(1b)
#define ASM_CALL_ARG1 \
"movq %[arg1], %%rdi \n" \
diff --git a/include/linux/objtool.h b/include/linux/objtool.h
index e3cb135..c722a92 100644
--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -177,11 +177,11 @@
*/
#define ANNOTATE_UNRET_BEGIN ASM_ANNOTATE(ANNOTYPE_UNRET_BEGIN)
/*
- * This should be used directly after an instruction that is considered
+ * This should be used to refer to an instruction that is considered
* terminating, like a noreturn CALL or UD2 when we know they are not -- eg
* WARN using UD2.
*/
-#define ANNOTATE_REACHABLE ASM_ANNOTATE(ANNOTYPE_REACHABLE)
+#define ANNOTATE_REACHABLE(label) __ASM_ANNOTATE(label, ANNOTYPE_REACHABLE)
#else
#define ANNOTATE_NOENDBR ANNOTATE type=ANNOTYPE_NOENDBR
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 27d0c41..26bdd3e 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -614,19 +614,6 @@ static int init_pv_ops(struct objtool_file *file)
return 0;
}
-static struct instruction *find_last_insn(struct objtool_file *file,
- struct section *sec)
-{
- struct instruction *insn = NULL;
- unsigned int offset;
- unsigned int end = (sec->sh.sh_size > 10) ? sec->sh.sh_size - 10 : 0;
-
- for (offset = sec->sh.sh_size - 1; offset >= end && !insn; offset--)
- insn = find_insn(file, sec, offset);
-
- return insn;
-}
-
static int create_static_call_sections(struct objtool_file *file)
{
struct static_call_site *site;
@@ -2281,16 +2268,6 @@ static int read_annotate(struct objtool_file *file,
offset = reloc->sym->offset + reloc_addend(reloc);
insn = find_insn(file, reloc->sym->sec, offset);
- /*
- * Reachable annotations are 'funneh' and act on the previous instruction :/
- */
- if (type == ANNOTYPE_REACHABLE) {
- if (insn)
- insn = prev_insn_same_sec(file, insn);
- else if (offset == reloc->sym->sec->sh.sh_size)
- insn = find_last_insn(file, reloc->sym->sec);
- }
-
if (!insn) {
WARN("bad .discard.annotate_insn entry: %d of type %d", reloc_idx(reloc), type);
return -1;
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [tip: objtool/core] objtool: Convert {.UN}REACHABLE to ANNOTATE
2024-11-28 9:39 ` [PATCH v2 14/16] objtool: Convert {.UN}REACHABLE to ANNOTATE Peter Zijlstra
@ 2024-12-02 11:15 ` tip-bot2 for Peter Zijlstra
0 siblings, 0 replies; 36+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2024-12-02 11:15 UTC (permalink / raw)
To: linux-tip-commits
Cc: Josh Poimboeuf, Peter Zijlstra (Intel), Josh Poimboeuf, x86,
linux-kernel
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: e7a174fb43d24adca066e82d1cb9fdee092d48d1
Gitweb: https://git.kernel.org/tip/e7a174fb43d24adca066e82d1cb9fdee092d48d1
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Thu, 28 Nov 2024 10:39:05 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 02 Dec 2024 12:01:44 +01:00
objtool: Convert {.UN}REACHABLE to ANNOTATE
Suggested-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/20241128094312.353431347@infradead.org
---
arch/loongarch/include/asm/bug.h | 2 +-
arch/x86/entry/entry_64.S | 4 +-
arch/x86/include/asm/bug.h | 2 +-
arch/x86/include/asm/irq_stack.h | 2 +-
include/linux/objtool.h | 18 ++----
include/linux/objtool_types.h | 1 +-
tools/include/linux/objtool_types.h | 1 +-
tools/objtool/check.c | 82 +++++++---------------------
8 files changed, 36 insertions(+), 76 deletions(-)
diff --git a/arch/loongarch/include/asm/bug.h b/arch/loongarch/include/asm/bug.h
index 561ac1b..e25404a 100644
--- a/arch/loongarch/include/asm/bug.h
+++ b/arch/loongarch/include/asm/bug.h
@@ -45,7 +45,7 @@
#define __WARN_FLAGS(flags) \
do { \
instrumentation_begin(); \
- __BUG_FLAGS(BUGFLAG_WARNING|(flags), ASM_REACHABLE); \
+ __BUG_FLAGS(BUGFLAG_WARNING|(flags), ANNOTATE_REACHABLE);\
instrumentation_end(); \
} while (0)
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 1b5be07..9248660 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -311,7 +311,7 @@ SYM_CODE_END(xen_error_entry)
call \cfunc
/* For some configurations \cfunc ends up being a noreturn. */
- REACHABLE
+ ANNOTATE_REACHABLE
jmp error_return
.endm
@@ -532,7 +532,7 @@ SYM_CODE_START(\asmsym)
call \cfunc
/* For some configurations \cfunc ends up being a noreturn. */
- REACHABLE
+ ANNOTATE_REACHABLE
jmp paranoid_exit
diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h
index 806649c..dd8fb17 100644
--- a/arch/x86/include/asm/bug.h
+++ b/arch/x86/include/asm/bug.h
@@ -92,7 +92,7 @@ do { \
do { \
__auto_type __flags = BUGFLAG_WARNING|(flags); \
instrumentation_begin(); \
- _BUG_FLAGS(ASM_UD2, __flags, ASM_REACHABLE); \
+ _BUG_FLAGS(ASM_UD2, __flags, ANNOTATE_REACHABLE); \
instrumentation_end(); \
} while (0)
diff --git a/arch/x86/include/asm/irq_stack.h b/arch/x86/include/asm/irq_stack.h
index b71ad17..5455747 100644
--- a/arch/x86/include/asm/irq_stack.h
+++ b/arch/x86/include/asm/irq_stack.h
@@ -101,7 +101,7 @@
#define ASM_CALL_ARG0 \
"call %c[__func] \n" \
- ASM_REACHABLE
+ ANNOTATE_REACHABLE
#define ASM_CALL_ARG1 \
"movq %[arg1], %%rdi \n" \
diff --git a/include/linux/objtool.h b/include/linux/objtool.h
index fd487d4..e3cb135 100644
--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -111,14 +111,6 @@
#endif
.endm
-
-.macro REACHABLE
-.Lhere_\@:
- .pushsection .discard.reachable
- .long .Lhere_\@
- .popsection
-.endm
-
.macro ANNOTATE type:req
.Lhere_\@:
.pushsection .discard.annotate_insn,"M",@progbits,8
@@ -138,14 +130,11 @@
#define STACK_FRAME_NON_STANDARD_FP(func)
#define __ASM_ANNOTATE(label, type)
#define ASM_ANNOTATE(type)
-#define ASM_REACHABLE
#else
.macro UNWIND_HINT type:req sp_reg=0 sp_offset=0 signal=0
.endm
.macro STACK_FRAME_NON_STANDARD func:req
.endm
-.macro REACHABLE
-.endm
.macro ANNOTATE type:req
.endm
#endif
@@ -187,6 +176,12 @@
* it will be ignored.
*/
#define ANNOTATE_UNRET_BEGIN ASM_ANNOTATE(ANNOTYPE_UNRET_BEGIN)
+/*
+ * This should be used directly after an instruction that is considered
+ * terminating, like a noreturn CALL or UD2 when we know they are not -- eg
+ * WARN using UD2.
+ */
+#define ANNOTATE_REACHABLE ASM_ANNOTATE(ANNOTYPE_REACHABLE)
#else
#define ANNOTATE_NOENDBR ANNOTATE type=ANNOTYPE_NOENDBR
@@ -196,6 +191,7 @@
#define ANNOTATE_IGNORE_ALTERNATIVE ANNOTATE type=ANNOTYPE_IGNORE_ALTS
#define ANNOTATE_INTRA_FUNCTION_CALL ANNOTATE type=ANNOTYPE_INTRA_FUNCTION_CALL
#define ANNOTATE_UNRET_BEGIN ANNOTATE type=ANNOTYPE_UNRET_BEGIN
+#define ANNOTATE_REACHABLE ANNOTATE type=ANNOTYPE_REACHABLE
#endif
#if defined(CONFIG_NOINSTR_VALIDATION) && \
diff --git a/include/linux/objtool_types.h b/include/linux/objtool_types.h
index 23d6fb6..df5d9fa 100644
--- a/include/linux/objtool_types.h
+++ b/include/linux/objtool_types.h
@@ -64,5 +64,6 @@ struct unwind_hint {
#define ANNOTYPE_UNRET_BEGIN 5
#define ANNOTYPE_IGNORE_ALTS 6
#define ANNOTYPE_INTRA_FUNCTION_CALL 7
+#define ANNOTYPE_REACHABLE 8
#endif /* _LINUX_OBJTOOL_TYPES_H */
diff --git a/tools/include/linux/objtool_types.h b/tools/include/linux/objtool_types.h
index 23d6fb6..df5d9fa 100644
--- a/tools/include/linux/objtool_types.h
+++ b/tools/include/linux/objtool_types.h
@@ -64,5 +64,6 @@ struct unwind_hint {
#define ANNOTYPE_UNRET_BEGIN 5
#define ANNOTYPE_IGNORE_ALTS 6
#define ANNOTYPE_INTRA_FUNCTION_CALL 7
+#define ANNOTYPE_REACHABLE 8
#endif /* _LINUX_OBJTOOL_TYPES_H */
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 798cff5..27d0c41 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -627,56 +627,6 @@ static struct instruction *find_last_insn(struct objtool_file *file,
return insn;
}
-/*
- * Mark "ud2" instructions and manually annotated dead ends.
- */
-static int add_dead_ends(struct objtool_file *file)
-{
- struct section *rsec;
- struct reloc *reloc;
- struct instruction *insn;
- uint64_t offset;
-
- /*
- * UD2 defaults to being a dead-end, allow them to be annotated for
- * non-fatal, eg WARN.
- */
- rsec = find_section_by_name(file->elf, ".rela.discard.reachable");
- if (!rsec)
- return 0;
-
- for_each_reloc(rsec, reloc) {
- if (reloc->sym->type == STT_SECTION) {
- offset = reloc_addend(reloc);
- } else if (reloc->sym->local_label) {
- offset = reloc->sym->offset;
- } else {
- WARN("unexpected relocation symbol type in %s", rsec->name);
- return -1;
- }
-
- insn = find_insn(file, reloc->sym->sec, offset);
- if (insn)
- insn = prev_insn_same_sec(file, insn);
- else if (offset == reloc->sym->sec->sh.sh_size) {
- insn = find_last_insn(file, reloc->sym->sec);
- if (!insn) {
- WARN("can't find reachable insn at %s+0x%" PRIx64,
- reloc->sym->sec->name, offset);
- return -1;
- }
- } else {
- WARN("can't find reachable insn at %s+0x%" PRIx64,
- reloc->sym->sec->name, offset);
- return -1;
- }
-
- insn->dead_end = false;
- }
-
- return 0;
-}
-
static int create_static_call_sections(struct objtool_file *file)
{
struct static_call_site *site;
@@ -2306,6 +2256,7 @@ static int read_annotate(struct objtool_file *file,
struct section *sec;
struct instruction *insn;
struct reloc *reloc;
+ uint64_t offset;
int type, ret;
sec = find_section_by_name(file->elf, ".discard.annotate_insn");
@@ -2327,8 +2278,19 @@ static int read_annotate(struct objtool_file *file,
for_each_reloc(sec->rsec, reloc) {
type = *(u32 *)(sec->data->d_buf + (reloc_idx(reloc) * sec->sh.sh_entsize) + 4);
- insn = find_insn(file, reloc->sym->sec,
- reloc->sym->offset + reloc_addend(reloc));
+ offset = reloc->sym->offset + reloc_addend(reloc);
+ insn = find_insn(file, reloc->sym->sec, offset);
+
+ /*
+ * Reachable annotations are 'funneh' and act on the previous instruction :/
+ */
+ if (type == ANNOTYPE_REACHABLE) {
+ if (insn)
+ insn = prev_insn_same_sec(file, insn);
+ else if (offset == reloc->sym->sec->sh.sh_size)
+ insn = find_last_insn(file, reloc->sym->sec);
+ }
+
if (!insn) {
WARN("bad .discard.annotate_insn entry: %d of type %d", reloc_idx(reloc), type);
return -1;
@@ -2420,6 +2382,10 @@ static int __annotate_late(struct objtool_file *file, int type, struct instructi
insn->unret = 1;
break;
+ case ANNOTYPE_REACHABLE:
+ insn->dead_end = false;
+ break;
+
default:
break;
}
@@ -2566,14 +2532,6 @@ static int decode_sections(struct objtool_file *file)
if (ret)
return ret;
- /*
- * Must be after add_call_destinations() such that it can override
- * dead_end_function() marks.
- */
- ret = add_dead_ends(file);
- if (ret)
- return ret;
-
ret = add_jump_table_alts(file);
if (ret)
return ret;
@@ -2582,6 +2540,10 @@ static int decode_sections(struct objtool_file *file)
if (ret)
return ret;
+ /*
+ * Must be after add_call_destinations() such that it can override
+ * dead_end_function() marks.
+ */
ret = read_annotate(file, __annotate_late);
if (ret)
return ret;
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [tip: objtool/core] objtool: Remove annotate_{,un}reachable()
2024-11-28 9:39 ` [PATCH v2 13/16] objtool: Remove annotate_{,un}reachable() Peter Zijlstra
@ 2024-12-02 11:15 ` tip-bot2 for Peter Zijlstra
0 siblings, 0 replies; 36+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2024-12-02 11:15 UTC (permalink / raw)
To: linux-tip-commits
Cc: Peter Zijlstra (Intel), Josh Poimboeuf, x86, linux-kernel
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 06e24745985c8dd0da18337503afcf2f2fdbdff1
Gitweb: https://git.kernel.org/tip/06e24745985c8dd0da18337503afcf2f2fdbdff1
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Thu, 28 Nov 2024 10:39:04 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 02 Dec 2024 12:01:44 +01:00
objtool: Remove annotate_{,un}reachable()
There are no users of annotate_reachable() left.
And the annotate_unreachable() usage in unreachable() is plain wrong;
it will hide dangerous fall-through code-gen.
Remove both.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/20241128094312.235637588@infradead.org
---
include/linux/compiler.h | 27 +------------------------
tools/objtool/check.c | 43 +--------------------------------------
2 files changed, 2 insertions(+), 68 deletions(-)
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 7be8089..3d9a0e4 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -109,35 +109,9 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
/* Unreachable code */
#ifdef CONFIG_OBJTOOL
-/*
- * These macros help objtool understand GCC code flow for unreachable code.
- * The __COUNTER__ based labels are a hack to make each instance of the macros
- * unique, to convince GCC not to merge duplicate inline asm statements.
- */
-#define __stringify_label(n) #n
-
-#define __annotate_reachable(c) ({ \
- asm volatile(__stringify_label(c) ":\n\t" \
- ".pushsection .discard.reachable\n\t" \
- ".long " __stringify_label(c) "b - .\n\t" \
- ".popsection\n\t"); \
-})
-#define annotate_reachable() __annotate_reachable(__COUNTER__)
-
-#define __annotate_unreachable(c) ({ \
- asm volatile(__stringify_label(c) ":\n\t" \
- ".pushsection .discard.unreachable\n\t" \
- ".long " __stringify_label(c) "b - .\n\t" \
- ".popsection\n\t" : : "i" (c)); \
-})
-#define annotate_unreachable() __annotate_unreachable(__COUNTER__)
-
/* Annotate a C jump table to allow objtool to follow the code flow */
#define __annotate_jump_table __section(".rodata..c_jump_table,\"a\",@progbits #")
-
#else /* !CONFIG_OBJTOOL */
-#define annotate_reachable()
-#define annotate_unreachable()
#define __annotate_jump_table
#endif /* CONFIG_OBJTOOL */
@@ -147,7 +121,6 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
* control elsewhere.
*/
#define unreachable() do { \
- annotate_unreachable(); \
barrier_before_unreachable(); \
__builtin_unreachable(); \
} while (0)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 3bea8b2..798cff5 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -638,47 +638,8 @@ static int add_dead_ends(struct objtool_file *file)
uint64_t offset;
/*
- * Check for manually annotated dead ends.
- */
- rsec = find_section_by_name(file->elf, ".rela.discard.unreachable");
- if (!rsec)
- goto reachable;
-
- for_each_reloc(rsec, reloc) {
- if (reloc->sym->type == STT_SECTION) {
- offset = reloc_addend(reloc);
- } else if (reloc->sym->local_label) {
- offset = reloc->sym->offset;
- } else {
- WARN("unexpected relocation symbol type in %s", rsec->name);
- return -1;
- }
-
- insn = find_insn(file, reloc->sym->sec, offset);
- if (insn)
- insn = prev_insn_same_sec(file, insn);
- else if (offset == reloc->sym->sec->sh.sh_size) {
- insn = find_last_insn(file, reloc->sym->sec);
- if (!insn) {
- WARN("can't find unreachable insn at %s+0x%" PRIx64,
- reloc->sym->sec->name, offset);
- return -1;
- }
- } else {
- WARN("can't find unreachable insn at %s+0x%" PRIx64,
- reloc->sym->sec->name, offset);
- return -1;
- }
-
- insn->dead_end = true;
- }
-
-reachable:
- /*
- * These manually annotated reachable checks are needed for GCC 4.4,
- * where the Linux unreachable() macro isn't supported. In that case
- * GCC doesn't know the "ud2" is fatal, so it generates code as if it's
- * not a dead end.
+ * UD2 defaults to being a dead-end, allow them to be annotated for
+ * non-fatal, eg WARN.
*/
rsec = find_section_by_name(file->elf, ".rela.discard.reachable");
if (!rsec)
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [tip: objtool/core] loongarch: Use ASM_REACHABLE
2024-11-28 9:39 ` [PATCH v2 12/16] loongarch: Use ASM_REACHABLE Peter Zijlstra
@ 2024-12-02 11:15 ` tip-bot2 for Peter Zijlstra
0 siblings, 0 replies; 36+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2024-12-02 11:15 UTC (permalink / raw)
To: linux-tip-commits
Cc: Peter Zijlstra (Intel), Josh Poimboeuf, x86, linux-kernel
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 624bde3465f660e54a7cd4c1efc3e536349fead5
Gitweb: https://git.kernel.org/tip/624bde3465f660e54a7cd4c1efc3e536349fead5
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Thu, 28 Nov 2024 10:39:03 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 02 Dec 2024 12:01:44 +01:00
loongarch: Use ASM_REACHABLE
annotate_reachable() is unreliable since the compiler is free to place
random code inbetween two consecutive asm() statements.
This removes the last and only annotate_reachable() user.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/20241128094312.133437051@infradead.org
---
arch/loongarch/include/asm/bug.h | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/arch/loongarch/include/asm/bug.h b/arch/loongarch/include/asm/bug.h
index 0838887..561ac1b 100644
--- a/arch/loongarch/include/asm/bug.h
+++ b/arch/loongarch/include/asm/bug.h
@@ -4,6 +4,7 @@
#include <asm/break.h>
#include <linux/stringify.h>
+#include <linux/objtool.h>
#ifndef CONFIG_DEBUG_BUGVERBOSE
#define _BUGVERBOSE_LOCATION(file, line)
@@ -33,25 +34,25 @@
#define ASM_BUG_FLAGS(flags) \
__BUG_ENTRY(flags) \
- break BRK_BUG
+ break BRK_BUG;
#define ASM_BUG() ASM_BUG_FLAGS(0)
-#define __BUG_FLAGS(flags) \
- asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags)));
+#define __BUG_FLAGS(flags, extra) \
+ asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags)) \
+ extra);
#define __WARN_FLAGS(flags) \
do { \
instrumentation_begin(); \
- __BUG_FLAGS(BUGFLAG_WARNING|(flags)); \
- annotate_reachable(); \
+ __BUG_FLAGS(BUGFLAG_WARNING|(flags), ASM_REACHABLE); \
instrumentation_end(); \
} while (0)
#define BUG() \
do { \
instrumentation_begin(); \
- __BUG_FLAGS(0); \
+ __BUG_FLAGS(0, ""); \
unreachable(); \
} while (0)
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [tip: objtool/core] x86: Convert unreachable() to BUG()
2024-11-28 9:39 ` [PATCH v2 11/16] x86: Convert unreachable() to BUG() Peter Zijlstra
@ 2024-12-02 11:15 ` tip-bot2 for Peter Zijlstra
2024-12-16 9:32 ` Peter Zijlstra
0 siblings, 1 reply; 36+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2024-12-02 11:15 UTC (permalink / raw)
To: linux-tip-commits
Cc: Peter Zijlstra (Intel), Josh Poimboeuf, x86, linux-kernel
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 2190966fbc14ca2cd4ea76eefeb96a47d8e390df
Gitweb: https://git.kernel.org/tip/2190966fbc14ca2cd4ea76eefeb96a47d8e390df
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Thu, 28 Nov 2024 10:39:02 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 02 Dec 2024 12:01:43 +01:00
x86: Convert unreachable() to BUG()
Avoid unreachable() as it can (and will in the absence of UBSAN)
generate fallthrough code. Use BUG() so we get a UD2 trap (with
unreachable annotation).
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/20241128094312.028316261@infradead.org
---
arch/x86/kernel/process.c | 2 +-
arch/x86/kernel/reboot.c | 2 +-
arch/x86/kvm/svm/sev.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index f63f8fd..15507e7 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -838,7 +838,7 @@ void __noreturn stop_this_cpu(void *dummy)
#ifdef CONFIG_SMP
if (smp_ops.stop_this_cpu) {
smp_ops.stop_this_cpu();
- unreachable();
+ BUG();
}
#endif
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 6159228..dc1dd3f 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -883,7 +883,7 @@ static int crash_nmi_callback(unsigned int val, struct pt_regs *regs)
if (smp_ops.stop_this_cpu) {
smp_ops.stop_this_cpu();
- unreachable();
+ BUG();
}
/* Assume hlt works */
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 943bd07..fe6cc76 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -3820,7 +3820,7 @@ next_range:
goto next_range;
}
- unreachable();
+ BUG();
}
static int __sev_snp_update_protected_guest_state(struct kvm_vcpu *vcpu)
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [tip: objtool/core] unreachable: Unify
2024-11-28 9:39 ` [PATCH v2 10/16] unreachable: Unify Peter Zijlstra
@ 2024-12-02 11:15 ` tip-bot2 for Peter Zijlstra
0 siblings, 0 replies; 36+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2024-12-02 11:15 UTC (permalink / raw)
To: linux-tip-commits
Cc: Peter Zijlstra (Intel), Josh Poimboeuf, x86, linux-kernel
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: c837de3810982cd41cd70e5170da1931439f025c
Gitweb: https://git.kernel.org/tip/c837de3810982cd41cd70e5170da1931439f025c
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Thu, 28 Nov 2024 10:39:01 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 02 Dec 2024 12:01:43 +01:00
unreachable: Unify
Since barrier_before_unreachable() is empty for !GCC it is trivial to
unify the two definitions. Less is more.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/20241128094311.924381359@infradead.org
---
include/linux/compiler-gcc.h | 12 ------------
include/linux/compiler.h | 10 +++++++---
2 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index d0ed958..c9b5818 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -52,18 +52,6 @@
*/
#define barrier_before_unreachable() asm volatile("")
-/*
- * Mark a position in code as unreachable. This can be used to
- * suppress control flow warnings after asm blocks that transfer
- * control elsewhere.
- */
-#define unreachable() \
- do { \
- annotate_unreachable(); \
- barrier_before_unreachable(); \
- __builtin_unreachable(); \
- } while (0)
-
#if defined(CONFIG_ARCH_USE_BUILTIN_BSWAP)
#define __HAVE_BUILTIN_BSWAP32__
#define __HAVE_BUILTIN_BSWAP64__
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 469a64d..7be8089 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -141,12 +141,16 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
#define __annotate_jump_table
#endif /* CONFIG_OBJTOOL */
-#ifndef unreachable
-# define unreachable() do { \
+/*
+ * Mark a position in code as unreachable. This can be used to
+ * suppress control flow warnings after asm blocks that transfer
+ * control elsewhere.
+ */
+#define unreachable() do { \
annotate_unreachable(); \
+ barrier_before_unreachable(); \
__builtin_unreachable(); \
} while (0)
-#endif
/*
* KENTRY - kernel entry point
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [tip: objtool/core] objtool: Collect more annotations in objtool.h
2024-11-28 9:39 ` [PATCH v2 09/16] objtool: Collect more annotations in objtool.h Peter Zijlstra
@ 2024-12-02 11:15 ` tip-bot2 for Peter Zijlstra
0 siblings, 0 replies; 36+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2024-12-02 11:15 UTC (permalink / raw)
To: linux-tip-commits
Cc: Josh Poimboeuf, Peter Zijlstra (Intel), Josh Poimboeuf, x86,
linux-kernel
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: bb8170067470cc7af28e4386e600b1e0a6a8956a
Gitweb: https://git.kernel.org/tip/bb8170067470cc7af28e4386e600b1e0a6a8956a
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Thu, 28 Nov 2024 10:39:00 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 02 Dec 2024 12:01:43 +01:00
objtool: Collect more annotations in objtool.h
Suggested-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/20241128094311.786598147@infradead.org
---
arch/x86/include/asm/alternative.h | 12 +----
arch/x86/include/asm/nospec-branch.h | 9 +---
include/linux/instrumentation.h | 4 +-
include/linux/objtool.h | 80 +++++++++++++++++----------
4 files changed, 55 insertions(+), 50 deletions(-)
diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
index 595695f..e3903b7 100644
--- a/arch/x86/include/asm/alternative.h
+++ b/arch/x86/include/asm/alternative.h
@@ -56,12 +56,6 @@
#endif
/*
- * objtool annotation to ignore the alternatives and only consider the original
- * instruction(s).
- */
-#define ANNOTATE_IGNORE_ALTERNATIVE ASM_ANNOTATE(ANNOTYPE_IGNORE_ALTS)
-
-/*
* The patching flags are part of the upper bits of the @ft_flags parameter when
* specifying them. The split is currently like this:
*
@@ -308,12 +302,6 @@ void nop_func(void);
#endif
/*
- * objtool annotation to ignore the alternatives and only consider the original
- * instruction(s).
- */
-#define ANNOTATE_IGNORE_ALTERNATIVE ANNOTATE type=ANNOTYPE_IGNORE_ALTS
-
-/*
* Issue one struct alt_instr descriptor entry (need to put it into
* the section .altinstructions, see below). This entry contains
* enough information for the alternatives patching code to patch an
diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h
index 50340a1..7e8bf78 100644
--- a/arch/x86/include/asm/nospec-branch.h
+++ b/arch/x86/include/asm/nospec-branch.h
@@ -180,13 +180,6 @@
#ifdef __ASSEMBLY__
/*
- * This should be used immediately before an indirect jump/call. It tells
- * objtool the subsequent indirect jump/call is vouched safe for retpoline
- * builds.
- */
-#define ANNOTATE_RETPOLINE_SAFE ANNOTATE type=ANNOTYPE_RETPOLINE_SAFE
-
-/*
* (ab)use RETPOLINE_SAFE on RET to annotate away 'bare' RET instructions
* vs RETBleed validation.
*/
@@ -345,8 +338,6 @@
#else /* __ASSEMBLY__ */
-#define ANNOTATE_RETPOLINE_SAFE ASM_ANNOTATE(ANNOTYPE_RETPOLINE_SAFE)
-
typedef u8 retpoline_thunk_t[RETPOLINE_THUNK_SIZE];
extern retpoline_thunk_t __x86_indirect_thunk_array[];
extern retpoline_thunk_t __x86_indirect_call_thunk_array[];
diff --git a/include/linux/instrumentation.h b/include/linux/instrumentation.h
index c8f866c..bf675a8 100644
--- a/include/linux/instrumentation.h
+++ b/include/linux/instrumentation.h
@@ -10,7 +10,7 @@
/* Begin/end of an instrumentation safe region */
#define __instrumentation_begin(c) ({ \
asm volatile(__stringify(c) ": nop\n\t" \
- __ASM_ANNOTATE(__ASM_BREF(c), ANNOTYPE_INSTR_BEGIN)\
+ ANNOTATE_INSTR_BEGIN(__ASM_BREF(c)) \
: : "i" (c)); \
})
#define instrumentation_begin() __instrumentation_begin(__COUNTER__)
@@ -48,7 +48,7 @@
*/
#define __instrumentation_end(c) ({ \
asm volatile(__stringify(c) ": nop\n\t" \
- __ASM_ANNOTATE(__ASM_BREF(c), ANNOTYPE_INSTR_END) \
+ ANNOTATE_INSTR_END(__ASM_BREF(c)) \
: : "i" (c)); \
})
#define instrumentation_end() __instrumentation_end(__COUNTER__)
diff --git a/include/linux/objtool.h b/include/linux/objtool.h
index 42287c1..fd487d4 100644
--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -63,8 +63,6 @@
"911:\n\t" \
__ASM_ANNOTATE(911b, type)
-#define ANNOTATE_NOENDBR ASM_ANNOTATE(ANNOTYPE_NOENDBR)
-
#else /* __ASSEMBLY__ */
/*
@@ -113,19 +111,6 @@
#endif
.endm
-/*
- * Use objtool to validate the entry requirement that all code paths do
- * VALIDATE_UNRET_END before RET.
- *
- * NOTE: The macro must be used at the beginning of a global symbol, otherwise
- * it will be ignored.
- */
-#if defined(CONFIG_NOINSTR_VALIDATION) && \
- (defined(CONFIG_MITIGATION_UNRET_ENTRY) || defined(CONFIG_MITIGATION_SRSO))
-#define VALIDATE_UNRET_BEGIN ANNOTATE type=ANNOTYPE_UNRET_BEGIN
-#else
-#define VALIDATE_UNRET_BEGIN
-#endif
.macro REACHABLE
.Lhere_\@:
@@ -142,14 +127,6 @@
.popsection
.endm
-#define ANNOTATE_NOENDBR ANNOTATE type=ANNOTYPE_NOENDBR
-
-/*
- * This macro indicates that the following intra-function call is valid.
- * Any non-annotated intra-function call will cause objtool to issue a warning.
- */
-#define ANNOTATE_INTRA_FUNCTION_CALL ANNOTATE type=ANNOTYPE_INTRA_FUNCTION_CALL
-
#endif /* __ASSEMBLY__ */
#else /* !CONFIG_OBJTOOL */
@@ -161,16 +138,12 @@
#define STACK_FRAME_NON_STANDARD_FP(func)
#define __ASM_ANNOTATE(label, type)
#define ASM_ANNOTATE(type)
-#define ANNOTATE_NOENDBR
#define ASM_REACHABLE
#else
-#define ANNOTATE_INTRA_FUNCTION_CALL
.macro UNWIND_HINT type:req sp_reg=0 sp_offset=0 signal=0
.endm
.macro STACK_FRAME_NON_STANDARD func:req
.endm
-.macro ANNOTATE_NOENDBR
-.endm
.macro REACHABLE
.endm
.macro ANNOTATE type:req
@@ -179,4 +152,57 @@
#endif /* CONFIG_OBJTOOL */
+#ifndef __ASSEMBLY__
+/*
+ * Annotate away the various 'relocation to !ENDBR` complaints; knowing that
+ * these relocations will never be used for indirect calls.
+ */
+#define ANNOTATE_NOENDBR ASM_ANNOTATE(ANNOTYPE_NOENDBR)
+/*
+ * This should be used immediately before an indirect jump/call. It tells
+ * objtool the subsequent indirect jump/call is vouched safe for retpoline
+ * builds.
+ */
+#define ANNOTATE_RETPOLINE_SAFE ASM_ANNOTATE(ANNOTYPE_RETPOLINE_SAFE)
+/*
+ * See linux/instrumentation.h
+ */
+#define ANNOTATE_INSTR_BEGIN(label) __ASM_ANNOTATE(label, ANNOTYPE_INSTR_BEGIN)
+#define ANNOTATE_INSTR_END(label) __ASM_ANNOTATE(label, ANNOTYPE_INSTR_END)
+/*
+ * objtool annotation to ignore the alternatives and only consider the original
+ * instruction(s).
+ */
+#define ANNOTATE_IGNORE_ALTERNATIVE ASM_ANNOTATE(ANNOTYPE_IGNORE_ALTS)
+/*
+ * This macro indicates that the following intra-function call is valid.
+ * Any non-annotated intra-function call will cause objtool to issue a warning.
+ */
+#define ANNOTATE_INTRA_FUNCTION_CALL ASM_ANNOTATE(ANNOTYPE_INTRA_FUNCTION_CALL)
+/*
+ * Use objtool to validate the entry requirement that all code paths do
+ * VALIDATE_UNRET_END before RET.
+ *
+ * NOTE: The macro must be used at the beginning of a global symbol, otherwise
+ * it will be ignored.
+ */
+#define ANNOTATE_UNRET_BEGIN ASM_ANNOTATE(ANNOTYPE_UNRET_BEGIN)
+
+#else
+#define ANNOTATE_NOENDBR ANNOTATE type=ANNOTYPE_NOENDBR
+#define ANNOTATE_RETPOLINE_SAFE ANNOTATE type=ANNOTYPE_RETPOLINE_SAFE
+/* ANNOTATE_INSTR_BEGIN ANNOTATE type=ANNOTYPE_INSTR_BEGIN */
+/* ANNOTATE_INSTR_END ANNOTATE type=ANNOTYPE_INSTR_END */
+#define ANNOTATE_IGNORE_ALTERNATIVE ANNOTATE type=ANNOTYPE_IGNORE_ALTS
+#define ANNOTATE_INTRA_FUNCTION_CALL ANNOTATE type=ANNOTYPE_INTRA_FUNCTION_CALL
+#define ANNOTATE_UNRET_BEGIN ANNOTATE type=ANNOTYPE_UNRET_BEGIN
+#endif
+
+#if defined(CONFIG_NOINSTR_VALIDATION) && \
+ (defined(CONFIG_MITIGATION_UNRET_ENTRY) || defined(CONFIG_MITIGATION_SRSO))
+#define VALIDATE_UNRET_BEGIN ANNOTATE_UNRET_BEGIN
+#else
+#define VALIDATE_UNRET_BEGIN
+#endif
+
#endif /* _LINUX_OBJTOOL_H */
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [tip: objtool/core] objtool: Collapse annotate sequences
2024-11-28 9:38 ` [PATCH v2 08/16] objtool: Collapse annotate sequences Peter Zijlstra
@ 2024-12-02 11:15 ` tip-bot2 for Peter Zijlstra
0 siblings, 0 replies; 36+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2024-12-02 11:15 UTC (permalink / raw)
To: linux-tip-commits
Cc: Peter Zijlstra (Intel), Josh Poimboeuf, x86, linux-kernel
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: a8a330dd9900024dc18b048c4f0f3c6ad22ff4c1
Gitweb: https://git.kernel.org/tip/a8a330dd9900024dc18b048c4f0f3c6ad22ff4c1
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Thu, 28 Nov 2024 10:38:59 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 02 Dec 2024 12:01:42 +01:00
objtool: Collapse annotate sequences
Reduce read_annotate() runs by collapsing subsequent runs into a
single call.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/20241128094311.688871544@infradead.org
---
tools/objtool/check.c | 87 +++++++++++++++---------------------------
1 file changed, 32 insertions(+), 55 deletions(-)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 2222fe7..3bea8b2 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2381,21 +2381,24 @@ static int read_annotate(struct objtool_file *file,
return 0;
}
-static int __annotate_ignore_alts(struct objtool_file *file, int type, struct instruction *insn)
+static int __annotate_early(struct objtool_file *file, int type, struct instruction *insn)
{
- if (type != ANNOTYPE_IGNORE_ALTS)
- return 0;
+ switch (type) {
+ case ANNOTYPE_IGNORE_ALTS:
+ insn->ignore_alts = true;
+ break;
- insn->ignore_alts = true;
- return 0;
-}
+ /*
+ * Must be before read_unwind_hints() since that needs insn->noendbr.
+ */
+ case ANNOTYPE_NOENDBR:
+ insn->noendbr = 1;
+ break;
-static int __annotate_noendbr(struct objtool_file *file, int type, struct instruction *insn)
-{
- if (type != ANNOTYPE_NOENDBR)
- return 0;
+ default:
+ break;
+ }
- insn->noendbr = 1;
return 0;
}
@@ -2429,26 +2432,21 @@ static int __annotate_ifc(struct objtool_file *file, int type, struct instructio
return 0;
}
-static int __annotate_retpoline_safe(struct objtool_file *file, int type, struct instruction *insn)
+static int __annotate_late(struct objtool_file *file, int type, struct instruction *insn)
{
- if (type != ANNOTYPE_RETPOLINE_SAFE)
- return 0;
-
- if (insn->type != INSN_JUMP_DYNAMIC &&
- insn->type != INSN_CALL_DYNAMIC &&
- insn->type != INSN_RETURN &&
- insn->type != INSN_NOP) {
- WARN_INSN(insn, "retpoline_safe hint not an indirect jump/call/ret/nop");
- return -1;
- }
+ switch (type) {
+ case ANNOTYPE_RETPOLINE_SAFE:
+ if (insn->type != INSN_JUMP_DYNAMIC &&
+ insn->type != INSN_CALL_DYNAMIC &&
+ insn->type != INSN_RETURN &&
+ insn->type != INSN_NOP) {
+ WARN_INSN(insn, "retpoline_safe hint not an indirect jump/call/ret/nop");
+ return -1;
+ }
- insn->retpoline_safe = true;
- return 0;
-}
+ insn->retpoline_safe = true;
+ break;
-static int __annotate_instr(struct objtool_file *file, int type, struct instruction *insn)
-{
- switch (type) {
case ANNOTYPE_INSTR_BEGIN:
insn->instr++;
break;
@@ -2457,6 +2455,10 @@ static int __annotate_instr(struct objtool_file *file, int type, struct instruct
insn->instr--;
break;
+ case ANNOTYPE_UNRET_BEGIN:
+ insn->unret = 1;
+ break;
+
default:
break;
}
@@ -2464,16 +2466,6 @@ static int __annotate_instr(struct objtool_file *file, int type, struct instruct
return 0;
}
-static int __annotate_unret(struct objtool_file *file, int type, struct instruction *insn)
-{
- if (type != ANNOTYPE_UNRET_BEGIN)
- return 0;
-
- insn->unret = 1;
- return 0;
-
-}
-
/*
* Return true if name matches an instrumentation function, where calls to that
* function from noinstr code can safely be removed, but compilers won't do so.
@@ -2583,14 +2575,7 @@ static int decode_sections(struct objtool_file *file)
add_ignores(file);
add_uaccess_safe(file);
- ret = read_annotate(file, __annotate_ignore_alts);
- if (ret)
- return ret;
-
- /*
- * Must be before read_unwind_hints() since that needs insn->noendbr.
- */
- ret = read_annotate(file, __annotate_noendbr);
+ ret = read_annotate(file, __annotate_early);
if (ret)
return ret;
@@ -2636,15 +2621,7 @@ static int decode_sections(struct objtool_file *file)
if (ret)
return ret;
- ret = read_annotate(file, __annotate_retpoline_safe);
- if (ret)
- return ret;
-
- ret = read_annotate(file, __annotate_instr);
- if (ret)
- return ret;
-
- ret = read_annotate(file, __annotate_unret);
+ ret = read_annotate(file, __annotate_late);
if (ret)
return ret;
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [tip: objtool/core] objtool: Convert ANNOTATE_INTRA_FUNCTION_CALL to ANNOTATE
2024-11-28 9:38 ` [PATCH v2 07/16] objtool: Convert ANNOTATE_INTRA_FUNCTION_CALL " Peter Zijlstra
@ 2024-12-02 11:15 ` tip-bot2 for Peter Zijlstra
0 siblings, 0 replies; 36+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2024-12-02 11:15 UTC (permalink / raw)
To: linux-tip-commits
Cc: Peter Zijlstra (Intel), Josh Poimboeuf, x86, linux-kernel
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 112765ca1cb9353e71b4f5af4e6e6c4a69c28d99
Gitweb: https://git.kernel.org/tip/112765ca1cb9353e71b4f5af4e6e6c4a69c28d99
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Thu, 28 Nov 2024 10:38:58 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 02 Dec 2024 12:01:42 +01:00
objtool: Convert ANNOTATE_INTRA_FUNCTION_CALL to ANNOTATE
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/20241128094311.584892071@infradead.org
---
include/linux/objtool.h | 16 +----
include/linux/objtool_types.h | 1 +-
tools/include/linux/objtool_types.h | 1 +-
tools/objtool/check.c | 96 +++++++++++-----------------
4 files changed, 47 insertions(+), 67 deletions(-)
diff --git a/include/linux/objtool.h b/include/linux/objtool.h
index 5f0bf80..42287c1 100644
--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -68,16 +68,6 @@
#else /* __ASSEMBLY__ */
/*
- * This macro indicates that the following intra-function call is valid.
- * Any non-annotated intra-function call will cause objtool to issue a warning.
- */
-#define ANNOTATE_INTRA_FUNCTION_CALL \
- 999: \
- .pushsection .discard.intra_function_calls; \
- .long 999b; \
- .popsection;
-
-/*
* In asm, there are two kinds of code: normal C-type callable functions and
* the rest. The normal callable functions can be called by other code, and
* don't do anything unusual with the stack. Such normal callable functions
@@ -154,6 +144,12 @@
#define ANNOTATE_NOENDBR ANNOTATE type=ANNOTYPE_NOENDBR
+/*
+ * This macro indicates that the following intra-function call is valid.
+ * Any non-annotated intra-function call will cause objtool to issue a warning.
+ */
+#define ANNOTATE_INTRA_FUNCTION_CALL ANNOTATE type=ANNOTYPE_INTRA_FUNCTION_CALL
+
#endif /* __ASSEMBLY__ */
#else /* !CONFIG_OBJTOOL */
diff --git a/include/linux/objtool_types.h b/include/linux/objtool_types.h
index eab15db..23d6fb6 100644
--- a/include/linux/objtool_types.h
+++ b/include/linux/objtool_types.h
@@ -63,5 +63,6 @@ struct unwind_hint {
#define ANNOTYPE_INSTR_END 4
#define ANNOTYPE_UNRET_BEGIN 5
#define ANNOTYPE_IGNORE_ALTS 6
+#define ANNOTYPE_INTRA_FUNCTION_CALL 7
#endif /* _LINUX_OBJTOOL_TYPES_H */
diff --git a/tools/include/linux/objtool_types.h b/tools/include/linux/objtool_types.h
index eab15db..23d6fb6 100644
--- a/tools/include/linux/objtool_types.h
+++ b/tools/include/linux/objtool_types.h
@@ -63,5 +63,6 @@ struct unwind_hint {
#define ANNOTYPE_INSTR_END 4
#define ANNOTYPE_UNRET_BEGIN 5
#define ANNOTYPE_IGNORE_ALTS 6
+#define ANNOTYPE_INTRA_FUNCTION_CALL 7
#endif /* _LINUX_OBJTOOL_TYPES_H */
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index ba2cb9b..2222fe7 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2339,7 +2339,8 @@ static int read_unwind_hints(struct objtool_file *file)
return 0;
}
-static int read_annotate(struct objtool_file *file, int (*func)(int type, struct instruction *insn))
+static int read_annotate(struct objtool_file *file,
+ int (*func)(struct objtool_file *file, int type, struct instruction *insn))
{
struct section *sec;
struct instruction *insn;
@@ -2372,7 +2373,7 @@ static int read_annotate(struct objtool_file *file, int (*func)(int type, struct
return -1;
}
- ret = func(type, insn);
+ ret = func(file, type, insn);
if (ret < 0)
return ret;
}
@@ -2380,7 +2381,7 @@ static int read_annotate(struct objtool_file *file, int (*func)(int type, struct
return 0;
}
-static int __annotate_ignore_alts(int type, struct instruction *insn)
+static int __annotate_ignore_alts(struct objtool_file *file, int type, struct instruction *insn)
{
if (type != ANNOTYPE_IGNORE_ALTS)
return 0;
@@ -2389,7 +2390,7 @@ static int __annotate_ignore_alts(int type, struct instruction *insn)
return 0;
}
-static int __annotate_noendbr(int type, struct instruction *insn)
+static int __annotate_noendbr(struct objtool_file *file, int type, struct instruction *insn)
{
if (type != ANNOTYPE_NOENDBR)
return 0;
@@ -2398,7 +2399,37 @@ static int __annotate_noendbr(int type, struct instruction *insn)
return 0;
}
-static int __annotate_retpoline_safe(int type, struct instruction *insn)
+static int __annotate_ifc(struct objtool_file *file, int type, struct instruction *insn)
+{
+ unsigned long dest_off;
+
+ if (type != ANNOTYPE_INTRA_FUNCTION_CALL)
+ return 0;
+
+ if (insn->type != INSN_CALL) {
+ WARN_INSN(insn, "intra_function_call not a direct call");
+ return -1;
+ }
+
+ /*
+ * Treat intra-function CALLs as JMPs, but with a stack_op.
+ * See add_call_destinations(), which strips stack_ops from
+ * normal CALLs.
+ */
+ insn->type = INSN_JUMP_UNCONDITIONAL;
+
+ dest_off = arch_jump_destination(insn);
+ insn->jump_dest = find_insn(file, insn->sec, dest_off);
+ if (!insn->jump_dest) {
+ WARN_INSN(insn, "can't find call dest at %s+0x%lx",
+ insn->sec->name, dest_off);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int __annotate_retpoline_safe(struct objtool_file *file, int type, struct instruction *insn)
{
if (type != ANNOTYPE_RETPOLINE_SAFE)
return 0;
@@ -2415,7 +2446,7 @@ static int __annotate_retpoline_safe(int type, struct instruction *insn)
return 0;
}
-static int __annotate_instr(int type, struct instruction *insn)
+static int __annotate_instr(struct objtool_file *file, int type, struct instruction *insn)
{
switch (type) {
case ANNOTYPE_INSTR_BEGIN:
@@ -2433,7 +2464,7 @@ static int __annotate_instr(int type, struct instruction *insn)
return 0;
}
-static int __annotate_unret(int type, struct instruction *insn)
+static int __annotate_unret(struct objtool_file *file, int type, struct instruction *insn)
{
if (type != ANNOTYPE_UNRET_BEGIN)
return 0;
@@ -2443,55 +2474,6 @@ static int __annotate_unret(int type, struct instruction *insn)
}
-static int read_intra_function_calls(struct objtool_file *file)
-{
- struct instruction *insn;
- struct section *rsec;
- struct reloc *reloc;
-
- rsec = find_section_by_name(file->elf, ".rela.discard.intra_function_calls");
- if (!rsec)
- return 0;
-
- for_each_reloc(rsec, reloc) {
- unsigned long dest_off;
-
- if (reloc->sym->type != STT_SECTION) {
- WARN("unexpected relocation symbol type in %s",
- rsec->name);
- return -1;
- }
-
- insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
- if (!insn) {
- WARN("bad .discard.intra_function_call entry");
- return -1;
- }
-
- if (insn->type != INSN_CALL) {
- WARN_INSN(insn, "intra_function_call not a direct call");
- return -1;
- }
-
- /*
- * Treat intra-function CALLs as JMPs, but with a stack_op.
- * See add_call_destinations(), which strips stack_ops from
- * normal CALLs.
- */
- insn->type = INSN_JUMP_UNCONDITIONAL;
-
- dest_off = arch_jump_destination(insn);
- insn->jump_dest = find_insn(file, insn->sec, dest_off);
- if (!insn->jump_dest) {
- WARN_INSN(insn, "can't find call dest at %s+0x%lx",
- insn->sec->name, dest_off);
- return -1;
- }
- }
-
- return 0;
-}
-
/*
* Return true if name matches an instrumentation function, where calls to that
* function from noinstr code can safely be removed, but compilers won't do so.
@@ -2630,7 +2612,7 @@ static int decode_sections(struct objtool_file *file)
* Must be before add_call_destination(); it changes INSN_CALL to
* INSN_JUMP.
*/
- ret = read_intra_function_calls(file);
+ ret = read_annotate(file, __annotate_ifc);
if (ret)
return ret;
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [tip: objtool/core] objtool: Convert ANNOTATE_IGNORE_ALTERNATIVE to ANNOTATE
2024-11-28 9:38 ` [PATCH v2 06/16] objtool: Convert ANNOTATE_IGNORE_ALTERNATIVE " Peter Zijlstra
@ 2024-12-02 11:15 ` tip-bot2 for Peter Zijlstra
0 siblings, 0 replies; 36+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2024-12-02 11:15 UTC (permalink / raw)
To: linux-tip-commits
Cc: Peter Zijlstra (Intel), Josh Poimboeuf, x86, linux-kernel
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: f0cd57c35a75f152d3b31b9be3f7f413b96a6d3f
Gitweb: https://git.kernel.org/tip/f0cd57c35a75f152d3b31b9be3f7f413b96a6d3f
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Thu, 28 Nov 2024 10:38:57 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 02 Dec 2024 12:01:42 +01:00
objtool: Convert ANNOTATE_IGNORE_ALTERNATIVE to ANNOTATE
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/20241128094311.465691316@infradead.org
---
arch/x86/include/asm/alternative.h | 14 +--------
include/linux/objtool_types.h | 1 +-
tools/include/linux/objtool_types.h | 1 +-
tools/objtool/check.c | 45 ++++++----------------------
4 files changed, 15 insertions(+), 46 deletions(-)
diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
index dc03a64..595695f 100644
--- a/arch/x86/include/asm/alternative.h
+++ b/arch/x86/include/asm/alternative.h
@@ -4,6 +4,7 @@
#include <linux/types.h>
#include <linux/stringify.h>
+#include <linux/objtool.h>
#include <asm/asm.h>
#define ALT_FLAGS_SHIFT 16
@@ -58,11 +59,7 @@
* objtool annotation to ignore the alternatives and only consider the original
* instruction(s).
*/
-#define ANNOTATE_IGNORE_ALTERNATIVE \
- "999:\n\t" \
- ".pushsection .discard.ignore_alts\n\t" \
- ".long 999b\n\t" \
- ".popsection\n\t"
+#define ANNOTATE_IGNORE_ALTERNATIVE ASM_ANNOTATE(ANNOTYPE_IGNORE_ALTS)
/*
* The patching flags are part of the upper bits of the @ft_flags parameter when
@@ -314,12 +311,7 @@ void nop_func(void);
* objtool annotation to ignore the alternatives and only consider the original
* instruction(s).
*/
-.macro ANNOTATE_IGNORE_ALTERNATIVE
- .Lannotate_\@:
- .pushsection .discard.ignore_alts
- .long .Lannotate_\@
- .popsection
-.endm
+#define ANNOTATE_IGNORE_ALTERNATIVE ANNOTATE type=ANNOTYPE_IGNORE_ALTS
/*
* Issue one struct alt_instr descriptor entry (need to put it into
diff --git a/include/linux/objtool_types.h b/include/linux/objtool_types.h
index 16236a5..eab15db 100644
--- a/include/linux/objtool_types.h
+++ b/include/linux/objtool_types.h
@@ -62,5 +62,6 @@ struct unwind_hint {
#define ANNOTYPE_INSTR_BEGIN 3
#define ANNOTYPE_INSTR_END 4
#define ANNOTYPE_UNRET_BEGIN 5
+#define ANNOTYPE_IGNORE_ALTS 6
#endif /* _LINUX_OBJTOOL_TYPES_H */
diff --git a/tools/include/linux/objtool_types.h b/tools/include/linux/objtool_types.h
index 16236a5..eab15db 100644
--- a/tools/include/linux/objtool_types.h
+++ b/tools/include/linux/objtool_types.h
@@ -62,5 +62,6 @@ struct unwind_hint {
#define ANNOTYPE_INSTR_BEGIN 3
#define ANNOTYPE_INSTR_END 4
#define ANNOTYPE_UNRET_BEGIN 5
+#define ANNOTYPE_IGNORE_ALTS 6
#endif /* _LINUX_OBJTOOL_TYPES_H */
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 2a70374..ba2cb9b 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1310,40 +1310,6 @@ static void add_uaccess_safe(struct objtool_file *file)
}
/*
- * FIXME: For now, just ignore any alternatives which add retpolines. This is
- * a temporary hack, as it doesn't allow ORC to unwind from inside a retpoline.
- * But it at least allows objtool to understand the control flow *around* the
- * retpoline.
- */
-static int add_ignore_alternatives(struct objtool_file *file)
-{
- struct section *rsec;
- struct reloc *reloc;
- struct instruction *insn;
-
- rsec = find_section_by_name(file->elf, ".rela.discard.ignore_alts");
- if (!rsec)
- return 0;
-
- for_each_reloc(rsec, reloc) {
- if (reloc->sym->type != STT_SECTION) {
- WARN("unexpected relocation symbol type in %s", rsec->name);
- return -1;
- }
-
- insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
- if (!insn) {
- WARN("bad .discard.ignore_alts entry");
- return -1;
- }
-
- insn->ignore_alts = true;
- }
-
- return 0;
-}
-
-/*
* Symbols that replace INSN_CALL_DYNAMIC, every (tail) call to such a symbol
* will be added to the .retpoline_sites section.
*/
@@ -2414,6 +2380,15 @@ static int read_annotate(struct objtool_file *file, int (*func)(int type, struct
return 0;
}
+static int __annotate_ignore_alts(int type, struct instruction *insn)
+{
+ if (type != ANNOTYPE_IGNORE_ALTS)
+ return 0;
+
+ insn->ignore_alts = true;
+ return 0;
+}
+
static int __annotate_noendbr(int type, struct instruction *insn)
{
if (type != ANNOTYPE_NOENDBR)
@@ -2626,7 +2601,7 @@ static int decode_sections(struct objtool_file *file)
add_ignores(file);
add_uaccess_safe(file);
- ret = add_ignore_alternatives(file);
+ ret = read_annotate(file, __annotate_ignore_alts);
if (ret)
return ret;
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [tip: objtool/core] objtool: Convert VALIDATE_UNRET_BEGIN to ANNOTATE
2024-11-28 9:38 ` [PATCH v2 05/16] objtool: Convert VALIDATE_UNRET_BEGIN " Peter Zijlstra
@ 2024-12-02 11:15 ` tip-bot2 for Peter Zijlstra
0 siblings, 0 replies; 36+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2024-12-02 11:15 UTC (permalink / raw)
To: linux-tip-commits
Cc: Peter Zijlstra (Intel), Josh Poimboeuf, x86, linux-kernel
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 18aa6118a1689b4d73c5ebbd917ae3f20c9c0db1
Gitweb: https://git.kernel.org/tip/18aa6118a1689b4d73c5ebbd917ae3f20c9c0db1
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Thu, 28 Nov 2024 10:38:56 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 02 Dec 2024 12:01:42 +01:00
objtool: Convert VALIDATE_UNRET_BEGIN to ANNOTATE
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/20241128094311.358508242@infradead.org
---
include/linux/objtool.h | 9 +++------
include/linux/objtool_types.h | 1 +-
tools/include/linux/objtool_types.h | 1 +-
tools/objtool/check.c | 28 +++++-----------------------
4 files changed, 10 insertions(+), 29 deletions(-)
diff --git a/include/linux/objtool.h b/include/linux/objtool.h
index 89c67cd..5f0bf80 100644
--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -130,15 +130,12 @@
* NOTE: The macro must be used at the beginning of a global symbol, otherwise
* it will be ignored.
*/
-.macro VALIDATE_UNRET_BEGIN
#if defined(CONFIG_NOINSTR_VALIDATION) && \
(defined(CONFIG_MITIGATION_UNRET_ENTRY) || defined(CONFIG_MITIGATION_SRSO))
-.Lhere_\@:
- .pushsection .discard.validate_unret
- .long .Lhere_\@ - .
- .popsection
+#define VALIDATE_UNRET_BEGIN ANNOTATE type=ANNOTYPE_UNRET_BEGIN
+#else
+#define VALIDATE_UNRET_BEGIN
#endif
-.endm
.macro REACHABLE
.Lhere_\@:
diff --git a/include/linux/objtool_types.h b/include/linux/objtool_types.h
index d4d68dd..16236a5 100644
--- a/include/linux/objtool_types.h
+++ b/include/linux/objtool_types.h
@@ -61,5 +61,6 @@ struct unwind_hint {
#define ANNOTYPE_RETPOLINE_SAFE 2
#define ANNOTYPE_INSTR_BEGIN 3
#define ANNOTYPE_INSTR_END 4
+#define ANNOTYPE_UNRET_BEGIN 5
#endif /* _LINUX_OBJTOOL_TYPES_H */
diff --git a/tools/include/linux/objtool_types.h b/tools/include/linux/objtool_types.h
index d4d68dd..16236a5 100644
--- a/tools/include/linux/objtool_types.h
+++ b/tools/include/linux/objtool_types.h
@@ -61,5 +61,6 @@ struct unwind_hint {
#define ANNOTYPE_RETPOLINE_SAFE 2
#define ANNOTYPE_INSTR_BEGIN 3
#define ANNOTYPE_INSTR_END 4
+#define ANNOTYPE_UNRET_BEGIN 5
#endif /* _LINUX_OBJTOOL_TYPES_H */
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 8e39c7f..2a70374 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2458,33 +2458,15 @@ static int __annotate_instr(int type, struct instruction *insn)
return 0;
}
-static int read_validate_unret_hints(struct objtool_file *file)
+static int __annotate_unret(int type, struct instruction *insn)
{
- struct section *rsec;
- struct instruction *insn;
- struct reloc *reloc;
-
- rsec = find_section_by_name(file->elf, ".rela.discard.validate_unret");
- if (!rsec)
+ if (type != ANNOTYPE_UNRET_BEGIN)
return 0;
- for_each_reloc(rsec, reloc) {
- if (reloc->sym->type != STT_SECTION) {
- WARN("unexpected relocation symbol type in %s", rsec->name);
- return -1;
- }
-
- insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
- if (!insn) {
- WARN("bad .discard.instr_end entry");
- return -1;
- }
- insn->unret = 1;
- }
-
+ insn->unret = 1;
return 0;
-}
+}
static int read_intra_function_calls(struct objtool_file *file)
{
@@ -2705,7 +2687,7 @@ static int decode_sections(struct objtool_file *file)
if (ret)
return ret;
- ret = read_validate_unret_hints(file);
+ ret = read_annotate(file, __annotate_unret);
if (ret)
return ret;
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [tip: objtool/core] objtool: Convert instrumentation_{begin,end}() to ANNOTATE
2024-11-28 9:38 ` [PATCH v2 04/16] objtool: Convert instrumentation_{begin,end}() " Peter Zijlstra
@ 2024-12-02 11:15 ` tip-bot2 for Peter Zijlstra
0 siblings, 0 replies; 36+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2024-12-02 11:15 UTC (permalink / raw)
To: linux-tip-commits
Cc: Peter Zijlstra (Intel), Josh Poimboeuf, x86, linux-kernel
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 317f2a64618c528539d17fe6957a64106087fbd2
Gitweb: https://git.kernel.org/tip/317f2a64618c528539d17fe6957a64106087fbd2
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Thu, 28 Nov 2024 10:38:55 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 02 Dec 2024 12:01:41 +01:00
objtool: Convert instrumentation_{begin,end}() to ANNOTATE
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/20241128094311.245980207@infradead.org
---
include/linux/instrumentation.h | 11 ++----
include/linux/objtool.h | 12 +++++--
include/linux/objtool_types.h | 2 +-
tools/include/linux/objtool_types.h | 2 +-
tools/objtool/check.c | 49 +++++-----------------------
5 files changed, 28 insertions(+), 48 deletions(-)
diff --git a/include/linux/instrumentation.h b/include/linux/instrumentation.h
index bc7babe..c8f866c 100644
--- a/include/linux/instrumentation.h
+++ b/include/linux/instrumentation.h
@@ -4,14 +4,14 @@
#ifdef CONFIG_NOINSTR_VALIDATION
+#include <linux/objtool.h>
#include <linux/stringify.h>
/* Begin/end of an instrumentation safe region */
#define __instrumentation_begin(c) ({ \
asm volatile(__stringify(c) ": nop\n\t" \
- ".pushsection .discard.instr_begin\n\t" \
- ".long " __stringify(c) "b - .\n\t" \
- ".popsection\n\t" : : "i" (c)); \
+ __ASM_ANNOTATE(__ASM_BREF(c), ANNOTYPE_INSTR_BEGIN)\
+ : : "i" (c)); \
})
#define instrumentation_begin() __instrumentation_begin(__COUNTER__)
@@ -48,9 +48,8 @@
*/
#define __instrumentation_end(c) ({ \
asm volatile(__stringify(c) ": nop\n\t" \
- ".pushsection .discard.instr_end\n\t" \
- ".long " __stringify(c) "b - .\n\t" \
- ".popsection\n\t" : : "i" (c)); \
+ __ASM_ANNOTATE(__ASM_BREF(c), ANNOTYPE_INSTR_END) \
+ : : "i" (c)); \
})
#define instrumentation_end() __instrumentation_end(__COUNTER__)
#else /* !CONFIG_NOINSTR_VALIDATION */
diff --git a/include/linux/objtool.h b/include/linux/objtool.h
index b5e9c0a..89c67cd 100644
--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -51,13 +51,18 @@
".long 998b\n\t" \
".popsection\n\t"
-#define ASM_ANNOTATE(type) \
- "911:\n\t" \
+#define __ASM_BREF(label) label ## b
+
+#define __ASM_ANNOTATE(label, type) \
".pushsection .discard.annotate_insn,\"M\",@progbits,8\n\t" \
- ".long 911b - .\n\t" \
+ ".long " __stringify(label) " - .\n\t" \
".long " __stringify(type) "\n\t" \
".popsection\n\t"
+#define ASM_ANNOTATE(type) \
+ "911:\n\t" \
+ __ASM_ANNOTATE(911b, type)
+
#define ANNOTATE_NOENDBR ASM_ANNOTATE(ANNOTYPE_NOENDBR)
#else /* __ASSEMBLY__ */
@@ -161,6 +166,7 @@
#define UNWIND_HINT(type, sp_reg, sp_offset, signal) "\n\t"
#define STACK_FRAME_NON_STANDARD(func)
#define STACK_FRAME_NON_STANDARD_FP(func)
+#define __ASM_ANNOTATE(label, type)
#define ASM_ANNOTATE(type)
#define ANNOTATE_NOENDBR
#define ASM_REACHABLE
diff --git a/include/linux/objtool_types.h b/include/linux/objtool_types.h
index 1b34836..d4d68dd 100644
--- a/include/linux/objtool_types.h
+++ b/include/linux/objtool_types.h
@@ -59,5 +59,7 @@ struct unwind_hint {
*/
#define ANNOTYPE_NOENDBR 1
#define ANNOTYPE_RETPOLINE_SAFE 2
+#define ANNOTYPE_INSTR_BEGIN 3
+#define ANNOTYPE_INSTR_END 4
#endif /* _LINUX_OBJTOOL_TYPES_H */
diff --git a/tools/include/linux/objtool_types.h b/tools/include/linux/objtool_types.h
index 1b34836..d4d68dd 100644
--- a/tools/include/linux/objtool_types.h
+++ b/tools/include/linux/objtool_types.h
@@ -59,5 +59,7 @@ struct unwind_hint {
*/
#define ANNOTYPE_NOENDBR 1
#define ANNOTYPE_RETPOLINE_SAFE 2
+#define ANNOTYPE_INSTR_BEGIN 3
+#define ANNOTYPE_INSTR_END 4
#endif /* _LINUX_OBJTOOL_TYPES_H */
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index c5b5230..8e39c7f 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2440,48 +2440,19 @@ static int __annotate_retpoline_safe(int type, struct instruction *insn)
return 0;
}
-static int read_instr_hints(struct objtool_file *file)
+static int __annotate_instr(int type, struct instruction *insn)
{
- struct section *rsec;
- struct instruction *insn;
- struct reloc *reloc;
-
- rsec = find_section_by_name(file->elf, ".rela.discard.instr_end");
- if (!rsec)
- return 0;
-
- for_each_reloc(rsec, reloc) {
- if (reloc->sym->type != STT_SECTION) {
- WARN("unexpected relocation symbol type in %s", rsec->name);
- return -1;
- }
-
- insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
- if (!insn) {
- WARN("bad .discard.instr_end entry");
- return -1;
- }
+ switch (type) {
+ case ANNOTYPE_INSTR_BEGIN:
+ insn->instr++;
+ break;
+ case ANNOTYPE_INSTR_END:
insn->instr--;
- }
-
- rsec = find_section_by_name(file->elf, ".rela.discard.instr_begin");
- if (!rsec)
- return 0;
-
- for_each_reloc(rsec, reloc) {
- if (reloc->sym->type != STT_SECTION) {
- WARN("unexpected relocation symbol type in %s", rsec->name);
- return -1;
- }
-
- insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
- if (!insn) {
- WARN("bad .discard.instr_begin entry");
- return -1;
- }
+ break;
- insn->instr++;
+ default:
+ break;
}
return 0;
@@ -2730,7 +2701,7 @@ static int decode_sections(struct objtool_file *file)
if (ret)
return ret;
- ret = read_instr_hints(file);
+ ret = read_annotate(file, __annotate_instr);
if (ret)
return ret;
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [tip: objtool/core] objtool: Convert ANNOTATE_RETPOLINE_SAFE to ANNOTATE
2024-11-28 9:38 ` [PATCH v2 03/16] objtool: Convert ANNOTATE_RETPOLINE_SAFE " Peter Zijlstra
@ 2024-12-02 11:15 ` tip-bot2 for Peter Zijlstra
0 siblings, 0 replies; 36+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2024-12-02 11:15 UTC (permalink / raw)
To: linux-tip-commits
Cc: Peter Zijlstra (Intel), Josh Poimboeuf, x86, linux-kernel
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: bf5febebd99fddfc6226a94e937d38a8d470b24e
Gitweb: https://git.kernel.org/tip/bf5febebd99fddfc6226a94e937d38a8d470b24e
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Thu, 28 Nov 2024 10:38:54 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 02 Dec 2024 12:01:41 +01:00
objtool: Convert ANNOTATE_RETPOLINE_SAFE to ANNOTATE
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/20241128094311.145275669@infradead.org
---
arch/x86/include/asm/nospec-branch.h | 13 +------
include/linux/objtool_types.h | 1 +-
tools/include/linux/objtool_types.h | 1 +-
tools/objtool/check.c | 52 +++++++++------------------
4 files changed, 22 insertions(+), 45 deletions(-)
diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h
index 96b410b..50340a1 100644
--- a/arch/x86/include/asm/nospec-branch.h
+++ b/arch/x86/include/asm/nospec-branch.h
@@ -184,12 +184,7 @@
* objtool the subsequent indirect jump/call is vouched safe for retpoline
* builds.
*/
-.macro ANNOTATE_RETPOLINE_SAFE
-.Lhere_\@:
- .pushsection .discard.retpoline_safe
- .long .Lhere_\@
- .popsection
-.endm
+#define ANNOTATE_RETPOLINE_SAFE ANNOTATE type=ANNOTYPE_RETPOLINE_SAFE
/*
* (ab)use RETPOLINE_SAFE on RET to annotate away 'bare' RET instructions
@@ -350,11 +345,7 @@
#else /* __ASSEMBLY__ */
-#define ANNOTATE_RETPOLINE_SAFE \
- "999:\n\t" \
- ".pushsection .discard.retpoline_safe\n\t" \
- ".long 999b\n\t" \
- ".popsection\n\t"
+#define ANNOTATE_RETPOLINE_SAFE ASM_ANNOTATE(ANNOTYPE_RETPOLINE_SAFE)
typedef u8 retpoline_thunk_t[RETPOLINE_THUNK_SIZE];
extern retpoline_thunk_t __x86_indirect_thunk_array[];
diff --git a/include/linux/objtool_types.h b/include/linux/objtool_types.h
index 4884f8c..1b34836 100644
--- a/include/linux/objtool_types.h
+++ b/include/linux/objtool_types.h
@@ -58,5 +58,6 @@ struct unwind_hint {
* Annotate types
*/
#define ANNOTYPE_NOENDBR 1
+#define ANNOTYPE_RETPOLINE_SAFE 2
#endif /* _LINUX_OBJTOOL_TYPES_H */
diff --git a/tools/include/linux/objtool_types.h b/tools/include/linux/objtool_types.h
index 4884f8c..1b34836 100644
--- a/tools/include/linux/objtool_types.h
+++ b/tools/include/linux/objtool_types.h
@@ -58,5 +58,6 @@ struct unwind_hint {
* Annotate types
*/
#define ANNOTYPE_NOENDBR 1
+#define ANNOTYPE_RETPOLINE_SAFE 2
#endif /* _LINUX_OBJTOOL_TYPES_H */
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index a74ff26..c5b5230 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2373,12 +2373,12 @@ static int read_unwind_hints(struct objtool_file *file)
return 0;
}
-static int read_annotate(struct objtool_file *file, void (*func)(int type, struct instruction *insn))
+static int read_annotate(struct objtool_file *file, int (*func)(int type, struct instruction *insn))
{
struct section *sec;
struct instruction *insn;
struct reloc *reloc;
- int type;
+ int type, ret;
sec = find_section_by_name(file->elf, ".discard.annotate_insn");
if (!sec)
@@ -2406,53 +2406,37 @@ static int read_annotate(struct objtool_file *file, void (*func)(int type, struc
return -1;
}
- func(type, insn);
+ ret = func(type, insn);
+ if (ret < 0)
+ return ret;
}
return 0;
}
-static void __annotate_noendbr(int type, struct instruction *insn)
+static int __annotate_noendbr(int type, struct instruction *insn)
{
if (type != ANNOTYPE_NOENDBR)
- return;
+ return 0;
insn->noendbr = 1;
+ return 0;
}
-static int read_retpoline_hints(struct objtool_file *file)
+static int __annotate_retpoline_safe(int type, struct instruction *insn)
{
- struct section *rsec;
- struct instruction *insn;
- struct reloc *reloc;
-
- rsec = find_section_by_name(file->elf, ".rela.discard.retpoline_safe");
- if (!rsec)
+ if (type != ANNOTYPE_RETPOLINE_SAFE)
return 0;
- for_each_reloc(rsec, reloc) {
- if (reloc->sym->type != STT_SECTION) {
- WARN("unexpected relocation symbol type in %s", rsec->name);
- return -1;
- }
-
- insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
- if (!insn) {
- WARN("bad .discard.retpoline_safe entry");
- return -1;
- }
-
- if (insn->type != INSN_JUMP_DYNAMIC &&
- insn->type != INSN_CALL_DYNAMIC &&
- insn->type != INSN_RETURN &&
- insn->type != INSN_NOP) {
- WARN_INSN(insn, "retpoline_safe hint not an indirect jump/call/ret/nop");
- return -1;
- }
-
- insn->retpoline_safe = true;
+ if (insn->type != INSN_JUMP_DYNAMIC &&
+ insn->type != INSN_CALL_DYNAMIC &&
+ insn->type != INSN_RETURN &&
+ insn->type != INSN_NOP) {
+ WARN_INSN(insn, "retpoline_safe hint not an indirect jump/call/ret/nop");
+ return -1;
}
+ insn->retpoline_safe = true;
return 0;
}
@@ -2742,7 +2726,7 @@ static int decode_sections(struct objtool_file *file)
if (ret)
return ret;
- ret = read_retpoline_hints(file);
+ ret = read_annotate(file, __annotate_retpoline_safe);
if (ret)
return ret;
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [tip: objtool/core] objtool: Convert ANNOTATE_NOENDBR to ANNOTATE
2024-11-28 9:38 ` [PATCH v2 02/16] objtool: Convert ANNOTATE_NOENDBR to ANNOTATE Peter Zijlstra
@ 2024-12-02 11:15 ` tip-bot2 for Peter Zijlstra
0 siblings, 0 replies; 36+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2024-12-02 11:15 UTC (permalink / raw)
To: linux-tip-commits
Cc: Peter Zijlstra (Intel), Josh Poimboeuf, x86, linux-kernel
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 22c3d58079688b697f36d670616e463cbb14d058
Gitweb: https://git.kernel.org/tip/22c3d58079688b697f36d670616e463cbb14d058
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Thu, 28 Nov 2024 10:38:53 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 02 Dec 2024 12:01:41 +01:00
objtool: Convert ANNOTATE_NOENDBR to ANNOTATE
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/20241128094311.042140333@infradead.org
---
include/linux/objtool.h | 17 +++------------
include/linux/objtool_types.h | 5 ++++-
tools/include/linux/objtool_types.h | 5 ++++-
tools/objtool/check.c | 32 ++++------------------------
4 files changed, 19 insertions(+), 40 deletions(-)
diff --git a/include/linux/objtool.h b/include/linux/objtool.h
index d98531e..b5e9c0a 100644
--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -45,12 +45,6 @@
#define STACK_FRAME_NON_STANDARD_FP(func)
#endif
-#define ANNOTATE_NOENDBR \
- "986: \n\t" \
- ".pushsection .discard.noendbr\n\t" \
- ".long 986b\n\t" \
- ".popsection\n\t"
-
#define ASM_REACHABLE \
"998:\n\t" \
".pushsection .discard.reachable\n\t" \
@@ -64,6 +58,8 @@
".long " __stringify(type) "\n\t" \
".popsection\n\t"
+#define ANNOTATE_NOENDBR ASM_ANNOTATE(ANNOTYPE_NOENDBR)
+
#else /* __ASSEMBLY__ */
/*
@@ -122,13 +118,6 @@
#endif
.endm
-.macro ANNOTATE_NOENDBR
-.Lhere_\@:
- .pushsection .discard.noendbr
- .long .Lhere_\@
- .popsection
-.endm
-
/*
* Use objtool to validate the entry requirement that all code paths do
* VALIDATE_UNRET_END before RET.
@@ -161,6 +150,8 @@
.popsection
.endm
+#define ANNOTATE_NOENDBR ANNOTATE type=ANNOTYPE_NOENDBR
+
#endif /* __ASSEMBLY__ */
#else /* !CONFIG_OBJTOOL */
diff --git a/include/linux/objtool_types.h b/include/linux/objtool_types.h
index 453a4f4..4884f8c 100644
--- a/include/linux/objtool_types.h
+++ b/include/linux/objtool_types.h
@@ -54,4 +54,9 @@ struct unwind_hint {
#define UNWIND_HINT_TYPE_SAVE 6
#define UNWIND_HINT_TYPE_RESTORE 7
+/*
+ * Annotate types
+ */
+#define ANNOTYPE_NOENDBR 1
+
#endif /* _LINUX_OBJTOOL_TYPES_H */
diff --git a/tools/include/linux/objtool_types.h b/tools/include/linux/objtool_types.h
index 453a4f4..4884f8c 100644
--- a/tools/include/linux/objtool_types.h
+++ b/tools/include/linux/objtool_types.h
@@ -54,4 +54,9 @@ struct unwind_hint {
#define UNWIND_HINT_TYPE_SAVE 6
#define UNWIND_HINT_TYPE_RESTORE 7
+/*
+ * Annotate types
+ */
+#define ANNOTYPE_NOENDBR 1
+
#endif /* _LINUX_OBJTOOL_TYPES_H */
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index b0efc8e..a74ff26 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2412,32 +2412,12 @@ static int read_annotate(struct objtool_file *file, void (*func)(int type, struc
return 0;
}
-static void __annotate_nop(int type, struct instruction *insn)
+static void __annotate_noendbr(int type, struct instruction *insn)
{
-}
-
-static int read_noendbr_hints(struct objtool_file *file)
-{
- struct instruction *insn;
- struct section *rsec;
- struct reloc *reloc;
-
- rsec = find_section_by_name(file->elf, ".rela.discard.noendbr");
- if (!rsec)
- return 0;
-
- for_each_reloc(rsec, reloc) {
- insn = find_insn(file, reloc->sym->sec,
- reloc->sym->offset + reloc_addend(reloc));
- if (!insn) {
- WARN("bad .discard.noendbr entry");
- return -1;
- }
-
- insn->noendbr = 1;
- }
+ if (type != ANNOTYPE_NOENDBR)
+ return;
- return 0;
+ insn->noendbr = 1;
}
static int read_retpoline_hints(struct objtool_file *file)
@@ -2713,12 +2693,10 @@ static int decode_sections(struct objtool_file *file)
if (ret)
return ret;
- read_annotate(file, __annotate_nop);
-
/*
* Must be before read_unwind_hints() since that needs insn->noendbr.
*/
- ret = read_noendbr_hints(file);
+ ret = read_annotate(file, __annotate_noendbr);
if (ret)
return ret;
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [tip: objtool/core] objtool: Generic annotation infrastructure
2024-11-28 9:38 ` [PATCH v2 01/16] objtool: Generic annotation infrastructure Peter Zijlstra
@ 2024-12-02 11:15 ` tip-bot2 for Peter Zijlstra
0 siblings, 0 replies; 36+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2024-12-02 11:15 UTC (permalink / raw)
To: linux-tip-commits
Cc: Peter Zijlstra (Intel), Josh Poimboeuf, x86, linux-kernel
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 2116b349e29a2e9ba17ea2e45b31234e4b350793
Gitweb: https://git.kernel.org/tip/2116b349e29a2e9ba17ea2e45b31234e4b350793
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Thu, 28 Nov 2024 10:38:52 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 02 Dec 2024 12:01:41 +01:00
objtool: Generic annotation infrastructure
Avoid endless .discard.foo sections for each annotation, create a
single .discard.annotate_insn section that takes an annotation type along
with the instruction.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/20241128094310.932794537@infradead.org
---
include/linux/objtool.h | 18 ++++++++++++++++-
tools/objtool/check.c | 45 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 63 insertions(+)
diff --git a/include/linux/objtool.h b/include/linux/objtool.h
index b3b8d3d..d98531e 100644
--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -57,6 +57,13 @@
".long 998b\n\t" \
".popsection\n\t"
+#define ASM_ANNOTATE(type) \
+ "911:\n\t" \
+ ".pushsection .discard.annotate_insn,\"M\",@progbits,8\n\t" \
+ ".long 911b - .\n\t" \
+ ".long " __stringify(type) "\n\t" \
+ ".popsection\n\t"
+
#else /* __ASSEMBLY__ */
/*
@@ -146,6 +153,14 @@
.popsection
.endm
+.macro ANNOTATE type:req
+.Lhere_\@:
+ .pushsection .discard.annotate_insn,"M",@progbits,8
+ .long .Lhere_\@ - .
+ .long \type
+ .popsection
+.endm
+
#endif /* __ASSEMBLY__ */
#else /* !CONFIG_OBJTOOL */
@@ -155,6 +170,7 @@
#define UNWIND_HINT(type, sp_reg, sp_offset, signal) "\n\t"
#define STACK_FRAME_NON_STANDARD(func)
#define STACK_FRAME_NON_STANDARD_FP(func)
+#define ASM_ANNOTATE(type)
#define ANNOTATE_NOENDBR
#define ASM_REACHABLE
#else
@@ -167,6 +183,8 @@
.endm
.macro REACHABLE
.endm
+.macro ANNOTATE type:req
+.endm
#endif
#endif /* CONFIG_OBJTOOL */
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 4ce176a..b0efc8e 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2373,6 +2373,49 @@ static int read_unwind_hints(struct objtool_file *file)
return 0;
}
+static int read_annotate(struct objtool_file *file, void (*func)(int type, struct instruction *insn))
+{
+ struct section *sec;
+ struct instruction *insn;
+ struct reloc *reloc;
+ int type;
+
+ sec = find_section_by_name(file->elf, ".discard.annotate_insn");
+ if (!sec)
+ return 0;
+
+ if (!sec->rsec)
+ return 0;
+
+ if (sec->sh.sh_entsize != 8) {
+ static bool warned = false;
+ if (!warned) {
+ WARN("%s: dodgy linker, sh_entsize != 8", sec->name);
+ warned = true;
+ }
+ sec->sh.sh_entsize = 8;
+ }
+
+ for_each_reloc(sec->rsec, reloc) {
+ type = *(u32 *)(sec->data->d_buf + (reloc_idx(reloc) * sec->sh.sh_entsize) + 4);
+
+ insn = find_insn(file, reloc->sym->sec,
+ reloc->sym->offset + reloc_addend(reloc));
+ if (!insn) {
+ WARN("bad .discard.annotate_insn entry: %d of type %d", reloc_idx(reloc), type);
+ return -1;
+ }
+
+ func(type, insn);
+ }
+
+ return 0;
+}
+
+static void __annotate_nop(int type, struct instruction *insn)
+{
+}
+
static int read_noendbr_hints(struct objtool_file *file)
{
struct instruction *insn;
@@ -2670,6 +2713,8 @@ static int decode_sections(struct objtool_file *file)
if (ret)
return ret;
+ read_annotate(file, __annotate_nop);
+
/*
* Must be before read_unwind_hints() since that needs insn->noendbr.
*/
^ permalink raw reply related [flat|nested] 36+ messages in thread
* Re: [tip: objtool/core] x86: Convert unreachable() to BUG()
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
@ 2024-12-16 9:32 ` Peter Zijlstra
2024-12-24 9:47 ` [tip: objtool/core] x86/mm: " tip-bot2 for Peter Zijlstra
0 siblings, 1 reply; 36+ messages in thread
From: Peter Zijlstra @ 2024-12-16 9:32 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-tip-commits, Josh Poimboeuf, x86
On Mon, Dec 02, 2024 at 11:15:21AM -0000, tip-bot2 for Peter Zijlstra wrote:
> The following commit has been merged into the objtool/core branch of tip:
>
> Commit-ID: 2190966fbc14ca2cd4ea76eefeb96a47d8e390df
> Gitweb: https://git.kernel.org/tip/2190966fbc14ca2cd4ea76eefeb96a47d8e390df
> Author: Peter Zijlstra <peterz@infradead.org>
> AuthorDate: Thu, 28 Nov 2024 10:39:02 +01:00
> Committer: Peter Zijlstra <peterz@infradead.org>
> CommitterDate: Mon, 02 Dec 2024 12:01:43 +01:00
>
> x86: Convert unreachable() to BUG()
>
> Avoid unreachable() as it can (and will in the absence of UBSAN)
> generate fallthrough code. Use BUG() so we get a UD2 trap (with
> unreachable annotation).
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
> Link: https://lore.kernel.org/r/20241128094312.028316261@infradead.org
Urgh, one got lost:
vmlinux.o: warning: objtool: page_fault_oops() falls through to next function is_prefetch()
---
arch/x86/mm/fault.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index e6c469b323cc..ac52255fab01 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -678,7 +678,7 @@ page_fault_oops(struct pt_regs *regs, unsigned long error_code,
ASM_CALL_ARG3,
, [arg1] "r" (regs), [arg2] "r" (address), [arg3] "r" (&info));
- unreachable();
+ BUG();
}
#endif
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [tip: objtool/core] x86/mm: Convert unreachable() to BUG()
2024-12-16 9:32 ` Peter Zijlstra
@ 2024-12-24 9:47 ` tip-bot2 for Peter Zijlstra
0 siblings, 0 replies; 36+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2024-12-24 9:47 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Peter Zijlstra (Intel), x86, linux-kernel
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 41a1e976623eb430f7b5a8619d3810b44e6235ad
Gitweb: https://git.kernel.org/tip/41a1e976623eb430f7b5a8619d3810b44e6235ad
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Mon, 16 Dec 2024 11:08:12 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 17 Dec 2024 17:47:21 +01:00
x86/mm: Convert unreachable() to BUG()
Commit 2190966fbc14 ("x86: Convert unreachable() to BUG()") missed
one.
And after commit 06e24745985c ("objtool: Remove
annotate_{,un}reachable()") the invalid use of unreachable()
(rightfully) triggers warnings:
vmlinux.o: warning: objtool: page_fault_oops() falls through to next function is_prefetch()
Fixes: 2190966fbc14 ("x86: Convert unreachable() to BUG()")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20241216093215.GD12338@noisy.programming.kicks-ass.net
---
arch/x86/mm/fault.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index e6c469b..ac52255 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -678,7 +678,7 @@ page_fault_oops(struct pt_regs *regs, unsigned long error_code,
ASM_CALL_ARG3,
, [arg1] "r" (regs), [arg2] "r" (address), [arg3] "r" (&info));
- unreachable();
+ BUG();
}
#endif
^ permalink raw reply related [flat|nested] 36+ messages in thread
end of thread, other threads:[~2024-12-24 9:47 UTC | newest]
Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-28 9:38 [PATCH v2 00/16] objtool: Rewrite annotations Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 01/16] objtool: Generic annotation infrastructure Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 02/16] objtool: Convert ANNOTATE_NOENDBR to ANNOTATE Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 03/16] objtool: Convert ANNOTATE_RETPOLINE_SAFE " Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 04/16] objtool: Convert instrumentation_{begin,end}() " Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 05/16] objtool: Convert VALIDATE_UNRET_BEGIN " Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 06/16] objtool: Convert ANNOTATE_IGNORE_ALTERNATIVE " Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 07/16] objtool: Convert ANNOTATE_INTRA_FUNCTION_CALL " Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 08/16] objtool: Collapse annotate sequences Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 09/16] objtool: Collect more annotations in objtool.h Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 10/16] unreachable: Unify Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 11/16] x86: Convert unreachable() to BUG() Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-12-16 9:32 ` Peter Zijlstra
2024-12-24 9:47 ` [tip: objtool/core] x86/mm: " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 12/16] loongarch: Use ASM_REACHABLE Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 13/16] objtool: Remove annotate_{,un}reachable() Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 14/16] objtool: Convert {.UN}REACHABLE to ANNOTATE Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 15/16] objtool: Fix ANNOTATE_REACHABLE to be a normal annotation Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 16/16] objtool: Warn about unknown annotation types Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 18:44 ` [PATCH v2 00/16] objtool: Rewrite annotations Josh Poimboeuf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox