[Git][cmucl/cmucl][rtoy-mmap-anon-control-and-binding-stacks] 2 commits: Updates to handle random stack locations better.
Raymond Toy
rtoy at common-lisp.net
Sat Oct 3 14:56:20 UTC 2015
Raymond Toy pushed to branch rtoy-mmap-anon-control-and-binding-stacks at cmucl / cmucl
Commits:
1869d093 by Raymond Toy at 2015-10-03T07:55:34Z
Updates to handle random stack locations better.
* Print out some better messages from os_protect
* Add make_hole to actually make a hole
* make_holes only does the read-only and static spaces.
* make_stack_holes handles the binding and control stacks.
- - - - -
4b838e3f by Raymond Toy at 2015-10-03T07:56:07Z
Make holes in the stacks, as before.
- - - - -
2 changed files:
- src/lisp/solaris-os.c
- src/lisp/validate.c
Changes:
=====================================
src/lisp/solaris-os.c
=====================================
--- a/src/lisp/solaris-os.c
+++ b/src/lisp/solaris-os.c
@@ -169,8 +169,14 @@ os_flush_icache(os_vm_address_t address, os_vm_size_t length)
void
os_protect(os_vm_address_t address, os_vm_size_t length, os_vm_prot_t prot)
{
- if (mprotect((void *) address, length, prot) == -1)
- perror("mprotect");
+ if (mprotect((void *) address, length, prot) == -1) {
+ char msg[1000];
+
+ snprintf(msg, sizeof(msg), "mprotect: os_protect(0x%p, %u, 0x%x): ",
+ address, length, prot);
+
+ perror(msg);
+ }
}
static boolean
@@ -430,27 +436,37 @@ static unsigned long *space_size[] = {
#define HOLE_SIZE 0x2000
void
-make_holes(void)
+make_hole(int index)
{
- int k;
os_vm_address_t hole;
/* Make holes of the appropriate size for desired spaces */
- for (k = 0; k < sizeof(spaces) / sizeof(spaces[0]); ++k) {
-
- hole = spaces[k] + *space_size[k];
+ hole = spaces[k] + *space_size[k];
- if (os_validate(hole, HOLE_SIZE) == NULL) {
- fprintf(stderr,
- "ensure_space: Failed to validate hole of %d bytes at 0x%08lX\n",
- HOLE_SIZE, (unsigned long) hole);
- exit(1);
- }
- /* Make it inaccessible */
- os_protect(hole, HOLE_SIZE, 0);
+ if (os_validate(hole, HOLE_SIZE) == NULL) {
+ fprintf(stderr,
+ "ensure_space: Failed to validate hole of %d bytes at 0x%08lX\n",
+ HOLE_SIZE, (unsigned long) hole);
+ exit(1);
}
+ /* Make it inaccessible */
+ os_protect(hole, HOLE_SIZE, 0);
+}
+
+void
+make_holes(void)
+{
+ os_vm_address_t hole;
+
+ /*
+ * Make holes of the appropriate size for desired spaces. The
+ * stacks are handled in make_stack_holes.
+ */
+ make_hole(0); /* Read-only space */
+ make_hole(1); /* Static space */
+
/* Round up the dynamic_space_size to the nearest SPARSE_BLOCK_SIZE */
dynamic_space_size = round_up_sparse_size(dynamic_space_size);
@@ -477,6 +493,13 @@ make_holes(void)
#endif
}
+void
+make_stack_holes(void)
+{
+ make_hole(2);
+ make_hole(3);
+}
+
void *
os_dlsym(const char *sym_name, lispobj lib_list)
{
=====================================
src/lisp/validate.c
=====================================
--- a/src/lisp/validate.c
+++ b/src/lisp/validate.c
@@ -18,6 +18,7 @@
#ifdef sparc
extern void make_holes(void);
+extern void make_stack_holes(void);
#endif
static void
@@ -124,6 +125,10 @@ validate_stacks()
/* Binding Stack */
binding_stack = os_validate(NULL, binding_stack_size);
+#ifdef sparc
+ make_stack_holes();
+#endif
+
#ifdef RED_ZONE_HIT
os_guard_control_stack(0, 1);
#endif
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/compare/586ca74df2c5289c9154e688e092e1b4a3f7d4cf...4b838e3f56bbfb80f9d7eee847644cffdf69a7e4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cmucl-cvs/attachments/20151003/d8b02c61/attachment.html>
More information about the cmucl-cvs
mailing list