summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/boot/installgrub/installgrub.c25
-rw-r--r--usr/src/cmd/boot/installgrub/installgrub.h6
-rw-r--r--usr/src/grub/capability2
3 files changed, 25 insertions, 8 deletions
diff --git a/usr/src/cmd/boot/installgrub/installgrub.c b/usr/src/cmd/boot/installgrub/installgrub.c
index 4d29d0236e..694193d9c7 100644
--- a/usr/src/cmd/boot/installgrub/installgrub.c
+++ b/usr/src/cmd/boot/installgrub/installgrub.c
@@ -672,16 +672,18 @@ init_device(ig_device_t *device, char *path)
if (get_raw_partition_fd(device) != BC_SUCCESS)
return (BC_ERROR);
- if (fstyp_init(device->part_fd, 0, NULL, &fhdl) != 0)
- return (BC_ERROR);
+ if (is_efi(device->type)) {
+ if (fstyp_init(device->part_fd, 0, NULL, &fhdl) != 0)
+ return (BC_ERROR);
- if (fstyp_ident(fhdl, "zfs", &fident) != 0) {
+ if (fstyp_ident(fhdl, "zfs", &fident) != 0) {
+ fstyp_fini(fhdl);
+ (void) fprintf(stderr, gettext("Booting of EFI labeled "
+ "disks is only supported with ZFS\n"));
+ return (BC_ERROR);
+ }
fstyp_fini(fhdl);
- (void) fprintf(stderr, gettext("Booting of EFI labeled disks "
- "is only supported with ZFS\n"));
- return (BC_ERROR);
}
- fstyp_fini(fhdl);
if (get_start_sector(device) != BC_SUCCESS)
return (BC_ERROR);
@@ -998,7 +1000,16 @@ write_stage2(ig_data_t *install)
* For disk, write stage2 starting at STAGE2_BLKOFF sector.
* Note that we use stage2->buf rather than stage2->file, because we
* may have extended information after the latter.
+ *
+ * If we're writing to an EFI-labeled disk where stage2 lives in the
+ * 3.5MB boot loader gap following the ZFS vdev labels, make sure the
+ * size of the buffer doesn't exceed the size of the gap.
*/
+ if (is_efi(device->type) && stage2->buf_size > STAGE2_MAXSIZE) {
+ (void) fprintf(stderr, WRITE_FAIL_STAGE2);
+ return (BC_ERROR);
+ }
+
offset = STAGE2_BLKOFF(device->type) * SECTOR_SIZE;
if (write_out(device->part_fd, stage2->buf, stage2->buf_size,
diff --git a/usr/src/cmd/boot/installgrub/installgrub.h b/usr/src/cmd/boot/installgrub/installgrub.h
index 037ffad4ce..cf3f4f5a92 100644
--- a/usr/src/cmd/boot/installgrub/installgrub.h
+++ b/usr/src/cmd/boot/installgrub/installgrub.h
@@ -91,6 +91,12 @@ enum ig_devtype_t {
#define STAGE2_BLKOFF(type) \
(is_efi(type) ? 1024 : 50) /* offset from start of part */
+/*
+ * Maximum size of stage2 on EFI-labeled disks. Must not be larger than
+ * VDEV_BOOT_SIZE, defined in usr/src/uts/common/fs/zfs/sys/vdev_impl.h
+ */
+#define STAGE2_MAXSIZE (1ULL << 19)
+
#ifdef __cplusplus
}
#endif
diff --git a/usr/src/grub/capability b/usr/src/grub/capability
index e0f25f1275..111cd61ccb 100644
--- a/usr/src/grub/capability
+++ b/usr/src/grub/capability
@@ -29,7 +29,7 @@
# GRUB necessitating that the boot blocks be reinstalled for that fix or
# enhancement to take effect.
#
-VERSION=24
+VERSION=25
dboot
xVM
zfs