Re: [BUG] 4.9.0 build error on Alpha
Bob, > Credit to all who participated in working this issue. Matt -- attached > is a patch set to be applied against the kernel.org 4.9.0 source tree. > If it passes inspection, please approve and forward upstream. > > Apologies for not including in-line, but I don't trust my mailer to > preserve formatting unless I send as an attachment. Thanks for your contribution; you need to add a `Signed-off-by' tag though for your change to go anywhere. Also I think the part will need some further work; at the very least the comment needs to be updated to state why the conditional has now been hardwired. Ultimately I think all the hackery can go and `__copy_tofrom_user_nocheck' and `__clear_user' be replaced with direct calls to `__copy_user' and `__do_clear_user' respectively (and `__do_clear_user' renamed to `__clear_user' at the same time) as the +/- 4MiB branch range is too low these days to guarantee a kernel binary to fit within. Alternatively a configuration option might be added for the branch optimisation to stay instead if selected, perhaps also adding the `-msmall-text' compiler option to let small configurations take advantage of it globally rather than just in . This might not be liked by people running build bots though as it would inevitably cause some configurations to fail linking. Maciej
Re: [BUG] 4.9.0 build error on Alpha
Credit to all who participated in working this issue. Matt -- attached is a patch set to be applied against the kernel.org 4.9.0 source tree. If it passes inspection, please approve and forward upstream. Apologies for not including in-line, but I don't trust my mailer to preserve formatting unless I send as an attachment. Thanks. --Bob This series of patches addresses vmlinux ld relocation errors on the Alpha architecture that appeared at some point after the 4.8.0 release of the kernel.org source tree. Fixes are as suggested by Helge Dellerand Michael Cree , with significant input from Maciej W. Rozycki and Matt Turner . The patch set is known to apply cleanly to 4.9.0. Approach is to define a new "alphalib" section for all the Alpha-specific library functions to be linked into the final vmlinux. The "uaccess.h" patch addresses "__copy_user" relocation errors reported elsewhere. Tested-by: Bob Tracy --- a/arch/alpha/include/asm/uaccess.h 2016-11-19 08:26:53.0 -0600 +++ b/arch/alpha/include/asm/uaccess.h 2016-12-31 15:01:41.621694846 -0600 @@ -344,7 +344,7 @@ /* This little bit of silliness is to get the GP loaded for a function that ordinarily wouldn't. Otherwise we could have it done by the macro directly, which can be optimized the linker. */ -#ifdef MODULE +#if 1 #define __module_address(sym) "r"(sym), #define __module_call(ra, arg, sym)"jsr $" #ra ",(%" #arg ")," #sym #else --- a/arch/alpha/kernel/vmlinux.lds.S 2016-11-19 08:26:53.0 -0600 +++ b/arch/alpha/kernel/vmlinux.lds.S 2016-12-31 09:06:15.548643355 -0600 @@ -20,6 +20,7 @@ _text = .; /* Text and read-only data */ .text : { HEAD_TEXT + *(.alphalib) TEXT_TEXT SCHED_TEXT CPUIDLE_TEXT --- a/arch/alpha/lib/callback_srm.S 2016-11-19 08:26:53.0 -0600 +++ b/arch/alpha/lib/callback_srm.S 2016-12-31 21:24:37.930036466 -0600 @@ -5,7 +5,7 @@ #include #include -.text +.section .alphalib,"ax" #define HWRPB_CRB_OFFSET 0xc0 #if defined(CONFIG_ALPHA_SRM) || defined(CONFIG_ALPHA_GENERIC) --- a/arch/alpha/lib/clear_page.S 2016-11-19 08:26:53.0 -0600 +++ b/arch/alpha/lib/clear_page.S 2016-12-31 21:25:11.237910422 -0600 @@ -4,7 +4,7 @@ * Zero an entire page. */ #include - .text + .section .alphalib,"ax" .align 4 .global clear_page .ent clear_page --- a/arch/alpha/lib/clear_user.S 2016-11-19 08:26:53.0 -0600 +++ b/arch/alpha/lib/clear_user.S 2016-12-31 00:54:48.458611939 -0600 @@ -24,6 +24,8 @@ * Clobbers: * $1,$2,$3,$4,$5,$6 */ +.section .alphalib,"ax" + #include /* Allow an exception for an insn; exit if we get one. */ --- a/arch/alpha/lib/copy_page.S2016-11-19 08:26:53.0 -0600 +++ b/arch/alpha/lib/copy_page.S2016-12-31 21:25:35.673189381 -0600 @@ -4,7 +4,7 @@ * Copy an entire page. */ #include - .text + .section .alphalib,"ax" .align 4 .global copy_page .ent copy_page --- a/arch/alpha/lib/copy_user.S2016-11-19 08:26:53.0 -0600 +++ b/arch/alpha/lib/copy_user.S2016-12-31 00:57:16.032150766 -0600 @@ -26,6 +26,7 @@ * $1,$2,$3,$4,$5,$6,$7 */ +.section .alphalib,"ax" #include /* Allow an exception for an insn; exit if we get one. */ --- a/arch/alpha/lib/csum_ipv6_magic.S 2016-11-19 08:26:53.0 -0600 +++ b/arch/alpha/lib/csum_ipv6_magic.S 2016-12-31 00:57:26.872418989 -0600 @@ -12,6 +12,7 @@ * added by Ivan Kokshaysky */ +.section .alphalib,"ax" #include .globl csum_ipv6_magic .align 4 --- a/arch/alpha/lib/dbg_current.S 2007-12-03 00:52:36.0 -0600 +++ b/arch/alpha/lib/dbg_current.S 2016-12-31 21:26:09.439047824 -0600 @@ -7,7 +7,7 @@ #include - .text + .section .alphalib,"ax" .set noat .globl _mcount --- a/arch/alpha/lib/dbg_stackcheck.S 2007-12-03 00:52:36.0 -0600 +++ b/arch/alpha/lib/dbg_stackcheck.S 2016-12-31 21:26:21.816347141 -0600 @@ -7,7 +7,7 @@ #include - .text + .section .alphalib,"ax" .set noat .align 3 --- a/arch/alpha/lib/dbg_stackkill.S2007-12-03 00:52:36.0 -0600 +++ b/arch/alpha/lib/dbg_stackkill.S2016-12-31 21:26:31.401796458 -0600 @@ -8,7 +8,7 @@ #include - .text + .section .alphalib,"ax" .set noat .align 5 --- a/arch/alpha/lib/divide.S 2016-11-19 08:26:53.0 -0600 +++ b/arch/alpha/lib/divide.S 2016-12-31 00:58:07.403557879 -0600 @@ -45,6 +45,7 @@ * $28 - compare status */ +.section .alphalib,"ax" #include #define halt .long 0 --- a/arch/alpha/lib/ev67-strcat.S 2016-11-19 08:26:53.0 -0600 +++ b/arch/alpha/lib/ev67-strcat.S
Re: [BUG] 4.9.0 build error on Alpha
On Sat, Dec 31, 2016 at 09:32:58PM -0600, Bob Tracy wrote: > On Sun, Jan 01, 2017 at 01:23:06AM +, Maciej W. Rozycki wrote: > > You need to *replace* any `.text' pseudo-ops throughout with the said > > `.section' pseudo-op for this to have any effect. > > That makes sense, especially given the fact the *original* error > messages didn't change. Sorry for being "thick". Corrections made. > Build proceeding... That did the trick, along with Michael's "uaccess.h" patch. Success. --Bob
Re: [BUG] 4.9.0 build error on Alpha
On Sat, Dec 31, 2016 at 09:20:37AM -0600, Bob Tracy wrote: > On Sat, Dec 31, 2016 at 10:11:45AM +, Maciej W. Rozycki wrote: > > (...) > > You need to keep the `*(.alphalib)' line only, i.e. drop the first and > > the last line added by the patch, as the output section statement and its > > curly braces surrounding input section specifiers are already produced > > elsewhere. > > (...) > > Thought to try this, but, bad news. > > With '.section .alphalib,"ax"' added to the top of "arch/alpha/lib/*.S" > (below opening comment block, if present, but prior to any include > directives), > and the modified patch to "arch/alpha/kernel/vmlinux.lds.S", I now get > multiple relocation errors as follows: > > LD init/built-in.o > arch/alpha/lib/lib.a(strcat.o): In function `strcat': > (.text+0x60): relocation truncated to fit: BRADDR against symbol `__stxcpy' > defined in .text section in arch/alpha/lib/lib.a(stxcpy.o) > arch/alpha/lib/lib.a(strncat.o): In function `strncat': > (.text+0x60): relocation truncated to fit: BRADDR against symbol `__stxncpy' > defined in .text section in arch/alpha/lib/lib.a(stxncpy.o) > drivers/built-in.o: In function `radeon_cs_parser_init.part.4': > drivers/gpu/drm/radeon/radeon_cs.o:(.text+0x119bd0): relocation truncated to > fit: BRSGP against symbol `__copy_user' defined in .alphalib section in > arch/alpha/lib/lib.a(copy_user.o) Try changing the #ifdef MODULE above __copy_tofrom_user_nocheck to #if 1 in uaccess.h. That should fix the copy_user relocation errors. Cheers Michael.
Re: [BUG] 4.9.0 build error on Alpha
On Sun, Jan 01, 2017 at 01:23:06AM +, Maciej W. Rozycki wrote: > You need to *replace* any `.text' pseudo-ops throughout with the said > `.section' pseudo-op for this to have any effect. That makes sense, especially given the fact the *original* error messages didn't change. Sorry for being "thick". Corrections made. Build proceeding... --Bob
Re: [BUG] 4.9.0 build error on Alpha
On Sat, 31 Dec 2016, Bob Tracy wrote: > With '.section .alphalib,"ax"' added to the top of "arch/alpha/lib/*.S" > (below opening comment block, if present, but prior to any include > directives), > and the modified patch to "arch/alpha/kernel/vmlinux.lds.S", I now get > multiple relocation errors as follows: You need to *replace* any `.text' pseudo-ops throughout with the said `.section' pseudo-op for this to have any effect. HTH, Maciej
Re: [BUG] 4.9.0 build error on Alpha
On Sun, Jan 01, 2017 at 08:38:51AM +1300, Michael Cree wrote: > On Sat, Dec 31, 2016 at 09:20:37AM -0600, Bob Tracy wrote: > > With '.section .alphalib,"ax"' added to the top of "arch/alpha/lib/*.S" > > (below opening comment block, if present, but prior to any include > > directives), > > and the modified patch to "arch/alpha/kernel/vmlinux.lds.S", I now get > > multiple relocation errors as follows: > > > > LD init/built-in.o > > arch/alpha/lib/lib.a(strcat.o): In function `strcat': > > (.text+0x60): relocation truncated to fit: BRADDR against symbol `__stxcpy' > > defined in .text section in arch/alpha/lib/lib.a(stxcpy.o) > > arch/alpha/lib/lib.a(strncat.o): In function `strncat': > > (.text+0x60): relocation truncated to fit: BRADDR against symbol > > `__stxncpy' defined in .text section in arch/alpha/lib/lib.a(stxncpy.o) > > drivers/built-in.o: In function `radeon_cs_parser_init.part.4': > > drivers/gpu/drm/radeon/radeon_cs.o:(.text+0x119bd0): relocation truncated > > to fit: BRSGP against symbol `__copy_user' defined in .alphalib section in > > arch/alpha/lib/lib.a(copy_user.o) > > Try changing the #ifdef MODULE above __copy_tofrom_user_nocheck to > #if 1 in uaccess.h. That should fix the copy_user relocation errors. Have accumulated enough patches that I'm running a "from scratch" build rather than trusting all the dependency checking. It will be sometime next year before I report back :-). --Bob
Re: [BUG] 4.9.0 build error on Alpha
On Sat, Dec 31, 2016 at 10:11:45AM +, Maciej W. Rozycki wrote: > (...) > You need to keep the `*(.alphalib)' line only, i.e. drop the first and > the last line added by the patch, as the output section statement and its > curly braces surrounding input section specifiers are already produced > elsewhere. > (...) Thought to try this, but, bad news. With '.section .alphalib,"ax"' added to the top of "arch/alpha/lib/*.S" (below opening comment block, if present, but prior to any include directives), and the modified patch to "arch/alpha/kernel/vmlinux.lds.S", I now get multiple relocation errors as follows: LD init/built-in.o arch/alpha/lib/lib.a(strcat.o): In function `strcat': (.text+0x60): relocation truncated to fit: BRADDR against symbol `__stxcpy' defined in .text section in arch/alpha/lib/lib.a(stxcpy.o) arch/alpha/lib/lib.a(strncat.o): In function `strncat': (.text+0x60): relocation truncated to fit: BRADDR against symbol `__stxncpy' defined in .text section in arch/alpha/lib/lib.a(stxncpy.o) drivers/built-in.o: In function `radeon_cs_parser_init.part.4': drivers/gpu/drm/radeon/radeon_cs.o:(.text+0x119bd0): relocation truncated to fit: BRSGP against symbol `__copy_user' defined in .alphalib section in arch/alpha/lib/lib.a(copy_user.o) drivers/gpu/drm/radeon/radeon_cs.o:(.text+0x119cd8): relocation truncated to fit: BRSGP against symbol `__copy_user' defined in .alphalib section in arch/alpha/lib/lib.a(copy_user.o) drivers/gpu/drm/radeon/radeon_cs.o:(.text+0x119db4): relocation truncated to fit: BRSGP against symbol `__copy_user' defined in .alphalib section in arch/alpha/lib/lib.a(copy_user.o) drivers/built-in.o: In function `radeon_cs_ioctl': (.text+0x11aa28): relocation truncated to fit: BRSGP against symbol `__copy_user' defined in .alphalib section in arch/alpha/lib/lib.a(copy_user.o) drivers/built-in.o: In function `radeon_cs_ioctl': (.text+0x11aaf8): relocation truncated to fit: BRSGP against symbol `__copy_user' defined in .alphalib section in arch/alpha/lib/lib.a(copy_user.o) drivers/built-in.o: In function `vga_arb_read': drivers/gpu/vga/.tmp_vgaarb.o:(.text+0x215844): relocation truncated to fit: BRSGP against symbol `__copy_user' defined in .alphalib section in arch/alpha/lib/lib.a(copy_user.o) drivers/built-in.o: In function `vga_arb_write': drivers/gpu/vga/.tmp_vgaarb.o:(.text+0x2162c4): relocation truncated to fit: BRSGP against symbol `__copy_user' defined in .alphalib section in arch/alpha/lib/lib.a(copy_user.o) drivers/built-in.o: In function `dma_buf_ioctl': drivers/dma-buf/.tmp_dma-buf.o:(.text+0x233998): relocation truncated to fit: BRSGP against symbol `__copy_user' defined in .alphalib section in arch/alpha/lib/lib.a(copy_user.o) drivers/built-in.o: In function `generic_ide_ioctl': (.text+0x237c64): additional relocation overflows omitted from the output Makefile:969: recipe for target 'vmlinux' failed make: *** [vmlinux] Error 1 --Bob
Re: [BUG] 4.9.0 build error on Alpha
On Sat, 31 Dec 2016, Bob Tracy wrote: > > > Another possibility could be to put all the lib functions into > > > a "alphalib" section into the final vmlinux. > > > For that add at the top of each of the .S files in lib/ > > > .section .alphalib,"ax" > > > and apply the attached patch for arch/alpha/kernel/vmlinux.lds.S > > > Patch and suggestion is completely untested. Indeed, this is even better as there won't be any unused objects included in output this way. Good idea! > > Worth a try. I'll get going on this and report back with the results in > > a few hours. > > Apologies in advance if the formatting isn't properly preserved :-(. > Syntax error on line 294 of the generated "vmlinux.lds" file, which is > right where the added ".alphalib:" stanza begins: You need to keep the `*(.alphalib)' line only, i.e. drop the first and the last line added by the patch, as the output section statement and its curly braces surrounding input section specifiers are already produced elsewhere. As a good measure you may want to prepend `ALIGN_FUNCTION();' as well, although I'm not sure offhand if it really matters here. HTH, Maciej
Re: [BUG] 4.9.0 build error on Alpha
On Sat, Dec 31, 2016 at 12:43:37AM -0600, Bob Tracy wrote: > On Fri, Dec 30, 2016 at 10:07:06PM +0100, Helge Deller wrote: > > (...) > > Another possibility could be to put all the lib functions into > > a "alphalib" section into the final vmlinux. > > For that add at the top of each of the .S files in lib/ > > .section .alphalib,"ax" > > and apply the attached patch for arch/alpha/kernel/vmlinux.lds.S > > Patch and suggestion is completely untested. > > Worth a try. I'll get going on this and report back with the results in > a few hours. Apologies in advance if the formatting isn't properly preserved :-(. Syntax error on line 294 of the generated "vmlinux.lds" file, which is right where the added ".alphalib:" stanza begins: (...) OUTPUT_FORMAT("elf64-alpha") OUTPUT_ARCH(alpha) ENTRY(__start) PHDRS { kernel PT_LOAD; note PT_NOTE; } jiffies = jiffies_64; SECTIONS { . = 0xfc31; _text = .; /* Text and read-only data */ .text : { *(.head.text) .alphalib: { *(.alphalib) } :kernel . = ALIGN(8); *(.text.hot .text .text.fixup .text.unlikely) *(.ref.text) . = ALIGN(8); __sched_text_start = .; *(.sched.text) __sched_text_end = .; . = ALIGN(8); __cpuidle_text_start = .; *(.cpuidle.text) __cpuidle_text_end = .; . = ALIGN(8); __lock_text_start = .; *(.spinlock.text) __lock_text_end = .; *(.fixup) *(.gnu.warning) } :kernel swapper_pg_dir = (0xfc00 +0x30); _etext = .; /* End of text section */ .notes : AT(ADDR(.notes) - 0) { __start_notes = .; *(.note.*) __stop_notes = .; } :kernel :note .dummy : { *(.dummy) } :kernel (...) --Bob
Re: [BUG] 4.9.0 build error on Alpha
On Fri, Dec 30, 2016 at 10:07:06PM +0100, Helge Deller wrote: > (...) > Another possibility could be to put all the lib functions into > a "alphalib" section into the final vmlinux. > For that add at the top of each of the .S files in lib/ > .section .alphalib,"ax" > and apply the attached patch for arch/alpha/kernel/vmlinux.lds.S > Patch and suggestion is completely untested. Worth a try. I'll get going on this and report back with the results in a few hours. --Bob
Re: [BUG] 4.9.0 build error on Alpha
Hi Bob, On 30.12.2016 17:02, Maciej W. Rozycki wrote: > On Thu, 29 Dec 2016, Bob Tracy wrote: > >>> I'm guessing it's another symptom of the old "kernel too big" problem? >> >> How has this been worked around in the past? I have a fairly >> feature-full kernel, but the only built-in drivers are for the things >> that have to be present at boot time. > > This looks like a link ordering issue to me, the failures are branches > between objects built from arch/alpha/lib/*.S assembly sources, which > must have got moved apart more with the switch of the compiler version. Seems right. > One workaround might be making them a .o rather than .a target, which > will ensure they're close to each other, at the cost of a small kernel > size increase if some of these functions would otherwise be unused. Possible. > Replacing branches with full address calculation and register jumps might > be another, although this would cost some run time instead, so I think the > former approach is a bit better. Another possibility could be to put all the lib functions into a "alphalib" section into the final vmlinux. For that add at the top of each of the .S files in lib/ .section .alphalib,"ax" and apply the attached patch for arch/alpha/kernel/vmlinux.lds.S Patch and suggestion is completely untested. Helge diff --git a/arch/alpha/kernel/vmlinux.lds.S b/arch/alpha/kernel/vmlinux.lds.S index cebecfb..88af6bc 100644 --- a/arch/alpha/kernel/vmlinux.lds.S +++ b/arch/alpha/kernel/vmlinux.lds.S @@ -20,6 +20,9 @@ SECTIONS _text = .; /* Text and read-only data */ .text : { HEAD_TEXT + .alphalib: { + *(.alphalib) + } :kernel TEXT_TEXT SCHED_TEXT CPUIDLE_TEXT
Re: [BUG] 4.9.0 build error on Alpha
On Thu, 29 Dec 2016, Bob Tracy wrote: > > I'm guessing it's another symptom of the old "kernel too big" problem? > > How has this been worked around in the past? I have a fairly > feature-full kernel, but the only built-in drivers are for the things > that have to be present at boot time. This looks like a link ordering issue to me, the failures are branches between objects built from arch/alpha/lib/*.S assembly sources, which must have got moved apart more with the switch of the compiler version. One workaround might be making them a .o rather than .a target, which will ensure they're close to each other, at the cost of a small kernel size increase if some of these functions would otherwise be unused. Replacing branches with full address calculation and register jumps might be another, although this would cost some run time instead, so I think the former approach is a bit better. HTH, Maciej
Re: [BUG] 4.9.0 build error on Alpha
On Thu, Dec 29, 2016 at 10:23:04PM -0500, Matt Turner wrote: > FWIW, when I saw your first email I tried compiling with gcc-4.9.4, > 5.4.0, and 6.2.0. All compiled my config fine. That's worth quite a bit to me, actually :-). Tells me that downgrading my toolchain is probably a waste of time and effort. > I'm guessing it's another symptom of the old "kernel too big" problem? How has this been worked around in the past? I have a fairly feature-full kernel, but the only built-in drivers are for the things that have to be present at boot time. If drivers compiled as modules contribute to the bloat, I could easily omit file system support for things I'll likely never see attached to an alpha. Similarly, drivers for removable USB devices I don't currently use with the system could be omitted as well. Netfilter keeps growing like the hairball it is: features I'm not likely to ever use could be disabled if that might help. --Bob
Re: [BUG] 4.9.0 build error on Alpha
FWIW, when I saw your first email I tried compiling with gcc-4.9.4, 5.4.0, and 6.2.0. All compiled my config fine. I'm guessing it's another symptom of the old "kernel too big" problem?
[BUG] 4.9.0 build error on Alpha
I'm guessing this is Alpha-specific at the moment, because I'm getting a world-class lettin' alone from the kernel developers. Saw another binutils update come through a couple of days ago, so tried another from-scratch kernel build. No change in the outcome. This "smells" like a gcc or binutils issue, because the Alpha-specific code being compiled and linked against hasn't changed in a very long time. Both "strcat" and "stxcpy" come from assembly language source files in the "arch/alpha/lib" directory. In addition to trying new toolchain components as updates appear, I've tried making various changes to my kernel configuration in an attempt to make the problem move to a different place in the build process or go away entirely. Nothing has had any effect whatsoever. I would reluctantly try downgrading gcc to version 4.x if someone thought that might make any difference. I'd rather identify how the current toolchain is going off in the weeds, if that's what is going on here. > LD init/built-in.o > arch/alpha/lib/lib.a(strcat.o): In function `strcat': > (.text+0x60): relocation truncated to fit: BRADDR against symbol `__stxcpy' > defined in .text section in arch/alpha/lib/lib.a(stxcpy.o) > arch/alpha/lib/lib.a(strncat.o): In function `strncat': > (.text+0x60): relocation truncated to fit: BRADDR against symbol `__stxncpy' > defined in .text section in arch/alpha/lib/lib.a(stxncpy.o) > Makefile:969: recipe for target 'vmlinux' failed > make: *** [vmlinux] Error 1 --Bob