FreeBSD/sys/amd64/vmm/amd/svm.c
/*
 * Inject an event to vcpu as described in section 15.20, "Event injection".
 */
Inject an event to vcpu as described in section 15.20, "Event injection".
Inject an event to vcpu as described in section 15 . 20 " Event injection " .
static void
svm_eventinject(struct svm_softc *sc, int vcpu, int intr_type, int vector,
		 uint32_t error, bool ec_valid)
{
	struct vmcb_ctrl *ctrl;
	ctrl = svm_get_vmcb_ctrl(sc, vcpu);
	KASSERT((ctrl->eventinj & VMCB_EVENTINJ_VALID) == 0,
	    ("%s: event already pending %#lx", __func__, ctrl->eventinj));
	KASSERT(vector >=0 && vector <= 255, ("%s: invalid vector %d",
	    __func__, vector));
	switch (intr_type) {
	case VMCB_EVENTINJ_TYPE_INTR:
	case VMCB_EVENTINJ_TYPE_NMI:
	case VMCB_EVENTINJ_TYPE_INTn:
		break;
	case VMCB_EVENTINJ_TYPE_EXCEPTION:
		if (vector >= 0 && vector <= 31 && vector != 2)
			break;
	default:
		panic("%s: invalid intr_type/vector: %d/%d", __func__,
		    intr_type, vector);
	}
	ctrl->eventinj = vector | (intr_type << 8) | VMCB_EVENTINJ_VALID;
	if (ec_valid) {
		ctrl->eventinj |= VMCB_EVENTINJ_EC_VALID;
		ctrl->eventinj |= (uint64_t)error << 32;
		VCPU_CTR3(sc->vm, vcpu, "Injecting %s at vector %d errcode %#x",
		    intrtype_to_str(intr_type), vector, error);
	} else {
		VCPU_CTR2(sc->vm, vcpu, "Injecting %s at vector %d",
		    intrtype_to_str(intr_type), vector);
	}
}
static void svm_eventinject ( struct svm_softc * sc , int vcpu , int intr_type , int vector , uint32_t error , bool ec_valid ) { struct vmcb_ctrl * ctrl ; ctrl = svm_get_vmcb_ctrl ( sc , vcpu ) ; KASSERT ( ( ctrl -> eventinj & VMCB_EVENTINJ_VALID ) == 0 , ( " " , __func__ , ctrl -> eventinj ) ) ; KASSERT ( vector >= 0 && vector <= 255 , ( " " , __func__ , vector ) ) ; switch ( intr_type ) { case VMCB_EVENTINJ_TYPE_INTR : case VMCB_EVENTINJ_TYPE_NMI : case VMCB_EVENTINJ_TYPE_INTn : break ; case VMCB_EVENTINJ_TYPE_EXCEPTION : if ( vector >= 0 && vector <= 31 && vector != 2 ) break ; default : panic ( " " , __func__ , intr_type , vector ) ; } ctrl -> eventinj = vector | ( intr_type << 8 ) | VMCB_EVENTINJ_VALID ; if ( ec_valid ) { ctrl -> eventinj |= VMCB_EVENTINJ_EC_VALID ; ctrl -> eventinj |= ( uint64_t ) error << 32 ; VCPU_CTR3 ( sc -> vm , vcpu , " " , intrtype_to_str ( intr_type ) , vector , error ) ; } else { VCPU_CTR2 ( sc -> vm , vcpu , " " , intrtype_to_str ( intr_type ) , vector ) ; } }
Inject an event to vcpu as described in section 15.20, "Event injection".
Inject an event to vcpu as described in section 15 . 20 " Event injection " .
/* FALLTHROUGH */