NetBSD-Users archive

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

Re: Xen boot strangeness (Was: Re: [SOLVED] Re: Xen 4.18.5_20250521nb0 not ELF binary (Was: Re: EFI and Xen))



On 5/29/2025 4:02 PM, Greg A. Woods wrote:
> At Thu, 29 May 2025 15:01:50 -0400, Chuck Zmudzinski <frchuckz%gmail.com@localhost> wrote:
> 
>> When I pass bootdev=dk12 in boot.cfg, the bootloader strangely tries dk1 as root
>> (which is wrong) and correctly detects dk11 as the dump device. But it never
>> gives me the chance to enter the correct root device and instead tries to load
>> init which of course it cannot find the NetBSD init on dk1 because dk1 is not
>> the correct NetBSD root device. In fact on this box a Linux distro is installed
>> on dk1, as evidenced by the filesystem type detected on dk1: ext2fs.
> 
> Ah, I think that's a bug related to some bizarre/old hacks to find the
> "booted_partion" for non-GPT disks:
> 
> 		if (strncmp(xcp.xcp_bootdev, devname, strlen(devname)))
> 			continue;
> 
> 		if (is_disk && strlen(xcp.xcp_bootdev) > strlen(devname)) {
> 			/* XXX check device_cfdata as in x86_autoconf.c? */
> 			booted_partition = toupper(
> 				xcp.xcp_bootdev[strlen(devname)]) - 'A';
> 			DPRINTF(("%s: booted_partition: %d\n", __func__, booted_partition));
> 		}
> 

You are correct. I patched this code and got rid of the strangeness.

When I patch it like this:

		if (is_disk && strlen(xcp.xcp_bootdev) > strlen(devname)) {
			/* XXX check device_cfdata as in x86_autoconf.c? */
			booted_partition = toupper(
				xcp.xcp_bootdev[strlen(devname)]) - 'A';
			/ * Make sure we have a sane value for booted_partition */
			if (booted_partition & 0xfffffff0)
				continue;
			DPRINTF(("%s: booted_partition: %d\n", __func__, booted_partition));
		}

Then I can pass bootdev=dk12 in boot.cfg to the DOM0 kernel and it now correctly
finds dk12 as the root device instead of strangely finding dk1 as the root device:

snip...
[    13.924443] boot device: dk12
[    14.114443] root on dk12 dumps on dk11
...

And it boots normally. Strangeness solved!

When I patched the kernel, I also commented out the com* at puc? port ? in
the config file for the kernel to solve the other problem I was having with
the com port causing a crash unless I run disable com* at the uc> prompt.

So, with a kernel patched like this, which I installed on the root partition
as netbsd-XEN3_DOM0.dkfix I can now go back to using the vga console and boot
NetBSD/xen PV dom0 normally from the boot menu without needed to interact
with the boot process at the serial console.

The boot.cfg command that now works very well is:

menu=Boot normally with Xen:dev hd2d:;load /netbsd-XEN3_DOM0.dkfix console=pc bootdev=dk12;multiboot /xen.gz dom0_mem=2G dom0_max_vcpus=4 console=vga cet=no-ibt pv-l1tf=false

Thanks, everyone, for all your input...

Chuck Zmudzinski


Home | Main Index | Thread Index | Old Index