Skip to contentSkip to conversation

XEN: fix vmx exception mistake

PATCH Superseded Xudong Hao 4 participants 12 messages May 24, 2012 – May 30, 2012

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Xudong Hao

author
#0 lore raw

cover XEN: fix vmx exception mistake

This series of patches fix the mistake for debug exception(#DB), overflow exception(#OF) and INT3(#BP), INTn instruction emulation.

Introduce new function vmx_inject_sw_exception() which deliver the software excetion, software interrupt and privileged software exception. Split hardware exception as a seperate function(old function vmx_inject_hw_exception()).

Also Passed down intruction length to exception emulation handler function.

And supply a interface for userspace to inject trap.

PATCH 1: Pass the instruction length field down to exception emulation,
by changing hypercall parameter and adding a parameter in fucntion hvm_inject_exception(), so that exception emulation can set correct instruction length.

PATCH 2: Fix the mistake for debug exception(#DB), overflow exception(#OF) and
INT3(#BP), INTn instruction emulation.

Introduce new function vmx_inject_sw_exception() which deliver the software excetion, software interrupt and privileged software exception. Split hardware exception as a seperate function(old function vmx_inject_hw_exception()).

PATCH 3: Add a parameter to represent instruction length in function
xc_hvm_inject_trap(), user should set this value when this function is called.

author
#1 lore raw

PATCH 1/3 xen: Add instruction length parameter in function hvm_inject_exception

VMX exception: Pass the instruction length field down to exception emulation, by changing hypercall parameter and adding a parameter in fucntion hvm_inject_exception(), so that exception emulation can set correct instruction length.

---
 xen/arch/x86/hvm/emulate.c       |    4 +-
 xen/arch/x86/hvm/hvm.c           |   40 +++++++++++++++++++------------------
 xen/arch/x86/hvm/io.c            |    2 +-
 xen/arch/x86/hvm/svm/emulate.c   |    4 +-
 xen/arch/x86/hvm/svm/nestedsvm.c |    6 ++--
 xen/arch/x86/hvm/svm/svm.c       |   34 ++++++++++++++++----------------
 xen/arch/x86/hvm/vmx/vmx.c       |    2 +-
 xen/arch/x86/hvm/vmx/vvmx.c      |    6 ++--
 xen/arch/x86/mm/shadow/common.c  |    2 +-
 xen/arch/x86/mm/shadow/multi.c   |    2 +-
 xen/include/asm-x86/hvm/hvm.h    |    4 +-
 xen/include/asm-x86/hvm/vcpu.h   |    1 +
 xen/include/public/hvm/hvm_op.h  |    2 +
 13 files changed, 57 insertions(+), 52 deletions(-)
xen/arch/x86/hvm/emulate.c +2 -2
index 2b50670..b6d1984 100644
@@ -326,7 +326,7 @@ static int hvmemul_linear_to_phys(
     {
         if ( pfec == PFEC_page_paged || pfec == PFEC_page_shared )
             return X86EMUL_RETRY;
-        hvm_inject_exception(TRAP_page_fault, pfec, addr);
+        hvm_inject_exception(TRAP_page_fault, 0, pfec, addr);
         return X86EMUL_EXCEPTION;
     }
 
@@ -349,7 +349,7 @@ static int hvmemul_linear_to_phys(
                 ASSERT(!reverse);
                 if ( npfn != INVALID_GFN )
                     return X86EMUL_UNHANDLEABLE;
-                hvm_inject_exception(TRAP_page_fault, pfec, addr & PAGE_MASK);
+                hvm_inject_exception(TRAP_page_fault, 0, pfec, addr & PAGE_MASK);
                 return X86EMUL_EXCEPTION;
             }
             *reps = done;
xen/arch/x86/hvm/hvm.c +21 -19
index efd5587..fa8b220 100644
@@ -350,6 +350,7 @@ void hvm_do_resume(struct vcpu *v)
     if (v->arch.hvm_vcpu.inject_trap != -1) 
     {
         hvm_inject_exception(v->arch.hvm_vcpu.inject_trap, 
+                             v->arch.hvm_vcpu.instruction_len, 
                              v->arch.hvm_vcpu.inject_error_code, 
                              v->arch.hvm_vcpu.inject_cr2);
         v->arch.hvm_vcpu.inject_trap = -1;
@@ -1194,7 +1195,7 @@ void hvm_triple_fault(void)
     domain_shutdown(v->domain, SHUTDOWN_reboot);
 }
 
-void hvm_inject_exception(unsigned int trapnr, int errcode, unsigned long cr2)
+void hvm_inject_exception(unsigned int trapnr, int inslen, int errcode, unsigned long cr2)
 {
     struct vcpu *curr = current;
 
@@ -1221,7 +1222,7 @@ void hvm_inject_exception(unsigned int trapnr, int errcode, unsigned long cr2)
         }
     }
 
-    hvm_funcs.inject_exception(trapnr, errcode, cr2);
+    hvm_funcs.inject_exception(trapnr, inslen, errcode, cr2);
 }
 
 int hvm_hap_nested_page_fault(unsigned long gpa,
@@ -1270,7 +1271,7 @@ int hvm_hap_nested_page_fault(unsigned long gpa,
             return -1;
         case NESTEDHVM_PAGEFAULT_MMIO:
             if ( !handle_mmio() )
-                hvm_inject_exception(TRAP_gp_fault, 0, 0);
+                hvm_inject_exception(TRAP_gp_fault, 0, 0, 0);
             return 1;
         }
     }
@@ -1337,7 +1338,7 @@ int hvm_hap_nested_page_fault(unsigned long gpa,
     {
         put_gfn(p2m->domain, gfn);
         if ( !handle_mmio() )
-            hvm_inject_exception(TRAP_gp_fault, 0, 0);
+            hvm_inject_exception(TRAP_gp_fault, 0, 0, 0);
         rc = 1;
         goto out;
     }
@@ -1380,7 +1381,7 @@ int hvm_hap_nested_page_fault(unsigned long gpa,
     {
         gdprintk(XENLOG_WARNING,
                  "trying to write to read-only grant mapping\n");
-        hvm_inject_exception(TRAP_gp_fault, 0, 0);
+        hvm_inject_exception(TRAP_gp_fault, 0, 0, 0);
         rc = 1;
         goto out_put_gfn;
     }
@@ -1441,7 +1442,7 @@ int hvm_handle_xsetbv(u64 new_bv)
 
     return 0;
 err:
-    hvm_inject_exception(TRAP_gp_fault, 0, 0);
+    hvm_inject_exception(TRAP_gp_fault, 0, 0, 0);
     return -1;
 }
 
@@ -1457,7 +1458,7 @@ int hvm_set_efer(uint64_t value)
     {
         gdprintk(XENLOG_WARNING, "Trying to set reserved bit in "
                  "EFER: 0x%"PRIx64"\n", value);
-        hvm_inject_exception(TRAP_gp_fault, 0, 0);
+        hvm_inject_exception(TRAP_gp_fault, 0, 0, 0);
         return X86EMUL_EXCEPTION;
     }
 
@@ -1466,7 +1467,7 @@ int hvm_set_efer(uint64_t value)
     {
         gdprintk(XENLOG_WARNING,
                  "Trying to change EFER.LME with paging enabled\n");
-        hvm_inject_exception(TRAP_gp_fault, 0, 0);
+        hvm_inject_exception(TRAP_gp_fault, 0, 0, 0);
         return X86EMUL_EXCEPTION;
     }
 
@@ -1722,7 +1723,7 @@ int hvm_set_cr0(unsigned long value)
     return X86EMUL_OKAY;
 
  gpf:
-    hvm_inject_exception(TRAP_gp_fault, 0, 0);
+    hvm_inject_exception(TRAP_gp_fault, 0, 0, 0);
     return X86EMUL_EXCEPTION;
 }
 
@@ -1808,7 +1809,7 @@ int hvm_set_cr4(unsigned long value)
     return X86EMUL_OKAY;
 
  gpf:
-    hvm_inject_exception(TRAP_gp_fault, 0, 0);
+    hvm_inject_exception(TRAP_gp_fault, 0, 0, 0);
     return X86EMUL_EXCEPTION;
 }
 
@@ -2104,7 +2105,7 @@ static int hvm_load_segment_selector(
  unmap_and_fail:
     hvm_unmap_entry(pdesc);
  fail:
-    hvm_inject_exception(fault_type, sel & 0xfffc, 0);
+    hvm_inject_exception(fault_type, 0, sel & 0xfffc, 0);
  hvm_map_fail:
     return 1;
 }
@@ -2139,7 +2140,7 @@ void hvm_task_switch(
     {
         hvm_inject_exception((taskswitch_reason == TSW_iret) ?
                              TRAP_invalid_tss : TRAP_gp_fault,
-                             tss_sel & 0xfff8, 0);
+                             0, tss_sel & 0xfff8, 0);
         goto out;
     }
 
@@ -2164,7 +2165,7 @@ void hvm_task_switch(
 
     if ( !tr.attr.fields.p )
     {
-        hvm_inject_exception(TRAP_no_segment, tss_sel & 0xfff8, 0);
+        hvm_inject_exception(TRAP_no_segment, 0, tss_sel & 0xfff8, 0);
         goto out;
     }
 
@@ -2172,13 +2173,13 @@ void hvm_task_switch(
     {
         hvm_inject_exception(
             (taskswitch_reason == TSW_iret) ? TRAP_invalid_tss : TRAP_gp_fault,
-            tss_sel & 0xfff8, 0);
+            0, tss_sel & 0xfff8, 0);
         goto out;
     }
 
     if ( tr.limit < (sizeof(tss)-1) )
     {
-        hvm_inject_exception(TRAP_invalid_tss, tss_sel & 0xfff8, 0);
+        hvm_inject_exception(TRAP_invalid_tss, 0, tss_sel & 0xfff8, 0);
         goto out;
     }
 
@@ -2283,7 +2284,7 @@ void hvm_task_switch(
         goto out;
 
     if ( (tss.trace & 1) && !exn_raised )
-        hvm_inject_exception(TRAP_debug, tss_sel & 0xfff8, 0);
+        hvm_inject_exception(TRAP_debug, 0, tss_sel & 0xfff8, 0);
 
     tr.attr.fields.type = 0xb; /* busy 32-bit tss */
     hvm_set_segment_register(v, x86_seg_tr, &tr);
@@ -2362,7 +2363,7 @@ static enum hvm_copy_result __hvm_copy(
                 if ( pfec == PFEC_page_shared )
                     return HVMCOPY_gfn_shared;
                 if ( flags & HVMCOPY_fault )
-                    hvm_inject_exception(TRAP_page_fault, pfec, addr);
+                    hvm_inject_exception(TRAP_page_fault, 0, pfec, addr);
                 return HVMCOPY_bad_gva_to_gfn;
             }
         }
@@ -2849,7 +2850,7 @@ int hvm_msr_read_intercept(unsigned int msr, uint64_t *msr_content)
     return ret;
 
  gp_fault:
-    hvm_inject_exception(TRAP_gp_fault, 0, 0);
+    hvm_inject_exception(TRAP_gp_fault, 0, 0, 0);
     ret = X86EMUL_EXCEPTION;
     *msr_content = -1ull;
     goto out;
@@ -2962,7 +2963,7 @@ int hvm_msr_write_intercept(unsigned int msr, uint64_t msr_content)
     return ret;
 
 gp_fault:
-    hvm_inject_exception(TRAP_gp_fault, 0, 0);
+    hvm_inject_exception(TRAP_gp_fault, 0, 0, 0);
     return X86EMUL_EXCEPTION;
 }
 
@@ -4272,6 +4273,7 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE(void) arg)
         else 
         {
             v->arch.hvm_vcpu.inject_trap       = tr.trap;
+            v->arch.hvm_vcpu.instruction_len   = tr.inslen;
             v->arch.hvm_vcpu.inject_error_code = tr.error_code;
             v->arch.hvm_vcpu.inject_cr2        = tr.cr2;
         }
xen/arch/x86/hvm/io.c +1 -1
index 41a2ede..bd856fd 100644
@@ -200,7 +200,7 @@ int handle_mmio(void)
         return 0;
     case X86EMUL_EXCEPTION:
         if ( ctxt.exn_pending )
-            hvm_inject_exception(ctxt.exn_vector, ctxt.exn_error_code, 0);
+            hvm_inject_exception(ctxt.exn_vector, ctxt.exn_insn_len, ctxt.exn_error_code, 0);
         break;
     default:
         break;
xen/arch/x86/hvm/svm/emulate.c +2 -2
index 6000bff..8b67f2f 100644
@@ -147,7 +147,7 @@ static int fetch(struct vcpu *v, u8 *buf, unsigned long addr, int len)
         /* Not OK: fetches from non-RAM pages are not supportable. */
         gdprintk(XENLOG_WARNING, "Bad instruction fetch at %#lx (%#lx)\n",
                  (unsigned long) guest_cpu_user_regs()->eip, addr);
-        hvm_inject_exception(TRAP_gp_fault, 0, 0);
+        hvm_inject_exception(TRAP_gp_fault, 0, 0, 0);
         return 0;
     }
     return 1;
@@ -216,7 +216,7 @@ int __get_instruction_length_from_list(struct vcpu *v,
     gdprintk(XENLOG_WARNING,
              "%s: Mismatch between expected and actual instruction bytes: "
              "eip = %lx\n",  __func__, (unsigned long)vmcb->rip);
-    hvm_inject_exception(TRAP_gp_fault, 0, 0);
+    hvm_inject_exception(TRAP_gp_fault, 0, 0, 0);
     return 0;
 
  done:
xen/arch/x86/hvm/svm/nestedsvm.c +3 -3
index 8714bb0..ac04f3b 100644
@@ -735,7 +735,7 @@ nsvm_vcpu_vmrun(struct vcpu *v, struct cpu_user_regs *regs)
     default:
         gdprintk(XENLOG_ERR,
             "nsvm_vcpu_vmentry failed, injecting #UD\n");
-        hvm_inject_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE, 0);
+        hvm_inject_exception(TRAP_invalid_op, 0, HVM_DELIVER_NO_ERROR_CODE, 0);
         /* Must happen after hvm_inject_exception or it doesn't work right. */
         nv->nv_vmswitch_in_progress = 0;
         return 1;
@@ -1509,7 +1509,7 @@ void svm_vmexit_do_stgi(struct cpu_user_regs *regs, struct vcpu *v)
     unsigned int inst_len;
 
     if ( !nestedhvm_enabled(v->domain) ) {
-        hvm_inject_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE, 0);
+        hvm_inject_exception(TRAP_invalid_op, 0, HVM_DELIVER_NO_ERROR_CODE, 0);
         return;
     }
 
@@ -1529,7 +1529,7 @@ void svm_vmexit_do_clgi(struct cpu_user_regs *regs, struct vcpu *v)
     vintr_t intr;
 
     if ( !nestedhvm_enabled(v->domain) ) {
-        hvm_inject_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE, 0);
+        hvm_inject_exception(TRAP_invalid_op, 0, HVM_DELIVER_NO_ERROR_CODE, 0);
         return;
     }
 
xen/arch/x86/hvm/svm/svm.c +17 -17
index e717dda..87fb8a1 100644
@@ -109,7 +109,7 @@ void __update_guest_eip(struct cpu_user_regs *regs, unsigned int inst_len)
     curr->arch.hvm_svm.vmcb->interrupt_shadow = 0;
 
     if ( regs->eflags & X86_EFLAGS_TF )
-        hvm_inject_exception(TRAP_debug, HVM_DELIVER_NO_ERROR_CODE, 0);
+        hvm_inject_exception(TRAP_debug, 0, HVM_DELIVER_NO_ERROR_CODE, 0);
 }
 
 static void svm_cpu_down(void)
@@ -1067,7 +1067,7 @@ static void svm_vcpu_destroy(struct vcpu *v)
 }
 
 static void svm_inject_exception(
-    unsigned int trapnr, int errcode, unsigned long cr2)
+    unsigned int trapnr, int inslen, int errcode, unsigned long cr2)
 {
     struct vcpu *curr = current;
     struct vmcb_struct *vmcb = curr->arch.hvm_svm.vmcb;
@@ -1361,7 +1361,7 @@ static void svm_fpu_dirty_intercept(void)
     {
        /* Check if l1 guest must make FPU ready for the l2 guest */
        if ( v->arch.hvm_vcpu.guest_cr[0] & X86_CR0_TS )
-           hvm_inject_exception(TRAP_no_device, HVM_DELIVER_NO_ERROR_CODE, 0);
+           hvm_inject_exception(TRAP_no_device, 0, HVM_DELIVER_NO_ERROR_CODE, 0);
        else
            vmcb_set_cr0(n1vmcb, vmcb_get_cr0(n1vmcb) & ~X86_CR0_TS);
        return;
@@ -1579,7 +1579,7 @@ static int svm_msr_read_intercept(unsigned int msr, uint64_t *msr_content)
     return X86EMUL_OKAY;
 
  gpf:
-    hvm_inject_exception(TRAP_gp_fault, 0, 0);
+    hvm_inject_exception(TRAP_gp_fault, 0, 0, 0);
     return X86EMUL_EXCEPTION;
 }
 
@@ -1708,7 +1708,7 @@ static int svm_msr_write_intercept(unsigned int msr, uint64_t msr_content)
     return X86EMUL_OKAY;
 
  gpf:
-    hvm_inject_exception(TRAP_gp_fault, 0, 0);
+    hvm_inject_exception(TRAP_gp_fault, 0, 0, 0);
     return X86EMUL_EXCEPTION;
 }
 
@@ -1784,13 +1784,13 @@ svm_vmexit_do_vmrun(struct cpu_user_regs *regs,
 {
     if (!nestedhvm_enabled(v->domain)) {
         gdprintk(XENLOG_ERR, "VMRUN: nestedhvm disabled, injecting #UD\n");
-        hvm_inject_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE, 0);
+        hvm_inject_exception(TRAP_invalid_op, 0, HVM_DELIVER_NO_ERROR_CODE, 0);
         return;
     }
 
     if (!nestedsvm_vmcb_map(v, vmcbaddr)) {
         gdprintk(XENLOG_ERR, "VMRUN: mapping vmcb failed, injecting #UD\n");
-        hvm_inject_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE, 0);
+        hvm_inject_exception(TRAP_invalid_op, 0, HVM_DELIVER_NO_ERROR_CODE, 0);
         return;
     }
 
@@ -1830,7 +1830,7 @@ svm_vmexit_do_vmload(struct vmcb_struct *vmcb,
     return;
 
  inject:
-    hvm_inject_exception(ret, HVM_DELIVER_NO_ERROR_CODE, 0);
+    hvm_inject_exception(ret, 0, HVM_DELIVER_NO_ERROR_CODE, 0);
     return;
 }
 
@@ -1864,7 +1864,7 @@ svm_vmexit_do_vmsave(struct vmcb_struct *vmcb,
     return;
 
  inject:
-    hvm_inject_exception(ret, HVM_DELIVER_NO_ERROR_CODE, 0);
+    hvm_inject_exception(ret, 0, HVM_DELIVER_NO_ERROR_CODE, 0);
     return;
 }
 
@@ -1880,11 +1880,11 @@ static void svm_vmexit_ud_intercept(struct cpu_user_regs *regs)
     switch ( rc )
     {
     case X86EMUL_UNHANDLEABLE:
-        hvm_inject_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE, 0);
+        hvm_inject_exception(TRAP_invalid_op, 0, 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);
+            hvm_inject_exception(ctxt.exn_vector, ctxt.exn_insn_len, ctxt.exn_error_code, 0);
         /* fall through */
     default:
         hvm_emulate_writeback(&ctxt);
@@ -2212,7 +2212,7 @@ void svm_vmexit_handler(struct cpu_user_regs *regs)
             break;
         }
 
-        hvm_inject_exception(TRAP_page_fault, regs->error_code, va);
+        hvm_inject_exception(TRAP_page_fault, 0, regs->error_code, va);
         break;
     }
 
@@ -2285,7 +2285,7 @@ void svm_vmexit_handler(struct cpu_user_regs *regs)
                 __update_guest_eip(regs, vmcb->exitinfo2 - vmcb->rip);
         }
         else if ( !handle_mmio() )
-            hvm_inject_exception(TRAP_gp_fault, 0, 0);
+            hvm_inject_exception(TRAP_gp_fault, 0, 0, 0);
         break;
 
     case VMEXIT_CR0_READ ... VMEXIT_CR15_READ:
@@ -2293,7 +2293,7 @@ void svm_vmexit_handler(struct cpu_user_regs *regs)
         if ( cpu_has_svm_decode && (vmcb->exitinfo1 & (1ULL << 63)) )
             svm_vmexit_do_cr_access(vmcb, regs);
         else if ( !handle_mmio() ) 
-            hvm_inject_exception(TRAP_gp_fault, 0, 0);
+            hvm_inject_exception(TRAP_gp_fault, 0, 0, 0);
         break;
 
     case VMEXIT_INVLPG:
@@ -2303,7 +2303,7 @@ void svm_vmexit_handler(struct cpu_user_regs *regs)
             __update_guest_eip(regs, vmcb->nextrip - vmcb->rip);
         }
         else if ( !handle_mmio() )
-            hvm_inject_exception(TRAP_gp_fault, 0, 0);
+            hvm_inject_exception(TRAP_gp_fault, 0, 0, 0);
         break;
 
     case VMEXIT_INVLPGA:
@@ -2349,7 +2349,7 @@ void svm_vmexit_handler(struct cpu_user_regs *regs)
 
     case VMEXIT_MONITOR:
     case VMEXIT_MWAIT:
-        hvm_inject_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE, 0);
+        hvm_inject_exception(TRAP_invalid_op, 0, HVM_DELIVER_NO_ERROR_CODE, 0);
         break;
 
     case VMEXIT_VMRUN:
@@ -2368,7 +2368,7 @@ void svm_vmexit_handler(struct cpu_user_regs *regs)
         svm_vmexit_do_clgi(regs, v);
         break;
     case VMEXIT_SKINIT:
-        hvm_inject_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE, 0);
+        hvm_inject_exception(TRAP_invalid_op, 0, HVM_DELIVER_NO_ERROR_CODE, 0);
         break;
 
     case VMEXIT_XSETBV:
xen/arch/x86/hvm/vmx/vmx.c +1 -1
index d5cb279..e15b7a4 100644
@@ -2226,7 +2226,7 @@ static void vmx_vmexit_ud_intercept(struct cpu_user_regs *regs)
         break;
     case X86EMUL_EXCEPTION:
         if ( ctxt.exn_pending )
-            hvm_inject_exception(ctxt.exn_vector, ctxt.exn_error_code, 0);
+            hvm_inject_exception(ctxt.exn_vector, ctxt.exn_insn_len, ctxt.exn_error_code, 0);
         /* fall through */
     default:
         hvm_emulate_writeback(&ctxt);
xen/arch/x86/hvm/vmx/vvmx.c +3 -3
index b0ae0ee..6a55edb 100644
@@ -304,12 +304,12 @@ vmexit:
     
 invalid_op:
     gdprintk(XENLOG_ERR, "vmx_inst_check_privilege: invalid_op\n");
-    hvm_inject_exception(TRAP_invalid_op, 0, 0);
+    hvm_inject_exception(TRAP_invalid_op, 0, 0, 0);
     return X86EMUL_EXCEPTION;
 
 gp_fault:
     gdprintk(XENLOG_ERR, "vmx_inst_check_privilege: gp_fault\n");
-    hvm_inject_exception(TRAP_gp_fault, 0, 0);
+    hvm_inject_exception(TRAP_gp_fault, 0, 0, 0);
     return X86EMUL_EXCEPTION;
 }
 
@@ -386,7 +386,7 @@ static int decode_vmx_inst(struct cpu_user_regs *regs,
     return X86EMUL_OKAY;
 
 gp_fault:
-    hvm_inject_exception(TRAP_gp_fault, 0, 0);
+    hvm_inject_exception(TRAP_gp_fault, 0, 0, 0);
     return X86EMUL_EXCEPTION;
 }
 
xen/arch/x86/mm/shadow/common.c +1 -1
index 59be993..8b864d2 100644
@@ -135,7 +135,7 @@ static int hvm_translate_linear_addr(
 
     if ( !okay )
     {
-        hvm_inject_exception(TRAP_gp_fault, 0, 0);
+        hvm_inject_exception(TRAP_gp_fault, 0, 0, 0);
         return X86EMUL_EXCEPTION;
     }
 
xen/arch/x86/mm/shadow/multi.c +1 -1
index 9368385..199bd85 100644
@@ -4825,7 +4825,7 @@ static mfn_t emulate_gva_to_mfn(struct vcpu *v,
     if ( gfn == INVALID_GFN ) 
     {
         if ( is_hvm_vcpu(v) )
-            hvm_inject_exception(TRAP_page_fault, pfec, vaddr);
+            hvm_inject_exception(TRAP_page_fault, 0, pfec, vaddr);
         else
             propagate_page_fault(vaddr, pfec);
         return _mfn(BAD_GVA_TO_GFN);
xen/include/asm-x86/hvm/hvm.h +2 -2
index 22f9451..3ba1615 100644
@@ -124,7 +124,7 @@ struct hvm_function_table {
 
     void (*set_tsc_offset)(struct vcpu *v, u64 offset);
 
-    void (*inject_exception)(unsigned int trapnr, int errcode,
+    void (*inject_exception)(unsigned int trapnr, int inslen, int errcode,
                              unsigned long cr2);
 
     void (*init_hypercall_page)(struct domain *d, void *hypercall_page);
@@ -320,7 +320,7 @@ void hvm_migrate_timers(struct vcpu *v);
 void hvm_do_resume(struct vcpu *v);
 void hvm_migrate_pirqs(struct vcpu *v);
 
-void hvm_inject_exception(unsigned int trapnr, int errcode, unsigned long cr2);
+void hvm_inject_exception(unsigned int trapnr, int inslen, int errcode, unsigned long cr2);
 
 static inline int hvm_event_pending(struct vcpu *v)
 {
xen/include/asm-x86/hvm/vcpu.h +1 -0
index 537da96..c325fd1 100644
@@ -166,6 +166,7 @@ struct hvm_vcpu {
     void *fpu_exception_callback_arg;
     /* Pending hw/sw interrupt */
     int           inject_trap;       /* -1 for nothing to inject */
+    int           instruction_len;
     int           inject_error_code;
     unsigned long inject_cr2;
 
xen/include/public/hvm/hvm_op.h +2 -0
index 6a78f75..4bafd88 100644
@@ -219,6 +219,8 @@ struct xen_hvm_inject_trap {
     uint32_t vcpuid;
     /* Trap number */
     uint32_t trap;
+    /* Intruction length */
+    uint32_t inslen;
     /* Error code, or -1 to skip */
     uint32_t error_code;
     /* CR2 for page faults */
Signature · 1 line
1.5.5
#2 lore raw

Re: [PATCH 1/3] xen: Add instruction length parameter in function hvm_inject_exception

Quoted 7 lines · Xudong Hao

VMX exception: Pass the instruction length field down to exception emulation, by changing hypercall parameter and adding a parameter in fucntion hvm_inject_exception(), so that exception emulation can set correct instruction length.

I don't like adding yet another parameter for all callers, especially as we should also be passing down the event type (sw interrupt, hw exception, ...) and that would bloat the parameter list further.

I attach a cleanup patch which packs everything into a new struct and renames hvm_inject_exception to hvm_inject_trap. I then define a couple of wrappers around that function for existing callers, so that their parameter lists actually *shrink*.

Let me know what you think. If it looks acceptable I can check it in and we can build on top of this restructuring. The aim being to keep hvm/vmx_inject_trap dumb, and push down the knowledge from the callers into it.

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw

Re: [PATCH 1/3] xen: Add instruction length parameter in function hvm_inject_exception

Quoted 19 lines · Keir Fraser
Quoted 7 lines · Xudong Hao

VMX exception: Pass the instruction length field down to exception emulation, by changing hypercall parameter and adding a parameter in fucntion hvm_inject_exception(), so that exception emulation can set correct instruction length.

I don't like adding yet another parameter for all callers, especially as we should also be passing down the event type (sw interrupt, hw exception, ...) and that would bloat the parameter list further.

I attach a cleanup patch which packs everything into a new struct and renames hvm_inject_exception to hvm_inject_trap. I then define a couple of wrappers around that function for existing callers, so that their parameter lists actually *shrink*.

Quoted 4 lines

Let me know what you think. If it looks acceptable I can check it in and we can build on top of this restructuring. The aim being to keep hvm/vmx_inject_trap dumb, and push down the knowledge from the callers into it.

So I take it that with just this patch injecting of software interrupts will not work and I should hold off on testing that out. What is the plan for injecting software interrupts? Add another libxc API for that?

Thanks,
Aravindh

#4 lore raw

Re: [PATCH 1/3] xen: Add instruction length parameter in function hvm_inject_exception

Quoted 14 lines · Aravindh Puthiyaparambil
Quoted 9 lines

I don't like adding yet another parameter for all callers, especially as we should also be passing down the event type (sw interrupt, hw exception, ...) and that would bloat the parameter list further.

I attach a cleanup patch which packs everything into a new struct and renames hvm_inject_exception to hvm_inject_trap. I then define a couple of wrappers around that function for existing callers, so that their parameter lists actually *shrink*.

Quoted 4 lines

Let me know what you think. If it looks acceptable I can check it in and we can build on top of this restructuring. The aim being to keep hvm/vmx_inject_trap dumb, and push down the knowledge from the callers into it.

Quoted 4 lines

So I take it that with just this patch injecting of software interrupts will not work and I should hold off on testing that out. What is the plan for injecting software interrupts? Add another libxc API for that?

Yes, everything represented in my 'struct hvm_trap', plus instruction length, which my patch doesn't add, should be part of the trap injection API through hvm_op hypercall and libxc. So the toolstack can inject an arbitrary trap type, on an arbitrary vector, specify an error code (and cr2 for page fault), and specify an increment for rIP when the trap is successfully injected. All through one API function.

But as you say, my patch is just a proposed refactoring basis for Xudong's patches. It actually almost certainly reverts some behaviour that you guys actually want, which then gets added back in more sanely in patches that go on top.

-- Keir

#5 lore raw

Re: [PATCH 1/3] xen: Add instruction length parameter in function hvm_inject_exception

Quoted 21 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]] On Behalf Of Keir Fraser
Sent: Saturday, May 26, 2012 4:42 AM
To: Aravindh Puthiyaparambil
Cc: Hao, Xudong; [email protected]; [email protected]; Dong, Eddie; Ian Jackson; Zhang, Xiantao
Subject: Re: [PATCH 1/3] xen: Add instruction length parameter in function hvm_inject_exception

Quoted 9 lines · Aravindh Puthiyaparambil
Quoted 9 lines

I don't like adding yet another parameter for all callers, especially as we should also be passing down the event type (sw interrupt, hw exception, ...) and that would bloat the parameter list further.

I attach a cleanup patch which packs everything into a new struct and renames hvm_inject_exception to hvm_inject_trap. I then define a couple of wrappers around that function for existing callers, so that their parameter lists actually *shrink*.

Quoted 11 lines
Quoted 3 lines
Quoted 3 lines

Let me know what you think. If it looks acceptable I can check it in and we can build on top of this restructuring. The aim being to keep hvm/vmx_inject_trap dumb, and push down the knowledge from the callers

into

Quoted 6 lines
Quoted 1 line

it.

So I take it that with just this patch injecting of software interrupts will not work and I should hold off on testing that out. What is the plan for injecting software interrupts? Add another libxc API for that?

I'll write libxc API and correct the new function vmx_inject_trap() based on Keir's restructuring.

Quoted 3 lines

Yes, everything represented in my 'struct hvm_trap', plus instruction length, which my patch doesn't add, should be part of the trap injection API through hvm_op hypercall and libxc.

I can add instruction length in hvm_trap.

Quoted 10 lines

So the toolstack can inject an arbitrary
trap type, on an arbitrary vector, specify an error code (and cr2 for page fault), and specify an increment for rIP when the trap is successfully injected. All through one API function.

But as you say, my patch is just a proposed refactoring basis for Xudong's patches. It actually almost certainly reverts some behaviour that you guys actually want, which then gets added back in more sanely in patches that go on top.

Sure, I'll finish our things.

Quoted 2 lines

-- Keir

#6 lore raw

Re: [PATCH 1/3] xen: Add instruction length parameter in function hvm_inject_exception

In reply to Keir Fraser
Quoted 29 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]] On Behalf Of Keir Fraser
Sent: Friday, May 25, 2012 4:53 PM
To: Hao, Xudong; [email protected]
Cc: [email protected]; Dong, Eddie; Aravindh Puthiyaparambil; Ian Jackson; Zhang, Xiantao
Subject: Re: [PATCH 1/3] xen: Add instruction length parameter in function hvm_inject_exception

Quoted 1 line · Xudong Hao

VMX exception: Pass the instruction length field down to exception

emulation,

Quoted 6 lines

by changing hypercall parameter and adding a parameter in fucntion hvm_inject_exception(), so that exception emulation can set correct instruction length.

I don't like adding yet another parameter for all callers, especially as we should also be passing down the event type (sw interrupt, hw exception, ...) and that would bloat the parameter list further.

I attach a cleanup patch which packs everything into a new struct and renames hvm_inject_exception to hvm_inject_trap. I then define a couple of wrappers around that function for existing callers, so that their parameter lists actually *shrink*.

Quoted 5 lines

Let me know what you think. If it looks acceptable I can check it in and we can build on top of this restructuring. The aim being to keep hvm/vmx_inject_trap dumb, and push down the knowledge from the callers into
it.

Hi, Keir

This patch is fine to me, just one small comments: the note below the hvm_inject_hw_exception(TRAP*) should change to hvm_inject_hw_exception from hvm_inject_exception.

xen/arch/x86/hvm/svm/nestedsvm.c Fri May 25 09:45:00 2012 +0100 renamed from xen/arch/x86/hvm/svm/nestedsvm.c Fri May 25 08:21:25 2012 +0100 +1 -1
@@ -735,7 +735,7 @@ nsvm_vcpu_vmrun(struct vcpu *v, struct c
     default:
         gdprintk(XENLOG_ERR,
             "nsvm_vcpu_vmentry failed, injecting #UD\n");
-        hvm_inject_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE, 0);
+        hvm_inject_hw_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE);
         /* Must happen after hvm_inject_exception or it doesn't work right. */
 

And I'll add instruction length represented in 'struct hvm_trap', and correct the _trap.type in new function vmx_inject_trap() based on the restructuring.

Quoted 2 lines

-- Keir

#7 lore raw

Re: [PATCH 1/3] xen: Add instruction length parameter in function hvm_inject_exception

Quoted 5 lines · Xudong

Hi, Keir

This patch is fine to me, just one small comments: the note below the hvm_inject_hw_exception(TRAP*) should change to hvm_inject_hw_exception from hvm_inject_exception.

Yes indeed. Thanks!

-- Keir

Quoted 17 lines
xen/arch/x86/hvm/svm/nestedsvm.c Fri May 25 09:45:00 2012 +0100 renamed from xen/arch/x86/hvm/svm/nestedsvm.c Fri May 25 08:21:25 2012 +0100 +1 -1
@@ -735,7 +735,7 @@ nsvm_vcpu_vmrun(struct vcpu *v, struct c
     default:
         gdprintk(XENLOG_ERR,
             "nsvm_vcpu_vmentry failed, injecting #UD\n");
-        hvm_inject_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE, 0);
+        hvm_inject_hw_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE);
         /* Must happen after hvm_inject_exception or it doesn't work right.
 */
 

And I'll add instruction length represented in 'struct hvm_trap', and correct the _trap.type in new function vmx_inject_trap() based on the restructuring.

Quoted 2 lines

-- Keir

#8 lore raw

Re: [PATCH 1/3] xen: Add instruction length parameter in function hvm_inject_exception

Quoted 11 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Monday, May 28, 2012 2:50 PM
To: Hao, Xudong; [email protected]
Cc: [email protected]; Dong, Eddie; Aravindh Puthiyaparambil; Ian Jackson; Zhang, Xiantao
Subject: Re: [PATCH 1/3] xen: Add instruction length parameter in function hvm_inject_exception

On 28/05/2012 07:24, "Hao, Xudong" <[email protected]> wrote:

Quoted 9 lines
Quoted 4 lines

Hi, Keir

This patch is fine to me, just one small comments: the note below the hvm_inject_hw_exception(TRAP*) should change to

hvm_inject_hw_exception from

Quoted 1 line

hvm_inject_exception.

Yes indeed. Thanks!

Hi, Keir

Can you check your patch in? then I can send my patches out based you.

#9 lore raw

Re: [PATCH 1/3] xen: Add instruction length parameter in function hvm_inject_exception

Quoted 16 lines · Xudong
Quoted 16 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Monday, May 28, 2012 2:50 PM
To: Hao, Xudong; [email protected]
Cc: [email protected]; Dong, Eddie; Aravindh Puthiyaparambil; Ian Jackson; Zhang, Xiantao
Subject: Re: [PATCH 1/3] xen: Add instruction length parameter in function hvm_inject_exception

Quoted 4 lines · Xudong

Hi, Keir

This patch is fine to me, just one small comments: the note below the hvm_inject_hw_exception(TRAP*) should change to

hvm_inject_hw_exception from

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

hvm_inject_exception.

Yes indeed. Thanks!

Hi, Keir

Can you check your patch in? then I can send my patches out based you.

Please make my patch the first of your series. You can add my s-o-b line:

-- Keir

#10 lore raw

Re: [PATCH 1/3] xen: Add instruction length parameter in function hvm_inject_exception

Quoted 32 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Tuesday, May 29, 2012 8:39 PM
To: Hao, Xudong; [email protected]
Cc: [email protected]; Dong, Eddie; Aravindh Puthiyaparambil; Ian Jackson; Zhang, Xiantao
Subject: Re: [PATCH 1/3] xen: Add instruction length parameter in function hvm_inject_exception

Quoted 21 lines · Xudong
Quoted 20 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Monday, May 28, 2012 2:50 PM
To: Hao, Xudong; [email protected]
Cc: [email protected]; Dong, Eddie; Aravindh Puthiyaparambil; Ian Jackson; Zhang, Xiantao
Subject: Re: [PATCH 1/3] xen: Add instruction length parameter in function hvm_inject_exception

Quoted 4 lines · Xudong

Hi, Keir

This patch is fine to me, just one small comments: the note below the hvm_inject_hw_exception(TRAP*) should change to

hvm_inject_hw_exception from

Quoted 1 line

hvm_inject_exception.

Yes indeed. Thanks!

Quoted 7 lines
Quoted 3 lines

Hi, Keir

Can you check your patch in? then I can send my patches out based you.

Please make my patch the first of your series. You can add my s-o-b line:

Okay.

Quoted 3 lines

-- Keir

author
#11 lore raw

PATCH 2/3 VMX: Fix the mistake of exception execution

In reply to Xudong Hao

Fix the mistake for debug exception(#DB), overflow exception(#OF) and INT3(#BP), INTn instruction emulation.

Introduce new function vmx_inject_sw_exception() which deliver the software excetion, software interrupt and privileged software exception. Split hardware exception as a seperate function(old function vmx_inject_hw_exception()).

According to instruction length, to distinguish INT3 is generated by opcode 'CC' or 'CD ib =3', so do INTO and #DB(debug exception).

Note:
* For INTn (CD ib), it should use type 4 (software interrupt).

* For INT3 (CC; NOT CD ib with ib=3) and INTO (CE; NOT CD ib with ib=4), it should use type 6 (software exception).

* For other exceptions (#DE, #DB, #BR, #UD, #NM, #TS, #NP, #SS, #GP, #PF, #MF, #AC, #MC, and #XM), it should use type 3 (hardware exception).

* In the unlikely event that you are emulating the undocumented opcode F1 (informally called INT1 or ICEBP), it would use type 5 (privileged software exception).

---
 xen/arch/x86/hvm/vmx/vmx.c        |  141 +++++++++++++++++++++++++++++++------
 xen/include/asm-x86/hvm/hvm.h     |    1 +
 xen/include/asm-x86/hvm/vmx/vmx.h |    1 +
 3 files changed, 122 insertions(+), 21 deletions(-)
xen/arch/x86/hvm/vmx/vmx.c +120 -21
index e15b7a4..8d78ffa 100644
@@ -1344,12 +1344,27 @@ static void __vmx_inject_exception(int trap, int type, int error_code)
         curr->arch.hvm_vmx.vmx_emulate = 1;
 }
 
-void vmx_inject_hw_exception(int trap, int error_code)
+/*
+ * Generate the virtual event to guest.
+ * NOTE:
+ *    This is for processor execution generated exceptions,
+ * and handle all software exception/interrupt, which include:
+ *  - INT 3(CC), INTO (CE) instruction emulation, which should
+ *    use X86_EVENTTYPE_SW_EXCEPTION;
+ *  - INT nn (CD nn) instruction emulation, which should use
+ *    X86_EVENTTYPE_SW_INTERRUPT as interrupt type;
+ *  - opcode 0xf1 generated #DB should use privileged software
+ *    exception.
+ *
+ *    The caller of this function should set correct instruction
+ * length.
+ */
+void vmx_inject_sw_exception(int trap, int inslen, int error_code)
 {
     unsigned long intr_info;
     struct vcpu *curr = current;
 
-    int type = X86_EVENTTYPE_HW_EXCEPTION;
+    int type = X86_EVENTTYPE_SW_EXCEPTION;
 
     if ( nestedhvm_vcpu_in_guestmode(curr) )
         intr_info = vcpu_2_nvmx(curr).intr.intr_info;
@@ -1358,17 +1373,6 @@ void vmx_inject_hw_exception(int trap, int error_code)
 
     switch ( trap )
     {
-    case TRAP_debug:
-        type = X86_EVENTTYPE_SW_EXCEPTION;
-        if ( guest_cpu_user_regs()->eflags & X86_EFLAGS_TF )
-        {
-            __restore_debug_registers(curr);
-            write_debugreg(6, read_debugreg(6) | 0x4000);
-        }
-        if ( cpu_has_monitor_trap_flag )
-            break;
-        /* fall through */
-
     case TRAP_int3:
         if ( curr->domain->debugger_attached )
         {
@@ -1377,16 +1381,75 @@ void vmx_inject_hw_exception(int trap, int error_code)
             return;
         }
 
-        type = X86_EVENTTYPE_SW_EXCEPTION;
-        __vmwrite(VM_ENTRY_INSTRUCTION_LEN, 1); /* int3 */
+        if ( inslen == 2 )
+            type = X86_EVENTTYPE_SW_INTERRUPT;  /* CD ib with ib=3 */
+        break;
+
+    case TRAP_overflow:
+        if ( inslen == 2 )
+            type = X86_EVENTTYPE_SW_INTERRUPT;  /* CD ib with ib=4 */
+        break;
+
+    case TRAP_debug:
+        /* Handle DB generated by 0xf1 */
+        type = X86_EVENTTYPE_PRI_SW_EXCEPTION;
         break;
 
     default:
-        if ( trap > TRAP_last_reserved )
+        if ( trap > TRAP_last_reserved ) /* int imm8 */
+        {
+            type = X86_EVENTTYPE_SW_INTERRUPT;
+        }
+        break;
+
+    __vmwrite(VM_ENTRY_INSTRUCTION_LEN, inslen);
+
+    }
+
+    if ( nestedhvm_vcpu_in_guestmode(curr) &&
+         nvmx_intercepts_exception(curr, trap, error_code) )
+    {
+        nvmx_enqueue_n2_exceptions (curr, 
+            INTR_INFO_VALID_MASK | (type<<8) | trap,
+            error_code); 
+        return;
+    }
+    else
+        __vmx_inject_exception(trap, type, error_code);
+
+    HVMTRACE_2D(INJ_EXC, trap, error_code);
+}
+
+/*
+ * Generate the virtual event to guest.
+ * NOTE:
+ *    This is only for hardware exceptions type delivery.
+ */
+void vmx_inject_hw_exception(int trap, int error_code)
+{
+    unsigned long intr_info;
+    struct vcpu *curr = current;
+
+    int type = X86_EVENTTYPE_HW_EXCEPTION;
+
+    if ( nestedhvm_vcpu_in_guestmode(curr) )
+        intr_info = vcpu_2_nvmx(curr).intr.intr_info;
+    else
+        intr_info = __vmread(VM_ENTRY_INTR_INFO);
+
+    switch ( trap )
+    {
+    case TRAP_debug:
+        if ( guest_cpu_user_regs()->eflags & X86_EFLAGS_TF )
         {
-            type = X86_EVENTTYPE_SW_EXCEPTION;
-            __vmwrite(VM_ENTRY_INSTRUCTION_LEN, 2); /* int imm8 */
+            __restore_debug_registers(curr);
+            write_debugreg(6, read_debugreg(6) | 0x4000);
         }
+        if ( cpu_has_monitor_trap_flag )
+            break;
+        /* fall through */
+
+    default:
         break;
     }
 
@@ -1455,12 +1518,47 @@ void vmx_inject_nmi(void)
 }
 
 static void vmx_inject_exception(
-    unsigned int trapnr, int errcode, unsigned long cr2)
+    unsigned int trapnr, int inslen, int errcode, unsigned long cr2)
 {
     if ( trapnr == TRAP_page_fault )
         current->arch.hvm_vcpu.guest_cr[2] = cr2;
 
-    vmx_inject_hw_exception(trapnr, errcode);
+    switch(trapnr)
+    {
+        case TRAP_divide_error:
+        case TRAP_bounds:
+        case TRAP_invalid_op:
+        case TRAP_no_device:
+        case TRAP_invalid_tss:
+        case TRAP_no_segment:
+        case TRAP_stack_error:
+        case TRAP_gp_fault:
+        case TRAP_page_fault:
+        case TRAP_copro_error:
+        case TRAP_alignment_check:
+        case TRAP_machine_check:
+        case TRAP_simd_error:
+            vmx_inject_hw_exception(trapnr, errcode);
+            break;
+
+        case TRAP_debug:
+            if ( inslen != 0 )
+                /* icebp: opcode 0xf1 generate #DB, should be a privileged
+                 * software exception */
+                vmx_inject_sw_exception(trapnr, inslen, errcode);
+            else
+                vmx_inject_hw_exception(trapnr, errcode);
+            break;
+
+        case TRAP_int3:
+        case TRAP_overflow:
+            vmx_inject_sw_exception(trapnr, inslen, errcode);
+            break;
+    
+        default:
+            vmx_inject_sw_exception(trapnr, inslen, errcode);
+            break;
+    }
 }
 
 static int vmx_event_pending(struct vcpu *v)
@@ -2440,7 +2538,8 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
                 
                 if ( handled < 0 ) 
                 {
-                    vmx_inject_exception(TRAP_int3, HVM_DELIVER_NO_ERROR_CODE, 0);
+                    vmx_inject_exception(TRAP_int3,
+                       __vmread(VM_EXIT_INSTRUCTION_LEN), HVM_DELIVER_NO_ERROR_CODE, 0);
                     break;
                 }
                 else if ( handled )
xen/include/asm-x86/hvm/hvm.h +1 -0
index 3ba1615..c65ad09 100644
@@ -370,6 +370,7 @@ static inline int hvm_do_pmu_interrupt(struct cpu_user_regs *regs)
 #define X86_EVENTTYPE_NMI                   2    /* NMI                */
 #define X86_EVENTTYPE_HW_EXCEPTION          3    /* hardware exception */
 #define X86_EVENTTYPE_SW_INTERRUPT          4    /* software interrupt */
+#define X86_EVENTTYPE_PRI_SW_EXCEPTION      5    /* privileged software exception */
 #define X86_EVENTTYPE_SW_EXCEPTION          6    /* software exception */
 
 int hvm_event_needs_reinjection(uint8_t type, uint8_t vector);
xen/include/asm-x86/hvm/vmx/vmx.h +1 -0
index f003f84..61078a6 100644
@@ -387,6 +387,7 @@ static inline int __vmxon(u64 addr)
     return rc;
 }
 
+void vmx_inject_sw_exception(int trap, int inslen, int error_code);
 void vmx_inject_hw_exception(int trap, int error_code);
 void vmx_inject_extint(int trap);
 void vmx_inject_nmi(void);
Signature · 1 line
1.5.5