Opened 6 years ago

Closed 6 years ago

#783 closed defect (fixed)

Uspace code targeted for ARMv4 contains ARMv5 instructions

Reported by: Jakub Jermář Owned by: Jiří Zárevúcky
Priority: major Milestone: 0.9.1
Component: gcc/libgcc/arm32 Version: mainline
Keywords: gta02 Cc:
Blocker for: Depends on:
See also:

Description

As of commit 21374e03107e5b1bc843b1d8e853a323ab9db107, HelenOS fails to boot on the OpenMoko Freerunner GTA 02 phone like this:

HelenOS bootloader, release 0.7.2 (Boosted Effort), revision 21374e031
Built on 2018-12-17 22:54:28 for arm32
Copyright (c) 2001-2018 HelenOS project
Boot loader: 0x30008000 -> 0x30015d3c

Memory statistics
 0x30015000|0x30015000: bootstrap stack
 0x30010000|0x30010000: bootstrap page table
 0x30015838|0x30015838: boot info structure
 0xb0a08000|0x30a08000: kernel entry point
Boot loader: 0x30008000 -> 0x30015d3c
Payload: 0x30015d3c -> 0x309af53c
Kernel load address: 0x30a08000
Kernel start: 0xb0a08000
RAM end: 0x31a08000 (16777216 bytes available)

Inflating components ... 
 0xb0a08000|0x30a08000: kernel.elf image (616612/616612 bytes)
 0xb0a9f000|0x30a9f000: ns image (110400/110400 bytes)
 0xb0aba000|0x30aba000: loader image (110328/110328 bytes)
 0xb0ad5000|0x30ad5000: init image (138192/138192 bytes)
 0xb0af7000|0x30af7000: locsrv image (126016/126016 bytes)
 0xb0b16000|0x30b16000: rd image (116756/116756 bytes)
 0xb0b33000|0x30b33000: vfs image (140676/140676 bytes)
 0xb0b56000|0x30b56000: logger image (122672/122672 bytes)
 0xb0b74000|0x30b74000: ext4fs image (181492/181492 bytes)
 0xb0ba1000|0x30ba1000: initrd.img image (8388608/8388608 bytes)
Done.
Booting the kernel...
SPARTAN kernel, release 0.7.2 (Boosted Effort), revision 21374e031
Built on 2018-12-17 22:54:28 for arm32
Copyright (c) 2001-2018 HelenOS project
Detected 1 CPU(s), 131040 KiB free memory

######> Kernel panic on cpu0 due to a failed assertion: <######
waitq_sleep_timeout() at generic/src/synch/waitq.c:241:
(!PREEMPTION_DISABLED) || (PARAM_NON_BLOCKING(flags, usec))

CURRENT=0xb05f2000: pe=1 thread=0xb05f0000 task=0xb05ef000 cpu=0xb05eb008 as=0xb0009000 magic=0xfacefeed
thread="kinit"
task="kernel"
0xb05f3dfc: generic/src/debug/stacktrace.o:stack_trace()+0x0000001c
0xb05f3e2c: generic/src/debug/panic.o:panic_common()+0x00000178
0xb05f3e74: generic/src/synch/waitq.o:waitq_sleep_timeout()+0x00000104
0xb05f3e84: generic/src/synch/semaphore.o:_semaphore_down_timeout()+0x00000014
0xb05f3ed4: generic/src/synch/mutex.o:_mutex_lock_timeout()+0x00000044
0xb05f3f2c: generic/src/mm/as.o:as_page_fault()+0x00000060
0xb05f3f64: arch/arm32/src/mm/page_fault.o:data_abort()+0x00000240
0xb05f3f9c: generic/src/interrupt/interrupt.o:exc_dispatch()+0x000000cc
0xb05f3fb4: arch/arm32/src/ras.o:ras_check()+0x00000030
cpu0: halted

Change History (10)

comment:1 by Jakub Jermář, 6 years ago

After fixing the zeroed contex_t::cpu_mode in commit 336b7393ec3e072439a0e045724088e669be87d4, the boot now reaches userspace. However, some tasks crash:

HelenOS bootloader, release 0.7.2 (Boosted Effort), revision 485281ee1
Built on 2018-12-18 21:07:59 for arm32
Copyright (c) 2001-2018 HelenOS project
Boot loader: 0x30008000 -> 0x30015d3c

Memory statistics
 0x30015000|0x30015000: bootstrap stack
 0x30010000|0x30010000: bootstrap page table
 0x30015838|0x30015838: boot info structure
 0xb0a08000|0x30a08000: kernel entry point
