mirror of
https://github.com/drasko/codezero.git
synced 2026-11-30 20:54:21 +01:00
Added userland support for exregs/read, mm0 slightly more graceful for illegal access
This commit is contained in:
@@ -9,5 +9,6 @@
|
||||
struct fault_data;
|
||||
unsigned int vm_prot_flags(pte_t pte);
|
||||
void set_generic_fault_params(struct fault_data *fault);
|
||||
void fault_handle_error(struct fault_data *fault);
|
||||
|
||||
#endif /* __INITTASK_ARCH_MM_H__ */
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <arch/mm.h>
|
||||
#include <task.h>
|
||||
#include <vm_area.h>
|
||||
#include <l4lib/exregs.h>
|
||||
|
||||
/* Extracts generic protection flags from architecture-specific pte */
|
||||
unsigned int vm_prot_flags(pte_t pte)
|
||||
@@ -38,6 +39,17 @@ void arch_print_fault_params(struct fault_data *fault) { }
|
||||
#endif
|
||||
|
||||
|
||||
void fault_handle_error(struct fault_data *fault)
|
||||
{
|
||||
struct task_ids ids;
|
||||
|
||||
/* Suspend the task */
|
||||
ids.tid = fault->task->tid;
|
||||
BUG_ON(l4_thread_control(THREAD_SUSPEND, &ids) < 0);
|
||||
|
||||
BUG();
|
||||
}
|
||||
|
||||
/*
|
||||
* PTE STATES:
|
||||
* PTE type field: 00 (Translation fault)
|
||||
|
||||
@@ -850,19 +850,19 @@ int do_page_fault(struct fault_data *fault)
|
||||
if (vma_flags & VM_NONE) {
|
||||
printf("Illegal access, tid: %d, address: 0x%x, PC @ 0x%x,\n",
|
||||
fault->task->tid, fault->address, fault->kdata->faulty_pc);
|
||||
BUG();
|
||||
fault_handle_error(fault);
|
||||
}
|
||||
|
||||
/* The access reason is not included in the vma's listed flags */
|
||||
if (!(reason & vma_flags)) {
|
||||
printf("Illegal access, tid: %d, address: 0x%x, PC @ 0x%x\n",
|
||||
fault->task->tid, fault->address, fault->kdata->faulty_pc);
|
||||
BUG();
|
||||
fault_handle_error(fault);
|
||||
}
|
||||
|
||||
if ((reason & VM_EXEC) && (vma_flags & VM_EXEC)) {
|
||||
printf("Exec faults unsupported yet.\n");
|
||||
BUG(); /* Can't handle this yet. */
|
||||
fault_handle_error(fault);
|
||||
}
|
||||
|
||||
/* Handle legitimate faults */
|
||||
|
||||
@@ -32,6 +32,7 @@ int main(int argc, char *argv[])
|
||||
char *parent_of_all;
|
||||
char pidbuf[10];
|
||||
|
||||
printf("New task started: %d\n", __raw_tid(getpid()));
|
||||
|
||||
/* Convert current pid to string */
|
||||
sprintf(pidbuf, "%d", getpid());
|
||||
@@ -44,6 +45,8 @@ int main(int argc, char *argv[])
|
||||
goto out;
|
||||
}
|
||||
|
||||
printf("New task continues: %d\n", __raw_tid(getpid()));
|
||||
|
||||
/* Get parent of all pid as a string from environment */
|
||||
parent_of_all = getenv("parent_of_all");
|
||||
pagerid = ascii_to_int(getenv("pagerid"));
|
||||
|
||||
Reference in New Issue
Block a user