]> xenbits.xensource.com Git - xen.git/commitdiff
x86/emulate: provide further information about software events
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 29 Sep 2014 08:20:47 +0000 (10:20 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 29 Sep 2014 08:20:47 +0000 (10:20 +0200)
This is needed by subsequent patches to support correctly injecting sofware
events for HVM Guests.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/hvm/emulate.c
xen/arch/x86/x86_emulate/x86_emulate.c
xen/arch/x86/x86_emulate/x86_emulate.h

index 6ab06e048adf9efee13f39cb8edae1d146952333..5d5d765b8b5e1c56404f8a1c5446dc1db7442bdc 100644 (file)
@@ -1119,6 +1119,7 @@ static int hvmemul_inject_hw_exception(
 }
 
 static int hvmemul_inject_sw_interrupt(
+    enum x86_swint_type type,
     uint8_t vector,
     uint8_t insn_len,
     struct x86_emulate_ctxt *ctxt)
index 1e79d0f1d6292cc1ad6f52ceaacf59928e11b7ff..e06aa60a579e173a304525fe76e1d770ae01b5b2 100644 (file)
@@ -1333,6 +1333,7 @@ x86_emulate(
     bool_t lock_prefix = 0;
     int override_seg = -1, rc = X86EMUL_OKAY;
     struct operand src, dst;
+    enum x86_swint_type swint_type;
     DECLARE_ALIGNED(mmval_t, mmval);
     /*
      * Data operand effective address (usually computed from ModRM).
@@ -2629,14 +2630,17 @@ x86_emulate(
 
     case 0xcc: /* int3 */
         src.val = EXC_BP;
+        swint_type = x86_swint_int3;
         goto swint;
 
     case 0xcd: /* int imm8 */
         src.val = insn_fetch_type(uint8_t);
+        swint_type = x86_swint_int;
     swint:
         fail_if(!in_realmode(ctxt, ops)); /* XSA-106 */
         fail_if(ops->inject_sw_interrupt == NULL);
-        rc = ops->inject_sw_interrupt(src.val, _regs.eip - ctxt->regs->eip,
+        rc = ops->inject_sw_interrupt(swint_type, src.val,
+                                      _regs.eip - ctxt->regs->eip,
                                       ctxt) ? : X86EMUL_EXCEPTION;
         goto done;
 
@@ -2645,6 +2649,7 @@ x86_emulate(
         if ( !(_regs.eflags & EFLG_OF) )
             break;
         src.val = EXC_OF;
+        swint_type = x86_swint_into;
         goto swint;
 
     case 0xcf: /* iret */ {
@@ -3312,6 +3317,7 @@ x86_emulate(
 
     case 0xf1: /* int1 (icebp) */
         src.val = EXC_DB;
+        swint_type = x86_swint_icebp;
         goto swint;
 
     case 0xf4: /* hlt */
index 107addf42cedf3ee96556a5176f82d7370fc330a..b336e173fbd4f8d16c3a2f3154dd3168afc3bb0f 100644 (file)
@@ -51,6 +51,14 @@ enum x86_segment {
 
 #define is_x86_user_segment(seg) ((unsigned)(seg) <= x86_seg_gs)
 
+/* Classification of the types of software generated interrupts/exceptions. */
+enum x86_swint_type {
+    x86_swint_icebp, /* 0xf1 */
+    x86_swint_int3,  /* 0xcc */
+    x86_swint_into,  /* 0xce */
+    x86_swint_int,   /* 0xcd $n */
+};
+
 /* 
  * Attribute for segment selector. This is a copy of bit 40:47 & 52:55 of the
  * segment descriptor. It happens to match the format of an AMD SVM VMCB.
@@ -337,6 +345,7 @@ struct x86_emulate_ops
 
     /* inject_sw_interrupt */
     int (*inject_sw_interrupt)(
+        enum x86_swint_type type,
         uint8_t vector,
         uint8_t insn_len,
         struct x86_emulate_ctxt *ctxt);