NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

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



>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:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jan 20 05:50:00 +0000 2018
>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.



Home | Main Index | Thread Index | Old Index