6 * This software is part of the SBCL system. See the README file for
9 * This software is derived from the CMU CL system, which was
10 * written at Carnegie Mellon University and released into the
11 * public domain. The software is in the public domain and is
12 * provided with absolutely no warranty. See the COPYING and CREDITS
13 * files for more information.
25 #include "interr.h" /* for declaration of lose */
29 ensure_space(lispobj
*start
, uword_t size
)
31 if (os_validate((os_vm_address_t
)start
,(os_vm_size_t
)size
)==NULL
) {
33 "ensure_space: failed to validate %lu bytes at 0x%08lx\n",
37 "(hint: Try \"ulimit -a\"; maybe you should increase memory limits.)\n");
42 os_vm_address_t undefined_alien_address
= 0;
45 ensure_undefined_alien(void) {
46 os_vm_address_t start
= os_validate(NULL
, os_vm_page_size
);
48 os_protect(start
, os_vm_page_size
, OS_VM_PROT_NONE
);
49 undefined_alien_address
= start
;
51 lose("could not allocate guard page for undefined alien\n");
55 /* what a vague name! Something like create_all_spaces() would be more clear */
60 printf("validating memory ...");
64 ensure_space( (lispobj
*)READ_ONLY_SPACE_START
, READ_ONLY_SPACE_SIZE
);
65 ensure_space( (lispobj
*)STATIC_SPACE_START
, STATIC_SPACE_SIZE
);
66 #ifdef LISP_FEATURE_GENCGC
67 ensure_space( (lispobj
*)DYNAMIC_SPACE_START
, dynamic_space_size
);
69 ensure_space( (lispobj
*)DYNAMIC_0_SPACE_START
, dynamic_space_size
);
70 ensure_space( (lispobj
*)DYNAMIC_1_SPACE_START
, dynamic_space_size
);
73 #ifdef LISP_FEATURE_LINKAGE_TABLE
74 ensure_space( (lispobj
*)LINKAGE_TABLE_SPACE_START
,
75 LINKAGE_TABLE_SPACE_SIZE
);
78 #ifdef LISP_FEATURE_OS_PROVIDES_DLOPEN
79 ensure_undefined_alien();
88 protect_page(void *page
, int protect_p
, os_vm_prot_t flags
) {
89 os_protect(page
, os_vm_page_size
, protect_p
?
90 flags
: OS_VM_PROT_ALL
);
93 #define DEF_PROTECT_PAGE(name,page_name,flags) \
95 protect_##name(int protect_p, struct thread *thread) { \
97 thread = arch_os_get_current_thread(); \
98 protect_page(page_name(thread), protect_p, flags); \
101 DEF_PROTECT_PAGE(control_stack_hard_guard_page
,
102 CONTROL_STACK_HARD_GUARD_PAGE
,
104 DEF_PROTECT_PAGE(control_stack_guard_page
,
105 CONTROL_STACK_GUARD_PAGE
,
106 OS_VM_PROT_READ
|OS_VM_PROT_EXECUTE
)
107 DEF_PROTECT_PAGE(control_stack_return_guard_page
,
108 CONTROL_STACK_RETURN_GUARD_PAGE
,
109 OS_VM_PROT_READ
|OS_VM_PROT_EXECUTE
)
111 DEF_PROTECT_PAGE(binding_stack_hard_guard_page
,
112 BINDING_STACK_HARD_GUARD_PAGE
,
114 DEF_PROTECT_PAGE(binding_stack_guard_page
,
115 BINDING_STACK_GUARD_PAGE
,
117 DEF_PROTECT_PAGE(binding_stack_return_guard_page
,
118 BINDING_STACK_RETURN_GUARD_PAGE
,
121 DEF_PROTECT_PAGE(alien_stack_hard_guard_page
,
122 ALIEN_STACK_HARD_GUARD_PAGE
,
124 DEF_PROTECT_PAGE(alien_stack_guard_page
,
125 ALIEN_STACK_GUARD_PAGE
,
127 DEF_PROTECT_PAGE(alien_stack_return_guard_page
,
128 ALIEN_STACK_RETURN_GUARD_PAGE
,