* [RFC][PATCH 0/2] x86: ASM based __bug_table and rethunks
@ 2024-10-07 8:32 Peter Zijlstra
2024-10-07 8:32 ` [RFC][PATCH 1/2] x86: Provide assembly __bug_table helpers Peter Zijlstra
2024-10-07 8:32 ` [RFC][PATCH 2/2] x86: Clean up default rethunk warning Peter Zijlstra
0 siblings, 2 replies; 12+ messages in thread
From: Peter Zijlstra @ 2024-10-07 8:32 UTC (permalink / raw)
To: bp, david.kaplan, jpoimboe; +Cc: linux-kernel, peterz, x86
Hi,
I ran into the __warn_thunk_thunk_thunk_thunk thing and urgh.
Make it a 'simple' WARN_ON_ONCE(). And since all of x86_64 has the same rewrite
rules, simplify the ifdeffery madness too.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [RFC][PATCH 1/2] x86: Provide assembly __bug_table helpers
2024-10-07 8:32 [RFC][PATCH 0/2] x86: ASM based __bug_table and rethunks Peter Zijlstra
@ 2024-10-07 8:32 ` Peter Zijlstra
2024-10-07 17:21 ` Josh Poimboeuf
2024-10-23 11:22 ` Borislav Petkov
2024-10-07 8:32 ` [RFC][PATCH 2/2] x86: Clean up default rethunk warning Peter Zijlstra
1 sibling, 2 replies; 12+ messages in thread
From: Peter Zijlstra @ 2024-10-07 8:32 UTC (permalink / raw)
To: bp, david.kaplan, jpoimboe; +Cc: linux-kernel, peterz, x86
Rework the __bug_table helpers such that usage from assembly becomes
possible.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/x86/include/asm/bug.h | 50 ++++++++++++++++++---------------------------
1 file changed, 21 insertions(+), 29 deletions(-)
--- a/arch/x86/include/asm/bug.h
+++ b/arch/x86/include/asm/bug.h
@@ -28,46 +28,38 @@
#ifdef CONFIG_GENERIC_BUG
#ifdef CONFIG_X86_32
-# define __BUG_REL(val) ".long " __stringify(val)
+#define ASM_BUG_REL(val) .long val
#else
-# define __BUG_REL(val) ".long " __stringify(val) " - ."
+#define ASM_BUG_REL(val) .long val - .
#endif
#ifdef CONFIG_DEBUG_BUGVERBOSE
+#define ASM_BUGTABLE_VERBOSE(file, line) \
+ ASM_BUG_REL(file) ; \
+ .word line
+#define ASM_BUGTABLE_VERBOSE_SIZE 6
+#else
+#define ASM_BUGTABLE_VERBOSE(file, line)
+#define ASM_BUGTABLE_VERBOSE_SIZE 0
+#endif
-#define _BUG_FLAGS(ins, flags, extra) \
-do { \
- asm_inline volatile("1:\t" ins "\n" \
- ".pushsection __bug_table,\"aw\"\n" \
- "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \
- "\t" __BUG_REL(%c0) "\t# bug_entry::file\n" \
- "\t.word %c1" "\t# bug_entry::line\n" \
- "\t.word %c2" "\t# bug_entry::flags\n" \
- "\t.org 2b+%c3\n" \
- ".popsection\n" \
- extra \
- : : "i" (__FILE__), "i" (__LINE__), \
- "i" (flags), \
- "i" (sizeof(struct bug_entry))); \
-} while (0)
-
-#else /* !CONFIG_DEBUG_BUGVERBOSE */
+#define ASM_BUGTABLE_FLAGS(at, file, line, flags) \
+ .pushsection __bug_table, "aw" ; \
+ 123: ASM_BUG_REL(at) ; \
+ ASM_BUGTABLE_VERBOSE(file, line) ; \
+ .word flags ; \
+ .org 123b + 6 + ASM_BUGTABLE_VERBOSE_SIZE ; \
+ .popsection
#define _BUG_FLAGS(ins, flags, extra) \
do { \
asm_inline volatile("1:\t" ins "\n" \
- ".pushsection __bug_table,\"aw\"\n" \
- "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \
- "\t.word %c0" "\t# bug_entry::flags\n" \
- "\t.org 2b+%c1\n" \
- ".popsection\n" \
- extra \
- : : "i" (flags), \
- "i" (sizeof(struct bug_entry))); \
+ __stringify(ASM_BUGTABLE_FLAGS(1b, %c0, %c1, %c2)) "\n" \
+ extra \
+ : : "i" (__FILE__), "i" (__LINE__), \
+ "i" (flags)); \
} while (0)
-#endif /* CONFIG_DEBUG_BUGVERBOSE */
-
#else
#define _BUG_FLAGS(ins, flags, extra) asm volatile(ins)
^ permalink raw reply [flat|nested] 12+ messages in thread
* [RFC][PATCH 2/2] x86: Clean up default rethunk warning
2024-10-07 8:32 [RFC][PATCH 0/2] x86: ASM based __bug_table and rethunks Peter Zijlstra
2024-10-07 8:32 ` [RFC][PATCH 1/2] x86: Provide assembly __bug_table helpers Peter Zijlstra
@ 2024-10-07 8:32 ` Peter Zijlstra
2024-10-07 17:33 ` Josh Poimboeuf
2024-11-04 11:47 ` Borislav Petkov
1 sibling, 2 replies; 12+ messages in thread
From: Peter Zijlstra @ 2024-10-07 8:32 UTC (permalink / raw)
To: bp, david.kaplan, jpoimboe; +Cc: linux-kernel, peterz, x86
Replace the funny __warn_thunk thing with a more regular
WARN_ON_ONCE(), and simplify the ifdeffery.
Notably this avoids RET from having recursive RETs (once from the
thunk and once from the C function) -- recursive RET makes my head
hurt for no good reason.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/x86/entry/entry.S | 3 ---
arch/x86/include/asm/nospec-branch.h | 2 --
arch/x86/kernel/cpu/bugs.c | 5 -----
arch/x86/lib/retpoline.S | 20 ++++++++++++--------
4 files changed, 12 insertions(+), 18 deletions(-)
--- a/arch/x86/entry/entry.S
+++ b/arch/x86/entry/entry.S
@@ -10,8 +10,6 @@
#include <asm/segment.h>
#include <asm/cache.h>
-#include "calling.h"
-
.pushsection .noinstr.text, "ax"
SYM_FUNC_START(entry_ibpb)
@@ -45,4 +43,3 @@ EXPORT_SYMBOL_GPL(mds_verw_sel);
.popsection
-THUNK warn_thunk_thunk, __warn_thunk
--- a/arch/x86/include/asm/nospec-branch.h
+++ b/arch/x86/include/asm/nospec-branch.h
@@ -387,8 +387,6 @@ extern void clear_bhb_loop(void);
extern void (*x86_return_thunk)(void);
-extern void __warn_thunk(void);
-
#ifdef CONFIG_MITIGATION_CALL_DEPTH_TRACKING
extern void call_depth_return_thunk(void);
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -3025,8 +3025,3 @@ ssize_t cpu_show_reg_file_data_sampling(
return cpu_show_common(dev, attr, buf, X86_BUG_RFDS);
}
#endif
-
-void __warn_thunk(void)
-{
- WARN_ONCE(1, "Unpatched return thunk in use. This should not happen!\n");
-}
--- a/arch/x86/lib/retpoline.S
+++ b/arch/x86/lib/retpoline.S
@@ -12,9 +12,14 @@
#include <asm/percpu.h>
#include <asm/frame.h>
#include <asm/nops.h>
+#include <asm/bug.h>
- .section .text..__x86.indirect_thunk
+#define WARN_ONCE \
+ 1: ALTERNATIVE "", "ud2", X86_FEATURE_ALWAYS ; \
+ ASM_BUGTABLE_FLAGS(1b, 0, 0, BUGFLAG_WARNING | BUGFLAG_ONCE) ; \
+ REACHABLE
+ .section .text..__x86.indirect_thunk
.macro POLINE reg
ANNOTATE_INTRA_FUNCTION_CALL
@@ -382,16 +387,15 @@ SYM_FUNC_END(call_depth_return_thunk)
SYM_CODE_START(__x86_return_thunk)
UNWIND_HINT_FUNC
ANNOTATE_NOENDBR
-#if defined(CONFIG_MITIGATION_UNRET_ENTRY) || \
- defined(CONFIG_MITIGATION_SRSO) || \
- defined(CONFIG_MITIGATION_CALL_DEPTH_TRACKING)
- ALTERNATIVE __stringify(ANNOTATE_UNRET_SAFE; ret), \
- "jmp warn_thunk_thunk", X86_FEATURE_ALWAYS
-#else
+
+#ifdef CONFIG_X86_64
+ WARN_ONCE
+#endif
+
ANNOTATE_UNRET_SAFE
ret
-#endif
int3
+
SYM_CODE_END(__x86_return_thunk)
EXPORT_SYMBOL(__x86_return_thunk)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC][PATCH 1/2] x86: Provide assembly __bug_table helpers
2024-10-07 8:32 ` [RFC][PATCH 1/2] x86: Provide assembly __bug_table helpers Peter Zijlstra
@ 2024-10-07 17:21 ` Josh Poimboeuf
2024-10-23 11:22 ` Borislav Petkov
1 sibling, 0 replies; 12+ messages in thread
From: Josh Poimboeuf @ 2024-10-07 17:21 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: bp, david.kaplan, linux-kernel, x86
On Mon, Oct 07, 2024 at 10:32:11AM +0200, Peter Zijlstra wrote:
> +#define ASM_BUGTABLE_FLAGS(at, file, line, flags) \
> + .pushsection __bug_table, "aw" ; \
> + 123: ASM_BUG_REL(at) ; \
> + ASM_BUGTABLE_VERBOSE(file, line) ; \
> + .word flags ; \
> + .org 123b + 6 + ASM_BUGTABLE_VERBOSE_SIZE ; \
^
should be a tab?
Nice cleanup!
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
--
Josh
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC][PATCH 2/2] x86: Clean up default rethunk warning
2024-10-07 8:32 ` [RFC][PATCH 2/2] x86: Clean up default rethunk warning Peter Zijlstra
@ 2024-10-07 17:33 ` Josh Poimboeuf
2024-10-08 7:25 ` Peter Zijlstra
2024-11-04 11:47 ` Borislav Petkov
1 sibling, 1 reply; 12+ messages in thread
From: Josh Poimboeuf @ 2024-10-07 17:33 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: bp, david.kaplan, linux-kernel, x86
On Mon, Oct 07, 2024 at 10:32:12AM +0200, Peter Zijlstra wrote:
> Replace the funny __warn_thunk thing with a more regular
> WARN_ON_ONCE(), and simplify the ifdeffery.
>
> Notably this avoids RET from having recursive RETs (once from the
> thunk and once from the C function) -- recursive RET makes my head
> hurt for no good reason.
This could use an explanation for why the ifdefs can be removed and why
the alternative can be removed.
> +#define WARN_ONCE \
> + 1: ALTERNATIVE "", "ud2", X86_FEATURE_ALWAYS ; \
> + ASM_BUGTABLE_FLAGS(1b, 0, 0, BUGFLAG_WARNING | BUGFLAG_ONCE) ; \
> + REACHABLE
Can we not use __FILE__ and __LINE__ here? Also why not put this in
asm/bug.h?
> SYM_CODE_START(__x86_return_thunk)
> UNWIND_HINT_FUNC
> ANNOTATE_NOENDBR
> -#if defined(CONFIG_MITIGATION_UNRET_ENTRY) || \
> - defined(CONFIG_MITIGATION_SRSO) || \
> - defined(CONFIG_MITIGATION_CALL_DEPTH_TRACKING)
> - ALTERNATIVE __stringify(ANNOTATE_UNRET_SAFE; ret), \
> - "jmp warn_thunk_thunk", X86_FEATURE_ALWAYS
> -#else
> +
> +#ifdef CONFIG_X86_64
> + WARN_ONCE
> +#endif
Isn't this return thunk used before apply_returns()? How does that not
trigger the warning?
--
Josh
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC][PATCH 2/2] x86: Clean up default rethunk warning
2024-10-07 17:33 ` Josh Poimboeuf
@ 2024-10-08 7:25 ` Peter Zijlstra
2024-10-08 16:45 ` Josh Poimboeuf
0 siblings, 1 reply; 12+ messages in thread
From: Peter Zijlstra @ 2024-10-08 7:25 UTC (permalink / raw)
To: Josh Poimboeuf; +Cc: bp, david.kaplan, linux-kernel, x86
On Mon, Oct 07, 2024 at 10:33:45AM -0700, Josh Poimboeuf wrote:
> On Mon, Oct 07, 2024 at 10:32:12AM +0200, Peter Zijlstra wrote:
> > Replace the funny __warn_thunk thing with a more regular
> > WARN_ON_ONCE(), and simplify the ifdeffery.
> >
> > Notably this avoids RET from having recursive RETs (once from the
> > thunk and once from the C function) -- recursive RET makes my head
> > hurt for no good reason.
>
> This could use an explanation for why the ifdefs can be removed and why
> the alternative can be removed.
The alternative is in the WARN_ONCE now.
> > +#define WARN_ONCE \
> > + 1: ALTERNATIVE "", "ud2", X86_FEATURE_ALWAYS ; \
> > + ASM_BUGTABLE_FLAGS(1b, 0, 0, BUGFLAG_WARNING | BUGFLAG_ONCE) ; \
> > + REACHABLE
>
> Can we not use __FILE__ and __LINE__ here?
Because for asm, __FILE__ is spelled like:
#ifdef CONFIG_DEBUG_BUGVERBOSE
.pushsection .rodata.str1.1, "aMS",@progbits,1
.LC0:
.string __FILE__
.popsection
#endif
1: ALTERNATIVE "", "ud2", X86_FEATURE_ALWAYS
ASM_BUGTABLE_FLAGS(1b, LC0b, __LINE__, BUGFLAG_WARNING | BUGFLAG_ONCE)
REACHABLE
And I didn't feel the whole thing was worth the trouble, if NULL bug
will only print the symbol name and that should be clear enough.
> Also why not put this in asm/bug.h?
Because the ALTERNATIVE..
> > SYM_CODE_START(__x86_return_thunk)
> > UNWIND_HINT_FUNC
> > ANNOTATE_NOENDBR
> > -#if defined(CONFIG_MITIGATION_UNRET_ENTRY) || \
> > - defined(CONFIG_MITIGATION_SRSO) || \
> > - defined(CONFIG_MITIGATION_CALL_DEPTH_TRACKING)
> > - ALTERNATIVE __stringify(ANNOTATE_UNRET_SAFE; ret), \
> > - "jmp warn_thunk_thunk", X86_FEATURE_ALWAYS
> > -#else
> > +
> > +#ifdef CONFIG_X86_64
> > + WARN_ONCE
> > +#endif
>
> Isn't this return thunk used before apply_returns()? How does that not
> trigger the warning?
You missed the ALTERNATIVE I squirreled away in the WARN thing :-)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC][PATCH 2/2] x86: Clean up default rethunk warning
2024-10-08 7:25 ` Peter Zijlstra
@ 2024-10-08 16:45 ` Josh Poimboeuf
2024-10-09 7:59 ` Peter Zijlstra
0 siblings, 1 reply; 12+ messages in thread
From: Josh Poimboeuf @ 2024-10-08 16:45 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: bp, david.kaplan, linux-kernel, x86
On Tue, Oct 08, 2024 at 09:25:02AM +0200, Peter Zijlstra wrote:
> On Mon, Oct 07, 2024 at 10:33:45AM -0700, Josh Poimboeuf wrote:
> > On Mon, Oct 07, 2024 at 10:32:12AM +0200, Peter Zijlstra wrote:
> > > Replace the funny __warn_thunk thing with a more regular
> > > WARN_ON_ONCE(), and simplify the ifdeffery.
> > >
> > > Notably this avoids RET from having recursive RETs (once from the
> > > thunk and once from the C function) -- recursive RET makes my head
> > > hurt for no good reason.
> >
> > This could use an explanation for why the ifdefs can be removed and why
> > the alternative can be removed.
>
> The alternative is in the WARN_ONCE now.
Ah, sneaky... It should really be called WARN_ONCE_AFTER_ALTERNATIVES or
something.
--
Josh
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC][PATCH 2/2] x86: Clean up default rethunk warning
2024-10-08 16:45 ` Josh Poimboeuf
@ 2024-10-09 7:59 ` Peter Zijlstra
0 siblings, 0 replies; 12+ messages in thread
From: Peter Zijlstra @ 2024-10-09 7:59 UTC (permalink / raw)
To: Josh Poimboeuf; +Cc: bp, david.kaplan, linux-kernel, x86
On Tue, Oct 08, 2024 at 09:45:14AM -0700, Josh Poimboeuf wrote:
> On Tue, Oct 08, 2024 at 09:25:02AM +0200, Peter Zijlstra wrote:
> > On Mon, Oct 07, 2024 at 10:33:45AM -0700, Josh Poimboeuf wrote:
> > > On Mon, Oct 07, 2024 at 10:32:12AM +0200, Peter Zijlstra wrote:
> > > > Replace the funny __warn_thunk thing with a more regular
> > > > WARN_ON_ONCE(), and simplify the ifdeffery.
> > > >
> > > > Notably this avoids RET from having recursive RETs (once from the
> > > > thunk and once from the C function) -- recursive RET makes my head
> > > > hurt for no good reason.
> > >
> > > This could use an explanation for why the ifdefs can be removed and why
> > > the alternative can be removed.
> >
> > The alternative is in the WARN_ONCE now.
>
> Ah, sneaky... It should really be called WARN_ONCE_AFTER_ALTERNATIVES or
> something.
Yeah, I suppose it should.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC][PATCH 1/2] x86: Provide assembly __bug_table helpers
2024-10-07 8:32 ` [RFC][PATCH 1/2] x86: Provide assembly __bug_table helpers Peter Zijlstra
2024-10-07 17:21 ` Josh Poimboeuf
@ 2024-10-23 11:22 ` Borislav Petkov
1 sibling, 0 replies; 12+ messages in thread
From: Borislav Petkov @ 2024-10-23 11:22 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: david.kaplan, jpoimboe, linux-kernel, x86
On Mon, Oct 07, 2024 at 10:32:11AM +0200, Peter Zijlstra wrote:
> +#define ASM_BUGTABLE_FLAGS(at, file, line, flags) \
> + .pushsection __bug_table, "aw" ; \
> + 123: ASM_BUG_REL(at) ; \
> + ASM_BUGTABLE_VERBOSE(file, line) ; \
> + .word flags ; \
> + .org 123b + 6 + ASM_BUGTABLE_VERBOSE_SIZE ; \
I'm guessing this second 6 is the sizeof(long + word) of the second two?
I.e., in here:
asm __inline volatile("1:\t" ".byte 0x0f, 0x0b" "\n"
".pushsection __bug_table, \"aw\" ;
123:
.long 1b - . ;
.long %c0 - . ;
^^^^^^^^^^^^^
.word %c1 ;
.word %c2 ;
^^^^^^^^^^
.org 123b + 6 + 6 ;
.popsection" "\n" ""
Can we add a define for it too instead of a naked 6?
> + .popsection
>
> #define _BUG_FLAGS(ins, flags, extra) \
> do { \
> asm_inline volatile("1:\t" ins "\n" \
s/ins/insn/ while at it.
The usual abbreviation for an "instruction".
> - ".pushsection __bug_table,\"aw\"\n" \
> - "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \
> - "\t.word %c0" "\t# bug_entry::flags\n" \
> - "\t.org 2b+%c1\n" \
> - ".popsection\n" \
> - extra \
> - : : "i" (flags), \
> - "i" (sizeof(struct bug_entry))); \
> + __stringify(ASM_BUGTABLE_FLAGS(1b, %c0, %c1, %c2)) "\n" \
> + extra \
> + : : "i" (__FILE__), "i" (__LINE__), \
> + "i" (flags)); \
> } while (0)
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC][PATCH 2/2] x86: Clean up default rethunk warning
2024-10-07 8:32 ` [RFC][PATCH 2/2] x86: Clean up default rethunk warning Peter Zijlstra
2024-10-07 17:33 ` Josh Poimboeuf
@ 2024-11-04 11:47 ` Borislav Petkov
2024-11-04 14:29 ` Peter Zijlstra
1 sibling, 1 reply; 12+ messages in thread
From: Borislav Petkov @ 2024-11-04 11:47 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: david.kaplan, jpoimboe, linux-kernel, x86
On Mon, Oct 07, 2024 at 10:32:12AM +0200, Peter Zijlstra wrote:
> - .section .text..__x86.indirect_thunk
> +#define WARN_ONCE \
This should be in the asm section of arch/x86/include/asm/bug.h so that other
asm code can use it. It will come in handy...
> + 1: ALTERNATIVE "", "ud2", X86_FEATURE_ALWAYS ; \
... but uff, you can't because of this ALTERNATIVE. This is a conditional
WARN_ONCE. Yuck.
I guess ALT_WARN_ONCE or so...
> + ASM_BUGTABLE_FLAGS(1b, 0, 0, BUGFLAG_WARNING | BUGFLAG_ONCE) ; \
> + REACHABLE
>
> + .section .text..__x86.indirect_thunk
>
> .macro POLINE reg
> ANNOTATE_INTRA_FUNCTION_CALL
> @@ -382,16 +387,15 @@ SYM_FUNC_END(call_depth_return_thunk)
> SYM_CODE_START(__x86_return_thunk)
> UNWIND_HINT_FUNC
> ANNOTATE_NOENDBR
> -#if defined(CONFIG_MITIGATION_UNRET_ENTRY) || \
> - defined(CONFIG_MITIGATION_SRSO) || \
> - defined(CONFIG_MITIGATION_CALL_DEPTH_TRACKING)
> - ALTERNATIVE __stringify(ANNOTATE_UNRET_SAFE; ret), \
> - "jmp warn_thunk_thunk", X86_FEATURE_ALWAYS
> -#else
> +
> +#ifdef CONFIG_X86_64
> + WARN_ONCE
> +#endif
And you can add an empty 32-bit WARN_ONCE macro so that we don't have this
ifdeffery here where ifdeffery gives the last drop of making this file totally
unreadable...
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC][PATCH 2/2] x86: Clean up default rethunk warning
2024-11-04 11:47 ` Borislav Petkov
@ 2024-11-04 14:29 ` Peter Zijlstra
2024-11-04 14:39 ` Borislav Petkov
0 siblings, 1 reply; 12+ messages in thread
From: Peter Zijlstra @ 2024-11-04 14:29 UTC (permalink / raw)
To: Borislav Petkov; +Cc: david.kaplan, jpoimboe, linux-kernel, x86
On Mon, Nov 04, 2024 at 12:47:28PM +0100, Borislav Petkov wrote:
> On Mon, Oct 07, 2024 at 10:32:12AM +0200, Peter Zijlstra wrote:
> > - .section .text..__x86.indirect_thunk
> > +#define WARN_ONCE \
>
> This should be in the asm section of arch/x86/include/asm/bug.h so that other
> asm code can use it. It will come in handy...
>
> > + 1: ALTERNATIVE "", "ud2", X86_FEATURE_ALWAYS ; \
>
> ... but uff, you can't because of this ALTERNATIVE. This is a conditional
> WARN_ONCE. Yuck.
>
> I guess ALT_WARN_ONCE or so...
Yeah, Josh already said similar things.
> > + ASM_BUGTABLE_FLAGS(1b, 0, 0, BUGFLAG_WARNING | BUGFLAG_ONCE) ; \
> > + REACHABLE
> >
> > + .section .text..__x86.indirect_thunk
> >
> > .macro POLINE reg
> > ANNOTATE_INTRA_FUNCTION_CALL
> > @@ -382,16 +387,15 @@ SYM_FUNC_END(call_depth_return_thunk)
> > SYM_CODE_START(__x86_return_thunk)
> > UNWIND_HINT_FUNC
> > ANNOTATE_NOENDBR
> > -#if defined(CONFIG_MITIGATION_UNRET_ENTRY) || \
> > - defined(CONFIG_MITIGATION_SRSO) || \
> > - defined(CONFIG_MITIGATION_CALL_DEPTH_TRACKING)
> > - ALTERNATIVE __stringify(ANNOTATE_UNRET_SAFE; ret), \
> > - "jmp warn_thunk_thunk", X86_FEATURE_ALWAYS
> > -#else
> > +
> > +#ifdef CONFIG_X86_64
> > + WARN_ONCE
> > +#endif
>
> And you can add an empty 32-bit WARN_ONCE macro so that we don't have this
> ifdeffery here where ifdeffery gives the last drop of making this file totally
> unreadable...
I just realized all the rethunk crap is 64bit only anyway. So it don't
matter.
But the reason I did this is that we never rewrite thunk calls on 32bit
(really, we should just strip all mitigation shit from it and leave it
to rot).
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC][PATCH 2/2] x86: Clean up default rethunk warning
2024-11-04 14:29 ` Peter Zijlstra
@ 2024-11-04 14:39 ` Borislav Petkov
0 siblings, 0 replies; 12+ messages in thread
From: Borislav Petkov @ 2024-11-04 14:39 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: david.kaplan, jpoimboe, linux-kernel, x86
On Mon, Nov 04, 2024 at 03:29:53PM +0100, Peter Zijlstra wrote:
> I just realized all the rethunk crap is 64bit only anyway. So it don't
> matter.
>
> But the reason I did this is that we never rewrite thunk calls on 32bit
> (really, we should just strip all mitigation shit from it and leave it
> to rot).
Perfectly fine with me.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-11-04 14:40 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-07 8:32 [RFC][PATCH 0/2] x86: ASM based __bug_table and rethunks Peter Zijlstra
2024-10-07 8:32 ` [RFC][PATCH 1/2] x86: Provide assembly __bug_table helpers Peter Zijlstra
2024-10-07 17:21 ` Josh Poimboeuf
2024-10-23 11:22 ` Borislav Petkov
2024-10-07 8:32 ` [RFC][PATCH 2/2] x86: Clean up default rethunk warning Peter Zijlstra
2024-10-07 17:33 ` Josh Poimboeuf
2024-10-08 7:25 ` Peter Zijlstra
2024-10-08 16:45 ` Josh Poimboeuf
2024-10-09 7:59 ` Peter Zijlstra
2024-11-04 11:47 ` Borislav Petkov
2024-11-04 14:29 ` Peter Zijlstra
2024-11-04 14:39 ` Borislav Petkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox