NetBSD Problem Report #52934

From www@NetBSD.org  Sat Jan 20 05:48:53 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 CF4EC7A1DC
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 20 Jan 2018 05:48:53 +0000 (UTC)
Message-Id: <20180120054845.44738803E9@mollari.NetBSD.org>
Date: Sat, 20 Jan 2018 05:48:45 +0000 (UTC)
From: oshima-ya@yagoto-urayama.jp
Reply-To: oshima-ya@yagoto-urayama.jp
To: gnats-bugs@NetBSD.org
Subject: The binary whitch has 4K p_aligin in the Elf Phdr cause to system hangup in the NetBSD/earm RPI (Kernel PageSize is 8k).
X-Send-Pr-Version: www-1.0

>Number:         52934
>Category:       port-arm
>Synopsis:       The binary whitch has 4K p_aligin in the Elf Phdr cause to system hangup in the NetBSD/earm RPI (Kernel PageSize is 8k).
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    port-arm-maintainer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jan 20 05:50:00 +0000 2018
>Closed-Date:    Sun Jun 20 07:14:12 +0000 2021
>Last-Modified:  Sun Jun 20 07:14:12 +0000 2021
>Originator:     Yasushi Oshima
>Release:        NetBSD/evbarm 8.0_BETA
>Organization:
>Environment:
NetBSD rpi 8.0_BETA NetBSD 8.0_BETA (RPI.201801180820Z) evbarm earmv6hf
>Description:
This problem will occur in NetBSD/earm 7.x, 8.0_BETA and later current.

When building pkgsrc/lang/go14 in NetBSD/earmv6 RPI, the go_bootstrap command built by go-toolchain causes to hang the system.
 * go_bootstrap binary is in work/go/pkg/tool/netbsd_arm/

This go_bootstrap has 4K p_align in Elf Phdr:

% readelf -l go_bootstrap
lf file type is EXEC (Executable file)
Entry point 0xa4ab8
There are 5 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x00010034 0x00010034 0x000a0 0x000a0 R   0x1000
  NOTE           0x000be8 0x00010be8 0x00010be8 0x00018 0x00018 R   0x4
  LOAD           0x000000 0x00010000 0x00010000 0x1c8ff0 0x1c8ff0 R E 0x1000
  LOAD           0x1c9000 0x001d9000 0x001d9000 0x1575d4 0x1575d4 R   0x1000
  LOAD           0x321000 0x00331000 0x00331000 0x12420 0x22df8 RW  0x1000

When run this go_bootstrap:

$ ./go_bootstrap
(no return)

When enter ddb from serial console:
Stopped in pid 338.1 (sh) at    netbsd:cpu_Debugger+0x4:        bx      r14
db> bt
0x9b8a9bc4: netbsd:plcomintr+0xc
0x9b8a9be4: netbsd:pic_dispatch+0x28
0x9b8a9c64: netbsd:pic_do_pending_ints+0x29c
0x9b8a9cfc: netbsd:irq_entry+0x60
0x9b8a9d94: netbsd:execve_runproc+0x1b0
0x9b8a9f1c: netbsd:execve1+0x44
0x9b8a9f34: netbsd:sys_execve+0x20
0x9b8a9fac: netbsd:syscall+0x10c
db> ps
PID    LID S CPU     FLAGS       STRUCT LWP *               NAME WAIT
338  >   1 7   0         0           9bc1ab80                 sh
39       1 3   0         0           9b383c20                 sh wait
723      1 3   0        80           9bc1a340                csh pause
664      1 3   0        80           9be4c5a0              login wait
733      1 2   0         0           999e3980               cron
604      1 3   0        80           9b382620              inetd kqueue
630      1 3   0        80           9bc1a8c0               qmgr kqueue
663      1 2   0         0           9b3828e0             pickup
596      1 2   0         0           999e3c40             master

This shows that syscall execve() does not return.


The default page_size of RPI's earm kernel is 8k.

% getconf PAGE_SIZE
8192

When change p_align of go_bootstrap to 8k or higher, this problem does not appear.

Also when use a custom kernel - a pagesize to 4k by add config 
options PGSHIFT=12, this will not occur, too.

The go14 toolchain's linker sets p_align to 4k. It will be worse of Go,
and it has been changed to 8K when go 1.8 or later.
But system hangup will be a problem of NetBSD's kernel.

I don't know whether this problem will occur on other arch.

>How-To-Repeat:
Make pkgsrc/lang/go14 on NetBSD/evbearm RPI.

For re-produce, the problem binary (go_bootstrap) is here:
 http://www.yagoto-urayama.jp/~oshimaya/netbsd/files/goarm/original/go_bootstrap.gz
 This causes a system hangup.

The binary which has been changed p_align 4k to 64k:
 http://www.yagoto-urayama.jp/~oshimaya/netbsd/files/goarm/patchedone/go_bootstrap.gz
 This does not cause a system hangup, but will SEGV by another problem of go.

The binary which has been changed p_align and fix another problems:
 http://www.yagoto-urayama.jp/~oshimaya/netbsd/files/goarm/patchedall/go_bootstrap.gz

 This works well and show a usage.

All patches for go14 is here:
 https://github.com/oshimaya/pkgsrc/tree/master/lang/go14/patches/
For changing a p_align is:
 https://github.com/oshimaya/pkgsrc/blob/master/lang/go14/patches/patch-src_cmd_5l_obj.c

>Fix:
none.

>Release-Note:

>Audit-Trail:
From: Nick Hudson <skrll@netbsd.org>
To: gnats-bugs@NetBSD.org, port-arm-maintainer@netbsd.org,
 gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc: 
Subject: Re: port-arm/52934: The binary whitch has 4K p_aligin in the Elf Phdr
 cause to system hangup in the NetBSD/earm RPI (Kernel PageSize is 8k).
Date: Sat, 20 Jan 2018 12:55:10 +0000

 This is a multi-part message in MIME format.
 --------------4B9AB0682FF65F322F1B0336
 Content-Type: text/plain; charset=utf-8; format=flowed
 Content-Transfer-Encoding: 7bit

 On 01/20/18 05:50, oshima-ya@yagoto-urayama.jp wrote:
 >> Number:         52934
 >> Category:       port-arm
 >> Synopsis:       The binary whitch has 4K p_aligin in the Elf Phdr cause to system hangup in the NetBSD/earm RPI (Kernel PageSize is 8k).
 I think the correct fix is to mark as 8K p_align. This patch should do it

 Nick

 --------------4B9AB0682FF65F322F1B0336
 Content-Type: text/x-patch;
  name="arm.pagesize.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="arm.pagesize.diff"

 Index: external/gpl3/binutils/dist/ld/emulparams/armelf_nbsd.sh
 ===================================================================
 RCS file: /cvsroot/src/external/gpl3/binutils/dist/ld/emulparams/armelf_nbsd.sh,v
 retrieving revision 1.9
 diff -u -p -r1.9 armelf_nbsd.sh
 --- external/gpl3/binutils/dist/ld/emulparams/armelf_nbsd.sh	11 Oct 2016 07:05:29 -0000	1.9
 +++ external/gpl3/binutils/dist/ld/emulparams/armelf_nbsd.sh	20 Jan 2018 12:54:55 -0000
 @@ -1,5 +1,5 @@
  . ${srcdir}/emulparams/armelf.sh
 -MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
 +COMMONPAGESIZE=0x2000
  TEXT_START_ADDR=0x00010000
  TARGET2_TYPE=got-rel
  GENERATE_PIE_SCRIPT=yes

 --------------4B9AB0682FF65F322F1B0336--

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/52934 CVS commit: src/sys/arch/arm/arm
Date: Sat, 20 Jan 2018 09:43:25 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Sat Jan 20 14:43:25 UTC 2018

 Modified Files:
 	src/sys/arch/arm/arm: cpufunc_asm_arm11x6.S

 Log Message:
 PR/52934: Yasushi Oshima: Apply the erratum fix that was applied to wbinv_range
 to isync_range so that we don't hang when we try to sync from execcmd_readvn().
 XXX: pullup 8


 To generate a diff of this commit:
 cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/arm/cpufunc_asm_arm11x6.S

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

