Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3968409rwi; Sat, 22 Oct 2022 03:05:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6/FLAX8MFzR1ngE0NHjB+YsKd/7tPC2iXIlC/G8mNft4Ey7T0V85i2a7n9Tl1vXKj8tbkG X-Received: by 2002:a63:1455:0:b0:438:e26b:ab1f with SMTP id 21-20020a631455000000b00438e26bab1fmr19291069pgu.183.1666433103637; Sat, 22 Oct 2022 03:05:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666433103; cv=none; d=google.com; s=arc-20160816; b=GIx27gw9WZ+/8ZrMBSCdzJLJqIBviVhqljO+qkVPh5roarW3r/TH5S9lEib/0bF1iZ x/L4/04Tx4C+f6PlhGmIdpB5xTb745MGhGkREx7nc5hXFJ0MSRskPCNY1hzUgw9MLFiN p8pboGDD+fIjbdF31XfNi7Qkg8CFzURt5V5yZNvt/LR5IWCD3S6HWaaw0l4hwi6rzxjN 2g/+PzKIkwb+DMdXNUEv6nbF87FYFPotoBNLpyfwBEZDiTQXj4DLDnHXl4xuM9eZ8gk9 EUOAMA9JwK3BSbuUTPly2f0IYOuSdWYnla+z55YZpKRKMV1nOWNSMuda5gdqUeVPk26+ SwPg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7qLPlh+qY61Vg0AVqBdPPqLOxPS0TKWJgcCBAzrOCvM=; b=EwhVTt10YLItkpURE4ffZww4gtua65WWRr4V3bcvFqpWQJTSQsDKcijYp6+7gA5PyP gfhehdSr3evAb/IZXfYQTnt0Aa3pj7JEAvVCYsbnNJvoOPxwhVNljuG7I3PDYislEhJr CCdU0XLqGwKYVJ2m7yapAhv4rzxBB3KRiTMOuP+PgzHxlH+sPRBBbfgnwVQlAn45aaq1 6aOZ9ROGBT0Q3MeQQFV3QDFIjcdIeN0Tub5uU4/tf7orojhRqS+YvCuuT43FgEYVflrp rIKVXsal9652pXUnXuTqu4tlcRjAmoo08o2ZrRBOj/S4/IcTzP16U/GWVJenWn1Gs6Sf UhMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fefuh4Dg; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z5-20020a63c045000000b0043af57e5d16si25611970pgi.724.2022.10.22.03.04.49; Sat, 22 Oct 2022 03:05:03 -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=@linuxfoundation.org header.s=korg header.b=fefuh4Dg; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229574AbiJVKAM (ORCPT + 99 others); Sat, 22 Oct 2022 06:00:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230157AbiJVJ7o (ORCPT ); Sat, 22 Oct 2022 05:59:44 -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 2BDB241523; Sat, 22 Oct 2022 02:14:39 -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 C026860BA2; Sat, 22 Oct 2022 08:07:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B09DBC433D7; Sat, 22 Oct 2022 08:07:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666426066; bh=0fvtEFI43QThxu2xB2MBCAmBh4JcfuNcBuF2dhDcgv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fefuh4DgUy9JFXTL2te6slUHKb/QL3QRl5hyrZx5KQQDHHDz3C+JlQGMSIQoiFRji OuKAPRgnrFzDLRaaG4IbdZ7mhA8QPYXQSblA+203GY7eKxrsMZWkBkVQgq3XJnDwux RcoSp/r39F5EHGBp33mZrnEAcReRNZsT3SyIGe08= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sachin Sant , Guenter Roeck , Nicholas Piggin , Michael Ellerman Subject: [PATCH 5.19 707/717] powerpc/64s/interrupt: Fix lost interrupts when returning to soft-masked context Date: Sat, 22 Oct 2022 09:29:46 +0200 Message-Id: <20221022072529.720783758@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 From: Nicholas Piggin commit a4cb3651a174366cc85a677da9e3681fbe97fdae upstream. It's possible for an interrupt returning to an irqs-disabled context to lose a pending soft-masked irq because it branches to part of the exit code for irqs-enabled contexts, which is meant to clear only the PACA_IRQS_HARD_DIS flag from PACAIRQHAPPENED by zeroing the byte. This just looks like a simple thinko from a recent commit (if there was no hard mask pending, there would be no reason to clear it anyway). This also adds comment to the code that actually does need to clear the flag. Fixes: e485f6c751e0a ("powerpc/64/interrupt: Fix return to masked context after hard-mask irq becomes pending") Reported-by: Sachin Sant Reported-by: Guenter Roeck Signed-off-by: Nicholas Piggin Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20221013064418.1311104-1-npiggin@gmail.com Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kernel/interrupt_64.S | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) --- a/arch/powerpc/kernel/interrupt_64.S +++ b/arch/powerpc/kernel/interrupt_64.S @@ -571,7 +571,7 @@ _ASM_NOKPROBE_SYMBOL(interrupt_return_\s beq .Lfast_kernel_interrupt_return_\srr\() // EE already disabled lbz r11,PACAIRQHAPPENED(r13) andi. r10,r11,PACA_IRQ_MUST_HARD_MASK - beq 1f // No HARD_MASK pending + beq .Lfast_kernel_interrupt_return_\srr\() // No HARD_MASK pending /* Must clear MSR_EE from _MSR */ #ifdef CONFIG_PPC_BOOK3S @@ -588,12 +588,23 @@ _ASM_NOKPROBE_SYMBOL(interrupt_return_\s b .Lfast_kernel_interrupt_return_\srr\() .Linterrupt_return_\srr\()_soft_enabled: + /* + * In the soft-enabled case, need to double-check that we have no + * pending interrupts that might have come in before we reached the + * restart section of code, and restart the exit so those can be + * handled. + * + * If there are none, it is be possible that the interrupt still + * has PACA_IRQ_HARD_DIS set, which needs to be cleared for the + * interrupted context. This clear will not clobber a new pending + * interrupt coming in, because we're in the restart section, so + * such would return to the restart location. + */ #ifdef CONFIG_PPC_BOOK3S lbz r11,PACAIRQHAPPENED(r13) andi. r11,r11,(~PACA_IRQ_HARD_DIS)@l bne- interrupt_return_\srr\()_kernel_restart #endif -1: li r11,0 stb r11,PACAIRQHAPPENED(r13) // clear the possible HARD_DIS