[PATCH 3/3] target/i386: Tell why guest exits to user space due to #AC

Xiaoyao Li posted 3 patches 5 years, 10 months ago
Maintainers: Richard Henderson <rth@twiddle.net>, Paolo Bonzini <pbonzini@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>
[PATCH 3/3] target/i386: Tell why guest exits to user space due to #AC
Posted by Xiaoyao Li 5 years, 10 months ago
Tell why guest exits from kvm to user space due to #AC, so user knows
what happened.

Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
 target/i386/kvm.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 411402aa29fa..36bc1485d478 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -4464,8 +4464,15 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
         ret = -1;
         break;
     case KVM_EXIT_EXCEPTION:
-        fprintf(stderr, "KVM: exception %d exit (error code 0x%x)\n",
-                run->ex.exception, run->ex.error_code);
+        if (run->ex.exception == AC_VECTOR) {
+            fprintf(stderr, "Guest encounters an #AC due to split lock. Because "
+                    "guest doesn't expect this split lock #AC (it doesn't set "
+                    "msr_test_ctrl.split_lock_detect) and host sets "
+                    "split_lock_detect=fatal, guest has to be killed.\n");
+        } else {
+            fprintf(stderr, "KVM: exception %d exit (error code 0x%x)\n",
+                    run->ex.exception, run->ex.error_code);
+        }
         ret = -1;
         break;
     case KVM_EXIT_DEBUG:
-- 
2.20.1