示例#1
0
static void free_contiguous_memory(unsigned long mem,
				   u_int tot_mem_len, u_int mem_order) {
  if(unlikely(enable_debug))
    printk("[DNA] free_contiguous_memory(0x%08lx,%u,%d)\n",
	   mem, tot_mem_len, mem_order);

  if(mem != 0) {
    unreserve_memory(mem, tot_mem_len);
    free_pages(mem, mem_order);
  }
}
示例#2
0
int
master_exit(void)
{
    /* Determine if any enclaves are running - if so, we cannot exit */
    struct enclave_info * enclaves = NULL;
    uint32_t num_enclaves;

    enclaves = hobbes_get_enclave_list(&num_enclaves);
    if (enclaves == NULL) {
	ERROR("Could not retrieve enclave list\n");
	return -1;
    }

    switch (num_enclaves) {
	case 0:
	    ERROR("0 active enclaves: the master DB has been corrupted\n");
	    return -1;

	case 1:
	    break;
	
	default:
	    ERROR("Cannot stop Leviathan: there are %d active enclaves that must be destroyed first\n",
		num_enclaves - 1);
	    free(enclaves);
	    return -1;
    }

    /* Ensure that the enclave is just the master */
    if (enclaves[0].type != MASTER_ENCLAVE) {
	ERROR("Only 1 enclave running, but it is not the master. Cannot stop Leviathan\n");
	free(enclaves);
	return -1;
    }

    free(enclaves);

    /* Re-online all resources */
    release_memory();
    release_cpus();

    /* Ensure all resources are unlocked */
    unreserve_memory();
    unreserve_cpus();

    return 0;
}