Received: by 10.213.65.68 with SMTP id h4csp647258imn; Fri, 6 Apr 2018 06:43:27 -0700 (PDT) X-Google-Smtp-Source: AIpwx49dIdavJZQ06Y/pC/pDV93pPzgQ7OghHntbai7lHm1dmGb102ooakHZXq4C0tPVGvuOb3IV X-Received: by 10.98.8.133 with SMTP id 5mr20329158pfi.154.1523022207797; Fri, 06 Apr 2018 06:43:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523022207; cv=none; d=google.com; s=arc-20160816; b=I1pzIIa7QlMSuTZw06rG0ILdL5V0eUgKtUTqfXqEoFbTz60ig3laBj3rdFdSKnRFEH S8GdbTzTHsCDeQI8bPaQEo5/yGVdmUNLqDEvoC/0t9kbLs/0WM9pV9ad5u2BEyhGyYvo YemLcpp/06Pai94EhTMabskFpujNHDL1Wf5WVsyi+cASBPuogO1Ov4C7oJ1gLUKBywEl ergIPwbXuVMABG8sKr3d+ZXfIBXpP6CVEAkyxkrlhsrDtuHmxjxHglVOAHhya3P2eFe/ tvFRIIB0lJaXrCTgz+1c2aqn4N1tPJ0J4lWE+OmowRaXgeaowfm5B52hoZyiGx/Oowsc 91Bw== 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=JK+K9ev3BsSGHCfKs27YDgYvF3sT+kbBRKJ45NF9dX0=; b=bRr/GI4FtCl0tHOf5YWf+962yc8uqrBfP2CgC9fBGleZMFUjMHJEttcV5Hiy+Tdgjn QBKne0gk9+sQ/nBSDxicHuS4BYlRoqCttfu4rFFUq3zPNLM26XJ7RiM5b+LPGJ0xCm3Q HTVQf5YYbvYfTFoq6UaX/EBTtNRwL5xd6cmwQWngQOe0ZOow37ljf+yGPUr7Fahtblmz Ct0f66lqZuoSHBKI/F/kEsGBLBbbKneMdyzcDjUop+1bpjPVGGp1uBI5nUxyMJibWene F2T9sx9HGT/bn7RwzH2FbgJuVj57B0rqe16xvsVpKwh9C2gdK/zT1whupbqbqYI0FHEW Q6Tw== 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 b9si7344645pgn.191.2018.04.06.06.43.13; Fri, 06 Apr 2018 06:43:27 -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 S932938AbeDFNmD (ORCPT + 99 others); Fri, 6 Apr 2018 09:42:03 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36720 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932615AbeDFNmB (ORCPT ); Fri, 6 Apr 2018 09:42:01 -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 75130D2E; Fri, 6 Apr 2018 13:42:00 +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.15 17/72] powerpc/64s: Fix lost pending interrupt due to race causing lost update to irq_happened Date: Fri, 6 Apr 2018 15:23:52 +0200 Message-Id: <20180406084350.872940110@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084349.367583460@linuxfoundation.org> References: <20180406084349.367583460@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.15-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 @@ -475,6 +475,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; }