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

From: H. Peter Anvin
Date: Wed Feb 06 2008 - 16:07:26 EST


Ian Campbell wrote:
Signed-off-by: Ian Campbell <ijc@xxxxxxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: H. Peter Anvin <hpa@xxxxxxxxx>
---
Documentation/i386/boot.txt | 7 +++
arch/x86/boot/tools/build.c | 88 ++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 94 insertions(+), 1 deletions(-)

diff --git a/Documentation/i386/boot.txt b/Documentation/i386/boot.txt
index b5f5ba1..b567fb5 100644
--- a/Documentation/i386/boot.txt
+++ b/Documentation/i386/boot.txt
@@ -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.)

**** THE KERNEL COMMAND LINE
The kernel command line has become an important way for the boot
diff --git a/arch/x86/boot/tools/build.c b/arch/x86/boot/tools/build.c
index b424874..2ba22e8 100644
--- a/arch/x86/boot/tools/build.c
+++ b/arch/x86/boot/tools/build.c
@@ -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".

+ 0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U,

The "U"s are redundant.

-hpa
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/