From patchwork Tue Nov 16 08:24:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 12692709 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28C3EC433F5 for ; Tue, 16 Nov 2021 08:26:57 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id EE53061B49 for ; Tue, 16 Nov 2021 08:26:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EE53061B49 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=fceFVXIXYoMcRbcfwcB05HkpaqWXKPkwhrfR/1Ofgkg=; b=kfKefIrAXfBKCL iBWSQWbDcBt41oYmUhfUvsy6end3eLMYyl+JHCglgSP6eYT9B5KURJvL/2ahuXqUnQQhEwAolqUBk udHj7rm3JORP4/WK/l8HrKjT/U35CmRtflthUszKRdvdxlKfZjfPqTu2RUDs1WFU9fqxLM0CpxCHW w1t0yI9qRm/XzYYDrLNi7tWeNGWFRv/42aa/G7q7glot6hGHqVqjITpM5vfKRoEurNFpjgykJZYQe Z9SU+fv2BzR26c1HGYtpmqYX/FjRgW5UAEDwbNbos2WOi5h+nhPKUAwVc1hEvwYwE02z7vKm/s0K6 WKp2Ew2WUlfHiksQ5FlQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmtmN-000hDK-4s; Tue, 16 Nov 2021 08:25:24 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmtmI-000hBu-0K for linux-arm-kernel@lists.infradead.org; Tue, 16 Nov 2021 08:25:19 +0000 Received: by mail-pf1-x432.google.com with SMTP id r130so17522641pfc.1 for ; Tue, 16 Nov 2021 00:25:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nY2dUOfwcuVKwH86QJzNlyUT0GQ8vz+924KfMba1VPc=; b=oSII1gGobUz74S1uShIbxvtB9PL+5gr0XRnOdKajgLmgjcr8SPMBvJ2YLAQsGydgxH Kfqu/L7Ny+8D4vzlghK2mW6TH6oTU960Za3Whpdo/NpbuDZsCgCdtepPdtPshTS0SRDP Sz0cVqMGVpKMMgykohMJ+kG24qfp1Lxs4kZywiaMcO+kihO7+aeyrRbEsXGZSh9Lyr+/ EV9MW8w8+WjG065mEus3QQPDyEhOIhYKZFk6tWBF9Exe0LLyAi0ZiBD1Jy17/oRFwYzW fXX6Jih65H0wgrz39PK1QKXnS4Sd6mqkQZPPqxhv6Xyi6/8ndw/X244hwtOgFMW9gXqk 3NzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nY2dUOfwcuVKwH86QJzNlyUT0GQ8vz+924KfMba1VPc=; b=pXtlkOQ6fsa2lUPBOO+PzJYiEP9Zk8zKpx2GOVJpc7Uz2/2pyIP5dqPOzIABH/face UHa5jByVIfa90sZNGjzAhZBgAzt8rsy1M/zGU7T+eCn15V04mBpwun7XBnGqFF0O15yn janPWjuW9H0C8qPATIprn9M+GDmBzCTtKLP5IRHP6gYV8vFgCZ83dEW6S9oRdzRvxFgy cWxV2O0gUVKLQ0hKynZEit5qyuRqJ7w0qXPLtDWybfBB6cIhuHj90Vwvuejt/FNNb5U0 ChdGY7zWD5yPXc+QBwalpMeoKmN/+mXL2huVbD8LEvrUJF6+L5JkoJo8CVul1qWj8HvM /QBw== X-Gm-Message-State: AOAM532X0PVoZpex8V4obsumbJ8SacbVd/BFSzTZVOKeQCaCiCbfBzgt vP/D+tHBesiuXiNR44YDC59fRyCPwQ== X-Google-Smtp-Source: ABdhPJz03QLHrF+LuFmlRgA1TEZN2mJcp+0wT3SYhdpk62BirAg9JaxG04qeJdqCNjOMKMRv5kr7Wg== X-Received: by 2002:aa7:8a56:0:b0:494:6b49:cbfa with SMTP id n22-20020aa78a56000000b004946b49cbfamr39292806pfa.72.1637051115911; Tue, 16 Nov 2021 00:25:15 -0800 (PST) Received: from piliu.users.ipa.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id 11sm17104011pfl.41.2021.11.16.00.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 00:25:15 -0800 (PST) From: Pingfan Liu To: linux-arm-kernel@lists.infradead.org Cc: Pingfan Liu , Mark Rutland , "Paul E . McKenney" , Catalin Marinas , Will Deacon , Marc Zyngier , Thomas Gleixner , Joey Gouly , Sami Tolvanen , Julien Thierry , Yuichi Ito , rcu@vger.kernel.org Subject: [PATCHv3 0/4] arm64: Fixes RCU deadlock due to a mistaken Date: Tue, 16 Nov 2021 16:24:46 +0800 Message-Id: <20211116082450.10357-1-kernelfans@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211116_002518_084924_9E61C084 X-CRM114-Status: UNSURE ( 9.68 ) X-CRM114-Notice: Please train this message. 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org It was [PATCHv2 1/5] arm64/entry-common: push the judgement of nmi ahead [1], but as discussion, I found it hit a deadlock, so change subject in v3. Linux kernel places strict semantics between NMI and maskable interrupt. So does the RCU component, else deadlock may happen. The current arm64 entry code can partially breach this rule through calling rcu_nmi_enter() in pNMI conext without calling __nmi_enter(). Finally, it calls __rcu_irq_enter_check_tick() trying to hold raw_spin_lock_rcu_node(rdp->mynode), but this spinlock can already been held by a task running note_gp_changes()->raw_spin_trylock_rcu_node(rnp). Then deadlock happens. The organization of this series: [1/4] aims to fix this bug [2-3/4] ease the implementation of [1/4] [4/4] is a cleanup To do: Does arm need to handle pNMI as arm64? v2 -> v3: drop handle_arch_nmi interface [1]: https://lore.kernel.org/linux-arm-kernel/20210924132837.45994-2-kernelfans@gmail.com/ Cc: Mark Rutland Cc: Paul E. McKenney Cc: Catalin Marinas Cc: Will Deacon Cc: Marc Zyngier Cc: Thomas Gleixner Cc: Joey Gouly Cc: Sami Tolvanen Cc: Julien Thierry Cc: Thomas Gleixner Cc: Yuichi Ito Cc: rcu@vger.kernel.org To: linux-arm-kernel@lists.infradead.org Pingfan Liu (4): arm64: entry: judge nmi ealier to avoid deadlock in RCU arm64: entry: distinguish pNMI earlier in el0 interrupt irqchip: GICv3: expose pNMI discriminator arm64: entry: remove pNMI judgement in __el1_interrupt() path arch/arm64/kernel/entry-common.c | 55 +++++++++++++++++++++----------- arch/arm64/kernel/irq.c | 15 +++++++++ drivers/irqchip/irq-gic-v3.c | 16 ++++++---- 3 files changed, 62 insertions(+), 24 deletions(-)