Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp821748rwi; Wed, 19 Oct 2022 03:28:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7i0J4/qdOlH5qGJaHc4cRDMzXHEdBjaTPGTPx7lcNJPJ3VKJUbLEs1INy6tj8RlJYyY9h+ X-Received: by 2002:a17:906:ef8c:b0:78d:96b9:a0ad with SMTP id ze12-20020a170906ef8c00b0078d96b9a0admr6215870ejb.529.1666175338988; Wed, 19 Oct 2022 03:28:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666175338; cv=none; d=google.com; s=arc-20160816; b=DCRdxV/aC5wLTX5npjdReGxjE/IB2iI2IaS7ZOCijnZel2HSBgyDRKx91X/HlUT7eX LfgRrb53KE/whisCUFcSgSiFj7AiPJ4SAvOaW75BU9qrtLYy8XqLpvukKDOyF/69eZgl eTpIZYeTseV9SzeXx5I1MAN1mg3LSbj7RUv7ETQcZqP+p8Op8nNYgus91mG/bAaxDfxA hVVhG5g+nX42rB0dnc46Cuw05/vGPzSETou4ndrYmBJW2VaGJWMGmw/7HUbZxcs+guAt 6x33cG9UET1b4yWU4DnLlWDCL2MxkuvicXSLwkOT3Y7LTD/CBS5EkzGbgUD8c2VRIUUs gtvQ== 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=M4FBYP+8KOnG9NQPi7cLr2pqxzDFouRgzRtGIwP5jrkL69aYIxHTHG+rdEUrpW/w+g Fi8bmj4agQdR+eyibhM9ibij802QpN2C9WzqlbcqqidnrqhsE0Y97gPA6invNu2/kJGs Lm+W1llGNI7agVgmrgj+UNTbyABGeU5ejQvbsdWQFht/OErlyTZnT3kzCZEgJZZhUuNb cADjkhvzzUpuDJQ65O2oZpSjEGcJeHBdHGxwmuiK4/6xxHv5WBY3x630SW3Ace2Ly58b VbeAOGVmvXQyIEyKpWrG+Mi+8as09yHnNQrUZ30wyciZecroqE+GTRBvFm8CzXLuavmC 8s7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ywmKqZuG; 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 cb17-20020a0564020b7100b00459c448d32csi12093595edb.446.2022.10.19.03.28.32; Wed, 19 Oct 2022 03:28:58 -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=ywmKqZuG; 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 S234479AbiJSJoL (ORCPT + 99 others); Wed, 19 Oct 2022 05:44:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234577AbiJSJkr (ORCPT ); Wed, 19 Oct 2022 05:40:47 -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 8C705F035F; Wed, 19 Oct 2022 02:17:09 -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 3E53B61800; Wed, 19 Oct 2022 09:16:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56855C433C1; Wed, 19 Oct 2022 09:16:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666171000; bh=0fvtEFI43QThxu2xB2MBCAmBh4JcfuNcBuF2dhDcgv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ywmKqZuGivTVQepAN3b+e1fTXAyOEo6M4EGLK+BNsbWacYurRSC1hekOEiwKhxMTI noForu5Y4v0goiBtsnIQ0xSrzTGKrBkhfv1M6lfrvUWsIt1EGayXOumbtQe8UqSFrQ EB1/1bz3TLTJvIKCRJVwyhOLHEq6hO9VSIIMo+5Y= 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 6.0 856/862] powerpc/64s/interrupt: Fix lost interrupts when returning to soft-masked context Date: Wed, 19 Oct 2022 10:35:43 +0200 Message-Id: <20221019083327.701054960@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@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