From: Arne Welzel Date: Wed, 21 Mar 2018 19:29:58 +0000 (+0100) Subject: bsd.own.mk: use -mno-unaligned-access on ARM X-Git-Url: http://zhaoyanbai.com/repos/icons/static/gitweb.js?a=commitdiff_plain;h=5e9e5b98f6f1bc482c78412565788f0e34ae42b6;p=minix.git bsd.own.mk: use -mno-unaligned-access on ARM Without this option, gcc may emit code accessing unaligned memory. This, and the fact that SCTRL.A (System Control Register - Alignment Check) is set to 1 in Minix causes data aborts when such code is encountered. This was the cause of #104. The `minix-service' executable caused unaligned memory accesses calling into getpwnam(). These then trigger data abort exceptions. On ARM, these were previously forwarded to `vm' as pagefaults. However, `vm' did not properly handle them, but instead allocated one page for the faulting address (over and over again) and then resumed the process at the faulting instruction (over and over again). This behavior masked the whole story as an OOM. Below the assembly version getpwent.c in which unaligned memory accesses are even highlighted... ... 341 ldr lr, [sp, #48] 342 cmp lr, #0 343 bne .L46 344 ldr r0, [r4] @ unaligned 345 add r1, r7, #5 346 str r0, [sp, #4] @ unaligned 347 ldr r4, [sp, #4] 348 mov r5, r4, asr #31 349 strd r4, [r8, #40] ... This should fix #104. It was tested on an actual Beaglebone Black. An alternative fix would be to disable alignment checking by setting SCTRL.A to 0 and allowing unaligned memory accesses. Change-Id: I4d366eb0af1b2936bca369fd28014fb829228ad5 --- diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk index f76d5f8a7..946e5dece 100644 --- a/share/mk/bsd.own.mk +++ b/share/mk/bsd.own.mk @@ -82,6 +82,11 @@ SMP_FLAGS += -DCONFIG_MAX_CPUS=${CONFIG_MAX_CPUS} CPPFLAGS+= ${SMP_FLAGS} +# Disabled unaligned accesses on ARM +.if !empty(MACHINE_ARCH:Mearm*) +CFLAGS+= -mno-unaligned-access +.endif + __uname_s!= uname -s .if ${__uname_s:Uunknown} == "Minix" USETOOLS?= never