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.
27 ensure_space(lispobj *start, unsigned long size)
29 if (os_validate((os_vm_address_t)start,(os_vm_size_t)size)==NULL) {
31 "ensure_space: failed to validate %ld bytes at 0x%08lx\n",
33 (unsigned long)start);
35 "(hint: Try \"ulimit -a\"; maybe you should increase memory limits.)\n");
40 os_vm_address_t undefined_alien_address = 0;
43 ensure_undefined_alien(void) {
44 os_vm_address_t start = os_validate(NULL, os_vm_page_size);
46 os_protect(start, os_vm_page_size, OS_VM_PROT_NONE);
47 undefined_alien_address = start;
49 lose("could not allocate guard page for undefined alien\n");
57 printf("validating memory ...");
61 ensure_space( (lispobj *)READ_ONLY_SPACE_START, READ_ONLY_SPACE_SIZE);
62 ensure_space( (lispobj *)STATIC_SPACE_START , STATIC_SPACE_SIZE);
63 #ifdef LISP_FEATURE_GENCGC
64 ensure_space( (lispobj *)DYNAMIC_SPACE_START , dynamic_space_size);
66 ensure_space( (lispobj *)DYNAMIC_0_SPACE_START, dynamic_space_size);
67 ensure_space( (lispobj *)DYNAMIC_1_SPACE_START, dynamic_space_size);
70 #ifdef LISP_FEATURE_LINKAGE_TABLE
71 ensure_space( (lispobj *)LINKAGE_TABLE_SPACE_START, LINKAGE_TABLE_SPACE_SIZE);
74 #ifdef LISP_FEATURE_OS_PROVIDES_DLOPEN
75 ensure_undefined_alien();
84 protect_control_stack_guard_page(int protect_p) {
85 struct thread *th = arch_os_get_current_thread();
86 os_protect(CONTROL_STACK_GUARD_PAGE(th),
87 os_vm_page_size,protect_p ?
88 (OS_VM_PROT_READ|OS_VM_PROT_EXECUTE) : OS_VM_PROT_ALL);
92 protect_control_stack_return_guard_page(int protect_p) {
93 struct thread *th = arch_os_get_current_thread();
94 os_protect(CONTROL_STACK_RETURN_GUARD_PAGE(th),
95 os_vm_page_size,protect_p ?
96 (OS_VM_PROT_READ|OS_VM_PROT_EXECUTE) : OS_VM_PROT_ALL);
99 /* these OOAO violations are here because with mach exception handlers
100 * we need to protect the stack guard pages from the mach exception
101 * handlers which run on a different thread, so we take a thread
102 * argument here. Too bad we don't have keywords args in C. */
104 protect_control_stack_guard_page_thread(int protect_p, struct thread *th) {
105 os_protect(CONTROL_STACK_GUARD_PAGE(th),
106 os_vm_page_size,protect_p ?
107 (OS_VM_PROT_READ|OS_VM_PROT_EXECUTE) : OS_VM_PROT_ALL);
111 protect_control_stack_return_guard_page_thread(int protect_p, struct thread* th) {
112 os_protect(CONTROL_STACK_RETURN_GUARD_PAGE(th),
113 os_vm_page_size,protect_p ?
114 (OS_VM_PROT_READ|OS_VM_PROT_EXECUTE) : OS_VM_PROT_ALL);