summaryrefslogtreecommitdiff
path: root/sysdeps/l4
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/l4')
-rw-r--r--sysdeps/l4/hurd/ia32/pt-setup.c22
-rw-r--r--sysdeps/l4/hurd/pt-sysdep.h3
-rw-r--r--sysdeps/l4/hurd/pt-thread-alloc.c4
-rw-r--r--sysdeps/l4/hurd/pt-thread-halt.c25
-rw-r--r--sysdeps/l4/hurd/pt-thread-start.c41
5 files changed, 38 insertions, 57 deletions
diff --git a/sysdeps/l4/hurd/ia32/pt-setup.c b/sysdeps/l4/hurd/ia32/pt-setup.c
index a179bdfd..800d5b1b 100644
--- a/sysdeps/l4/hurd/ia32/pt-setup.c
+++ b/sysdeps/l4/hurd/ia32/pt-setup.c
@@ -20,6 +20,8 @@
#include <l4.h>
#include <pt-internal.h>
+#include <hurd/thread.h>
+#include <hurd/exceptions.h>
/* The stack layout used on the i386 is:
@@ -63,14 +65,20 @@ __pthread_setup (struct __pthread *thread,
thread->mcontext.pc = entry_point;
thread->mcontext.sp = stack_setup (thread, start_routine, arg);
+ if (__pthread_num_threads == 1)
+ return 0;
- if (__pthread_num_threads != 1)
- {
- assert (! ADDR_IS_VOID (thread->exception_handler_stack.addr));
- thread->exception_handler_sp
- = ADDR_TO_PTR (addr_extend (thread->exception_handler_stack.addr,
- 0, PAGESIZE_LOG2));
- }
+ assert (! ADDR_IS_VOID (thread->exception_page.addr));
+
+ struct exception_page *exception_page
+ = ADDR_TO_PTR (addr_extend (thread->exception_page.addr,
+ 0, PAGESIZE_LOG2));
+
+ /* SP is set to the end of the exception page. */
+ exception_page->exception_handler_sp = (l4_word_t) exception_page + PAGESIZE;
+
+ exception_page->exception_handler_ip = (l4_word_t) &exception_handler_entry;
+ exception_page->exception_handler_end = (l4_word_t) &exception_handler_end;
return 0;
}
diff --git a/sysdeps/l4/hurd/pt-sysdep.h b/sysdeps/l4/hurd/pt-sysdep.h
index 1c51731c..5c66330e 100644
--- a/sysdeps/l4/hurd/pt-sysdep.h
+++ b/sysdeps/l4/hurd/pt-sysdep.h
@@ -33,8 +33,7 @@
#define PTHREAD_SYSDEP_MEMBERS \
struct storage object; \
l4_thread_id_t threadid; \
- struct storage exception_handler_stack; \
- l4_word_t exception_handler_sp; \
+ struct storage exception_page; \
l4_word_t my_errno;
extern inline struct __pthread *
diff --git a/sysdeps/l4/hurd/pt-thread-alloc.c b/sysdeps/l4/hurd/pt-thread-alloc.c
index 2a421995..9e2bc2a3 100644
--- a/sysdeps/l4/hurd/pt-thread-alloc.c
+++ b/sysdeps/l4/hurd/pt-thread-alloc.c
@@ -55,7 +55,7 @@ __pthread_thread_alloc (struct __pthread *thread)
if (ADDR_IS_VOID (storage.addr))
return EAGAIN;
- thread->exception_handler_stack = storage;
+ thread->exception_page = storage;
storage = storage_alloc (meta_data_activity, cap_thread,
@@ -63,7 +63,7 @@ __pthread_thread_alloc (struct __pthread *thread)
STORAGE_MEDIUM_LIVED, ADDR_VOID);
if (ADDR_IS_VOID (storage.addr))
{
- storage_free (thread->exception_handler_stack.addr, false);
+ storage_free (thread->exception_page.addr, false);
return EAGAIN;
}
diff --git a/sysdeps/l4/hurd/pt-thread-halt.c b/sysdeps/l4/hurd/pt-thread-halt.c
index c6ae76f5..4aa112b1 100644
--- a/sysdeps/l4/hurd/pt-thread-halt.c
+++ b/sysdeps/l4/hurd/pt-thread-halt.c
@@ -30,8 +30,8 @@ static struct storage saved_object;
void
__pthread_thread_halt (struct __pthread *thread, int need_dealloc)
{
- struct storage exception_handler_stack = thread->exception_handler_stack;
- thread->exception_handler_stack.addr = ADDR_VOID;
+ struct storage exception_page = thread->exception_page;
+ thread->exception_page.addr = ADDR_VOID;
struct storage object = thread->object;
l4_thread_id_t tid = thread->threadid;
@@ -46,24 +46,9 @@ __pthread_thread_halt (struct __pthread *thread, int need_dealloc)
saved_object.addr = ADDR_VOID;
}
- /* Stop the exception handler thread. */
- l4_word_t dummy = 0;
- error_t err = rm_thread_exregs (ADDR_VOID, object.addr,
- HURD_EXREGS_EXCEPTION_THREAD
- | HURD_EXREGS_STOP | HURD_EXREGS_ABORT_IPC,
- ADDR_VOID,
- 0, (struct cap_addr_trans) CAP_ADDR_TRANS_VOID,
- ADDR_VOID,
- 0, 0, 0, 0,
- ADDR_VOID, ADDR_VOID,
- &dummy, &dummy, &dummy, &dummy);
- if (err)
- panic ("Error stopping exception thread.");
-
- /* Free its stack. */
- assert (! ADDR_IS_VOID (exception_handler_stack.addr));
- storage_free (exception_handler_stack.addr, false);
- exception_handler_stack.addr = ADDR_VOID;
+ /* Free the exception page. */
+ assert (! ADDR_IS_VOID (exception_page.addr));
+ storage_free (exception_page.addr, false);
if (tid == l4_myself ())
/* If we try to storage_free (storage.addr), we will freeze in the
diff --git a/sysdeps/l4/hurd/pt-thread-start.c b/sysdeps/l4/hurd/pt-thread-start.c
index ae5dfa8c..f2d7ef59 100644
--- a/sysdeps/l4/hurd/pt-thread-start.c
+++ b/sysdeps/l4/hurd/pt-thread-start.c
@@ -35,45 +35,34 @@ __pthread_thread_start (struct __pthread *thread)
{
assert (__pthread_total == 1);
assert (l4_is_thread_equal (l4_myself (), thread->threadid));
- l4_set_user_defined_handle_of (hurd_exception_thread (l4_myself ()),
- (l4_word_t) thread);
l4_set_user_defined_handle ((l4_word_t) thread);
}
else
{
- struct cap_addr_trans addr_trans = CAP_ADDR_TRANS_VOID;
+ struct hurd_thread_exregs_in in;
+ struct hurd_thread_exregs_out out;
- /* First, start the exception thread. */
- l4_word_t dummy;
- err = rm_thread_exregs (ADDR_VOID, thread->object.addr,
- HURD_EXREGS_EXCEPTION_THREAD
- | HURD_EXREGS_SET_SP_IP
- | HURD_EXREGS_SET_USER_HANDLE
- | HURD_EXREGS_START
- | HURD_EXREGS_ABORT_IPC,
- ADDR_VOID, 0, addr_trans, ADDR_VOID,
- (l4_word_t) thread->exception_handler_sp,
- (l4_word_t) exception_handler_loop, 0,
- thread,
- ADDR_VOID, ADDR_VOID,
- &dummy, &dummy, &dummy, &dummy);
- assert (err == 0);
+ in.aspace = ADDR (0, 0);
+ in.aspace_addr_trans = CAP_ADDR_TRANS_VOID;
+ in.aspace_addr_trans_flags = CAP_COPY_COPY_SOURCE_GUARD;
+
+ in.activity = ADDR_VOID;
+
+ in.exception_page = thread->exception_page.addr;
+
+ in.sp = (l4_word_t) thread->mcontext.sp;
+ in.ip = (l4_word_t) thread->mcontext.pc;
+ in.user_handle = (l4_word_t) thread;
err = rm_thread_exregs (ADDR_VOID, thread->object.addr,
HURD_EXREGS_SET_ASPACE
| HURD_EXREGS_SET_ACTIVITY
+ | HURD_EXREGS_SET_EXCEPTION_PAGE
| HURD_EXREGS_SET_SP_IP
| HURD_EXREGS_SET_USER_HANDLE
| HURD_EXREGS_START
| HURD_EXREGS_ABORT_IPC,
- ADDR (0, 0),
- CAP_COPY_COPY_SOURCE_GUARD, addr_trans,
- ADDR_VOID,
- (l4_word_t) thread->mcontext.sp,
- (l4_word_t) thread->mcontext.pc, 0,
- thread,
- ADDR_VOID, ADDR_VOID,
- &dummy, &dummy, &dummy, &dummy);
+ in, &out);
assert (err == 0);
}
return 0;