x86: define OBJCOPYFLAGS explicitly for each target.
Subsystems (3)
PATCH 1/1 x86: define OBJCOPYFLAGS explicitly for each target.
Do this rather than defining a global version and overriding it in almost all cases in order to make subsequent patches simpler.
--- arch/x86/Makefile | 1 - arch/x86/boot/Makefile | 2 +- arch/x86/boot/compressed/Makefile | 1 + 3 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/Makefile +0 -1
@@ -92,7 +92,6 @@ KBUILD_AFLAGS += $(cfi) $(cfi-sigframe) KBUILD_CFLAGS += $(cfi) $(cfi-sigframe) LDFLAGS := -m elf_$(UTS_MACHINE) -OBJCOPYFLAGS := -O binary -R .note -R .comment -S # Speed up the build KBUILD_CFLAGS += -pipe
arch/x86/boot/Makefile +1 -1
@@ -80,6 +80,7 @@ $(obj)/zImage $(obj)/bzImage: $(obj)/setup.bin \ $(call if_changed,image) @echo 'Kernel: $@ is ready' ' (#'`cat .version`')' +OBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE $(call if_changed,objcopy)
@@ -90,7 +91,6 @@ $(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE $(call if_changed,ld) OBJCOPYFLAGS_setup.bin := -O binary - $(obj)/setup.bin: $(obj)/setup.elf FORCE $(call if_changed,objcopy)
arch/x86/boot/compressed/Makefile +1 -0
@@ -22,6 +22,7 @@ $(obj)/vmlinux: $(src)/vmlinux_$(BITS).lds $(obj)/head_$(BITS).o $(obj)/misc.o $ $(call if_changed,ld) @: +OBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S $(obj)/vmlinux.bin: vmlinux FORCE $(call if_changed,objcopy)
Signature · 1 line
1.5.3.8
PATCH 1/1 x86: use ELF format in compressed images.
This allows other boot loaders such as the Xen domain builder the opportunity to extract the ELF file.
--- Documentation/i386/boot.txt | 18 +++++++++++++ arch/x86/boot/Makefile | 14 ++++++++++ arch/x86/boot/compressed/Makefile | 2 +- arch/x86/boot/compressed/misc.c | 49 +++++++++++++++++++++++++++++++++++++ arch/x86/boot/header.S | 6 ++++ 5 files changed, 88 insertions(+), 1 deletions(-)
Documentation/i386/boot.txt +18 -0
@@ -170,6 +170,8 @@ Offset Proto Name Meaning 0238/4 2.06+ cmdline_size Maximum size of the kernel command line 023C/4 2.07+ hardware_subarch Hardware subarchitecture 0240/8 2.07+ hardware_subarch_data Subarchitecture-specific data +0248/4 2.08+ compressed_payload_offset +024C/4 2.08+ compressed_payload_length (1) For backwards compatibility, if the setup_sects field contains 0, the real value is 4.
@@ -512,6 +514,22 @@ Protocol: 2.07+ A pointer to data that is specific to hardware subarch +Field name: compressed_payload_offset +Type: read +Offset/size: 0x248/4 +Protocol: 2.08+ + + If non-zero then this field contains the offset from the end of the + real-mode code to the compressed payload. The compression format + should be determined using the standard magic number, currently only + gzip is used. + +Field name: compressed_payload_length +Type: read +Offset/size: 0x24c/4 +Protocol: 2.08+ + + The length of the compressed payload. **** THE KERNEL COMMAND LINE
arch/x86/boot/Makefile +14 -0
@@ -86,6 +86,20 @@ $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE SETUP_OBJS = $(addprefix $(obj)/,$(setup-y)) +sed-offsets := -e 's/^00*/0/' \ + -e 's/^\([0-9a-fA-F]*\) . \(input_data\|input_data_end\)$$/\#define \2 0x\1/p' + +quiet_cmd_offsets = OFFSETS $@ + cmd_offsets = $(NM) $< | sed -n $(sed-offsets) > $@ + +$(obj)/offsets.h: $(obj)/compressed/vmlinux FORCE + $(call if_changed,offsets) + +targets += offsets.h + +AFLAGS_header.o += -I$(obj) +$(obj)/header.o: $(obj)/offsets.h + LDFLAGS_setup.elf := -T $(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE $(call if_changed,ld)
arch/x86/boot/compressed/Makefile +1 -1
@@ -22,7 +22,7 @@ $(obj)/vmlinux: $(src)/vmlinux_$(BITS).lds $(obj)/head_$(BITS).o $(obj)/misc.o $ $(call if_changed,ld) @: -OBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S +OBJCOPYFLAGS_vmlinux.bin := -R .comment -S $(obj)/vmlinux.bin: vmlinux FORCE $(call if_changed,objcopy)
arch/x86/boot/compressed/misc.c +49 -0
73 lines not on this page · raw message
arch/x86/boot/header.S +6 -0
@@ -22,6 +22,7 @@ #include <asm/page.h> #include <asm/setup.h> #include "boot.h" +#include "offsets.h" SETUPSECTS = 4 /* default nr of setup-sectors */ BOOTSEG = 0x07C0 /* original address of boot-sector */
@@ -223,6 +224,11 @@ hardware_subarch: .long 0 # subarchitecture, added with 2.07 hardware_subarch_data: .quad 0 +compressed_payload_offset: + .long input_data +compressed_payload_length: + .long input_data_end-input_data + # End of setup header ##################################################### .section ".inittext", "ax"
Signature · 1 line
1.5.3.8
PATCH 1/1 x86: use ELF format in compressed images.
In reply to Ian CampbellThis allows other boot loaders such as the Xen domain builder the opportunity to extract the ELF file.
--- Documentation/i386/boot.txt | 18 +++++++++++++ arch/x86/boot/Makefile | 14 ++++++++++ arch/x86/boot/compressed/Makefile | 2 +- arch/x86/boot/compressed/misc.c | 49 +++++++++++++++++++++++++++++++++++++ arch/x86/boot/header.S | 6 ++++ 5 files changed, 88 insertions(+), 1 deletions(-)
Documentation/i386/boot.txt +18 -0
@@ -170,6 +170,8 @@ Offset Proto Name Meaning 0238/4 2.06+ cmdline_size Maximum size of the kernel command line 023C/4 2.07+ hardware_subarch Hardware subarchitecture 0240/8 2.07+ hardware_subarch_data Subarchitecture-specific data +0248/4 2.08+ compressed_payload_offset +024C/4 2.08+ compressed_payload_length (1) For backwards compatibility, if the setup_sects field contains 0, the real value is 4.
@@ -512,6 +514,22 @@ Protocol: 2.07+ A pointer to data that is specific to hardware subarch +Field name: compressed_payload_offset +Type: read +Offset/size: 0x248/4 +Protocol: 2.08+ + + If non-zero then this field contains the offset from the end of the + real-mode code to the compressed payload. The compression format + should be determined using the standard magic number, currently only + gzip is used. + +Field name: compressed_payload_length +Type: read +Offset/size: 0x24c/4 +Protocol: 2.08+ + + The length of the compressed payload. **** THE KERNEL COMMAND LINE
arch/x86/boot/Makefile +14 -0
@@ -86,6 +86,20 @@ $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE SETUP_OBJS = $(addprefix $(obj)/,$(setup-y)) +sed-offsets := -e 's/^00*/0/' \ + -e 's/^\([0-9a-fA-F]*\) . \(input_data\|input_data_end\)$$/\#define \2 0x\1/p' + +quiet_cmd_offsets = OFFSETS $@ + cmd_offsets = $(NM) $< | sed -n $(sed-offsets) > $@ + +$(obj)/offsets.h: $(obj)/compressed/vmlinux FORCE + $(call if_changed,offsets) + +targets += offsets.h + +AFLAGS_header.o += -I$(obj) +$(obj)/header.o: $(obj)/offsets.h + LDFLAGS_setup.elf := -T $(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE $(call if_changed,ld)
arch/x86/boot/compressed/Makefile +1 -1
@@ -22,7 +22,7 @@ $(obj)/vmlinux: $(src)/vmlinux_$(BITS).lds $(obj)/head_$(BITS).o $(obj)/misc.o $ $(call if_changed,ld) @: -OBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S +OBJCOPYFLAGS_vmlinux.bin := -R .comment -S $(obj)/vmlinux.bin: vmlinux FORCE $(call if_changed,objcopy)
arch/x86/boot/compressed/misc.c +49 -0
73 lines not on this page · raw message
arch/x86/boot/header.S +6 -0
@@ -22,6 +22,7 @@ #include <asm/page.h> #include <asm/setup.h> #include "boot.h" +#include "offsets.h" SETUPSECTS = 4 /* default nr of setup-sectors */ BOOTSEG = 0x07C0 /* original address of boot-sector */
@@ -223,6 +224,11 @@ hardware_subarch: .long 0 # subarchitecture, added with 2.07 hardware_subarch_data: .quad 0 +compressed_payload_offset: + .long input_data +compressed_payload_length: + .long input_data_end-input_data + # End of setup header ##################################################### .section ".inittext", "ax"
Signature · 1 line
1.5.3.8
PATCH 1/1 x86: add a crc32 checksum to the kernel image.
--- Documentation/i386/boot.txt | 5 +++ arch/x86/boot/tools/build.c | 78 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 0 deletions(-)
Documentation/i386/boot.txt +5 -0
@@ -531,6 +531,11 @@ Protocol: 2.08+ The length of the compressed payload. +**** THE IMAGE CHECKSUM + +The CRC-32 checksum of the entire file is appended to the end of the +file. The CRC of the file including these trailing bytes is therefore 0. + **** THE KERNEL COMMAND LINE The kernel command line has become an important way for the boot
arch/x86/boot/tools/build.c +78 -0
102 lines not on this page · raw message
Signature · 1 line
1.5.3.8
PATCH 1/1 x86: bump image header to version 2.08.
--- arch/x86/boot/header.S | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/boot/header.S +1 -1
@@ -120,7 +120,7 @@ _start: # Part 2 of the header, from the old setup.S .ascii "HdrS" # header signature - .word 0x0207 # header version number (>= 0x0105) + .word 0x0208 # header version number (>= 0x0105) # or else old loadlin-1.5 will fail) .globl realmode_swtch realmode_swtch: .word 0, 0 # default_switch, SETUPSEG
Signature · 1 line
1.5.3.8
H. Peter Anvin
reviewerRe: [PATCH] x86: add a crc32 checksum to the kernel image.
In reply to Ian CampbellQuoted 14 lines · Ian Campbell
Signed-off-by Ian Campbell <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc H. Peter Anvin <[email protected]>--- Documentation/i386/boot.txt | 5 +++ arch/x86/boot/tools/build.c | 78 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 0 deletions(-)Documentation/i386/boot.txt +0
-0
Documentation/i386/boot.txt Protocol: 2.08+ · line 538
Quoted 8 lines
Documentation/i386/boot.txt +5
-0@@ -531,6 +531,11 @@ Protocol: 2.08+ The length of the compressed payload. +**** THE IMAGE CHECKSUM + +The CRC-32 checksum of the entire file is appended to the end of the +file. The CRC of the file including these trailing bytes is therefore 0. +
Hm. I have some minor concerns about this:
* The classical length field is only available in multiples of 16 (I realize your patches change that to some degree, but I'd hate to make the guarantee that the image payload is the last thing in the image -- it loses flexibility for the future.) The end of the image isn't available in all cases, so this would require padding it out to a 16-byte boundary before appending the CRC32. An mmap is guaranteed to be zero-padded out to the next page boundary, so explicitly rounding sz up (instead of when calculating sys_size) should do the job.
* I believe it is recommended to store the inverse of the crc32, not the crc32 itself - it catches more errors. This is also the reason to start out with ~0 rather than 0.
* Please don't use "unsigned long" to represent a 32-bit number.
-hpa
H. Peter Anvin
reviewerRe: [PATCH] x86: add a crc32 checksum to the kernel image.
Quoted 5 lines · H. Peter Anvin
Hm. I have some minor concerns about this:
* The classical length field is only available in multiples of 16 (I realize your patches change that to some degree, but I'd hate to make the guarantee that the image payload is the last thing in the image -- it loses flexibility for the future.) The end of the image isn't available in all cases, so this would require padding it out to a 16-byte boundary before appending the CRC32. An mmap is guaranteed to be zero-padded out to the next page boundary, so explicitly rounding sz up (instead of when calculating
sys_size) should do the job.
Thinking about this more carefully, we should probably have it rounded up to a 16-byte boundary *including* the CRC32, so the CRC32 is included in the notional image.
-hpa
Re: [PATCH] x86: add a crc32 checksum to the kernel image.
In reply to H. Peter AnvinQuoted 10 lines · H. Peter Anvin
Hm. I have some minor concerns about this:
* The classical length field is only available in multiples of 16 (I realize your patches change that to some degree, but I'd hate to make the guarantee that the image payload is the last thing in the image -- it loses flexibility for the future.) The end of the image isn't available in all cases, so this would require padding it out to a 16-byte boundary before appending the CRC32. An mmap is guaranteed to be zero-padded out to the next page boundary, so explicitly rounding sz up (instead of when calculating
sys_size) should do the job.
Peter in a followup mail:
Quoted 3 lines
Thinking about this more carefully, we should probably have it rounded up to a 16-byte boundary *including* the CRC32, so the CRC32 is included in the notional image.
Agreed.
Peter in the first mail again:
Quoted 3 lines
* I believe it is recommended to store the inverse of the crc32, not the crc32 itself - it catches more errors. This is also the reason to start out with ~0 rather than 0.
If you store the inverted checksum then the complete file will always sum to 0xdebb20e3 rather than zero.
However I'm told that inverting the checksum only protects extra zeroes after the CRC. Given that we checksum over a known length and don't especially care about trailing zeroes in any case I think it is nicer if the file checksums to zero.
Quoted 1 line
* Please don't use "unsigned long" to represent a 32-bit number.
Fixed.
---
Quoted 1 line
From
1c614383dc9cb0c7791ebab386dc012db336b28cMon Sep 17 00:00:00 2001
From: Ian Campbell <[email protected]>
Date: Fri, 1 Feb 2008 09:01:22 +0000
Subject: [PATCH] x86: add a crc32 checksum to the kernel image.
--- Documentation/i386/boot.txt | 7 +++ arch/x86/boot/tools/build.c | 88 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 94 insertions(+), 1 deletions(-)
Documentation/i386/boot.txt +7 -0
@@ -531,6 +531,13 @@ Protocol: 2.08+ The length of the compressed payload. +**** THE IMAGE CHECKSUM + +The CRC-32 is calculated over the entire file using an initial +remainder of 0xffffffff. The checksum is appended to the file +therefore the CRC of the file up to the limit specified in the syssize +field of the header is always 0. + **** THE KERNEL COMMAND LINE The kernel command line has become an important way for the boot
arch/x86/boot/tools/build.c +87 -1
118 lines not on this page · raw message
Signature · 9 lines
1.5.3.8 -- Ian Campbell In matters of principle, stand like a rock; in matters of taste, swim with the current. -- Thomas Jefferson
Ingo Molnar
AppliedRe: [PATCH] x86: add a crc32 checksum to the kernel image.
Quoted 3 lines · Ian Campbell
Quoted 1 line
* Please don't use "unsigned long" to represent a 32-bit number.
Fixed.
thanks, applied.
Ingo
Re: [PATCH] x86: add a crc32 checksum to the kernel image.
In reply to Ian CampbellQuoted 20 lines · On Fri, 01 Feb 2008 09:02:48 +0000 Ian Campbell wrote:
---
Quoted 1 line
From
1c614383dc9cb0c7791ebab386dc012db336b28cMon Sep 17 00:00:00 2001From: Ian Campbell <[email protected]>
Date: Fri, 1 Feb 2008 09:01:22 +0000
Subject: [PATCH] x86: add a crc32 checksum to the kernel image.Signed-off-by Ian Campbell <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc H. Peter Anvin <[email protected]>--- Documentation/i386/boot.txt | 7 +++ arch/x86/boot/tools/build.c | 88 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 94 insertions(+), 1 deletions(-)Documentation/i386/boot.txt +0
-0
Documentation/i386/boot.txt Protocol: 2.08+ · line 537
Quoted 7 lines
Documentation/i386/boot.txt +4
-0@@ -531,6 +531,13 @@ Protocol: 2.08+ The length of the compressed payload. +**** THE IMAGE CHECKSUM + +The CRC-32 is calculated over the entire file using an initial +remainder of 0xffffffff. The checksum is appended to the file
Run-on sentences.
Use period (full stop) or semi-colon at end of above sentence. If using a period, capitalize the next word. Thanks.
Documentation/i386/boot.txt Protocol: 2.08+ · line 543
Quoted 6 lines
Documentation/i386/boot.txt +3
-0+therefore the CRC of the file up to the limit specified in the syssize +field of the header is always 0. + **** THE KERNEL COMMAND LINE The kernel command line has become an important way for the boot
---
~Randy
Re: [PATCH] x86: add a crc32 checksum to the kernel image.
Quoted 12 lines · Randy Dunlap
Documentation/i386/boot.txt Protocol: 2.08+ · line 537
Quoted 5 lines · On Fri, 01 Feb 2008 09:02:48 +0000 Ian Campbell wrote:
Documentation/i386/boot.txt +4
-0+**** THE IMAGE CHECKSUM + +The CRC-32 is calculated over the entire file using an initial +remainder of 0xffffffff. The checksum is appended to the fileRun-on sentences.
Use period (full stop) or semi-colon at end of above sentence. If using a period, capitalize the next word. Thanks.
Quoted 2 lines
Documentation/i386/boot.txt Protocol: 2.08+ · line 539
Quoted 2 lines
Documentation/i386/boot.txt +2
-0+therefore the CRC of the file up to the limit specified in the syssize +field of the header is always 0.
Thanks. I went with:
+The CRC-32 is calculated over the entire file using an initial +remainder of 0xffffffff. The checksum is appended to the file; +therefore the CRC of the file up to the limit specified in the syssize +field of the header is always 0.
Signature · 4 lines
Ian Campbell If the master dies and the disciple grieves, the lives of both have been wasted.
Re: [PATCH] x86: add a crc32 checksum to the kernel image.
Quoted 17 lines · Ian Campbell
Quoted 11 lines · Randy Dunlap
Documentation/i386/boot.txt Protocol: 2.08+ · line 537
Quoted 5 lines · On Fri, 01 Feb 2008 09:02:48 +0000 Ian Campbell wrote:
Documentation/i386/boot.txt +4
-0+**** THE IMAGE CHECKSUM + +The CRC-32 is calculated over the entire file using an initial +remainder of 0xffffffff. The checksum is appended to the fileRun-on sentences.
Use period (full stop) or semi-colon at end of above sentence. If using a period, capitalize the next word. Thanks.Quoted 2 lines
Documentation/i386/boot.txt Protocol: 2.08+ · line 539
Quoted 2 lines
Documentation/i386/boot.txt +2
-0+therefore the CRC of the file up to the limit specified in the syssize +field of the header is always 0.Thanks. I went with:
Documentation/i386/boot.txt Protocol: 2.08+ · line 539
Quoted 4 lines
Documentation/i386/boot.txt +4
-0+The CRC-32 is calculated over the entire file using an initial +remainder of 0xffffffff. The checksum is appended to the file; +therefore the CRC of the file up to the limit specified in the syssize +field of the header is always 0.
Fine, thanks.
Signature · 1 line
~Randy
Re: [PATCH] x86: add a crc32 checksum to the kernel image.
In reply to Ian CampbellIsn't a crc32 calculation already defined? Yes; in lib/crc32.c. One is surely enough.
H. Peter Anvin
reviewerRe: [PATCH] x86: add a crc32 checksum to the kernel image.
Quoted 2 lines · David Newall
Isn't a crc32 calculation already defined? Yes; in
lib/crc32.c. One is surely enough.
As long as it can be included in user-space code we should use that one.
-hpa
Re: [PATCH] x86: add a crc32 checksum to the kernel image.
Quoted 5 lines · H. Peter Anvin
Quoted 2 lines · David Newall
Isn't a crc32 calculation already defined? Yes; in
lib/crc32.c. One is surely enough.As long as it can be included in user-space code we should use that one.
You're right. I misread the patch. I thought the calculation was being added to kernel code.
Re: [PATCH] x86: add a crc32 checksum to the kernel image.
In reply to H. Peter AnvinQuoted 5 lines · H. Peter Anvin
Quoted 2 lines · David Newall
Isn't a crc32 calculation already defined? Yes; in
lib/crc32.c. One is surely enough.As long as it can be included in user-space code we should use that one.
I don't think it can. There is a main function surrounded by #ifdef UNITTEST which might once have worked but now there is far too much kernel gunk in there (as you might expect).
If I can work up the enthusiasm I might break out the core algorithm into a separate file that can be used in both the kernel and userspace.
Ian.
Signature · 6 lines
Ian Campbell Current Noise: Reverend Bizarre - Cirith Ungol "Would I turn on the gas if my pal Mugsy were in there?" "You might, rabbit, you might!" -- Looney Tunes, Bugs and Thugs (1954, Friz Freleng)
Quoted 2 lines · Ian Campbell
Do this rather than defining a global version and overriding it in almost all cases in order to make subsequent patches simpler.
thanks Ian - i've picked up #1, #2 and #4 from your series. Once #3 is OK to Peter i'll add that too. (#4, the bumping of the version needs #3 to be meaningful.)
Ingo