15 Commits

Author SHA1 Message Date
745732f9e0 works better, but weird failures 2018-03-25 23:02:18 +02:00
9b46824596 Create README.md 2018-03-25 23:02:18 +02:00
b08f83a54b Remove unncessary variable definitions 2018-03-25 23:02:18 +02:00
648fa467d6 ARM: Compile whole tree with clang.
Note: GCC is still the default compiler, to use clang do the following:

 $ BUILDVARS="" ./releasetools/arm_sdimage.sh
2018-03-25 23:02:17 +02:00
40308cd1ed ARM: Remove linker script for VM.
The linker script has been replaced by small adaptations to make sure
the required structures are aligned at runtime per hardware
requirements.

In some cases, the linker script failed to guarantee proper physical
addresses alignement.

This is important for page entries descriptors which are required to be
aligned as the MMU doesn't support unaligned accesses to those.

Change-Id: I3e22d3da102230be2534b4261e2c6c937e367de6
2018-03-25 23:02:17 +02:00
Arne Welzel
35b65c5af1 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
2018-03-25 17:44:11 +02:00
Arne Welzel
0dd719f1bd kernel/arm: send SIGSEGV to processes
On second thought, handle unknown faults caused by processes by sending
SIGSEGV to them instead of bringing the whole system to a grind.

arm/archconst: use values defined in armreg.h

Change-Id: Ieed5bb06910ab0c8eef1e68b0b4eec680867acd3
2018-03-25 15:16:29 +02:00
Arne Welzel
5e9e5b98f6 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
2018-03-25 11:23:21 +02:00
Arne Welzel
7c3424c244 kernel/arm: do not treat all data aborts as pagefaults
For now, distinguish alignment, translation and permission faults.
The first kind of faults cause the kernel to send SIGBUS to the
process causing the fault, the latter two are forwarded to `vm' as
pagefaults. Previously, any data abort was forwarded to `vm' as
a pagefault, resulting in hard to debug issue #104.

