Received: by 10.213.65.68 with SMTP id h4csp717342imn; Fri, 6 Apr 2018 07:46:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx48FB3Ba1wq+Sg3Vxsq/VQ/xArw87ZR3BhwHM4ewlVdsr96KJ4xBLXPBTfGEgc1ApEJAe5Ts X-Received: by 2002:a17:902:b707:: with SMTP id d7-v6mr28000209pls.188.1523026009949; Fri, 06 Apr 2018 07:46:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523026009; cv=none; d=google.com; s=arc-20160816; b=ZglbQ4d57GdLlFJ9nR0W49Rf6U44Ad+mudidzquRzRXB2N2gsYxJDDlcT9Sy1aiFZi Z8CZUJloAwrbe6ErHnsiV0AMM5bm+hqPxV3KCbBkd3v1ev56W9UrR1c4sR9VgvNiadgO Jsg4MHeZbK1wCToBnBIeDXsKpwJjTGCx3NykWXu4u2Lc2OK9uAqVw4o8/U4f7hlm0KNw TecJePN7hpSsQYakYXgaJzHhHfO2kKOf8JkYNESLRYyWdI9lnyQ0eJ5uMjmkbp9uqSeM SdfHiOiD/rlI1HeDtQfdhgnzh0xMj7qCapvEY2Qw/LlTcfQNFgarOvSD0GTbsG/PVrMG +e0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=V8HClNqZ80DYITDFgpPF4lAEMFsrZZAKagHjG03hM98=; b=trHMAONqsBUyZwjTkNDdyKy5Ryg9WqmQfjg9klFssmoWUacB03JSRbOmDZfWoFqVgm aAIzv23OWEmwpDor66jKwGPl6FRsgHxnD/nHuXYv3Jnl7E8TCKXvFkIPswvkmEmNFA7a ELtBLpVhgcpSxDTF3m0+/pSlCyyOJpvD0AXw7ElYUPEwrUt+54JA6ibRZMGgVV4/QAYT VDrDRuX/nkyHJErfdSsn34aZf0xbHB2CgWtJZ3AzJX931ee7A1UbgCm/oB/TkLkvr3zD KidvylblbgLbi3AY/Ot1V0dW+5sFk7YNQ5wwjlUq0squPPZpFIfhFlK5sNNIXmt/k95U o0xQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c41-v6si8614648plj.704.2018.04.06.07.46.36; Fri, 06 Apr 2018 07:46:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755825AbeDFOpQ (ORCPT + 99 others); Fri, 6 Apr 2018 10:45:16 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58100 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755730AbeDFNd7 (ORCPT ); Fri, 6 Apr 2018 09:33:59 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id F2CAAD02; Fri, 6 Apr 2018 13:33:57 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Carol L. Soto" , Nicholas Piggin , Michael Ellerman Subject: [PATCH 4.9 009/102] powerpc/64s: Fix lost pending interrupt due to race causing lost update to irq_happened Date: Fri, 6 Apr 2018 15:22:50 +0200 Message-Id: <20180406084332.878852809@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084331.507038179@linuxfoundation.org> References: <20180406084331.507038179@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nicholas Piggin commit ff6781fd1bb404d8a551c02c35c70cec1da17ff1 upstream. force_external_irq_replay() can be called in the do_IRQ path with interrupts hard enabled and soft disabled if may_hard_irq_enable() set MSR[EE]=1. It updates local_paca->irq_happened with a load, modify, store sequence. If a maskable interrupt hits during this sequence, it will go to the masked handler to be marked pending in irq_happened. This update will be lost when the interrupt returns and the store instruction executes. This can result in unpredictable latencies, timeouts, lockups, etc. Fix this by ensuring hard interrupts are disabled before modifying irq_happened. This could cause any maskable asynchronous interrupt to get lost, but it was noticed on P9 SMP system doing RDMA NVMe target over 100GbE, so very high external interrupt rate and high IPI rate. The hang was bisected down to enabling doorbell interrupts for IPIs. These provided an interrupt type that could run at high rates in the do_IRQ path, stressing the race. Fixes: 1d607bb3bd60 ("powerpc/irq: Add mechanism to force a replay of interrupts") Cc: stable@vger.kernel.org # v4.8+ Reported-by: Carol L. Soto Signed-off-by: Nicholas Piggin Signed-off-by: Michael Ellerman Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kernel/irq.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/arch/powerpc/kernel/irq.c +++ b/arch/powerpc/kernel/irq.c @@ -372,6 +372,14 @@ void force_external_irq_replay(void) */ WARN_ON(!arch_irqs_disabled()); + /* + * Interrupts must always be hard disabled before irq_happened is + * modified (to prevent lost update in case of interrupt between + * load and store). + */ + __hard_irq_disable(); + local_paca->irq_happened |= PACA_IRQ_HARD_DIS; + /* Indicate in the PACA that we have an interrupt to replay */ local_paca->irq_happened |= PACA_IRQ_EE; }