xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Subject: [PATCH 2/6] x86/emulate: Provide further information about software events
Date: Tue, 23 Sep 2014 16:03:27 +0100	[thread overview]
Message-ID: <1411484611-31027-3-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1411484611-31027-1-git-send-email-andrew.cooper3@citrix.com>

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             |    1 +
 xen/arch/x86/x86_emulate/x86_emulate.c |    8 +++++++-
 xen/arch/x86/x86_emulate/x86_emulate.h |    9 +++++++++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index 6ab06e0..5d5d765 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -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)
diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
index 1e79d0f..e06aa60 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -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 */
diff --git a/xen/arch/x86/x86_emulate/x86_emulate.h b/xen/arch/x86/x86_emulate/x86_emulate.h
index 107addf..b336e17 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.h
+++ b/xen/arch/x86/x86_emulate/x86_emulate.h
@@ -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);
-- 
1.7.10.4

  parent reply	other threads:[~2014-09-23 15:03 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-23 15:03 [PATCH 0/6] HVM Emulation and trap injection fixes Andrew Cooper
2014-09-23 15:03 ` [PATCH 1/6] x86emul: fix SYSCALL/SYSENTER/SYSEXIT emulation Andrew Cooper
2014-09-23 15:03 ` Andrew Cooper [this message]
2014-09-23 15:03 ` [PATCH 3/6] x86/hvm: Don't discard the SW/HW event distinction from the emulator Andrew Cooper
2014-09-25 20:57   ` Tian, Kevin
2014-09-26 20:12   ` Boris Ostrovsky
2014-09-23 15:03 ` [PATCH 4/6] x86/emulate: Support for emulating software event injection Andrew Cooper
2014-09-23 22:24   ` Aravind Gopalakrishnan
2014-09-24  9:22     ` Andrew Cooper
2014-09-24 13:01   ` Boris Ostrovsky
2014-09-24 13:04     ` Andrew Cooper
2014-09-24 13:24       ` Boris Ostrovsky
2014-09-24 14:20         ` Andrew Cooper
2014-09-26 20:13           ` Boris Ostrovsky
2014-09-26 21:09   ` Aravind Gopalakrishnan
2014-09-23 15:03 ` [PATCH 5/6] x86/hvm: Forced Emulation Prefix for debug builds of Xen Andrew Cooper
2014-09-23 15:27   ` Jan Beulich
2014-09-23 16:09     ` [PATCH v2 " Andrew Cooper
2014-09-23 16:21       ` Jan Beulich
2014-09-25 21:04         ` Tian, Kevin
2014-09-23 18:20       ` Boris Ostrovsky
2014-09-23 18:23         ` Andrew Cooper
2014-09-23 20:17           ` Boris Ostrovsky
2014-09-24 12:56             ` Andrew Cooper
2014-09-26 20:14       ` Boris Ostrovsky
2014-09-23 15:03 ` [PATCH 6/6] x86/svm: Misc cleanup Andrew Cooper
2014-09-26 20:15   ` Boris Ostrovsky
2014-09-23 15:19 ` [PATCH 0/6] HVM Emulation and trap injection fixes Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1411484611-31027-3-git-send-email-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).