diff options
author | H. Peter Anvin <hpa@linux.intel.com> | 2011-01-25 16:53:42 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2011-01-25 16:53:42 -0800 |
commit | 036fa4e1a8aefeba3f39ebd634fe242b0ab84ce3 (patch) | |
tree | e84359406f8fdaae2fc004128e12245e93e84867 | |
parent | ac1a3f7dc145eafd199f2d14d26b34c77af7d586 (diff) | |
download | syslinux-036fa4e1a8aefeba3f39ebd634fe242b0ab84ce3.tar.gz |
disk: put a magic at the end of the boot sector
Put a magic signature at the end of the boot sector, and a backpointer
to the code that contains the pointer to the main code extent. This
is useful for integrity-checking tools, and could help the installer
in the future.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r-- | core/diskboot.inc | 10 | ||||
-rw-r--r-- | core/diskfs.inc | 5 | ||||
-rw-r--r-- | core/diskstart.inc | 5 | ||||
-rw-r--r-- | libinstaller/syslxint.h | 8 |
4 files changed, 19 insertions, 9 deletions
diff --git a/core/diskboot.inc b/core/diskboot.inc index 4a730b0b..574db456 100644 --- a/core/diskboot.inc +++ b/core/diskboot.inc @@ -262,6 +262,7 @@ eddcheck: ; with parsing the superblock and root directory; it doesn't fit ; together with EBIOS support, unfortunately. ; +Sect1Load: mov eax,strict dword Sect1Ptr0_VAL ; 0xdeadbeef Sect1Ptr0 equ $-4 mov edx,strict dword Sect1Ptr1_VAL ; 0xfeedface @@ -273,9 +274,8 @@ Sect1Ptr1 equ $-4 cmp dword [ldlinux_magic+4],LDLINUX_MAGIC^HEXDATE jne kaboom - ; Go for it... - jmp 0:ldlinux_ent - + ; Go for it! This also normalizes CS:IP. + jmp ldlinux_ent ; ; getonesec: load a single disk linear sector EDX:EAX into the buffer @@ -423,8 +423,10 @@ xint13: bailmsg: db 'Boot error', 0Dh, 0Ah, 0 ; This fails if the boot sector overflowsg - zb 1FEh-($-$$) + zb 1F8h-($-$$) +bs_magic dd LDLINUX_MAGIC +bs_link dw (Sect1Load - bootsec) | BS_MAGIC_VER bootsignature dw 0xAA55 ; diff --git a/core/diskfs.inc b/core/diskfs.inc index a04a4f0d..fc80a153 100644 --- a/core/diskfs.inc +++ b/core/diskfs.inc @@ -2,7 +2,7 @@ ; ----------------------------------------------------------------------- ; ; Copyright 1994-2009 H. Peter Anvin - All Rights Reserved -; Copyright 2009 Intel Corporation; author: H. Peter Anvin +; Copyright 2009-2011 Intel Corporation; author: H. Peter Anvin ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by @@ -27,6 +27,9 @@ retry_count equ 16 ; How patient are we with the disk? %assign HIGHMEM_SLOP 0 ; Avoid this much memory near the top LDLINUX_MAGIC equ 0x3eb202fe ; A random number to identify ourselves with +; This indicates the general format of the last few bytes in the boot sector +BS_MAGIC_VER equ 0x1b << 9 + SECTOR_SHIFT equ 9 SECTOR_SIZE equ (1 << SECTOR_SHIFT) diff --git a/core/diskstart.inc b/core/diskstart.inc index 4e2d1fcf..b3c09286 100644 --- a/core/diskstart.inc +++ b/core/diskstart.inc @@ -1,7 +1,7 @@ ; ----------------------------------------------------------------------- ; ; Copyright 1994-2009 H. Peter Anvin - All Rights Reserved -; Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin +; Copyright 2009-2011 Intel Corporation; author: H. Peter Anvin ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by @@ -92,7 +92,8 @@ ldlinux_ent: ; value in CS, but we don't want to deal with that anymore from now ; on. ; - sti ; In case of broken INT 13h BIOSes + jmp 0:.next ; Normalize CS:IP +.next: sti ; In case of broken INT 13h BIOSes ; ; Tell the user we got this far diff --git a/libinstaller/syslxint.h b/libinstaller/syslxint.h index 14a7fc2b..80c40f76 100644 --- a/libinstaller/syslxint.h +++ b/libinstaller/syslxint.h @@ -1,6 +1,7 @@ /* ----------------------------------------------------------------------- * * * Copyright 2007-2008 H. Peter Anvin - All Rights Reserved + * Copyright 2009-2011 Intel Corporation; author: H. Peter Anvin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -156,6 +157,7 @@ void memcpy_from_sl(void *dst, const void *src, size_t len); #endif #define LDLINUX_MAGIC 0x3eb202fe +#define BS_MAGIC_VER (0x1b << 9) /* Patch area for disk-based installers */ struct patch_area { @@ -214,7 +216,7 @@ struct boot_sector { uint32_t VolumeID; char VolumeLabel[11]; char FileSysType[8]; - uint8_t Code[448]; + uint8_t Code[442]; } __attribute__ ((packed)) bs16; struct { uint32_t FATSz32; @@ -230,10 +232,12 @@ struct boot_sector { uint32_t VolumeID; char VolumeLabel[11]; char FileSysType[8]; - uint8_t Code[420]; + uint8_t Code[414]; } __attribute__ ((packed)) bs32; } __attribute__ ((packed)); + uint32_t bsMagic; + uint16_t bsForwardPtr; uint16_t bsSignature; } __attribute__ ((packed)); |