コード例 #1
0
ファイル: vmdb.c プロジェクト: bhargavz/cloudproxy
void vmdb_remote_execute ( GUEST_CPU_HANDLE gcpu, VMDB_REMOTE_PARAMS *params)
    {
    const VIRTUAL_CPU_ID   *vcpu = guest_vcpu(gcpu);

    if (NULL != vcpu) {
        IPC_DESTINATION dst;

        dst.addr_shorthand = IPI_DST_ALL_EXCLUDING_SELF;
        params->guest_id = vcpu->guest_id;
        ipc_execute_handler(dst, (IPC_HANDLER_FN) vmdb_remote_handler, params);
        }
    else {
        VMDB_LOG(level_error,"%s Failed to locate VCPU\n", __FUNCTION__);
        }
    }
コード例 #2
0
ファイル: guest_control.c プロジェクト: 01org/ikgt-core
/* ---------------------------- APIs --------------------------------------- */
void guest_control_setup(guest_handle_t guest, const vmexit_control_t *request)
{
	guest_gcpu_econtext_t ctx;
	guest_cpu_handle_t gcpu;
	mon_state_t mon_state;
	cpu_id_t this_hcpu_id = hw_cpu_id();

	MON_ASSERT(guest);

	/* setup vmexit requests without applying */
	for (gcpu = mon_guest_gcpu_first(guest, &ctx); gcpu;
	     gcpu = mon_guest_gcpu_next(&ctx))
		gcpu_control_setup_only(gcpu, request);

	/* now apply */
	mon_state = mon_get_state();

	if (MON_STATE_BOOT == mon_state) {
		/* may be run on BSP only */
		MON_ASSERT(0 == this_hcpu_id);

		/* single thread mode with all APs yet not init */
		for (gcpu = mon_guest_gcpu_first(guest, &ctx); gcpu;
		     gcpu = mon_guest_gcpu_next(&ctx))
			gcpu_control_apply_only(gcpu);
	} else if (MON_STATE_RUN == mon_state) {
		ipc_comm_guest_struct_t ipc;
		uint32_t wait_for_ipc_count = 0;
		ipc_destination_t ipc_dst;

		mon_memset(&ipc, 0, sizeof(ipc));
		mon_memset(&ipc_dst, 0, sizeof(ipc_dst));

		/* multi-thread mode with all APs ready and running
		 * or in Wait-For-SIPI state on behalf of guest */

		ipc.guest = guest;

		/* first apply for gcpus allocated for this hw cpu */
		apply_vmexit_config(this_hcpu_id, &ipc);

		/* reset executed counter and flush memory */
		hw_assign_as_barrier(&(ipc.executed), 0);

		/* send for execution */
		ipc_dst.addr_shorthand = IPI_DST_ALL_EXCLUDING_SELF;
		wait_for_ipc_count =
			ipc_execute_handler(ipc_dst, apply_vmexit_config, &ipc);

		/* wait for execution finish */
		while (wait_for_ipc_count != ipc.executed) {
			/* avoid deadlock - process one IPC if exist */
			ipc_process_one_ipc();
			hw_pause();
		}
	} else {
		/* not supported mode */
		MON_LOG(mask_anonymous, level_trace,
			"Unsupported global mon_state=%d in"
			" guest_request_vmexit_on()\n",
			mon_state);
		MON_DEADLOOP();
	}
}