16 main(int argc
, char *argv
[])
18 #define CHUNKSIZE 8192
21 #define CHUNKS (CHUNKS1+CHUNKS2)
22 #define LARGESIZE 262144
25 #define STARTV 0x90000000
26 char *vaddr
= (char *) STARTV
;
32 for(i
= 0; i
< CHUNKS
; i
++) {
33 v
[i
] = minix_mmap(vaddr
, CHUNKSIZE
, PROT_READ
|PROT_WRITE
, 0,
35 if(v
[i
] == MAP_FAILED
) {
37 fprintf(stderr
, "minix_mmap failed\n");
42 "minix_mmap said 0x%p but i wanted 0x%p\n",
49 #define DEV_ZERO "/dev/zero"
50 if((fd
=open(DEV_ZERO
, O_RDONLY
)) < 0) {
52 fprintf(stderr
, "open failed for %s\n", DEV_ZERO
);
56 #define TOTAL1 (CHUNKS1*CHUNKSIZE)
57 /* Make single read cross region boundary. */
58 if((l
=read(fd
, v
[0], TOTAL1
)) != TOTAL1
) {
59 fprintf(stderr
, "read %d but expected %d\n", l
, TOTAL1
);
63 /* Force single copy to cross region boundary. */
66 t
= v
[CHUNKS1
]+CHUNKSIZE
-2;
67 if((l
=read(fd
, t
, CHUNKSIZE
)) != CHUNKSIZE
) {
68 fprintf(stderr
, "read %d but expected %d\n", l
, CHUNKSIZE
);
73 /* Now start a child to test bogus memory access */
74 if((f
= fork()) == -1) {
82 if(waitpid(f
, &st
, 0) < 0) {
87 fprintf(stderr
, "child not signaled\n");
90 if(WEXITSTATUS(st
) != 0) {
91 fprintf(stderr
, "child exited with nonzero status\n");
95 /* Child performs bogus read */
97 char *buf
= v
[CHUNKS
-1];
99 res
= read(fd
, buf
, LARGESIZE
);
101 fprintf(stderr
, "res %d\n", res
);
104 if(errno
!= EFAULT
) {
105 fprintf(stderr
, "errno %d\n", errno
);