crash - /* * crash.c * * Commit a variety of exceptions,...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
/* * crash.c * * Commit a variety of exceptions, primarily address faults. * * Once the basic system calls assignment is complete, none of these * should crash the kernel. * * They should all, however, terminate this program, except for the * one that writes to the code segment. (That one won't cause program * termination until/unless you implement read-only segments in your * VM system.) */ #include <stdio.h> #include <unistd.h> #include <err.h> #if defined(__mips__) #define KERNEL_ADDR 0x80000000 #define INVAL_ADDR 0x40000000 #define INSN_TYPE u_int32_t #define INVAL_INSN 0x0000003f #else #error "Please fix this" #endif typedef void (*func)(void); static void read_from_null(void) { int *null = NULL; volatile int x; x = *null; } static void read_from_inval(void) { int *ptr = (int *) INVAL_ADDR; volatile int x; x = *ptr; } static void read_from_kernel(void) { int *ptr = (int *) KERNEL_ADDR; volatile int x; x = *ptr; } static void write_to_null(void)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
{ int *null = NULL; *null = 6; } static
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

crash - /* * crash.c * * Commit a variety of exceptions,...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online