From patchwork Sat Oct 22 07:29:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7800 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1133456wrr; Sat, 22 Oct 2022 03:04:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6QaIJmP/6294SJdUcFnmy4tIAkC9IvG9vwwxKzqPLcuH6q5OtG+B6x3ToD5A/BKCPief/H X-Received: by 2002:a05:6a00:843:b0:563:fd4:d73 with SMTP id q3-20020a056a00084300b005630fd40d73mr23568805pfk.47.1666433076445; Sat, 22 Oct 2022 03:04:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666433076; cv=none; d=google.com; s=arc-20160816; b=odpPCB7TtRtz6QhCB30AgTTVJw1TohmjvHsoioRDSQTSMawHacbOHoKQ0TOGS2S4GR d2EOs20R0/d7gr934ZD084S7yCqaNuw0aXuWQroLIa7xaBkciUb83F1roTu0S7nnW2FA au/3LTG7nVOAEqY/mB8MUTR21uK9e0f0C0hLKr/8UcX3pwGoHOgsBmRVnGBnCM8H60Tr smiuvikpULKvhRkOHpy7lRBZWUMBqGwP0Kftmewe+2wJbETo2lEm3LBdjCyNRiuVLgHj ua6ZJjW9ymJhnEQeOIPwDVbA72r0BSis/yftNafzkDtlo7d7x0cd7ZEQXKWCvAj8qMxW R5hA== 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 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.22; Sat, 22 Oct 2022 03:04:36 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747381729674135673?= X-GMAIL-MSGID: =?utf-8?q?1747381729674135673?= 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