lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201218143122.19459-15-info@metux.net>
Date:   Fri, 18 Dec 2020 15:31:13 +0100
From:   "Enrico Weigelt, metux IT consult" <info@...ux.net>
To:     linux-kernel@...r.kernel.org
Cc:     mark.rutland@....com, alexander.shishkin@...ux.intel.com,
        jolsa@...hat.com, namhyung@...nel.org, catalin.marinas@....com,
        will@...nel.org, msalter@...hat.com, jacquiot.aurelien@...il.com,
        gerg@...ux-m68k.org, geert@...ux-m68k.org,
        tsbogend@...ha.franken.de, James.Bottomley@...senPartnership.com,
        deller@....de, benh@...nel.crashing.org, paulus@...ba.org,
        ysato@...rs.sourceforge.jp, dalias@...c.org, davem@...emloft.net,
        tglx@...utronix.de, bp@...en8.de, x86@...nel.org, hpa@...or.com,
        linus.walleij@...aro.org, bgolaszewski@...libre.com,
        maz@...nel.org, tony@...mide.com, arnd@...db.de,
        linux-alpha@...r.kernel.org, linux-c6x-dev@...ux-c6x.org,
        linux-ia64@...r.kernel.org, linux-m68k@...ts.linux-m68k.org,
        linux-mips@...r.kernel.org, linux-parisc@...r.kernel.org,
        linuxppc-dev@...ts.ozlabs.org, linux-s390@...r.kernel.org,
        linux-sh@...r.kernel.org, sparclinux@...r.kernel.org,
        linux-gpio@...r.kernel.org, linux-omap@...r.kernel.org,
        linux-arch@...r.kernel.org
Subject: [PATCH 14/23] kernel: generic counter for interrupt errors

We currently have counters for spurious interrupt spread over all the
individual architectures. Mostly done in the arch's ack_bad_irq(),
sometimes also in arch specific drivers.

It's time to consolidate this code duplication:

  * introduce a global counter and inlined accessors
  * increase the counter in all call sites of ack_bad_irq()
  * subsequent patches will transform the individual archs one by one

Signed-off-by: Enrico Weigelt, metux IT consult <info@...ux.net>
---
 include/asm-generic/irq-err.h | 17 +++++++++++++++++
 kernel/irq/dummychip.c        |  2 ++
 kernel/irq/handle.c           |  4 ++++
 kernel/irq/irqdesc.c          |  2 ++
 4 files changed, 25 insertions(+)
 create mode 100644 include/asm-generic/irq-err.h

diff --git a/include/asm-generic/irq-err.h b/include/asm-generic/irq-err.h
new file mode 100644
index 000000000000..33c75eb50c10
--- /dev/null
+++ b/include/asm-generic/irq-err.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ASM_GENERIC_IRQ_ERR_H
+#define __ASM_GENERIC_IRQ_ERR_H
+
+extern atomic_t irq_err_counter;
+
+static inline void irq_err_inc(void)
+{
+	atomic_inc(&irq_err_counter);
+}
+
+static inline int irq_err_get(void)
+{
+	return atomic_read(&irq_err_counter);
+}
+
+#endif /* __ASM_GENERIC_IRQ_ERR_H */
diff --git a/kernel/irq/dummychip.c b/kernel/irq/dummychip.c
index 0b0cdf206dc4..93585dab9bd0 100644
--- a/kernel/irq/dummychip.c
+++ b/kernel/irq/dummychip.c
@@ -8,6 +8,7 @@
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/export.h>
+#include <asm-generic/irq-err.h>
 
 #include "internals.h"
 
@@ -20,6 +21,7 @@ static void ack_bad(struct irq_data *data)
 	struct irq_desc *desc = irq_data_to_desc(data);
 
 	print_irq_desc(data->irq, desc);
+	irq_err_inc();
 	ack_bad_irq(data->irq);
 }
 
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index 762a928e18f9..ad90f5a56c3a 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -13,11 +13,14 @@
 #include <linux/sched.h>
 #include <linux/interrupt.h>
 #include <linux/kernel_stat.h>
+#include <asm-generic/irq-err.h>
 
 #include <trace/events/irq.h>
 
 #include "internals.h"
 
+atomic_t irq_err_counter;
+
 #ifdef CONFIG_GENERIC_IRQ_MULTI_HANDLER
 void (*handle_arch_irq)(struct pt_regs *) __ro_after_init;
 #endif
@@ -34,6 +37,7 @@ void handle_bad_irq(struct irq_desc *desc)
 
 	print_irq_desc(irq, desc);
 	kstat_incr_irqs_this_cpu(desc);
+	irq_err_inc();
 	ack_bad_irq(irq);
 }
 EXPORT_SYMBOL_GPL(handle_bad_irq);
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 62a381351775..6192672be4d2 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -16,6 +16,7 @@
 #include <linux/bitmap.h>
 #include <linux/irqdomain.h>
 #include <linux/sysfs.h>
+#include <asm-generic/irq-err.h>
 
 #include "internals.h"
 
@@ -684,6 +685,7 @@ int __handle_domain_irq(struct irq_domain *domain, unsigned int hwirq,
 		if (printk_ratelimit())
 			pr_warn("spurious IRQ: irq=%d hwirq=%d nr_irqs=%d\n",
 				irq, hwirq, nr_irqs);
+		irq_err_inc();
 		ack_bad_irq(irq);
 		ret = -EINVAL;
 	} else {
-- 
2.11.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