* [PATCH] arm64: Fix 'lock held when returning to user space' lockdep warning
@ 2023-05-26 18:48 Eric Chan
2023-05-30 9:46 ` Mark Rutland
0 siblings, 1 reply; 3+ messages in thread
From: Eric Chan @ 2023-05-26 18:48 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon
Cc: Mark Rutland, Paul E . McKenney, Mark Brown, Frederic Weisbecker,
Mukesh Ojha, Josh Poimboeuf, linux-arm-kernel, linux-kernel,
Eric Chan
The arm64 architecture lacks support for CONFIG_GENERIC_ENTRY, resulting
in the failure to report the lockdep warning
"lock held when returning to user space" when lockdep is enabled.
Rename the function to align with exit_to_user_mode_prepare in
kernel/entry/common.c to improve readability.
Signed-off-by: Eric Chan <ericchancf@google.com>
---
arch/arm64/kernel/entry-common.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c
index 3af3c01c93a6..9d6827201b6c 100644
--- a/arch/arm64/kernel/entry-common.c
+++ b/arch/arm64/kernel/entry-common.c
@@ -126,7 +126,7 @@ static __always_inline void __exit_to_user_mode(void)
lockdep_hardirqs_on(CALLER_ADDR0);
}
-static __always_inline void prepare_exit_to_user_mode(struct pt_regs *regs)
+static __always_inline void exit_to_user_mode_prepare(struct pt_regs *regs)
{
unsigned long flags;
@@ -135,11 +135,13 @@ static __always_inline void prepare_exit_to_user_mode(struct pt_regs *regs)
flags = read_thread_flags();
if (unlikely(flags & _TIF_WORK_MASK))
do_notify_resume(regs, flags);
+
+ lockdep_sys_exit();
}
static __always_inline void exit_to_user_mode(struct pt_regs *regs)
{
- prepare_exit_to_user_mode(regs);
+ exit_to_user_mode_prepare(regs);
mte_check_tfsr_exit();
__exit_to_user_mode();
}
--
2.41.0.rc0.172.g3f132b7071-goog
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] arm64: Fix 'lock held when returning to user space' lockdep warning
2023-05-26 18:48 [PATCH] arm64: Fix 'lock held when returning to user space' lockdep warning Eric Chan
@ 2023-05-30 9:46 ` Mark Rutland
2023-05-31 8:47 ` Eric Chan
0 siblings, 1 reply; 3+ messages in thread
From: Mark Rutland @ 2023-05-30 9:46 UTC (permalink / raw)
To: Eric Chan
Cc: Catalin Marinas, Will Deacon, Paul E . McKenney, Mark Brown,
Frederic Weisbecker, Mukesh Ojha, Josh Poimboeuf,
linux-arm-kernel, linux-kernel
Hi Eric,
The subject line for this patch is misleading, as it makes it sound like we're
currently hitting a warning of the form:
lock held when returning to user space
... when in actuality this patch is *adding* support for that warning.
This is a missing feature, not a fix (and e.g. doesn't require backporting to
stable).
On Fri, May 26, 2023 at 06:48:23PM +0000, Eric Chan wrote:
> The arm64 architecture lacks support for CONFIG_GENERIC_ENTRY, resulting
> in the failure to report the lockdep warning
> "lock held when returning to user space" when lockdep is enabled.
>
> Rename the function to align with exit_to_user_mode_prepare in
> kernel/entry/common.c to improve readability.
Considering the point about the commit title, could you please reword this to
be clear that we're adding support for a feature, rather than fixing something
that's broken, e.g.
| arm64: lockdep: enable checks for held locks when returning to userspace
|
| Currently arm64 doesn't use CONFIG_GENERIC_ENTRY and doesn't call
| lockdep_sys_exit() when returning to userspace. This means that lockdep won't
| check for held locks when returning to userspace, which would be useful to
| detect kernel bugs.
|
| Call lockdep_sys_exit() when returning to userspace, enabling checking for
| held locks.
|
| At the same time, rename arm64's prepare_exit_to_user_mode() to
| exit_to_user_mode_prepare() to more clearly align with the naming in the
| generic entry code.
With that wording:
Acked-by: Mark Rutland <mark.rutland@arm.com>
Thanks,
Mark.
> Signed-off-by: Eric Chan <ericchancf@google.com>
> ---
> arch/arm64/kernel/entry-common.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c
> index 3af3c01c93a6..9d6827201b6c 100644
> --- a/arch/arm64/kernel/entry-common.c
> +++ b/arch/arm64/kernel/entry-common.c
> @@ -126,7 +126,7 @@ static __always_inline void __exit_to_user_mode(void)
> lockdep_hardirqs_on(CALLER_ADDR0);
> }
>
> -static __always_inline void prepare_exit_to_user_mode(struct pt_regs *regs)
> +static __always_inline void exit_to_user_mode_prepare(struct pt_regs *regs)
> {
> unsigned long flags;
>
> @@ -135,11 +135,13 @@ static __always_inline void prepare_exit_to_user_mode(struct pt_regs *regs)
> flags = read_thread_flags();
> if (unlikely(flags & _TIF_WORK_MASK))
> do_notify_resume(regs, flags);
> +
> + lockdep_sys_exit();
> }
>
> static __always_inline void exit_to_user_mode(struct pt_regs *regs)
> {
> - prepare_exit_to_user_mode(regs);
> + exit_to_user_mode_prepare(regs);
> mte_check_tfsr_exit();
> __exit_to_user_mode();
> }
> --
> 2.41.0.rc0.172.g3f132b7071-goog
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] arm64: Fix 'lock held when returning to user space' lockdep warning
2023-05-30 9:46 ` Mark Rutland
@ 2023-05-31 8:47 ` Eric Chan
0 siblings, 0 replies; 3+ messages in thread
From: Eric Chan @ 2023-05-31 8:47 UTC (permalink / raw)
To: Mark Rutland
Cc: Catalin Marinas, Will Deacon, Paul E . McKenney, Mark Brown,
Frederic Weisbecker, Mukesh Ojha, Josh Poimboeuf,
linux-arm-kernel, linux-kernel
Hi Mark,
Thank you for your detailed response and guidance. I will prepare
PATCH v2 promptly and resubmit it for review.
Thanks,
Eric Chan
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-31 8:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-26 18:48 [PATCH] arm64: Fix 'lock held when returning to user space' lockdep warning Eric Chan
2023-05-30 9:46 ` Mark Rutland
2023-05-31 8:47 ` Eric Chan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).