Boot loader: 0x30008000 -> 0x30015d3c
Payload: 0x30015d3c -> 0x309af53c
Kernel load address: 0x30a08000
Kernel start: 0xb0a08000
RAM end: 0x31a08000 (16777216 bytes available)

Inflating components ... 
 0xb0a08000|0x30a08000: kernel.elf image (616612/616612 bytes)
 0xb0a9f000|0x30a9f000: ns image (110400/110400 bytes)
 0xb0aba000|0x30aba000: loader image (110328/110328 bytes)
 0xb0ad5000|0x30ad5000: init image (138192/138192 bytes)
 0xb0af7000|0x30af7000: locsrv image (126016/126016 bytes)
 0xb0b16000|0x30b16000: rd image (116756/116756 bytes)
 0xb0b33000|0x30b33000: vfs image (140676/140676 bytes)
 0xb0b56000|0x30b56000: logger image (122672/122672 bytes)
 0xb0b74000|0x30b74000: ext4fs image (181492/181492 bytes)
 0xb0ba1000|0x30ba1000: initrd.img image (8388608/8388608 bytes)
Done.
Booting the kernel...
SPARTAN kernel, release 0.7.2 (Boosted Effort), revision 485281ee1
Built on 2018-12-18 21:07:59 for arm32
Copyright (c) 2001-2018 HelenOS project
Detected 1 CPU(s), 131040 KiB free memory
Kernel console ready (press any key to activate)
Program loader at 0xc01b2000
RAM disk at 0x30ba1000 (size 8388608 bytes)
Task init:ns (2) killed due to an exception at program counter 0x00110b48.
r0 =0x00000100  r1 =0x00000010  r2 =0x0000000f  r3 =0x00000000
r4 =0x00000010  r5 =0x000002c8  r6 =0x00135000  r7 =0x00123d34
r8 =0x00122d14  r9 =0x00133ffc  r10=0x00000000  fp =0x7fffff74
r12=0x7fffff78  sp =0x7fffff48  lr =0x00107b18  spsr=0x60000050
0x7fffff74: 0x00110b48()
0x7fffff8c: 0x001082c4()
0x7fffffac: 0x0010cec4()
0x7fffffc4: 0x0010c5f8()
0x7fffffdc: 0x001012f8()
0x7fffffec: 0x00100260()
0x7ffffffc: 0x001001ec()
Kill message: Undefined instruction.

The instruction before the reported address is in udivsi3:

  110b44:       e16f2f11        clz     r2, r1             <= ARMv5 instruction
  110b48:       e262201f        rsb     r2, r2, #31

CLZ is supported in ARMv5, but GTA02 is ARMv4 only.

comment:2 by Jiří Zárevúcky, 6 years ago

Sounds like libgcc arm multilib is not configured correctly.

comment:3 by Jakub Jermář, 6 years ago

Milestone: 0.8.00.9.1

comment:4 by Jakub Jermář, 6 years ago

This is my configuration:

$ /usr/local/cross/bin/arm-helenos-gcc --print-multi-lib
.;
thumb;@mthumb
arm/autofp/v5te/fpu;@marm@mfpu=auto@march=armv5te+fp@mfloat-abi=hard
arm/autofp/v7a/fpu;@marm@mfpu=auto@march=armv7-a+fp@mfloat-abi=hard
thumb/autofp/v7a/fpu;@mthumb@mfpu=auto@march=armv7-a+fp@mfloat-abi=hard

comment:5 by Jakub Jermář, 6 years ago

Component: helenos/kernel/arm32helenos/gcc/libgcc
Summary: HelenOS does not boot on GTA02Uspace code targeted for AMRv4 contains ARMv5 instructions

comment:6 by Jakub Jermář, 6 years ago

Summary: Uspace code targeted for AMRv4 contains ARMv5 instructionsUspace code targeted for ARMv4 contains ARMv5 instructions

comment:7 by Jiří Zárevúcky, 6 years ago

Owner: set to Jiří Zárevúcky
Status: newassigned

comment:8 by Jiří Zárevúcky, 6 years ago

Somehow I omitted support for ARMv4 entirely — it defaulted to ARMv5.
It should be fixed now (9546de7).

comment:9 by Jakub Jermář, 6 years ago

Thanks for fixing this!
Successfully tested on gta02, rpi and bbone. Please feel free to close the ticket.

comment:10 by Jiří Zárevúcky, 6 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.