git: 10625515ad47 - stable/13 - MFC: mips: fix early kernel panic when setting up interrupt counters
Oleksandr Tymoshenko
gonzo at FreeBSD.org
Wed Feb 3 05:06:49 UTC 2021
The branch stable/13 has been updated by gonzo:
URL: https://cgit.FreeBSD.org/src/commit/?id=10625515ad47b52f38c13f4f1d8f8c848e9df4ee
commit 10625515ad47b52f38c13f4f1d8f8c848e9df4ee
Author: Oleksandr Tymoshenko <gonzo at FreeBSD.org>
AuthorDate: 2021-02-01 07:56:22 +0000
Commit: Oleksandr Tymoshenko <gonzo at FreeBSD.org>
CommitDate: 2021-02-03 05:06:37 +0000
MFC: mips: fix early kernel panic when setting up interrupt counters
Commit 248f0ca converted intrcnt and intrnames from u_long[]
and char[] to u_long* and char* respectively, but for non-INTRNG mips
these symbols were defined in .S file as a pre-allocated static arrays,
so the problem wasn't cought at compile time. Conversion from an array
to a pointer requires pointer initialization and it wasn't done
for MIPS, so whatever happenned to be in the begginning of intcnt[]
array was used as a pointer value.
Move intrcnt/intrnames to C code and allocate them dynamically
although with a fixed size at the moment.
Reviewed by: emaste
PR: 253051
Differential Revision: https://reviews.freebsd.org/D28424
MFC after: 1 day
(cherry picked from commit e0a0a3efcb09a10ad1de29aca622ea580b2663d2)
mips: fix NLM platforms breakage caused by e0a0a3ef
NetLogic platforms have their own implementation of cpu_init_interrupts.
Apply the same logic to it as to intr_machdep.c.
PR: 253051
(cherry picked from commit d6f9c5a6d2f87865f9714d2b8dfd1a9f3080c71e)
---
sys/mips/mips/exception.S | 36 ------------------------------------
sys/mips/mips/intr_machdep.c | 22 ++++++++++++++++++++++
sys/mips/nlm/intr_machdep.c | 18 ++++++++++++++++++
3 files changed, 40 insertions(+), 36 deletions(-)
diff --git a/sys/mips/mips/exception.S b/sys/mips/mips/exception.S
index 892bebc8f37f..719904ac83b7 100644
--- a/sys/mips/mips/exception.S
+++ b/sys/mips/mips/exception.S
@@ -80,12 +80,6 @@ dtrace_invop_calltrap_addr:
.text
#endif
-/*
- * Reasonable limit
- */
-#define INTRCNT_COUNT 256
-
-
/*
*----------------------------------------------------------------------------
*
@@ -1206,36 +1200,6 @@ FPReturn:
.set pop
END(MipsFPTrap)
-#ifndef INTRNG
-/*
- * Interrupt counters for vmstat.
- */
- .data
- .globl intrcnt
- .globl sintrcnt
- .globl intrnames
- .globl sintrnames
-intrnames:
- .space INTRCNT_COUNT * (MAXCOMLEN + 1) * 2
-sintrnames:
-#ifdef __mips_n64
- .quad INTRCNT_COUNT * (MAXCOMLEN + 1) * 2
-#else
- .int INTRCNT_COUNT * (MAXCOMLEN + 1) * 2
-#endif
-
- .align (_MIPS_SZLONG / 8)
-intrcnt:
- .space INTRCNT_COUNT * (_MIPS_SZLONG / 8) * 2
-sintrcnt:
-#ifdef __mips_n64
- .quad INTRCNT_COUNT * (_MIPS_SZLONG / 8) * 2
-#else
- .int INTRCNT_COUNT * (_MIPS_SZLONG / 8) * 2
-#endif
-#endif /* INTRNG */
-
-
/*
* Vector to real handler in KSEG1.
*/
diff --git a/sys/mips/mips/intr_machdep.c b/sys/mips/mips/intr_machdep.c
index 3b278276865c..a36944f657ca 100644
--- a/sys/mips/mips/intr_machdep.c
+++ b/sys/mips/mips/intr_machdep.c
@@ -50,6 +50,19 @@ __FBSDID("$FreeBSD$");
#include <machine/md_var.h>
#include <machine/trap.h>
+#ifndef INTRNG
+#define INTRCNT_COUNT 256
+#define INTRNAME_LEN (2*MAXCOMLEN + 1)
+
+MALLOC_DECLARE(M_MIPSINTR);
+MALLOC_DEFINE(M_MIPSINTR, "mipsintr", "MIPS interrupt handling");
+
+u_long *intrcnt;
+char *intrnames;
+size_t sintrcnt;
+size_t sintrnames;
+#endif
+
static struct intr_event *hardintr_events[NHARD_IRQS];
static struct intr_event *softintr_events[NSOFT_IRQS];
static mips_intrcnt_t mips_intr_counters[NSOFT_IRQS + NHARD_IRQS];
@@ -121,6 +134,15 @@ cpu_init_interrupts()
int i;
char name[MAXCOMLEN + 1];
+#ifndef INTRNG
+ intrcnt = mallocarray(INTRCNT_COUNT, sizeof(u_long), M_MIPSINTR,
+ M_WAITOK | M_ZERO);
+ intrnames = mallocarray(INTRCNT_COUNT, INTRNAME_LEN, M_MIPSINTR,
+ M_WAITOK | M_ZERO);
+ sintrcnt = INTRCNT_COUNT * sizeof(u_long);
+ sintrnames = INTRCNT_COUNT * INTRNAME_LEN;
+#endif
+
/*
* Initialize all available vectors so spare IRQ
* would show up in systat output
diff --git a/sys/mips/nlm/intr_machdep.c b/sys/mips/nlm/intr_machdep.c
index b66118c06ee8..33bfad1fe882 100644
--- a/sys/mips/nlm/intr_machdep.c
+++ b/sys/mips/nlm/intr_machdep.c
@@ -59,6 +59,17 @@ __FBSDID("$FreeBSD$");
#include <mips/nlm/hal/pic.h>
#include <mips/nlm/xlp.h>
+#define INTRCNT_COUNT 256
+#define INTRNAME_LEN (2*MAXCOMLEN + 1)
+
+MALLOC_DECLARE(M_MIPSINTR);
+MALLOC_DEFINE(M_MIPSINTR, "mipsintr", "MIPS interrupt handling");
+
+u_long *intrcnt;
+char *intrnames;
+size_t sintrcnt;
+size_t sintrnames;
+
struct xlp_intrsrc {
void (*bus_ack)(int, void *); /* Additional ack */
void *bus_ack_arg; /* arg for additional ack */
@@ -295,6 +306,13 @@ cpu_init_interrupts()
int i;
char name[MAXCOMLEN + 1];
+ intrcnt = mallocarray(INTRCNT_COUNT, sizeof(u_long), M_MIPSINTR,
+ M_WAITOK | M_ZERO);
+ intrnames = mallocarray(INTRCNT_COUNT, INTRNAME_LEN, M_MIPSINTR,
+ M_WAITOK | M_ZERO);
+ sintrcnt = INTRCNT_COUNT * sizeof(u_long);
+ sintrnames = INTRCNT_COUNT * INTRNAME_LEN;
+
/*
* Initialize all available vectors so spare IRQ
* would show up in systat output
More information about the dev-commits-src-all
mailing list