x86: boot protocol updates.
Subsystems (3)
v3 cover x86: boot protocol updates.
Updates since last time:
- Rebased to latest x86.git#mm (no changes required).
PATCH v3 1/3 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 | 56 +++++++++++++++++++++++++++++++++++++ arch/x86/boot/header.S | 6 ++++ 5 files changed, 95 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
@@ -94,6 +94,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 +56 -0
80 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.4
PATCH v3 1/3 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 | 56 +++++++++++++++++++++++++++++++++++++ arch/x86/boot/header.S | 6 ++++ 5 files changed, 95 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
@@ -94,6 +94,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 +56 -0
80 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.4
PATCH v3 2/3 x86: add a crc32 checksum to the kernel image.
--- Documentation/i386/boot.txt | 8 ++++ arch/x86/boot/tools/build.c | 88 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 95 insertions(+), 1 deletions(-)
Documentation/i386/boot.txt +8 -0
@@ -531,6 +531,14 @@ Protocol: 2.08+ The length of the compressed payload. +**** THE IMAGE CHECKSUM + +From boot protocol version 2.08 onwards the CRC-32 is calculated over +the entire file using the characteristic polynomial 0x04C11DB7 and 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 · 1 line
1.5.4
PATCH v3 3/3 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.4
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
In reply to Ian CampbellQuoted 2 lines · Ian Campbell
This allows other boot loaders such as the Xen domain builder the opportunity to extract the ELF file.
Right, Xen currently can't boot bzImage (it needs the ELF image) so you
still can't use the same kernel image on Xen as bare-metal.
Documentation/i386/boot.txt Protocol: 2.07+ · line 525
Quoted 9 lines
Documentation/i386/boot.txt +9
-0+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.
Should probably mention that the payload format is expected to be ELF.
Quoted 11 lines
arch/x86/boot/Makefile +3
-0@@ -94,6 +94,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' +
arch/x86/boot/Makefile $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE · line 109
Quoted 10 lines
arch/x86/boot/Makefile +10
-0+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
How about this?
+sed-offsets := -e 's/^00*/0/' \
+ -e 's/^\([0-9a-fA-F]*\) . \(input_data\|input_data_end\)$$/-D\2=0x\1 /p'
+
+$(obj)/header.o: AFLAGS_header.o += $(shell $(NM) $(obj)/compressed/vmlinux | sed -n $(sed-offsets)) +$(obj)/header.o: $(obj)/compressed/vmlinux FORCE
Cheers,
Mark.
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
In reply to Ian CampbellQuoted 2 lines · Ian Campbell
This allows other boot loaders such as the Xen domain builder the opportunity to extract the ELF file.
Right, Xen currently can't boot bzImage (it needs the ELF image) so you
still can't use the same kernel image on Xen as bare-metal.
Documentation/i386/boot.txt Protocol: 2.07+ · line 525
Quoted 9 lines
Documentation/i386/boot.txt +9
-0+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.
Should probably mention that the payload format is expected to be ELF.
Quoted 11 lines
arch/x86/boot/Makefile +3
-0@@ -94,6 +94,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' +
arch/x86/boot/Makefile $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE · line 109
Quoted 10 lines
arch/x86/boot/Makefile +10
-0+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
How about this?
+sed-offsets := -e 's/^00*/0/' \
+ -e 's/^\([0-9a-fA-F]*\) . \(input_data\|input_data_end\)$$/-D\2=0x\1 /p'
+
+$(obj)/header.o: AFLAGS_header.o += $(shell $(NM) $(obj)/compressed/vmlinux | sed -n $(sed-offsets)) +$(obj)/header.o: $(obj)/compressed/vmlinux FORCE
Cheers,
Mark.
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
Quoted 6 lines · Mark McLoughlin
Quoted 2 lines · Ian Campbell
This allows other boot loaders such as the Xen domain builder the opportunity to extract the ELF file.
Right, Xen currently can't boot bzImage (it needs the ELF image) so you
still can't use the same kernel image on Xen as bare-metal.
I have a xen domain builder patch as well. I was waiting for the Linux side to gain some traction before putting it forward (I'd attach it now but it's at home on a laptop which is sleeping).
Quoted 11 lines
Documentation/i386/boot.txt Protocol: 2.07+ · line 525
Quoted 9 lines
Documentation/i386/boot.txt +9
-0+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.Should probably mention that the payload format is expected to be ELF.
Agreed. Probably the same deal as the compression format, i.e. use the magic number but only ELF is possible today (even less likely to change than the compression format I guess...).
Review
Quoted 7 lines
How about this?
(quoted diff) +5
-0+sed-offsets := -e 's/^00*/0/' \ + -e 's/^\([0-9a-fA-F]*\) . \(input_data\|input_data_end\)$$/-D\2=0x\1 /p' + +$(obj)/header.o: AFLAGS_header.o += $(shell $(NM) $(obj)/compressed/vmlinux | sed -n $(sed-offsets)) +$(obj)/header.o: $(obj)/compressed/vmlinux FORCE
That's probably a neater way of doing it. Although the ".../header.o:
AFLAGS_header.o" is redundant, either
header.o: AFLAGS += foo or AFLAGS_header.o += foo
with the second being preferred in Linux Makefiles I think.
I'll try and get an updated patch out before I head for my flight tomorrow.
Ian.
Signature · 5 lines
Ian Campbell Current Noise: Reverend Bizarre - The Festival While money can't buy happiness, it certainly lets you choose your own form of misery.
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
In reply to Mark McLoughlinQuoted 6 lines · Mark McLoughlin
Quoted 2 lines · Ian Campbell
This allows other boot loaders such as the Xen domain builder the opportunity to extract the ELF file.
Right, Xen currently can't boot bzImage (it needs the ELF image) so you
still can't use the same kernel image on Xen as bare-metal.
I have a xen domain builder patch as well. I was waiting for the Linux side to gain some traction before putting it forward (I'd attach it now but it's at home on a laptop which is sleeping).
Quoted 11 lines
Documentation/i386/boot.txt Protocol: 2.07+ · line 525
Quoted 9 lines
Documentation/i386/boot.txt +9
-0+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.Should probably mention that the payload format is expected to be ELF.
Agreed. Probably the same deal as the compression format, i.e. use the magic number but only ELF is possible today (even less likely to change than the compression format I guess...).
Review
Quoted 7 lines
How about this?
(quoted diff) +5
-0+sed-offsets := -e 's/^00*/0/' \ + -e 's/^\([0-9a-fA-F]*\) . \(input_data\|input_data_end\)$$/-D\2=0x\1 /p' + +$(obj)/header.o: AFLAGS_header.o += $(shell $(NM) $(obj)/compressed/vmlinux | sed -n $(sed-offsets)) +$(obj)/header.o: $(obj)/compressed/vmlinux FORCE
That's probably a neater way of doing it. Although the ".../header.o:
AFLAGS_header.o" is redundant, either
header.o: AFLAGS += foo or AFLAGS_header.o += foo
with the second being preferred in Linux Makefiles I think.
I'll try and get an updated patch out before I head for my flight tomorrow.
Ian.
Signature · 5 lines
Ian Campbell Current Noise: Reverend Bizarre - The Festival While money can't buy happiness, it certainly lets you choose your own form of misery.
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
Quoted 11 lines · Ian Campbell
Quoted 6 lines · Mark McLoughlin
Quoted 2 lines · Ian Campbell
This allows other boot loaders such as the Xen domain builder the opportunity to extract the ELF file.
Right, Xen currently can't boot bzImage (it needs the ELF image) so you
still can't use the same kernel image on Xen as bare-metal.I have a xen domain builder patch as well. I was waiting for the Linux side to gain some traction before putting it forward (I'd attach it now but it's at home on a laptop which is sleeping).
Yep, just want to highlight to people that your patches (or an alternative) are needed before the same pv_ops kernel truly can be used on bare-metal and Xen.
Quoted 11 lines
Review
Quoted 7 lines
How about this?
(quoted diff) +5
-0+sed-offsets := -e 's/^00*/0/' \ + -e 's/^\([0-9a-fA-F]*\) . \(input_data\|input_data_end\)$$/-D\2=0x\1 /p' + +$(obj)/header.o: AFLAGS_header.o += $(shell $(NM) $(obj)/compressed/vmlinux | sed -n $(sed-offsets)) +$(obj)/header.o: $(obj)/compressed/vmlinux FORCEThat's probably a neater way of doing it. Although the "
.../header.o:
AFLAGS_header.o" is redundant, eitherheader.o: AFLAGS += foo
With this, AFLAGS would apply to building when building the prerequisites of header.o too, which you don't want
The make manual says:
"when you define a target-specific variable that variable value is
also in effect for all prerequisites of this target, and all their prerequisites"
Quoted 3 lines
or
AFLAGS_header.o += foowith the second being preferred in Linux Makefiles I think.
And with this, it would try and read vmlinux before it is built.
But, hmm, given the fact that the variable is defined when building prerequisites, you'd think that even in my version AFLAGS would be evaluated before building vmlinux.
Cheers,
Mark.
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
In reply to Ian CampbellQuoted 11 lines · Ian Campbell
Quoted 6 lines · Mark McLoughlin
Quoted 2 lines · Ian Campbell
This allows other boot loaders such as the Xen domain builder the opportunity to extract the ELF file.
Right, Xen currently can't boot bzImage (it needs the ELF image) so you
still can't use the same kernel image on Xen as bare-metal.I have a xen domain builder patch as well. I was waiting for the Linux side to gain some traction before putting it forward (I'd attach it now but it's at home on a laptop which is sleeping).
Yep, just want to highlight to people that your patches (or an alternative) are needed before the same pv_ops kernel truly can be used on bare-metal and Xen.
Quoted 11 lines
Review
Quoted 7 lines
How about this?
(quoted diff) +5
-0+sed-offsets := -e 's/^00*/0/' \ + -e 's/^\([0-9a-fA-F]*\) . \(input_data\|input_data_end\)$$/-D\2=0x\1 /p' + +$(obj)/header.o: AFLAGS_header.o += $(shell $(NM) $(obj)/compressed/vmlinux | sed -n $(sed-offsets)) +$(obj)/header.o: $(obj)/compressed/vmlinux FORCEThat's probably a neater way of doing it. Although the "
.../header.o:
AFLAGS_header.o" is redundant, eitherheader.o: AFLAGS += foo
With this, AFLAGS would apply to building when building the prerequisites of header.o too, which you don't want
The make manual says:
"when you define a target-specific variable that variable value is
also in effect for all prerequisites of this target, and all their prerequisites"
Quoted 3 lines
or
AFLAGS_header.o += foowith the second being preferred in Linux Makefiles I think.
And with this, it would try and read vmlinux before it is built.
But, hmm, given the fact that the variable is defined when building prerequisites, you'd think that even in my version AFLAGS would be evaluated before building vmlinux.
Cheers,
Mark.
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
Quoted 9 lines · Mark McLoughlin
On Thu, 2008-02-14 at 17:01 +0000, Ian Campbell wrote:
With this, AFLAGS would apply to building when building the prerequisites of header.o too, which you don't wantThe make manual says:
"when you define a target-specific variable that variable value is
also in effect for all prerequisites of this target, and all their prerequisites"
Ah yes, quite right.
I think given that subtleties of these kinds of variable definitions it's probably clearer to stick with the header file way of doing things. it's nice and straight forward.
Ian.
Signature · 5 lines
Ian Campbell Davis' Law of Traffic Density: The density of rush-hour traffic is directly proportional to 1.5 times the amount of extra time you allow to arrive on time.
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
In reply to Mark McLoughlinQuoted 9 lines · Mark McLoughlin
On Thu, 2008-02-14 at 17:01 +0000, Ian Campbell wrote:
With this, AFLAGS would apply to building when building the prerequisites of header.o too, which you don't wantThe make manual says:
"when you define a target-specific variable that variable value is
also in effect for all prerequisites of this target, and all their prerequisites"
Ah yes, quite right.
I think given that subtleties of these kinds of variable definitions it's probably clearer to stick with the header file way of doing things. it's nice and straight forward.
Ian.
Signature · 5 lines
Ian Campbell Davis' Law of Traffic Density: The density of rush-hour traffic is directly proportional to 1.5 times the amount of extra time you allow to arrive on time.
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
In reply to Ian CampbellQuoted 4 lines · Ian Campbell
I have a xen domain builder patch as well. I was waiting for the Linux side to gain some traction before putting it forward (I'd attach it now but it's at home on a laptop which is sleeping).
Here it is:
# HG changeset patch
# User [email protected]
# Date 1203011758 0
# Node ID 3079b4b3835e3aba52bb6548bbbced70471a9f32 # Parent 42369d21641d6297dc369441c3bfd355880d28c0 Support loading Linux bzImage v2.08 and up.
tools/libxc/Makefile +1 -0
@@ -40,6 +40,7 @@ GUEST_SRCS-y += libelf-dominfo.c libelf- # new domain builder GUEST_SRCS-y += xc_dom_core.c xc_dom_boot.c GUEST_SRCS-y += xc_dom_elfloader.c +GUEST_SRCS-y += xc_dom_bzimageloader.c GUEST_SRCS-y += xc_dom_binloader.c GUEST_SRCS-y += xc_dom_compat_linux.c
tools/libxc/xc_dom_bzimageloader.c new file +159 -0
159 lines not on this page · raw message
tools/libxc/xc_dom_elfloader.c +1 -1
@@ -281,7 +281,7 @@ static int xc_dom_load_elf_kernel(struct/* ------------------------------------------------------------------------ */ -static struct xc_dom_loader elf_loader = { +struct xc_dom_loader elf_loader = { .name ="ELF-generic" , .probe = xc_dom_probe_elf_kernel, .parser = xc_dom_parse_elf_kernel,
Signature · 5 lines
Ian Campbell The English have no respect for their language, and will not teach their children to speak it. -- G. B. Shaw
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
In reply to Ian CampbellQuoted 4 lines · Ian Campbell
I have a xen domain builder patch as well. I was waiting for the Linux side to gain some traction before putting it forward (I'd attach it now but it's at home on a laptop which is sleeping).
Here it is:
# HG changeset patch
# User [email protected]
# Date 1203011758 0
# Node ID 3079b4b3835e3aba52bb6548bbbced70471a9f32 # Parent 42369d21641d6297dc369441c3bfd355880d28c0 Support loading Linux bzImage v2.08 and up.
tools/libxc/Makefile +1 -0
@@ -40,6 +40,7 @@ GUEST_SRCS-y += libelf-dominfo.c libelf- # new domain builder GUEST_SRCS-y += xc_dom_core.c xc_dom_boot.c GUEST_SRCS-y += xc_dom_elfloader.c +GUEST_SRCS-y += xc_dom_bzimageloader.c GUEST_SRCS-y += xc_dom_binloader.c GUEST_SRCS-y += xc_dom_compat_linux.c
tools/libxc/xc_dom_bzimageloader.c new file +159 -0
159 lines not on this page · raw message
tools/libxc/xc_dom_elfloader.c +1 -1
@@ -281,7 +281,7 @@ static int xc_dom_load_elf_kernel(struct/* ------------------------------------------------------------------------ */ -static struct xc_dom_loader elf_loader = { +struct xc_dom_loader elf_loader = { .name ="ELF-generic" , .probe = xc_dom_probe_elf_kernel, .parser = xc_dom_parse_elf_kernel,
Signature · 5 lines
Ian Campbell The English have no respect for their language, and will not teach their children to speak it. -- G. B. Shaw
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
Quoted 7 lines · Ian Campbell
Quoted 4 lines · Ian Campbell
I have a xen domain builder patch as well. I was waiting for the Linux side to gain some traction before putting it forward (I'd attach it now but it's at home on a laptop which is sleeping).
Quoted 9 lines
Here it is:
# HG changeset patch
# User [email protected]
# Date 1203011758 0
# Node ID3079b4b3835e3aba52bb6548bbbced70471a9f32# Parent42369d21641d6297dc369441c3bfd355880d28c0Support loading Linux bzImage v2.08 and up.
Do you also have a patch to update the boot protocol?
J
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
In reply to Ian CampbellQuoted 7 lines · Ian Campbell
Quoted 4 lines · Ian Campbell
I have a xen domain builder patch as well. I was waiting for the Linux side to gain some traction before putting it forward (I'd attach it now but it's at home on a laptop which is sleeping).
Quoted 9 lines
Here it is:
# HG changeset patch
# User [email protected]
# Date 1203011758 0
# Node ID3079b4b3835e3aba52bb6548bbbced70471a9f32# Parent42369d21641d6297dc369441c3bfd355880d28c0Support loading Linux bzImage v2.08 and up.
Do you also have a patch to update the boot protocol?
J
H. Peter Anvin
reviewerRe: [PATCHv3 1/3] x86: use ELF format in compressed images.
Quoted 3 lines · Jeremy Fitzhardinge
Do you also have a patch to update the boot protocol?
Looking for anything different than the root of this thread?
-hpa
H. Peter Anvin
reviewerRe: [PATCHv3 1/3] x86: use ELF format in compressed images.
In reply to Jeremy FitzhardingeQuoted 3 lines · Jeremy Fitzhardinge
Do you also have a patch to update the boot protocol?
Looking for anything different than the root of this thread?
-hpa
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
Quoted 6 lines · H. Peter Anvin
Quoted 3 lines · Jeremy Fitzhardinge
Do you also have a patch to update the boot protocol?
Looking for anything different than the root of this thread?
Yes, the patch for the Xen domain builder to boot a bzImage using the Linux boot protocol rather than the Xen one. Ian's patch will extract the ELF file from the bzImage, but still boot it by finding the Xen entrypoint in the notes, with %esi pointing to the Xen start_info rather than the boot_params (unless I'm missing something).
J
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
In reply to H. Peter AnvinQuoted 6 lines · H. Peter Anvin
Quoted 3 lines · Jeremy Fitzhardinge
Do you also have a patch to update the boot protocol?
Looking for anything different than the root of this thread?
Yes, the patch for the Xen domain builder to boot a bzImage using the Linux boot protocol rather than the Xen one. Ian's patch will extract the ELF file from the bzImage, but still boot it by finding the Xen entrypoint in the notes, with %esi pointing to the Xen start_info rather than the boot_params (unless I'm missing something).
J
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
In reply to Ian CampbellQuoted 12 lines · Ian Campbell
Quoted 7 lines
Review
Quoted 7 lines
(quoted diff) +6
-0+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 ofthe
Quoted 1 line
Quoted 1 line
+ real-mode code to the compressed payload. The compression
format
Quoted 1 line
Quoted 1 line
+ should be determined using the standard magic number, currently
only
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
+ gzip is used.
Should probably mention that the payload format is expected to
be ELF.
Agreed. Probably the same deal as the compression format, i.e. use the magic number but only ELF is possible today (even less likely to change than the compression format I guess...).
Updated with a note about ELF format payload.
I've also changed the fields to just payload_{offset,length} and adjusted the description to allow for the possibility of non-compressed ELF payloads. I don't have a use for it myself but I can see how it might be useful (embedded systems?) so it seems reasonable not to rule it out. ELF-in-gzip and plain ELF can both be identified by magic numbers.
Ian.
---
From 544c003d4067d895556180fc11a951e211202d0d Mon Sep 17 00:00:00 2001
From: Ian Campbell <[email protected]>
Date: Thu, 14 Feb 2008 18:29:01 +0000
Subject: [PATCH] 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 | 20 +++++++++++++ arch/x86/boot/Makefile | 14 +++++++++ arch/x86/boot/compressed/Makefile | 2 +- arch/x86/boot/compressed/misc.c | 56 +++++++++++++++++++++++++++++++++++++ arch/x86/boot/header.S | 4 ++ 5 files changed, 95 insertions(+), 1 deletions(-)
Documentation/i386/boot.txt +20 -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+ payload_offset Offset of kernel payload +024C/4 2.08+ payload_length Length of kernel payload (1) For backwards compatibility, if the setup_sects field contains 0, the real value is 4.
@@ -512,6 +514,24 @@ Protocol: 2.07+ A pointer to data that is specific to hardware subarch +Field name: 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 payload. + + The payload may be compressed. The format of both the compressed and + uncompressed data should be determined using the standard magic + numbers. Currently only gzip compressed ELF is used. + +Field name: payload_length +Type: read +Offset/size: 0x24c/4 +Protocol: 2.08+ + + The length of the payload. **** THE KERNEL COMMAND LINE
arch/x86/boot/Makefile +14 -0
@@ -94,6 +94,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 +56 -0
80 lines not on this page · raw message
arch/x86/boot/header.S +4 -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,9 @@ hardware_subarch: .long 0 # subarchitecture, added with 2.07 hardware_subarch_data: .quad 0 +payload_offset: .long input_data +payload_length: .long input_data_end-input_data + # End of setup header ##################################################### .section ".inittext", "ax"
Signature · 8 lines
1.5.4 -- Ian Campbell The moss on the tree does not fear the talons of the hawk.
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
In reply to Ian CampbellQuoted 12 lines · Ian Campbell
Quoted 7 lines
Review
Quoted 7 lines
(quoted diff) +6
-0+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 ofthe
Quoted 1 line
Quoted 1 line
+ real-mode code to the compressed payload. The compression
format
Quoted 1 line
Quoted 1 line
+ should be determined using the standard magic number, currently
only
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
+ gzip is used.
Should probably mention that the payload format is expected to
be ELF.
Agreed. Probably the same deal as the compression format, i.e. use the magic number but only ELF is possible today (even less likely to change than the compression format I guess...).
Updated with a note about ELF format payload.
I've also changed the fields to just payload_{offset,length} and adjusted the description to allow for the possibility of non-compressed ELF payloads. I don't have a use for it myself but I can see how it might be useful (embedded systems?) so it seems reasonable not to rule it out. ELF-in-gzip and plain ELF can both be identified by magic numbers.
Ian.
---
Quoted 1 line
From
544c003d4067d895556180fc11a951e211202d0dMon Sep 17 00:00:00 2001
From: Ian Campbell <[email protected]>
Date: Thu, 14 Feb 2008 18:29:01 +0000
Subject: [PATCH] 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 | 20 +++++++++++++ arch/x86/boot/Makefile | 14 +++++++++ arch/x86/boot/compressed/Makefile | 2 +- arch/x86/boot/compressed/misc.c | 56 +++++++++++++++++++++++++++++++++++++ arch/x86/boot/header.S | 4 ++ 5 files changed, 95 insertions(+), 1 deletions(-)
Documentation/i386/boot.txt +20 -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+ payload_offset Offset of kernel payload +024C/4 2.08+ payload_length Length of kernel payload (1) For backwards compatibility, if the setup_sects field contains 0, the real value is 4.
@@ -512,6 +514,24 @@ Protocol: 2.07+ A pointer to data that is specific to hardware subarch +Field name: 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 payload. + + The payload may be compressed. The format of both the compressed and + uncompressed data should be determined using the standard magic + numbers. Currently only gzip compressed ELF is used. + +Field name: payload_length +Type: read +Offset/size: 0x24c/4 +Protocol: 2.08+ + + The length of the payload. **** THE KERNEL COMMAND LINE
arch/x86/boot/Makefile +14 -0
@@ -94,6 +94,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 +56 -0
80 lines not on this page · raw message
arch/x86/boot/header.S +4 -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,9 @@ hardware_subarch: .long 0 # subarchitecture, added with 2.07 hardware_subarch_data: .quad 0 +payload_offset: .long input_data +payload_length: .long input_data_end-input_data + # End of setup header ##################################################### .section ".inittext", "ax"
Signature · 8 lines
1.5.4 -- Ian Campbell The moss on the tree does not fear the talons of the hawk.
H. Peter Anvin
reviewerRe: [PATCHv3 1/3] x86: use ELF format in compressed images.
In reply to Ian CampbellQuoted 5 lines · Ian Campbell
Agreed. Probably the same deal as the compression format, i.e. use the magic number but only ELF is possible today (even less likely to change than the compression format I guess...).
Quite.
-hpa
H. Peter Anvin
reviewerRe: [PATCHv3 1/3] x86: use ELF format in compressed images.
In reply to Ian CampbellQuoted 5 lines · Ian Campbell
Agreed. Probably the same deal as the compression format, i.e. use the magic number but only ELF is possible today (even less likely to change than the compression format I guess...).
Quite.
-hpa
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
In reply to Ian CampbellQuoted 155 lines · Ian Campbell
This allows other boot loaders such as the Xen domain builder the
opportunity to extract the ELF file.Signed-off-by Ian Campbell <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Jeremy Fitzhardinge <[email protected]>---
Documentation/i386/boot.txt | 18 ++++++++++++ arch/x86/boot/Makefile | 14 +++++++++ arch/x86/boot/compressed/Makefile | 2 +- arch/x86/boot/compressed/misc.c | 56 +++++++++++++++++++++++++++++++++++++ arch/x86/boot/header.S | 6 ++++ 5 files changed, 95 insertions(+), 1 deletions(-)diff --git
a/Documentation/i386/boot.txtb/Documentation/i386/boot.txtindex fc49b79..b5f5ba1 100644
---a/Documentation/i386/boot.txt
+++b/Documentation/i386/boot.txt
@@ -170,6 +170,8 @@ Offset Proto Name Meaning0238/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_sectsfield 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
diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile index f88458e..9695aff 100644
--- a/arch/x86/boot/Makefile
+++ b/arch/x86/boot/Makefile
@@ -94,6 +94,20 @@ $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCESETUP_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) diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index d2b9f3b..92fdd35 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -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)diff --git
a/arch/x86/boot/compressed/misc.cb/arch/x86/boot/compressed/misc.cindex 8182e32..69aec2f 100644
---a/arch/x86/boot/compressed/misc.c
+++b/arch/x86/boot/compressed/misc.c
@@ -15,6 +15,10 @@
* we just keep it from happening
*/
#undefCONFIG_PARAVIRT
+#ifdefCONFIG_X86_32
+#define _ASM_DESC_H_ 1
+#endif
+
#ifdefCONFIG_X86_64
#define _LINUX_STRING_H_ 1
#define__LINUX_BITMAP_H1
@@ -22,6 +26,7 @@#include <
linux/linkage.h>
#include <linux/screen_info.h>
+#include <linux/elf.h>
#include <asm/io.h>
#include <asm/page.h>
#include <asm/boot.h>
@@ -365,6 +370,56 @@ static voiderror(char *x)asm("hlt");}
+static void
parse_elf(void *output)
+{
+#ifdefCONFIG_X86_64
+Elf64_Ehdrehdr;
+Elf64_Phdr*phdrs, *phdr;
+#else
+Elf32_Ehdrehdr;
+Elf32_Phdr*phdrs, *phdr;
+#endif
+ void *dest;
+ int i;
+
+memcpy(&ehdr, output, sizeof(ehdr));+ if(ehdr.e_ident[EI_MAG0] != ELFMAG0 || + ehdr.e_ident[EI_MAG1] != ELFMAG1 || + ehdr.e_ident[EI_MAG2] != ELFMAG2 ||+ ehdr.e_ident[EI_MAG3] != ELFMAG3)
+ {
+error("Kernel is not a valid ELF file");
+ return;
+ }
+
+ putstr("Parsing ELF... ");
+
+ phdrs =malloc(sizeof(*phdrs) * ehdr.e_phnum);
+ if (!phdrs)
+error("Failed to allocate space for phdrs");
+
+memcpy(phdrs, output + ehdr.e_phoff, sizeof(*phdrs) * ehdr.e_phnum);
+
+ for (i=0; i<ehdr.e_phnum; i++) {
+ phdr = &phdrs[i];
+
+ switch (phdr->p_type) {
+ casePT_LOAD:
+#ifdefCONFIG_RELOCATABLE
+ dest = output;
Quoted 8 lines
+ dest += (
phdr->p_paddr-LOAD_PHYSICAL_ADDR);
+#else
+ dest = (void*)(phdr->p_paddr);
+#endif
+ memcpy(dest,
+ output +phdr->p_offset,
+phdr->p_filesz);
+ break;
so will cost every bzImage extra memory copy? that could be 18M or even more big.
wonder if can have one some other kind elf format, and offset load address to avoid that mem copy.
YH
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
In reply to Ian CampbellQuoted 155 lines · Ian Campbell
This allows other boot loaders such as the Xen domain builder the
opportunity to extract the ELF file.Signed-off-by Ian Campbell <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Jeremy Fitzhardinge <[email protected]>---
Documentation/i386/boot.txt | 18 ++++++++++++ arch/x86/boot/Makefile | 14 +++++++++ arch/x86/boot/compressed/Makefile | 2 +- arch/x86/boot/compressed/misc.c | 56 +++++++++++++++++++++++++++++++++++++ arch/x86/boot/header.S | 6 ++++ 5 files changed, 95 insertions(+), 1 deletions(-)diff --git
a/Documentation/i386/boot.txtb/Documentation/i386/boot.txtindex fc49b79..b5f5ba1 100644
---a/Documentation/i386/boot.txt
+++b/Documentation/i386/boot.txt
@@ -170,6 +170,8 @@ Offset Proto Name Meaning0238/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_sectsfield 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
diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile index f88458e..9695aff 100644
--- a/arch/x86/boot/Makefile
+++ b/arch/x86/boot/Makefile
@@ -94,6 +94,20 @@ $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCESETUP_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) diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index d2b9f3b..92fdd35 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -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)diff --git
a/arch/x86/boot/compressed/misc.cb/arch/x86/boot/compressed/misc.cindex 8182e32..69aec2f 100644
---a/arch/x86/boot/compressed/misc.c
+++b/arch/x86/boot/compressed/misc.c
@@ -15,6 +15,10 @@
* we just keep it from happening
*/
#undefCONFIG_PARAVIRT
+#ifdefCONFIG_X86_32
+#define _ASM_DESC_H_ 1
+#endif
+
#ifdefCONFIG_X86_64
#define _LINUX_STRING_H_ 1
#define__LINUX_BITMAP_H1
@@ -22,6 +26,7 @@#include <
linux/linkage.h>
#include <linux/screen_info.h>
+#include <linux/elf.h>
#include <asm/io.h>
#include <asm/page.h>
#include <asm/boot.h>
@@ -365,6 +370,56 @@ static voiderror(char *x)asm("hlt");}
+static void
parse_elf(void *output)
+{
+#ifdefCONFIG_X86_64
+Elf64_Ehdrehdr;
+Elf64_Phdr*phdrs, *phdr;
+#else
+Elf32_Ehdrehdr;
+Elf32_Phdr*phdrs, *phdr;
+#endif
+ void *dest;
+ int i;
+
+memcpy(&ehdr, output, sizeof(ehdr));+ if(ehdr.e_ident[EI_MAG0] != ELFMAG0 || + ehdr.e_ident[EI_MAG1] != ELFMAG1 || + ehdr.e_ident[EI_MAG2] != ELFMAG2 ||+ ehdr.e_ident[EI_MAG3] != ELFMAG3)
+ {
+error("Kernel is not a valid ELF file");
+ return;
+ }
+
+ putstr("Parsing ELF... ");
+
+ phdrs =malloc(sizeof(*phdrs) * ehdr.e_phnum);
+ if (!phdrs)
+error("Failed to allocate space for phdrs");
+
+memcpy(phdrs, output + ehdr.e_phoff, sizeof(*phdrs) * ehdr.e_phnum);
+
+ for (i=0; i<ehdr.e_phnum; i++) {
+ phdr = &phdrs[i];
+
+ switch (phdr->p_type) {
+ casePT_LOAD:
+#ifdefCONFIG_RELOCATABLE
+ dest = output;
Quoted 8 lines
+ dest += (
phdr->p_paddr-LOAD_PHYSICAL_ADDR);
+#else
+ dest = (void*)(phdr->p_paddr);
+#endif
+ memcpy(dest,
+ output +phdr->p_offset,
+phdr->p_filesz);
+ break;
so will cost every bzImage extra memory copy? that could be 18M or even more big.
wonder if can have one some other kind elf format, and offset load address to avoid that mem copy.
YH
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
Quoted 2 lines · Yinghai Lu
so will cost every bzImage extra memory copy? that could be 18M or even more big.
Is it a huge deal for something that happens exactly once on boot? How does the time take compare with the time to do the decompression?
18M seems like an awfully large kernel image to me. My distro (Debian) kernel is more like 3M uncompressed. If someone was interested in fast booting presumably they would either build a kernel with exactly what they need.
Quoted 2 lines
wonder if can have one some other kind elf format, and offset load address to avoid that mem copy.
I guess you could reduce the load address by sizeof(headers) and add a dest == (output + phdr->p_offset) test before the copy.
Another possibility, which is much more complex, is that the ELF parsing could be integrated into the decompressor such that the data is decompressed into the correct location directly.
Ian.
Signature · 4 lines
Ian Campbell People who have no faults are terrible; there is no way of taking advantage of them.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/virtualization
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
In reply to Yinghai LuQuoted 2 lines · Yinghai Lu
so will cost every bzImage extra memory copy? that could be 18M or even more big.
Is it a huge deal for something that happens exactly once on boot? How does the time take compare with the time to do the decompression?
18M seems like an awfully large kernel image to me. My distro (Debian) kernel is more like 3M uncompressed. If someone was interested in fast booting presumably they would either build a kernel with exactly what they need.
Quoted 2 lines
wonder if can have one some other kind elf format, and offset load address to avoid that mem copy.
I guess you could reduce the load address by sizeof(headers) and add a dest == (output + phdr->p_offset) test before the copy.
Another possibility, which is much more complex, is that the ELF parsing could be integrated into the decompressor such that the data is decompressed into the correct location directly.
Ian.
Signature · 4 lines
Ian Campbell People who have no faults are terrible; there is no way of taking advantage of them.
H. Peter Anvin
reviewerRe: [PATCHv3 1/3] x86: use ELF format in compressed images.
In reply to Yinghai LuQuoted 2 lines · Yinghai Lu
so will cost every bzImage extra memory copy? that could be 18M or even more big.
I wouldn't worry about that. You will typically have several copies of the images during the execution of the boot loader.
-hpa
H. Peter Anvin
reviewerRe: [PATCHv3 1/3] x86: use ELF format in compressed images.
In reply to Yinghai LuQuoted 2 lines · Yinghai Lu
so will cost every bzImage extra memory copy? that could be 18M or even more big.
I wouldn't worry about that. You will typically have several copies of the images during the execution of the boot loader.
-hpa
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
Quoted 8 lines · H. Peter Anvin
Quoted 3 lines · Yinghai Lu
so will cost every bzImage extra memory copy? that could be 18M or even more big.
I wouldn't worry about that. You will typically have several copies of the
images during the execution of the boot loader.
i put all drivers needed in kernel.
1. bootloader copy bzImage (6M) to memory
2. arch/x86/boot/compressed/head_32.S, will copy bzImage to end of buffer to do uncompress on possiton.
3. parse_elf will copy the vmlinux (the uncompressed, that is some big, 18M)
I suggest that could have special elf header, and will only have one PT_LOAD, and avoid the copy, and just offset start address of uncompressed kernel for jump later.
YH
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
In reply to H. Peter AnvinQuoted 8 lines · H. Peter Anvin
Quoted 3 lines · Yinghai Lu
so will cost every bzImage extra memory copy? that could be 18M or even more big.
I wouldn't worry about that. You will typically have several copies of the
images during the execution of the boot loader.
i put all drivers needed in kernel.
1. bootloader copy bzImage (6M) to memory
2. arch/x86/boot/compressed/head_32.S, will copy bzImage to end of buffer to do uncompress on possiton.
3. parse_elf will copy the vmlinux (the uncompressed, that is some big, 18M)
I suggest that could have special elf header, and will only have one PT_LOAD, and avoid the copy, and just offset start address of uncompressed kernel for jump later.
YH
H. Peter Anvin
reviewerRe: [PATCHv3 1/3] x86: use ELF format in compressed images.
Quoted 15 lines · Yinghai Lu
Quoted 7 lines · H. Peter Anvin
Quoted 3 lines · Yinghai Lu
so will cost every bzImage extra memory copy? that could be 18M or even more big.
I wouldn't worry about that. You will typically have several copies of the
images during the execution of the boot loader.i put all drivers needed in kernel.
1. bootloader copy bzImage (6M) to memory
2.arch/x86/boot/compressed/head_32.S, will copy bzImage to end of buffer to do uncompress on possiton.
3.parse_elfwill copy the vmlinux (the uncompressed, that is some big, 18M)
Quoted 3 lines
I suggest that could have special elf header, and will only have one
PT_LOAD, and avoid the copy, and just offset start address of uncompressed kernel for jump later.
Once again, I think you will have a hard time measuring the time difference.
The start address of the uncompressed kernel is defined at compile time.
Typically it is set based on alignment constraints in the hardware;
for x86-32 is is normally 1 MB but for reasonably large hardware 16 MB is better (in fact, I have proposed making 16 MB the default.) Recovery kernels are frequently compiled with completely different addresses.
With your proposal, this would no longer be possible to be a configurable option, which would be a major loss -- a major loss of functionality for a small fraction of time at bootup time (which is almost certainly dwarfed by all the other copying and initialization that happens at boot time.)
-hpa
H. Peter Anvin
reviewerRe: [PATCHv3 1/3] x86: use ELF format in compressed images.
In reply to Yinghai LuQuoted 15 lines · Yinghai Lu
Quoted 7 lines · H. Peter Anvin
Quoted 3 lines · Yinghai Lu
so will cost every bzImage extra memory copy? that could be 18M or even more big.
I wouldn't worry about that. You will typically have several copies of the
images during the execution of the boot loader.i put all drivers needed in kernel.
1. bootloader copy bzImage (6M) to memory
2.arch/x86/boot/compressed/head_32.S, will copy bzImage to end of buffer to do uncompress on possiton.
3.parse_elfwill copy the vmlinux (the uncompressed, that is some big, 18M)
Quoted 3 lines
I suggest that could have special elf header, and will only have one
PT_LOAD, and avoid the copy, and just offset start address of uncompressed kernel for jump later.
Once again, I think you will have a hard time measuring the time difference.
The start address of the uncompressed kernel is defined at compile time.
Typically it is set based on alignment constraints in the hardware;
for x86-32 is is normally 1 MB but for reasonably large hardware 16 MB is better (in fact, I have proposed making 16 MB the default.) Recovery kernels are frequently compiled with completely different addresses.
With your proposal, this would no longer be possible to be a configurable option, which would be a major loss -- a major loss of functionality for a small fraction of time at bootup time (which is almost certainly dwarfed by all the other copying and initialization that happens at boot time.)
-hpa
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
Quoted 24 lines · H. Peter Anvin
Quoted 10 lines · Yinghai Lu
Quoted 8 lines · H. Peter Anvin
Quoted 4 lines · Yinghai Lu
so will cost every bzImage extra memory copy? that could be 18M or even more big.
I wouldn't worry about that. You will typically have several copies of
the
Quoted 8 lines
Quoted 2 lines
images during the execution of the boot loader.
i put all drivers needed in kernel.
1. bootloader copy bzImage (6M) to memory
2.arch/x86/boot/compressed/head_32.S, will copy bzImage to end of buffer to do uncompress on possiton.
3.parse_elfwill copy the vmlinux (the uncompressed, that is some big,18M)
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
I suggest that could have special elf header, and will only have one
PT_LOAD, and avoid the copy, and just offset start address of uncompressed kernel for jump later.Once again, I think you will have a hard time measuring the time
difference.
ok.
forget about my proposal..
YH
Re: [PATCHv3 1/3] x86: use ELF format in compressed images.
In reply to H. Peter AnvinQuoted 24 lines · H. Peter Anvin
Quoted 10 lines · Yinghai Lu
Quoted 8 lines · H. Peter Anvin
Quoted 4 lines · Yinghai Lu
so will cost every bzImage extra memory copy? that could be 18M or even more big.
I wouldn't worry about that. You will typically have several copies of
the
Quoted 8 lines
Quoted 2 lines
images during the execution of the boot loader.
i put all drivers needed in kernel.
1. bootloader copy bzImage (6M) to memory
2.arch/x86/boot/compressed/head_32.S, will copy bzImage to end of buffer to do uncompress on possiton.
3.parse_elfwill copy the vmlinux (the uncompressed, that is some big,18M)
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
I suggest that could have special elf header, and will only have one
PT_LOAD, and avoid the copy, and just offset start address of uncompressed kernel for jump later.Once again, I think you will have a hard time measuring the time
difference.
ok.
forget about my proposal..
YH
Thomas Gleixner
AppliedQuoted 3 lines · Ian Campbell
Updates since last time:
- Rebased to latest x86.git#mm (no changes required).
Applied. Thanks,
tglx
Quoted 7 lines · Thomas Gleixner
Quoted 3 lines · Ian Campbell
Updates since last time:
- Rebased to latest x86.git#mm (no changes required).Applied. Thanks,
Thank you.
Could you take this version of "1/3 x86: use ELF format in compressed images" instead? It contains a slightly improved version of the doc section making it clear that ELF is used for the uncompressed data. It also renames the field to just payload_{offset,length} so as to not rule out the possibility of uncompressed payloads.
Quoted 1 line
From
7d2b37d7b0342e748320e2104adbdd8ba0b3666dMon Sep 17 00:00:00 2001
From: Ian Campbell <[email protected]>
Date: Thu, 14 Feb 2008 18:29:01 +0000
Subject: [PATCH] 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 | 20 +++++++++++++ arch/x86/boot/Makefile | 14 +++++++++ arch/x86/boot/compressed/Makefile | 2 +- arch/x86/boot/compressed/misc.c | 56 +++++++++++++++++++++++++++++++++++++ arch/x86/boot/header.S | 4 ++ 5 files changed, 95 insertions(+), 1 deletions(-)
Documentation/i386/boot.txt +20 -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+ payload_offset Offset of kernel payload +024C/4 2.08+ payload_length Length of kernel payload (1) For backwards compatibility, if the setup_sects field contains 0, the real value is 4.
@@ -512,6 +514,24 @@ Protocol: 2.07+ A pointer to data that is specific to hardware subarch +Field name: 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 payload. + + The payload may be compressed. The format of both the compressed and + uncompressed data should be determined using the standard magic + numbers. Currently only gzip compressed ELF is used. + +Field name: payload_length +Type: read +Offset/size: 0x24c/4 +Protocol: 2.08+ + + The length of the payload. **** THE KERNEL COMMAND LINE
arch/x86/boot/Makefile +14 -0
@@ -94,6 +94,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 +56 -0
80 lines not on this page · raw message
arch/x86/boot/header.S +4 -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,9 @@ hardware_subarch: .long 0 # subarchitecture, added with 2.07 hardware_subarch_data: .quad 0 +payload_offset: .long input_data +payload_length: .long input_data_end-input_data + # End of setup header ##################################################### .section ".inittext", "ax"
Signature · 9 lines
1.5.4 -- Ian Campbell Modern art is what happens when painters stop looking at girls and persuade themselves that they have a better idea. -- John Ciardi