summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2010-12-07 00:30:40 +0000
committerdlg <dlg@openbsd.org>2010-12-07 00:30:40 +0000
commitcd8cadc5349bef20db31ec1490fb83c6ef9c6713 (patch)
treebb16351e79c1d1b69816086c47a7bf1d1d01dd73
parentComplete the merge of bsd.lv version 1.10.7: (diff)
downloadwireguard-openbsd-cd8cadc5349bef20db31ec1490fb83c6ef9c6713.tar.xz
wireguard-openbsd-cd8cadc5349bef20db31ec1490fb83c6ef9c6713.zip
the boot loader passes a variable that identifies the disk its
booting off made up of a bunch of fields like adapter, controller, disk, and partition offsets, plus a table of all the disks it can see which includes this id and a checksum. the kernel goes through and checksums the disks and then maps that back to the id associated with that disk, and then compares some of the fields in those ids against the boot disks id to figure out which disk its on. the problem is we overflow one of those fields (the disk id one). since the other fields are set to 0 by the boot loader, this doesnt really matter that much. however, since those fields are now significant because of the overflow, we should compare them too. this prevents sd16 being matched as the boot disk after sd0 on my system with 25 disks attached. ok krw@ weingart@
-rw-r--r--sys/arch/amd64/amd64/dkcsum.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/sys/arch/amd64/amd64/dkcsum.c b/sys/arch/amd64/amd64/dkcsum.c
index 41f7fdb9ded..0475b483abb 100644
--- a/sys/arch/amd64/amd64/dkcsum.c
+++ b/sys/arch/amd64/amd64/dkcsum.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dkcsum.c,v 1.15 2008/12/10 23:41:19 krw Exp $ */
+/* $OpenBSD: dkcsum.c,v 1.16 2010/12/07 00:30:40 dlg Exp $ */
/*-
* Copyright (c) 1997 Niklas Hallqvist. All rights reserved.
@@ -71,10 +71,13 @@ dkcsumattach(void)
#ifdef DEBUG
printf("dkcsum: bootdev=%#x\n", bootdev);
- for (bdi = bios_diskinfo; bdi->bios_number != -1; bdi++)
- if (bdi->bios_number & 0x80)
- printf("dkcsum: BIOS drive %#x checksum is %#x\n",
- bdi->bios_number, bdi->checksum);
+ for (bdi = bios_diskinfo; bdi->bios_number != -1; bdi++) {
+ if (bdi->bios_number & 0x80) {
+ printf("dkcsum: BIOS drive %#x bsd_dev=%#x "
+ "checksum=%#x\n", bdi->bios_number, bdi->bsd_dev,
+ bdi->checksum);
+ }
+ }
#endif
pribootdev = altbootdev = 0;
@@ -180,7 +183,9 @@ dkcsumattach(void)
*/
/* B_TYPE dependent hd unit counting bootblocks */
- if ((B_TYPE(bootdev) == B_TYPE(hit->bsd_dev)) &&
+ if ((B_ADAPTOR(bootdev) == B_ADAPTOR(hit->bsd_dev)) &&
+ (B_CONTROLLER(bootdev) == B_CONTROLLER(hit->bsd_dev)) &&
+ (B_TYPE(bootdev) == B_TYPE(hit->bsd_dev)) &&
(B_UNIT(bootdev) == B_UNIT(hit->bsd_dev))) {
int type, ctrl, adap, part, unit;