Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4458401ybz; Tue, 28 Apr 2020 11:38:08 -0700 (PDT) X-Google-Smtp-Source: APiQypIOj21lfMFdHVHMLmTJs3/ggu93CMkJggBsWhmVM2WjMtPX38kS8jCZ7vYXFkJySnMSMxBI X-Received: by 2002:a17:906:4e50:: with SMTP id g16mr25642682ejw.338.1588099087898; Tue, 28 Apr 2020 11:38:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588099087; cv=none; d=google.com; s=arc-20160816; b=pYaxmNzUoMuX8PEbDVNxsXGa92ch4Cv4Ayu3kBdsfx6CSiITJnM4oqZXaf+CWtr9bS 7+AN5J4ZPSnQYYi3ktbvr6SoAi5XRl7izNtx5h3oQea2nU2488ulPmdiAhHvxD05XLhO JF0I0y3EwkRonEuirnBMgZswppsEnnpIyuJzhoTM84xySziEOEdNsZ2UuM8Qmggvd+r3 6PGBLClceC+/YOOZpEXy1ucq+BOcITwcdZX347ZLeP+PUEzzLaOr7Ifx+ktWDAfVbI5w +YBOznHnKuY3+fUm6B1NMVrYPTpDkA4tHT9dywNz8qWwtDYua7bztwyVOzJoPUYzdDCN /EIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=B/7re9gFCcfAraqn4aNWr4CYmOVOBUKskNQ7bIfZdbw=; b=djFv89wJ7593oU3qQyWBav6XAm5pI/sXXQr8usYrLLyE/i9/IqT7BQTxOnv95lxNHx +XRbkAPZS5zHd3+QnrkS8JACc3t63zxq7hNiXMlE8Z8WDFT03UybE2HGlymSmHdAVx20 ujBQqumaa+hy94/YXUGzgj3gPv7Mt23IYJIf54lIIvQN8vQ3kHxVGFz7ayxYqX6CPBP/ ndBa8zWIhEISsg6rFEqrODSKu2BNk3tNJJyQBvuy5re5f9cfI4B/Td/x+uYh7c0bt45Z WKAMg67j92YdKma/Oyq5o/DMb+CRcmhAelwNpFv7G0AoGJDMpr1/WSrtsat99cPpnbG1 POzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="OHhwW/YT"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k9si2167656edj.96.2020.04.28.11.37.44; Tue, 28 Apr 2020 11:38:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="OHhwW/YT"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730261AbgD1Sf2 (ORCPT + 99 others); Tue, 28 Apr 2020 14:35:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:52560 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730245AbgD1Sf0 (ORCPT ); Tue, 28 Apr 2020 14:35:26 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 C747B208E0; Tue, 28 Apr 2020 18:35:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588098925; bh=yQHRGgg3m1GX/ZcnnSRuq3xEturIrft/FV/zlgGBQcA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OHhwW/YTOQmDuDltVuXO77ktZzc1zhn2jbkfaD/jvjhBZlHiJGKcMApmXH1mb/P9d H6fL9IRX/fxy3vUcQaBsIpeVgUCsGiAZ2Ndgx37zNWGIjO+QD7ZYYG6tE1TQA0EEyp wum0x7zUDZFPs5KqMBVV9zWA3ztTh4mNHOxcWLHQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Piggin , Michael Ellerman , Sasha Levin Subject: [PATCH 5.4 032/168] Revert "powerpc/64: irq_work avoid interrupt when called with hardware irqs enabled" Date: Tue, 28 Apr 2020 20:23:26 +0200 Message-Id: <20200428182235.783498423@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200428182231.704304409@linuxfoundation.org> References: <20200428182231.704304409@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nicholas Piggin [ Upstream commit abc3fce76adbdfa8f87272c784b388cd20b46049 ] This reverts commit ebb37cf3ffd39fdb6ec5b07111f8bb2f11d92c5f. That commit does not play well with soft-masked irq state manipulations in idle, interrupt replay, and possibly others due to tracing code sometimes using irq_work_queue (e.g., in trace_hardirqs_on()). That can cause PACA_IRQ_DEC to become set when it is not expected, and be ignored or cleared or cause warnings. The net result seems to be missing an irq_work until the next timer interrupt in the worst case which is usually not going to be noticed, however it could be a long time if the tick is disabled, which is against the spirit of irq_work and might cause real problems. The idea is still solid, but it would need more work. It's not really clear if it would be worth added complexity, so revert this for now (not a straight revert, but replace with a comment explaining why we might see interrupts happening, and gives git blame something to find). Fixes: ebb37cf3ffd3 ("powerpc/64: irq_work avoid interrupt when called with hardware irqs enabled") Signed-off-by: Nicholas Piggin Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20200402120401.1115883-1-npiggin@gmail.com Signed-off-by: Sasha Levin --- arch/powerpc/kernel/time.c | 44 +++++++++++--------------------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index 11301a1187f33..0e0a2227af7d7 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c @@ -522,35 +522,6 @@ static inline void clear_irq_work_pending(void) "i" (offsetof(struct paca_struct, irq_work_pending))); } -void arch_irq_work_raise(void) -{ - preempt_disable(); - set_irq_work_pending_flag(); - /* - * Non-nmi code running with interrupts disabled will replay - * irq_happened before it re-enables interrupts, so setthe - * decrementer there instead of causing a hardware exception - * which would immediately hit the masked interrupt handler - * and have the net effect of setting the decrementer in - * irq_happened. - * - * NMI interrupts can not check this when they return, so the - * decrementer hardware exception is raised, which will fire - * when interrupts are next enabled. - * - * BookE does not support this yet, it must audit all NMI - * interrupt handlers to ensure they call nmi_enter() so this - * check would be correct. - */ - if (IS_ENABLED(CONFIG_BOOKE) || !irqs_disabled() || in_nmi()) { - set_dec(1); - } else { - hard_irq_disable(); - local_paca->irq_happened |= PACA_IRQ_DEC; - } - preempt_enable(); -} - #else /* 32-bit */ DEFINE_PER_CPU(u8, irq_work_pending); @@ -559,16 +530,27 @@ DEFINE_PER_CPU(u8, irq_work_pending); #define test_irq_work_pending() __this_cpu_read(irq_work_pending) #define clear_irq_work_pending() __this_cpu_write(irq_work_pending, 0) +#endif /* 32 vs 64 bit */ + void arch_irq_work_raise(void) { + /* + * 64-bit code that uses irq soft-mask can just cause an immediate + * interrupt here that gets soft masked, if this is called under + * local_irq_disable(). It might be possible to prevent that happening + * by noticing interrupts are disabled and setting decrementer pending + * to be replayed when irqs are enabled. The problem there is that + * tracing can call irq_work_raise, including in code that does low + * level manipulations of irq soft-mask state (e.g., trace_hardirqs_on) + * which could get tangled up if we're messing with the same state + * here. + */ preempt_disable(); set_irq_work_pending_flag(); set_dec(1); preempt_enable(); } -#endif /* 32 vs 64 bit */ - #else /* CONFIG_IRQ_WORK */ #define test_irq_work_pending() 0 -- 2.20.1