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, unsigned long size)
31 if (os_validate((os_vm_address_t)start,(os_vm_size_t)size)==NULL) {
33 "ensure_space: failed to validate %ld bytes at 0x%08lx\n",
35 (unsigned long)start);
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");
59 printf("validating memory ...");
63 ensure_space( (lispobj *)READ_ONLY_SPACE_START, READ_ONLY_SPACE_SIZE);
64 ensure_space( (lispobj *)STATIC_SPACE_START , STATIC_SPACE_SIZE);
65 #ifdef LISP_FEATURE_GENCGC
66 ensure_space( (lispobj *)DYNAMIC_SPACE_START , dynamic_space_size);
68 ensure_space( (lispobj *)DYNAMIC_0_SPACE_START, dynamic_space_size);
69 ensure_space( (lispobj *)DYNAMIC_1_SPACE_START, dynamic_space_size);
72 #ifdef LISP_FEATURE_LINKAGE_TABLE
73 ensure_space( (lispobj *)LINKAGE_TABLE_SPACE_START,
74 LINKAGE_TABLE_SPACE_SIZE);
77 #ifdef LISP_FEATURE_OS_PROVIDES_DLOPEN
78 ensure_undefined_alien();
87 protect_control_stack_guard_page(int protect_p) {
88 struct thread *th = arch_os_get_current_thread();
89 os_protect(CONTROL_STACK_GUARD_PAGE(th),
90 os_vm_page_size,protect_p ?
91 (OS_VM_PROT_READ|OS_VM_PROT_EXECUTE) : OS_VM_PROT_ALL);
95 protect_control_stack_return_guard_page(int protect_p) {
96 struct thread *th = arch_os_get_current_thread();
97 os_protect(CONTROL_STACK_RETURN_GUARD_PAGE(th),
98 os_vm_page_size,protect_p ?
99 (OS_VM_PROT_READ|OS_VM_PROT_EXECUTE) : OS_VM_PROT_ALL);
102 /* these OOAO violations are here because with mach exception handlers
103 * we need to protect the stack guard pages from the mach exception
104 * handlers which run on a different thread, so we take a thread
105 * argument here. Too bad we don't have keywords args in C. */
107 protect_control_stack_guard_page_thread(int protect_p, struct thread *th) {
108 os_protect(CONTROL_STACK_GUARD_PAGE(th),
109 os_vm_page_size,protect_p ?
110 (OS_VM_PROT_READ|OS_VM_PROT_EXECUTE) : OS_VM_PROT_ALL);
114 protect_control_stack_return_guard_page_thread(int protect_p,
116 os_protect(CONTROL_STACK_RETURN_GUARD_PAGE(th),
117 os_vm_page_size,protect_p ?
118 (OS_VM_PROT_READ|OS_VM_PROT_EXECUTE) : OS_VM_PROT_ALL);