diff options
author | Neal H. Walfield <neal@gnu.org> | 2009-01-16 21:18:32 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@gnu.org> | 2009-01-16 21:18:32 +0100 |
commit | 8e7249d8deae3a82c086f435b7e31ec16d1457da (patch) | |
tree | f1b309d53e2452b7bfe99cdfbfda0a1697f24e02 /libhurd-mm | |
parent | 992370c0219936911f3bba6c62b00c886ecae392 (diff) |
Conditionalize use of l4 functions on USE_L4.
/
2009-01-16 Neal H. Walfield <neal@gnu.org>
* Makefile.am (L4_SUBDIRS): New variable. Set to l4 directories
if USE_L4 is true, otherwise leave empty.
(SUBDIRS): Remove libl4 and laden. Replace with $(USE_L4).
Rearrange order.
benchmarks/
2009-01-16 Neal H. Walfield <neal@gnu.org>
* activity-distribution.c (main): Use vg_thread_id_t and
hurd_myself, not l4_thread_id_t and l4_myself.
[USE_L4]: Only l4_sleep in this case.
* cache.c (helper_fork): Use hurd_myself, not l4_myself.
(main) [USE_L4]: Only call _L4_kdb in this case.
* shared-memory-distribution.c (main): Use vg_thread_id_t and
hurd_myself, not l4_thread_id_t and l4_myself.
hieronymus/
2009-01-16 Neal H. Walfield <neal@gnu.org>
* hieronymus.c (main): Use uint64_t, not l4_uint64_t.
(main) [USE_L4]: Don't sleep in this case.
hurd/
2009-01-16 Neal H. Walfield <neal@gnu.org>
* lock.h (ss_mutex_trace_add) [! USE_L4]: Set SS_LOCK_TRACE[I].TID
to zero.
* thread.h (hurd_myself) [USE_L4]: Return l4_myself.
* trace.h (trace_buffer_add) [! USE_L4 && ! RM_INTERN]: Use
hurd_myself, not l4_myself.
[! USE_L4 && RM_INTERN]: Don't print a tid.
libc-parts/
2009-01-16 Neal H. Walfield <neal@gnu.org>
* _exit.c (_exit): Use sched_yield, not l4_yield.
* backtrace.c [USE_L4]: Only include <l4.h> in this case.
[! RM_INTERN]: Include <hurd/thread.h>.
(backtrace_print) [! USE_L4 && ! RM_INTERN]: Use hurd_myself to
get the caller's tid.
[! USE_L4 && RM_INTERN]: Don't print a tid.
* ia32-cmain.c [! USE_L4]: Don't include <l4/globals.h>,
<l4/init.h>, <l4/stubs.h>, or <l4/stubs-init.h>.
(cmain) [! USE_L4]: Don't call l4_init or l4_init_stubs.
* loader.c: Don't include <l4.h>. Include <bits/wordsize.h> and
<endian.h>.
(loader_elf_load): Use __WORDSIZE, __BYTE_ORDER, __LITTLE_ENDIAN
and __BIG_ENDIAN instead of their L4 names.
* panic.c: Include <viengoos/thread.h>.
[! RM_INTERN]: Include <hurd/thread.h>.
(panic_) [! USE_L4 && ! RM_INTERN]: Use hurd_myself, not
l4_myself.
[! USE_L4 && RM_INTERN]: Don't print a tid.
(panic_): Call sched_yield, not l4_yield.
* process-spawn.c (process_spawn) [! USE_L4]: Don't pass utcb and
kip information. Change sp from a l4_word_to to a uintptr_t.
* profile.c [! USE_L4]: Don't include <l4.h>.
(now) [__gnu_hurd_viengoos__ && ! USE_L4]: Just return 0.
(struct profile_block): Change tid to a vg_thread_id_t.
(MYSELF) [__gnu_hurd_viengoos__ && ! USE_L4]: Just return 0.
* s_printf.c (io_buffer_flush) [! USE_L4]: Abort.
libhurd-mm/
2009-01-16 Neal H. Walfield <neal@gnu.org>
* anonymous.h: Don't include <l4/thread.h>. Include
<viengoos/thread.h>.
(struct anonymous_pager): Change fill_thread's type to
vg_thread_id_t.
* anonymous.c (fault): Use hurd_myself and vg_niltid, not
l4_myself and l4_nilthread.
* as-build.c: Don't include <l4.h>.
* as.h: Include <hurd/thread.h>. Don't include <l4/types.h>.
(as_lock): Change as_rwlock_owner's type to vg_thread_id_t. Use
hurd_myself, not l4_myself.
(as_lock_readonly): Likewise.
(as_unlock): Likewise.
* as.c [! USE_L4]: Don't include <l4/types.h> or <l4/kip.h>.
Include <bits/wordsize.h>.
(DATA_ADDR_MAX): Define for 64-bit virtual address spaces.
(as_rwlock_owner): Change type to vg_thread_id_t.
(as_alloc_slow) [USE_L4]: Only check for conflicts with the kip
and utcb in this case.
(as_init) [USE_L4]: Only reserve the kip and utcb in this case.
* exceptions.c [USE_L4]: Only include <l4/thread.h> in this case.
(l4_utcb_state_save) [! USE_L4]: Make a no-op.
(l4_utcb_state_restore) [! USE_L4]: Likewise.
(hurd_activation_handler_normal): Use hurd_myself, not l4_myself.
* map.c: Don't include <l4.h>.
(map_fault): Use VG_WRITE, not L4_FPAGE_WRITABLE.
* storage.c (storage_check_reserve_internal): Change
as_rwlock_owner's type to vg_thread_id_t.
libpthread/
2009-01-16 Neal H. Walfield <neal@gnu.org>
* sysdeps/viengoos/pt-spin.c [USE_L4]: Only include <l4.h> in this
case.
(_pthread_spin_lock): Only implement exponential back off if a
sleep function is available.
* sysdeps/viengoos/pt-stack-alloc.c: Don't include <l4.h>.
* sysdeps/viengoos/pt-sysdep.c (sched_yield) [! USE_L4]: Just
return.
(init_routine) [USE_L4]: Abort.
* sysdeps/viengoos/pt-sysdep.h [USE_L4]: Only include <l4.h> in
this case.
(_pthread_self) [! USE_L4]: Abort.
* sysdeps/viengoos/pt-thread-alloc.c (__pthread_thread_alloc): Use
hurd_myself, not l4_myself.
[! USE_L4]: Abort.
* sysdeps/viengoos/pt-thread-start.c (__pthread_thread_start): Use
hurd_myself, not l4_myself. use uintptr_t, not l4_word_t.
* sysdeps/viengoos/sig-sysdep.h (SIGNAL_DISPATCH_ENTRY)
[! USE_L4]: Abort.
(SIGNAL_DISPATCH_EXIT) [! USE_L4]: Likewise.
libviengoos/
2009-01-16 Neal H. Walfield <neal@gnu.org>
* viengoos/thread.h (VG_READ): Define.
(VG_WRITE): Define.
(VG_EXECUTE): Likewise.
(VG_ACTIVATION_FAULT_INFO_PRINTF): Use them.
ruth/
2009-01-16 Neal H. Walfield <neal@gnu.org>
* ruth.c [USE_L4]: Only include <l4.h> in this case.
(main) [! USE_L4]: Don't print resource manager's thread id.
(main): Use uintptr_t, not l4_word_t. Use hurd_myself, not
l4_myself. Use sched_yield, not l4_yield. Improve
synchronization for object_reply_on_destruction test in case
sched_yield is a no-op.
viengoos/
2009-01-16 Neal H. Walfield <neal@gnu.org>
* cap.h: Don't include <l4.h>.
* mutex.h [USE_L4]: Only include <l4/thread.h> in this case.
(ss_mutex_t) [! USE_L4]: Define to be an int.
(ss_mutex_lock) [! USE_L4]: Make a no-op.
(ss_mutex_unlock) [! USE_L4]: Likewise.
(ss_mutex_trylock) [! USE_L4]: Likewise.
* object.h [USE_L4]: Only include <l4.h> in this case.
(object_desc_unmap) [! USE_L4]: Make a no-op.
(object_desc_flush) [! USE_L4]: Likewise.
* thread.h: Don't include <l4.h>.
(struct thread): Make tid a vg_thread_id_t, not an l4_thread_id_t.
(thread_lookup): Make threadid a vg_thread_id_t, not an
l4_thread_id_t.
Diffstat (limited to 'libhurd-mm')
-rw-r--r-- | libhurd-mm/ChangeLog | 30 | ||||
-rw-r--r-- | libhurd-mm/anonymous.c | 8 | ||||
-rw-r--r-- | libhurd-mm/anonymous.h | 4 | ||||
-rw-r--r-- | libhurd-mm/as-build.c | 1 | ||||
-rw-r--r-- | libhurd-mm/as.c | 24 | ||||
-rw-r--r-- | libhurd-mm/as.h | 16 | ||||
-rw-r--r-- | libhurd-mm/exceptions.c | 16 | ||||
-rw-r--r-- | libhurd-mm/map.c | 5 | ||||
-rw-r--r-- | libhurd-mm/storage.c | 39 |
9 files changed, 91 insertions, 52 deletions
diff --git a/libhurd-mm/ChangeLog b/libhurd-mm/ChangeLog index 121e73c..aad6471 100644 --- a/libhurd-mm/ChangeLog +++ b/libhurd-mm/ChangeLog @@ -1,5 +1,35 @@ 2009-01-16 Neal H. Walfield <neal@gnu.org> + * anonymous.h: Don't include <l4/thread.h>. Include + <viengoos/thread.h>. + (struct anonymous_pager): Change fill_thread's type to + vg_thread_id_t. + * anonymous.c (fault): Use hurd_myself and vg_niltid, not + l4_myself and l4_nilthread. + * as-build.c: Don't include <l4.h>. + * as.h: Include <hurd/thread.h>. Don't include <l4/types.h>. + (as_lock): Change as_rwlock_owner's type to vg_thread_id_t. Use + hurd_myself, not l4_myself. + (as_lock_readonly): Likewise. + (as_unlock): Likewise. + * as.c [! USE_L4]: Don't include <l4/types.h> or <l4/kip.h>. + Include <bits/wordsize.h>. + (DATA_ADDR_MAX): Define for 64-bit virtual address spaces. + (as_rwlock_owner): Change type to vg_thread_id_t. + (as_alloc_slow) [USE_L4]: Only check for conflicts with the kip + and utcb in this case. + (as_init) [USE_L4]: Only reserve the kip and utcb in this case. + * exceptions.c [USE_L4]: Only include <l4/thread.h> in this case. + (l4_utcb_state_save) [! USE_L4]: Make a no-op. + (l4_utcb_state_restore) [! USE_L4]: Likewise. + (hurd_activation_handler_normal): Use hurd_myself, not l4_myself. + * map.c: Don't include <l4.h>. + (map_fault): Use VG_WRITE, not L4_FPAGE_WRITABLE. + * storage.c (storage_check_reserve_internal): Change + as_rwlock_owner's type to vg_thread_id_t. + +2009-01-16 Neal H. Walfield <neal@gnu.org> + * exceptions.c (hurd_activation_stack_dump): Use AF_REGS_FMT and AF_REGS_PRINTF rather than naming the registers explicitly. (hurd_activation_handler_normal): Likewise. diff --git a/libhurd-mm/anonymous.c b/libhurd-mm/anonymous.c index a653ae2..1827711 100644 --- a/libhurd-mm/anonymous.c +++ b/libhurd-mm/anonymous.c @@ -161,7 +161,7 @@ fault (struct pager *pager, uintptr_t offset, int count, bool read_only, if (! ss_mutex_trylock (&anon->fill_lock)) /* The fill lock is held. */ { - if (anon->fill_thread == l4_myself ()) + if (anon->fill_thread == hurd_myself ()) /* By us! */ recursive = true; @@ -172,8 +172,8 @@ fault (struct pager *pager, uintptr_t offset, int count, bool read_only, /* We have the lock. */ if (! recursive) - assert (anon->fill_thread == l4_nilthread); - anon->fill_thread = l4_myself (); + assert (anon->fill_thread == vg_niltid); + anon->fill_thread = hurd_myself (); if (! recursive && (anon->flags & ANONYMOUS_THREAD_SAFE)) /* Revoke access to the visible region. */ @@ -424,7 +424,7 @@ fault (struct pager *pager, uintptr_t offset, int count, bool read_only, })); } - anon->fill_thread = l4_nilthread; + anon->fill_thread = vg_niltid; ss_mutex_unlock (&anon->fill_lock); } } diff --git a/libhurd-mm/anonymous.h b/libhurd-mm/anonymous.h index 28d1b9a..291d7f6 100644 --- a/libhurd-mm/anonymous.h +++ b/libhurd-mm/anonymous.h @@ -24,7 +24,7 @@ #include <hurd/pager.h> #include <hurd/btree.h> #include <viengoos/addr.h> -#include <l4/thread.h> +#include <viengoos/thread.h> /* Forward. */ struct anonymous_pager; @@ -125,7 +125,7 @@ struct anonymous_pager anonymous_pager_fill_t fill; /* The thread in the fill function. (If none, NULL.) */ - l4_thread_id_t fill_thread; + vg_thread_id_t fill_thread; /* Used to serialize the fill function. Also protects FILL_THREAD. If ANONYMOUS_THREAD_SAFE is set, then this lock protects the staging area. Must be taken while holding LOCK. */ diff --git a/libhurd-mm/as-build.c b/libhurd-mm/as-build.c index 5097117..0ccf16a 100644 --- a/libhurd-mm/as-build.c +++ b/libhurd-mm/as-build.c @@ -18,7 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <l4.h> #include <stddef.h> #include <assert.h> diff --git a/libhurd-mm/as.c b/libhurd-mm/as.c index 1a291db..de3bc8f 100644 --- a/libhurd-mm/as.c +++ b/libhurd-mm/as.c @@ -28,18 +28,26 @@ #include <hurd/btree.h> #include <hurd/slab.h> #include <hurd/mutex.h> -#include <l4/types.h> -#include <l4/kip.h> + +#ifdef USE_L4 +# include <l4/types.h> +# include <l4/kip.h> +#endif #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) +#include <bits/wordsize.h> +#if __WORDSIZE == 32 +# define DATA_ADDR_MAX (0xC0000000ULL) +#elif __WORDSIZE == 64 +/* XXX: For now, assume that we have 48 bits of virtual address + space. */ +# define DATA_ADDR_MAX (1ULL << 48) #else -#error define DATA_ADDR_MAX +# error __WORDSIZE not defined or invalid. #endif /* Set to true before as_init returns. Indicates that the shadow page @@ -47,7 +55,7 @@ extern struct hurd_startup_data *__hurd_startup_data; bool as_init_done; pthread_rwlock_t as_rwlock; -l4_thread_id_t as_rwlock_owner; +vg_thread_id_t as_rwlock_owner; /* We keep track of the regions which are unallocated. These regions are kept in a btree allowing for fast allocation, fast searching @@ -399,6 +407,7 @@ as_alloc_slow (int width) if (end >= DATA_ADDR_MAX) return 0; +#ifdef USE_L4 if (! (end < (uintptr_t) l4_kip () || (uintptr_t) l4_kip () + l4_kip_area_size () <= start)) /* Overlaps the KIP. */ @@ -408,6 +417,7 @@ as_alloc_slow (int width) || ((uintptr_t) _L4_utcb () + l4_utcb_size () <= start))) /* Overlaps the UTCB. */ return 0; +#endif /* Be sure we haven't already given this address out. */ int i; @@ -615,9 +625,11 @@ as_init (void) } } +#ifdef USE_L4 /* Reserve the kip and the utcb. */ as_alloc_at (VG_ADDR ((uintptr_t) l4_kip (), VG_ADDR_BITS), l4_kip_area_size ()); as_alloc_at (VG_ADDR ((uintptr_t) _L4_utcb (), VG_ADDR_BITS), l4_utcb_size ()); +#endif /* And the page at 0. */ as_alloc_at (vg_addr_chop (VG_PTR_TO_ADDR (0), PAGESIZE_LOG2), 1); diff --git a/libhurd-mm/as.h b/libhurd-mm/as.h index 24f8f3e..96a37e2 100644 --- a/libhurd-mm/as.h +++ b/libhurd-mm/as.h @@ -24,8 +24,8 @@ #include <viengoos/addr.h> #include <viengoos/cap.h> +#include <hurd/thread.h> #include <stdbool.h> -#include <l4/types.h> /* The address space allocator keeps track of which addresses are allocated and which are available. The allocator supports the @@ -104,7 +104,7 @@ static inline void as_lock (void) { extern pthread_rwlock_t as_rwlock; - extern l4_thread_id_t as_rwlock_owner; + extern vg_thread_id_t as_rwlock_owner; as_lock_ensure_stack (AS_STACK_SPACE); @@ -112,10 +112,10 @@ as_lock (void) for (;;) { - assert (as_rwlock_owner != l4_myself ()); + assert (as_rwlock_owner != hurd_myself ()); pthread_rwlock_wrlock (&as_rwlock); assert (as_rwlock_owner == 0); - as_rwlock_owner = l4_myself (); + as_rwlock_owner = hurd_myself (); if (! storage_have_reserve ()) { @@ -133,7 +133,7 @@ static inline void as_lock_readonly (void) { extern pthread_rwlock_t as_rwlock; - extern l4_thread_id_t as_rwlock_owner; + extern vg_thread_id_t as_rwlock_owner; as_lock_ensure_stack (AS_STACK_SPACE); @@ -141,7 +141,7 @@ as_lock_readonly (void) for (;;) { - assert (as_rwlock_owner != l4_myself ()); + assert (as_rwlock_owner != hurd_myself ()); pthread_rwlock_rdlock (&as_rwlock); assert (as_rwlock_owner == 0); @@ -160,12 +160,12 @@ static inline void as_unlock (void) { extern pthread_rwlock_t as_rwlock; - extern l4_thread_id_t as_rwlock_owner; + extern vg_thread_id_t as_rwlock_owner; if (as_rwlock_owner) /* Only set for a write lock. */ { - assert (as_rwlock_owner == l4_myself ()); + assert (as_rwlock_owner == hurd_myself ()); as_rwlock_owner = 0; } diff --git a/libhurd-mm/exceptions.c b/libhurd-mm/exceptions.c index 6ad928a..76026bd 100644 --- a/libhurd-mm/exceptions.c +++ b/libhurd-mm/exceptions.c @@ -25,7 +25,10 @@ #include <hurd/mm.h> #include <viengoos/misc.h> #include <hurd/slab.h> -#include <l4/thread.h> + +#ifdef USE_L4 +# include <l4/thread.h> +#endif #include <signal.h> #include <string.h> @@ -102,6 +105,7 @@ hurd_activation_frame_longjmp (struct activation_frame *activation_frame, #endif } +#ifdef USE_L4 static void l4_utcb_state_save (struct activation_frame *activation_frame) { @@ -131,6 +135,10 @@ l4_utcb_state_restore (struct activation_frame *activation_frame) memcpy (&utcb[_L4_UTCB_MR0], &activation_frame->saved_message, L4_NUM_MRS * sizeof (uintptr_t)); } +#else +# define l4_utcb_state_save(f) +# define l4_utcb_state_restore(f) +#endif /* Fetch any pending activation. */ void @@ -345,10 +353,10 @@ hurd_activation_handler_normal (struct activation_frame *activation_frame, VG_ADDR_PRINTF (fault), AF_REGS_PRINTF (activation_frame)); - extern l4_thread_id_t as_rwlock_owner; + extern vg_thread_id_t as_rwlock_owner; bool r = false; - if (likely (as_rwlock_owner != l4_myself ())) + if (likely (as_rwlock_owner != hurd_myself ())) r = map_fault (fault, ip, info); if (! r) { @@ -378,7 +386,7 @@ hurd_activation_handler_normal (struct activation_frame *activation_frame, if (! catcher) { - if (as_rwlock_owner == l4_myself ()) + if (as_rwlock_owner == hurd_myself ()) debug (0, "I hold as_rwlock!"); debug (0, "SIGSEGV at " VG_ADDR_FMT " " AF_REGS_FMT, diff --git a/libhurd-mm/map.c b/libhurd-mm/map.c index 2147d6b..370f2f0 100644 --- a/libhurd-mm/map.c +++ b/libhurd-mm/map.c @@ -25,7 +25,6 @@ #include <hurd/storage.h> #include <hurd/as.h> #include <hurd/slab.h> -#include <l4.h> #include <string.h> @@ -346,11 +345,11 @@ map_fault (vg_addr_t fault_addr, uintptr_t ip, struct vg_activation_fault_info i } /* Note: write access implies read access. */ - if (((info.access & L4_FPAGE_WRITABLE) && ! (map->access & MAP_ACCESS_WRITE)) + if (((info.access & VG_WRITE) && ! (map->access & MAP_ACCESS_WRITE)) || ! map->access) { debug (0, "Invalid %s access at " VG_ADDR_FMT ": " MAP_FMT, - info.access & L4_FPAGE_WRITABLE ? "write" : "read", + info.access & VG_WRITE ? "write" : "read", VG_ADDR_PRINTF (fault_addr), MAP_PRINTF (map)); maps_lock_unlock (); diff --git a/libhurd-mm/storage.c b/libhurd-mm/storage.c index 585b9d9..433bf4c 100644 --- a/libhurd-mm/storage.c +++ b/libhurd-mm/storage.c @@ -390,7 +390,7 @@ storage_check_reserve_internal (bool force_allocate, pages and if not to call some as-yet unwritten function which forces the reserve to grow. */ { - extern l4_thread_id_t as_rwlock_owner; + extern vg_thread_id_t as_rwlock_owner; if (as_rwlock_owner) { if (as_rwlock_owner == hurd_myself ()) @@ -738,23 +738,6 @@ storage_free_ (vg_addr_t object, bool unmap_now) ss_mutex_lock (&storage_descs_lock); - { - int cnt = 0; - struct storage_desc *desc; - for (desc = hurd_btree_storage_desc_first (&storage_descs); - desc; - desc = hurd_btree_storage_desc_next (desc)) - cnt += desc->free; - - if (cnt != free_count) - for (desc = hurd_btree_storage_desc_first (&storage_descs); - desc; - desc = hurd_btree_storage_desc_next (desc)) - debug (0, "Folio at " VG_ADDR_FMT " %d free", - VG_ADDR_PRINTF (desc->folio), desc->free); - assertx (cnt == free_count, "%d != %d", cnt, free_count); - } - /* Find the storage descriptor. */ struct storage_desc *storage; storage = hurd_btree_storage_desc_find (&storage_descs, &folio); @@ -810,7 +793,8 @@ storage_free_ (vg_addr_t object, bool unmap_now) vg_addr_t shadow_addr = vg_addr_chop (VG_PTR_TO_ADDR (shadow), PAGESIZE_LOG2); - if (VG_ADDR_EQ (vg_addr_chop (shadow_addr, VG_FOLIO_OBJECTS_LOG2), folio)) + if (VG_ADDR_EQ (vg_addr_chop (shadow_addr, + VG_FOLIO_OBJECTS_LOG2), folio)) { /* The shadow was allocate from ourself, which we already freed. */ @@ -848,11 +832,18 @@ storage_free_ (vg_addr_t object, bool unmap_now) int idx = vg_addr_extract (object, VG_FOLIO_OBJECTS_LOG2); bit_dealloc (storage->alloced, idx); - error_t err = vg_folio_object_alloc (meta_data_activity, - folio, idx, vg_cap_void, - VG_OBJECT_POLICY_DEFAULT, 0, - NULL, NULL); - assert (err == 0); + if (unmap_now +#ifndef NDEBUG + || 1 +#endif + ) + { + error_t err = vg_folio_object_alloc (meta_data_activity, + folio, idx, vg_cap_void, + VG_OBJECT_POLICY_DEFAULT, 0, + NULL, NULL); + assert (err == 0); + } if (likely (!! shadow)) { |