Message ID | 20230526184823.1230974-1-ericchancf@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp695413vqr; Fri, 26 May 2023 12:10:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ45MX6S8QHAtzmcnorGQA5+vUqjrIrLDb8TvtBh5YseMPVAWBTiWIaKODfP0a5NJBARPPSa X-Received: by 2002:a05:6a00:99b:b0:64d:fd0:dd1a with SMTP id u27-20020a056a00099b00b0064d0fd0dd1amr5931299pfg.16.1685128255551; Fri, 26 May 2023 12:10:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685128255; cv=none; d=google.com; s=arc-20160816; b=y/juqoP5iAFJ0YSYR8/DWXZRgyUSBsTQrGC7I6r3d65V+83F3GgaLM3ywm/uKIuF6s tpg8k/yv82WDVKxkN7/ctTaywXIo49iimMdmmevdpCNE/mZuvIpB7+dsiDF/Ox9nnp3t eYU4ZxM6+09a7HIqLHs/1otjwnzAPO8FAYkqcPlPS3PDWnVvUr0Kdo3qhBCNBpUmeG6M VW6WDwThzrBGyO8crNC8KSBcSY65u2vq/2/pC2gDyULFwOSgApwT6Z+L3SPToFo99L+a dUhyjNrzq0Z0zucS7yzVh4H//AQBqMX8o9cMJ4+r1immWNrMjFxfMLQzPAOwWkSwvYoV yyug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=pr0CfxQy0sGUiXzLTyaj373l3U9KzezGvaWkoYzA3QE=; b=bc7hAUivGKQOexlqzPspIwP15GjROaNdtJ0OoouiKZn6ASuK0aEZLV9czjnoLWB0Zw h5HGdKd1ggBli1ywwrXf3Cmco6cjOQv4JEJt4UXudZpvdZ2+JpnNV7BebShnqXFpgPTB jsx9sIdS4feeKOdhASNAe1caLTF6HL/9E8hckmKIcTgWhqxtUiEnhgrJQ6CTtcnX0BiC Tz699ketDGymFKB2CW+YACb+VL3imDB5hqs+uAI0XdDioPh9yX4Jl6yyU5qwVumEf99U vFnCW5RUG9iH75RQmAbFb+hTtshr/U/toHGviMh26x/3O7ahgfYGgT7ed+CXWAvxRf5G +S+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=qgAB1W5N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s18-20020aa78bd2000000b006499946fbe5si4579204pfd.321.2023.05.26.12.10.41; Fri, 26 May 2023 12:10:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=qgAB1W5N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242889AbjEZSse (ORCPT <rfc822;zhanglyra.2023@gmail.com> + 99 others); Fri, 26 May 2023 14:48:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230104AbjEZSsb (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 26 May 2023 14:48:31 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 415ACAD for <linux-kernel@vger.kernel.org>; Fri, 26 May 2023 11:48:30 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-ba802c775caso2358564276.2 for <linux-kernel@vger.kernel.org>; Fri, 26 May 2023 11:48:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685126909; x=1687718909; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=pr0CfxQy0sGUiXzLTyaj373l3U9KzezGvaWkoYzA3QE=; b=qgAB1W5NVq0jFTTBMjUg8Hw2q2NCZNUP+DbQz09KcF8PA6oV1ga9KYZU8oGCp5XDsc YuYYUi7x1xKpvEXZD59MCmcTwYmJgER8UKA56ZeiLEvH0lZVfq4r1Q9FJDx3hSqHFfVV cdF+xUutRZlK83XxrwxlR165AcmV3ycZH9lKCDkInV021tXS/6QItALaayAdaf0KPxGd kku0H6olSVdfFiUq01Lly+my+AaSOkIJJ51Xm6s1jzONF6tNwuNpUzyBwNDE1K/uj1qD knBzoTTVOEDEj3TfmEZ30cInDdSnw7Nue2SYcVHnEd6dIBDcEItqUUZc/FsuTXX1GKPk d8OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685126909; x=1687718909; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=pr0CfxQy0sGUiXzLTyaj373l3U9KzezGvaWkoYzA3QE=; b=SB9/lFrqcSGOTjnFf+PS8fcMM/G9zVaJa/+wxCkEk0vwDCH9LBKig/ssFJoajcO8ne g6ZRUq0s7jYtlxfH/P8rt4JEwOEU2A3d/F8t6XBkpej/Y2Yg5z7PbV/LnsMv86Wtq5tR aZy0DxThpUFOUzlVG9hTG2mIKLseYgy8OLIX6IqRCvxF17mceIAwvI7rFpXSIFFMTiFV NkdakyOkhlqqMw76WlZEwPdrtdo+wWuW4THj3TfjRzFxodapBfYbu+dfUdFWkyNoD1oQ uFaBAUXPV0APxCMjcrAWZG2vNyOFOdQaDRFLocAQcoe4FMl0O4kTrgksncAdbk9TmyBB 7gGw== X-Gm-Message-State: AC+VfDwn4vU9ApHl/5nEJwAesIe5u+HvHyN3z4qoi3NkEwQjF6CTA25Z +IsgFAMRzRlWH//dTFgTZj/3aRWlupEeq3pz X-Received: from ericchancf.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:4139]) (user=ericchancf job=sendgmr) by 2002:a05:6902:1826:b0:bac:bae6:b363 with SMTP id cf38-20020a056902182600b00bacbae6b363mr1450617ybb.3.1685126909551; Fri, 26 May 2023 11:48:29 -0700 (PDT) Date: Fri, 26 May 2023 18:48:23 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Message-ID: <20230526184823.1230974-1-ericchancf@google.com> Subject: [PATCH] arm64: Fix 'lock held when returning to user space' lockdep warning From: Eric Chan <ericchancf@google.com> To: Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com>, "Paul E . McKenney" <paulmck@kernel.org>, Mark Brown <broonie@kernel.org>, Frederic Weisbecker <frederic@kernel.org>, Mukesh Ojha <quic_mojha@quicinc.com>, Josh Poimboeuf <jpoimboe@kernel.org>, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Eric Chan <ericchancf@google.com> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766985045627236539?= X-GMAIL-MSGID: =?utf-8?q?1766985045627236539?= |
Series |
arm64: Fix 'lock held when returning to user space' lockdep warning
|
|
Commit Message
Eric Chan
May 26, 2023, 6:48 p.m. UTC
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(-)
Comments
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 >
Hi Mark, Thank you for your detailed response and guidance. I will prepare PATCH v2 promptly and resubmit it for review. Thanks, Eric Chan
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(); }