The branch main has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=78c1d174a1e13c6522bd4d663225fc9cbabc329d

commit 78c1d174a1e13c6522bd4d663225fc9cbabc329d
Author:     Bojan Novković <[email protected]>
AuthorDate: 2023-12-07 22:40:28 +0000
Commit:     John Baldwin <[email protected]>
CommitDate: 2023-12-07 23:10:53 +0000

    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
---
 sys/amd64/vmm/amd/svm.c | 9 +++++----
 1 file 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;

Reply via email to