Skip to contentSkip to conversation

XEN: fix vmx exception mistake

PATCH In review Xudong Hao 4 participants 13 messages May 30, 2012 – Jun 1, 2012

lore
Share & tools
lore

Xudong Hao

author
#0 lore raw

v2 cover XEN: fix vmx exception mistake

Changes from v1:
- Define new struct hvm_trap to represent information of trap, include instruction length.
- Renames hvm_inject_exception to hvm_inject_trap. Then define a couple of wrappers around that function for existing callers, so that their parameter lists actually *shrink*.

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

PATCH 3 and PATCH 4 supply an interface for userspace to inject trap.

PATCH 1: Define new struct hvm_trap and cleanup vmx exception.

PATCH 2: Fix the mistake for debug exception(#DB), overflow exception(#OF) and INT3(#BP), INTn instruction emulation. Add inslen field in struct hvm_trap.

PATCH 3: Add parameter inslen for hypercall HVMOP_inject_trap, supply interface used by passing instruction length from userspace.

PATCH 4: 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 v2 1/4 xen: Define new struct hvm_trap and cleanup vmx exception

Define new struct hvm_trap to represent information of trap, and renames hvm_inject_exception to hvm_inject_trap, then define a couple of wrappers around that function for existing callers.

---
 xen/arch/x86/hvm/emulate.c              |    4 +-
 xen/arch/x86/hvm/hvm.c                  |   90 ++++++++++-------
 xen/arch/x86/hvm/io.c                   |    2 +-
 xen/arch/x86/hvm/svm/emulate.c          |    4 +-
 xen/arch/x86/hvm/svm/nestedsvm.c        |   16 ++--
 xen/arch/x86/hvm/svm/svm.c              |   66 +++++++------
 xen/arch/x86/hvm/vmx/intr.c             |    2 +-
 xen/arch/x86/hvm/vmx/vmx.c              |  169 ++++++++++++++-----------------
 xen/arch/x86/hvm/vmx/vpmu_core2.c       |    8 +-
 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           |   22 +++--
 xen/include/asm-x86/hvm/svm/nestedsvm.h |    3 +-
 xen/include/asm-x86/hvm/vcpu.h          |    7 +-
 xen/include/asm-x86/hvm/vmx/vmx.h       |    1 -
 16 files changed, 205 insertions(+), 199 deletions(-)
xen/arch/x86/hvm/emulate.c +2 -2
index 2b50670..9bfba48 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_page_fault(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_page_fault(pfec, addr & PAGE_MASK);
                 return X86EMUL_EXCEPTION;
             }
             *reps = done;
xen/arch/x86/hvm/hvm.c +53 -37

242 lines not on this page · raw message

xen/arch/x86/hvm/io.c +1 -1
index 41a2ede..31af045 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_hw_exception(ctxt.exn_vector, ctxt.exn_error_code);
         break;
     default:
         break;
xen/arch/x86/hvm/svm/emulate.c +2 -2
index 6000bff..0c72f00 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_hw_exception(TRAP_gp_fault, 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_hw_exception(TRAP_gp_fault, 0);
     return 0;
 
  done:
xen/arch/x86/hvm/svm/nestedsvm.c +8 -8
index 8714bb0..6ed3260 100644
@@ -735,8 +735,8 @@ 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);
-        /* Must happen after hvm_inject_exception or it doesn't work right. */
+        hvm_inject_hw_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE);
+        /* Must happen after hvm_inject_hw_exception or it doesn't work right. */
         nv->nv_vmswitch_in_progress = 0;
         return 1;
     }
@@ -796,12 +796,12 @@ nsvm_vcpu_vmexit_inject(struct vcpu *v, struct cpu_user_regs *regs,
 }
 
 int
-nsvm_vcpu_vmexit_trap(struct vcpu *v, unsigned int trapnr,
-                      int errcode, unsigned long cr2)
+nsvm_vcpu_vmexit_trap(struct vcpu *v, struct hvm_trap *trap)
 {
     ASSERT(vcpu_nestedhvm(v).nv_vvmcx != NULL);
 
-    nestedsvm_vmexit_defer(v, VMEXIT_EXCEPTION_DE + trapnr, errcode, cr2);
+    nestedsvm_vmexit_defer(v, VMEXIT_EXCEPTION_DE + trap->vector,
+                           trap->error_code, trap->cr2);
     return NESTEDHVM_VMEXIT_DONE;
 }
 
@@ -1176,7 +1176,7 @@ enum hvm_intblk nsvm_intr_blocked(struct vcpu *v)
     }
 
     if ( nv->nv_vmexit_pending ) {
-        /* hvm_inject_exception() must have run before.
+        /* hvm_inject_hw_exception() must have run before.
          * exceptions have higher priority than interrupts.
          */
         return hvm_intblk_rflags_ie;
@@ -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_hw_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE);
         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_hw_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE);
         return;
     }
 
xen/arch/x86/hvm/svm/svm.c +35 -31

199 lines not on this page · raw message

xen/arch/x86/hvm/vmx/intr.c +1 -1
index d675011..590c483 100644
@@ -251,7 +251,7 @@ void vmx_intr_assist(void)
     }
     else if ( intack.source == hvm_intsrc_mce )
     {
-        vmx_inject_hw_exception(TRAP_machine_check, HVM_DELIVER_NO_ERROR_CODE);
+        hvm_inject_hw_exception(TRAP_machine_check, HVM_DELIVER_NO_ERROR_CODE);
     }
     else
     {
xen/arch/x86/hvm/vmx/vmx.c +77 -92

303 lines not on this page · raw message

xen/arch/x86/hvm/vmx/vpmu_core2.c +4 -4
index 266d4a6..c79103e 100644
@@ -421,7 +421,7 @@ static int core2_vpmu_do_wrmsr(unsigned int msr, uint64_t msr_content)
                 if ( vpmu_is_set(vpmu, VPMU_CPU_HAS_BTS) )
                     return 1;
                 gdprintk(XENLOG_WARNING, "Debug Store is not supported on this cpu\n");
-                vmx_inject_hw_exception(TRAP_gp_fault, 0);
+                hvm_inject_hw_exception(TRAP_gp_fault, 0);
                 return 0;
             }
         }
@@ -437,7 +437,7 @@ static int core2_vpmu_do_wrmsr(unsigned int msr, uint64_t msr_content)
     case MSR_CORE_PERF_GLOBAL_STATUS:
         gdprintk(XENLOG_INFO, "Can not write readonly MSR: "
                  "MSR_PERF_GLOBAL_STATUS(0x38E)!\n");
-        vmx_inject_hw_exception(TRAP_gp_fault, 0);
+        hvm_inject_hw_exception(TRAP_gp_fault, 0);
         return 1;
     case MSR_IA32_PEBS_ENABLE:
         if ( msr_content & 1 )
@@ -452,7 +452,7 @@ static int core2_vpmu_do_wrmsr(unsigned int msr, uint64_t msr_content)
                 gdprintk(XENLOG_WARNING,
                          "Illegal address for IA32_DS_AREA: %#" PRIx64 "x\n",
                          msr_content);
-                vmx_inject_hw_exception(TRAP_gp_fault, 0);
+                hvm_inject_hw_exception(TRAP_gp_fault, 0);
                 return 1;
             }
             core2_vpmu_cxt->pmu_enable->ds_area_enable = msr_content ? 1 : 0;
@@ -544,7 +544,7 @@ static int core2_vpmu_do_wrmsr(unsigned int msr, uint64_t msr_content)
             break;
         }
         if (inject_gp)
-            vmx_inject_hw_exception(TRAP_gp_fault, 0);
+            hvm_inject_hw_exception(TRAP_gp_fault, 0);
         else
             wrmsrl(msr, msr_content);
     }
xen/arch/x86/hvm/vmx/vvmx.c +3 -3
index b0ae0ee..fc733a9 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_hw_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE);
     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_hw_exception(TRAP_gp_fault, 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_hw_exception(TRAP_gp_fault, 0);
     return X86EMUL_EXCEPTION;
 }
 
xen/arch/x86/mm/shadow/common.c +1 -1
index 59be993..dc245be 100644
@@ -135,7 +135,7 @@ static int hvm_translate_linear_addr(
 
     if ( !okay )
     {
-        hvm_inject_exception(TRAP_gp_fault, 0, 0);
+        hvm_inject_hw_exception(TRAP_gp_fault, 0);
         return X86EMUL_EXCEPTION;
     }
 
xen/arch/x86/mm/shadow/multi.c +1 -1
index 9368385..4f56ae6 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_page_fault(pfec, vaddr);
         else
             propagate_page_fault(vaddr, pfec);
         return _mfn(BAD_GVA_TO_GFN);
xen/include/asm-x86/hvm/hvm.h +13 -9
index 22f9451..65f7e20 100644
@@ -71,6 +71,13 @@ enum hvm_intblk {
 #define HVM_HAP_SUPERPAGE_2MB   0x00000001
 #define HVM_HAP_SUPERPAGE_1GB   0x00000002
 
+struct hvm_trap {
+    int           vector;
+    unsigned int  type;         /* X86_EVENTTYPE_* */
+    int           error_code;   /* HVM_DELIVER_NO_ERROR_CODE if n/a */
+    unsigned long cr2;          /* Only for TRAP_page_fault h/w exception */
+};
+
 /*
  * The hardware virtual machine (HVM) interface abstracts away from the
  * x86/x86_64 CPU virtualization assist specifics. Currently this interface
@@ -124,8 +131,7 @@ struct hvm_function_table {
 
     void (*set_tsc_offset)(struct vcpu *v, u64 offset);
 
-    void (*inject_exception)(unsigned int trapnr, int errcode,
-                             unsigned long cr2);
+    void (*inject_trap)(struct hvm_trap *trap);
 
     void (*init_hypercall_page)(struct domain *d, void *hypercall_page);
 
@@ -162,10 +168,7 @@ struct hvm_function_table {
                                 struct cpu_user_regs *regs);
     int (*nhvm_vcpu_vmexit)(struct vcpu *v, struct cpu_user_regs *regs,
                                 uint64_t exitcode);
-    int (*nhvm_vcpu_vmexit_trap)(struct vcpu *v,
-                                unsigned int trapnr,
-                                int errcode,
-                                unsigned long cr2);
+    int (*nhvm_vcpu_vmexit_trap)(struct vcpu *v, struct hvm_trap *trap);
     uint64_t (*nhvm_vcpu_guestcr3)(struct vcpu *v);
     uint64_t (*nhvm_vcpu_hostcr3)(struct vcpu *v);
     uint32_t (*nhvm_vcpu_asid)(struct vcpu *v);
@@ -320,7 +323,9 @@ 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_trap(struct hvm_trap *trap);
+void hvm_inject_hw_exception(unsigned int trapnr, int errcode);
+void hvm_inject_page_fault(int errcode, unsigned long cr2);
 
 static inline int hvm_event_pending(struct vcpu *v)
 {
@@ -479,8 +484,7 @@ int nhvm_vcpu_vmexit(struct vcpu *v, struct cpu_user_regs *regs,
 /* inject vmexit into l1 guest. l1 guest will see a VMEXIT due to
  * 'trapnr' exception.
  */ 
-int nhvm_vcpu_vmexit_trap(struct vcpu *v,
-    unsigned int trapnr, int errcode, unsigned long cr2);
+int nhvm_vcpu_vmexit_trap(struct vcpu *v, struct hvm_trap *trap);
 
 /* returns l2 guest cr3 in l2 guest physical address space. */
 uint64_t nhvm_vcpu_guestcr3(struct vcpu *v);
xen/include/asm-x86/hvm/svm/nestedsvm.h +1 -2
index f6951b3..fa83023 100644
@@ -114,8 +114,7 @@ int nsvm_vcpu_hostrestore(struct vcpu *v, struct cpu_user_regs *regs);
 int nsvm_vcpu_vmrun(struct vcpu *v, struct cpu_user_regs *regs);
 int nsvm_vcpu_vmexit_inject(struct vcpu *v, struct cpu_user_regs *regs,
     uint64_t exitcode);
-int nsvm_vcpu_vmexit_trap(struct vcpu *v, unsigned int trapnr,
-                      int errcode, unsigned long cr2);
+int nsvm_vcpu_vmexit_trap(struct vcpu *v, struct hvm_trap *trap);
 uint64_t nsvm_vcpu_guestcr3(struct vcpu *v);
 uint64_t nsvm_vcpu_hostcr3(struct vcpu *v);
 uint32_t nsvm_vcpu_asid(struct vcpu *v);
xen/include/asm-x86/hvm/vcpu.h +3 -4
index 537da96..f2da72d 100644
@@ -164,10 +164,9 @@ struct hvm_vcpu {
     /* Callback into x86_emulate when emulating FPU/MMX/XMM instructions. */
     void (*fpu_exception_callback)(void *, struct cpu_user_regs *);
     void *fpu_exception_callback_arg;
-    /* Pending hw/sw interrupt */
-    int           inject_trap;       /* -1 for nothing to inject */
-    int           inject_error_code;
-    unsigned long inject_cr2;
+
+    /* Pending hw/sw interrupt (.vector = -1 means nothing pending). */
+    struct hvm_trap     inject_trap;
 
     struct viridian_vcpu viridian;
 };
xen/include/asm-x86/hvm/vmx/vmx.h +0 -1
index f003f84..accfa3f 100644
@@ -387,7 +387,6 @@ static inline int __vmxon(u64 addr)
     return rc;
 }
 
-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
author
#2 lore raw

PATCH v2 2/4 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.

Add inslen field in struct hvm_trap. 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    |   43 ++++++++++++++++++++++++++++++++++++++++-
 xen/include/asm-x86/hvm/hvm.h |    2 +
 2 files changed, 44 insertions(+), 1 deletions(-)
xen/arch/x86/hvm/vmx/vmx.c +42 -1
index c96d18b..cf08a11 100644
@@ -1381,6 +1381,19 @@ void vmx_inject_nmi(void)
                            HVM_DELIVER_NO_ERROR_CODE);
 }
 
