1#!/bin/sh 2 3# Test scenario by Michiel Boland <michiel@boland.org> 4 5# panic: pmap_remove_all: page 0xc491f000 is fictitious 6 7[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 8 9. ../default.cfg 10 11odir=`pwd` 12cd /tmp 13sed '1,/^EOF/d' < $odir/$0 > mmap.c 14mycc -o mmap -Wall mmap.c 15rm -f mmap.c 16 17./mmap 18rm -f ./mmap 19exit 20 21EOF 22#include <sys/types.h> 23#include <sys/mman.h> 24#include <fcntl.h> 25#include <stdio.h> 26#include <unistd.h> 27 28static const off_t map_address = 0xa0000; 29static const size_t map_size = 0x1000; 30 31static int testit(int fd) 32{ 33 void *p; 34 int rv; 35 36 p = mmap(NULL, 2 * map_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 37 map_address); 38 if (p == MAP_FAILED) { 39 perror("mmap"); 40 return -1; 41 } 42 rv = *(char *) p; 43 if (munmap(p, map_size) == -1) { 44 perror("munmap"); 45 return -1; 46 } 47 return rv; 48} 49 50int main(void) 51{ 52 int fd, rv; 53 54 fd = open("/dev/mem", O_RDWR); 55 if (fd == -1) { 56 perror("open"); 57 return 1; 58 } 59 rv = testit(fd); 60 close(fd); 61 return rv; 62} 63 64