Skip to content
Snippets Groups Projects
Commit e7c9885f authored by Adrian Danis's avatar Adrian Danis
Browse files

ia32: Rework the notion of isValidVTableRoot to be a check for what is...

ia32: Rework the notion of isValidVTableRoot to be a check for what is permissable for a TCB to contain in its VTableRoot, and create a new isValidNativeRoot to be a check for whether a capability is a PD or PDPT that can be directly run. VTableRoots that are not native would be something like EPT if using vtx
parent f2ac14f1
No related branches found
No related tags found
No related merge requests found
......@@ -41,7 +41,7 @@ bool_t map_kernel_window(
#endif
);
void *getValidVSpaceRoot(cap_t vspace_cap);
void *getValidNativeRoot(cap_t vspace_cap);
pde_t *get_boot_pd(void);
void* map_temp_boot_page(void* entry, uint32_t large_pages);
bool_t init_vm_state(pdpte_t *kernel_pdpt, pde_t* kernel_pd, pte_t* kernel_pt);
......@@ -70,6 +70,7 @@ void deleteASID(asid_t asid, void* vspace);
void unmapPage(vm_page_size_t page_size, asid_t asid, vptr_t vptr, void *pptr);
void setVMRoot(tcb_t *tcb);
bool_t CONST isValidVTableRoot(cap_t cap);
bool_t CONST isValidNativeRoot(cap_t cap);
exception_t checkValidIPCBuffer(vptr_t vptr, cap_t cap);
vm_rights_t CONST maskVMRights(vm_rights_t vm_rights, cap_rights_t cap_rights_mask);
exception_t decodeIA32MMUInvocation(word_t label, unsigned int length, cptr_t cptr, cte_t *cte, cap_t cap, extra_caps_t extraCaps, word_t* buffer);
......
......@@ -158,7 +158,7 @@ endpoint_ptr_set_epQueue_head_np(endpoint_t *ep_ptr, word_t epQueue_head)
static inline bool_t
isValidVTableRoot_fp(cap_t pd_cap)
isValidNativeRoot_fp(cap_t pd_cap)
{
#ifdef CONFIG_PAE_PAGING
return cap_capType_equals(pd_cap, cap_pdpt_cap) && cap_pdpt_cap_get_capPDPTIsMapped(pd_cap);
......@@ -323,7 +323,7 @@ fastpath_call(word_t cptr, word_t msgInfo)
#endif
/* Ensure that the destination has a valid VTable. */
if (unlikely(! isValidVTableRoot_fp(newVTable))) {
if (unlikely(! isValidNativeRoot_fp(newVTable))) {
slowpath(SysCall);
}
......@@ -459,7 +459,7 @@ fastpath_reply_wait(word_t cptr, word_t msgInfo)
#endif
/* Ensure that the destination has a valid MMU. */
if (unlikely(! isValidVTableRoot_fp (newVTable))) {
if (unlikely(! isValidNativeRoot_fp (newVTable))) {
slowpath(SysReplyWait);
}
......
......@@ -1062,7 +1062,7 @@ static void flushTable(void *vspace, word_t vptr, pte_t* pt)
/* check if page table belongs to current address space */
threadRoot = TCB_PTR_CTE_PTR(ksCurThread, tcbVTable)->cap;
if (isValidVTableRoot(threadRoot) && (void*)pptr_of_cap(threadRoot) == vspace) {
if (isValidNativeRoot(threadRoot) && (void*)pptr_of_cap(threadRoot) == vspace) {
/* find valid mappings */
for (i = 0; i < BIT(PT_BITS); i++) {
if (pte_get_present(pt[i])) {
......@@ -1110,7 +1110,7 @@ void setVMRoot(tcb_t* tcb)
threadRoot = TCB_PTR_CTE_PTR(tcb, tcbVTable)->cap;
vspace_root = getValidVSpaceRoot(threadRoot);
vspace_root = getValidNativeRoot(threadRoot);
if (!vspace_root) {
setCurrentPD(pptr_to_paddr(ia32KSkernelPDPT));
return;
......@@ -1197,7 +1197,7 @@ void unmapPage(vm_page_size_t page_size, asid_t asid, vptr_t vptr, void *pptr)
/* check if page belongs to current address space */
threadRoot = TCB_PTR_CTE_PTR(ksCurThread, tcbVTable)->cap;
if (isValidVTableRoot(threadRoot) && (void*)pptr_of_cap(threadRoot) == find_ret.vspace_root) {
if (isValidNativeRoot(threadRoot) && (void*)pptr_of_cap(threadRoot) == find_ret.vspace_root) {
invalidateTLBentry(vptr);
}
......@@ -1365,7 +1365,7 @@ decodeIA32PageTableInvocation(
attr = vmAttributesFromWord(getSyscallArg(1, buffer));
vspaceCap = extraCaps.excaprefs[0]->cap;
if (!isValidVTableRoot(vspaceCap)) {
if (!isValidNativeRoot(vspaceCap)) {
current_syscall_error.type = seL4_InvalidCapability;
current_syscall_error.invalidCapNumber = 1;
......@@ -1487,7 +1487,7 @@ decodeIA32FrameInvocation(
return EXCEPTION_SYSCALL_ERROR;
}
if (!isValidVTableRoot(vspaceCap)) {
if (!isValidNativeRoot(vspaceCap)) {
userError("IA32Frame: Attempting to map frame into invalid page directory cap.");
current_syscall_error.type = seL4_InvalidCapability;
current_syscall_error.invalidCapNumber = 1;
......@@ -1627,7 +1627,7 @@ decodeIA32FrameInvocation(
vmAttr = vmAttributesFromWord(getSyscallArg(1, buffer));
vspaceCap = extraCaps.excaprefs[0]->cap;
if (!isValidVTableRoot(vspaceCap)) {
if (!isValidNativeRoot(vspaceCap)) {
userError("IA32FrameRemap: Attempting to map frame into invalid page directory.");
current_syscall_error.type = seL4_InvalidCapability;
current_syscall_error.invalidCapNumber = 1;
......
......@@ -181,15 +181,20 @@ bool_t CONST isVTableRoot(cap_t cap)
return cap_get_capType(cap) == cap_page_directory_cap;
}
bool_t CONST isValidVTableRoot(cap_t cap)
bool_t CONST isValidNativeRoot(cap_t cap)
{
return isVTableRoot(cap) &&
cap_page_directory_cap_get_capPDIsMapped(cap);
}
void *getValidVSpaceRoot(cap_t vspace_cap)
bool_t CONST isValidVTableRoot(cap_t cap)
{
return isValidNativeRoot(cap);
}
void *getValidNativeRoot(cap_t vspace_cap)
{
if (isValidVTableRoot(vspace_cap)) {
if (isValidNativeRoot(vspace_cap)) {
return PDE_PTR(cap_page_directory_cap_get_capPDBasePtr(vspace_cap));
}
return NULL;
......
......@@ -223,7 +223,7 @@ bool_t CONST isVTableRoot(cap_t cap)
return cap_get_capType(cap) == cap_pdpt_cap;
}
bool_t CONST isValidVTableRoot(cap_t cap)
bool_t CONST isValidNativeRoot(cap_t cap)
{
if (!isVTableRoot(cap) ||
!cap_pdpt_cap_get_capPDPTIsMapped(cap)) {
......@@ -232,9 +232,13 @@ bool_t CONST isValidVTableRoot(cap_t cap)
return true;
}
void *getValidVSpaceRoot(cap_t vspace_cap)
bool_t CONST isValidVTableRoot(cap_t cap) {
return isValidNativeRoot(cap);
}
void *getValidNativeRoot(cap_t vspace_cap)
{
if (isValidVTableRoot(vspace_cap)) {
if (isValidNativeRoot(vspace_cap)) {
return PDPTE_PTR(cap_pdpt_cap_get_capPDPTBasePtr(vspace_cap));
}
return NULL;
......@@ -304,7 +308,7 @@ void unmapPageDirectory(asid_t asid, vptr_t vaddr, pde_t *pd)
);
/* check if page directory belongs to current address space */
threadRoot = TCB_PTR_CTE_PTR(ksCurThread, tcbVTable)->cap;
if (isValidVTableRoot(threadRoot) && (void*)pptr_of_cap(threadRoot) == find_ret.vspace_root) {
if (isValidNativeRoot(threadRoot) && (void*)pptr_of_cap(threadRoot) == find_ret.vspace_root) {
/* according to the intel manual if we modify a pdpt we must
* reload cr3 */
write_cr3(read_cr3());
......@@ -377,7 +381,7 @@ decodeIA32PageDirectoryInvocation(
attr = vmAttributesFromWord(getSyscallArg(1, buffer));
vspaceCap = extraCaps.excaprefs[0]->cap;
if (!isValidVTableRoot(vspaceCap)) {
if (!isValidNativeRoot(vspaceCap)) {
current_syscall_error.type = seL4_InvalidCapability;
current_syscall_error.invalidCapNumber = 1;
return EXCEPTION_SYSCALL_ERROR;
......@@ -436,7 +440,7 @@ decodeIA32PageDirectoryInvocation(
/* according to the intel manual if we modify a pdpt we must
* reload cr3 */
threadRoot = TCB_PTR_CTE_PTR(ksCurThread, tcbVTable)->cap;
if (isValidVTableRoot(threadRoot) && (void*)pptr_of_cap(threadRoot) == (void*)pptr_of_cap(vspaceCap)) {
if (isValidNativeRoot(threadRoot) && (void*)pptr_of_cap(threadRoot) == (void*)pptr_of_cap(vspaceCap)) {
write_cr3(read_cr3());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment