seL4/include/object/notification.h
Curtis Millar 6a9e860e4e mcs: Only unbind extant donated ntfn sc
When determining whether a SC donated from the notification should be
returned, we must ensure not to try and return a NULL SC to a
notification with not bound SC.

This could occur when a passive server performs a NBSendWait/NBSendRecv
with a notification in the receive phase, where the SC for the receiver
was returned in the send phase and the notification has no bound SC.

Signed-off-by: Curtis Millar <curtis.millar@data61.csiro.au>
2021-04-29 12:07:07 +10:00

39 lines
1.2 KiB
C

/*
* Copyright 2014, General Dynamics C4 Systems
*
* SPDX-License-Identifier: GPL-2.0-only
*/
#pragma once
#include <types.h>
#include <object/structures.h>
void sendSignal(notification_t *ntfnPtr, word_t badge);
void receiveSignal(tcb_t *thread, cap_t cap, bool_t isBlocking);
void cancelAllSignals(notification_t *ntfnPtr);
void cancelSignal(tcb_t *threadPtr, notification_t *ntfnPtr);
void completeSignal(notification_t *ntfnPtr, tcb_t *tcb);
void unbindMaybeNotification(notification_t *ntfnPtr);
void unbindNotification(tcb_t *tcb);
void bindNotification(tcb_t *tcb, notification_t *ntfnPtr);
#ifdef CONFIG_KERNEL_MCS
void reorderNTFN(notification_t *notification, tcb_t *thread);
static inline void maybeReturnSchedContext(notification_t *ntfnPtr, tcb_t *tcb)
{
sched_context_t *sc = SC_PTR(notification_ptr_get_ntfnSchedContext(ntfnPtr));
if (sc != NULL && sc == tcb->tcbSchedContext) {
tcb->tcbSchedContext = NULL;
sc->scTcb = NULL;
/* If the current thread returns its sched context then it should not
by default continue running. */
if (tcb == NODE_STATE(ksCurThread)) {
rescheduleRequired();
}
}
}
#endif