2 * Shared mapping creation.
20 #define SHM_PROT_PAGES 30
25 unsigned int shm_pages
;
27 /* round up shm to nearest page size */
28 shm_pages
= ((sizeof(struct shm_s
) + page_size
- 1) & ~(page_size
- 1)) / page_size
;
30 /* Waste some address space to set up some "protection" near the SHM location. */
31 p
= alloc_shared((SHM_PROT_PAGES
+ shm_pages
+ SHM_PROT_PAGES
) * page_size
);
33 /* clear whole mapping, including the redzones. */
34 memset(p
, 0, shm_pages
* page_size
);
36 /* set the redzones to PROT_NONE */
37 mprotect(p
, SHM_PROT_PAGES
* page_size
, PROT_NONE
);
38 mprotect(p
+ (SHM_PROT_PAGES
+ shm_pages
) * page_size
,
39 SHM_PROT_PAGES
* page_size
, PROT_NONE
);
41 shm
= p
+ SHM_PROT_PAGES
* page_size
;
44 void create_shm_arrays(void)
46 shm
->child_syscall_count
= alloc_shared(max_children
* sizeof(unsigned long));
48 shm
->pids
= alloc_shared(max_children
* sizeof(pid_t
));
50 shm
->tv
= alloc_shared(max_children
* sizeof(struct timeval
));
52 shm
->syscall
= alloc_shared(max_children
* sizeof(struct syscallrecord
));
53 shm
->previous
= alloc_shared(max_children
* sizeof(struct syscallrecord
));
55 shm
->mappings
= alloc_shared(max_children
* sizeof(struct map
*));
56 shm
->num_mappings
= alloc_shared(max_children
* sizeof(unsigned int));
58 shm
->seeds
= alloc_shared(max_children
* sizeof(int));
59 shm
->kill_count
= alloc_shared(max_children
* sizeof(unsigned char));
60 shm
->logfiles
= alloc_shared(max_children
* sizeof(FILE *));
61 shm
->scratch
= alloc_shared(max_children
* sizeof(unsigned long));
68 output(2, "shm is at %p\n", shm
);
70 shm
->total_syscalls_done
= 1;
72 if (user_set_seed
== TRUE
)
73 shm
->seed
= init_seed(seed
);
75 shm
->seed
= new_seed();
76 /* Set seed in parent thread */
79 for (i
= 0; i
< max_children
; i
++) {
81 shm
->pids
[i
] = EMPTY_PIDSLOT
;
83 shm
->previous
[i
].nr
= shm
->syscall
[i
].nr
= -1;
85 shm
->previous
[i
].a1
= shm
->syscall
[i
].a1
= -1;
86 shm
->previous
[i
].a2
= shm
->syscall
[i
].a2
= -1;
87 shm
->previous
[i
].a3
= shm
->syscall
[i
].a3
= -1;
88 shm
->previous
[i
].a4
= shm
->syscall
[i
].a4
= -1;
89 shm
->previous
[i
].a5
= shm
->syscall
[i
].a5
= -1;
90 shm
->previous
[i
].a6
= shm
->syscall
[i
].a6
= -1;