From f15959a737706a348c388a43e3f0cd801a9721b8 Mon Sep 17 00:00:00 2001 From: Joel Beeren <joel.beeren@nicta.com.au> Date: Wed, 15 Jul 2015 12:18:11 +1000 Subject: [PATCH] SELFOUR-220: only delete reply cap when waiting on sync endpoint --- haskell/src/SEL4/API/Syscall.lhs | 5 +++-- src/api/syscall.c | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/haskell/src/SEL4/API/Syscall.lhs b/haskell/src/SEL4/API/Syscall.lhs index 935ad802c..94b1ce82f 100644 --- a/haskell/src/SEL4/API/Syscall.lhs +++ b/haskell/src/SEL4/API/Syscall.lhs @@ -178,13 +178,14 @@ The "Wait" system call blocks waiting to receive a message through a specified e > handleWait :: Kernel () > handleWait = do > thread <- getCurThread -> deleteCallerCap thread > epCPtr <- asUser thread $ liftM CPtr $ getRegister capRegister > (capFaultOnFailure epCPtr True $ do > epCap <- lookupCap thread epCPtr > case epCap of > EndpointCap { capEPCanReceive = True } -> -> withoutFailure $ receiveIPC thread epCap +> withoutFailure $ do +> deleteCallerCap thread +> receiveIPC thread epCap > AsyncEndpointCap { capAEPCanReceive = True } -> > withoutFailure $ receiveAsyncIPC thread epCap > _ -> throw $ MissingCapability { missingCapBitsLeft = 0 }) diff --git a/src/api/syscall.c b/src/api/syscall.c index f3f7d3a3d..175d4f028 100644 --- a/src/api/syscall.c +++ b/src/api/syscall.c @@ -308,8 +308,6 @@ handleWait(void) word_t epCPtr; lookupCap_ret_t lu_ret; - deleteCallerCap(ksCurThread); - epCPtr = getRegister(ksCurThread, capRegister); lu_ret = lookupCap(ksCurThread, epCPtr); @@ -322,6 +320,7 @@ handleWait(void) switch (cap_get_capType(lu_ret.cap)) { case cap_endpoint_cap: + if (unlikely(!cap_endpoint_cap_get_capCanReceive(lu_ret.cap))) { current_lookup_fault = lookup_fault_missing_capability_new(0); current_fault = fault_cap_fault_new(epCPtr, true); @@ -329,6 +328,7 @@ handleWait(void) break; } + deleteCallerCap(ksCurThread); receiveIPC(ksCurThread, lu_ret.cap); break; -- GitLab