Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1688568ybi; Wed, 17 Jul 2019 20:09:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6tGXtF/XnQvca5DwjnX7GzzYNBW2P6LjZcys1SqzaxjUn5perDsUPO+5VfMbGCaV3JS9b X-Received: by 2002:a17:90a:22c6:: with SMTP id s64mr49095699pjc.5.1563419385733; Wed, 17 Jul 2019 20:09:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563419385; cv=none; d=google.com; s=arc-20160816; b=FUvRVYRg6ErzKi8mHazDsKWfQf0TWWTFQfg0YV/SF8hu9xYZqrxdaPk+7LP+lcMxGc X7Ij8uK3DQluSFKmLx3Ye40VDnpCyoereEX2WANfninGDxck0JfUc/wjreACERKhszhq RMbiWK4D0fwjCt+P07/vGRloaBcJPLpX9YvREYnHnMT20B/hfpV6OTNfKyG5PlaZsSMv LoO3e2w/18sh2xOV21ADBUOhktEilZiNxV9N24SeIeQYA3vf1b2lzSchl428XP5cm9Ho TDPBNBWIpFL0Y4zfXBleykG1mMxiDI5X+ykX8FpFd3eITeKONBtIvnLxAxWXFfyCWIw9 EtJQ== 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=APTrleS0XyBfhYw358iho/3qhQeJp17PNBctvFbXXIM=; b=fZaLERB0wEQROtwd8jeXGTN7aydRajAeL7ceoUNsTrlE9yP62LGZcRiZZfm4ZBd38S CdFp8KEmy9k2M8oyTuyJeRp5tR3oCDiuuwHyty3lZ6hdzhXmM2bzi5Fm8zdonfzSnl6m CzUnCRp83Kx4FKnDEZ2PKq9s5qxeRt4fSD1iv6BtnQIRCt4FgCeABLzOM13+vbRK2gBU 1pFIEgAHk5FAFRnL2YSwOIuubzXs7R5+kclkTuS5DOizRzQioAXBkmiA4pHnGFARWrTa HPmGszxR8+XJLmJSNHXY4oNVY/4JM0CcZswsCCkw8HOP9ph6RxWSgiLIOzFIjyQNL5Ts YbKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=l2NxL3NV; 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 q24si27035494pff.62.2019.07.17.20.09.30; Wed, 17 Jul 2019 20:09:45 -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; dkim=pass header.i=@kernel.org header.s=default header.b=l2NxL3NV; 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 S2390717AbfGRDIW (ORCPT + 99 others); Wed, 17 Jul 2019 23:08:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:40246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390705AbfGRDIU (ORCPT ); Wed, 17 Jul 2019 23:08:20 -0400 Received: from localhost (115.42.148.210.bf.2iij.net [210.148.42.115]) (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 6011020818; Thu, 18 Jul 2019 03:08:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563419299; bh=2NnYurcBklqmnqT1VQithL4VeHbtrCVlDnNF0EYmTsE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l2NxL3NVKe0cw3MNh7dN4qGR+pQ17zs4l/xJBX+06n0dwxr2GjMvyJecnxPRn5aKz eBgzpp24Y1qXLw38KGpLC3aZkghDgbcAlOJqgi+S9EUIK/xqh+GZFxplbwcKu24rv+ 9vcv9K+9Gv18+SFtueX33y5S2XZn6mcBvpMH7ggo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robert Hodaszi , Marc Zyngier , Thomas Gleixner Subject: [PATCH 4.19 34/47] x86/irq: Handle spurious interrupt after shutdown gracefully Date: Thu, 18 Jul 2019 12:01:48 +0900 Message-Id: <20190718030051.635882875@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190718030045.780672747@linuxfoundation.org> References: <20190718030045.780672747@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: Thomas Gleixner tglx@linutronix.de commit b7107a67f0d125459fe41f86e8079afd1a5e0b15 upstream Since the rework of the vector management, warnings about spurious interrupts have been reported. Robert provided some more information and did an initial analysis. The following situation leads to these warnings: CPU 0 CPU 1 IO_APIC interrupt is raised sent to CPU1 Unable to handle immediately (interrupts off, deep idle delay) mask() ... free() shutdown() synchronize_irq() clear_vector() do_IRQ() -> vector is clear Before the rework the vector entries of legacy interrupts were statically assigned and occupied precious vector space while most of them were unused. Due to that the above situation was handled silently because the vector was handled and the core handler of the assigned interrupt descriptor noticed that it is shut down and returned. While this has been usually observed with legacy interrupts, this situation is not limited to them. Any other interrupt source, e.g. MSI, can cause the same issue. After adding proper synchronization for level triggered interrupts, this can only happen for edge triggered interrupts where the IO-APIC obviously cannot provide information about interrupts in flight. While the spurious warning is actually harmless in this case it worries users and driver developers. Handle it gracefully by marking the vector entry as VECTOR_SHUTDOWN instead of VECTOR_UNUSED when the vector is freed up. If that above late handling happens the spurious detector will not complain and switch the entry to VECTOR_UNUSED. Any subsequent spurious interrupt on that line will trigger the spurious warning as before. Fixes: 464d12309e1b ("x86/vector: Switch IOAPIC to global reservation mode") Reported-by: Robert Hodaszi Signed-off-by: Thomas Gleixner - Tested-by: Robert Hodaszi Cc: Marc Zyngier Link: https://lkml.kernel.org/r/20190628111440.459647741@linutronix.de Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/hw_irq.h | 3 ++- arch/x86/kernel/apic/vector.c | 4 ++-- arch/x86/kernel/irq.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) --- a/arch/x86/include/asm/hw_irq.h +++ b/arch/x86/include/asm/hw_irq.h @@ -151,7 +151,8 @@ extern char irq_entries_start[]; #endif #define VECTOR_UNUSED NULL -#define VECTOR_RETRIGGERED ((void *)~0UL) +#define VECTOR_SHUTDOWN ((void *)~0UL) +#define VECTOR_RETRIGGERED ((void *)~1UL) typedef struct irq_desc* vector_irq_t[NR_VECTORS]; DECLARE_PER_CPU(vector_irq_t, vector_irq); --- a/arch/x86/kernel/apic/vector.c +++ b/arch/x86/kernel/apic/vector.c @@ -342,7 +342,7 @@ static void clear_irq_vector(struct irq_ trace_vector_clear(irqd->irq, vector, apicd->cpu, apicd->prev_vector, apicd->prev_cpu); - per_cpu(vector_irq, apicd->cpu)[vector] = VECTOR_UNUSED; + per_cpu(vector_irq, apicd->cpu)[vector] = VECTOR_SHUTDOWN; irq_matrix_free(vector_matrix, apicd->cpu, vector, managed); apicd->vector = 0; @@ -351,7 +351,7 @@ static void clear_irq_vector(struct irq_ if (!vector) return; - per_cpu(vector_irq, apicd->prev_cpu)[vector] = VECTOR_UNUSED; + per_cpu(vector_irq, apicd->prev_cpu)[vector] = VECTOR_SHUTDOWN; irq_matrix_free(vector_matrix, apicd->prev_cpu, vector, managed); apicd->prev_vector = 0; apicd->move_in_progress = 0; --- a/arch/x86/kernel/irq.c +++ b/arch/x86/kernel/irq.c @@ -246,7 +246,7 @@ __visible unsigned int __irq_entry do_IR if (!handle_irq(desc, regs)) { ack_APIC_irq(); - if (desc != VECTOR_RETRIGGERED) { + if (desc != VECTOR_RETRIGGERED && desc != VECTOR_SHUTDOWN) { pr_emerg_ratelimited("%s: %d.%d No irq handler for vector\n", __func__, smp_processor_id(), vector);