FreeBSD Bugzilla – Attachment 246762 Details for
Bug 273814
sysutils/grub2-bhyve: fails to boot OpenBSD Current kernel
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
grub2-bhyve.patch.2
grub2-bhyve.patch (text/plain), 11.21 KB, created by
Yuichiro NAITO
on 2023-12-04 07:23:44 UTC
(
hide
)
Description:
grub2-bhyve.patch.2
Filename:
MIME Type:
Creator:
Yuichiro NAITO
Created:
2023-12-04 07:23:44 UTC
Size:
11.21 KB
patch
obsolete
>diff --git a/sysutils/grub2-bhyve/Makefile b/sysutils/grub2-bhyve/Makefile >index b220b10b1273..4433c6c055f6 100644 >--- a/sysutils/grub2-bhyve/Makefile >+++ b/sysutils/grub2-bhyve/Makefile >@@ -1,7 +1,7 @@ > PORTNAME= grub2-bhyve > DISTVERSIONPREFIX= v > DISTVERSION= 0.40 >-PORTREVISION= 10 >+PORTREVISION= 11 > CATEGORIES= sysutils > > PATCH_SITES+= https://github.com/grehan-freebsd/grub2-bhyve/commit/ >diff --git a/sysutils/grub2-bhyve/files/patch-grub-core_loader_i386_bsd.c b/sysutils/grub2-bhyve/files/patch-grub-core_loader_i386_bsd.c >new file mode 100644 >index 000000000000..73d3c15cc779 >--- /dev/null >+++ b/sysutils/grub2-bhyve/files/patch-grub-core_loader_i386_bsd.c >@@ -0,0 +1,71 @@ >+--- grub-core/loader/i386/bsd.c.orig 2015-08-31 22:42:56 UTC >++++ grub-core/loader/i386/bsd.c >+@@ -74,6 +74,7 @@ static struct grub_openbsd_ramdisk_descriptor openbsd_ >+ static grub_uint32_t openbsd_root; >+ static struct grub_relocator *relocator = NULL; >+ static struct grub_openbsd_ramdisk_descriptor openbsd_ramdisk; >++static grub_int32_t openbsd_force_legacy_console = 0; >+ >+ struct bsd_tag >+ { >+@@ -132,6 +133,7 @@ static const struct grub_arg_option openbsd_opts[] = >+ {"config", 'c', 0, N_("Change configured devices."), 0, 0}, >+ {"single", 's', 0, N_("Boot into single mode."), 0, 0}, >+ {"kdb", 'd', 0, N_("Enter in KDB on boot."), 0, 0}, >++ {"legacy", 'l', 0, N_("Use legacy boot structure."), 0, 0}, >+ {"root", 'r', 0, N_("Set root device."), "[sd|wd]XY", ARG_TYPE_STRING}, >+ {"serial", 'h', GRUB_ARG_OPTION_OPTIONAL, >+ N_("Use serial console."), >+@@ -145,7 +147,7 @@ static const grub_uint32_t openbsd_flags[] = >+ static const grub_uint32_t openbsd_flags[] = >+ { >+ OPENBSD_RB_ASKNAME, OPENBSD_RB_HALT, OPENBSD_RB_CONFIG, >+- OPENBSD_RB_SINGLE, OPENBSD_RB_KDB, 0 >++ OPENBSD_RB_SINGLE, OPENBSD_RB_KDB, OPENBSD_RB_LEGACY, 0 >+ }; >+ >+ #define OPENBSD_ROOT_ARG (ARRAY_SIZE (openbsd_flags) - 1) >+@@ -811,6 +813,25 @@ grub_openbsd_boot (void) >+ grub_err_t err; >+ grub_size_t tag_buf_len; >+ >++ if (openbsd_force_legacy_console || ! is_64bit || >++ (openbsd_ramdisk.osrelease < 7003 && openbsd_ramdisk.osrelease > 0)) >++ { >++ struct bsd_tag *tag; >++ for (tag = tags; tag; tag = tag->next) >++ if (tag->type == OPENBSD_BOOTARG_CONSOLE) >++ { >++ struct grub_openbsd_bootarg_console *s = >++ (struct grub_openbsd_bootarg_console *) tag -> data; >++ struct grub_openbsd_bootarg_console_legacy l_serial; >++ grub_memset (&l_serial, 0, sizeof (l_serial)); >++ l_serial.device = s -> device; >++ l_serial.speed = s -> speed; >++ l_serial.addr = -1; >++ grub_memcpy(tag -> data, &l_serial, sizeof(l_serial)); >++ tag -> len = sizeof(l_serial); >++ } >++ } >++ >+ err = grub_bsd_add_mmap (); >+ if (err) >+ return err; >+@@ -1644,6 +1665,9 @@ grub_cmd_openbsd (grub_extcmd_context_t ctxt, int argc >+ else >+ bootdev = 0; >+ >++ openbsd_force_legacy_console = bootflags & OPENBSD_RB_LEGACY; >++ bootflags &= ~OPENBSD_RB_LEGACY; >++ >+ if (ctxt->state[OPENBSD_SERIAL_ARG].set) >+ { >+ struct grub_openbsd_bootarg_console serial; >+@@ -1686,6 +1710,7 @@ grub_cmd_openbsd (grub_extcmd_context_t ctxt, int argc >+ struct grub_openbsd_bootarg_console serial; >+ >+ grub_memset (&serial, 0, sizeof (serial)); >++ >+ serial.device = (GRUB_OPENBSD_VGA_MAJOR << 8); >+ grub_bsd_add_meta (OPENBSD_BOOTARG_CONSOLE, &serial, sizeof (serial)); >+ bootflags &= ~OPENBSD_RB_SERCONS; >diff --git a/sysutils/grub2-bhyve/files/patch-grub-core_loader_i386_bsdXX.c b/sysutils/grub2-bhyve/files/patch-grub-core_loader_i386_bsdXX.c >new file mode 100644 >index 000000000000..abd9edd85563 >--- /dev/null >+++ b/sysutils/grub2-bhyve/files/patch-grub-core_loader_i386_bsdXX.c >@@ -0,0 +1,170 @@ >+--- grub-core/loader/i386/bsdXX.c.orig 2015-08-31 22:42:56 UTC >++++ grub-core/loader/i386/bsdXX.c >+@@ -521,17 +521,68 @@ SUFFIX(grub_openbsd_find_ramdisk) (grub_file_t file, >+ struct grub_openbsd_ramdisk_descriptor *desc) >+ { >+ unsigned symoff, stroff, symsize, strsize, symentsize; >++ Elf_Shdr *rodata; >++ char *shdr = NULL; >+ >+ { >+ grub_err_t err; >+ Elf_Ehdr e; >+- Elf_Shdr *s; >+- char *shdr = NULL; >++ Elf_Shdr *s, *strtab; >++ char *strarr; >+ >+ err = read_headers (file, filename, &e, &shdr); >+ if (err) >+ return err; >+ >++ for (s = (Elf_Shdr *) shdr; >++ s < (Elf_Shdr *) (shdr + e.e_shnum * e.e_shentsize); >++ s = (Elf_Shdr *) ((char *) s + e.e_shentsize)) >++ if (s->sh_type == SHT_STRTAB) >++ break; >++ if (s >= (Elf_Shdr *) ((char *) shdr + e.e_shnum * e.e_shentsize)) >++ { >++ grub_free (shdr); >++ return GRUB_ERR_NONE; >++ } >++ strtab = s; >++ >++ strarr = grub_malloc (strtab->sh_size); >++ if (!strarr) >++ { >++ grub_free (shdr); >++ return grub_errno; >++ } >++ >++ if (grub_file_seek (file, strtab->sh_offset) == (grub_off_t) -1) >++ { >++ grub_free (strarr); >++ grub_free (shdr); >++ return grub_errno; >++ } >++ if (grub_file_read (file, strarr, strtab->sh_size) != (grub_ssize_t) strtab->sh_size) >++ { >++ grub_free (strarr); >++ grub_free (shdr); >++ if (! grub_errno) >++ return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), >++ filename); >++ return grub_errno; >++ } >++ >++ for (s = (Elf_Shdr *) shdr; >++ s < (Elf_Shdr *) (shdr + e.e_shnum * e.e_shentsize); >++ s = (Elf_Shdr *) ((char *) s + e.e_shentsize)) >++ if (s->sh_type == SHT_PROGBITS && >++ grub_strcmp(&strarr[s->sh_name], ".rodata") == 0) >++ break; >++ grub_free (strarr); >++ if (s >= (Elf_Shdr *) ((char *) shdr + e.e_shnum * e.e_shentsize)) >++ { >++ grub_free (shdr); >++ return GRUB_ERR_NONE; >++ } >++ rodata = s; >++ >+ for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) (shdr >+ + e.e_shnum * e.e_shentsize); >+ s = (Elf_Shdr *) ((char *) s + e.e_shentsize)) >+@@ -550,24 +601,26 @@ SUFFIX(grub_openbsd_find_ramdisk) (grub_file_t file, >+ s = (Elf_Shdr *) (shdr + e.e_shentsize * s->sh_link); >+ stroff = s->sh_offset; >+ strsize = s->sh_size; >+- grub_free (shdr); >+ } >+ { >+- Elf_Sym *syms, *sym, *imagesym = NULL, *sizesym = NULL; >++ Elf_Sym *syms, *sym, *imagesym = NULL, *sizesym = NULL, *osrelsym = NULL; >+ unsigned i; >+ char *strs; >+ >+ syms = grub_malloc (symsize); >+- if (!syms) >++ if (!syms) { >++ grub_free (shdr); >+ return grub_errno; >+- >++ } >+ if (grub_file_seek (file, symoff) == (grub_off_t) -1) >+ { >++ grub_free (shdr); >+ grub_free (syms); >+ return grub_errno; >+ } >+ if (grub_file_read (file, syms, symsize) != (grub_ssize_t) symsize) >+ { >++ grub_free (shdr); >+ grub_free (syms); >+ if (! grub_errno) >+ return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), >+@@ -578,6 +631,7 @@ SUFFIX(grub_openbsd_find_ramdisk) (grub_file_t file, >+ strs = grub_malloc (strsize); >+ if (!strs) >+ { >++ grub_free (shdr); >+ grub_free (syms); >+ return grub_errno; >+ } >+@@ -586,6 +640,7 @@ SUFFIX(grub_openbsd_find_ramdisk) (grub_file_t file, >+ return grub_errno; >+ if (grub_file_read (file, strs, strsize) != (grub_ssize_t) strsize) >+ { >++ grub_free (shdr); >+ grub_free (syms); >+ grub_free (strs); >+ if (! grub_errno) >+@@ -605,9 +660,48 @@ SUFFIX(grub_openbsd_find_ramdisk) (grub_file_t file, >+ imagesym = sym; >+ if (grub_strcmp (strs + sym->st_name, "rd_root_size") == 0) >+ sizesym = sym; >+- if (imagesym && sizesym) >++ if (grub_strcmp (strs + sym->st_name, "osrelease") == 0) >++ osrelsym = sym; >++ if (imagesym && sizesym && osrelsym) >+ break; >+ } >++ if (osrelsym) { >++ char *p; >++ int major, minor; >++ grub_size_t sz; >++ char osrel[16]; >++ stroff = ((osrelsym->st_value - rodata->sh_addr) + rodata->sh_offset); >++ if (grub_file_seek (file, stroff) == (grub_off_t) -1) { >++ grub_free (shdr); >++ grub_free (syms); >++ grub_free (strs); >++ return grub_errno; >++ } >++ sz = sizeof(osrel) < osrelsym->st_size ? sizeof(osrel) : osrelsym->st_size; >++ if (grub_file_read (file, osrel, sz) != (grub_ssize_t) sz) { >++ grub_free (shdr); >++ grub_free (syms); >++ grub_free (strs); >++ return grub_errno; >++ } >++ osrel[sz - 1] = '\0'; >++ major = minor = 0; >++ for (p = osrel; *p != '\0'; p++) >++ if (*p >= '0' && *p <= '9') >++ major = major * 10 + *p - '0'; >++ else >++ break; >++ if (*p == '.') >++ p++; >++ for (; *p != '\0'; p++) >++ if (*p >= '0' && *p <= '9') >++ minor = minor * 10 + *p - '0'; >++ else >++ break; >++ desc->osrelease = major * 1000 + minor; >++ grub_free (shdr); >++ } >++ >+ if (!imagesym || !sizesym) >+ { >+ grub_free (syms); >diff --git a/sysutils/grub2-bhyve/files/patch-include_grub_i386_bsd.h b/sysutils/grub2-bhyve/files/patch-include_grub_i386_bsd.h >new file mode 100644 >index 000000000000..7279bcac3fa0 >--- /dev/null >+++ b/sysutils/grub2-bhyve/files/patch-include_grub_i386_bsd.h >@@ -0,0 +1,10 @@ >+--- include/grub/i386/bsd.h.orig 2015-08-31 22:42:56 UTC >++++ include/grub/i386/bsd.h >+@@ -108,6 +108,7 @@ struct grub_openbsd_ramdisk_descriptor >+ grub_size_t max_size; >+ grub_uint8_t *target; >+ grub_uint32_t *size; >++ grub_uint32_t osrelease; >+ }; >+ >+ grub_err_t grub_openbsd_find_ramdisk32 (grub_file_t file, >diff --git a/sysutils/grub2-bhyve/files/patch-include_grub_i386_openbsd__bootarg.h b/sysutils/grub2-bhyve/files/patch-include_grub_i386_openbsd__bootarg.h >new file mode 100644 >index 000000000000..850faf5d19ac >--- /dev/null >+++ b/sysutils/grub2-bhyve/files/patch-include_grub_i386_openbsd__bootarg.h >@@ -0,0 +1,35 @@ >+--- include/grub/i386/openbsd_bootarg.h.orig 2015-08-31 22:42:56 UTC >++++ include/grub/i386/openbsd_bootarg.h >+@@ -63,6 +63,7 @@ >+ #define OPENBSD_BOOTARG_MMAP 0 >+ #define OPENBSD_BOOTARG_PCIBIOS 4 >+ #define OPENBSD_BOOTARG_CONSOLE 5 >++#define OPENBSD_BOOTARG_CONSOLE_LEGACY 6 >+ >+ struct grub_openbsd_bootargs >+ { >+@@ -71,12 +72,23 @@ struct grub_openbsd_bootargs >+ grub_uint32_t ba_next; >+ } __attribute__ ((packed)); >+ >+-struct grub_openbsd_bootarg_console >++struct grub_openbsd_bootarg_console_legacy >+ { >+ grub_uint32_t device; >+ grub_uint32_t speed; >+ grub_int32_t addr; >+ grub_uint32_t freq; >++}; >++ >++struct grub_openbsd_bootarg_console >++{ >++ grub_uint32_t device; >++ grub_uint32_t speed; >++ grub_uint64_t addr; >++ grub_int32_t freq; >++ grub_uint32_t flags; >++ grub_int32_t reg_width; >++ grub_int32_t reg_shift; >+ }; >+ >+ struct grub_openbsd_bootarg_pcibios >diff --git a/sysutils/grub2-bhyve/files/patch-include_grub_i386_openbsd__reboot.h b/sysutils/grub2-bhyve/files/patch-include_grub_i386_openbsd__reboot.h >new file mode 100644 >index 000000000000..03bc0b29edbe >--- /dev/null >+++ b/sysutils/grub2-bhyve/files/patch-include_grub_i386_openbsd__reboot.h >@@ -0,0 +1,10 @@ >+--- include/grub/i386/openbsd_reboot.h.orig 2015-08-31 22:42:56 UTC >++++ include/grub/i386/openbsd_reboot.h >+@@ -68,6 +68,7 @@ >+ #define OPENBSD_RB_POWERDOWN (1 << 12) /* attempt to power down machine */ >+ #define OPENBSD_RB_SERCONS (1 << 13) /* use serial console if available */ >+ #define OPENBSD_RB_USERREQ (1 << 14) /* boot() called at user request (e.g. ddb) */ >++#define OPENBSD_RB_LEGACY (1 << 31) /* Use legacy serial console structure */ >+ >+ #define OPENBSD_B_DEVMAGIC 0xa0000000 >+ #define OPENBSD_B_ADAPTORSHIFT 24
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 273814
:
244872
|
246762
|
247472