NetBSD Problem Report #54869

From tsutsui@ceres.dti.ne.jp  Sat Jan 18 06:14:14 2020
Return-Path: <tsutsui@ceres.dti.ne.jp>
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 B5C2E7A19B
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 18 Jan 2020 06:14:14 +0000 (UTC)
Message-Id: <202001180614.00I6E5Gu001598@ceres.dti.ne.jp>
Date: Sat, 18 Jan 2020 15:14:05 +0900 (JST)
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Reply-To: tsutsui@ceres.dti.ne.jp
To: gnats-bugs@NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: nfsserver module load failure on NetBSD/sun3
X-Send-Pr-Version: 3.95

>Number:         54869
>Category:       port-sun3
>Synopsis:       nfsserver module load failure on NetBSD/sun3
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-sun3-maintainer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jan 18 06:15:00 +0000 2020
>Closed-Date:    Sat Feb 01 05:39:05 +0000 2020
>Last-Modified:  Sat Feb 01 06:20:01 +0000 2020
>Originator:     Izumi Tsutsui
>Release:        NetBSD 9.0_RC1
>Organization:
>Environment:
System: NetBSD mirage 9.0_RC1 NetBSD 9.0_RC1 (GENERIC) #13: Fri Jan 17 21:38:33 JST 2020 tsutsui@mirage:/s/netbsd-9/src/sys/arch/i386/compile/GENERIC i386
Architecture: m68k
Machine: sun3
>Description:
"modload nfsserver" on NetBSD/sun3 9.0_RC1 (GENERIC+MODULAR kernel) fails:
---
# uname -a
NetBSD  9.0_RC1 NetBSD 9.0_RC1 (MODULAR) #0: Tue Jan 14 23:20:20 JST 2020  tsutsui@mirage:/s/netbsd-9/src/sys/arch/sun3/compile/MODULAR sun3
# modload nfsserver
[ 361.3700220] kobj_checksyms, 988: [nfsserver]: linker error: symbol `pmap_update' not found
[ 361.4200220] WARNING: module error: unable to affix module `nfsserver', error 8
modload: nfsserver: Exec format error
# modload msdos
# modload ext2fs
# 
---

