NetBSD Problem Report #53490

From www@NetBSD.org  Wed Aug  1 15:07:55 2018
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id D22707A111
	for <gnats-bugs@gnats.NetBSD.org>; Wed,  1 Aug 2018 15:07:54 +0000 (UTC)
Message-Id: <20180801150753.9B5317A14F@mollari.NetBSD.org>
Date: Wed,  1 Aug 2018 15:07:53 +0000 (UTC)
From: triaxx@NetBSD.org
Reply-To: triaxx@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: sysutils/grub2: module loaded even if feature is builtin
X-Send-Pr-Version: www-1.0

>Number:         53490
>Category:       pkg
>Synopsis:       sysutils/grub2: module loaded even if feature is builtin
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Aug 01 15:10:00 +0000 2018
>Last-Modified:  Sun May 03 13:45:01 +0000 2020
>Originator:     Frédéric Fauberteau
>Release:        netbsd-8-0-RELEASE (pkgsrc-2018Q2)
>Organization:
>Environment:
NetBSD hydralisk 8.0 NetBSD 8.0 (HYDRALISK) #1: Tue Jul 31 18:43:06 CEST 2018  root@hydralisk:/usr/obj/sys/arch/amd64/compile/HYDRALISK amd64
>Description:
At boot, the following errors at printed due to grub2 that loads ffs.kmod:

--- dmesg ---
NetBSD 8.0 (HYDRALISK) #1: Tue Jul 31 18:43:06 CEST 2018
    root@hydralisk:/usr/obj/sys/arch/amd64/compile/HYDRALISK
total memory = 3839 MB
avail memory = 3704 MB
kobj_checksyms, 1003: [ffs.kmod]: linker error: global symbol `ffs_vnodeop_opv_desc' redefined
kobj_checksyms, 1003: [ffs.kmod]: linker error: global symbol `ffs_snapshot_fini' redefined
*** idem ***
kobj_checksyms, 1003: [ffs.kmod]: linker error: global symbol `ufs_direnter' redefined
WARNING: module error: unable to load `ffs.kmod' pushed by boot loader, error 8
--- /dmesg ---

Actually, ffs is builtin:

--- modstat ---
$ modstat | grep "^ffs"
ffs                     vfs      builtin  -        2       - wapbl
--- /modstat ---
>How-To-Repeat:
# grub-mkconfig -o /grub/grub.cfg

The NetBSD prober (/usr/pkg/etc/grub/10_netbsd) detects fs type of the root filesystem and loads the corresponding module unconditionally.
>Fix:
pgoyette@ suggests teaching grub not to "push" modules that are already built-in.

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: pkg-manager->pgoyette
Responsible-Changed-By: pgoyette@NetBSD.org
Responsible-Changed-When: Wed, 01 Aug 2018 22:13:12 +0000
Responsible-Changed-Why:
I'll work on it


From: Paul Goyette <paul@whooppee.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/53490 (sysutils/grub2: module loaded even if feature is
 builtin)
Date: Thu, 2 Aug 2018 06:16:21 +0800 (+08)

 Note that I've changed the category on this PR.  It was originally
 "pkg" but there are other ways to trigger the sub-optimal kernel
 behaviour (ie, the "load" command in /boot.cfg).

From: Paul Goyette <paul@whooppee.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/53490 (sysutils/grub2: module loaded even if feature is
 builtin)
Date: Fri, 3 Aug 2018 07:05:45 +0800 (+08)

 > >Fix:
 > pgoyette@ suggests teaching grub not to "push" modules that are 
 > already built-in.

 FWIW, although that might be the ideal solution, it's not practical, as
 that would involve teaching grub an awful lot about the internals (and
 structure) of the NetBSD kernel.

 The only solution that might be available here is to figure out why
 (and more importantly, how) grub is trying to actually load the modules,
 rather than simply "pushing" them to the NetBSD tertiary bootloader (as
 in module_prime() used by normal secondary boot).  I have so far been
 unable to even build the grub2 package.


