Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2597903iof; Wed, 8 Jun 2022 08:13:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlcHeJunrTB+vRkGiJl4atY/w2KXMfcYwF4so/0LI0O6ClORd1V37aKKz1GfIoO+K3Uq3n X-Received: by 2002:a17:90a:c70a:b0:1e2:eb3e:239f with SMTP id o10-20020a17090ac70a00b001e2eb3e239fmr57988867pjt.94.1654701183406; Wed, 08 Jun 2022 08:13:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654701183; cv=none; d=google.com; s=arc-20160816; b=QzcuQ8o6kPjyaFtyUvWj1K0EUjEFgXhUamPezgzSw93qi+ipZei1TG9fzpblMGEMjb Ve5mmbT49W3oLjGCpbku6bMVr7g60G3S8wsWypA3xmwMls5lt1wJNRQJf20nT8navyWt Yu3pDTBI/eGPn22PvWh6tzGklLsncLKSZNmkURO/58Pt4v0P/4ZY8UEAhHHO45e2o+2h QNguF8mGyu8GAmPWBGWoD3JVomM0fk8UtXBATfgsJoQOycBunVwo7Xi8Ts1l+B9A6p9a VCYgbwWKoUV34/wlNDb9KpHTl1iov2cJeS7ZlGNRR1x4WazHD/t0VmxQTRq+EczgXm4J dvTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xdmaEcS7f5HNEZFOAV0qG+OzKj6o6hHgSDhBslKoXSk=; b=j5sqngB+T/Yn3X+N1wmSW47nRWPRvK9cMB0EmOQBHEDFMEFOz5kzZKPWgASDxYhB9W d27HEmqA/3ZuIYBwC68eQNlXqwqyJOv17SI74z/IBi1swDv8JhrNsWDP14AfzHR4iDdX NLVLzBf+fjA9gNMiVXVA/oyARdpyJoeftX/SIRuvmQYiIuEI950Y+qI+1sSAXIVPuRhx WACqUUTTj5iwi6INqD0zBLxFXvmthreIdDjQUpLLpsM5KclBnj6aR2z76UHvw1hQnC9d WHjZxqnC85b7/FPZb4E+o/CJaRQY7q3K6/OVrClyqFK+Qn+taFswJKsLyJi4/bMCjZWG byNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jMTVaqAH; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id i5-20020a170902c28500b00163f8c2dec7si26026313pld.347.2022.06.08.08.13.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 08:13:03 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jMTVaqAH; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6A09C212D86; Wed, 8 Jun 2022 07:43:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241727AbiFHOli (ORCPT + 99 others); Wed, 8 Jun 2022 10:41:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241773AbiFHOlF (ORCPT ); Wed, 8 Jun 2022 10:41:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE2E014CDFF for ; Wed, 8 Jun 2022 07:40:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3ABFB61B9D for ; Wed, 8 Jun 2022 14:40:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A431C34116; Wed, 8 Jun 2022 14:40:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654699251; bh=y5jci0bqRsZ94ArUjZ+9wtURoMvqstdDqOTJ7Eps920=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jMTVaqAHpvYtuYZbDdq0xRaTEYUoMoxdL9RzYX4fvHhmmIBADbynz/isWETDuuZpr 6rJLLQYsgYy129uWysAmkBqNofZdLzW7C+wmpUEVoCyg17DfCD7JGASvG7FlH+YIT0 fvmpBkcK4PEb8PzrBYx9kQkT7plW75ia0RgIIS7DX1vB2HeOMlTQg2IewoOtb4GjHd tnZQhW+VOqvI45IfoRAZoo91ft0oROL/ZpPHA2UxpsAtbmXUy1FxddX8/4EDfuf4BQ 83Xb6Y3B/i4rijDVLjWO0LzJut9JvBe9AllEVr9eIVkfi3wHbGaBRE6/tjrWgtDovR i7hcI8RcnZEgQ== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Peter Zijlstra , Phil Auld , Alex Belits , Nicolas Saenz Julienne , Xiongfeng Wang , Neeraj Upadhyay , Thomas Gleixner , Yu Liao , Boqun Feng , "Paul E . McKenney" , Marcelo Tosatti , Paul Gortmaker , Uladzislau Rezki , Joel Fernandes Subject: [PATCH 02/20] context_tracking: Add a note about noinstr VS unsafe context tracking functions Date: Wed, 8 Jun 2022 16:40:19 +0200 Message-Id: <20220608144037.1765000-3-frederic@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220608144037.1765000-1-frederic@kernel.org> References: <20220608144037.1765000-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Some context tracking functions enter or exit into/from RCU idle mode while using trace-able and lockdep-aware IRQs (un-)masking. As a result those functions can't get tagged as noinstr. This is unlikely to be fixed since these are obsolete APIs. Drop a note about this matter. Reported-by: Peter Zijlstra Cc: Paul E. McKenney Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Neeraj Upadhyay Cc: Uladzislau Rezki Cc: Joel Fernandes Cc: Boqun Feng Cc: Nicolas Saenz Julienne Cc: Marcelo Tosatti Cc: Xiongfeng Wang Cc: Yu Liao Cc: Phil Auld Cc: Paul Gortmaker Cc: Alex Belits Signed-off-by: Frederic Weisbecker --- kernel/context_tracking.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c index 36a98c48aedc..b8032ebf4314 100644 --- a/kernel/context_tracking.c +++ b/kernel/context_tracking.c @@ -103,6 +103,16 @@ void noinstr __context_tracking_enter(enum ctx_state state) } EXPORT_SYMBOL_GPL(__context_tracking_enter); +/* + * OBSOLETE: + * This function should be noinstr but the below local_irq_restore() is + * unsafe because it involves illegal RCU uses through tracing and lockdep. + * This is unlikely to be fixed as this function is obsolete. The preferred + * way is to call __context_tracking_enter() through user_enter_irqoff() + * or context_tracking_guest_enter(). It should be the arch entry code + * responsibility to call into context tracking with IRQs disabled. + + */ void context_tracking_enter(enum ctx_state state) { unsigned long flags; @@ -125,6 +135,14 @@ void context_tracking_enter(enum ctx_state state) NOKPROBE_SYMBOL(context_tracking_enter); EXPORT_SYMBOL_GPL(context_tracking_enter); +/* + * OBSOLETE: + * This function should be noinstr but it unsafely calls local_irq_restore(), + * involving illegal RCU uses through tracing and lockdep. + * This is unlikely to be fixed as this function is obsolete. The preferred + * way is to call user_enter_irqoff(). It should be the arch entry code + * responsibility to call into context tracking with IRQs disabled. + */ void context_tracking_user_enter(void) { user_enter(); @@ -168,6 +186,15 @@ void noinstr __context_tracking_exit(enum ctx_state state) } EXPORT_SYMBOL_GPL(__context_tracking_exit); +/* + * OBSOLETE: + * This function should be noinstr but the below local_irq_save() is + * unsafe because it involves illegal RCU uses through tracing and lockdep. + * This is unlikely to be fixed as this function is obsolete. The preferred + * way is to call __context_tracking_exit() through user_exit_irqoff() + * or context_tracking_guest_exit(). It should be the arch entry code + * responsibility to call into context tracking with IRQs disabled. + */ void context_tracking_exit(enum ctx_state state) { unsigned long flags; @@ -182,6 +209,14 @@ void context_tracking_exit(enum ctx_state state) NOKPROBE_SYMBOL(context_tracking_exit); EXPORT_SYMBOL_GPL(context_tracking_exit); +/* + * OBSOLETE: + * This function should be noinstr but it unsafely calls local_irq_save(), + * involving illegal RCU uses through tracing and lockdep. This is unlikely + * to be fixed as this function is obsolete. The preferred way is to call + * user_exit_irqoff(). It should be the arch entry code responsibility to + * call into context tracking with IRQs disabled. + */ void context_tracking_user_exit(void) { user_exit(); -- 2.25.1