Any unhandled fault status results in a disaster. This seems
better than naively hoping `vm' can do something about it.

Change-Id: I526f575bb2681e087e20fd49c5c0846cdd450c31
2018-03-25 11:22:35 +02:00
Marcelo Alencar
a27e58e1f7 Fix brazilian ABNT2 keymap
This adds two missing keys (0x73 and 0x7e) and fixes KP_PERIOD (it
should type a comma, not a period), as mentioned in

https://groups.google.com/d/msg/minix3/Pezep_HOL3I/mnfZXAeLsTMJ

Closes #247

Change-Id: Id85d04e36adcaa1a502cac8e5013396ea92502fe
2018-03-23 07:38:56 +01:00
blackdragonepic
4667c87c4d remove a duplicate include
removed #include <minix/type.h> duplicate

Closes #246

Change-Id: Icd575c452d562eb601133157a77d9d995ce043e9
2018-03-23 07:38:25 +01:00
Nik Nyby
2117e99cef Update usage man page: remove reference to /usr/ast
This directory no longer exists, probably since the netbsd file layout
re-organization.

Closes #244

Change-Id: Ie4e3761dbf3adbdd76cb6323f920a4abab6b29d5
2018-03-23 07:37:54 +01:00
Nik Nyby
9866ad31fd fs/mfs: Remove a few assert.h includes
Those are unnecessary.

Closes #241

Change-Id: I26db0f07c65e7d078e642001b97e6d4313e6660a
2018-03-23 07:36:59 +01:00
Nik Nyby
24f3305be0 mkfs.mfs: fix typo in error message
Closes #242

Change-Id: I91ec2b36b2abfa897a43c97d886578fd28a5c768
2018-03-23 07:33:25 +01:00
Krystian Lewandowski
b2ee0702ff pci server crashes during boot on Qubes OS
I tried to launch Minix3 in Qubes OS. While there is no problem to boot
minix as a qube (in Qubes OS terminology) before 3641562, it fails with
the commit (and after). I didn't digg into PCI handling but this change
fixes the problem. Minix handles NULL case from pci_subclass_name.

Change-Id: I162424d92b613598e6eb845a71f90a02e31041db
2017-11-16 23:05:02 +01:00
16 changed files with 116 additions and 14 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

@@ -53,7 +53,7 @@
K(GRAVE_ACCENT) = { '\'', '"', A('\''),A('\''),A('"'), C('@') },
K(COMMA) = { ',', '<', A(','), A(','), A('<'), C('@') },
K(PERIOD) = { '.', '>', A('.'), A('.'), A('>'), C('@') },
K(SLASH) = { 59, 58, A(59), A(58), A(59), C('@') },
K(SLASH) = { ';', ':', A(';'), A(';'), A(':'), C('@') },
K(CAPS_LOCK) = { CALOCK, CALOCK, CALOCK, CALOCK, CALOCK, CALOCK },
K(F1) = { F1, SF1, AF1, AF1, ASF1, CF1 },
K(F2) = { F2, SF2, AF2, AF2, ASF2, CF2 },
@@ -94,10 +94,11 @@
K(KP_8) = { NUP, '8', AUP, AUP, A('8'), CUP },
K(KP_9) = { NPGUP, '9', APGUP, APGUP, A('9'), CPGUP },
K(KP_0) = { NINSRT, '0', AINSRT, AINSRT, A('0'), CINSRT },
K(KP_PERIOD) = { NDEL, '.', A(DEL), A(DEL), A('.'), DEL },
K(KP_PERIOD) = { NDEL, ',', A(DEL), A(DEL), A(','), DEL },
K(EUROPE_2) = { '\\', '|', A('\\'),A('|'), A('\\'),C('@') },
K(APPLICATION) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
K(KP_EQUAL) = { '?', 0, 0, 0, 0, 0 },
K(I10L_1) = { '/', '?', A('/'), A('/'), A('?'), C('@') },
K(EQUAL_SIGN) = { '.', '.', 0, 0, 0, 0 },
K(SYSREQ) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
K(LEFT_CTRL) = { LCTRL, LCTRL, LCTRL, LCTRL, LCTRL, LCTRL },
K(LEFT_SHIFT) = { LSHIFT, LSHIFT, LSHIFT, LSHIFT, LSHIFT, LSHIFT },

View File

@@ -1,7 +1,6 @@
#include "fs.h"
#include "inode.h"
#include "clean.h"
#include <assert.h>
/*===========================================================================*
* fs_sync *

View File

@@ -1,6 +1,5 @@
#include "fs.h"
#include <string.h>
#include <assert.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
#include "inode.h"

View File

@@ -109,6 +109,36 @@ static void pagefault( struct proc *pr,
return;
}
static void
data_abort(int is_nested, struct proc *pr, reg_t *saved_lr,
struct ex_s *ep, u32_t dfar, u32_t dfsr)
{
/* Extract fault status bit [0:3, 10] from DFSR */
u32_t fs = dfsr & 0x0F;
fs |= ((dfsr >> 6) & 0x10);
/* Translation and permission faults are handled as pagefaults. */
if (is_trans_fault(fs) || is_perm_fault(fs)) {
pagefault(pr, saved_lr, is_nested, dfar, dfsr);
} else if (!is_nested) {
/* A user process caused some other kind of data abort. */
int signum = SIGSEGV;
if (is_align_fault(fs)) {
signum = SIGBUS;
} else {
printf("KERNEL: unknown data abort by proc %d sending "
"SIGSEGV (dfar=0x%lx dfsr=0x%lx fs=0x%lx)\n",
proc_nr(pr), dfar, dfsr, fs);
}
cause_sig(proc_nr(pr), signum);
} else { /* is_nested */
printf("KERNEL: inkernel data abort - disaster (dfar=0x%lx "
"dfsr=0x%lx fs=0x%lx)\n", dfar, dfsr, fs);
inkernel_disaster(pr, saved_lr, ep, is_nested);
}
}
static void inkernel_disaster(struct proc *saved_proc,
reg_t *saved_lr, struct ex_s *ep,
int is_nested)
@@ -171,7 +201,7 @@ void exception_handler(int is_nested, reg_t *saved_lr, int vector)
}
if (vector == DATA_ABORT_VECTOR) {
pagefault(saved_proc, saved_lr, is_nested, read_dfar(), read_dfsr());
data_abort(is_nested, saved_proc, saved_lr, ep, read_dfar(), read_dfsr());
return;
}

View File

@@ -21,6 +21,16 @@
#define INTERRUPT_VECTOR 6
#define FAST_INTERRUPT_VECTOR 7
/* Data abort helper */
#define is_align_fault(fault_status) \
((fault_status) == FAULT_ALIGN_0)
#define is_trans_fault(fault_status) \
(((fault_status) == FAULT_TRANS_S) || ((fault_status) == FAULT_TRANS_P))
#define is_perm_fault(fault_status) \
(((fault_status) == FAULT_PERM_S) || ((fault_status) == FAULT_PERM_P))
/*
* defines how many bytes are reserved at the top of the kernel stack for global
* information like currently scheduled process or current cpu id

View File

@@ -876,11 +876,6 @@ When exiting MINIX running under DOS the Boot Monitor's
.B exit
command will return you to the DOS prompt. The Boot Monitor and MINIX
are together just a pretty big DOS program as far DOS is concerned.
.SH FILES
.TP 12
.B /usr/ast
Honorary home directory of Andrew S. Tanenbaum. Doubles as the place where
the default setup for a new user is found.
.SH "SEE ALSO"
.BR dosminix (8),
.BR monitor (8),

View File

@@ -13,7 +13,6 @@
#include <minix/callnr.h>
#include <minix/com.h>
#include <minix/ds.h>
#include <minix/type.h>
#include <minix/endpoint.h>
#include <minix/minlib.h>
#include <minix/type.h>

View File

@@ -126,6 +126,8 @@ PROGS+= test63 mod
OBJS.${o} += common.o
.endfor
.include "./arch/${MACHINE_ARCH}/Makefile.inc"
# LSC Make sure there is not leftover after a failed testrun
clean: .PHONY .MAKE
@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

View File

@@ -264,7 +264,7 @@ main(int argc, char *argv[])
/* Determine the size of the device if not specified as -b or proto. */
maxblocks = sizeup(argv[optind]);
if (bblocks != 0 && bblocks + fs_offset_blocks > maxblocks && !insertmode) {
errx(4, "Given size -b %d exeeds device capacity(%d)\n", bblocks, maxblocks);
errx(4, "Given size -b %d exceeds device capacity(%d)\n", bblocks, maxblocks);
}
if (argc - optind == 1 && bblocks == 0) {

View File

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

View File

@@ -617,7 +617,11 @@ pci_subclass_name(pcireg_t reg)
subclassp++;
}
return subclassp->name;
if (subclassp) {
return subclassp->name;
} else {
return NULL;
}
}
#endif /* defined(__minix) && defined(_PCI_SERVER) */