NetBSD-Bugs archive

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

Re: port-amd64/59207: unexpected behavior of dev command in bootstrap code



The following reply was made to PR port-amd64/59207; it has been noted by GNATS.

From: Paul Goyette <paul%whooppee.com@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: rvp%sdf.org@localhost
Subject: Re: port-amd64/59207: unexpected behavior of dev command in bootstrap
 code
Date: Sat, 3 May 2025 18:06:10 -0700 (PDT)

 Is there any chance we can get these patches committed soon?
 
 they work just fine on my machine...
 
 
 On Wed, 26 Mar 2025, Paul Goyette wrote:
 
 > With the patches below, PLUS the pxeboot patch you sent offline, it
 > (bootx64.efi) works as desired.  I have removed all of the NAME=xxx
 > from the kernel filenames and set DEV=NAME=xxx (to override the initial
 > value of DEV=NAME-yyy.  It boots correctly from the specified kernel
 > file.
 >
 > A qemu VM installed with these patches still seems to ignore the DEV
 > command within boot.cfg (but I have not cacrefully verified this.)  I
 > was not able to test any other non-efi boots...
 >
 > Here is the pxeboot patch that you originally sent off-list:
 >
 > ```
 > diff -urN a/src/sys/arch/i386/stand/pxeboot/main.c
 > b/src/sys/arch/i386/stand/pxeboot/main.c
 > --- a/src/sys/arch/i386/stand/pxeboot/main.c    2024-11-10
 > 04:31:15.013906675 +0000
 > +++ b/src/sys/arch/i386/stand/pxeboot/main.c    2025-03-26
 > 11:07:28.331263167 +0000
 > @@ -180,6 +180,18 @@
 >        return (1);
 > }
 >
 > +/*
 > + * dummy function to satisfy link against call in
 > + * sys/arch/i386/stand/lib/bootmenu.c:do_bootcfg_command()
 > + */ +/* ARGSUSED */
 > +void
 > +command_dev(char *arg)
 > +{
 > +       (void)arg;
 > +       return;
 > +}
 > +
 > /* ARGSUSED */
 > void
 > command_help(char *arg)
 > ```
 >
 >
 >
 > On Wed, 26 Mar 2025, RVP via gnats wrote:
 >
 >> The following reply was made to PR port-amd64/59207; it has been noted by 
 >> GNATS.
 >> 
 >> From: RVP <rvp%SDF.ORG@localhost>
 >> To: gnats-bugs%netbsd.org@localhost
 >> Cc:
 >> Subject: Re: port-amd64/59207: unexpected behavior of dev command in 
 >> bootstrap
 >> code
 >> Date: Wed, 26 Mar 2025 07:44:21 +0000 (UTC)
 >> 
 >> On Sun, 23 Mar 2025, Paul Goyette via gnats wrote:
 >> 
 >> > It seems that the rndseed command behaves similarly, [...]
 >> >
 >> 
 >> Yeah, the set of commands recognized in /boot.cfg differ from those
 >> understood at the bootloader prompt.
 >> 
 >> For EFI on amd64, following the call sequence:
 >> 
 >> sys/arch/i386/stand/efiboot/efiboot.c:efi_main()	->
 >> sys/arch/i386/stand/efiboot/boot.c:boot()		->
 >> sys/arch/i386/stand/lib/bootmenu.c:parsebootconf()	->
 >> sys/lib/libsa/bootcfg.c:perform_bootcfg()
 >> 
 >> we see that only these commands are recognized in /boot.cfg:
 >> 
 >> menu, banner, timeout, default, consdev, root, format, clear &
 >> fs, load, userconf via the call-back function.
 >> 
 >> At the bootloader prompt, the `commands[]' array has the commands you can
 >> type in:
 >> 
 >> sys/arch/i386/stand/efiboot/efiboot.c:efi_main()	->
 >> sys/arch/i386/stand/efiboot/boot.c:boot()		->
 >> sys/arch/i386/stand/lib/menuutils.c:bootmenu()	-> docommand() ->
 >> sys/arch/i386/stand/efiboot/boot.c:			->
 >> 
 >> struct bootblk_command commands[] = { ... };
 >> 
 >> There're probably good reasons for this...
 >> 
 >> Anyway, Paul, can you please try this patch?
 >> 
 >> Thx,
 >> 
 >> -RVP
 >> 
 >> ---START patch---
 >> diff -urN a/src/sys/arch/i386/stand/boot/boot2.c 
 >> b/src/sys/arch/i386/stand/boot/boot2.c
 >> --- a/src/sys/arch/i386/stand/boot/boot2.c	2022-06-08 21:43:45.000000000 
 >> +0000
 >> +++ b/src/sys/arch/i386/stand/boot/boot2.c	2025-03-26 06:42:31.883704627 
 >> +0000
 >> @@ -130,7 +130,6 @@
 >>   void	command_quit(char *);
 >>   void	command_boot(char *);
 >>   void	command_pkboot(char *);
 >> -void	command_dev(char *);
 >>   void	command_consdev(char *);
 >>   void	command_root(char *);
 >>   #ifndef SMALL
 >> diff -urN a/src/sys/arch/i386/stand/dosboot/main.c 
 >> b/src/sys/arch/i386/stand/dosboot/main.c
 >> --- a/src/sys/arch/i386/stand/dosboot/main.c	2024-09-12 05:58:29.835738814 
 >> +0000
 >> +++ b/src/sys/arch/i386/stand/dosboot/main.c	2025-03-26 06:42:31.883704627 
 >> +0000
 >> @@ -65,7 +65,6 @@
 >>   void	command_quit(char *);
 >>   void	command_boot(char *);
 >>   void	command_mode(char *);
 >> -void	command_dev(char *);
 >>
 >>   const struct bootblk_command commands[] = {
 >>   	{ "help",	command_help },
 >> diff -urN a/src/sys/arch/i386/stand/lib/bootmenu.c 
 >> b/src/sys/arch/i386/stand/lib/bootmenu.c
 >> --- a/src/sys/arch/i386/stand/lib/bootmenu.c	2024-11-28 01:49:47.366302337 
 >> +0000
 >> +++ b/src/sys/arch/i386/stand/lib/bootmenu.c	2025-03-26 07:04:54.920298651 
 >> +0000
 >> @@ -57,10 +57,14 @@
 >>   static void
 >>   do_bootcfg_command(const char *cmd, char *arg)
 >>   {
 >> -	if (strcmp(cmd, BOOTCFG_CMD_LOAD) == 0)
 >> -		module_add(arg);
 >> -	else if (strcmp(cmd, "fs") == 0)
 >> +	if (strcmp(cmd, BOOTCFG_CMD_DEV) == 0)
 >> +		command_dev(arg);
 >> +	else if (strcmp(cmd, BOOTCFG_CMD_FS) == 0)
 >>   		fs_add(arg);
 >> +	else if (strcmp(cmd, BOOTCFG_CMD_LOAD) == 0)
 >> +		module_add(arg);
 >> +	else if (strcmp(cmd, BOOTCFG_CMD_RNDSEED) == 0)
 >> +		rnd_add(arg);
 >>   	else if (strcmp(cmd, BOOTCFG_CMD_USERCONF) == 0)
 >>   		userconf_add(arg);
 >>   }
 >> diff -urN a/src/sys/arch/i386/stand/lib/libi386.h 
 >> b/src/sys/arch/i386/stand/lib/libi386.h
 >> --- a/src/sys/arch/i386/stand/lib/libi386.h	2024-09-18 04:04:46.535251031 
 >> +0000
 >> +++ b/src/sys/arch/i386/stand/lib/libi386.h	2025-03-26 06:42:31.883704627 
 >> +0000
 >> @@ -150,6 +150,9 @@
 >>   void userconf_add(char *);
 >>   void module_add_split(const char *, uint8_t);
 >> 
 >> +/* Note: implementations differ in boot2, dosboot & efiboot */
 >> +void command_dev(char *);
 >> +
 >>   struct btinfo_framebuffer;
 >>   void framebuffer_configure(struct btinfo_framebuffer *);
 >> 
 >> diff -urN a/src/sys/lib/libsa/bootcfg.c b/src/sys/lib/libsa/bootcfg.c
 >> --- a/src/sys/lib/libsa/bootcfg.c	2022-01-05 16:01:54.000000000 +0000
 >> +++ b/src/sys/lib/libsa/bootcfg.c	2025-03-26 07:03:58.367307984 +0000
 >> @@ -227,8 +227,6 @@
 >>   			bootcfg_info.consdev = value;
 >>   		} else if (!strncmp(key, "root", 4)) {
 >>   			bootcfg_info.root = value;
 >> -		} else if (!strncmp(key, BOOTCFG_CMD_LOAD, 4)) {
 >> -			command(BOOTCFG_CMD_LOAD, value);
 >>   		} else if (!strncmp(key, "format", 6)) {
 >>   			printf("value:%c\n", *value);
 >>   			switch (*value) {
 >> @@ -251,8 +249,6 @@
 >>   			}
 >>   		} else if (!strncmp(key, "clear", 5)) {
 >>   			bootcfg_info.clear = !!atoi(value);
 >> -		} else if (!strncmp(key, BOOTCFG_CMD_USERCONF, 8)) {
 >> -			command(BOOTCFG_CMD_USERCONF, value);
 >>   		} else {
 >>   			command(key, value);
 >>   		}
 >> diff -urN a/src/sys/lib/libsa/bootcfg.h b/src/sys/lib/libsa/bootcfg.h
 >> --- a/src/sys/lib/libsa/bootcfg.h	2021-09-07 11:41:31.000000000 +0000
 >> +++ b/src/sys/lib/libsa/bootcfg.h	2025-03-26 07:12:00.103744727 +0000
 >> @@ -29,12 +29,15 @@
 >>   #ifndef _BOOTCFG_H
 >>   #define _BOOTCFG_H
 >> 
 >> -#define BOOTCFG_FILENAME "boot.cfg"
 >> -#define BOOTCFG_MAXMENU	 20
 >> -#define BOOTCFG_MAXBANNER 12
 >> +#define BOOTCFG_FILENAME	"boot.cfg"
 >> +#define BOOTCFG_MAXMENU		20
 >> +#define BOOTCFG_MAXBANNER	12
 >> 
 >> -#define BOOTCFG_CMD_LOAD	  "load"
 >> -#define BOOTCFG_CMD_USERCONF	  "userconf"
 >> +#define BOOTCFG_CMD_DEV		"dev"
 >> +#define BOOTCFG_CMD_FS		"fs"
 >> +#define BOOTCFG_CMD_LOAD	"load"
 >> +#define BOOTCFG_CMD_RNDSEED	"rndseed"
 >> +#define BOOTCFG_CMD_USERCONF	"userconf"
 >>
 >>   typedef void (*bootcfg_command)(const char *cmd, char *arg);
 >> 
 >> ---END patch---
 >> 
 >> 
 >> !DSPAM:67e3b09e68781226255623!
 >> 
 >> 
 >
 > +---------------------+--------------------------+----------------------+
 > | Paul Goyette (.sig) | PGP Key fingerprint:     | E-mail addresses:    |
 > | (Retired)           | 1B11 1849 721C 56C8 F63A | paul%whooppee.com@localhost    |
 > | Software Developer  | 6E2E 05FD 15CE 9F2D 5102 | pgoyette%netbsd.org@localhost  |
 > | & Network Engineer  |                          | pgoyette99%gmail.com@localhost |
 > +---------------------+--------------------------+----------------------+
 >
 
 +---------------------+--------------------------+----------------------+
 | Paul Goyette (.sig) | PGP Key fingerprint:     | E-mail addresses:    |
 | (Retired)           | 1B11 1849 721C 56C8 F63A | paul%whooppee.com@localhost    |
 | Software Developer  | 6E2E 05FD 15CE 9F2D 5102 | pgoyette%netbsd.org@localhost  |
 | & Network Engineer  |                          | pgoyette99%gmail.com@localhost |
 +---------------------+--------------------------+----------------------+
 


Home | Main Index | Thread Index | Old Index