From: Yasushi Oshima <oshima-ya@yagoto-urayama.jp>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: PR/52934 CVS commit: src/sys/arch/arm/arm
Date: Sun, 21 Jan 2018 11:34:48 +0900 (JST)

 > From: "Christos Zoulas" <christos@netbsd.org>
 > To: gnats-bugs@gnats.NetBSD.org
 > Cc: 
 > Subject: PR/52934 CVS commit: src/sys/arch/arm/arm
 > Date: Sat, 20 Jan 2018 09:43:25 -0500
 > 
 >  Module Name:	src
 >  Committed By:	christos
 >  Date:		Sat Jan 20 14:43:25 UTC 2018
 >  
 >  Modified Files:
 >  	src/sys/arch/arm/arm: cpufunc_asm_arm11x6.S
 >  
 >  Log Message:
 >  PR/52934: Yasushi Oshima: Apply the erratum fix that was applied to wbinv_range
 >  to isync_range so that we don't hang when we try to sync from execcmd_readvn().
 >  XXX: pullup 8
 >  

 The problem was solved by this change in current-kernel on my RPI.

 % ./go_bootstrap
 [1]   Abort trap              ./go_bootstrap
 % 

 Probably this is corrrect when p_align is smaller than a pagesize.

 I'll try in netbsd-8 later..

 Thanks.
 --
 Yasushi Oshima

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/52934 CVS commit: [netbsd-8] src/sys/arch/arm/arm
Date: Mon, 22 Jan 2018 12:32:38 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Mon Jan 22 12:32:38 UTC 2018

 Modified Files:
 	src/sys/arch/arm/arm [netbsd-8]: cpufunc_asm_arm11x6.S

 Log Message:
 Pull up following revision(s) (requested by skrll in ticket #507):
 	sys/arch/arm/arm/cpufunc_asm_arm11x6.S: revision 1.10
 PR/52934: Yasushi Oshima: Apply the erratum fix that was applied to wbinv_range
 to isync_range so that we don't hang when we try to sync from execcmd_readvn().
 XXX: pullup 8


 To generate a diff of this commit:
 cvs rdiff -u -r1.7.20.1 -r1.7.20.2 src/sys/arch/arm/arm/cpufunc_asm_arm11x6.S

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

From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/52934 CVS commit: [netbsd-7] src/sys/arch/arm/arm
Date: Mon, 19 Feb 2018 19:24:43 +0000

 Module Name:	src
 Committed By:	snj
 Date:		Mon Feb 19 19:24:43 UTC 2018

 Modified Files:
 	src/sys/arch/arm/arm [netbsd-7]: cpufunc_asm_arm11x6.S

 Log Message:
 Pull up following revision(s) (requested by skrll in ticket #1555):
 	sys/arch/arm/arm/cpufunc_asm_arm11x6.S: 1.10
 PR/52934: Yasushi Oshima: Apply the erratum fix that was applied to wbinv_range
 to isync_range so that we don't hang when we try to sync from execcmd_readvn().


 To generate a diff of this commit:
 cvs rdiff -u -r1.7.2.1 -r1.7.2.2 src/sys/arch/arm/arm/cpufunc_asm_arm11x6.S

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

State-Changed-From-To: open->feedback
State-Changed-By: maya@NetBSD.org
State-Changed-When: Mon, 04 Jun 2018 09:18:42 +0000
State-Changed-Why:
Is the change mentioned by nick also necessary? do binaries get marked with 4k p_align normally? how about Go binaries?


From: Yasushi Oshima <oshima-ya@yagoto-urayama.jp>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-arm/52934 (The binary whitch has 4K p_aligin in the Elf
 Phdr cause to system hangup in the NetBSD/earm RPI (Kernel PageSize is
 8k).)
Date: Sat, 14 Jul 2018 15:04:39 +0900 (JST)

 > Is the change mentioned by nick also necessary? do binaries get marked with 4k p_align normally? how about Go binaries?

 I think that it is not necessary.

 If a binary which marked p_align with 4k, it will not work on earmv6
 or earmv7 with 8k PAGESIZE.
 In the current go/arm binary, p_align has been changed to 64k, and
 now working. This is the same as standard toolchain(Gnu ld,...).

 Thanks.

State-Changed-From-To: feedback->closed
State-Changed-By: skrll@NetBSD.org
State-Changed-When: Sun, 20 Jun 2021 07:14:12 +0000
State-Changed-Why:
Appears to be fixed. Please open a new PR if further problems exist.


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