Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1760541ybz; Sat, 18 Apr 2020 07:57:10 -0700 (PDT) X-Google-Smtp-Source: APiQypKXr4CSuQe/P0n0h+1ALv55Xwcs0JfzZ8qCT90P75PWZneU+gYeCkfIoWRCQctoyqYM2pvG X-Received: by 2002:a17:906:2a86:: with SMTP id l6mr8132689eje.273.1587221830433; Sat, 18 Apr 2020 07:57:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587221830; cv=none; d=google.com; s=arc-20160816; b=Mp/KIDhODw6jNfLcrY8c7J798A2+ewIEGuD7vG467ErayRgqVg8YbuH2ZRIFiLNwLe C0wmEHMiZ8NgmOmAZ5O17xOpERourlrWxuMNRXdyXElhg3XC/VOMKwSjaSKGmZuckWX9 G/vpvnRaahEsf2WLvLoU1/KclSvCg1qWd3PyuqrJXD2BJLO8Fhyzv7q+ZheXZ2znhlO7 WLt2zjrx62T2ZbIf+lNNMRRKn/QHv3CbuUnYcwqSE8z44xAxo+3V4Ta5cIVrzQzVtEWP 6BSslG//8fqIplLw6dE66uOQk7leCp55hSjA78I9uMM7+fgwUGrrcElb9WZcgnn/+fPK ds7A== 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=B/7re9gFCcfAraqn4aNWr4CYmOVOBUKskNQ7bIfZdbw=; b=Hzrq6JV057f5JY4X9sXFQDcAWbWl1obsx/hV5FuFfObtOGu+qpdUv5KBPlk/VqArFe xagHhXUyGochJhZmP7Ip63DdmrnnRtanxKVQT2EDWikVuqN2EN+1D2RvQKuT7tZRSyJe v6cO1dTfFFv8qPR2dkgZBLDNqn+jieJYPmF6dUN+MgzLDOOWAonNXPGp9XD2sR4jSswG GDaA5KiPg408APBZxGqOqjokLfve9Z7rlLtGQlYBAg2vWUM8LwJXszGv0VWe+WVDhMWy ScmvdJORSGM5wBoTVk+hzROseVBqPh+eiMldJ8vkB4urLEBnk/HBvBcP7MkWvDn+a3lC OUDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=txVXuX4F; 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 cx17si11796929edb.383.2020.04.18.07.56.48; Sat, 18 Apr 2020 07:57:10 -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=txVXuX4F; 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 S1728843AbgDROyo (ORCPT + 99 others); Sat, 18 Apr 2020 10:54:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:50734 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728037AbgDROld (ORCPT ); Sat, 18 Apr 2020 10:41:33 -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 2D4CA22244; Sat, 18 Apr 2020 14:41:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587220892; bh=yQHRGgg3m1GX/ZcnnSRuq3xEturIrft/FV/zlgGBQcA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=txVXuX4FsPgaEmcG0mrN+6F5X/LTHswtn5TV/tFY3ygEPrgoZxMj2hDlP5k0GumFe w5gqie5tMAryC19/868rTsWfDr3FgKFfm/MDMrTMbja2avJo7e8U/t36aJwwSkyRLb 0Zgw+vOjgh9RLvWc3REYEil1+HG4qlw+eiLw2l0Y= 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.4 35/78] Revert "powerpc/64: irq_work avoid interrupt when called with hardware irqs enabled" Date: Sat, 18 Apr 2020 10:40:04 -0400 Message-Id: <20200418144047.9013-35-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200418144047.9013-1-sashal@kernel.org> References: <20200418144047.9013-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 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