Skip to contentSkip to conversation

x86: boot protocol updates.

PATCH Superseded Ian Campbell 2 participants 7 messages Feb 6, 2008 – Feb 7, 2008

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#1 lore raw

PATCH v2 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.

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(-)
Documentation/i386/boot.txt +18 -0
index fc49b79..b5f5ba1 100644
@@ -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
index f88458e..9695aff 100644
@@ -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
index d2b9f3b..92fdd35 100644
@@ -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
index 64ad901..8471658 100644
@@ -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
#2 lore raw

PATCH v2 1/3 x86: use ELF format in compressed images.

In reply to Ian Campbell

This allows other boot loaders such as the Xen domain builder the opportunity to extract the ELF file.

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(-)
Documentation/i386/boot.txt +18 -0
index fc49b79..b5f5ba1 100644
@@ -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
index f88458e..9695aff 100644
@@ -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
index d2b9f3b..92fdd35 100644
@@ -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
index 64ad901..8471658 100644
@@ -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
#3 lore raw

PATCH v2 2/3 x86: add a crc32 checksum to the kernel image.

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 +7 -0
index b5f5ba1..b567fb5 100644
@@ -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 · 1 line
1.5.4
#4 lore raw

PATCH v2 3/3 x86: bump image header to version 2.08.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc H. Peter Anvin <[email protected]>
---
 arch/x86/boot/header.S |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/boot/header.S +1 -1
index 8471658..40c91bb 100644
@@ -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
#5 lore raw

Re: [PATCHv2 2/3] x86: add a crc32 checksum to the kernel image.

In reply to Ian Campbell
Quoted 14 lines · Ian Campbell
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
index b5f5ba1..b567fb5 100644

Documentation/i386/boot.txt Protocol: 2.08+ · line 540

Quoted 10 lines
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.
+

This doesn't specify that the image checksum is present only for boot protocol 2.08 or later, nor does it specify the characteristic polynomial (for CRC32 in particular, I realize the Autodin II polynomial is pretty close to universal, but it should at least state that it is used.)

Quoted 8 lines
Documentation/i386/boot.txt +0 -0
 **** THE KERNEL COMMAND LINE
 
 The kernel command line has become an important way for the boot
arch/x86/boot/tools/build.c +0 -0
index b424874..2ba22e8 100644

arch/x86/boot/tools/build.c typedef unsigned long u32; · line 55

Quoted 6 lines
arch/x86/boot/tools/build.c +3 -0
@@ -50,6 +50,75 @@ typedef unsigned long  u32;
 u8 buf[SETUP_SECT_MAX*512];
 int is_big_kernel;
 
+/*----------------------------------------------------------------------*/
+
+static const unsigned int crctab32[] = {

Really should be "u32" rather than "unsigned int".

arch/x86/boot/tools/build.c typedef unsigned long u32; · line 56

Quoted 1 line
arch/x86/boot/tools/build.c +1 -0
+	0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U,

The "U"s are redundant.

-hpa

#6 lore raw

Re: [PATCHv2 2/3] x86: add a crc32 checksum to the kernel image.

On Wed, 2008-02-06 at 13:06 -0800, H. Peter Anvin wrote:
[...some comments...]

I fixed all of those up.

Thanks,
Ian.

---

x86: add a crc32 checksum to the kernel image.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc H. Peter Anvin <[email protected]>
---
 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
index b5f5ba1..05c24df 100644
@@ -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 · 8 lines
1.5.4


-- 
Ian Campbell

Hempstone's Question:
	If you have to travel on the Titanic, why not go first class?