NetBSD Problem Report #45895

From martin@duskware.de  Tue Jan 31 14:27:11 2012
Return-Path: <martin@duskware.de>
Received: from mail.netbsd.org (unknown [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id 6FBFC63B8C5
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 31 Jan 2012 14:27:11 +0000 (UTC)
Message-Id: <20120131140854.26B9DAF581D@emmas.aprisoft.de>
Date: Tue, 31 Jan 2012 15:08:54 +0100 (CET)
From: martin@NetBSD.org
Reply-To: martin@NetBSD.org
To: gnats-bugs@gnats.NetBSD.org
Subject: kernel modules not working on sparc64
X-Send-Pr-Version: 3.95

>Number:         45895
>Category:       port-sparc64
>Synopsis:       kernel modules not working on sparc64
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    martin
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jan 31 14:30:00 +0000 2012
>Closed-Date:    Mon Feb 06 10:42:52 +0000 2012
>Last-Modified:  Mon Feb 06 10:45:01 +0000 2012
>Originator:     Martin Husemann
>Release:        NetBSD 5.99.62
>Organization:
The NetBSD Foundation, Inc.
>Environment:
System: NetBSD nelly.aprisoft.de 5.99.62 NetBSD 5.99.62 (NELLY.MP) #193: Tue Jan 31 09:19:40 CET 2012 martin@emmas.aprisoft.de:/nelly/usr/src/sys/arch/sparc64/compile/NELLY.MP sparc64
Architecture: sparc64
Machine: sparc64
>Description:

Module-autoloading of tmpfs fails with

 text_access_fault: pc=10152f420 va=10152e000

>How-To-Repeat:

Run a MODULAR kernel, mount -t tmpfs.

>Fix:
n/a

>Release-Note:

>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/45895: kernel modules not working
Date: Tue, 31 Jan 2012 17:21:41 +0100

 Reproduced it on another machine with working DDB:

 Starting syslogd.
 Mounting all filesystems...
 text_access_fault: pc=10152f640 va=10152e000
 kernel trap 64: +fast instruction access MMU miss
 Stopped in pid 173.1 (mount_kernfs) at  10152f640:      undefined
 module_do_load(0, 0, 0, 0, 0, 2) at netbsd:module_do_load+0x6b4  
 module_autoload(42adc28, 2, 1a, 0, 42aa000, 42adc28) at netbsd:module_autoload+0
 xbc                                                                            
 do_sys_mount(438f800, 0, 100f40, ffffffffffffb338, 0, 0) at netbsd:do_sys_mount+
 0x544                                                                          
 sys___mount50(438f800, 42addd0, 42ade10, 1, 6e, 40414f28) at netbsd:sys___mount5
 0+0x28                                                                         
 syscall_plain(42aded0, 42addd0, 40745040, ffffffffffffaa81, 40745040, 5) at netb
 sd:syscall_plain+0x134                                                         

 which is line 1060:

 1058            prev_active = module_active;
 1059            module_active = mod;
 1060            error = (*mi->mi_modcmd)(MODULE_CMD_INIT, filedict ? filedict : props);
 1061            module_active = prev_active;

 and obviously mi->mi_modcmd does not point to a mapped page.

 Martin

State-Changed-From-To: open->closed
State-Changed-By: martin@NetBSD.org
State-Changed-When: Thu, 02 Feb 2012 12:05:40 +0000
State-Changed-Why:
Works again after recent kmem changes


Responsible-Changed-From-To: kern-bug-people->martin
Responsible-Changed-By: martin@NetBSD.org
Responsible-Changed-When: Sun, 05 Feb 2012 09:17:19 +0000
Responsible-Changed-Why:
I'll take care of it


State-Changed-From-To: closed->analyzed
State-Changed-By: martin@NetBSD.org
State-Changed-When: Sun, 05 Feb 2012 09:17:19 +0000
State-Changed-Why:
It is not realy fixed yet, just works sometimes by chance


From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-sparc64/45895: kernel modules not working
Date: Sun, 5 Feb 2012 10:23:20 +0100

 This depends on the code gen options we use for kernel and modules, and
 where the modules are placed relative to kernel text/data. We either
 need to move to other code model options for both kernel and modules
 (wastefull), or provide a module_map with a reserved VA range for
 loading modules (easy).

 A very simple way to reproduce this issue reliably is to move IODEV_BASE
 up by some MB and use the new free space for a module_map.

 The map is easy to implement, but picking a "proper" VA range is not
 that easy. I hope to have a patch (good enough for now) soon, we can
 discuss fine tuning later.

 Martin

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-sparc64/45895: kernel modules not working
Date: Sun, 5 Feb 2012 11:42:56 +0100

 --sm4nu43k4a2Rpi4c
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline

 Here is a patch that seems to work for me.

 Martin

 --sm4nu43k4a2Rpi4c
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename=patch

 Index: machdep.c
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/sparc64/sparc64/machdep.c,v
 retrieving revision 1.264
 diff -u -r1.264 machdep.c
 --- machdep.c	27 Jan 2012 18:53:03 -0000	1.264
 +++ machdep.c	5 Feb 2012 10:39:27 -0000
 @@ -75,6 +75,7 @@

  #include "opt_ddb.h"
  #include "opt_multiprocessor.h"
 +#include "opt_modular.h"
  #include "opt_compat_netbsd.h"
  #include "opt_compat_svr4.h"
  #include "opt_compat_sunos.h"
 @@ -152,6 +155,11 @@
  #endif

  extern vaddr_t avail_end;
 +#ifdef MODULAR
 +vaddr_t module_start, module_end;
 +static struct vm_map module_map_store;
 +extern struct vm_map *module_map;
 +#endif

  int	physmem;

 @@ -208,6 +216,12 @@
  #if 0
  	pmap_redzone();
  #endif
 +
 +#ifdef MODULAR
 +	uvm_map_setup(&module_map_store, module_start, module_end, 0);
 +	module_map_store.pmap = pmap_kernel();
 +	module_map = &module_map_store;
 +#endif
  }

  /*
 Index: pmap.c
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/sparc64/sparc64/pmap.c,v
 retrieving revision 1.275
 diff -u -r1.275 pmap.c
 --- pmap.c	12 Jul 2011 07:51:34 -0000	1.275
 +++ pmap.c	5 Feb 2012 10:39:28 -0000
 @@ -33,6 +33,7 @@

  #include "opt_ddb.h"
  #include "opt_multiprocessor.h"
 +#include "opt_modular.h"

  #include <sys/param.h>
  #include <sys/malloc.h>
 @@ -669,6 +670,9 @@
  void
  pmap_bootstrap(u_long kernelstart, u_long kernelend)
  {
 +#ifdef MODULAR
 +	extern vaddr_t module_start, module_end;
 +#endif
  	extern char etext[], data_start[];	/* start of data segment */
  	extern int msgbufmapped;
  	struct mem_region *mp, *mp1, *avail, *orig;
 @@ -1176,6 +1181,18 @@

  	vmmap = (vaddr_t)reserve_dumppages((void *)(u_long)vmmap);

 +#ifdef MODULAR
 +	/*
 +	 * Reserve 16 MB of VA for module loading. Right now our full
 +	 * GENERIC kernel is about 13 MB, so this looks good enough.
 +	 * If we make this bigger, we should adjust the KERNEND and
 +	 * associated defines in param.h.
 +	 */
 +	module_start = vmmap;
 +	vmmap += 16 * 1024*1024;
 +	module_end = vmmap;
 +#endif
 +
  	/*
  	 * Set up bounds of allocatable memory for vmstat et al.
  	 */

 --sm4nu43k4a2Rpi4c--

State-Changed-From-To: analyzed->closed
State-Changed-By: martin@NetBSD.org
State-Changed-When: Mon, 06 Feb 2012 10:42:52 +0000
State-Changed-Why:
Fixed


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/45895 CVS commit: src/sys/arch/sparc64/sparc64
Date: Mon, 6 Feb 2012 10:40:27 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Mon Feb  6 10:40:26 UTC 2012

 Modified Files:
 	src/sys/arch/sparc64/sparc64: machdep.c pmap.c

 Log Message:
 Provide a module_map (16 MB for now) to load modules close to kernel text
 and data.

 Fixes PR port-sparc64/45895. Ok: releng


 To generate a diff of this commit:
 cvs rdiff -u -r1.264 -r1.265 src/sys/arch/sparc64/sparc64/machdep.c
 cvs rdiff -u -r1.275 -r1.276 src/sys/arch/sparc64/sparc64/pmap.c

 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.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.