vmm: refactor event reflection in AMD SVM

This patch refactors AMD SVM event reflection to allow events to be
propagated to userland, rather than always reflected into the guest.

This is necessary to implement some capabilities that request VMEXITs
when a specific exception occurs (e.g. VM_CAP_BPT_EXIT).

Reviewed by:	jhb
Sponsored by:	Google, Inc. (GSoC 2022)
Differential Revision:	https://reviews.freebsd.org/D42405

(cherry picked from commit 78c1d174a1)
This commit is contained in:
Bojan Novković 2023-12-07 14:40:28 -08:00 committed by John Baldwin
parent 1309b3fd01
commit 6d80d20a64

View file

@ -1442,11 +1442,12 @@ svm_vmexit(struct svm_softc *svm_sc, struct svm_vcpu *vcpu,
info1 = 0;
break;
}
KASSERT(vmexit->inst_length == 0, ("invalid inst_length (%d) "
"when reflecting exception %d into guest",
vmexit->inst_length, idtvec));
if (reflect) {
KASSERT(vmexit->inst_length == 0,
("invalid inst_length (%d) "
"when reflecting exception %d into guest",
vmexit->inst_length, idtvec));
/* Reflect the exception back into the guest */
SVM_CTR2(vcpu, "Reflecting exception "
"%d/%#x into the guest", idtvec, (int)info1);
@ -1454,8 +1455,8 @@ svm_vmexit(struct svm_softc *svm_sc, struct svm_vcpu *vcpu,
errcode_valid, info1, 0);
KASSERT(error == 0, ("%s: vm_inject_exception error %d",
__func__, error));
handled = 1;
}
handled = 1;
break;
case VMCB_EXIT_MSR: /* MSR access. */
eax = state->rax;