From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 939DEC77B7A for ; Tue, 30 May 2023 09:46:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MknzIFT24Kyne4PvqhwqG9g92foY1oCvq0lb7Flysgs=; b=gkfd9uQLA9zmK5 PiOSnSxuYHmF+3hGf6sxHanuB2EMFxAZZ2IpsiwTHMOcplMTIqMPSLQiUqhKeS8uZWYk4b/R2FslQ ENPFOjeW9T8CGKnaNKp+nCA1AtUBRvAVcPWOAD5SK5jEb/l01FCjVxhME5io+IsTerTtNhl2cweeS xHZwftIJ99IYBCVuBSVb7RnXnJMS675W31p5jw1XMedgrm3zQlmAiYpHlN69swWhi2+q7MA9X+W1T Ji+VILRAY/n6a8S483RJrrujysa8gJ3jVKlcrsvS0ULXOSw1e7l0iZKAnEyPvIKtJRoFnnIo1OrJS Evnm7DERXVbtR7Rn5p/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3vw8-00DEkE-0Z; Tue, 30 May 2023 09:46:40 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3vw5-00DEiO-0k for linux-arm-kernel@lists.infradead.org; Tue, 30 May 2023 09:46:38 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 192C92F4; Tue, 30 May 2023 02:47:20 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.25.100]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 199643F663; Tue, 30 May 2023 02:46:32 -0700 (PDT) Date: Tue, 30 May 2023 10:46:27 +0100 From: Mark Rutland To: Eric Chan Cc: Catalin Marinas , Will Deacon , "Paul E . McKenney" , Mark Brown , Frederic Weisbecker , Mukesh Ojha , Josh Poimboeuf , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm64: Fix 'lock held when returning to user space' lockdep warning Message-ID: References: <20230526184823.1230974-1-ericchancf@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230526184823.1230974-1-ericchancf@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230530_024637_333778_83BE9C94 X-CRM114-Status: GOOD ( 24.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Thanks, Mark. > Signed-off-by: Eric Chan > --- > 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