tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

9.99.100 fallout: bootloader and modules



The x86 bootloader, and the MI efiboot, are unable to find modules
when the kernel version is 9.99.100 -- they try
/stand/$ARCH/9.99.0/modules instead, because of this logic:

/* sys/arch/i386/stand/lib/exec.c */
		snprintf(buf, bufsize,
		    "/stand/%s/%d.%d.%d/modules", machine,
		    netbsd_version / 100000000,
		    netbsd_version / 1000000 % 100,
		    netbsd_version / 100 % 100);		/* XXX */

/* sys/stand/efiboot/module.c */
	const u_int vmajor = netbsd_version / 100000000;
	const u_int vminor = netbsd_version / 1000000 % 100;
	const u_int vpatch = netbsd_version / 100 % 100;	/* XXX */

I will try the attached patch to do `% 10000' instead of `% 100' on
the lines marked XXX.  Likely other bootloaders will need to be
adjusted to handle this.  Loading modules from the bootloader in a
>=9.99.100 kernel will require updating the bootloader.

(After boot, module loading works fine because the kernel's module
loader uses the `osrelease' string instead of doing arithmetic on
__NetBSD_Version__.)
From 40c19f9c5a6dc16cbc869f88bfaca70b064d314c Mon Sep 17 00:00:00 2001
From: Taylor R Campbell <riastradh%NetBSD.org@localhost>
Date: Wed, 21 Sep 2022 11:42:25 +0000
Subject: [PATCH 1/2] i386/stand: Handle 9.99.100 by taking four, not two,
 digits.

We haven't used the revision part of __NetBSD_Version__ = MMmmrrpp00
in almos two decades so we're apparently reclaiming it as MMmmpppp00.
---
 sys/arch/i386/stand/lib/exec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/arch/i386/stand/lib/exec.c b/sys/arch/i386/stand/lib/exec.c
index 89acb0536fea..6a7ee70cf179 100644
--- a/sys/arch/i386/stand/lib/exec.c
+++ b/sys/arch/i386/stand/lib/exec.c
@@ -684,7 +684,7 @@ module_base_path(char *buf, size_t bufsize, const char *kernel_path)
 		    "/stand/%s/%d.%d.%d/modules", machine,
 		    netbsd_version / 100000000,
 		    netbsd_version / 1000000 % 100,
-		    netbsd_version / 100 % 100);
+		    netbsd_version / 100 % 10000);
 	} else if (netbsd_version != 0) {
 		/* release */
 		snprintf(buf, bufsize,

From 4de556562376b9a50f9f70984a937451f46c5773 Mon Sep 17 00:00:00 2001
From: Taylor R Campbell <riastradh%NetBSD.org@localhost>
Date: Wed, 21 Sep 2022 11:45:04 +0000
Subject: [PATCH 2/2] efiboot: Handle 9.99.100 by taking four, not two, digits.

We haven't used the revision part of __NetBSD_Version__ = MMmmrrpp00
in almos two decades so we're apparently reclaiming it as MMmmpppp00.
---
 sys/stand/efiboot/module.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/stand/efiboot/module.c b/sys/stand/efiboot/module.c
index 48023ccb0ca2..918f5345ce54 100644
--- a/sys/stand/efiboot/module.c
+++ b/sys/stand/efiboot/module.c
@@ -62,7 +62,7 @@ module_set_prefix(const char *kernel_path)
 #else
 	const u_int vmajor = netbsd_version / 100000000;
 	const u_int vminor = netbsd_version / 1000000 % 100;
-	const u_int vpatch = netbsd_version / 100 % 100;
+	const u_int vpatch = netbsd_version / 100 % 10000;
 
 	if (vminor == 99) {
 		snprintf(module_prefix, sizeof(module_prefix),


Home | Main Index | Thread Index | Old Index