int cnode_revoke(env_t env, seL4_CPtr cap) { cspacepath_t path; vka_cspace_make_path(&env->vka, cap, &path); return vka_cnode_revoke(&path); }
void thread_release(struct proc_tcb *thread) { assert(thread); assert(thread->vspaceRef); cspacepath_t path; vka_cspace_make_path(&procServ.vka, thread_tcb_obj(thread), &path); vka_cnode_revoke(&path); sel4utils_clean_up_thread(&procServ.vka, &thread->vspaceRef->vspace, &thread->sel4utilsThread); vs_unref(thread->vspaceRef); memset(thread, 0, sizeof(struct proc_tcb)); }
/* Run a single test. * Each test is launched as its own process. */ int run_test(struct testcase *test) { UNUSED int error; sel4utils_process_t test_process; /* Test intro banner. */ printf(" %s\n", test->name); error = sel4utils_configure_process(&test_process, &env.vka, &env.vspace, env.init->priority, TESTS_APP); assert(error == 0); /* set up caps about the process */ env.init->page_directory = copy_cap_to_process(&test_process, test_process.pd.cptr); env.init->root_cnode = SEL4UTILS_CNODE_SLOT; env.init->tcb = copy_cap_to_process(&test_process, test_process.thread.tcb.cptr); env.init->domain = copy_cap_to_process(&test_process, simple_get_init_cap(&env.simple, seL4_CapDomain)); #ifndef CONFIG_KERNEL_STABLE env.init->asid_pool = copy_cap_to_process(&test_process, simple_get_init_cap(&env.simple, seL4_CapInitThreadASIDPool)); #endif /* CONFIG_KERNEL_STABLE */ #ifdef CONFIG_IOMMU env.init->io_space = copy_cap_to_process(&test_process, simple_get_init_cap(&env.simple, seL4_CapIOSpace)); #endif /* CONFIG_IOMMU */ /* setup data about untypeds */ env.init->untypeds = copy_untypeds_to_process(&test_process, untypeds, num_untypeds); copy_timer_caps(env.init, &env, &test_process); /* copy the fault endpoint - we wait on the endpoint for a message * or a fault to see when the test finishes */ seL4_CPtr endpoint = copy_cap_to_process(&test_process, test_process.fault_endpoint.cptr); /* WARNING: DO NOT COPY MORE CAPS TO THE PROCESS BEYOND THIS POINT, * AS THE SLOTS WILL BE CONSIDERED FREE AND OVERRIDDEN BY THE TEST PROCESS. */ /* set up free slot range */ env.init->cspace_size_bits = CONFIG_SEL4UTILS_CSPACE_SIZE_BITS; env.init->free_slots.start = endpoint + 1; env.init->free_slots.end = (1u << CONFIG_SEL4UTILS_CSPACE_SIZE_BITS); assert(env.init->free_slots.start < env.init->free_slots.end); /* copy test name */ strncpy(env.init->name, test->name + strlen("TEST_"), TEST_NAME_MAX); #ifdef SEL4_DEBUG_KERNEL seL4_DebugNameThread(test_process.thread.tcb.cptr, env.init->name); #endif /* set up args for the test process */ char endpoint_string[10]; char sel4test_name[] = { TESTS_APP }; char zero_string[] = {"0"}; char *argv[] = {sel4test_name, zero_string, endpoint_string}; argv[0] = endpoint_string; snprintf(endpoint_string, 10, "%d", endpoint); /* spawn the process */ error = sel4utils_spawn_process_v(&test_process, &env.vka, &env.vspace, ARRAY_SIZE(argv), argv, 1); assert(error == 0); /* send env.init_data to the new process */ void *remote_vaddr = send_init_data(&env, test_process.fault_endpoint.cptr, &test_process); /* wait on it to finish or fault, report result */ seL4_Word badge; seL4_MessageInfo_t info = seL4_Wait(test_process.fault_endpoint.cptr, &badge); int result = seL4_GetMR(0); if (seL4_MessageInfo_get_label(info) != seL4_NoFault) { sel4utils_print_fault_message(info, test->name); result = FAILURE; } /* unmap the env.init data frame */ vspace_unmap_pages(&test_process.vspace, remote_vaddr, 1, PAGE_BITS_4K, NULL); /* reset all the untypeds for the next test */ for (int i = 0; i < num_untypeds; i++) { cspacepath_t path; vka_cspace_make_path(&env.vka, untypeds[i].cptr, &path); vka_cnode_revoke(&path); } /* destroy the process */ sel4utils_destroy_process(&test_process, &env.vka); test_assert(result == SUCCESS); return result; }