Re: 9.99.100 fallout: bootloader and modules

2022-09-21 Thread Jason Thorpe



> On Sep 21, 2022, at 5:00 AM, Johnny Billquist  wrote:
> 
> Searching for uses of netbsd_version, there is some more broken logic in a 
> few places, following similar patterns or assumptions.
> 
> Like in /usr/src/sys/arch/i386/stand/lib/exec.c:
> 
>if (netbsd_version / 100 % 100 == 99) {
>/* -current */
>snprintf(buf, bufsize,
>"/stand/%s/%d.%d.%d/modules", machine,
>netbsd_version / 1,
>netbsd_version / 100 % 100,
>netbsd_version / 100 % 100);
>} else if (netbsd_version != 0) {
>/* release */
>snprintf(buf, bufsize,
>"/stand/%s/%d.%d/modules", machine,
>netbsd_version / 1,
>netbsd_version / 100 % 100);
>}
> 
> 
> So just changing the modulo in the place you were suggesting isn't enough. :-P

Obviously we need a function in libsa or libkern for this.

-- thorpej



Re: 9.99.100 fallout: bootloader and modules

2022-09-21 Thread Johnny Billquist
Searching for uses of netbsd_version, there is some more broken logic in 
a few places, following similar patterns or assumptions.


Like in /usr/src/sys/arch/i386/stand/lib/exec.c:

if (netbsd_version / 100 % 100 == 99) {
/* -current */
snprintf(buf, bufsize,
"/stand/%s/%d.%d.%d/modules", machine,
netbsd_version / 1,
netbsd_version / 100 % 100,
netbsd_version / 100 % 100);
} else if (netbsd_version != 0) {
/* release */
snprintf(buf, bufsize,
"/stand/%s/%d.%d/modules", machine,
netbsd_version / 1,
netbsd_version / 100 % 100);
}


So just changing the modulo in the place you were suggesting isn't 
enough. :-P


  Johnny

On 2022-09-21 13:47, Taylor R Campbell wrote:

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 / 1,
netbsd_version / 100 % 100,
netbsd_version / 100 % 100);/* XXX */

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

I will try the attached patch to do `% 1' 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__.)


--
Johnny Billquist  || "I'm on a bus
  ||  on a psychedelic trip
email: b...@softjar.se ||  Reading murder books
pdp is alive! ||  tryin' to stay hip" - B. Idol