1/* 2 * Copyright 2014, General Dynamics C4 Systems 3 * 4 * This software may be distributed and modified according to the terms of 5 * the GNU General Public License version 2. Note that NO WARRANTY is provided. 6 * See "LICENSE_GPLv2.txt" for details. 7 * 8 * @TAG(GD_GPL) 9 */ 10 11#include <types.h> 12#include <api/failures.h> 13#include <machine/registerset.h> 14#include <object/structures.h> 15#include <arch/object/tcb.h> 16#include <arch/machine.h> 17 18word_t CONST Arch_decodeTransfer(word_t flags) 19{ 20 return 0; 21} 22 23exception_t CONST Arch_performTransfer(word_t arch, tcb_t *tcb_src, tcb_t *tcb_dest) 24{ 25 return EXCEPTION_NONE; 26} 27 28#ifdef CONFIG_VTX 29void Arch_leaveVMAsyncTransfer(tcb_t *tcb) 30{ 31 vcpu_sysvmenter_reply_to_user(tcb); 32} 33 34static exception_t performSetEPTRoot(tcb_t *tcb, cap_t cap, cte_t *slot) 35{ 36 cte_t *rootSlot; 37 exception_t e; 38 39 rootSlot = TCB_PTR_CTE_PTR(tcb, tcbArchEPTRoot); 40 e = cteDelete(rootSlot, true); 41 if (e != EXCEPTION_NONE) { 42 return e; 43 } 44 45 cteInsert(cap, slot, rootSlot); 46 47 setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart); 48 return EXCEPTION_NONE; 49} 50 51exception_t decodeSetEPTRoot(cap_t cap, extra_caps_t excaps) 52{ 53 cap_t rootCap; 54 cte_t *rootSlot; 55 deriveCap_ret_t dc_ret; 56 57 rootSlot = excaps.excaprefs[0]; 58 59 if (rootSlot == NULL) { 60 userError("TCB SetEPTRoot: Truncated message."); 61 current_syscall_error.type = seL4_TruncatedMessage; 62 return EXCEPTION_SYSCALL_ERROR; 63 } 64 65 rootCap = rootSlot->cap; 66 67 if (cap_get_capType(rootCap) != cap_ept_pml4_cap) { 68 userError("TCB SetEPTRoot: EPT PDPT is invalid."); 69 current_syscall_error.type = seL4_IllegalOperation; 70 return EXCEPTION_SYSCALL_ERROR; 71 } 72 73 dc_ret = deriveCap(rootSlot, rootCap); 74 if (dc_ret.status != EXCEPTION_NONE) { 75 return dc_ret.status; 76 } 77 78 if (!cap_ept_pml4_cap_get_capPML4IsMapped(dc_ret.cap)) { 79 userError("decodeSetEPTRoot: Invalid EPT cap."); 80 current_syscall_error.type = seL4_IllegalOperation; 81 return EXCEPTION_SYSCALL_ERROR; 82 } 83 84 return performSetEPTRoot(TCB_PTR(cap_thread_cap_get_capTCBPtr(cap)), dc_ret.cap, rootSlot); 85} 86#endif 87 88#ifdef ENABLE_SMP_SUPPORT 89void 90Arch_migrateTCB(tcb_t *thread) 91{ 92 /* check if thread own its current core FPU */ 93 if (nativeThreadUsingFPU(thread)) { 94 switchFpuOwner(NULL, thread->tcbAffinity); 95 } 96} 97#endif /* ENABLE_SMP_SUPPORT */ 98 99void 100Arch_setTCBIPCBuffer(tcb_t *thread, word_t bufferAddr) 101{ 102} 103