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:  Sat Aug 11 05:15:00 +0000 2018
>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

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.