>How-To-Repeat:
- Build NetBSD/sun3 kernel with GENERIC + MODULAR
- Use netboot to boot NetBSD/sun3 9.0_RC1 to singleuser
(symbol table is not loaded properly via ufsboot; I'll file another PR.)
- modload nfsserver

>Fix:
Actually src/sys/nfs/nfs_serv.c has pmap_update() in nfsrv_read():
 https://nxr.netbsd.org/xref/src/sys/nfs/nfs_serv.c?r=1.177#747
---
    740 			/* map pages */
    741 			for (i = 0; i < npages; i++) {
    742 				pmap_kenter_pa(lva, VM_PAGE_TO_PHYS(pgpp[i]),
    743 				    VM_PROT_READ, 0);
    744 				lva += PAGE_SIZE;
    745 			}
    746 
    747 			pmap_update(pmap_kernel());
    748 
    749 			mb->m_next = m;
    750 			mb = m;
    751 			error = 0;
    752 			uiop->uio_resid = 0;
---

On the other hand, all m68k ports define pmap_update() as no-op:
---
% grep pmap_update sys/arch/*/include/*.h
sys/arch/m68k/include/pmap_motorola.h:#define   pmap_update(pmap)               /* nothing (yet) */

 :

sys/arch/sun2/include/pmap.h:#define    pmap_update(pmap)               /* nothing (yet) */
sys/arch/sun3/include/pmap3.h:#define   pmap_update(pmap)               /* nothing (yet) */
sys/arch/sun3/include/pmap3x.h:#define  pmap_update(pmap)               /* nothing (yet) */
---

sys/arch/sun3/include/pmap3.h is included from sys/arch/sun3/include/pmap.h
by _SUN3_ or _SUN3X_:
 https://nxr.netbsd.org/xref/src/sys/arch/sun3/include/pmap.h?r=1.32#32
---
     32 #ifdef	_SUN3_
     33 #include <machine/pmap3.h>
     34 #endif	/* SUN3 */
     35 #ifdef	_SUN3X_
     36 #include <machine/pmap3x.h>
     37 #endif	/* SUN3X */
     38 
     39 #ifdef _KERNEL
     40 void pmap_procwr(struct proc *, vaddr_t, size_t);
     41 #endif
---

On module builds, neither _SUN3_ or _SUN3X_ is defined,
so pmap_update() is not defined then it causes the undefined refernece.

Which is better to solve this issue?
(1) move pmap_update() definition to sun3/include/pmap.h
(2) implicitly include pmap3.h on module builds
    (not sure if modules require pmap details that are defferent
     between sun3 and sun3x)

sun3/include/param.h and sun3/include/vmparam.h had the same problem,
but IIRC I changed all references of KERNBASE, KERN_END, USRSTACK etc.
to use variables:
 http://www.nerv.org/netbsd/?q=id:20101015T155554Z.478e44a7b8b76dcff1653a7bb0611ea28e9b4a46

---
Izumi Tsutsui

>Release-Note:

>Audit-Trail:
From: Jason Thorpe <thorpej@me.com>
To: gnats-bugs@netbsd.org
Cc: port-sun3-maintainer@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: port-sun3/54869: nfsserver module load failure on NetBSD/sun3
Date: Sat, 18 Jan 2020 07:10:34 -0800

 > On Jan 17, 2020, at 10:15 PM, Izumi Tsutsui <tsutsui@ceres.dti.ne.jp> =
 wrote:
 >=20
 > Which is better to solve this issue?
 > (1) move pmap_update() definition to sun3/include/pmap.h
 > (2) implicitly include pmap3.h on module builds
 >    (not sure if modules require pmap details that are defferent
 >     between sun3 and sun3x)

 I think the pmap module should provide a pmap_update() symbol.  Or =
 perhaps the NFS server should use a higher-level interface to do this =
 work?  Maybe I would lean towards that...

 -- thorpej

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: thorpej@me.com
Cc: gnats-bugs@netbsd.org, tsutsui@ceres.dti.ne.jp
Subject: Re: port-sun3/54869: nfsserver module load failure on NetBSD/sun3
Date: Sun, 19 Jan 2020 01:59:30 +0900

 > > Which is better to solve this issue?
 > > (1) move pmap_update() definition to sun3/include/pmap.h
 > > (2) implicitly include pmap3.h on module builds
 > >    (not sure if modules require pmap details that are defferent
 > >     between sun3 and sun3x)
 > 
 > I think the pmap module should provide a pmap_update() symbol.

 I'm afraid it's too late for 9.0 release.
 All other m68k ports have the same definitions.

 IMO all pmap functions described in pmap(9) man page should be
 declared in MI header, but I guess they aren't by histrical reason.

 In this manner, I have a feeling that sun3 should define all
 exported pmap APIs in the common sun3/include/pmap.h,
 rather than sun3/sun3x specific headers.
 (though there is difficulty on pmap_prefer(9))

 > Or perhaps the NFS server should use a higher-level interface
 > to do this work?  Maybe I would lean towards that...

 It uses pmap_kenter_pa() then MI pmap_update() is required.
 I'm not sure which level API can be used for modules...

 ---
 Izumi Tsutsui

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: thorpej@me.com
Cc: gnats-bugs@netbsd.org, tsutsui@ceres.dti.ne.jp
Subject: Re: port-sun3/54869: nfsserver module load failure on NetBSD/sun3
Date: Sun, 19 Jan 2020 02:26:45 +0900

 > In this manner, I have a feeling that sun3 should define all
 > exported pmap APIs in the common sun3/include/pmap.h,
 > rather than sun3/sun3x specific headers.
 > (though there is difficulty on pmap_prefer(9))

 For netbsd-9, the attached diff makes nfsserver module work on 3/60:

 ---
 Index: sys/arch/sun3/include/pmap.h
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/sun3/include/pmap.h,v
 retrieving revision 1.32
 diff -u -p -d -r1.32 pmap.h
 --- sys/arch/sun3/include/pmap.h	11 Dec 2009 18:31:27 -0000	1.32
 +++ sys/arch/sun3/include/pmap.h	18 Jan 2020 17:24:36 -0000
 @@ -37,6 +37,12 @@
  #endif	/* SUN3X */

  #ifdef _KERNEL
 +/*
 + * Some pmap(9) API macros should be defined here for module(7)
 + * because they are common between sun3 and sun3x. (see PR/54869)
 + */
 +#define	pmap_update(pmap)		/* nothing (yet) */
 +
  void pmap_procwr(struct proc *, vaddr_t, size_t);
  #endif

 Index: sys/arch/sun3/include/pmap3.h
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/sun3/include/pmap3.h,v
 retrieving revision 1.49
 diff -u -p -d -r1.49 pmap3.h
 --- sys/arch/sun3/include/pmap3.h	7 Jan 2013 16:58:09 -0000	1.49
 +++ sys/arch/sun3/include/pmap3.h	18 Jan 2020 17:24:36 -0000
 @@ -64,8 +64,6 @@ extern segsz_t pmap_wired_pages(pmap_t);
  /* We use the PA plus some low bits for device mmap. */
  #define pmap_phys_address(addr) 	(addr)

 -#define	pmap_update(pmap)		/* nothing (yet) */
 -
  /* Map a given physical region to a virtual region */
  extern vaddr_t pmap_map(vaddr_t, paddr_t, paddr_t, int);

 Index: sys/arch/sun3/include/pmap3x.h
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/sun3/include/pmap3x.h,v
 retrieving revision 1.29
 diff -u -p -d -r1.29 pmap3x.h
 --- sys/arch/sun3/include/pmap3x.h	3 Jun 2011 17:03:52 -0000	1.29
 +++ sys/arch/sun3/include/pmap3x.h	18 Jan 2020 17:24:36 -0000
 @@ -53,8 +53,6 @@ segsz_t pmap_count(pmap_t, int);
  /* We use the PA plus some low bits for device mmap. */
  #define pmap_phys_address(addr) 	(addr)

 -#define	pmap_update(pmap)		/* nothing (yet) */
 -
  /* Map a given physical region to a virtual region */
  vaddr_t pmap_map(vaddr_t, paddr_t, paddr_t, int);


 ---

 ---
 Izumi Tsutsui

From: Jason Thorpe <thorpej@me.com>
To: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Cc: gnats-bugs@netbsd.org
Subject: Re: port-sun3/54869: nfsserver module load failure on NetBSD/sun3
Date: Sat, 18 Jan 2020 10:13:48 -0800

 > On Jan 18, 2020, at 9:26 AM, Izumi Tsutsui <tsutsui@ceres.dti.ne.jp> wrote:
 > 
 >> In this manner, I have a feeling that sun3 should define all
 >> exported pmap APIs in the common sun3/include/pmap.h,
 >> rather than sun3/sun3x specific headers.
 >> (though there is difficulty on pmap_prefer(9))
 > 
 > For netbsd-9, the attached diff makes nfsserver module work on 3/60:

 This seems reasonable.

 > 
 > ---
 > Index: sys/arch/sun3/include/pmap.h
 > ===================================================================
 > RCS file: /cvsroot/src/sys/arch/sun3/include/pmap.h,v
 > retrieving revision 1.32
 > diff -u -p -d -r1.32 pmap.h
 > --- sys/arch/sun3/include/pmap.h	11 Dec 2009 18:31:27 -0000	1.32
 > +++ sys/arch/sun3/include/pmap.h	18 Jan 2020 17:24:36 -0000
 > @@ -37,6 +37,12 @@
 > #endif	/* SUN3X */
 > 
 > #ifdef _KERNEL
 > +/*
 > + * Some pmap(9) API macros should be defined here for module(7)
 > + * because they are common between sun3 and sun3x. (see PR/54869)
 > + */
 > +#define	pmap_update(pmap)		/* nothing (yet) */
 > +
 > void pmap_procwr(struct proc *, vaddr_t, size_t);
 > #endif
 > 
 > Index: sys/arch/sun3/include/pmap3.h
 > ===================================================================
 > RCS file: /cvsroot/src/sys/arch/sun3/include/pmap3.h,v
 > retrieving revision 1.49
 > diff -u -p -d -r1.49 pmap3.h
 > --- sys/arch/sun3/include/pmap3.h	7 Jan 2013 16:58:09 -0000	1.49
 > +++ sys/arch/sun3/include/pmap3.h	18 Jan 2020 17:24:36 -0000
 > @@ -64,8 +64,6 @@ extern segsz_t pmap_wired_pages(pmap_t);
 > /* We use the PA plus some low bits for device mmap. */
 > #define pmap_phys_address(addr) 	(addr)
 > 
 > -#define	pmap_update(pmap)		/* nothing (yet) */
 > -
 > /* Map a given physical region to a virtual region */
 > extern vaddr_t pmap_map(vaddr_t, paddr_t, paddr_t, int);
 > 
 > Index: sys/arch/sun3/include/pmap3x.h
 > ===================================================================
 > RCS file: /cvsroot/src/sys/arch/sun3/include/pmap3x.h,v
 > retrieving revision 1.29
 > diff -u -p -d -r1.29 pmap3x.h
 > --- sys/arch/sun3/include/pmap3x.h	3 Jun 2011 17:03:52 -0000	1.29
 > +++ sys/arch/sun3/include/pmap3x.h	18 Jan 2020 17:24:36 -0000
 > @@ -53,8 +53,6 @@ segsz_t pmap_count(pmap_t, int);
 > /* We use the PA plus some low bits for device mmap. */
 > #define pmap_phys_address(addr) 	(addr)
 > 
 > -#define	pmap_update(pmap)		/* nothing (yet) */
 > -
 > /* Map a given physical region to a virtual region */
 > vaddr_t pmap_map(vaddr_t, paddr_t, paddr_t, int);
 > 
 > 
 > ---
 > 
 > ---
 > Izumi Tsutsui
 > 

 -- thorpej

From: Paul Goyette <paul@whooppee.com>
To: gnats-bugs@netbsd.org
Cc: port-sun3-maintainer@netbsd.org, gnats-admin@netbsd.org, 
    netbsd-bugs@netbsd.org, tsutsui@ceres.dti.ne.jp
Subject: Re: port-sun3/54869: nfsserver module load failure on NetBSD/sun3
Date: Sat, 18 Jan 2020 10:21:22 -0800 (PST)

 > +#define	pmap_update(pmap)		/* nothing (yet) */

 Better to use

 +#define	pmap_update(pmap)	__nothing

 (which should elsewhere be defined as

 #define __nothing do {} while /* CONSTCOND */ 0




 +--------------------+--------------------------+-----------------------+
 | 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: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: paul@whooppee.com
Cc: gnats-bugs@netbsd.org, tsutsui@ceres.dti.ne.jp
Subject: Re: port-sun3/54869: nfsserver module load failure on NetBSD/sun3
Date: Sun, 19 Jan 2020 04:49:36 +0900

 > > +#define	pmap_update(pmap)		/* nothing (yet) */
 > 
 > Better to use
 > 
 > +#define	pmap_update(pmap)	__nothing

 I'll put it in a separate commit.
 (<m68k/pmap_motorola.h> has the same one but not related to this PR)

 > (which should elsewhere be defined as
 > 
 > #define __nothing do {} while /* CONSTCOND */ 0

 Actually it's defined as following in <sys/cdefs.h>:

 ---
 /*
  * To be used when an empty body is required like:
  *
  * #ifdef DEBUG
  * # define dprintf(a) printf(a)
  * #else
  * # define dprintf(a) __nothing
  * #endif
  *
  * We use ((void)0) instead of do {} while (0) so that it
  * works on , expressions.
  */
 #define __nothing	(/*LINTED*/(void)0)

 ---
 Izumi Tsutsui

From: "Izumi Tsutsui" <tsutsui@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54869 CVS commit: src/sys/arch/sun3/include
Date: Sat, 18 Jan 2020 20:47:15 +0000

 Module Name:	src
 Committed By:	tsutsui
 Date:		Sat Jan 18 20:47:15 UTC 2020

 Modified Files:
 	src/sys/arch/sun3/include: pmap.h pmap3.h pmap3x.h

 Log Message:
 Fix "modload nfsserver" failure on sun3.  PR/54869

 sun3 port has two definitions for different pmaps for sun3 (pmap3.h)
 and sun3x (pmap3x.h) and they are selected by _SUN3_ or _SUN3X_ macro,
 but neither of them is defined on module builds so common exported
 definitions required by module(7) should be in a common header,
 i.e. pmap.h.

 Should be pulled up to netbsd-9.


 To generate a diff of this commit:
 cvs rdiff -u -r1.32 -r1.33 src/sys/arch/sun3/include/pmap.h
 cvs rdiff -u -r1.49 -r1.50 src/sys/arch/sun3/include/pmap3.h
 cvs rdiff -u -r1.29 -r1.30 src/sys/arch/sun3/include/pmap3x.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54869 CVS commit: [netbsd-9] src/sys/arch/sun3/include
Date: Tue, 21 Jan 2020 15:41:44 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Tue Jan 21 15:41:43 UTC 2020

 Modified Files:
 	src/sys/arch/sun3/include [netbsd-9]: pmap.h pmap3.h pmap3x.h

 Log Message:
 Pull up following revision(s) (requested by tsutsui in ticket #636):

 	sys/arch/sun3/include/pmap.h: revision 1.33
 	sys/arch/sun3/include/pmap3.h: revision 1.50
 	sys/arch/sun3/include/pmap3x.h: revision 1.30

 Fix "modload nfsserver" failure on sun3.  PR/54869
 sun3 port has two definitions for different pmaps for sun3 (pmap3.h)
 and sun3x (pmap3x.h) and they are selected by _SUN3_ or _SUN3X_ macro,
 but neither of them is defined on module builds so common exported
 definitions required by module(7) should be in a common header,
 i.e. pmap.h.

 Should be pulled up to netbsd-9.


 To generate a diff of this commit:
 cvs rdiff -u -r1.32 -r1.32.68.1 src/sys/arch/sun3/include/pmap.h
 cvs rdiff -u -r1.49 -r1.49.42.1 src/sys/arch/sun3/include/pmap3.h
 cvs rdiff -u -r1.29 -r1.29.58.1 src/sys/arch/sun3/include/pmap3x.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Sat, 01 Feb 2020 05:39:05 +0000
State-Changed-Why:
Fixed and pulled up.


From: "Izumi Tsutsui" <tsutsui@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54869 CVS commit: src/sys/arch
Date: Sat, 1 Feb 2020 06:17:12 +0000

 Module Name:	src
 Committed By:	tsutsui
 Date:		Sat Feb  1 06:17:12 UTC 2020

 Modified Files:
 	src/sys/arch/m68k/include: pmap_motorola.h
 	src/sys/arch/sun2/include: pmap.h
 	src/sys/arch/sun3/include: pmap.h

 Log Message:
 Use "__nothing" macro defined in <sys/cdefs.h> for empty pmap_update().

 Suggested by pgoyette@ in PR/54869.


 To generate a diff of this commit:
 cvs rdiff -u -r1.34 -r1.35 src/sys/arch/m68k/include/pmap_motorola.h
 cvs rdiff -u -r1.26 -r1.27 src/sys/arch/sun2/include/pmap.h
 cvs rdiff -u -r1.33 -r1.34 src/sys/arch/sun3/include/pmap.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>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.