Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Fix exception handler memcpy()

The exception handler subroutines are declared as a single char, but
when copied to the required addresses the copy length is 0x80.

When range checks are enabled for memcpy() this results in a build
failure, with error messages such as:

In file included from arch/mips/mti-malta/malta-init.c:15:
In function 'memcpy',
inlined from 'mips_nmi_setup' at arch/mips/mti-malta/malta-init.c:98:2:
include/linux/string.h:376:4: error: call to '__read_overflow2' declared with attribute error: detected read beyond size of object passed as 2nd parameter
376 | __read_overflow2();
| ^~~~~~~~~~~~~~~~~~

Change the declarations to use type char[].

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: YunQiang Su <syq@debian.org>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Ben Hutchings and committed by
Thomas Bogendoerfer
f39293fd 21e1a03e

+12 -12
+2 -2
arch/mips/loongson2ef/common/init.c
··· 19 19 static void __init mips_nmi_setup(void) 20 20 { 21 21 void *base; 22 - extern char except_vec_nmi; 22 + extern char except_vec_nmi[]; 23 23 24 24 base = (void *)(CAC_BASE + 0x380); 25 - memcpy(base, &except_vec_nmi, 0x80); 25 + memcpy(base, except_vec_nmi, 0x80); 26 26 flush_icache_range((unsigned long)base, (unsigned long)base + 0x80); 27 27 } 28 28
+2 -2
arch/mips/loongson64/init.c
··· 22 22 static void __init mips_nmi_setup(void) 23 23 { 24 24 void *base; 25 - extern char except_vec_nmi; 25 + extern char except_vec_nmi[]; 26 26 27 27 base = (void *)(CAC_BASE + 0x380); 28 - memcpy(base, &except_vec_nmi, 0x80); 28 + memcpy(base, except_vec_nmi, 0x80); 29 29 flush_icache_range((unsigned long)base, (unsigned long)base + 0x80); 30 30 } 31 31
+4 -4
arch/mips/mti-malta/malta-init.c
··· 90 90 static void __init mips_nmi_setup(void) 91 91 { 92 92 void *base; 93 - extern char except_vec_nmi; 93 + extern char except_vec_nmi[]; 94 94 95 95 base = cpu_has_veic ? 96 96 (void *)(CAC_BASE + 0xa80) : 97 97 (void *)(CAC_BASE + 0x380); 98 - memcpy(base, &except_vec_nmi, 0x80); 98 + memcpy(base, except_vec_nmi, 0x80); 99 99 flush_icache_range((unsigned long)base, (unsigned long)base + 0x80); 100 100 } 101 101 102 102 static void __init mips_ejtag_setup(void) 103 103 { 104 104 void *base; 105 - extern char except_vec_ejtag_debug; 105 + extern char except_vec_ejtag_debug[]; 106 106 107 107 base = cpu_has_veic ? 108 108 (void *)(CAC_BASE + 0xa00) : 109 109 (void *)(CAC_BASE + 0x300); 110 - memcpy(base, &except_vec_ejtag_debug, 0x80); 110 + memcpy(base, except_vec_ejtag_debug, 0x80); 111 111 flush_icache_range((unsigned long)base, (unsigned long)base + 0x80); 112 112 } 113 113
+4 -4
arch/mips/pistachio/init.c
··· 83 83 static void __init mips_nmi_setup(void) 84 84 { 85 85 void *base; 86 - extern char except_vec_nmi; 86 + extern char except_vec_nmi[]; 87 87 88 88 base = cpu_has_veic ? 89 89 (void *)(CAC_BASE + 0xa80) : 90 90 (void *)(CAC_BASE + 0x380); 91 - memcpy(base, &except_vec_nmi, 0x80); 91 + memcpy(base, except_vec_nmi, 0x80); 92 92 flush_icache_range((unsigned long)base, 93 93 (unsigned long)base + 0x80); 94 94 } ··· 96 96 static void __init mips_ejtag_setup(void) 97 97 { 98 98 void *base; 99 - extern char except_vec_ejtag_debug; 99 + extern char except_vec_ejtag_debug[]; 100 100 101 101 base = cpu_has_veic ? 102 102 (void *)(CAC_BASE + 0xa00) : 103 103 (void *)(CAC_BASE + 0x300); 104 - memcpy(base, &except_vec_ejtag_debug, 0x80); 104 + memcpy(base, except_vec_ejtag_debug, 0x80); 105 105 flush_icache_range((unsigned long)base, 106 106 (unsigned long)base + 0x80); 107 107 }