x86/boot: adjust text gap/diff to work with 64-bytes alignment too
PATCH 1/1 x86/boot: adjust text gap/diff to work with 64-bytes alignment too
Xen compiled with -mtune=generic has .text alignment set to 64-bytes. Having text_diff non-64-bytes-aligned breaks stuff:
Traceback (most recent call last):
File "/builddir/build/BUILD/xen-4.20.0-build/xen-4.20.0-rc0/xen/./tools/combine_two_binaries.py", line 96, in <module>
raise Exception('File sizes do not match')
Exception: File sizes do not match: 70160 != 4080 + 66048
Adjust the numbers as suggested by Frediano to work with 64-bytes and even 128-bytes alignment.
--- xen/arch/x86/boot/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/x86/boot/Makefile +2 -2
@@ -40,8 +40,8 @@ LD32 := $(LD) $(subst x86_64,i386,$(LDFLAGS_DIRECT)) # are affected by both text_diff and text_gap. Ensure the sum of gap and diff # is greater than 2^16 so that any 16bit relocations if present in the object # file turns into a build-time error. -text_gap := 0x010200 -text_diff := 0x408020 +text_gap := 0x010240 +text_diff := 0x608040 $(obj)/build32.base.lds: AFLAGS-y += -DGAP=$(text_gap) -DTEXT_DIFF=$(text_diff) $(obj)/build32.offset.lds: AFLAGS-y += -DGAP=$(text_gap) -DTEXT_DIFF=$(text_diff) -DAPPLY_OFFSET
Signature · 1 line
2.46.0
Quoted 10 lines · Marek Marczykowski-Górecki
Xen compiled with -mtune=generic has .text alignment set to 64-bytes. Having
text_diffnon-64-bytes-aligned breaks stuff:Traceback (most recent call last):
File "/builddir/build/BUILD/xen-4.20.0-build/xen-4.20.0-rc0/xen/./tools/combine_two_binaries.py", line 96, in <module>
raise Exception('File sizes do not match')
Exception: File sizes do not match: 70160 != 4080 + 66048Adjust the numbers as suggested by Frediano to work with 64-bytes and even 128-bytes alignment.
And then breaking at 256? As indicated on Matrix, imo we should be able to cope with anything up to at least PAGE_SIZE. Or we should reduce .text alignment before linking.
Quoted 2 lines
Suggested-by Frediano Ziglio <[email protected]>Signed-off-by Marek Marczykowski-Górecki <[email protected]>
No Fixes: tag?
Jan
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Marek Marczykowski-Górecki
Xen compiled with -mtune=generic has .text alignment set to 64-bytes. Having
text_diffnon-64-bytes-aligned breaks stuff:Traceback (most recent call last):
File "/builddir/build/BUILD/xen-4.20.0-build/xen-4.20.0-rc0/xen/./tools/combine_two_binaries.py", line 96, in <module>
raise Exception('File sizes do not match')
Exception: File sizes do not match: 70160 != 4080 + 66048
Quoted 5 lines
Quoted 2 lines
Adjust the numbers as suggested by Frediano to work with 64-bytes and even 128-bytes alignment.
And then breaking at 256? As indicated on Matrix, imo we should be able to cope with anything up to at least
PAGE_SIZE. Or we should reduce .text alignment before linking.
Do you have a concrete proposal on how to do this?
Because if not, we've had 2 downstreams hit by this build failure, and we probably ought to take this patch as a stopgap fix, and see about doing the better fix for 4.20.
~Andrew
Quoted 10 lines · Andrew Cooper
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Marek Marczykowski-Górecki
Xen compiled with -mtune=generic has .text alignment set to 64-bytes. Having
text_diffnon-64-bytes-aligned breaks stuff:Traceback (most recent call last):
File "/builddir/build/BUILD/xen-4.20.0-build/xen-4.20.0-rc0/xen/./tools/combine_two_binaries.py", line 96, in <module>
raise Exception('File sizes do not match')
Exception: File sizes do not match: 70160 != 4080 + 66048
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Adjust the numbers as suggested by Frediano to work with 64-bytes and even 128-bytes alignment.
And then breaking at 256? As indicated on Matrix, imo we should be able to cope with anything up to at least
PAGE_SIZE. Or we should reduce .text alignment before linking.Do you have a concrete proposal on how to do this?
The latter suggestion would involve objcopy's --set-section-alignment, the former would involve using constants with the low 12 bits clear.
Quoted 3 lines
Because if not, we've had 2 downstreams hit by this build failure, and we probably ought to take this patch as a stopgap fix, and see about doing the better fix for 4.20.
4.21 that is, I guess. I never like such very much, because it's too likely that it'll then be forgotten.
Jan
Quoted 17 lines · Andrew Cooper
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Marek Marczykowski-Górecki
Xen compiled with -mtune=generic has .text alignment set to 64-bytes. Having
text_diffnon-64-bytes-aligned breaks stuff:Traceback (most recent call last):
File "/builddir/build/BUILD/xen-4.20.0-build/xen-4.20.0-rc0/xen/./tools/combine_two_binaries.py", line 96, in <module>
raise Exception('File sizes do not match')
Exception: File sizes do not match: 70160 != 4080 + 66048Quoted 5 lines
Quoted 2 lines
Adjust the numbers as suggested by Frediano to work with 64-bytes and even 128-bytes alignment.
And then breaking at 256? As indicated on Matrix, imo we should be able to cope with anything up to at least
PAGE_SIZE. Or we should reduce .text alignment before linking.
Quoted 6 lines
Do you have a concrete proposal on how to do this?
Because if not, we've had 2 downstreams hit by this build failure, and we probably ought to take this patch as a stopgap fix, and see about doing the better fix for 4.20.
I agree with this, merge this and then leave the improvements for follow up(s).
Yesterday I checked the output object file (built-in-32.o) to find that the output alignment is 1 byte, which is obviously wrong!
There's no current requirement for page alignment. As page management is done in both 32 and 64 bit code, pages are allocated in other parts of the sources and handled correctly.
Personally I prefer incremental development with sensible and self-contained improvements kept separate, instead of adding changes and changes because somebody touches a piece of code that can be improved. Usually any piece of code can be improved.
Frediano
Quoted 18 lines · Frediano Ziglio
Quoted 17 lines · Andrew Cooper
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Marek Marczykowski-Górecki
Xen compiled with -mtune=generic has .text alignment set to 64-bytes. Having
text_diffnon-64-bytes-aligned breaks stuff:Traceback (most recent call last):
File "/builddir/build/BUILD/xen-4.20.0-build/xen-4.20.0-rc0/xen/./tools/combine_two_binaries.py", line 96, in <module>
raise Exception('File sizes do not match')
Exception: File sizes do not match: 70160 != 4080 + 66048Quoted 5 lines
Quoted 2 lines
Adjust the numbers as suggested by Frediano to work with 64-bytes and even 128-bytes alignment.
And then breaking at 256? As indicated on Matrix, imo we should be able to cope with anything up to at least
PAGE_SIZE. Or we should reduce .text alignment before linking.Do you have a concrete proposal on how to do this?
Quoted 8 lines
Quoted 4 lines
Because if not, we've had 2 downstreams hit by this build failure, and we probably ought to take this patch as a stopgap fix, and see about doing the better fix for 4.20.
I agree with this, merge this and then leave the improvements for follow up(s).
Yesterday I checked the output object file (built-in-32.o) to find that the output alignment is 1 byte, which is obviously wrong!
No so. It's perfectly easy to end up with 1 byte alignment on .text, commonly with -Os.
e.g. In my build, reloc-trampoline.32.o has:
Sections:
Idx Name Size VMA LMA File off Algn
0 .group 00000008 00000000 00000000 00000034 2**2 CONTENTS, READONLY, GROUP, LINK_ONCE_DISCARD
1 .text 00000076 00000000 00000000 0000003c 2**0 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
2 .data 00000000 00000000 00000000 000000b2 2**0 CONTENTS, ALLOC, LOAD, DATA
3 .bss 00000000 00000000 00000000 000000b2 2**0 ALLOC
4 .text.__x86.get_pc_thunk.bx 00000004 00000000 00000000 000000b2 2**0 CONTENTS, ALLOC, LOAD, READONLY, CODE
5 .comment 00000020 00000000 00000000 000000b6 2**0 CONTENTS, READONLY
6 .note.GNU-stack 00000000 00000000 00000000 000000d6 2**0 CONTENTS, READONLY
and this is entirely reasonable IMO.
That said, the fact that built-in-32.S does not have at least one .align directive probably is an issue.
x86 will cope, and there's nothing interesting in this code that's going to choke on being misaligned.
~Andrew
Quoted 51 lines · Andrew Cooper
Quoted 18 lines · Frediano Ziglio
Quoted 17 lines · Andrew Cooper
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Marek Marczykowski-Górecki
Xen compiled with -mtune=generic has .text alignment set to 64-bytes. Having
text_diffnon-64-bytes-aligned breaks stuff:Traceback (most recent call last):
File "/builddir/build/BUILD/xen-4.20.0-build/xen-4.20.0-rc0/xen/./tools/combine_two_binaries.py", line 96, in <module>
raise Exception('File sizes do not match')
Exception: File sizes do not match: 70160 != 4080 + 66048Quoted 5 lines
Quoted 2 lines
Adjust the numbers as suggested by Frediano to work with 64-bytes and even 128-bytes alignment.
And then breaking at 256? As indicated on Matrix, imo we should be able to cope with anything up to at least
PAGE_SIZE. Or we should reduce .text alignment before linking.Do you have a concrete proposal on how to do this?
Quoted 8 lines
Quoted 4 lines
Because if not, we've had 2 downstreams hit by this build failure, and we probably ought to take this patch as a stopgap fix, and see about doing the better fix for 4.20.
I agree with this, merge this and then leave the improvements for follow up(s).
Yesterday I checked the output object file (built-in-32.o) to find that the output alignment is 1 byte, which is obviously wrong!
No so. It's perfectly easy to end up with 1 byte alignment on .text, commonly with -Os.
e.g. In my build, reloc-trampoline.32.o has:
Sections:
Idx Name Size VMA LMA File off Algn 0 .group 00000008 00000000 00000000 00000034 2**2CONTENTS, READONLY, GROUP,
LINK_ONCE_DISCARD
1 .text 00000076 00000000 000000000000003c2**0
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
2 .data 00000000 00000000 00000000000000b22**0
CONTENTS, ALLOC, LOAD, DATA
3 .bss 00000000 00000000 00000000000000b22**0
ALLOC
4 .text.__x86.get_pc_thunk.bx 00000004 00000000 00000000000000b22**0
CONTENTS, ALLOC, LOAD, READONLY, CODE
5 .comment 00000020 00000000 00000000000000b62**0
CONTENTS, READONLY
6 .note.GNU-stack 00000000 00000000 00000000000000d62**0
CONTENTS, READONLY
Quoted 8 lines
and this is entirely reasonable IMO.
That said, the fact that
built-in-32.Sdoes not have at least one .align directive probably is an issue.x86 will cope, and there's nothing interesting in this code that's going to choke on being misaligned.
What about something like
https://github.com/freddy77/xen/commit/299a1fd70a84e9b52b84d59daff6878a3c42a595
?
Frediano
Quoted 1 line · Jan Beulich
No Fixes: tag?
I guess this would be appropriate:
(but not relevant for backports, since that's only in 4.20 release cycle)
Signature · 3 lines
Best Regards, Marek Marczykowski-Górecki Invisible Things Lab