All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Serbinenko <phcoder@gmail.com>
To: grub-devel@gnu.org
Cc: Vladimir Serbinenko <phcoder@gmail.com>
Subject: [PATCH v2 3/4] Do NULL memory quirk workaround only when explicitly requested
Date: Fri, 17 May 2024 10:45:39 +0300	[thread overview]
Message-ID: <20240517074540.2576-3-phcoder@gmail.com> (raw)
In-Reply-To: <20240517074540.2576-1-phcoder@gmail.com>

It's only needed for DragonFlyBSD and breaks OpenBSD bsd.mp variant

Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
---
 grub-core/loader/i386/bsd.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c
index 58b976861..af2b7cb9a 100644
--- a/grub-core/loader/i386/bsd.c
+++ b/grub-core/loader/i386/bsd.c
@@ -71,6 +71,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
 #define ALIGN_PAGE(a)	ALIGN_UP (a, 4096)
 
 static int kernel_type = KERNEL_TYPE_NONE;
+static int do_null_quirk;
 static grub_dl_t my_mod;
 static grub_addr_t entry, entry_hi, kern_start, kern_end;
 static void *kern_chunk_src;
@@ -123,16 +124,19 @@ static const struct grub_arg_option freebsd_opts[] =
     {"dfltroot", 'r', 0, N_("Use compiled-in root device."), 0, 0},
     {"single", 's', 0, N_("Boot into single mode."), 0, 0},
     {"verbose", 'v', 0, N_("Boot with verbose messages."), 0, 0},
+    {"null-quirk", 0, 0, N_("Workaround NULL bug that prevents DragonFlyBSD to boot with coreboot"), 0, 0},
     {0, 0, 0, 0, 0, 0}
   };
 
+#define FREEBSD_NULL_QUIRK_FLAG 14
+
 static const grub_uint32_t freebsd_flags[] =
 {
   FREEBSD_RB_DUAL, FREEBSD_RB_SERIAL, FREEBSD_RB_ASKNAME,
   FREEBSD_RB_CDROM, FREEBSD_RB_CONFIG, FREEBSD_RB_KDB,
   FREEBSD_RB_GDB, FREEBSD_RB_MUTE, FREEBSD_RB_NOINTR,
   FREEBSD_RB_PAUSE, FREEBSD_RB_QUIET, FREEBSD_RB_DFLTROOT,
-  FREEBSD_RB_SINGLE, FREEBSD_RB_VERBOSE, 0
+  FREEBSD_RB_SINGLE, FREEBSD_RB_VERBOSE, 0, 0
 };
 
 static const struct grub_arg_option openbsd_opts[] =
@@ -326,8 +330,8 @@ generate_e820_mmap_iter (grub_uint64_t addr, grub_uint64_t size,
   ctx->cur.addr = addr;
   ctx->cur.size = size;
 
-  if (type == GRUB_MEMORY_COREBOOT_TABLES
-      && addr == 0)
+   if (type == GRUB_MEMORY_COREBOOT_TABLES
+       && addr == 0 && do_null_quirk)
       /* Nowadays the tables at 0 don't contain anything important but
        *BSD needs the memory at 0 for own needs.
        */
@@ -925,7 +929,7 @@ grub_freebsd_boot (void)
 	 DragonFlyBSD needs the memory at 0 for own needs.
        */
       if (efi_mmap_size_out >= sizeof(grub_efi_memory_descriptor_t) && efidescs->physical_start == 0
-	  && efidescs->type == GRUB_EFI_RESERVED_MEMORY_TYPE && efidescs->num_pages <= (grub_coreboot_get_zerotables_size() >> GRUB_EFI_PAGE_SHIFT))
+	  && efidescs->type == GRUB_EFI_RESERVED_MEMORY_TYPE && do_null_quirk && efidescs->num_pages <= (grub_coreboot_get_zerotables_size() >> GRUB_EFI_PAGE_SHIFT))
 	{
 	  efidescs->type = GRUB_EFI_CONVENTIONAL_MEMORY;
 	}
@@ -1851,6 +1855,7 @@ grub_cmd_freebsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
 {
   kernel_type = KERNEL_TYPE_FREEBSD;
   bootflags = grub_bsd_parse_flags (ctxt->state, freebsd_flags);
+  do_null_quirk = ctxt->state[FREEBSD_NULL_QUIRK_FLAG].set;
 
   if (grub_bsd_load (argc, argv) == GRUB_ERR_NONE)
     {
@@ -1931,6 +1936,7 @@ grub_cmd_openbsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
 
   kernel_type = KERNEL_TYPE_OPENBSD;
   bootflags = grub_bsd_parse_flags (ctxt->state, openbsd_flags);
+  do_null_quirk = 0;
 
   if (ctxt->state[OPENBSD_ROOT_ARG].set && ctxt->state[OPENBSD_ROOT_ARG].arg != NULL)
     {
@@ -2025,6 +2031,7 @@ grub_cmd_netbsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
   grub_err_t err;
   kernel_type = KERNEL_TYPE_NETBSD;
   bootflags = grub_bsd_parse_flags (ctxt->state, netbsd_flags);
+  do_null_quirk = 0;
 
   if (grub_bsd_load (argc, argv) == GRUB_ERR_NONE)
     {
-- 
2.39.2


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

  parent reply	other threads:[~2024-05-17  7:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-17  7:45 [PATCH v2 1/4] smbios: Export grub_smbios_get_eps3 function Vladimir Serbinenko
2024-05-17  7:45 ` [PATCH v2 2/4] loader/bsd: Improve loading of *BSD on EFI platforms Vladimir Serbinenko
2024-05-17  7:45 ` Vladimir Serbinenko [this message]
2024-05-17  7:45 ` [PATCH v2 4/4] loader/bsd: Add missing zeros Vladimir Serbinenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240517074540.2576-3-phcoder@gmail.com \
    --to=phcoder@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.