Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp592103rwd; Wed, 31 May 2023 02:39:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6xdhEq9pR08M8048GKni4EtrZ061OxJUcfdXQ+ZZhz1gZPnQUShmdP6aBdtQyk4HNphy25 X-Received: by 2002:a05:6870:1728:b0:19a:26bc:58e3 with SMTP id h40-20020a056870172800b0019a26bc58e3mr3363196oae.21.1685525991932; Wed, 31 May 2023 02:39:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685525991; cv=none; d=google.com; s=arc-20160816; b=V9r9w2V9ydIv/EQyNZwEABuQF3gSUSLIn5JAcrStzQCMkENZAlDOcQ1ck+PsnZB7N/ 8s2J0S8lxUxatHduqyWt/nTPc1osAZEnGinVGwhG/v2e/Piyst1lnvbH5TOIibfGZ1Gq p04gky2wa/T1btiKylWqmLvbXSgTm/mCCdM8CuvPUcUjVYaYPQ9TLACT938W8h8IgDI6 9JBuKmsdmW16kx7hrNMVabfKYpS8OuUBosbAcEmu8zV1XzA1xWCBQu/mtwcuDjVdkEJ9 20q9Wc4jawZCpG528/l2/+AfVK9YBYnnJrQ4XQLLun1fUQgS0gfhgofSjOIBJEDQT1X7 qoEg== 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=uDyUEUKWPkyh/YNSCkrScqS2AVFO7CTNEmU88s6Pdgk=; b=tascNFT9cuAzS9ljAfAFRGjGOOZJ0dK/qnw/rJltQWlWnxn373tLnUMUONjLTe8TnW LLMJh04BxU7b2FEnHEzaegOkeeE5SrIiufIWVUTg9ZzZ8pMn5PdiRw9d7rPuHgRlA7D0 jiJdxi8V/inJbm0Isg+FMJ/LPos0mJDjTNMD4xhZj7DQXGT7j3M68R0XJLVoso9+IQSi R6ootrJXITX0U/I0vd1FlI8/2qoYCmPj/D8VYwlrt4vj9EFLxhEMXT5jlTVJwA7z1Ww7 wogAuaCzlyeG5r39yq4eyU4kNAM310bG5gsyLP3FWP2va7j3XmaQ5S90By67eTmCe5iz VOqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=IDvx1FzI; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y27-20020aa78f3b000000b0064f8b5f1d84si3281379pfr.202.2023.05.31.02.39.37; Wed, 31 May 2023 02:39:51 -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=IDvx1FzI; 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 S235314AbjEaJKy (ORCPT + 99 others); Wed, 31 May 2023 05:10:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235388AbjEaJJs (ORCPT ); Wed, 31 May 2023 05:09:48 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E41EE58 for ; Wed, 31 May 2023 02:09:17 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-bad0f5d6a7dso10699684276.0 for ; Wed, 31 May 2023 02:09:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685524155; x=1688116155; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=uDyUEUKWPkyh/YNSCkrScqS2AVFO7CTNEmU88s6Pdgk=; b=IDvx1FzI0zs8uomF/kYtxD5FQiXlgdcTWFeLWPSIgoNW+QgeAKm6njvIMJovu2Sz70 g66SXYGQ3eUlS5rMixU7zaGHV9pdFknoG7XY4MvFFxwEVFZF1xznZm7tGSft5ICPRX+r OZEdaSr4LxdfMCZXXsXHlaY55zFdqeXmcb8ogZ05Z9QkGIkpatTc3d7ITMq3dZv1fbot Ob2vItvFSgI9vSODMQFQBgWEyN/zUlQXyXZAy5RN8xblQCv0h14kJXOzzEitjpmoOWmz uD13m7tTxjLkWL1CfCpNBr7eL1T0bhOS2ltLWbNaWdkRMhBJ9wHK+wYrKZT5SJ0mOOf4 lfxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685524155; x=1688116155; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=uDyUEUKWPkyh/YNSCkrScqS2AVFO7CTNEmU88s6Pdgk=; b=ZFws3rYWakFsLTSCnLffXbK+zhC39dpiQgaUnfmm5aIrGcBi+OWj+cJbhYRh58t/Te c3O8aq1FK0W1XdZ2eiO+sFNWn3batrdyosNkWMTZyekWKVrjkCgZgEgwgYb18Q2HEyBl f+g34qRZifoyZqeeJzD9VS15I33RG1N2NvEKtlE7jJUf4uxOUdkWt2nvB+C5i4kfovxK RfJogkYv7lvQRJDPNr//EYr89Eig32P+3GAysdKgRqYcBm1LeMcu0ZNg+ilB6CAorvfu q8tq9I21hrN0FRNvhF1qyCBo7btqlGtUOgC4FI13oiLO84JtADHV+IYsbGAguUR44oga qWvQ== X-Gm-Message-State: AC+VfDwGYP7rgcqQb6pP2Rw/0pIPHmr3aYTF+qLniY0Q3amzC0+ywm3R 1WlmhseXavd/6ceYzh08ZOIEqtNQu5HGIopX X-Received: from ericchancf.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:4139]) (user=ericchancf job=sendgmr) by 2002:a25:818e:0:b0:ba8:736a:5bec with SMTP id p14-20020a25818e000000b00ba8736a5becmr3012561ybk.6.1685524155765; Wed, 31 May 2023 02:09:15 -0700 (PDT) Date: Wed, 31 May 2023 09:09:09 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Message-ID: <20230531090909.357047-1-ericchancf@google.com> Subject: [PATCH v2] arm64: lockdep: enable checks for held locks when returning to userspace From: Eric Chan To: Catalin Marinas , Will Deacon , Mark Rutland Cc: "Paul E . McKenney" , Anshuman Khandual , Frederic Weisbecker , Mukesh Ojha , Josh Poimboeuf , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Eric Chan 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: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Eric Chan Acked-by: Mark Rutland --- 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 V1 -> V2 : Revise the commit message to make it clearer and avoid any misleading information.