diff mbox

[v7,3/3] x86/vmx: Clean up TRAP_int3 handling

Message ID 1467050887-5806-3-git-send-email-tamas@tklengyel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tamas K Lengyel June 27, 2016, 6:08 p.m. UTC
Clean up the handling of TRAP_int3 VMEXITs to conform to the handling
of TRAP_debug.

Signed-off-by: Tamas K Lengyel <tamas@tklengyel.com>
---
Cc: Jun Nakajima <jun.nakajima@intel.com>
Cc: Kevin Tian <kevin.tian@intel.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/hvm/vmx/vmx.c | 36 ++++++++++++------------------------
 1 file changed, 12 insertions(+), 24 deletions(-)

Comments

Tian, Kevin June 29, 2016, 1:58 a.m. UTC | #1
> From: Tamas K Lengyel [mailto:tamas@tklengyel.com]
> Sent: Tuesday, June 28, 2016 2:08 AM
> 
> Clean up the handling of TRAP_int3 VMEXITs to conform to the handling
> of TRAP_debug.
> 
> Signed-off-by: Tamas K Lengyel <tamas@tklengyel.com>

Acked-by: Kevin Tian <kevin.tian@intel.com>
diff mbox

Patch

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 5b22d87..c981450 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -3402,17 +3402,10 @@  void vmx_vmexit_handler(struct cpu_user_regs *regs)
             else
                 domain_pause_for_debugger();
             break;
-        case TRAP_int3: 
-        {
+        case TRAP_int3:
             HVMTRACE_1D(TRAP, vector);
-            if ( v->domain->debugger_attached )
+            if ( !v->domain->debugger_attached )
             {
-                update_guest_eip(); /* Safe: INT3 */            
-                v->arch.gdbsx_vcpu_event = TRAP_int3;
-                domain_pause_for_debugger();
-                break;
-            }
-            else {
                 unsigned long insn_len;
                 int rc;
 
@@ -3423,22 +3416,17 @@  void vmx_vmexit_handler(struct cpu_user_regs *regs)
                                        insn_len);
 
                 if ( !rc )
-                {
-                    struct hvm_trap trap = {
-                        .vector = TRAP_int3,
-                        .type = X86_EVENTTYPE_SW_EXCEPTION,
-                        .error_code = HVM_DELIVER_NO_ERROR_CODE,
-                        .insn_len = insn_len
-                    };
-                    hvm_inject_trap(&trap);
-                    break;
-                }
-                if ( rc > 0 )
-                    break;
+                    vmx_propagate_intr(intr_info);
+                if ( rc < 0 )
+                    goto exit_and_crash;
             }
-
-            goto exit_and_crash;
-        }
+            else
+            {
+                update_guest_eip(); /* Safe: INT3 */
+                v->arch.gdbsx_vcpu_event = TRAP_int3;
+                domain_pause_for_debugger();
+            }
+            break;
         case TRAP_no_device:
             HVMTRACE_1D(TRAP, vector);
             vmx_fpu_dirty_intercept();