Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1723586ybz; Sat, 18 Apr 2020 07:11:58 -0700 (PDT) X-Google-Smtp-Source: APiQypLZfPTrHhG218zwv83Q0qCwDfbF4t0eIwd/2ownrbpxuv4Izu7rynaBbr16WdRncNy7JDks X-Received: by 2002:a50:9b53:: with SMTP id a19mr7477902edj.104.1587219118465; Sat, 18 Apr 2020 07:11:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587219118; cv=none; d=google.com; s=arc-20160816; b=bcU4pjMT057mf221P11vXnVBjlO3sOxjO36JczYZNed/qEsEUrR7J8QWj3HaaO91+Q dKnUqawEqsKwexczdC97aBh+j418d2V/6filVIckRpgPbyi4cW5FqK2tc7i4rrv5AlcT 8PzaqNRSjd+uEbg29kuhfCeUtWAZQXyieJWA336i3QNBPkRHcsgaHzM7vXhp5o2dvV2F vhHwCS2bTTIHCdtWqEK75nLLTFaGsMozEKTRAVgTGUHM1zj5/G3cg8qkCEqZ+0rvYJ8n 86cohwzlN+YXJyI/EqOa2xifDnuPmPR0Ok6VwgUuCmHlpX66tMwC6pYHSNPk3W748y2G KIhQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Uv358UNvFbGHlEH788oJFfs13TAmlGMbo5Lug3M/xSQ=; b=OFbp5qB/tQ38BdnmDinTui+JVSnwpPkgJwiuiLF1Zp95T775RrZs/6SrRB1f5cJ4S8 7H/Lf1GxHqeaZfBJYlGvwyng/gyMI9pwkaB+y9Q1lX9EpyDVMDDfIpNTvXirfcpT4A+w 3gNoFE1ADTUAjH1DirbdujraFzeOEolE4E09F5srwSBf+PskBoABccjodc6Xjrp9LpIH Nh3Tog8PhIgvItJyxVxKxnul9v2eRb7arADYeHg9hChWK9CG8num8QV6GPYjaNcWvXAc DX9YA/VkpKQblLlhM7b0bp7BIeMzW3UbiY6G7HABKLIeKujeHCsCgH7iRcPih+NqQxVz xeqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="L2/8ubJb"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l30si2638483edl.17.2020.04.18.07.11.36; Sat, 18 Apr 2020 07:11:58 -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="L2/8ubJb"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726813AbgDROKF (ORCPT + 99 others); Sat, 18 Apr 2020 10:10:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:37720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726760AbgDROJ6 (ORCPT ); Sat, 18 Apr 2020 10:09:58 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 111C622240; Sat, 18 Apr 2020 14:09:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587218997; bh=iljF7Edtms053YjF9mQtzQ/ve2E9hUgK2Tcg3enhmPM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L2/8ubJbdZDKs+6bkDQgJpSKC6wNIRYrMu2OdgfbgsEGNuOR7gDjrtg4RoePTWCbN eM5ty3+W8gQqnJA6B+4IxyvsRVIgS6cjCEtnz3MAshrvjccfc2vCg5rtnywUa22VXm fJSFxVaKekrIaKjNW3Z0dSA6yx5T08Cy5xVYDJrI= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nicholas Piggin , Michael Ellerman , Sasha Levin , linuxppc-dev@lists.ozlabs.org Subject: [PATCH AUTOSEL 5.5 37/75] Revert "powerpc/64: irq_work avoid interrupt when called with hardware irqs enabled" Date: Sat, 18 Apr 2020 10:08:32 -0400 Message-Id: <20200418140910.8280-37-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200418140910.8280-1-sashal@kernel.org> References: <20200418140910.8280-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 1168e8b37e306..716f8d0960a7b 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