* [PATCH] compiler.h: Fix annotation macro misplacement with Clang
@ 2021-11-08 22:35 Josh Poimboeuf
2021-12-22 9:10 ` [tip: objtool/urgent] " tip-bot2 for Josh Poimboeuf
0 siblings, 1 reply; 3+ messages in thread
From: Josh Poimboeuf @ 2021-11-08 22:35 UTC (permalink / raw)
To: x86
Cc: linux-kernel, Vasily Gorbik, Peter Zijlstra, Miroslav Benes,
kernel test robot
When building with Clang and CONFIG_TRACE_BRANCH_PROFILING, there are a
lot of unreachable warnings, like:
arch/x86/kernel/traps.o: warning: objtool: handle_xfd_event()+0x134: unreachable instruction
Without an input to the inline asm, 'volatile' is ignored for some
reason and Clang feels free to move the reachable() annotation away from
its intended location.
Fix that by re-adding the counter value to the inputs.
Fixes: f1069a8756b9 ("compiler.h: Avoid using inline asm operand modifiers")
Fixes: c199f64ff93c ("instrumentation.h: Avoid using inline asm operand modifiers")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
include/linux/compiler.h | 4 ++--
include/linux/instrumentation.h | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 3d5af56337bd..429dcebe2b99 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -121,7 +121,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
asm volatile(__stringify_label(c) ":\n\t" \
".pushsection .discard.reachable\n\t" \
".long " __stringify_label(c) "b - .\n\t" \
- ".popsection\n\t"); \
+ ".popsection\n\t" : : "i" (c)); \
})
#define annotate_reachable() __annotate_reachable(__COUNTER__)
@@ -129,7 +129,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
asm volatile(__stringify_label(c) ":\n\t" \
".pushsection .discard.unreachable\n\t" \
".long " __stringify_label(c) "b - .\n\t" \
- ".popsection\n\t"); \
+ ".popsection\n\t" : : "i" (c)); \
})
#define annotate_unreachable() __annotate_unreachable(__COUNTER__)
diff --git a/include/linux/instrumentation.h b/include/linux/instrumentation.h
index fa2cd8c63dcc..24359b4a9605 100644
--- a/include/linux/instrumentation.h
+++ b/include/linux/instrumentation.h
@@ -11,7 +11,7 @@
asm volatile(__stringify(c) ": nop\n\t" \
".pushsection .discard.instr_begin\n\t" \
".long " __stringify(c) "b - .\n\t" \
- ".popsection\n\t"); \
+ ".popsection\n\t" : : "i" (c)); \
})
#define instrumentation_begin() __instrumentation_begin(__COUNTER__)
@@ -50,7 +50,7 @@
asm volatile(__stringify(c) ": nop\n\t" \
".pushsection .discard.instr_end\n\t" \
".long " __stringify(c) "b - .\n\t" \
- ".popsection\n\t"); \
+ ".popsection\n\t" : : "i" (c)); \
})
#define instrumentation_end() __instrumentation_end(__COUNTER__)
#else
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* [tip: objtool/urgent] compiler.h: Fix annotation macro misplacement with Clang
2021-11-08 22:35 [PATCH] compiler.h: Fix annotation macro misplacement with Clang Josh Poimboeuf
@ 2021-12-22 9:10 ` tip-bot2 for Josh Poimboeuf
2022-01-03 17:58 ` Borislav Petkov
0 siblings, 1 reply; 3+ messages in thread
From: tip-bot2 for Josh Poimboeuf @ 2021-12-22 9:10 UTC (permalink / raw)
To: linux-tip-commits
Cc: kernel test robot, Josh Poimboeuf, Peter Zijlstra, x86,
Vasily Gorbik, Miroslav Benes, linux-kernel
The following commit has been merged into the objtool/urgent branch of tip:
Commit-ID: dcce50e6cc4d86a63dc0a9a6ee7d4f948ccd53a1
Gitweb: https://git.kernel.org/tip/dcce50e6cc4d86a63dc0a9a6ee7d4f948ccd53a1
Author: Josh Poimboeuf <jpoimboe@redhat.com>
AuthorDate: Mon, 08 Nov 2021 14:35:59 -08:00
Committer: Josh Poimboeuf <jpoimboe@redhat.com>
CommitterDate: Tue, 21 Dec 2021 15:09:46 -08:00
compiler.h: Fix annotation macro misplacement with Clang
When building with Clang and CONFIG_TRACE_BRANCH_PROFILING, there are a
lot of unreachable warnings, like:
arch/x86/kernel/traps.o: warning: objtool: handle_xfd_event()+0x134: unreachable instruction
Without an input to the inline asm, 'volatile' is ignored for some
reason and Clang feels free to move the reachable() annotation away from
its intended location.
Fix that by re-adding the counter value to the inputs.
Fixes: f1069a8756b9 ("compiler.h: Avoid using inline asm operand modifiers")
Fixes: c199f64ff93c ("instrumentation.h: Avoid using inline asm operand modifiers")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/0417e96909b97a406323409210de7bf13df0b170.1636410380.git.jpoimboe@redhat.com
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: x86@kernel.org
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Miroslav Benes <mbenes@suse.cz>
---
include/linux/compiler.h | 4 ++--
include/linux/instrumentation.h | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 3d5af56..429dceb 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -121,7 +121,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
asm volatile(__stringify_label(c) ":\n\t" \
".pushsection .discard.reachable\n\t" \
".long " __stringify_label(c) "b - .\n\t" \
- ".popsection\n\t"); \
+ ".popsection\n\t" : : "i" (c)); \
})
#define annotate_reachable() __annotate_reachable(__COUNTER__)
@@ -129,7 +129,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
asm volatile(__stringify_label(c) ":\n\t" \
".pushsection .discard.unreachable\n\t" \
".long " __stringify_label(c) "b - .\n\t" \
- ".popsection\n\t"); \
+ ".popsection\n\t" : : "i" (c)); \
})
#define annotate_unreachable() __annotate_unreachable(__COUNTER__)
diff --git a/include/linux/instrumentation.h b/include/linux/instrumentation.h
index fa2cd8c..24359b4 100644
--- a/include/linux/instrumentation.h
+++ b/include/linux/instrumentation.h
@@ -11,7 +11,7 @@
asm volatile(__stringify(c) ": nop\n\t" \
".pushsection .discard.instr_begin\n\t" \
".long " __stringify(c) "b - .\n\t" \
- ".popsection\n\t"); \
+ ".popsection\n\t" : : "i" (c)); \
})
#define instrumentation_begin() __instrumentation_begin(__COUNTER__)
@@ -50,7 +50,7 @@
asm volatile(__stringify(c) ": nop\n\t" \
".pushsection .discard.instr_end\n\t" \
".long " __stringify(c) "b - .\n\t" \
- ".popsection\n\t"); \
+ ".popsection\n\t" : : "i" (c)); \
})
#define instrumentation_end() __instrumentation_end(__COUNTER__)
#else
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [tip: objtool/urgent] compiler.h: Fix annotation macro misplacement with Clang
2021-12-22 9:10 ` [tip: objtool/urgent] " tip-bot2 for Josh Poimboeuf
@ 2022-01-03 17:58 ` Borislav Petkov
0 siblings, 0 replies; 3+ messages in thread
From: Borislav Petkov @ 2022-01-03 17:58 UTC (permalink / raw)
To: llvm
Cc: Josh Poimboeuf, linux-tip-commits, kernel test robot,
Peter Zijlstra, x86, Vasily Gorbik, Miroslav Benes, linux-kernel
I wonder if clang folks have seen this and perhaps have a comment as to
why the volatile gets ingored... Added.
On Wed, Dec 22, 2021 at 09:10:30AM -0000, tip-bot2 for Josh Poimboeuf wrote:
> The following commit has been merged into the objtool/urgent branch of tip:
>
> Commit-ID: dcce50e6cc4d86a63dc0a9a6ee7d4f948ccd53a1
> Gitweb: https://git.kernel.org/tip/dcce50e6cc4d86a63dc0a9a6ee7d4f948ccd53a1
> Author: Josh Poimboeuf <jpoimboe@redhat.com>
> AuthorDate: Mon, 08 Nov 2021 14:35:59 -08:00
> Committer: Josh Poimboeuf <jpoimboe@redhat.com>
> CommitterDate: Tue, 21 Dec 2021 15:09:46 -08:00
>
> compiler.h: Fix annotation macro misplacement with Clang
>
> When building with Clang and CONFIG_TRACE_BRANCH_PROFILING, there are a
> lot of unreachable warnings, like:
>
> arch/x86/kernel/traps.o: warning: objtool: handle_xfd_event()+0x134: unreachable instruction
>
> Without an input to the inline asm, 'volatile' is ignored for some
> reason and Clang feels free to move the reachable() annotation away from
> its intended location.
>
> Fix that by re-adding the counter value to the inputs.
>
> Fixes: f1069a8756b9 ("compiler.h: Avoid using inline asm operand modifiers")
> Fixes: c199f64ff93c ("instrumentation.h: Avoid using inline asm operand modifiers")
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
> Link: https://lore.kernel.org/r/0417e96909b97a406323409210de7bf13df0b170.1636410380.git.jpoimboe@redhat.com
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: x86@kernel.org
> Cc: Vasily Gorbik <gor@linux.ibm.com>
> Cc: Miroslav Benes <mbenes@suse.cz>
> ---
> include/linux/compiler.h | 4 ++--
> include/linux/instrumentation.h | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/compiler.h b/include/linux/compiler.h
> index 3d5af56..429dceb 100644
> --- a/include/linux/compiler.h
> +++ b/include/linux/compiler.h
> @@ -121,7 +121,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
> asm volatile(__stringify_label(c) ":\n\t" \
> ".pushsection .discard.reachable\n\t" \
> ".long " __stringify_label(c) "b - .\n\t" \
> - ".popsection\n\t"); \
> + ".popsection\n\t" : : "i" (c)); \
> })
> #define annotate_reachable() __annotate_reachable(__COUNTER__)
>
> @@ -129,7 +129,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
> asm volatile(__stringify_label(c) ":\n\t" \
> ".pushsection .discard.unreachable\n\t" \
> ".long " __stringify_label(c) "b - .\n\t" \
> - ".popsection\n\t"); \
> + ".popsection\n\t" : : "i" (c)); \
> })
> #define annotate_unreachable() __annotate_unreachable(__COUNTER__)
>
> diff --git a/include/linux/instrumentation.h b/include/linux/instrumentation.h
> index fa2cd8c..24359b4 100644
> --- a/include/linux/instrumentation.h
> +++ b/include/linux/instrumentation.h
> @@ -11,7 +11,7 @@
> asm volatile(__stringify(c) ": nop\n\t" \
> ".pushsection .discard.instr_begin\n\t" \
> ".long " __stringify(c) "b - .\n\t" \
> - ".popsection\n\t"); \
> + ".popsection\n\t" : : "i" (c)); \
> })
> #define instrumentation_begin() __instrumentation_begin(__COUNTER__)
>
> @@ -50,7 +50,7 @@
> asm volatile(__stringify(c) ": nop\n\t" \
> ".pushsection .discard.instr_end\n\t" \
> ".long " __stringify(c) "b - .\n\t" \
> - ".popsection\n\t"); \
> + ".popsection\n\t" : : "i" (c)); \
> })
> #define instrumentation_end() __instrumentation_end(__COUNTER__)
> #else
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-03 17:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-08 22:35 [PATCH] compiler.h: Fix annotation macro misplacement with Clang Josh Poimboeuf
2021-12-22 9:10 ` [tip: objtool/urgent] " tip-bot2 for Josh Poimboeuf
2022-01-03 17:58 ` Borislav Petkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox