WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] x86 hvm: Fix #UD interception.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] x86 hvm: Fix #UD interception.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 02 Jul 2009 08:50:27 -0700
Delivery-date: Thu, 02 Jul 2009 08:52:13 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1246456711 -3600
# Node ID 479f1fa084d6af8611b0973be0fb6d642db1f9f9
# Parent  945232b8e226893da8010c9523ae0a1678db5961
x86 hvm: Fix #UD interception.
 * Interception should be standard part of HVM_TRAP_MASK
 * Failed intercept should quietly forward #UD to the guest

Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 xen/arch/x86/hvm/svm/svm.c    |   20 +++++------------
 xen/arch/x86/hvm/svm/vmcb.c   |    3 --
 xen/arch/x86/hvm/vmx/vmcs.c   |    3 --
 xen/arch/x86/hvm/vmx/vmx.c    |   48 +++++++++++++++++-------------------------
 xen/include/asm-x86/hvm/hvm.h |    2 -
 5 files changed, 29 insertions(+), 47 deletions(-)

diff -r 945232b8e226 -r 479f1fa084d6 xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c        Wed Jul 01 10:54:25 2009 +0100
+++ b/xen/arch/x86/hvm/svm/svm.c        Wed Jul 01 14:58:31 2009 +0100
@@ -1226,24 +1226,16 @@ static void svm_vmexit_ud_intercept(stru
     switch ( rc )
     {
     case X86EMUL_UNHANDLEABLE:
-        gdprintk(XENLOG_WARNING,
-                 "instruction emulation failed @ %04x:%lx: "
-                 "%02x %02x %02x %02x %02x %02x\n",
-                 hvmemul_get_seg_reg(x86_seg_cs, &ctxt)->sel,
-                 ctxt.insn_buf_eip,
-                 ctxt.insn_buf[0], ctxt.insn_buf[1],
-                 ctxt.insn_buf[2], ctxt.insn_buf[3],
-                 ctxt.insn_buf[4], ctxt.insn_buf[5]);
-         return;
+        svm_inject_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE, 0);
+        break;
     case X86EMUL_EXCEPTION:
         if ( ctxt.exn_pending )
             hvm_inject_exception(ctxt.exn_vector, ctxt.exn_error_code, 0);
-        break;
+        /* fall through */
     default:
-        break;
-    }
-
-    hvm_emulate_writeback(&ctxt);
+        hvm_emulate_writeback(&ctxt);
+        break;
+    }
 }
 
 static void wbinvd_ipi(void *info)
diff -r 945232b8e226 -r 479f1fa084d6 xen/arch/x86/hvm/svm/vmcb.c
--- a/xen/arch/x86/hvm/svm/vmcb.c       Wed Jul 01 10:54:25 2009 +0100
+++ b/xen/arch/x86/hvm/svm/vmcb.c       Wed Jul 01 14:58:31 2009 +0100
@@ -227,8 +227,7 @@ static int construct_vmcb(struct vcpu *v
 
     vmcb->exception_intercepts =
         HVM_TRAP_MASK
-        | (1U << TRAP_no_device)
-        | (1U << TRAP_invalid_op);
+        | (1U << TRAP_no_device);
 
     if ( paging_mode_hap(v->domain) )
     {
diff -r 945232b8e226 -r 479f1fa084d6 xen/arch/x86/hvm/vmx/vmcs.c
--- a/xen/arch/x86/hvm/vmx/vmcs.c       Wed Jul 01 10:54:25 2009 +0100
+++ b/xen/arch/x86/hvm/vmx/vmcs.c       Wed Jul 01 14:58:31 2009 +0100
@@ -679,8 +679,7 @@ static int construct_vmcs(struct vcpu *v
     __vmwrite(EXCEPTION_BITMAP,
               HVM_TRAP_MASK
               | (paging_mode_hap(d) ? 0 : (1U << TRAP_page_fault))
-              | (1U << TRAP_no_device)
-              | (1U << TRAP_invalid_op));
+              | (1U << TRAP_no_device));
 
     v->arch.hvm_vcpu.guest_cr[0] = X86_CR0_PE | X86_CR0_ET;
     hvm_update_guest_cr(v, 0);
diff -r 945232b8e226 -r 479f1fa084d6 xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c        Wed Jul 01 10:54:25 2009 +0100
+++ b/xen/arch/x86/hvm/vmx/vmx.c        Wed Jul 01 14:58:31 2009 +0100
@@ -2258,34 +2258,26 @@ asmlinkage void vmx_enter_realmode(struc
 
 static void vmx_vmexit_ud_intercept(struct cpu_user_regs *regs)
 {
-     struct hvm_emulate_ctxt ctxt;
-     int rc;
- 
-     hvm_emulate_prepare(&ctxt, regs);
- 
-     rc = hvm_emulate_one(&ctxt);
- 
-     switch ( rc )
-     {
-     case X86EMUL_UNHANDLEABLE:
-         gdprintk(XENLOG_WARNING,
-                  "instruction emulation failed @ %04x:%lx: "
-                  "%02x %02x %02x %02x %02x %02x\n",
-                  hvmemul_get_seg_reg(x86_seg_cs, &ctxt)->sel,
-                  ctxt.insn_buf_eip,
-                  ctxt.insn_buf[0], ctxt.insn_buf[1],
-                  ctxt.insn_buf[2], ctxt.insn_buf[3],
-                  ctxt.insn_buf[4], ctxt.insn_buf[5]);
-          return;
-     case X86EMUL_EXCEPTION:
-         if ( ctxt.exn_pending )
-             hvm_inject_exception(ctxt.exn_vector, ctxt.exn_error_code, 0);
-         break;
-     default:
-         break;
-     }
- 
-     hvm_emulate_writeback(&ctxt);
+    struct hvm_emulate_ctxt ctxt;
+    int rc;
+
+    hvm_emulate_prepare(&ctxt, regs);
+
+    rc = hvm_emulate_one(&ctxt);
+
+    switch ( rc )
+    {
+    case X86EMUL_UNHANDLEABLE:
+        vmx_inject_hw_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE);
+        break;
+    case X86EMUL_EXCEPTION:
+        if ( ctxt.exn_pending )
+            hvm_inject_exception(ctxt.exn_vector, ctxt.exn_error_code, 0);
+        /* fall through */
+    default:
+        hvm_emulate_writeback(&ctxt);
+        break;
+    }
 }
 
 asmlinkage void vmx_vmexit_handler(struct cpu_user_regs *regs)
diff -r 945232b8e226 -r 479f1fa084d6 xen/include/asm-x86/hvm/hvm.h
--- a/xen/include/asm-x86/hvm/hvm.h     Wed Jul 01 10:54:25 2009 +0100
+++ b/xen/include/asm-x86/hvm/hvm.h     Wed Jul 01 14:58:31 2009 +0100
@@ -268,7 +268,7 @@ static inline int hvm_do_pmu_interrupt(s
         X86_CR4_OSFXSR | X86_CR4_OSXMMEXCPT)))
 
 /* These exceptions must always be intercepted. */
-#define HVM_TRAP_MASK (1U << TRAP_machine_check)
+#define HVM_TRAP_MASK ((1U << TRAP_machine_check) | (1U << TRAP_invalid_op))
 
 /*
  * x86 event types. This enumeration is valid for:

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] x86 hvm: Fix #UD interception., Xen patchbot-unstable <=