* [PATCH] x86/entry: Fix noinstr warning in __enter_from_user_mode()
@ 2023-02-26 0:01 Josh Poimboeuf
2023-03-20 10:59 ` [tip: core/urgent] entry: " tip-bot2 for Josh Poimboeuf
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Josh Poimboeuf @ 2023-02-26 0:01 UTC (permalink / raw)
To: x86
Cc: Peter Zijlstra, Thomas Gleixner, Frederic Weisbecker,
Paul E . McKenney, Andy Lutomirski, linux-kernel
__enter_from_user_mode() is triggering noinstr warnings with
CONFIG_DEBUG_PREEMPT due to its call of preempt_count_add() via
ct_state().
The preemption disable isn't needed as interrupts are already disabled.
And the context_tracking_enabled() check in ct_state() also isn't needed
as that's already being done by the CT_WARN_ON().
Just use __ct_state() instead.
Fixes the following warnings:
vmlinux.o: warning: objtool: enter_from_user_mode+0xba: call to preempt_count_add() leaves .noinstr.text section
vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0xf9: call to preempt_count_add() leaves .noinstr.text section
vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0xc7: call to preempt_count_add() leaves .noinstr.text section
vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0xba: call to preempt_count_add() leaves .noinstr.text section
Fixes: 171476775d32 ("context_tracking: Convert state to atomic_t")
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
include/linux/context_tracking.h | 1 +
kernel/entry/common.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/linux/context_tracking.h b/include/linux/context_tracking.h
index d4afa8508a80..3a7909ed5498 100644
--- a/include/linux/context_tracking.h
+++ b/include/linux/context_tracking.h
@@ -96,6 +96,7 @@ static inline void user_exit_irqoff(void) { }
static inline int exception_enter(void) { return 0; }
static inline void exception_exit(enum ctx_state prev_ctx) { }
static inline int ct_state(void) { return -1; }
+static inline int __ct_state(void) { return -1; }
static __always_inline bool context_tracking_guest_enter(void) { return false; }
static inline void context_tracking_guest_exit(void) { }
#define CT_WARN_ON(cond) do { } while (0)
diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index 846add8394c4..1314894d2efa 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -21,7 +21,7 @@ static __always_inline void __enter_from_user_mode(struct pt_regs *regs)
arch_enter_from_user_mode(regs);
lockdep_hardirqs_off(CALLER_ADDR0);
- CT_WARN_ON(ct_state() != CONTEXT_USER);
+ CT_WARN_ON(__ct_state() != CONTEXT_USER);
user_exit_irqoff();
instrumentation_begin();
--
2.39.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [tip: core/urgent] entry: Fix noinstr warning in __enter_from_user_mode()
2023-02-26 0:01 [PATCH] x86/entry: Fix noinstr warning in __enter_from_user_mode() Josh Poimboeuf
@ 2023-03-20 10:59 ` tip-bot2 for Josh Poimboeuf
2023-03-21 9:08 ` [PATCH] x86/entry: " Thomas Gleixner
2023-03-21 10:54 ` [tip: core/urgent] entry: " tip-bot2 for Josh Poimboeuf
2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Josh Poimboeuf @ 2023-03-20 10:59 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Josh Poimboeuf, Thomas Gleixner, x86, linux-kernel
The following commit has been merged into the core/urgent branch of tip:
Commit-ID: 3e2619c4ebba2cab8414c55b131b7a28f628de3b
Gitweb: https://git.kernel.org/tip/3e2619c4ebba2cab8414c55b131b7a28f628de3b
Author: Josh Poimboeuf <jpoimboe@kernel.org>
AuthorDate: Sat, 25 Feb 2023 16:01:36 -08:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Mon, 20 Mar 2023 11:57:12 +01:00
entry: Fix noinstr warning in __enter_from_user_mode()
__enter_from_user_mode() is triggering noinstr warnings with
CONFIG_DEBUG_PREEMPT due to its call of preempt_count_add() via
ct_state().
The preemption disable isn't needed as interrupts are already disabled.
And the context_tracking_enabled() check in ct_state() also isn't needed
as that's already being done by the CT_WARN_ON().
Just use __ct_state() instead.
Fixes the following warnings:
vmlinux.o: warning: objtool: enter_from_user_mode+0xba: call to preempt_count_add() leaves .noinstr.text section
vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0xf9: call to preempt_count_add() leaves .noinstr.text section
vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0xc7: call to preempt_count_add() leaves .noinstr.text section
vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0xba: call to preempt_count_add() leaves .noinstr.text section
Fixes: 171476775d32 ("context_tracking: Convert state to atomic_t")
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/d8955fa6d68dc955dda19baf13ae014ae27926f5.1677369694.git.jpoimboe@kernel.org
---
include/linux/context_tracking.h | 1 +
kernel/entry/common.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/linux/context_tracking.h b/include/linux/context_tracking.h
index d4afa85..3a7909e 100644
--- a/include/linux/context_tracking.h
+++ b/include/linux/context_tracking.h
@@ -96,6 +96,7 @@ static inline void user_exit_irqoff(void) { }
static inline int exception_enter(void) { return 0; }
static inline void exception_exit(enum ctx_state prev_ctx) { }
static inline int ct_state(void) { return -1; }
+static inline int __ct_state(void) { return -1; }
static __always_inline bool context_tracking_guest_enter(void) { return false; }
static inline void context_tracking_guest_exit(void) { }
#define CT_WARN_ON(cond) do { } while (0)
diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index 846add8..1314894 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -21,7 +21,7 @@ static __always_inline void __enter_from_user_mode(struct pt_regs *regs)
arch_enter_from_user_mode(regs);
lockdep_hardirqs_off(CALLER_ADDR0);
- CT_WARN_ON(ct_state() != CONTEXT_USER);
+ CT_WARN_ON(__ct_state() != CONTEXT_USER);
user_exit_irqoff();
instrumentation_begin();
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] x86/entry: Fix noinstr warning in __enter_from_user_mode()
2023-02-26 0:01 [PATCH] x86/entry: Fix noinstr warning in __enter_from_user_mode() Josh Poimboeuf
2023-03-20 10:59 ` [tip: core/urgent] entry: " tip-bot2 for Josh Poimboeuf
@ 2023-03-21 9:08 ` Thomas Gleixner
2023-03-21 10:54 ` [tip: core/urgent] entry: " tip-bot2 for Josh Poimboeuf
2 siblings, 0 replies; 4+ messages in thread
From: Thomas Gleixner @ 2023-03-21 9:08 UTC (permalink / raw)
To: Josh Poimboeuf, x86
Cc: Peter Zijlstra, Frederic Weisbecker, Paul E . McKenney,
Andy Lutomirski, linux-kernel
On Sat, Feb 25 2023 at 16:01, Josh Poimboeuf wrote:
> __enter_from_user_mode() is triggering noinstr warnings with
> CONFIG_DEBUG_PREEMPT due to its call of preempt_count_add() via
> ct_state().
>
> The preemption disable isn't needed as interrupts are already disabled.
> And the context_tracking_enabled() check in ct_state() also isn't needed
> as that's already being done by the CT_WARN_ON().
>
> Just use __ct_state() instead.
>
> Fixes the following warnings:
>
> vmlinux.o: warning: objtool: enter_from_user_mode+0xba: call to preempt_count_add() leaves .noinstr.text section
> vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0xf9: call to preempt_count_add() leaves .noinstr.text section
> vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0xc7: call to preempt_count_add() leaves .noinstr.text section
> vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0xba: call to preempt_count_add() leaves .noinstr.text section
>
> Fixes: 171476775d32 ("context_tracking: Convert state to atomic_t")
> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
> ---
> include/linux/context_tracking.h | 1 +
> kernel/entry/common.c | 2 +-
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/context_tracking.h b/include/linux/context_tracking.h
> index d4afa8508a80..3a7909ed5498 100644
> --- a/include/linux/context_tracking.h
> +++ b/include/linux/context_tracking.h
> @@ -96,6 +96,7 @@ static inline void user_exit_irqoff(void) { }
> static inline int exception_enter(void) { return 0; }
> static inline void exception_exit(enum ctx_state prev_ctx) { }
> static inline int ct_state(void) { return -1; }
> +static inline int __ct_state(void) { return -1; }
This results in a redefinition warning due to CONFIG_CONTEXT_TRACKING=y
and CONFIG_CONFIG_TRACKING_USER=n.
Those headers are a fricking mess.
Thanks,
tglx
^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip: core/urgent] entry: Fix noinstr warning in __enter_from_user_mode()
2023-02-26 0:01 [PATCH] x86/entry: Fix noinstr warning in __enter_from_user_mode() Josh Poimboeuf
2023-03-20 10:59 ` [tip: core/urgent] entry: " tip-bot2 for Josh Poimboeuf
2023-03-21 9:08 ` [PATCH] x86/entry: " Thomas Gleixner
@ 2023-03-21 10:54 ` tip-bot2 for Josh Poimboeuf
2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Josh Poimboeuf @ 2023-03-21 10:54 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Josh Poimboeuf, Thomas Gleixner, x86, linux-kernel
The following commit has been merged into the core/urgent branch of tip:
Commit-ID: f87d28673b71b35b248231a2086f9404afbb7f28
Gitweb: https://git.kernel.org/tip/f87d28673b71b35b248231a2086f9404afbb7f28
Author: Josh Poimboeuf <jpoimboe@kernel.org>
AuthorDate: Sat, 25 Feb 2023 16:01:36 -08:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Tue, 21 Mar 2023 11:53:16 +01:00
entry: Fix noinstr warning in __enter_from_user_mode()
__enter_from_user_mode() is triggering noinstr warnings with
CONFIG_DEBUG_PREEMPT due to its call of preempt_count_add() via
ct_state().
The preemption disable isn't needed as interrupts are already disabled.
And the context_tracking_enabled() check in ct_state() also isn't needed
as that's already being done by the CT_WARN_ON().
Just use __ct_state() instead.
Fixes the following warnings:
vmlinux.o: warning: objtool: enter_from_user_mode+0xba: call to preempt_count_add() leaves .noinstr.text section
vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0xf9: call to preempt_count_add() leaves .noinstr.text section
vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0xc7: call to preempt_count_add() leaves .noinstr.text section
vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0xba: call to preempt_count_add() leaves .noinstr.text section
Fixes: 171476775d32 ("context_tracking: Convert state to atomic_t")
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/d8955fa6d68dc955dda19baf13ae014ae27926f5.1677369694.git.jpoimboe@kernel.org
---
include/linux/context_tracking.h | 1 +
include/linux/context_tracking_state.h | 2 ++
kernel/entry/common.c | 2 +-
3 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/linux/context_tracking.h b/include/linux/context_tracking.h
index d4afa85..3a7909e 100644
--- a/include/linux/context_tracking.h
+++ b/include/linux/context_tracking.h
@@ -96,6 +96,7 @@ static inline void user_exit_irqoff(void) { }
static inline int exception_enter(void) { return 0; }
static inline void exception_exit(enum ctx_state prev_ctx) { }
static inline int ct_state(void) { return -1; }
+static inline int __ct_state(void) { return -1; }
static __always_inline bool context_tracking_guest_enter(void) { return false; }
static inline void context_tracking_guest_exit(void) { }
#define CT_WARN_ON(cond) do { } while (0)
diff --git a/include/linux/context_tracking_state.h b/include/linux/context_tracking_state.h
index 4a4d56f..fdd537e 100644
--- a/include/linux/context_tracking_state.h
+++ b/include/linux/context_tracking_state.h
@@ -46,7 +46,9 @@ struct context_tracking {
#ifdef CONFIG_CONTEXT_TRACKING
DECLARE_PER_CPU(struct context_tracking, context_tracking);
+#endif
+#ifdef CONFIG_CONTEXT_TRACKING_USER
static __always_inline int __ct_state(void)
{
return arch_atomic_read(this_cpu_ptr(&context_tracking.state)) & CT_STATE_MASK;
diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index 846add8..1314894 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -21,7 +21,7 @@ static __always_inline void __enter_from_user_mode(struct pt_regs *regs)
arch_enter_from_user_mode(regs);
lockdep_hardirqs_off(CALLER_ADDR0);
- CT_WARN_ON(ct_state() != CONTEXT_USER);
+ CT_WARN_ON(__ct_state() != CONTEXT_USER);
user_exit_irqoff();
instrumentation_begin();
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-03-21 10:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-26 0:01 [PATCH] x86/entry: Fix noinstr warning in __enter_from_user_mode() Josh Poimboeuf
2023-03-20 10:59 ` [tip: core/urgent] entry: " tip-bot2 for Josh Poimboeuf
2023-03-21 9:08 ` [PATCH] x86/entry: " Thomas Gleixner
2023-03-21 10:54 ` [tip: core/urgent] entry: " tip-bot2 for Josh Poimboeuf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.