Responsible-Changed-From-To: pgoyette->pkg-manager
Responsible-Changed-By: pgoyette@NetBSD.org
Responsible-Changed-When: Wed, 08 Aug 2018 22:57:17 +0000
Responsible-Changed-Why:
Not a kernel problem


From: Paul Goyette <paul@whooppee.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/53490 (sysutils/grub2: module loaded even if feature is
 builtin)
Date: Thu, 9 Aug 2018 06:56:22 +0800 (+08)

 This does not appear to be a problem with the kernel's module system,
 as detection of duplicate modules "pushed" from the bootloader already
 works.

 So, this is most likely a problem with grub2 itself, and probably is a
 result of directly trying to load a module rather than proper "push"
 of the module via module_prime().

 I still cannot get the grub2 package to build, so I'm unable to do any
 further debug on this.  I'll return the category to "pkg" and owner to 
 "pkg-manager"


 +------------------+--------------------------+----------------------------+
 | Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:          |
 | (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee dot com   |
 | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd dot org |
 +------------------+--------------------------+----------------------------+

From: =?UTF-8?Q?Fr=C3=A9d=C3=A9ric_Fauberteau?= <triaxx@NetBSD.org>
To: gnats-bugs@netbsd.org
Cc: pkg-manager@netbsd.org, gnats-admin@netbsd.org, pkgsrc-bugs@netbsd.org
Subject: Re: kern/53490 (sysutils/grub2: module loaded even if feature is  builtin)
Date: Sat, 11 Aug 2018 07:10:53 +0200

 Le 2018-08-09 01:00, Paul Goyette a écrit :
 > The following reply was made to PR pkg/53490; it has been noted by 
 > GNATS.
 > 
 > From: Paul Goyette <paul@whooppee.com>
 > To: gnats-bugs@NetBSD.org
 > Cc:
 > Subject: Re: kern/53490 (sysutils/grub2: module loaded even if feature 
 > is
 >  builtin)
 > Date: Thu, 9 Aug 2018 06:56:22 +0800 (+08)
 > 
 >  This does not appear to be a problem with the kernel's module system,
 >  as detection of duplicate modules "pushed" from the bootloader already
 >  works.

 Nice.

 >  So, this is most likely a problem with grub2 itself, and probably is a
 >  result of directly trying to load a module rather than proper "push"
 >  of the module via module_prime().
 > 
 >  I still cannot get the grub2 package to build, so I'm unable to do any
 >  further debug on this.  I'll return the category to "pkg" and owner to
 >  "pkg-manager"

 A solution could be to inspect kernel config during grub-mkconfig 
 through helper script:

 $NetBSD$

 --- util/grub.d/10_netbsd.in.orig 2016-02-28 14:22:21.000000000 +0000
 +++ util/grub.d/10_netbsd.in
 @@ -68,8 +68,9 @@ netbsd_load_fs_module ()

     kversion=$(zcat -f "${kernel}" | strings | sed -n -e '/^@(#)NetBSD/ { 
 s/^@(#)NetBSD \([0-9\.]*\) .*$/\1/g ; p ; q ; }')
     kmodule="/stand/${karch}/${kversion}/modules/${kmod}/${kmod}.kmod"
 +  builtin=$(if config -x /netbsd | grep "^file-system[[:space:]]*$(echo 
 ${kmod} | tr [a-z] [A-Z])" > /dev/null 2>&1 ; then echo yes ; else echo 
 no ; fi)

 -  if test -z "$karch" || test -z "$kversion" || test ! -f "${kmodule}"; 
 then
 +  if test -z "$karch" || test -z "$kversion" || test ! -f "${kmodule}" 
 || test "x${builtin}" = "xyes" ; then
       return
     fi

From: Paul Goyette <paul@whooppee.com>
To: gnats-bugs@NetBSD.org
Cc: triaxx@NetBSD.org
Subject: Re: kern/53490 (sysutils/grub2: module loaded even if feature is
 builtin)
Date: Tue, 21 Jan 2020 08:09:28 -0800 (PST)

 I will leave any changes to the sysutils/grub2 package to you, as I am
 still unable to get a working package built.


 > A solution could be to inspect kernel config during grub-mkconfig
 > through helper script:
 >
 > $NetBSD$
 >
 > --- util/grub.d/10_netbsd.in.orig 2016-02-28 14:22:21.000000000 +0000
 > +++ util/grub.d/10_netbsd.in
 > @@ -68,8 +68,9 @@ netbsd_load_fs_module ()
 >
 >    kversion=$(zcat -f "${kernel}" | strings | sed -n -e '/^@(#)NetBSD/ { s/^@(#)NetBSD \([0-9\.]*\) .*$/\1/g ; p ; q ; }')
 >    kmodule="/stand/${karch}/${kversion}/modules/${kmod}/${kmod}.kmod"
 > +  builtin=$(if config -x /netbsd | grep "^file-system[[:space:]]*$(echo ${kmod} | tr [a-z] [A-Z])" > /dev/null 2>&1 ; then echo yes ; else echo no ; fi)
 >
 > -  if test -z "$karch" || test -z "$kversion" || test ! -f "${kmodule}"; then
 > +  if test -z "$karch" || test -z "$kversion" || test ! -f "${kmodule}" || test "x${builtin}" = "xyes" ; then
 >       return
 >    fi
 >




 +--------------------+--------------------------+-----------------------+
 | Paul Goyette       | PGP Key fingerprint:     | E-mail addresses:     |
 | (Retired)          | FA29 0E3B 35AF E8AE 6651 | paul@whooppee.com     |
 | Software Developer | 0786 F758 55DE 53BA 7731 | pgoyette@netbsd.org   |
 +--------------------+--------------------------+-----------------------+

From: =?UTF-8?B?RnLDqWTDqXJpYyBGYXViZXJ0ZWF1?= <triaxx@NetBSD.org>
To: Paul Goyette <paul@whooppee.com>, gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/53490 (sysutils/grub2: module loaded even if feature is
 builtin)
Date: Sat, 2 May 2020 18:55:23 +0200

 Le 21/01/2020 à 17:09, Paul Goyette a écrit :
 > I will leave any changes to the sysutils/grub2 package to you, as I am
 > still unable to get a working package built.

 I just updated sysutils/grub2 to 2.04. Can you build it now?

From: Paul Goyette <paul@whooppee.com>
To: =?UTF-8?B?RnLDqWTDqXJpYyBGYXViZXJ0ZWF1?= <triaxx@NetBSD.org>
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/53490 (sysutils/grub2: module loaded even if feature is
 builtin)
Date: Sun, 3 May 2020 06:42:28 -0700 (PDT)

   This message is in MIME format.  The first part should be readable text,
   while the remaining parts are likely unreadable without MIME-aware tools.

 --0-785250015-1588513348=:25167
 Content-Type: TEXT/PLAIN; charset=utf-8; format=flowed
 Content-Transfer-Encoding: QUOTED-PRINTABLE

 On Sat, 2 May 2020, Fr=C3=A9d=C3=A9ric Fauberteau wrote:

 > Le 21/01/2020 =C3=A0 17:09, Paul Goyette a =C3=A9crit=C2=A0:
 >> I will leave any changes to the sysutils/grub2 package to you, as I am
 >> still unable to get a working package built.
 >
 > I just updated sysutils/grub2 to 2.04. Can you build it now?

 Nope.  Building on my amd64 9.99.52 host, it now fails with

 font/font.c:44:1: error: expected expression before 'struct'
   struct char_index_entry
   ^~~~~~



 +--------------------+--------------------------+-----------------------+
 | Paul Goyette       | PGP Key fingerprint:     | E-mail addresses:     |
 | (Retired)          | FA29 0E3B 35AF E8AE 6651 | paul@whooppee.com     |
 | Software Developer | 0786 F758 55DE 53BA 7731 | pgoyette@netbsd.org   |
 +--------------------+--------------------------+-----------------------+
 --0-785250015-1588513348=:25167--

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.