minix/tests/arm: naive tests to cause data aborts

Some assembly code to cause unaligned access as well as
segmentation faults to exercise the data abort path.

Change-Id: Ie419114b76a8db849537a94fda781019cf14d50d
This commit is contained in:
Arne Welzel 2018-03-22 15:47:36 +01:00 committed by Lionel Sambuc
parent 94ec38dc78
commit c8a66a6226
6 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,9 @@
#
# Sorted using sort_set.pl in releasetools.
# to add an entry simply add it at the end of the
# file and run
# ../../../../releasetools/sort_set.pl < mi > out
# mv out mi
#
./usr/tests/minix-posix/test_arm_segfault minix-tests
./usr/tests/minix-posix/test_arm_unaligned minix-tests

View File

@ -126,6 +126,8 @@ PROGS+= test63 mod
OBJS.${o} += common.o OBJS.${o} += common.o
.endfor .endfor
.include "./arch/${MACHINE_ARCH}/Makefile.inc"
# LSC Make sure there is not leftover after a failed testrun # LSC Make sure there is not leftover after a failed testrun
clean: .PHONY .MAKE clean: .PHONY .MAKE
@rm -rf DIR* @rm -rf DIR*

View File

@ -0,0 +1,7 @@
PROGS+= test_arm_segfault
PROGS+= test_arm_unaligned
.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}
test_arm_segfault.o : test_arm_segfault.S
test_arm_unaligned.o : test_arm_unaligned.S

View File

@ -0,0 +1,16 @@
.text
.global main
main:
push {lr}
ldr r0, =0xDEADBEE0 /* Hopefully this is not mapped... */
ldr r1, [r0]
ldr r0, =0x01010100 /* In case we survived, try something else */
ldr r1, [r0]
ldr r0, =msg
bl puts
mov r0, #0 /* test should check for non-zero exit code / signal */
pop {pc}
msg:
.ascii "ERROR - caused no segfault\n"

View File

@ -0,0 +1,26 @@
.text
.global main
main:
push {lr}
mov r0, sp
/* This should work */
ldr r0, [sp]
/* Unalign it */
add r0, #2
/* Try a non-word aligned word-load, this may work if SCTRL.A == 0 */
ldr r1, [r0]
/* Load non-word aligned dword, should die even with SCTRL.A == 0 */
ldrd r2, r3, [r0]
ldr r0, =msg
bl puts
mov r0, #0 /* test should check for non-zero exit code / signal */
pop {pc}
msg:
.ascii "ERROR - caused no sigbus\n"

View File