summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2016-05-16 11:23:59 +0300
committerDan McDonald <danmcd@joyent.com>2018-03-23 10:45:04 -0400
commit23274804946ea79b54ae682df4d33bbbb30b42ee (patch)
tree968620937ac92e378af237a48a39865d648e9610
parentb6bf6e1540f30bd97b8d6e2c21d95e17841e0f23 (diff)
downloadillumos-joyent-23274804946ea79b54ae682df4d33bbbb30b42ee.tar.gz
8758 loader: boot1.efi needs versioning
Reviewed by: Robert Mustacchi <rm@joyent.com> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/boot/sys/boot/common/multiboot.S (renamed from usr/src/boot/sys/boot/i386/gptzfsboot/multiboot.S)10
-rw-r--r--usr/src/boot/sys/boot/efi/boot1/Makefile10
-rw-r--r--usr/src/boot/sys/boot/efi/boot1/boot1.c23
-rw-r--r--usr/src/boot/sys/boot/i386/gptzfsboot/Makefile4
-rw-r--r--usr/src/boot/sys/boot/i386/gptzfsboot/zfsboot.c2
-rw-r--r--usr/src/boot/sys/boot/i386/libi386/multiboot.c2
-rw-r--r--usr/src/boot/sys/sys/multiboot.h (renamed from usr/src/boot/sys/boot/i386/libi386/multiboot.h)0
7 files changed, 41 insertions, 10 deletions
diff --git a/usr/src/boot/sys/boot/i386/gptzfsboot/multiboot.S b/usr/src/boot/sys/boot/common/multiboot.S
index 55a190e411..391ccd76c3 100644
--- a/usr/src/boot/sys/boot/i386/gptzfsboot/multiboot.S
+++ b/usr/src/boot/sys/boot/common/multiboot.S
@@ -10,18 +10,22 @@
*/
/*
- * Copyright 2015 Toomas Soome <tsoome@me.com>
+ * Copyright 2018 Toomas Soome <tsoome@me.com>
*/
.file "multiboot.s"
/*
* Provide fake multiboot header to support versioning and partition
- * start.
+ * start. The fake MB header is used by versioning code located in
+ * usr/src/cmd/boot/common. Since the BIOS bootblock is stored on raw disk,
+ * this fake header is used to store the location of the version info block.
+ * Additionally we use it to store partition start_sector, so we can identify
+ * our root file system partition. Note we are using LBA64 here.
*/
#define ASM_FILE
-#include <multiboot.h>
+#include <sys/multiboot.h>
.globl mb_header, start_sector
.text
diff --git a/usr/src/boot/sys/boot/efi/boot1/Makefile b/usr/src/boot/sys/boot/efi/boot1/Makefile
index 49960d53c2..aee4ba24fb 100644
--- a/usr/src/boot/sys/boot/efi/boot1/Makefile
+++ b/usr/src/boot/sys/boot/efi/boot1/Makefile
@@ -26,8 +26,10 @@ PROG= boot1.sym
MACHINE=$(MACH64)
# architecture-specific loader code
-SRCS= boot1.c self_reloc.c start.S ufs_module.c zfs_module.c devopen.c
-OBJS= boot1.o self_reloc.o start.o ufs_module.o zfs_module.o devopen.o
+SRCS= multiboot.S boot1.c self_reloc.c start.S ufs_module.c zfs_module.c \
+ devopen.c
+OBJS= multiboot.o boot1.o self_reloc.o start.o ufs_module.o zfs_module.o \
+ devopen.o
ASFLAGS=-m64 -fPIC
CFLAGS= -O2
@@ -91,6 +93,7 @@ boot1.efi: ${PROG}
-j .dynamic -j .dynsym -j .rel.dyn \
-j .rela.dyn -j .reloc -j .eh_frame \
--output-target=${EFI_TARGET} --subsystem efi-app ${PROG} $@
+ $(BTXLD) -V ${BOOT_VERSION} -o $@ $@
boot1.o: ./../../common/ufsread.c
@@ -120,6 +123,9 @@ clean clobber:
%.o: ../loader/%.c
$(COMPILE.c) $<
+%.o: ../../common/%.S
+ $(COMPILE.S) $<
+
%.o: ../../common/%.c
$(COMPILE.c) $<
diff --git a/usr/src/boot/sys/boot/efi/boot1/boot1.c b/usr/src/boot/sys/boot/efi/boot1/boot1.c
index 98fd3b00ff..9c3e11263f 100644
--- a/usr/src/boot/sys/boot/efi/boot1/boot1.c
+++ b/usr/src/boot/sys/boot/efi/boot1/boot1.c
@@ -456,9 +456,11 @@ static EFI_STATUS
probe_handle(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath, BOOLEAN *preferred)
{
dev_info_t *devinfo;
- EFI_BLOCK_IO *blkio;
- EFI_DEVICE_PATH *devpath;
+ EFI_BLOCK_IO *blkio = NULL;
+ EFI_DEVICE_PATH *devpath, *dp;
+ HARDDRIVE_DEVICE_PATH *hd;
EFI_STATUS status;
+ extern UINT64 start_sector; /* from multiboot.S */
UINTN i;
/* Figure out if we're dealing with an actual partition. */
@@ -489,6 +491,23 @@ probe_handle(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath, BOOLEAN *preferred)
*preferred = device_paths_match(imgpath, devpath);
+ /*
+ * This is the boot device. Check for the start of the partition.
+ * If it does not match what is specified in the stage1 loader then
+ * this is not our preferred device.
+ */
+ if (*preferred == TRUE && start_sector != 0) {
+ dp = devpath_last(devpath);
+
+ if (dp != NULL &&
+ dp->Type == MEDIA_DEVICE_PATH &&
+ dp->SubType == MEDIA_HARDDRIVE_DP) {
+ hd = (HARDDRIVE_DEVICE_PATH *)dp;
+ if (hd->PartitionStart != start_sector)
+ *preferred = FALSE;
+ }
+ }
+
/* Run through each module, see if it can load this partition */
for (i = 0; i < NUM_BOOT_MODULES; i++) {
if ((status = BS->AllocatePool(EfiLoaderData,
diff --git a/usr/src/boot/sys/boot/i386/gptzfsboot/Makefile b/usr/src/boot/sys/boot/i386/gptzfsboot/Makefile
index f492bf20fd..0a8793a0d8 100644
--- a/usr/src/boot/sys/boot/i386/gptzfsboot/Makefile
+++ b/usr/src/boot/sys/boot/i386/gptzfsboot/Makefile
@@ -52,7 +52,6 @@ CFLAGS= -nostdinc -DBOOTPROG=\"gptzfsboot\" \
-I../../../cddl/boot/zfs \
-I../btx/lib -I. \
-I../../.. \
- -I../../../sys \
-I../libi386 \
-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
@@ -135,6 +134,9 @@ devicename.o: ../libi386/devicename.c
time.o: ../libi386/time.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ ../libi386/$*.c
+multiboot.o: ../../common/multiboot.S
+ $(CC) $(CFLAGS) $(CCASFLAGS) -c -o $@ ../../common/$*.S
+
.S.o:
$(CC) $(CFLAGS) $(CCASFLAGS) -c -o $@ $<
diff --git a/usr/src/boot/sys/boot/i386/gptzfsboot/zfsboot.c b/usr/src/boot/sys/boot/i386/gptzfsboot/zfsboot.c
index cc161b564e..623114d1ae 100644
--- a/usr/src/boot/sys/boot/i386/gptzfsboot/zfsboot.c
+++ b/usr/src/boot/sys/boot/i386/gptzfsboot/zfsboot.c
@@ -23,7 +23,7 @@
#include <sys/disk.h>
#include <sys/reboot.h>
#include <sys/queue.h>
-#include <multiboot.h>
+#include <sys/multiboot.h>
#include <machine/bootinfo.h>
#include <machine/elf.h>
diff --git a/usr/src/boot/sys/boot/i386/libi386/multiboot.c b/usr/src/boot/sys/boot/i386/libi386/multiboot.c
index f169f73902..3ab8905352 100644
--- a/usr/src/boot/sys/boot/i386/libi386/multiboot.c
+++ b/usr/src/boot/sys/boot/i386/libi386/multiboot.c
@@ -49,7 +49,7 @@
#include <stand.h>
#include "bootstrap.h"
-#include "multiboot.h"
+#include <sys/multiboot.h>
#include "../zfs/libzfs.h"
#include "../i386/libi386/libi386.h"
#include "../i386/btx/lib/btxv86.h"
diff --git a/usr/src/boot/sys/boot/i386/libi386/multiboot.h b/usr/src/boot/sys/sys/multiboot.h
index 819fa2e501..819fa2e501 100644
--- a/usr/src/boot/sys/boot/i386/libi386/multiboot.h
+++ b/usr/src/boot/sys/sys/multiboot.h