+/*
+ * Generate the virtual event to guest.
+ * NOTE:
+ *    This is for processor execution generated exceptions,
+ * and handle #DB hardware exception and 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.
+ */
 static void vmx_inject_trap(struct hvm_trap *trap)
 {
     unsigned long intr_info;
@@ -1399,6 +1412,12 @@ static void vmx_inject_trap(struct hvm_trap *trap)
     switch ( _trap.vector )
     {
     case TRAP_debug:
+        _trap.type = X86_EVENTTYPE_HW_EXCEPTION;
+        if ( _trap.inslen != 1 ) {
+            _trap.type = X86_EVENTTYPE_PRI_SW_EXCEPTION;  /* opcode 0xf1 */
+            __vmwrite(VM_ENTRY_INSTRUCTION_LEN, _trap.inslen);
+        }
+
         if ( guest_cpu_user_regs()->eflags & X86_EFLAGS_TF )
         {
             __restore_debug_registers(curr);
@@ -1414,6 +1433,27 @@ static void vmx_inject_trap(struct hvm_trap *trap)
             domain_pause_for_debugger();
             return;
         }
+        _trap.type = X86_EVENTTYPE_SW_EXCEPTION;  /* CC */
+        if ( _trap.inslen != 1 )
+            _trap.type = X86_EVENTTYPE_SW_INTERRUPT;  /* CD ib with ib=3 */
+        __vmwrite(VM_ENTRY_INSTRUCTION_LEN, _trap.inslen);
+        break;
+
+    case TRAP_overflow:
+        _trap.type = X86_EVENTTYPE_SW_EXCEPTION;  /* CE */
+        if ( _trap.inslen != 1 )
+            _trap.type = X86_EVENTTYPE_SW_INTERRUPT;  /* CD ib with ib=4 */
+        __vmwrite(VM_ENTRY_INSTRUCTION_LEN, _trap.inslen);
+        break;
+
+    default:
+        if ( _trap.vector > TRAP_last_reserved ) /* int imm8 */
+        {
+            _trap.type = X86_EVENTTYPE_SW_INTERRUPT;
+            __vmwrite(VM_ENTRY_INSTRUCTION_LEN, _trap.inslen);
+        }
+        break;
+
     }
 
     if ( unlikely(intr_info & INTR_INFO_VALID_MASK) &&
@@ -2424,7 +2464,8 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
                     struct hvm_trap trap = {
                         .vector = TRAP_int3,
                         .type = X86_EVENTTYPE_SW_EXCEPTION,
-                        .error_code = HVM_DELIVER_NO_ERROR_CODE
+                        .error_code = HVM_DELIVER_NO_ERROR_CODE,
+                        .inslen = __vmread(VM_EXIT_INSTRUCTION_LEN)
                     };
                     hvm_inject_trap(&trap);
                     break;
xen/include/asm-x86/hvm/hvm.h +2 -0
index 65f7e20..a3d8bf1 100644
@@ -76,6 +76,7 @@ struct hvm_trap {
     unsigned int  type;         /* X86_EVENTTYPE_* */
     int           error_code;   /* HVM_DELIVER_NO_ERROR_CODE if n/a */
     unsigned long cr2;          /* Only for TRAP_page_fault h/w exception */
+    int           inslen;       /* Instruction length */ 
 };
 
 /*
@@ -375,6 +376,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);
Signature · 1 line
1.5.5
#3 lore raw

Re: [PATCH v2 2/4] VMX: Fix the mistake of exception execution

Quoted 7 lines
Quoted 1 line
Quoted 1 line · Xudong Hao

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

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

As noted previously, using the instruction length here is not fully correct. Depending on how significant the distinction between software interrupt and software exception is, taking into account something like the opcode sequence 66 CC may be necessary. If the distinction is insignificant, then perhaps a code comment should say so.

More comments inline...

Quoted 49 lines

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    |   43 
++++++++++++++++++++++++++++++++++++++++-
 xen/include/asm-x86/hvm/hvm.h |    2 +
 2 files changed, 44 insertions(+), 1 deletions(-)
xen/arch/x86/hvm/vmx/vmx.c +13 -0
index c96d18b..cf08a11 100644
@@ -1381,6 +1381,19 @@ void vmx_inject_nmi(void)
                            HVM_DELIVER_NO_ERROR_CODE);
 }
 
+/*
+ * Generate the virtual event to guest.
+ * NOTE:
+ *    This is for processor execution generated exceptions,
+ * and handle #DB hardware exception and 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.
+ */
 static void vmx_inject_trap(struct hvm_trap *trap)
 {
     unsigned long intr_info;

xen/arch/x86/hvm/vmx/vmx.c static void vmx_inject_trap(struct hvm_trap *trap) · line 1416

Quoted 5 lines
xen/arch/x86/hvm/vmx/vmx.c +2 -0
@@ -1399,6 +1412,12 @@ static void vmx_inject_trap(struct hvm_trap *trap)
     switch ( _trap.vector )
     {
     case TRAP_debug:
+        _trap.type = X86_EVENTTYPE_HW_EXCEPTION;
+        if ( _trap.inslen != 1 ) {

Opcode F1 certainly has length 1, so perhaps the condition is inverted? Perhaps length 0 should be used here to distinguish the hardware exception case from the F1-generated one.

Quoted 50 lines
xen/arch/x86/hvm/vmx/vmx.c +27 -1
+            _trap.type = X86_EVENTTYPE_PRI_SW_EXCEPTION;  /* opcode 0xf1 */
+            __vmwrite(VM_ENTRY_INSTRUCTION_LEN, _trap.inslen);
+        }
+
         if ( guest_cpu_user_regs()->eflags & X86_EFLAGS_TF )
         {
             __restore_debug_registers(curr);
@@ -1414,6 +1433,27 @@ static void vmx_inject_trap(struct hvm_trap *trap)
             domain_pause_for_debugger();
             return;
         }
+        _trap.type = X86_EVENTTYPE_SW_EXCEPTION;  /* CC */
+        if ( _trap.inslen != 1 )
+            _trap.type = X86_EVENTTYPE_SW_INTERRUPT;  /* CD ib with ib=3 */
+        __vmwrite(VM_ENTRY_INSTRUCTION_LEN, _trap.inslen);
+        break;
+
+    case TRAP_overflow:
+        _trap.type = X86_EVENTTYPE_SW_EXCEPTION;  /* CE */
+        if ( _trap.inslen != 1 )
+            _trap.type = X86_EVENTTYPE_SW_INTERRUPT;  /* CD ib with ib=4 */
+        __vmwrite(VM_ENTRY_INSTRUCTION_LEN, _trap.inslen);
+        break;
+
+    default:
+        if ( _trap.vector > TRAP_last_reserved ) /* int imm8 */
+        {
+            _trap.type = X86_EVENTTYPE_SW_INTERRUPT;
+            __vmwrite(VM_ENTRY_INSTRUCTION_LEN, _trap.inslen);
+        }
+        break;
+
     }
 
     if ( unlikely(intr_info & INTR_INFO_VALID_MASK) &&
@@ -2424,7 +2464,8 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
                     struct hvm_trap trap = {
                         .vector = TRAP_int3,
                         .type = X86_EVENTTYPE_SW_EXCEPTION,
-                        .error_code = HVM_DELIVER_NO_ERROR_CODE
+                        .error_code = HVM_DELIVER_NO_ERROR_CODE,
+                        .inslen = __vmread(VM_EXIT_INSTRUCTION_LEN)
                     };
                     hvm_inject_trap(&trap);
                     break;
xen/include/asm-x86/hvm/hvm.h +0 -0
index 65f7e20..a3d8bf1 100644

xen/include/asm-x86/hvm/hvm.h struct hvm_trap { · line 80

Quoted 5 lines
xen/include/asm-x86/hvm/hvm.h +1 -0
@@ -76,6 +76,7 @@ struct hvm_trap {
     unsigned int  type;         /* X86_EVENTTYPE_* */
     int           error_code;   /* HVM_DELIVER_NO_ERROR_CODE if n/a */
     unsigned long cr2;          /* Only for TRAP_page_fault h/w exception 
 */
+    int           inslen;       /* Instruction length */ 

May I suggest using "insnlen" instead?

Jan

Quoted 14 lines
xen/include/asm-x86/hvm/hvm.h +0 -0
 };
 

/*

xen/include/asm-x86/hvm/hvm.h +1 -0
@@ -375,6 +376,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);

Signature · 1 line
1.5.5
#4 lore raw

Re: [PATCH v2 2/4] VMX: Fix the mistake of exception execution

Quoted 16 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Wednesday, May 30, 2012 5:19 PM
To: Hao, Xudong
Cc: [email protected]; [email protected]; Dong, Eddie; Zhang, Xiantao; [email protected]; [email protected]
Subject: Re: [PATCH v2 2/4] VMX: Fix the mistake of exception execution

Quoted 7 lines
Quoted 1 line
Quoted 1 line · Xudong Hao

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

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

Quoted 7 lines

As noted previously, using the instruction length here is not fully correct. Depending on how significant the distinction between software interrupt and software exception is, taking into account something like the opcode sequence 66 CC may be necessary. If the distinction is insignificant, then perhaps a code comment should say so.

Jan, thanks comments, Keir added a trap type and both type and inslen can be specified by the caller now.

Quoted 58 lines

More comments inline...

xen/arch/x86/hvm/vmx/vmx.c static void vmx_inject_trap(struct hvm_trap

Quoted 49 lines

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    |   43
++++++++++++++++++++++++++++++++++++++++-
 xen/include/asm-x86/hvm/hvm.h |    2 +
 2 files changed, 44 insertions(+), 1 deletions(-)
xen/arch/x86/hvm/vmx/vmx.c +13 -0
index c96d18b..cf08a11 100644
@@ -1381,6 +1381,19 @@ void vmx_inject_nmi(void)
                            HVM_DELIVER_NO_ERROR_CODE);
 }
 
+/*
+ * Generate the virtual event to guest.
+ * NOTE:
+ *    This is for processor execution generated exceptions,
+ * and handle #DB hardware exception and 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.
+ */
 static void vmx_inject_trap(struct hvm_trap *trap)
 {
     unsigned long intr_info;
@@ -1399,6 +1412,12 @@ static void vmx_inject_trap(struct hvm_trap

*trap)

xen/arch/x86/hvm/vmx/vmx.c static void vmx_inject_trap(struct hvm_trap *trap) · line 1416

Quoted 5 lines
xen/arch/x86/hvm/vmx/vmx.c +2 -0
     switch ( _trap.vector )
     {
     case TRAP_debug:
+        _trap.type = X86_EVENTTYPE_HW_EXCEPTION;
+        if ( _trap.inslen != 1 ) {
Quoted 4 lines

Opcode F1 certainly has length 1, so perhaps the condition is inverted? Perhaps length 0 should be used here to distinguish the hardware exception case from the F1-generated one.

Yes, it's inverted..

Quoted 91 lines

xen/arch/x86/hvm/vmx/vmx.c static void vmx_inject_trap(struct hvm_trap · line 1417

Quoted 1 line
xen/arch/x86/hvm/vmx/vmx.c +1 -0
+            _trap.type = X86_EVENTTYPE_PRI_SW_EXCEPTION;  /*

opcode 0xf1 */

xen/arch/x86/hvm/vmx/vmx.c static void vmx_inject_trap(struct hvm_trap

Quoted 7 lines
xen/arch/x86/hvm/vmx/vmx.c +3 -0
+            __vmwrite(VM_ENTRY_INSTRUCTION_LEN, _trap.inslen);
+        }
+
         if ( guest_cpu_user_regs()->eflags & X86_EFLAGS_TF )
         {
             __restore_debug_registers(curr);
@@ -1414,6 +1433,27 @@ static void vmx_inject_trap(struct hvm_trap

*trap)

xen/arch/x86/hvm/vmx/vmx.c static void vmx_inject_trap(struct hvm_trap *trap)

Quoted 6 lines
xen/arch/x86/hvm/vmx/vmx.c +3 -0
             domain_pause_for_debugger();
             return;
         }
+        _trap.type = X86_EVENTTYPE_SW_EXCEPTION;  /* CC */
+        if ( _trap.inslen != 1 )
+            _trap.type = X86_EVENTTYPE_SW_INTERRUPT;  /* CD ib

with ib=3 */

xen/arch/x86/hvm/vmx/vmx.c static void vmx_inject_trap(struct hvm_trap *trap)

Quoted 7 lines
xen/arch/x86/hvm/vmx/vmx.c +7 -0
+        __vmwrite(VM_ENTRY_INSTRUCTION_LEN, _trap.inslen);
+        break;
+
+    case TRAP_overflow:
+        _trap.type = X86_EVENTTYPE_SW_EXCEPTION;  /* CE */
+        if ( _trap.inslen != 1 )
+            _trap.type = X86_EVENTTYPE_SW_INTERRUPT;  /* CD ib

with ib=4 */

xen/arch/x86/hvm/vmx/vmx.c void vmx_vmexit_handler(struct cpu_user_regs

Quoted 15 lines
xen/arch/x86/hvm/vmx/vmx.c +11 -0
+        __vmwrite(VM_ENTRY_INSTRUCTION_LEN, _trap.inslen);
+        break;
+
+    default:
+        if ( _trap.vector > TRAP_last_reserved ) /* int imm8 */
+        {
+            _trap.type = X86_EVENTTYPE_SW_INTERRUPT;
+            __vmwrite(VM_ENTRY_INSTRUCTION_LEN, _trap.inslen);
+        }
+        break;
+
     }
 
     if ( unlikely(intr_info & INTR_INFO_VALID_MASK) &&
@@ -2424,7 +2464,8 @@ void vmx_vmexit_handler(struct cpu_user_regs

*regs)

xen/arch/x86/hvm/vmx/vmx.c void vmx_vmexit_handler(struct cpu_user_regs *regs)

Quoted 4 lines
xen/arch/x86/hvm/vmx/vmx.c +0 -1
                     struct hvm_trap trap = {
                         .vector = TRAP_int3,
                         .type = X86_EVENTTYPE_SW_EXCEPTION,
-                        .error_code =

HVM_DELIVER_NO_ERROR_CODE

xen/arch/x86/hvm/vmx/vmx.c void vmx_vmexit_handler(struct cpu_user_regs · line 2467

Quoted 1 line
xen/arch/x86/hvm/vmx/vmx.c +1 -0
+                        .error_code =

HVM_DELIVER_NO_ERROR_CODE,

xen/arch/x86/hvm/vmx/vmx.c void vmx_vmexit_handler(struct cpu_user_regs · line 2468

Quoted 1 line
xen/arch/x86/hvm/vmx/vmx.c +1 -0
+                        .inslen =

__vmread(VM_EXIT_INSTRUCTION_LEN)

Review

Quoted 4 lines
xen/arch/x86/hvm/vmx/vmx.c +0 -0
                     };
                     hvm_inject_trap(&trap);
                     break;
(quoted diff) +0 -0

b/xen/include/asm-x86/hvm/hvm.h

xen/include/asm-x86/hvm/hvm.h struct hvm_trap { · line 77

Quoted 6 lines

index 65f7e20..a3d8bf1 100644

xen/include/asm-x86/hvm/hvm.h +0 -0
@@ -76,6 +76,7 @@ struct hvm_trap {
     unsigned int  type;         /* X86_EVENTTYPE_* */
     int           error_code;   /* HVM_DELIVER_NO_ERROR_CODE

if n/a */

xen/include/asm-x86/hvm/hvm.h struct hvm_trap { · line 78

Quoted 1 line
xen/include/asm-x86/hvm/hvm.h +0 -0
     unsigned long cr2;          /* Only for TRAP_page_fault h/w

exception

xen/include/asm-x86/hvm/hvm.h struct hvm_trap { · line 80

Quoted 2 lines
xen/include/asm-x86/hvm/hvm.h +1 -0
 */
+    int           inslen;       /* Instruction length */

May I suggest using "insnlen" instead?

Jan

xen/include/asm-x86/hvm/hvm.h static inline int hvm_do_pmu_interrupt(struct · line 377

Quoted 6 lines
xen/include/asm-x86/hvm/hvm.h +0 -0
 };
 

/*

xen/include/asm-x86/hvm/hvm.h +0 -0
@@ -375,6 +376,7 @@ static inline int hvm_do_pmu_interrupt(struct
 cpu_user_regs *regs)
 #define X86_EVENTTYPE_NMI                   2    /* NMI

*/

xen/include/asm-x86/hvm/hvm.h static inline int hvm_do_pmu_interrupt(struct · line 378

Quoted 1 line
xen/include/asm-x86/hvm/hvm.h +0 -0
 #define X86_EVENTTYPE_HW_EXCEPTION          3    /* hardware

exception */

xen/include/asm-x86/hvm/hvm.h static inline int hvm_do_pmu_interrupt(struct · line 379

Quoted 1 line
xen/include/asm-x86/hvm/hvm.h +0 -0
 #define X86_EVENTTYPE_SW_INTERRUPT          4    /* software

interrupt */

xen/include/asm-x86/hvm/hvm.h static inline int hvm_do_pmu_interrupt(struct · line 380

Quoted 1 line
xen/include/asm-x86/hvm/hvm.h +1 -0
+#define X86_EVENTTYPE_PRI_SW_EXCEPTION      5    /* privileged

software exception */

xen/include/asm-x86/hvm/hvm.h static inline int hvm_do_pmu_interrupt(struct · line 381

Quoted 1 line
xen/include/asm-x86/hvm/hvm.h +0 -0
 #define X86_EVENTTYPE_SW_EXCEPTION          6    /* software

exception */

Quoted 4 lines
xen/include/asm-x86/hvm/hvm.h +0 -1
 int hvm_event_needs_reinjection(uint8_t type, uint8_t vector);
--

1.5.5

author
#5 lore raw

PATCH v2 3/4 xen: Add instruction length parameter in hypercall HVMOP_inject_trap

In reply to Xudong Hao

Add parameter inslen for hypercall HVMOP_inject_trap, supply interface used by passing instruction length from userspace.

---
 xen/arch/x86/hvm/hvm.c          |    1 +
 xen/include/public/hvm/hvm_op.h |    2 ++
 2 files changed, 3 insertions(+), 0 deletions(-)
xen/arch/x86/hvm/hvm.c +1 -0
index f3c87bc..2921e9e 100644
@@ -4290,6 +4290,7 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE(void) arg)
         else 
         {
             v->arch.hvm_vcpu.inject_trap.vector = tr.trap;
+            v->arch.hvm_vcpu.inject_trap.inslen = tr.inslen;
             v->arch.hvm_vcpu.inject_trap.error_code = tr.error_code;
             v->arch.hvm_vcpu.inject_trap.cr2 = tr.cr2;
         }
xen/include/public/hvm/hvm_op.h +2 -0
index 6a78f75..4eccc85 100644
@@ -221,6 +221,8 @@ struct xen_hvm_inject_trap {
     uint32_t trap;
     /* Error code, or -1 to skip */
     uint32_t error_code;
+    /* Intruction length */
+    uint32_t inslen;
     /* CR2 for page faults */
     uint64_aligned_t cr2;
 };
Signature · 1 line
1.5.5
#6 lore raw

Re: [PATCH v2 3/4] xen: Add instruction length parameter in hypercall HVMOP_inject_trap

Quoted 30 lines
Quoted 1 line
Quoted 1 line · Xudong Hao

Add parameter inslen for hypercall HVMOP_inject_trap, supply interface used by
passing instruction length from userspace.

---
 xen/arch/x86/hvm/hvm.c          |    1 +
 xen/include/public/hvm/hvm_op.h |    2 ++
 2 files changed, 3 insertions(+), 0 deletions(-)
xen/arch/x86/hvm/hvm.c +1 -0
index f3c87bc..2921e9e 100644
@@ -4290,6 +4290,7 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE(void) 
 arg)
         else 
         {
             v->arch.hvm_vcpu.inject_trap.vector = tr.trap;
+            v->arch.hvm_vcpu.inject_trap.inslen = tr.inslen;
             v->arch.hvm_vcpu.inject_trap.error_code = tr.error_code;
             v->arch.hvm_vcpu.inject_trap.cr2 = tr.cr2;
         }
xen/include/public/hvm/hvm_op.h +0 -0
index 6a78f75..4eccc85 100644

xen/include/public/hvm/hvm_op.h struct xen_hvm_inject_trap { · line 225

Quoted 5 lines
xen/include/public/hvm/hvm_op.h +2 -0
@@ -221,6 +221,8 @@ struct xen_hvm_inject_trap {
     uint32_t trap;
     /* Error code, or -1 to skip */
     uint32_t error_code;
+    /* Intruction length */
+    uint32_t inslen;

Just like for the other patch - to me, "insnlen" would seem more appropriate.

Jan

Quoted 5 lines
xen/include/public/hvm/hvm_op.h +0 -0
     /* CR2 for page faults */
     uint64_aligned_t cr2;
 };
Signature · 1 line
1.5.5
#7 lore raw
In reply to Xudong Hao
Quoted 6 lines · Xudong Hao

Changes from v1:
- Define new struct hvm_trap to represent information of trap, include instruction length.
- Renames hvm_inject_exception to hvm_inject_trap. Then define a couple of wrappers around that function for existing callers, so that their parameter lists actually *shrink*.

I checked in the series, except for the bit that infers trap type from within vmx_inject_trap(). Instead I plumbed through a trap-type field to dom0 toolstack, so the type can be specified by the caller.

-- Keir

Quoted 19 lines

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

PATCH 3 and PATCH 4 supply an interface for userspace to inject trap.

PATCH 1: Define new struct hvm_trap and cleanup vmx exception.

PATCH 2: Fix the mistake for debug exception(#DB), overflow exception(#OF) and INT3(#BP), INTn instruction emulation. Add inslen field in struct hvm_trap.

PATCH 3: Add parameter inslen for hypercall HVMOP_inject_trap, supply interface
used by passing instruction length from userspace.

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

#8 lore raw
Quoted 17 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]] On Behalf Of Keir Fraser
Sent: Wednesday, May 30, 2012 6:40 PM
To: Hao, Xudong; [email protected]
Cc: [email protected]; Dong, Eddie; Aravindh Puthiyaparambil; Ian Jackson
Subject: Re: [PATCH v2 0/4] XEN: fix vmx exception mistake

Quoted 6 lines · Xudong Hao

Changes from v1:
- Define new struct hvm_trap to represent information of trap, include instruction length.
- Renames hvm_inject_exception to hvm_inject_trap. Then define a couple of wrappers around that function for existing callers, so that their parameter lists actually *shrink*.

Quoted 4 lines

I checked in the series, except for the bit that infers trap type from within vmx_inject_trap(). Instead I plumbed through a trap-type field to dom0 toolstack, so the type can be specified by the caller.

Thanks, that's more clean.

The INT3 trap type should be HVMOP_TRAP_sw_exc in tools/tests/xen-access/xen-access.c.

#9 lore raw
Quoted 23 lines · Xudong
Quoted 18 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]] On Behalf Of Keir Fraser
Sent: Wednesday, May 30, 2012 6:40 PM
To: Hao, Xudong; [email protected]
Cc: [email protected]; Dong, Eddie; Aravindh Puthiyaparambil; Ian Jackson
Subject: Re: [PATCH v2 0/4] XEN: fix vmx exception mistake

Quoted 7 lines · Xudong Hao

Changes from v1:
- Define new struct hvm_trap to represent information of trap, include instruction length.
- Renames hvm_inject_exception to hvm_inject_trap. Then define a couple of wrappers around that function for existing callers, so that their
parameter
lists actually *shrink*.

Quoted 4 lines

I checked in the series, except for the bit that infers trap type from within vmx_inject_trap(). Instead I plumbed through a trap-type field to dom0 toolstack, so the type can be specified by the caller.

Quoted 4 lines

Thanks, that's more clean.

The INT3 trap type should be HVMOP_TRAP_sw_exc in
tools/tests/xen-access/xen-access.c.

Thanks I'll fix it and renam einslen -> insn_len as Jan suggested.

-- Keir

#10 lore raw

Hi, Aravindh

This series patches has be checked in xen unstable tree Cset#25424~25429(except for #25426), can you test by your case?

Thanks,
-Xudong

Quoted 44 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]] On Behalf Of Keir Fraser
Sent: Wednesday, May 30, 2012 8:21 PM
To: Hao, Xudong; [email protected]
Cc: [email protected]; Dong, Eddie; Aravindh Puthiyaparambil; Ian Jackson
Subject: Re: [PATCH v2 0/4] XEN: fix vmx exception mistake

Quoted 8 lines · Xudong
Quoted 8 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]] On Behalf Of Keir Fraser
Sent: Wednesday, May 30, 2012 6:40 PM
To: Hao, Xudong; [email protected]
Cc: [email protected]; Dong, Eddie; Aravindh Puthiyaparambil; Ian Jackson
Subject: Re: [PATCH v2 0/4] XEN: fix vmx exception mistake

Quoted 6 lines
Quoted 6 lines · Xudong Hao
Quoted 5 lines

Changes from v1:
- Define new struct hvm_trap to represent information of trap, include instruction length.
- Renames hvm_inject_exception to hvm_inject_trap. Then define a couple

of

Quoted 9 lines
Quoted 8 lines
Quoted 3 lines

wrappers around that function for existing callers, so that their
parameter
lists actually *shrink*.

I checked in the series, except for the bit that infers trap type from within vmx_inject_trap(). Instead I plumbed through a trap-type field to dom0 toolstack, so the type can be specified by the caller.

Quoted 4 lines

Thanks, that's more clean.

The INT3 trap type should be HVMOP_TRAP_sw_exc in
tools/tests/xen-access/xen-access.c.

Thanks I'll fix it and renam einslen -> insn_len as Jan suggested.

-- Keir

#11 lore raw
Quoted 3 lines · Xudong

Hi, Aravindh

This series patches has be checked in xen unstable tree Cset#25424~25429(except for #25426), can you test by your case?

I ran my tests (injecting software interrupts and hardware exceptions) and they all passed.

Thanks,
Aravindh

Quoted 45 lines
Quoted 44 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]] On Behalf Of Keir Fraser
Sent: Wednesday, May 30, 2012 8:21 PM
To: Hao, Xudong; [email protected]
Cc: [email protected]; Dong, Eddie; Aravindh Puthiyaparambil; Ian Jackson
Subject: Re: [PATCH v2 0/4] XEN: fix vmx exception mistake

Quoted 8 lines · Xudong
Quoted 8 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]] On Behalf Of Keir Fraser
Sent: Wednesday, May 30, 2012 6:40 PM
To: Hao, Xudong; [email protected]
Cc: [email protected]; Dong, Eddie; Aravindh Puthiyaparambil; Ian Jackson
Subject: Re: [PATCH v2 0/4] XEN: fix vmx exception mistake

Quoted 6 lines
Quoted 6 lines · Xudong Hao
Quoted 5 lines

Changes from v1:
- Define new struct hvm_trap to represent information of trap, include instruction length.
- Renames hvm_inject_exception to hvm_inject_trap. Then define a couple

of

Quoted 9 lines
Quoted 8 lines
Quoted 3 lines

  wrappers around that function for existing callers, so that their parameter
  lists actually *shrink*.

I checked in the series, except for the bit that infers trap type from within vmx_inject_trap(). Instead I plumbed through a trap-type field to dom0 toolstack, so the type can be specified by the caller.

Quoted 4 lines

Thanks, that's more clean.

The INT3 trap type should be HVMOP_TRAP_sw_exc in
tools/tests/xen-access/xen-access.c.

Thanks I'll fix it and renam einslen -> insn_len as Jan suggested.

 -- Keir

#12 lore raw
Quoted 10 lines

-----Original Message-----
From: Aravindh Puthiyaparambil [mailto:[email protected]]
Sent: Friday, June 01, 2012 7:22 AM
To: Hao, Xudong
Cc: [email protected]; Dong, Eddie; Ian Jackson; Keir Fraser; [email protected]; Zhang, Xiantao
Subject: Re: [PATCH v2 0/4] XEN: fix vmx exception mistake

On Wed, May 30, 2012 at 7:00 PM, Hao, Xudong <[email protected]> wrote:

Quoted 8 lines
Quoted 3 lines

Hi, Aravindh

This series patches has be checked in xen unstable tree

Cset#25424~25429(except for #25426), can you test by your case?

I ran my tests (injecting software interrupts and hardware exceptions) and they all passed.

That's good, thanks for testing.

Quoted 49 lines

Thanks,
Aravindh

Quoted 18 lines
Quoted 18 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]] On Behalf Of Keir Fraser
Sent: Wednesday, May 30, 2012 8:21 PM
To: Hao, Xudong; [email protected]
Cc: [email protected]; Dong, Eddie; Aravindh Puthiyaparambil; Ian Jackson
Subject: Re: [PATCH v2 0/4] XEN: fix vmx exception mistake

Quoted 8 lines · Xudong
Quoted 8 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]] On Behalf Of Keir Fraser
Sent: Wednesday, May 30, 2012 6:40 PM
To: Hao, Xudong; [email protected]
Cc: [email protected]; Dong, Eddie; Aravindh Puthiyaparambil; Ian Jackson
Subject: Re: [PATCH v2 0/4] XEN: fix vmx exception mistake

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Xudong Hao
Quoted 5 lines

Changes from v1:
- Define new struct hvm_trap to represent information of trap, include instruction length.
- Renames hvm_inject_exception to hvm_inject_trap. Then define a

couple

Quoted 21 lines
Quoted 20 lines

of

Quoted 9 lines
Quoted 8 lines
Quoted 3 lines

  wrappers around that function for existing callers, so that their parameter
  lists actually *shrink*.

I checked in the series, except for the bit that infers trap type from within vmx_inject_trap(). Instead I plumbed through a trap-type field to dom0 toolstack, so the type can be specified by the caller.

Quoted 4 lines

Thanks, that's more clean.

The INT3 trap type should be HVMOP_TRAP_sw_exc in
tools/tests/xen-access/xen-access.c.

Thanks I'll fix it and renam einslen -> insn_len as Jan suggested.

 -- Keir