Can handle process page faults by killing them
This commit is contained in:
@@ -112,6 +112,10 @@ QEMU_OPTS?=-m $(QEMU_MEM) \
|
||||
$(QEMU_DEVS) \
|
||||
-smp $(QEMU_SMP)
|
||||
|
||||
ifdef QEMU_DEBUG
|
||||
QEMU_OPTS+=-s -S
|
||||
endif
|
||||
|
||||
$(O)/sys/amd64/image.iso: $(O)/sys/amd64/kernel.elf \
|
||||
$(O)/sys/amd64/loader.elf \
|
||||
$(O)/sys/amd64/initrd.img \
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "sys/thread.h"
|
||||
#include "sys/debug.h"
|
||||
|
||||
extern void amd64_syscall_yield_stopped();
|
||||
|
||||
int amd64_pfault(uintptr_t cr2) {
|
||||
struct cpu *cpu = get_cpu();
|
||||
_assert(cpu);
|
||||
@@ -13,8 +15,8 @@ int amd64_pfault(uintptr_t cr2) {
|
||||
thr->pid);
|
||||
|
||||
kdebug("CR2 = %p\n", cr2);
|
||||
//0xffffff000220f668
|
||||
|
||||
amd64_syscall_yield_stopped();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,15 @@ amd64_exc_isr_14:
|
||||
movq %cr2, %rdi
|
||||
call amd64_pfault
|
||||
|
||||
// If fault handler returned zero, it means next task is selected
|
||||
// and should be run
|
||||
test %rax, %rax
|
||||
jnz 1f
|
||||
|
||||
// Ok, continue
|
||||
|
||||
|
||||
// Fail
|
||||
1:
|
||||
cli
|
||||
hlt
|
||||
|
||||
+19
@@ -21,6 +21,25 @@ static int cmd_exec(const char *cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp(cmd, "crash")) {
|
||||
uint32_t *value_ptr = (uint32_t *) 0;
|
||||
*value_ptr = 123;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(cmd, "fork-crash")) {
|
||||
int pid = fork();
|
||||
|
||||
if (pid == 0) {
|
||||
printf("Crashing child\n");
|
||||
uint32_t *value_ptr = (uint32_t *) 0;
|
||||
*value_ptr = 123;
|
||||
printf("Shouldn't run\n");
|
||||
exit(-1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(cmd, "hello")) {
|
||||
int res;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user