aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBojan Novković <bojan.novkovic@fer.hr>2023-12-07 22:40:28 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2024-01-05 00:24:36 +0000
commit6d80d20a64a414782ab2e06ec0603bb40ecfbf41 (patch)
tree2c217ba5bcaa2b633f6dc30ad539039df33ee909
parent1309b3fd01138c7a65a22c2297f261be3d313f0e (diff)
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 78c1d174a1e13c6522bd4d663225fc9cbabc329d)
-rw-r--r--sys/amd64/vmm/amd/svm.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/amd64/vmm/amd/svm.c b/sys/amd64/vmm/amd/svm.c
index 33ab2eeaedf4..a502632f6ed6 100644
--- a/sys/amd64/vmm/amd/svm.c
+++ b/sys/amd64/vmm/amd/svm.c
@@ -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;