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 X-Spam-Level: X-Spam-Status: No, score=-14.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC881C433E0 for ; Thu, 18 Feb 2021 15:40:02 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 5D9E764E5F for ; Thu, 18 Feb 2021 15:40:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D9E764E5F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-ID:References:In-Reply-To:Subject:To:From: Date:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=hbPHLaNkLd7kFiPOx9HObpaDVqKznUYtiDqDDRyeVWU=; b=wlVvIKlSvtTJFNRhSHy9Eemz5 bxaZHlfkIWA1pzu6KP4Gm5OiI+MAsY7rb/uXKJImkHsGHvK9L/QgshMw+an1lJZqf44V+/xBteeCH XomUyht3L9gMrrOUoIuVxnUD9hk/nExm7/nXffKJEXdifHByLjRl2UjyLrpaNjYmRNHoj0Yjpr/r8 I/MYaqgEX7/35aK71UhHjPVukPJsdzyn5pOqrT4RpdOSUZt8L4xX5rfN4jOGVC55yhjHoW4Za20Pr +e1GCiVEnOJIY/KjIZsceY5rvYVzHFteu44UkmeYpEFG2pRTa0ukEqBaDZhotya7YbY4YtWmET/LO ABcxmD9Rg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lClNh-0005Gs-Fz; Thu, 18 Feb 2021 15:38:17 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lClNf-0005GK-5Y for linux-arm-kernel@lists.infradead.org; Thu, 18 Feb 2021 15:38:16 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A5C0964DDA; Thu, 18 Feb 2021 15:37:50 +0000 (UTC) Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1lClNE-00EmRQ-BZ; Thu, 18 Feb 2021 15:37:48 +0000 MIME-Version: 1.0 Date: Thu, 18 Feb 2021 15:37:48 +0000 From: Marc Zyngier To: Will Deacon Subject: Re: [PATCH v2] arm64: spectre: Prevent lockdep splat on v4 mitigation enable path In-Reply-To: <20210218140346.5224-1-will@kernel.org> References: <20210218140346.5224-1-will@kernel.org> User-Agent: Roundcube Webmail/1.4.11 Message-ID: <6ba6be0cfdb905706de6863d8a6768d7@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: will@kernel.org, linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, peterz@infradead.org, boqun.feng@gmail.com, saravanak@google.com, paulmck@kernel.org, samitolvanen@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210218_103815_420983_CFCE4719 X-CRM114-Status: GOOD ( 23.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Lorenzo Pieralisi , "Paul E . McKenney" , Saravana Kannan , Peter Zijlstra , Boqun Feng , Sami Tolvanen , linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2021-02-18 14:03, Will Deacon wrote: > The Spectre-v4 workaround is re-configured when resuming from suspend, > as the firmware may have re-enabled the mitigation despite the user > previously asking for it to be disabled. > > Enabling or disabling the workaround can result in an undefined > instruction exception on CPUs which implement PSTATE.SSBS but only > allow > it to be configured by adjusting the SPSR on exception return. We > handle > this by installing an 'undef hook' which effectively emulates the > access. > > Installing this hook requires us to take a couple of spinlocks both to > avoid corrupting the internal list of hooks but also to ensure that we > don't run into an unhandled exception. Unfortunately, when resuming > from > suspend, we haven't yet called rcu_idle_exit() and so lockdep gets > angry > about "suspicious RCU usage". In doing so, it tries to print a warning, > which leads it to get even more suspicious, this time about itself: > > | rcu_scheduler_active = 2, debug_locks = 1 > | RCU used illegally from extended quiescent state! > | 1 lock held by swapper/0: > | #0: (logbuf_lock){-.-.}-{2:2}, at: vprintk_emit+0x88/0x198 > | > | Call trace: > | dump_backtrace+0x0/0x1d8 > | show_stack+0x18/0x24 > | dump_stack+0xe0/0x17c > | lockdep_rcu_suspicious+0x11c/0x134 > | trace_lock_release+0xa0/0x160 > | lock_release+0x3c/0x290 > | _raw_spin_unlock+0x44/0x80 > | vprintk_emit+0xbc/0x198 > | vprintk_default+0x44/0x6c > | vprintk_func+0x1f4/0x1fc > | printk+0x54/0x7c > | lockdep_rcu_suspicious+0x30/0x134 > | trace_lock_acquire+0xa0/0x188 > | lock_acquire+0x50/0x2fc > | _raw_spin_lock+0x68/0x80 > | spectre_v4_enable_mitigation+0xa8/0x30c > | __cpu_suspend_exit+0xd4/0x1a8 > | cpu_suspend+0xa0/0x104 > | psci_cpu_suspend_enter+0x3c/0x5c > | psci_enter_idle_state+0x44/0x74 > | cpuidle_enter_state+0x148/0x2f8 > | cpuidle_enter+0x38/0x50 > | do_idle+0x1f0/0x2b4 > > Prevent these splats by running __cpu_suspend_exit() with RCU watching. > > Cc: Mark Rutland > Cc: Lorenzo Pieralisi > Cc: Peter Zijlstra > Cc: Boqun Feng > Cc: Marc Zyngier > Cc: Saravana Kannan > Suggested-by: "Paul E . McKenney" > Reported-by: Sami Tolvanen > Fixes: c28762070ca6 ("arm64: Rewrite Spectre-v4 mitigation code") > Signed-off-by: Will Deacon > --- > > v2: Use RCU_NONIDLE() instead of eliding the spinlock > > arch/arm64/kernel/suspend.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/kernel/suspend.c b/arch/arm64/kernel/suspend.c > index a67b37a7a47e..d7564891ffe1 100644 > --- a/arch/arm64/kernel/suspend.c > +++ b/arch/arm64/kernel/suspend.c > @@ -119,7 +119,7 @@ int cpu_suspend(unsigned long arg, int > (*fn)(unsigned long)) > if (!ret) > ret = -EOPNOTSUPP; > } else { > - __cpu_suspend_exit(); > + RCU_NONIDLE(__cpu_suspend_exit()); > } > > unpause_graph_tracing(); Ah, looks so much better! Acked-by: Marc Zyngier M. -- Jazz is not dead. It just smells funny... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel