[PATCH] EDD disksig patch for 2.6.1
From: Matt Domsch
Date: Tue Jan 20 2004 - 17:12:00 EST
I sent this patch before the holidays, had no feedback on it
specifically. The same functional code is in 2.4.x mainline now. I'm
still working on the follow-on patches for symlinks for IDE and SCSI
devices in sysfs, but those are separate from the disksig patch. For
Andrew, patch is appended, linux-2.6.1-edd1-disksig.patch. Please
consider for -mm and/or mainline.
Linus, please do a
bk pull http://mdomsch.bkbits.net/linux-2.5-edd-for-linus
This will update the following files:
Documentation/i386/zero-page.txt | 4 +++-
arch/i386/boot/setup.S | 21 +++++++++++++++++++++
arch/i386/kernel/edd.c | 22 +++++++++++++++++++++-
arch/i386/kernel/i386_ksyms.c | 6 ------
arch/i386/kernel/setup.c | 7 +++++++
include/asm-i386/edd.h | 6 +++++-
include/asm-i386/setup.h | 1 +
7 files changed, 58 insertions, 9 deletions
through these ChangeSets:
<Matt_Domsch@xxxxxxxx> (04/01/20 1.1505)
EDD: read disk80 MBR signature, export through edd module
There are 4 bytes in the MSDOS master boot record, at offset 0x1b8,
which may contain a per-system-unique signature. By first writing a
unique signature to each disk in the system, then rebooting, and then
reading the MBR to get the signature for the boot disk (int13 dev
80h), userspace may use it to compare against disks it knows as named
/dev/[hs]d[a-z], and thus determine which disk is the BIOS boot disk,
thus where the /boot, / and boot loaders should be placed.
This is useful in the case where the BIOS is not EDD3.0 compliant,
thus doesn't provide the PCI bus/dev/fn and IDE/SCSI location of the
boot disk, yet you need to know which disk is the boot disk. It's
most useful in OS installers.
This patch retrieves the signature from the disk in setup.S, stores it
in a space reserved in the empty_zero_page, copies it somewhere safe
in setup.c, and exports it via
/sys/firmware/edd/int13_disk80/mbr_signature in edd.c. Code is
covered under CONFIG_EDD=[ym].
--
Matt Domsch
Sr. Software Engineer, Lead Engineer
Dell Linux Solutions www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com
You can import this changeset into BK by piping this whole message to
'| bk receive [path to repository]' or apply the patch as usual.
===================================================================
ChangeSet@xxxxxx, 2004-01-20 15:45:36-06:00, Matt_Domsch@xxxxxxxx
EDD: read disk80 MBR signature, export through edd module
There are 4 bytes in the MSDOS master boot record, at offset 0x1b8,
which may contain a per-system-unique signature. By first writing a
unique signature to each disk in the system, then rebooting, and then
reading the MBR to get the signature for the boot disk (int13 dev
80h), userspace may use it to compare against disks it knows as named
/dev/[hs]d[a-z], and thus determine which disk is the BIOS boot disk,
thus where the /boot, / and boot loaders should be placed.
This is useful in the case where the BIOS is not EDD3.0 compliant,
thus doesn't provide the PCI bus/dev/fn and IDE/SCSI location of the
boot disk, yet you need to know which disk is the boot disk. It's
most useful in OS installers.
This patch retrieves the signature from the disk in setup.S, stores it
in a space reserved in the empty_zero_page, copies it somewhere safe
in setup.c, and exports it via
/sys/firmware/edd/int13_disk80/mbr_signature in edd.c. Code is
covered under CONFIG_EDD=[ym].
Documentation/i386/zero-page.txt | 4 +++-
arch/i386/boot/setup.S | 21 +++++++++++++++++++++
arch/i386/kernel/edd.c | 22 +++++++++++++++++++++-
arch/i386/kernel/i386_ksyms.c | 6 ------
arch/i386/kernel/setup.c | 7 +++++++
include/asm-i386/edd.h | 6 +++++-
include/asm-i386/setup.h | 1 +
7 files changed, 58 insertions, 9 deletions
diff -Nru a/Documentation/i386/zero-page.txt b/Documentation/i386/zero-page.txt
--- a/Documentation/i386/zero-page.txt Tue Jan 20 15:49:42 2004
+++ b/Documentation/i386/zero-page.txt Tue Jan 20 15:49:42 2004
@@ -72,8 +72,10 @@
0x21c unsigned long INITRD_SIZE, size in bytes of ramdisk image
0x220 4 bytes (setup.S)
0x224 unsigned short setup.S heap end pointer
+0x2cc 4 bytes DISK80_SIG_BUFFER (setup.S)
0x2d0 - 0x600 E820MAP
-0x600 - 0x7D4 EDDBUF (setup.S)
+0x600 - 0x7ff EDDBUF (setup.S) for disk signature read sector
+0x600 - 0x7d3 EDDBUF (setup.S) for edd data
0x800 string, 2K max COMMAND_LINE, the kernel commandline as
copied using CL_OFFSET.
diff -Nru a/arch/i386/boot/setup.S b/arch/i386/boot/setup.S
--- a/arch/i386/boot/setup.S Tue Jan 20 15:49:42 2004
+++ b/arch/i386/boot/setup.S Tue Jan 20 15:49:42 2004
@@ -49,6 +49,8 @@
* by Matt Domsch <Matt_Domsch@xxxxxxxx> October 2002
* conformant to T13 Committee www.t13.org
* projects 1572D, 1484D, 1386D, 1226DT
+ * disk signature read by Matt Domsch <Matt_Domsch@xxxxxxxx>
+ * and Andrew Wilks <Andrew_Wilks@xxxxxxxx> September 2003
*/
#include <linux/config.h>
@@ -578,6 +580,25 @@
#endif
#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
+# Read the first sector of device 80h and store the 4-byte signature
+ movl $0xFFFFFFFF, %eax
+ movl %eax, (DISK80_SIG_BUFFER) # assume failure
+ movb $READ_SECTORS, %ah
+ movb $1, %al # read 1 sector
+ movb $0x80, %dl # from device 80
+ movb $0, %dh # at head 0
+ movw $1, %cx # cylinder 0, sector 0
+ pushw %es
+ pushw %ds
+ popw %es
+ movw $EDDBUF, %bx
+ int $0x13
+ jc disk_sig_done
+ movl (EDDBUF+MBR_SIG_OFFSET), %eax
+ movl %eax, (DISK80_SIG_BUFFER) # store success
+disk_sig_done:
+ popw %es
+
# Do the BIOS Enhanced Disk Drive calls
# This consists of two calls:
# int 13h ah=41h "Check Extensions Present"
diff -Nru a/arch/i386/kernel/edd.c b/arch/i386/kernel/edd.c
--- a/arch/i386/kernel/edd.c Tue Jan 20 15:49:42 2004
+++ b/arch/i386/kernel/edd.c Tue Jan 20 15:49:42 2004
@@ -2,6 +2,7 @@
* linux/arch/i386/kernel/edd.c
* Copyright (C) 2002, 2003 Dell Inc.
* by Matt Domsch <Matt_Domsch@xxxxxxxx>
+ * disk80 signature by Matt Domsch, Andrew Wilks, and Sandeep K. Shandilya
*
* BIOS Enhanced Disk Drive Services (EDD)
* conformant to T13 Committee www.t13.org
@@ -59,7 +60,7 @@
MODULE_DESCRIPTION("sysfs interface to BIOS EDD information");
MODULE_LICENSE("GPL");
-#define EDD_VERSION "0.10 2003-Oct-11"
+#define EDD_VERSION "0.11 2003-Dec-17"
#define EDD_DEVICE_NAME_SIZE 16
#define REPORT_URL "http://domsch.com/linux/edd30/results.html"
@@ -260,6 +261,14 @@
}
static ssize_t
+edd_show_disk80_sig(struct edd_device *edev, char *buf)
+{
+ char *p = buf;
+ p += snprintf(p, left, "0x%08x\n", edd_disk80_sig);
+ return (p - buf);
+}
+
+static ssize_t
edd_show_extensions(struct edd_device *edev, char *buf)
{
struct edd_info *info = edd_dev_get_info(edev);
@@ -429,6 +438,15 @@
return 1;
}
+static int
+edd_has_disk80_sig(struct edd_device *edev)
+{
+ struct edd_info *info = edd_dev_get_info(edev);
+ if (!edev || !info)
+ return 0;
+ return info->device == 0x80;
+}
+
static EDD_DEVICE_ATTR(raw_data, 0444, edd_show_raw_data, NULL);
static EDD_DEVICE_ATTR(version, 0444, edd_show_version, NULL);
static EDD_DEVICE_ATTR(extensions, 0444, edd_show_extensions, NULL);
@@ -443,6 +461,7 @@
edd_has_default_sectors_per_track);
static EDD_DEVICE_ATTR(interface, 0444, edd_show_interface, edd_has_edd30);
static EDD_DEVICE_ATTR(host_bus, 0444, edd_show_host_bus, edd_has_edd30);
+static EDD_DEVICE_ATTR(mbr_signature, 0444, edd_show_disk80_sig, edd_has_disk80_sig);
/* These are default attributes that are added for every edd
@@ -464,6 +483,7 @@
&edd_attr_default_sectors_per_track,
&edd_attr_interface,
&edd_attr_host_bus,
+ &edd_attr_mbr_signature,
NULL,
};
diff -Nru a/arch/i386/kernel/i386_ksyms.c b/arch/i386/kernel/i386_ksyms.c
--- a/arch/i386/kernel/i386_ksyms.c Tue Jan 20 15:49:42 2004
+++ b/arch/i386/kernel/i386_ksyms.c Tue Jan 20 15:49:42 2004
@@ -32,7 +32,6 @@
#include <asm/pgalloc.h>
#include <asm/tlbflush.h>
#include <asm/nmi.h>
-#include <asm/edd.h>
#include <asm/ist.h>
extern void dump_thread(struct pt_regs *, struct user *);
@@ -201,11 +200,6 @@
EXPORT_SYMBOL(kmap_atomic);
EXPORT_SYMBOL(kunmap_atomic);
EXPORT_SYMBOL(kmap_atomic_to_page);
-#endif
-
-#ifdef CONFIG_EDD_MODULE
-EXPORT_SYMBOL(edd);
-EXPORT_SYMBOL(eddnr);
#endif
#if defined(CONFIG_X86_SPEEDSTEP_SMI) || defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE)
diff -Nru a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
--- a/arch/i386/kernel/setup.c Tue Jan 20 15:49:42 2004
+++ b/arch/i386/kernel/setup.c Tue Jan 20 15:49:42 2004
@@ -447,6 +447,12 @@
#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
unsigned char eddnr;
struct edd_info edd[EDDMAXNR];
+unsigned int edd_disk80_sig;
+#ifdef CONFIG_EDD_MODULE
+EXPORT_SYMBOL(eddnr);
+EXPORT_SYMBOL(edd);
+EXPORT_SYMBOL(edd_disk80_sig);
+#endif
/**
* copy_edd() - Copy the BIOS EDD information
* from empty_zero_page into a safe place.
@@ -456,6 +462,7 @@
{
eddnr = EDD_NR;
memcpy(edd, EDD_BUF, sizeof(edd));
+ edd_disk80_sig = DISK80_SIGNATURE;
}
#else
#define copy_edd() do {} while (0)
diff -Nru a/include/asm-i386/edd.h b/include/asm-i386/edd.h
--- a/include/asm-i386/edd.h Tue Jan 20 15:49:42 2004
+++ b/include/asm-i386/edd.h Tue Jan 20 15:49:42 2004
@@ -1,6 +1,6 @@
/*
* linux/include/asm-i386/edd.h
- * Copyright (C) 2002 Dell Inc.
+ * Copyright (C) 2002, 2003 Dell Inc.
* by Matt Domsch <Matt_Domsch@xxxxxxxx>
*
* structures and definitions for the int 13h, ax={41,48}h
@@ -41,6 +41,9 @@
#define EDDMAGIC1 0x55AA
#define EDDMAGIC2 0xAA55
+#define READ_SECTORS 0x02
+#define MBR_SIG_OFFSET 0x1B8
+#define DISK80_SIG_BUFFER 0x2cc
#ifndef __ASSEMBLY__
#define EDD_EXT_FIXED_DISK_ACCESS (1 << 0)
@@ -167,6 +170,7 @@
extern struct edd_info edd[EDDMAXNR];
extern unsigned char eddnr;
+extern unsigned int edd_disk80_sig;
#endif /*!__ASSEMBLY__ */
#endif /* _ASM_I386_EDD_H */
diff -Nru a/include/asm-i386/setup.h b/include/asm-i386/setup.h
--- a/include/asm-i386/setup.h Tue Jan 20 15:49:42 2004
+++ b/include/asm-i386/setup.h Tue Jan 20 15:49:42 2004
@@ -44,6 +44,7 @@
#define INITRD_START (*(unsigned long *) (PARAM+0x218))
#define INITRD_SIZE (*(unsigned long *) (PARAM+0x21c))
#define EDID_INFO (*(struct edid_info *) (PARAM+0x440))
+#define DISK80_SIGNATURE (*(unsigned int*) (PARAM+DISK80_SIG_BUFFER))
#define EDD_NR (*(unsigned char *) (PARAM+EDDNR))
#define EDD_BUF ((struct edd_info *) (PARAM+EDDBUF))
#define COMMAND_LINE ((char *) (PARAM+2048))
===================================================================
This BitKeeper patch contains the following changesets:
1.1505
## Wrapped with gzip_uu ##
M'XL( ':B#4 [59:U?;2!+];/V*FC"S8Q(_NO4V,^0$L)GUR0,.)K.[)\GQ
M:4LMK$$/CUH&G/7^]ZUNR48V$(,3''#L?EQ5W[Y57=7LP$?!L[W:>Y;GPVX:
M"V^L[< _4Y'OU7P>12TOC;'A+$VQH3U.8]Z.?36L/;IL<]]O1V$RO6GJ+:N)
MWYI!FC5EB]!PUBG+O3%<\4SLU6C+6+;DLPG?JYWU_OCX[N!,T_;WX6C,D@L^
MX#GL[VMYFEVQR!=O6#Z.TJ259RP1,<^9-&:^'#K7"='QGT4=@UCVG-K$=.8>
M]2EE)N4^T4W7-F_1I/&M5/A1*\TN5F%,0O'=,3J6.;<LLT.U+M 6M8@%Q&P3
MVM8)4&O/M/8,NTGL/4*@0MB;!5&?2FJ^P"L'FD0[A!^[E"/-@UZWNP<99S[X
MH;ATT9##,Q#A1<+R:<8;P&\F:99#/L[2Z<48<$\@3OUIQ'$N_IR/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xxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/