On 5/31/2025 4:29 PM, Greg A. Woods wrote: > At Fri, 30 May 2025 23:54:32 -0400, Chuck Zmudzinski <frchu...@gmail.com> > wrote: > Subject: Re: Xen boot strangeness (Was: Re: [SOLVED] Re: Xen > 4.18.5_20250521nb0 not ELF binary (Was: Re: EFI and Xen)) >> >> On 5/30/2025 4:35 PM, Greg A. Woods wrote: >> > On one such legacy system I pass "bootdev=sd0" and it figures out which >> > partition to use, but in theory this could/should be "root=sd0a" (maybe >> > with "dump=sd0b"). >> >> I would be curious to know what happens if you set bootdev=sd0a instead of >> bootdev=sd0 on that system. I cannot test the legacy case on my box. > > I have no reason to suspect it would fail -- though perhaps it would > indeed go through the silly logic of still setting the booted dev to > "sd0" and then assuming the root partition is the "a" slice that it had > just chopped off the given string. > >> I think your arguments to totally ditch the code that tries to find the >> "booted_partition" would be much stronger if trying sd0a instead of sd0 >> does not work. > > Getting rid of the silly code that makes assumptions about slice "a" > (and slice "b") and going directly to specifying the root device name > exactly with no tricks or assumptions would obviously also work.
I am not sure it is silly code - maybe - but take note that booted_partition is a global variable and it appears from comments in the code that there are cases when we need to calculate it and use it to get a successful boot such as when the partition device is covered by a wedge. In that case, we need booted_partition to be able to access the device by looking up the geometry from the disklabel instead of booting it directly (at least that is what the comments in the code say). >From sys/kern/init_main.c: static void rootconf_handle_wedges(void) { ... if (booted_nblks) { /* * bootloader passed geometry */ dev = booted_device; startblk = booted_startblk; nblks = booted_nblks; /* * keep booted_device and booted_partition * in case the kernel doesn't identify a wedge */ } else { /* * bootloader passed partition number * * We cannot ask the partition device directly when it is * covered by a wedge. Instead we look up the geometry in * the disklabel. */ vp = opendisk(booted_device); if (vp == NULL) return; VOP_UNLOCK(vp); error = VOP_IOCTL(vp, DIOCGDINFO, &label, FREAD, NOCRED); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); VOP_CLOSE(vp, FREAD, NOCRED); vput(vp); if (error) return; KASSERT(booted_partition >= 0 && booted_partition < MAXPARTITIONS); p = &label.d_partitions[booted_partition]; dev = booted_device; startblk = p->p_offset; nblks = p->p_size; } dev = dkwedge_find_partition(dev, startblk, nblks); if (dev != NULL) { booted_device = dev; booted_partition = 0; } } This code suggests that there are cases when we do need to find the correct "booted_partition"... Anyways, I filed a PR for this problem: https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=59451 We'll see if the NetBSD maintainers want to fix this... Chuck Zmudzinski