On PowerNV, grub should probably not call ofpathname

"Pape, Tobias" via Bug reports for the GRand Unified Bootloader <[email protected]> Thu, 22 Feb 2024 08:51:50 +0000
Newsgroups gmane.comp.boot-loaders.grub.bugs
Message-ID <[email protected]>
Dear Team and grub enthusiasts

I have been running into a peculiar problem when trying to call
grub for installation on a PowerNV environment.

(TL;DR: I ran into a problem during maas deployment: https://discourse.maas.io/t/deploying-custom-rhel-on-powernv/7681)


Context (skip to ### if unnecessary)

For Linux on IBM Power, we have seen that there are essentially 3 modes to run in:

- pSeries / PowerVM: The typical path when running something in a Power LPAR
- pSeries / PowerNV: The atypical path when running something on pSeries _without_ an LPAR
- OPAL / PowerNV. This is what we are talking about.

In OPAL/PowerNV, Grub is not actually the bootloader that loads the kernel, but
petitboot is. However, as far as I can tell, petitboot _uses_ grub's configuration
to actually do the boot.
So, parts of the grub infra are apparently necessary to have linux boot.

On pSeries, I think grub is used throughout, and I have seen the grub-ieee1275 
dealing with its specifics.

One part of that is, that when calling grub to install from linux, it will
detect it's running on a PowerPC/ieee1275 platform and try to do
the sensible thing for pSeries and update nvram. 
For that, it uses ofpathname, to map from block device names to openfirmware names.

It is sensible for grub to check that ofpathname works, and it does so
by rumning it with the --version flag 
(https://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/osdep/unix/platform.c#n185 )

### However, and this the actual thing, ofpathname does not like to be called on PowerNV _at all_:

pSeries: 
# ofpathname --version
ofpathname: Version 0.5
Written by: Nathan Fontenot <[email protected]>
# ofpathname sda
/pci@800000020000013/pci@0/pci@2/fibre-channel@0/disk@500507680d758135

PowerNV
# ofpathname --version
ofpathname: is not supported on the PowerNV Host platform
# ofpathname sda
ofpathname: is not supported on the PowerNV Host platform
#ofpathname I beg your pardon\?
ofpathname: is not supported on the PowerNV Host platform
# ofpathname
ofpathname: is not supported on the PowerNV Host platform

(code of ofpathname is bash and actually: 
. $PSERIES_PLATFORM
if [[ $platform = $PLATFORM_POWERNV ]]; then
        echo "$OFPATHNAME: is not supported on the $platform_name platform"
        exit 1
fi
)

Running grub-install with --no-nvram circumvents all this, but not all paths support 
adding that options; also, it is not really obvious that this path works.

Q: could grub be lenient and simply return if it finds out that ofpathname failed not 
because of an actual error, but that it is runnig on PowerNV? 
(ofpathname uses the `pseries_platform` script, which in turn greps /proc/cpuinfo)

Or another way: could grub on power-nv just assume --no-nvram by default?


Thanks and best regards
	-Tobias
smime.p7s (application/pkcs7-signature, 5.7 KB) - not displayed