Added userland support for exregs/read, mm0 slightly more graceful for illegal access

This commit is contained in:
Bahadir Balban
2009-11-05 15:56:01 +02:00
parent 3f870b540f
commit 35a5dc4c92
5 changed files with 51 additions and 3 deletions
+1
View File
@@ -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__ */
+12
View File
@@ -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)
+3 -3
View File
@@ -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"));