sparc32: Fix build with trapbase
authorSam Ravnborg <sam@ravnborg.org>
Sat, 24 Feb 2024 17:42:23 +0000 (18:42 +0100)
committerAndreas Larsson <andreas@gaisler.com>
Fri, 8 Mar 2024 20:20:23 +0000 (21:20 +0100)
Fix the following build errors:
irq_32.c:258:7: error: array subscript [16, 79] is outside array bounds of 'struct tt_entry[1]
irq_32.c:271:14: error: assignment to 'struct tt_entry *' from incompatible pointer type 'struct tt_entry (*)[]

trapbase is a pointer to an array of tt_entry, but the code declared it
as a pointer so the compiler see a single entry and not an array.
Fix this by modifyinf the declaration to be an array, and modify all
users to take the address of the first member.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: "David S. Miller" <davem@davemloft.net>
Reviewed-by: Andreas Larsson <andreas@gaisler.com>
Tested-by: Andreas Larsson <andreas@gaisler.com>
Signed-off-by: Andreas Larsson <andreas@gaisler.com>
Link: https://lore.kernel.org/r/20240224-sam-fix-sparc32-all-builds-v2-2-1f186603c5c4@ravnborg.org
arch/sparc/kernel/irq_32.c
arch/sparc/kernel/kernel.h
arch/sparc/kernel/kgdb_32.c
arch/sparc/kernel/leon_smp.c
arch/sparc/kernel/setup_32.c

index e8452be5123be3c9c2c10d516161dcf5fb623c4e..8605dd710f3c79dac9499acdb6884590a252190d 100644 (file)
@@ -268,11 +268,11 @@ int sparc_floppy_request_irq(unsigned int irq, irq_handler_t irq_handler)
        if (sparc_cpu_model != sparc_leon) {
                struct tt_entry *trap_table;
 
-               trap_table = &trapbase_cpu1;
+               trap_table = &trapbase_cpu1[0];
                INSTANTIATE(trap_table)
-               trap_table = &trapbase_cpu2;
+               trap_table = &trapbase_cpu2[0];
                INSTANTIATE(trap_table)
-               trap_table = &trapbase_cpu3;
+               trap_table = &trapbase_cpu3[0];
                INSTANTIATE(trap_table)
        }
 #endif
index 15da3c0597a564af026ccc93db42f8a80339c74d..a8fb7c0bf053a0af9affd33ce4ee24b2a17d4acc 100644 (file)
@@ -138,10 +138,10 @@ extern unsigned int t_nmi[];
 extern unsigned int linux_trap_ipi15_sun4d[];
 extern unsigned int linux_trap_ipi15_sun4m[];
 
-extern struct tt_entry trapbase;
-extern struct tt_entry trapbase_cpu1;
-extern struct tt_entry trapbase_cpu2;
-extern struct tt_entry trapbase_cpu3;
+extern struct tt_entry trapbase[];
+extern struct tt_entry trapbase_cpu1[];
+extern struct tt_entry trapbase_cpu2[];
+extern struct tt_entry trapbase_cpu3[];
 
 extern char cputypval[];
 
index 58ad3f7de1fb531061e93bdb7ab346181b2fbffb..3b2c673ec627da72cd7ae64ab1f72d44c636c3b9 100644 (file)
@@ -37,7 +37,7 @@ void pt_regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
        gdb_regs[GDB_Y] = regs->y;
        gdb_regs[GDB_PSR] = regs->psr;
        gdb_regs[GDB_WIM] = 0;
-       gdb_regs[GDB_TBR] = (unsigned long) &trapbase;
+       gdb_regs[GDB_TBR] = (unsigned long) &trapbase[0];
        gdb_regs[GDB_PC] = regs->pc;
        gdb_regs[GDB_NPC] = regs->npc;
        gdb_regs[GDB_FSR] = 0;
@@ -72,7 +72,7 @@ void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
 
        gdb_regs[GDB_PSR] = t->kpsr;
        gdb_regs[GDB_WIM] = t->kwim;
-       gdb_regs[GDB_TBR] = (unsigned long) &trapbase;
+       gdb_regs[GDB_TBR] = (unsigned long) &trapbase[0];
        gdb_regs[GDB_PC] = t->kpc;
        gdb_regs[GDB_NPC] = t->kpc + 4;
        gdb_regs[GDB_FSR] = 0;
index 991e9ad3d3e8f953894ca1015306b7d8e7e6688e..1ee393abc463e7970a2ce9d447e40080cade7dac 100644 (file)
@@ -245,13 +245,13 @@ void __init leon_smp_done(void)
 
        /* Free unneeded trap tables */
        if (!cpu_present(1)) {
-               free_reserved_page(virt_to_page(&trapbase_cpu1));
+               free_reserved_page(virt_to_page(&trapbase_cpu1[0]));
        }
        if (!cpu_present(2)) {
-               free_reserved_page(virt_to_page(&trapbase_cpu2));
+               free_reserved_page(virt_to_page(&trapbase_cpu2[0]));
        }
        if (!cpu_present(3)) {
-               free_reserved_page(virt_to_page(&trapbase_cpu3));
+               free_reserved_page(virt_to_page(&trapbase_cpu3[0]));
        }
        /* Ok, they are spinning and ready to go. */
        smp_processors_ready = 1;
index e3b72a7b46d37975ec65b6c200d3a68b7ca19def..704375c061e730d436baa57bcac3980b089b7129 100644 (file)
@@ -67,7 +67,7 @@ static void prom_sync_me(void)
        __asm__ __volatile__("wr %0, 0x0, %%tbr\n\t"
                             "nop\n\t"
                             "nop\n\t"
-                            "nop\n\t" : : "r" (&trapbase));
+                            "nop\n\t" : : "r" (&trapbase[0]));
 
        prom_printf("PROM SYNC COMMAND...\n");
        show_mem();
@@ -285,7 +285,7 @@ void __init setup_arch(char **cmdline_p)
        int i;
        unsigned long highest_paddr;
 
-       sparc_ttable = &trapbase;
+       sparc_ttable = &trapbase[0];
 
        /* Initialize PROM console and command line. */
        *cmdline_p = prom_getbootargs();