Skip to content

Commit

Permalink
capDL-tool, capdl-loader-app: support bound nfns
Browse files Browse the repository at this point in the history
Add support for binding notifications to TCBs.

Signed-off-by: Nick Spinale <nick@nickspinale.com>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
  • Loading branch information
nspin authored and lsf37 committed Jul 1, 2024
1 parent e3ff513 commit 60d1c3c
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
### Changes

* add support for SMC capability
* add support for binding notifications to TCBs
* enable MCS build; use `seL4_TCB_SetAffinity` only for non-MCS kernels
* allow `SchedControlCap` to refer to a secondary core
* minimal update for seL4 AArch64 VSpace API change, removing `seL4_ARM_PageGlobalDirectoryObject`
Expand Down
5 changes: 4 additions & 1 deletion capDL-tool/CapDL/Model.hs
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,11 @@ tcbSCSlot = 6
tcbTempFaultEPSlot :: Word
tcbTempFaultEPSlot = 7

tcbBoundNotificationSlot :: Word
tcbBoundNotificationSlot = 8

tcbBoundVCPUSlot :: Word
tcbBoundVCPUSlot = 8
tcbBoundVCPUSlot = 9

--
-- The string used when defining an IOSpaceMasterCap, an ASIDControlCap,
Expand Down
1 change: 1 addition & 0 deletions capDL-tool/CapDL/ParserUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ symbolic_slot =
<|> keyw "fault_ep_slot" tcbFaultEPSlot
<|> keyw "sc_slot" tcbSCSlot
<|> keyw "temp_fault_ep_slot" tcbTempFaultEPSlot
<|> keyw "bound_notification" tcbBoundNotificationSlot
<|> keyw "bound_vcpu" tcbBoundVCPUSlot

parse_slot :: MapParser Word
Expand Down
1 change: 1 addition & 0 deletions capDL-tool/CapDL/State.hs
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ validTCBSlotCap arch slot cap
| slot == tcbFaultEPSlot = is _EndpointCap cap
| slot == tcbSCSlot = is _SCCap cap
| slot == tcbTempFaultEPSlot = is _EndpointCap cap
| slot == tcbBoundNotificationSlot = is _NotificationCap cap
| slot == tcbBoundVCPUSlot = arch /= RISCV && is _VCPUCap cap
| otherwise = cap == NullCap

Expand Down
2 changes: 1 addition & 1 deletion capDL-tool/tools/capdl.vim
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ syn keyword CapDLAttribute addr affinity badge dom fault_ep G guard guard_size i
syn match CapDLCPP "[ \t]*#.*$"
syn match CapDLLiteral "\<\(0x\)\?[0-9]\+\(k\|M\)\?\( bits\)\?\>"
syn match CapDLLiteral "\<0x[0-f]\+\>"
syn keyword CapDLSymbolicSlot cspace vspace reply_slot caller_slot ipc_buffer_slot fault_ep_slot sc_slot temp_fault_ep_slot bound_vcpu
syn keyword CapDLSymbolicSlot cspace vspace reply_slot caller_slot ipc_buffer_slot fault_ep_slot sc_slot temp_fault_ep_slot bound_notification bound_vcpu

syn region Foldable start="{" end="}" fold transparent

Expand Down
3 changes: 2 additions & 1 deletion capdl-loader-app/include/capdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,10 @@ typedef struct {
#define CDL_TCB_FaultEP_Slot 5
#define CDL_TCB_SC_Slot 6
#define CDL_TCB_TemporalFaultEP_Slot 7
#define CDL_TCB_Notification_Slot 8

#if defined(CONFIG_ARM_HYPERVISOR_SUPPORT) || defined(CONFIG_VTX)
#define CDL_TCB_VCPU_SLOT 8
#define CDL_TCB_VCPU_SLOT 9
#endif

#define CDL_CapData_MakeGuard(x, y) \
Expand Down
9 changes: 9 additions & 0 deletions capdl-loader-app/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,8 @@ static void init_tcb(CDL_Model *spec, CDL_ObjID tcb)
if (cdl_ipcbuffer == NULL) {
ZF_LOGD(" Warning: TCB has no IPC buffer");
}
CDL_Cap *cdl_notification = get_cap_at(cdl_tcb, CDL_TCB_Notification_Slot);

#if defined(CONFIG_ARM_HYPERVISOR_SUPPORT) || defined(CONFIG_VTX)
CDL_Cap *cdl_vcpu = get_cap_at(cdl_tcb, CDL_TCB_VCPU_SLOT);
#endif
Expand All @@ -1030,6 +1032,7 @@ static void init_tcb(CDL_Model *spec, CDL_ObjID tcb)
seL4_CPtr sel4_vspace_root = cdl_vspace_root ? orig_caps(CDL_Cap_ObjID(cdl_vspace_root)) : 0;
seL4_CPtr sel4_ipcbuffer = cdl_ipcbuffer ? orig_caps(CDL_Cap_ObjID(cdl_ipcbuffer)) : 0;
seL4_CPtr UNUSED sel4_sc = cdl_sc ? orig_caps(CDL_Cap_ObjID(cdl_sc)) : 0;
seL4_CPtr sel4_notification = cdl_notification ? orig_caps(CDL_Cap_ObjID(cdl_notification)) : 0;
#if defined(CONFIG_ARM_HYPERVISOR_SUPPORT) || defined(CONFIG_VTX)
seL4_CPtr sel4_vcpu = cdl_vcpu ? orig_caps(CDL_Cap_ObjID(cdl_vcpu)) : 0;
#endif
Expand Down Expand Up @@ -1145,6 +1148,12 @@ static void init_tcb(CDL_Model *spec, CDL_ObjID tcb)

ZF_LOGF_IFERR(error, "");

if (sel4_notification) {
int error = seL4_TCB_BindNotification(sel4_tcb, sel4_notification);
ZF_LOGF_IFERR(error, "Failed to bind Notification %s to TCB %s",
CDL_Obj_Name(get_spec_object(spec, CDL_Cap_ObjID(cdl_notification))), CDL_Obj_Name(cdl_tcb));
}

#if defined(CONFIG_ARM_HYPERVISOR_SUPPORT) || defined(CONFIG_VTX)
if (sel4_vcpu) {
#ifdef CONFIG_ARM_HYPERVISOR_SUPPORT
Expand Down

0 comments on commit 60d1c3c

Please sign in to comment.