diff options
author | neal <neal> | 2007-11-19 22:42:36 +0000 |
---|---|---|
committer | neal <neal> | 2007-11-19 22:42:36 +0000 |
commit | 5c2c982ba3cfbe34c79cb2096018567ca6cd8fb6 (patch) | |
tree | 186d51c98040279981a620affa2fdf4b26dadcff | |
parent | f38367b6493d6d4a51011a8d0fa81d1f3f49ca9e (diff) |
hurd/
2007-11-19 Neal H. Walfield <neal@gnu.org>
* addr.h (ADDR_TO_PTR): Assert that the address corresponds to a
pointer, not the root of a mapped page. Update callers.
(PTR_TO_ADDR): Return an address corresponding to a pointer, not
the root of a mapped page. Update callers.
libhurd-mm/
2007-11-19 Neal H. Walfield <neal@gnu.org>
* as.c (__hurd_startup_data): Declare.
(free_space_desc_slab_alloc): Use ADDR_TO_PTR and PTR_TO_ADDR
correctly.
(free_space_desc_slab_dealloc): Likewise.
(allocate_object): Likewise.
(storage_alloc): Likewise.
(as_init): Likewise.
* capalloc.c (cappage_desc_slab_alloc): Likewise.
(cappage_desc_slab_dealloc): Likewise.
* storage.c (__hurd_startup_data): Declare.
(check_slab_space_reserve): Likewise.
(storage_desc_slab_dealloc): Likewise.
(shadow_setup): Likewise.
(storage_free): Likewise.
ruth/
2007-11-19 Neal H. Walfield <neal@gnu.org>
* ruth.c (main): Use ADDR_TO_PTR and PTR_TO_ADDR correctly.
-rw-r--r-- | hurd/ChangeLog | 9 | ||||
-rw-r--r-- | hurd/addr.h | 6 | ||||
-rw-r--r-- | libhurd-mm/ChangeLog | 17 | ||||
-rw-r--r-- | libhurd-mm/as.c | 18 | ||||
-rw-r--r-- | libhurd-mm/capalloc.c | 4 | ||||
-rw-r--r-- | libhurd-mm/storage.c | 19 | ||||
-rw-r--r-- | ruth/ChangeLog | 4 | ||||
-rw-r--r-- | ruth/ruth.c | 18 |
8 files changed, 69 insertions, 26 deletions
diff --git a/hurd/ChangeLog b/hurd/ChangeLog index 0285b46..fafbec5 100644 --- a/hurd/ChangeLog +++ b/hurd/ChangeLog @@ -1,6 +1,13 @@ 2007-11-19 Neal H. Walfield <neal@gnu.org> - * Makefile.am (includehurd_HEADERS): Add rpc.h and exceptions.h. + * addr.h (ADDR_TO_PTR): Assert that the address corresponds to a + pointer, not the root of a mapped page. Update callers. + (PTR_TO_ADDR): Return an address corresponding to a pointer, not + the root of a mapped page. Update callers. + +2007-11-19 Neal H. Walfield <neal@gnu.org> + + * Makefile.am (includehurd_HEADERS): Add rpc.h. * headers.m4: Link $(BUILDIR)/include/hurd/rpc.h to rpc.h. * rpc.h: New file. Moved and generalized definitions RPC template definitions here from ../viengoos/rm.h. diff --git a/hurd/addr.h b/hurd/addr.h index 4debb12..da27efb 100644 --- a/hurd/addr.h +++ b/hurd/addr.h @@ -145,12 +145,12 @@ addr_extract (addr_t addr, int width) #define ADDR_TO_PTR(addr_) \ ({ \ assert (addr_prefix ((addr_)) < ((uintptr_t) -1)); \ - assert (addr_depth ((addr_)) == ADDR_BITS - PAGESIZE_LOG2); \ + assert (addr_depth ((addr_)) == ADDR_BITS); \ (void *) (uintptr_t) addr_prefix ((addr_)); \ }) -/* Convert an pointer to an address. */ +/* Convert a pointer to an address. */ #define PTR_TO_ADDR(ptr_) \ - (ADDR ((uintptr_t) (ptr_), ADDR_BITS - PAGESIZE_LOG2)) + (ADDR ((uintptr_t) (ptr_), ADDR_BITS)) #endif diff --git a/libhurd-mm/ChangeLog b/libhurd-mm/ChangeLog index e8a3d75..3640148 100644 --- a/libhurd-mm/ChangeLog +++ b/libhurd-mm/ChangeLog @@ -1,3 +1,20 @@ +2007-11-19 Neal H. Walfield <neal@gnu.org> + + * as.c (__hurd_startup_data): Declare. + (free_space_desc_slab_alloc): Use ADDR_TO_PTR and PTR_TO_ADDR + correctly. + (free_space_desc_slab_dealloc): Likewise. + (allocate_object): Likewise. + (storage_alloc): Likewise. + (as_init): Likewise. + * capalloc.c (cappage_desc_slab_alloc): Likewise. + (cappage_desc_slab_dealloc): Likewise. + * storage.c (__hurd_startup_data): Declare. + (check_slab_space_reserve): Likewise. + (storage_desc_slab_dealloc): Likewise. + (shadow_setup): Likewise. + (storage_free): Likewise. + 2007-11-16 Neal H. Walfield <neal@gnu.org> * Makefile.am (COMMON_CPPFLAGS): Include \ at end of line. diff --git a/libhurd-mm/as.c b/libhurd-mm/as.c index 62430ef..f147462 100644 --- a/libhurd-mm/as.c +++ b/libhurd-mm/as.c @@ -30,6 +30,8 @@ #include <string.h> +extern struct hurd_startup_data *__hurd_startup_data; + /* The top of the data address space. */ #if L4_WORDSIZE == 32 #define DATA_ADDR_MAX (0xC0000000ULL) @@ -210,7 +212,7 @@ free_space_desc_slab_alloc (void *hook, size_t size, void **ptr) addr_t storage = storage_alloc (meta_data_activity, cap_page, STORAGE_LONG_LIVED, ADDR_VOID); - *ptr = ADDR_TO_PTR (storage); + *ptr = ADDR_TO_PTR (addr_extend (storage, 0, PAGESIZE_LOG2)); return 0; } @@ -220,7 +222,7 @@ free_space_desc_slab_dealloc (void *hook, void *buffer, size_t size) { assert (size == PAGESIZE); - addr_t addr = PTR_TO_ADDR (buffer); + addr_t addr = addr_chop (PTR_TO_ADDR (buffer), PAGESIZE_LOG2); storage_free (addr, false); return 0; @@ -442,7 +444,8 @@ allocate_object (enum cap_type type, addr_t addr) storage_free (storage, false); return rt; } - cap_set_shadow (&rt.cap, ADDR_TO_PTR (shadow)); + cap_set_shadow (&rt.cap, ADDR_TO_PTR (addr_extend (shadow, + 0, PAGESIZE_LOG2))); } rt.storage = storage; @@ -646,7 +649,7 @@ as_init (void) shadow_addr = storage_alloc (meta_data_activity, cap_page, STORAGE_LONG_LIVED, ADDR_VOID); - shadow = ADDR_TO_PTR (shadow_addr); + shadow = ADDR_TO_PTR (addr_extend (shadow_addr, 0, PAGESIZE_LOG2)); cap_set_shadow (cap, shadow); /* We expect at least one non-void capability per @@ -778,16 +781,17 @@ as_init (void) as_alloc_at (ADDR ((uintptr_t) _L4_utcb (), ADDR_BITS), l4_utcb_size ()); /* And the page at 0. */ - as_alloc_at (PTR_TO_ADDR (0), 1); + as_alloc_at (addr_chop (PTR_TO_ADDR (0), PAGESIZE_LOG2), 1); /* Free DESC_ADDITIONAL. */ for (i = 0, desc = &__hurd_startup_data->descs[0]; i < __hurd_startup_data->desc_count; i ++, desc ++) - if (ADDR_EQ (desc->object, PTR_TO_ADDR (desc_additional))) + if (ADDR_EQ (desc->object, + addr_chop (PTR_TO_ADDR (desc_additional), PAGESIZE_LOG2))) { storage_free (desc->storage, false); - as_free (PTR_TO_ADDR (desc_additional), 1); + as_free (addr_chop (PTR_TO_ADDR (desc_additional), PAGESIZE_LOG2), 1); break; } assert (i != __hurd_startup_data->desc_count); diff --git a/libhurd-mm/capalloc.c b/libhurd-mm/capalloc.c index f565201..c603dcf 100644 --- a/libhurd-mm/capalloc.c +++ b/libhurd-mm/capalloc.c @@ -89,7 +89,7 @@ cappage_desc_slab_alloc (void *hook, size_t size, void **ptr) cap_page, STORAGE_LONG_LIVED, ADDR_VOID); if (ADDR_IS_VOID (storage)) panic ("Out of storage"); - *ptr = ADDR_TO_PTR (storage); + *ptr = ADDR_TO_PTR (addr_extend (storage, 0, PAGESIZE_LOG2)); return 0; } @@ -99,7 +99,7 @@ cappage_desc_slab_dealloc (void *hook, void *buffer, size_t size) { assert (size == PAGESIZE); - addr_t addr = ADDR ((uintptr_t) buffer, ADDR_BITS - PAGESIZE_LOG2); + addr_t addr = addr_chop (PTR_TO_ADDR (buffer), PAGESIZE_LOG2); storage_free (addr, false); return 0; diff --git a/libhurd-mm/storage.c b/libhurd-mm/storage.c index 4e0f407..8442edf 100644 --- a/libhurd-mm/storage.c +++ b/libhurd-mm/storage.c @@ -36,6 +36,8 @@ #include "as.h" +extern struct hurd_startup_data *__hurd_startup_data; + /* Objects are allocated from folios. As a folio is the unit of storage allocation, we can only free a folio when it is completely empty. For this reason, we try to group long lived objects @@ -124,7 +126,7 @@ check_slab_space_reserve (void) addr_t addr = storage_alloc (meta_data_activity, cap_page, STORAGE_LONG_LIVED, ADDR_VOID); - slab_space_reserve = ADDR_TO_PTR (addr); + slab_space_reserve = ADDR_TO_PTR (addr_extend (addr, 0, PAGESIZE_LOG2)); } static error_t @@ -147,7 +149,7 @@ storage_desc_slab_dealloc (void *hook, void *buffer, size_t size) assert (size == PAGESIZE); - addr_t addr = PTR_TO_ADDR (buffer); + addr_t addr = addr_chop (PTR_TO_ADDR (buffer), PAGESIZE_LOG2); storage_free (addr, false); return 0; @@ -215,8 +217,10 @@ shadow_setup (struct cap *cap, struct storage_desc *storage) storage->folio, idx, cap_page, ADDR_VOID); assert (err == 0); - storage->shadow = ADDR_TO_PTR (addr_extend (storage->folio, idx, - FOLIO_OBJECTS_LOG2)); + storage->shadow = ADDR_TO_PTR (addr_extend (addr_extend (storage->folio, + idx, + FOLIO_OBJECTS_LOG2), + 0, PAGESIZE_LOG2)); cap_set_shadow (cap, storage->shadow); cap->type = cap_folio; @@ -418,12 +422,12 @@ storage_free (addr_t object, bool unmap_now) if (storage->free == FOLIO_OBJECTS - 1) { if (ADDR_EQ (addr_chop (PTR_TO_ADDR (storage->shadow), - FOLIO_OBJECTS_LOG2), + PAGESIZE_LOG2 + FOLIO_OBJECTS_LOG2), storage->folio)) /* The last allocated page is our shadow page. Free this folio. */ { - object = PTR_TO_ADDR (storage->shadow); + object = addr_chop (PTR_TO_ADDR (storage->shadow), PAGESIZE_LOG2); storage->shadow = NULL; freeing_shadow = true; goto restart; @@ -466,7 +470,8 @@ storage_free (addr_t object, bool unmap_now) if (shadow) { assert (! freeing_shadow); - storage_free (PTR_TO_ADDR (shadow), false); + storage_free (addr_chop (PTR_TO_ADDR (shadow), PAGESIZE_LOG2), + false); } else assert (freeing_shadow); diff --git a/ruth/ChangeLog b/ruth/ChangeLog index 13c7c37..219de8a 100644 --- a/ruth/ChangeLog +++ b/ruth/ChangeLog @@ -1,3 +1,7 @@ +2007-11-19 Neal H. Walfield <neal@gnu.org> + + * ruth.c (main): Use ADDR_TO_PTR and PTR_TO_ADDR correctly. + 2007-11-16 Neal H. Walfield <neal@gnu.org> * Makefile.am (ruth_CPPFLAGS): Move value from here... diff --git a/ruth/ruth.c b/ruth/ruth.c index 396fe17..006465d 100644 --- a/ruth/ruth.c +++ b/ruth/ruth.c @@ -79,7 +79,7 @@ getpagesize() int main (int argc, char *argv[]) { - output_debug = 2; + output_debug = 3; printf ("%s " PACKAGE_VERSION "\n", program_name); printf ("Hello, here is Ruth, your friendly root server!\n"); @@ -174,7 +174,8 @@ main (int argc, char *argv[]) addr_t shadow_addr = storage_alloc (activity, cap_page, STORAGE_EPHEMERAL, ADDR_VOID); - struct object *shadow = ADDR_TO_PTR (shadow_addr); + struct object *shadow = ADDR_TO_PTR (addr_extend (shadow_addr, + 0, PAGESIZE_LOG2)); cap_set_shadow (slot, shadow); memset (shadow, 0, PAGESIZE); @@ -209,7 +210,7 @@ main (int argc, char *argv[]) void *shadow = cap_get_shadow (slot); assert (shadow); - storage_free (PTR_TO_ADDR (shadow), 1); + storage_free (addr_chop (PTR_TO_ADDR (shadow), PAGESIZE_LOG2), 1); } as_free (root, 1); @@ -233,17 +234,22 @@ main (int argc, char *argv[]) : STORAGE_EPHEMERAL, ADDR_VOID); assert (! ADDR_IS_VOID (storage[i])); - * (int *) (ADDR_TO_PTR (storage[i])) = i; + * (int *) (ADDR_TO_PTR (addr_extend (storage[i], 0, PAGESIZE_LOG2))) + = i; int j; for (j = 0; j <= i; j ++) - assert (* (int *) (ADDR_TO_PTR (storage[j])) == j); + assert (* (int *) (ADDR_TO_PTR (addr_extend (storage[j], + 0, PAGESIZE_LOG2))) + == j); } for (i = 0; i < n; i ++) { storage_free (storage[i], true); } + + printf ("ok.\n"); } { @@ -276,7 +282,7 @@ main (int argc, char *argv[]) assert (! ADDR_IS_VOID (storage)); debug (1, "Writing before dealloc..."); - int *buffer = ADDR_TO_PTR (addr); + int *buffer = ADDR_TO_PTR (addr_extend (addr, 0, PAGESIZE_LOG2)); *buffer = 0; storage_free (storage, true); |