From 3e7135a1cdff2d88e83ceb71f2f444de5ea08e64 Mon Sep 17 00:00:00 2001 From: Jan Stoess Date: Wed, 15 Jul 2009 20:24:30 +0200 Subject: [PATCH] -Fixed unwinding IPCs when saved state is running but partner is still set -Make IO Fpage helpers compatible to C --- kernel/src/api/v4/thread.cc | 8 +++++--- kernel/src/api/v4/threadstate.h | 2 ++ user/include/l4/amd64/arch.h | 6 ++++-- user/include/l4/ia32/arch.h | 6 ++++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/kernel/src/api/v4/thread.cc b/kernel/src/api/v4/thread.cc index 62369a13..21694c3e 100644 --- a/kernel/src/api/v4/thread.cc +++ b/kernel/src/api/v4/thread.cc @@ -452,7 +452,8 @@ static void do_xcpu_unwind_partner (cpu_mb_entry_t * entry) return; } - if (! tcb->get_saved_partner ().is_nilthread ()) + if (! tcb->get_saved_partner ().is_nilthread () && + tcb->get_saved_state().is_polling_or_waiting() ) { // We have a nested IPC operation. Perform another unwind. tcb->restore_state (); @@ -505,7 +506,7 @@ redo_unwind: set_state (thread_state_t::running); partner = get_partner_tcb (); - if (cstate.is_polling () || cstate.is_waiting ()) + if (cstate.is_polling_or_waiting ()) { // IPC operation has not yet started. I.e., partner is not // yet involved. @@ -525,7 +526,8 @@ redo_unwind: tag = tag.error_tag (); } - if (! get_saved_partner ().is_nilthread ()) + if (! get_saved_partner ().is_nilthread () && + get_saved_state().is_polling_or_waiting()) { // We're handling a nested IPC. restore_state (); diff --git a/kernel/src/api/v4/threadstate.h b/kernel/src/api/v4/threadstate.h index 0f037364..a09e3ed2 100644 --- a/kernel/src/api/v4/threadstate.h +++ b/kernel/src/api/v4/threadstate.h @@ -90,6 +90,8 @@ public: { return state == waiting_timeout; } bool is_polling() { return state == polling; } + bool is_polling_or_waiting() + { return is_polling() || is_waiting(); } bool is_locked_running() { return state == locked_running; } bool is_locked_waiting() diff --git a/user/include/l4/amd64/arch.h b/user/include/l4/amd64/arch.h index f0077adf..6baee191 100644 --- a/user/include/l4/amd64/arch.h +++ b/user/include/l4/amd64/arch.h @@ -59,12 +59,13 @@ L4_INLINE L4_Fpage_t L4_Fpage (L4_IoFpage_t f) L4_INLINE L4_Fpage_t L4_IoFpage (L4_Word_t BasePort, int FpageSize) { L4_IoFpage_t fp; + L4_Fpage_t out; L4_Word_t msb = __L4_Msb (FpageSize); + fp.X.p = BasePort; fp.X.__two = 2; fp.X.s = (1UL << msb) < (L4_Word_t) FpageSize ? msb + 1 : msb; fp.X.rwx = L4_NoAccess; - L4_Fpage_t out; out.raw = fp.raw; return out; } @@ -72,11 +73,12 @@ L4_INLINE L4_Fpage_t L4_IoFpage (L4_Word_t BasePort, int FpageSize) L4_INLINE L4_Fpage_t L4_IoFpageLog2 (L4_Word_t BasePort, int FpageSize) { L4_IoFpage_t fp; + L4_Fpage_t out; + fp.X.p = BasePort; fp.X.__two = 2; fp.X.s = FpageSize; fp.X.rwx = L4_NoAccess; - L4_Fpage_t out; out.raw = fp.raw; return out; } diff --git a/user/include/l4/ia32/arch.h b/user/include/l4/ia32/arch.h index c7843bda..ed221d65 100644 --- a/user/include/l4/ia32/arch.h +++ b/user/include/l4/ia32/arch.h @@ -55,12 +55,13 @@ L4_INLINE L4_Fpage_t L4_Fpage (L4_IoFpage_t f) L4_INLINE L4_Fpage_t L4_IoFpage (L4_Word_t BasePort, int FpageSize) { L4_IoFpage_t fp; + L4_Fpage_t out; L4_Word_t msb = __L4_Msb (FpageSize); + fp.X.p = BasePort; fp.X.__two = 2; fp.X.s = (1UL << msb) < (L4_Word_t) FpageSize ? msb + 1 : msb; fp.X.rwx = L4_NoAccess; - L4_Fpage_t out; out.raw = fp.raw; return out; } @@ -68,11 +69,12 @@ L4_INLINE L4_Fpage_t L4_IoFpage (L4_Word_t BasePort, int FpageSize) L4_INLINE L4_Fpage_t L4_IoFpageLog2 (L4_Word_t BasePort, int FpageSize) { L4_IoFpage_t fp; + L4_Fpage_t out; + fp.X.p = BasePort; fp.X.__two = 2; fp.X.s = FpageSize; fp.X.rwx = L4_NoAccess; - L4_Fpage_t out; out.raw = fp.raw; return out; }