コード例 #1
0
ファイル: vmm_vcpu_irq.c プロジェクト: 32bitmicro/xvisor
static void vcpu_irq_wfi_try_resume(struct vmm_vcpu *vcpu, void *data)
{
	/* Try to resume the VCPU */
	if (data == (void *)TRUE) {
		vmm_manager_vcpu_resume(vcpu);
	}
}
コード例 #2
0
ファイル: cmd_vcpu.c プロジェクト: nmaiti/xvisor
static int cmd_vcpu_resume(vmm_chardev_t *cdev, int id)
{
	int ret = VMM_EFAIL;
	vmm_vcpu_t *vcpu = vmm_manager_vcpu(id);
	if (vcpu) {
		if ((ret = vmm_manager_vcpu_resume(vcpu))) {
			vmm_cprintf(cdev, "%s: Failed to resume\n", 
					  vcpu->name);
		} else {
			vmm_cprintf(cdev, "%s: Resumed\n", vcpu->name);
		}
	} else {
		vmm_cprintf(cdev, "Failed to find vcpu\n");
	}
	return ret;
}
コード例 #3
0
ファイル: vmm_vcpu_irq.c プロジェクト: 32bitmicro/xvisor
static int vcpu_irq_wfi_resume(struct vmm_vcpu *vcpu, bool use_async_ipi)
{
	int rc;
	irq_flags_t flags;
	bool try_vcpu_resume = FALSE;

	if (!vcpu) {
		return VMM_EINVALID;
	}

	/* Lock VCPU WFI */
	vmm_spin_lock_irqsave_lite(&vcpu->irqs.wfi.lock, flags);

	/* If VCPU was in wfi state then update state. */
	if (vcpu->irqs.wfi.state) {
		try_vcpu_resume = TRUE;

		/* Clear wait for irq state */
		vcpu->irqs.wfi.state = FALSE;

		/* Stop wait for irq timeout event */
		vmm_timer_event_stop(vcpu->irqs.wfi.priv);

		rc = VMM_OK;
	} else {
		rc = VMM_ENOTAVAIL;
	}

	/* Unlock VCPU WFI */
	vmm_spin_unlock_irqrestore_lite(&vcpu->irqs.wfi.lock, flags);

	/* Try to resume the VCPU */
	if (use_async_ipi) {
		/* The vcpu_irq_wfi_try_resume() will be executed by async
		 * IPI worker on hcpu assigned to vcpu (i.e. vcpu->hcpu).
		 * Case 1: try_vcpu_resume == TRUE
		 *   The vcpu_irq_wfi_try_resume() will try to resume vcpu
		 *   using vmm_manager_vcpu_resume(). This can fail if vcpu
		 *   is already in READY or RUNNING state.
		 * Case 2: try_resume == FALSE
		 *   The vcpu_irq_wfi_try_resume() will do nothing but
		 *   if vcpu was in RUNNING state then it will force atleast
		 *   one context switch for vcpu. This will help hardware
		 *   assisted interrupt-controller emulators to flush out
		 *   pending interrupts when vcpu is restored.
		 */
		vmm_manager_vcpu_hcpu_func(vcpu,
			VMM_VCPU_STATE_INTERRUPTIBLE,
			vcpu_irq_wfi_try_resume,
			(try_vcpu_resume) ? (void *)TRUE : (void *)FALSE);
	} else {
		/* Case 1: try_vcpu_resume == TRUE
		 *   We directly resume vcpu using vmm_manager_vcpu_resume().
		 *   This can fail if vcpu is in READY or RUNNING state.
		 * Case 2: try_vcpu_resume == FALSE
		 *   We do nothing.
		 */
		if (try_vcpu_resume) {
			vmm_manager_vcpu_resume(vcpu);
		}
	}

	return rc;
}