From c250ced3acd73c2dbe0165d9a98c2b4a1ecd5fec Mon Sep 17 00:00:00 2001 From: hschang Date: Wed, 2 Jul 2014 12:00:52 +0900 Subject: [PATCH] [linux-vuplus] apply patch kernel miscompileation with gcc 4.8 (get from http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=c022630633624a75b3b58f43dd3c6cc896a56cff) --- .../kernel_miscompilation_with_gcc_4_8.patch | 251 ++++++++++++++++++++ .../kernel_miscompilation_with_gcc_4_8.patch | 252 +++++++++++++++++++++ .../common/recipes/linux/linux-vuplus_3.1.1.bb | 7 +- .../common/recipes/linux/linux-vuplus_3.3.8.bb | 15 +- 4 files changed, 515 insertions(+), 10 deletions(-) create mode 100644 meta-bsp/common/recipes/linux/linux-vuplus-3.1.1/kernel_miscompilation_with_gcc_4_8.patch create mode 100644 meta-bsp/common/recipes/linux/linux-vuplus-3.3.8/kernel_miscompilation_with_gcc_4_8.patch diff --git a/meta-bsp/common/recipes/linux/linux-vuplus-3.1.1/kernel_miscompilation_with_gcc_4_8.patch b/meta-bsp/common/recipes/linux/linux-vuplus-3.1.1/kernel_miscompilation_with_gcc_4_8.patch new file mode 100644 index 0000000..013384b --- /dev/null +++ b/meta-bsp/common/recipes/linux/linux-vuplus-3.1.1/kernel_miscompilation_with_gcc_4_8.patch @@ -0,0 +1,251 @@ +commit 8511b7b083db01ad0538bea6a8af79f88fe02a8b +Author: hschang +Date: Wed Jan 8 20:32:42 2014 +0900 + + MIPS: Refactor 'clear_page' and 'copy_page' functions. + + Remove usage of the '__attribute__((alias("...")))' hack that aliased + to integer arrays containing micro-assembled instructions. This hack + breaks when building a microMIPS kernel. It also makes the code much + easier to understand. + + [ralf@linux-mips.org: Added back export of the clear_page and copy_page + symbols so certain modules will work again. Also fixed build with + CONFIG_SIBYTE_DMA_PAGEOPS enabled.] + + Signed-off-by: Steven J. Hill + Cc: linux-mips@linux-mips.org + Patchwork: https://patchwork.linux-mips.org/patch/3866/ + Acked-by: David Daney + Signed-off-by: Ralf Baechle + +diff --git a/arch/mips/kernel/mips_ksyms.c b/arch/mips/kernel/mips_ksyms.c +index 1d04807..17160bf 100644 +--- a/arch/mips/kernel/mips_ksyms.c ++++ b/arch/mips/kernel/mips_ksyms.c +@@ -5,7 +5,7 @@ + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * +- * Copyright (C) 1996, 97, 98, 99, 2000, 01, 03, 04, 05 by Ralf Baechle ++ * Copyright (C) 1996, 97, 98, 99, 2000, 01, 03, 04, 05, 12 by Ralf Baechle + * Copyright (C) 1999, 2000, 01 Silicon Graphics, Inc. + */ + #include +@@ -35,6 +35,13 @@ EXPORT_SYMBOL(memmove); + EXPORT_SYMBOL(kernel_thread); + + /* ++ * Functions that operate on entire pages. Mostly used by memory management. ++ */ ++ ++EXPORT_SYMBOL(clear_page); ++EXPORT_SYMBOL(copy_page); ++ ++/* + * Userspace access stuff. + */ + EXPORT_SYMBOL(__copy_user); +diff --git a/arch/mips/mm/Makefile b/arch/mips/mm/Makefile +index 95e5ccb..2f2dc25 100644 +--- a/arch/mips/mm/Makefile ++++ b/arch/mips/mm/Makefile +@@ -4,7 +4,7 @@ + + obj-y += cache.o dma-default.o extable.o fault.o \ + init.o mmap.o tlbex.o tlbex-fault.o uasm.o \ +- page.o ++ page.o page-funcs.o + + obj-$(CONFIG_32BIT) += ioremap.o pgtable-32.o + obj-$(CONFIG_64BIT) += pgtable-64.o +diff --git a/arch/mips/mm/page-funcs.S b/arch/mips/mm/page-funcs.S +new file mode 100644 +index 0000000..48a6b38 +--- /dev/null ++++ b/arch/mips/mm/page-funcs.S +@@ -0,0 +1,50 @@ ++/* ++ * This file is subject to the terms and conditions of the GNU General Public ++ * License. See the file "COPYING" in the main directory of this archive ++ * for more details. ++ * ++ * Micro-assembler generated clear_page/copy_page functions. ++ * ++ * Copyright (C) 2012 MIPS Technologies, Inc. ++ * Copyright (C) 2012 Ralf Baechle ++ */ ++#include ++#include ++ ++#ifdef CONFIG_SIBYTE_DMA_PAGEOPS ++#define cpu_clear_page_function_name clear_page_cpu ++#define cpu_copy_page_function_name copy_page_cpu ++#else ++#define cpu_clear_page_function_name clear_page ++#define cpu_copy_page_function_name copy_page ++#endif ++ ++/* ++ * Maximum sizes: ++ * ++ * R4000 128 bytes S-cache: 0x058 bytes ++ * R4600 v1.7: 0x05c bytes ++ * R4600 v2.0: 0x060 bytes ++ * With prefetching, 16 word strides 0x120 bytes ++ */ ++EXPORT(__clear_page_start) ++LEAF(cpu_clear_page_function_name) ++1: j 1b /* Dummy, will be replaced. */ ++ .space 288 ++END(cpu_clear_page_function_name) ++EXPORT(__clear_page_end) ++ ++/* ++ * Maximum sizes: ++ * ++ * R4000 128 bytes S-cache: 0x11c bytes ++ * R4600 v1.7: 0x080 bytes ++ * R4600 v2.0: 0x07c bytes ++ * With prefetching, 16 word strides 0x540 bytes ++ */ ++EXPORT(__copy_page_start) ++LEAF(cpu_copy_page_function_name) ++1: j 1b /* Dummy, will be replaced. */ ++ .space 1344 ++END(cpu_copy_page_function_name) ++EXPORT(__copy_page_end) +diff --git a/arch/mips/mm/page.c b/arch/mips/mm/page.c +index 36272f7..a22bd40 100644 +--- a/arch/mips/mm/page.c ++++ b/arch/mips/mm/page.c +@@ -6,6 +6,7 @@ + * Copyright (C) 2003, 04, 05 Ralf Baechle (ralf@linux-mips.org) + * Copyright (C) 2007 Maciej W. Rozycki + * Copyright (C) 2008 Thiemo Seufer ++ * Copyright (C) 2012 MIPS Technologies, Inc. + */ + #include + #include +@@ -72,45 +73,6 @@ static struct uasm_reloc __cpuinitdata relocs[5]; + #define cpu_is_r4600_v1_x() ((read_c0_prid() & 0xfffffff0) == 0x00002010) + #define cpu_is_r4600_v2_x() ((read_c0_prid() & 0xfffffff0) == 0x00002020) + +-/* +- * Maximum sizes: +- * +- * R4000 128 bytes S-cache: 0x058 bytes +- * R4600 v1.7: 0x05c bytes +- * R4600 v2.0: 0x060 bytes +- * With prefetching, 16 word strides 0x120 bytes +- */ +- +-static u32 clear_page_array[0x120 / 4]; +- +-#ifdef CONFIG_SIBYTE_DMA_PAGEOPS +-void clear_page_cpu(void *page) __attribute__((alias("clear_page_array"))); +-#else +-void clear_page(void *page) __attribute__((alias("clear_page_array"))); +-#endif +- +-EXPORT_SYMBOL(clear_page); +- +-/* +- * Maximum sizes: +- * +- * R4000 128 bytes S-cache: 0x11c bytes +- * R4600 v1.7: 0x080 bytes +- * R4600 v2.0: 0x07c bytes +- * With prefetching, 16 word strides 0x540 bytes +- */ +-static u32 copy_page_array[0x540 / 4]; +- +-#ifdef CONFIG_SIBYTE_DMA_PAGEOPS +-void +-copy_page_cpu(void *to, void *from) __attribute__((alias("copy_page_array"))); +-#else +-void copy_page(void *to, void *from) __attribute__((alias("copy_page_array"))); +-#endif +- +-EXPORT_SYMBOL(copy_page); +- +- + static int pref_bias_clear_store __cpuinitdata; + static int pref_bias_copy_load __cpuinitdata; + static int pref_bias_copy_store __cpuinitdata; +@@ -283,10 +245,15 @@ static inline void __cpuinit build_clear_pref(u32 **buf, int off) + } + } + ++extern u32 __clear_page_start; ++extern u32 __clear_page_end; ++extern u32 __copy_page_start; ++extern u32 __copy_page_end; ++ + void __cpuinit build_clear_page(void) + { + int off; +- u32 *buf = (u32 *)&clear_page_array; ++ u32 *buf = &__clear_page_start; + struct uasm_label *l = labels; + struct uasm_reloc *r = relocs; + int i; +@@ -357,17 +324,17 @@ void __cpuinit build_clear_page(void) + uasm_i_jr(&buf, RA); + uasm_i_nop(&buf); + +- BUG_ON(buf > clear_page_array + ARRAY_SIZE(clear_page_array)); ++ BUG_ON(buf > &__clear_page_end); + + uasm_resolve_relocs(relocs, labels); + + pr_debug("Synthesized clear page handler (%u instructions).\n", +- (u32)(buf - clear_page_array)); ++ (u32)(buf - &__clear_page_start)); + + pr_debug("\t.set push\n"); + pr_debug("\t.set noreorder\n"); +- for (i = 0; i < (buf - clear_page_array); i++) +- pr_debug("\t.word 0x%08x\n", clear_page_array[i]); ++ for (i = 0; i < (buf - &__clear_page_start); i++) ++ pr_debug("\t.word 0x%08x\n", (&__clear_page_start)[i]); + pr_debug("\t.set pop\n"); + } + +@@ -428,7 +395,7 @@ static inline void build_copy_store_pref(u32 **buf, int off) + void __cpuinit build_copy_page(void) + { + int off; +- u32 *buf = (u32 *)©_page_array; ++ u32 *buf = &__copy_page_start; + struct uasm_label *l = labels; + struct uasm_reloc *r = relocs; + int i; +@@ -596,21 +563,23 @@ void __cpuinit build_copy_page(void) + uasm_i_jr(&buf, RA); + uasm_i_nop(&buf); + +- BUG_ON(buf > copy_page_array + ARRAY_SIZE(copy_page_array)); ++ BUG_ON(buf > &__copy_page_end); + + uasm_resolve_relocs(relocs, labels); + + pr_debug("Synthesized copy page handler (%u instructions).\n", +- (u32)(buf - copy_page_array)); ++ (u32)(buf - &__copy_page_start)); + + pr_debug("\t.set push\n"); + pr_debug("\t.set noreorder\n"); +- for (i = 0; i < (buf - copy_page_array); i++) +- pr_debug("\t.word 0x%08x\n", copy_page_array[i]); ++ for (i = 0; i < (buf - &__copy_page_start); i++) ++ pr_debug("\t.word 0x%08x\n", (&__copy_page_start)[i]); + pr_debug("\t.set pop\n"); + } + + #ifdef CONFIG_SIBYTE_DMA_PAGEOPS ++extern void clear_page_cpu(void *page); ++extern void copy_page_cpu(void *to, void *from); + + /* + * Pad descriptors to cacheline, since each is exclusively owned by a diff --git a/meta-bsp/common/recipes/linux/linux-vuplus-3.3.8/kernel_miscompilation_with_gcc_4_8.patch b/meta-bsp/common/recipes/linux/linux-vuplus-3.3.8/kernel_miscompilation_with_gcc_4_8.patch new file mode 100644 index 0000000..ba69abe --- /dev/null +++ b/meta-bsp/common/recipes/linux/linux-vuplus-3.3.8/kernel_miscompilation_with_gcc_4_8.patch @@ -0,0 +1,252 @@ +commit c022630633624a75b3b58f43dd3c6cc896a56cff +Author: Steven J. Hill +Date: Fri Jul 6 21:56:01 2012 +0200 + + MIPS: Refactor 'clear_page' and 'copy_page' functions. + + Remove usage of the '__attribute__((alias("...")))' hack that aliased + to integer arrays containing micro-assembled instructions. This hack + breaks when building a microMIPS kernel. It also makes the code much + easier to understand. + + [ralf@linux-mips.org: Added back export of the clear_page and copy_page + symbols so certain modules will work again. Also fixed build with + CONFIG_SIBYTE_DMA_PAGEOPS enabled.] + + Signed-off-by: Steven J. Hill + Cc: linux-mips@linux-mips.org + Patchwork: https://patchwork.linux-mips.org/patch/3866/ + Acked-by: David Daney + Signed-off-by: Ralf Baechle + +diff --git a/arch/mips/kernel/mips_ksyms.c b/arch/mips/kernel/mips_ksyms.c +index 57ba13e..3fc1691 100644 +--- a/arch/mips/kernel/mips_ksyms.c ++++ b/arch/mips/kernel/mips_ksyms.c +@@ -5,7 +5,7 @@ + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * +- * Copyright (C) 1996, 97, 98, 99, 2000, 01, 03, 04, 05 by Ralf Baechle ++ * Copyright (C) 1996, 97, 98, 99, 2000, 01, 03, 04, 05, 12 by Ralf Baechle + * Copyright (C) 1999, 2000, 01 Silicon Graphics, Inc. + */ + #include +@@ -35,6 +35,12 @@ EXPORT_SYMBOL(memmove); + EXPORT_SYMBOL(kernel_thread); + + /* ++ * Functions that operate on entire pages. Mostly used by memory management. ++ */ ++EXPORT_SYMBOL(clear_page); ++EXPORT_SYMBOL(copy_page); ++ ++/* + * Userspace access stuff. + */ + EXPORT_SYMBOL(__copy_user); +diff --git a/arch/mips/mm/Makefile b/arch/mips/mm/Makefile +index 4aa2028..fd6203f 100644 +--- a/arch/mips/mm/Makefile ++++ b/arch/mips/mm/Makefile +@@ -3,8 +3,8 @@ + # + + obj-y += cache.o dma-default.o extable.o fault.o \ +- gup.o init.o mmap.o page.o tlbex.o \ +- tlbex-fault.o uasm.o ++ gup.o init.o mmap.o page.o page-funcs.o \ ++ tlbex.o tlbex-fault.o uasm.o + + obj-$(CONFIG_32BIT) += ioremap.o pgtable-32.o + obj-$(CONFIG_64BIT) += pgtable-64.o +diff --git a/arch/mips/mm/page-funcs.S b/arch/mips/mm/page-funcs.S +new file mode 100644 +index 0000000..48a6b38 +--- /dev/null ++++ b/arch/mips/mm/page-funcs.S +@@ -0,0 +1,50 @@ ++/* ++ * This file is subject to the terms and conditions of the GNU General Public ++ * License. See the file "COPYING" in the main directory of this archive ++ * for more details. ++ * ++ * Micro-assembler generated clear_page/copy_page functions. ++ * ++ * Copyright (C) 2012 MIPS Technologies, Inc. ++ * Copyright (C) 2012 Ralf Baechle ++ */ ++#include ++#include ++ ++#ifdef CONFIG_SIBYTE_DMA_PAGEOPS ++#define cpu_clear_page_function_name clear_page_cpu ++#define cpu_copy_page_function_name copy_page_cpu ++#else ++#define cpu_clear_page_function_name clear_page ++#define cpu_copy_page_function_name copy_page ++#endif ++ ++/* ++ * Maximum sizes: ++ * ++ * R4000 128 bytes S-cache: 0x058 bytes ++ * R4600 v1.7: 0x05c bytes ++ * R4600 v2.0: 0x060 bytes ++ * With prefetching, 16 word strides 0x120 bytes ++ */ ++EXPORT(__clear_page_start) ++LEAF(cpu_clear_page_function_name) ++1: j 1b /* Dummy, will be replaced. */ ++ .space 288 ++END(cpu_clear_page_function_name) ++EXPORT(__clear_page_end) ++ ++/* ++ * Maximum sizes: ++ * ++ * R4000 128 bytes S-cache: 0x11c bytes ++ * R4600 v1.7: 0x080 bytes ++ * R4600 v2.0: 0x07c bytes ++ * With prefetching, 16 word strides 0x540 bytes ++ */ ++EXPORT(__copy_page_start) ++LEAF(cpu_copy_page_function_name) ++1: j 1b /* Dummy, will be replaced. */ ++ .space 1344 ++END(cpu_copy_page_function_name) ++EXPORT(__copy_page_end) +diff --git a/arch/mips/mm/page.c b/arch/mips/mm/page.c +index cc0b626..98f530e 100644 +--- a/arch/mips/mm/page.c ++++ b/arch/mips/mm/page.c +@@ -6,6 +6,7 @@ + * Copyright (C) 2003, 04, 05 Ralf Baechle (ralf@linux-mips.org) + * Copyright (C) 2007 Maciej W. Rozycki + * Copyright (C) 2008 Thiemo Seufer ++ * Copyright (C) 2012 MIPS Technologies, Inc. + */ + #include + #include +@@ -71,45 +72,6 @@ static struct uasm_reloc __cpuinitdata relocs[5]; + #define cpu_is_r4600_v1_x() ((read_c0_prid() & 0xfffffff0) == 0x00002010) + #define cpu_is_r4600_v2_x() ((read_c0_prid() & 0xfffffff0) == 0x00002020) + +-/* +- * Maximum sizes: +- * +- * R4000 128 bytes S-cache: 0x058 bytes +- * R4600 v1.7: 0x05c bytes +- * R4600 v2.0: 0x060 bytes +- * With prefetching, 16 word strides 0x120 bytes +- */ +- +-static u32 clear_page_array[0x120 / 4]; +- +-#ifdef CONFIG_SIBYTE_DMA_PAGEOPS +-void clear_page_cpu(void *page) __attribute__((alias("clear_page_array"))); +-#else +-void clear_page(void *page) __attribute__((alias("clear_page_array"))); +-#endif +- +-EXPORT_SYMBOL(clear_page); +- +-/* +- * Maximum sizes: +- * +- * R4000 128 bytes S-cache: 0x11c bytes +- * R4600 v1.7: 0x080 bytes +- * R4600 v2.0: 0x07c bytes +- * With prefetching, 16 word strides 0x540 bytes +- */ +-static u32 copy_page_array[0x540 / 4]; +- +-#ifdef CONFIG_SIBYTE_DMA_PAGEOPS +-void +-copy_page_cpu(void *to, void *from) __attribute__((alias("copy_page_array"))); +-#else +-void copy_page(void *to, void *from) __attribute__((alias("copy_page_array"))); +-#endif +- +-EXPORT_SYMBOL(copy_page); +- +- + static int pref_bias_clear_store __cpuinitdata; + static int pref_bias_copy_load __cpuinitdata; + static int pref_bias_copy_store __cpuinitdata; +@@ -282,10 +244,15 @@ static inline void __cpuinit build_clear_pref(u32 **buf, int off) + } + } + ++extern u32 __clear_page_start; ++extern u32 __clear_page_end; ++extern u32 __copy_page_start; ++extern u32 __copy_page_end; ++ + void __cpuinit build_clear_page(void) + { + int off; +- u32 *buf = (u32 *)&clear_page_array; ++ u32 *buf = &__clear_page_start; + struct uasm_label *l = labels; + struct uasm_reloc *r = relocs; + int i; +@@ -356,17 +323,17 @@ void __cpuinit build_clear_page(void) + uasm_i_jr(&buf, RA); + uasm_i_nop(&buf); + +- BUG_ON(buf > clear_page_array + ARRAY_SIZE(clear_page_array)); ++ BUG_ON(buf > &__clear_page_end); + + uasm_resolve_relocs(relocs, labels); + + pr_debug("Synthesized clear page handler (%u instructions).\n", +- (u32)(buf - clear_page_array)); ++ (u32)(buf - &__clear_page_start)); + + pr_debug("\t.set push\n"); + pr_debug("\t.set noreorder\n"); +- for (i = 0; i < (buf - clear_page_array); i++) +- pr_debug("\t.word 0x%08x\n", clear_page_array[i]); ++ for (i = 0; i < (buf - &__clear_page_start); i++) ++ pr_debug("\t.word 0x%08x\n", (&__clear_page_start)[i]); + pr_debug("\t.set pop\n"); + } + +@@ -427,7 +394,7 @@ static inline void build_copy_store_pref(u32 **buf, int off) + void __cpuinit build_copy_page(void) + { + int off; +- u32 *buf = (u32 *)©_page_array; ++ u32 *buf = &__copy_page_start; + struct uasm_label *l = labels; + struct uasm_reloc *r = relocs; + int i; +@@ -595,21 +562,23 @@ void __cpuinit build_copy_page(void) + uasm_i_jr(&buf, RA); + uasm_i_nop(&buf); + +- BUG_ON(buf > copy_page_array + ARRAY_SIZE(copy_page_array)); ++ BUG_ON(buf > &__copy_page_end); + + uasm_resolve_relocs(relocs, labels); + + pr_debug("Synthesized copy page handler (%u instructions).\n", +- (u32)(buf - copy_page_array)); ++ (u32)(buf - &__copy_page_start)); + + pr_debug("\t.set push\n"); + pr_debug("\t.set noreorder\n"); +- for (i = 0; i < (buf - copy_page_array); i++) +- pr_debug("\t.word 0x%08x\n", copy_page_array[i]); ++ for (i = 0; i < (buf - &__copy_page_start); i++) ++ pr_debug("\t.word 0x%08x\n", (&__copy_page_start)[i]); + pr_debug("\t.set pop\n"); + } + + #ifdef CONFIG_SIBYTE_DMA_PAGEOPS ++extern void clear_page_cpu(void *page); ++extern void copy_page_cpu(void *to, void *from); + + /* + * Pad descriptors to cacheline, since each is exclusively owned by a diff --git a/meta-bsp/common/recipes/linux/linux-vuplus_3.1.1.bb b/meta-bsp/common/recipes/linux/linux-vuplus_3.1.1.bb index cd98980..853fc55 100644 --- a/meta-bsp/common/recipes/linux/linux-vuplus_3.1.1.bb +++ b/meta-bsp/common/recipes/linux/linux-vuplus_3.1.1.bb @@ -10,10 +10,11 @@ SRCREV = "r2" MODULE = "linux-3.1.1" SRC_URI += "http://archive.vuplus.com/download/kernel/linux-${KV}_${SRCREV}.tar.bz2 \ - file://fix_cpu_proc.patch;patch=1;pnum=1 \ + file://fix_cpu_proc.patch \ + file://igmp.patch \ + file://rt5372_kernel_3.1.1.patch \ + file://kernel_miscompilation_with_gcc_4_8.patch \ file://${MACHINE}_defconfig \ - file://igmp.patch;patch=1;pnum=1 \ - file://rt5372_kernel_3.1.1.patch \ " SRC_URI[md5sum] = "4dc3ac322453abbfaade7020cddea205" diff --git a/meta-bsp/common/recipes/linux/linux-vuplus_3.3.8.bb b/meta-bsp/common/recipes/linux/linux-vuplus_3.3.8.bb index 1c60f38..14f5462 100644 --- a/meta-bsp/common/recipes/linux/linux-vuplus_3.3.8.bb +++ b/meta-bsp/common/recipes/linux/linux-vuplus_3.3.8.bb @@ -11,15 +11,16 @@ SRCREV = "" MODULE = "linux-3.3.8" SRC_URI += "http://archive.vuplus.com/download/kernel/stblinux-3.3.6-2.0.tar.bz2 \ - file://brcm_3.3.patch;patch=1;pnum=1 \ - file://fix_cpu_proc.patch;patch=1;pnum=1 \ - file://brcm_mtd_mac.patch;patch=1;pnum=1 \ - file://dvb_core_5.5.patch;patch=1;pnum=1 \ - file://dvb_backport.patch;patch=1;pnum=1 \ - file://bmips-no-array-bounds.patch;patch=1;pnum=1 \ + file://brcm_3.3.patch \ + file://fix_cpu_proc.patch \ + file://brcm_mtd_mac.patch \ + file://dvb_core_5.5.patch \ + file://dvb_backport.patch \ + file://bmips-no-array-bounds.patch \ file://${MACHINE}_defconfig \ file://rt5372_kernel_3.3.8.patch \ - " + file://kernel_miscompilation_with_gcc_4_8.patch \ +" S = "${WORKDIR}/linux" -- 2.7.4