[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 04/15] x86/emul: Rename HVM_DELIVER_NO_ERROR_CODE to X86_EVENT_NO_EC



> -----Original Message-----
> From: Andrew Cooper [mailto:andrew.cooper3@xxxxxxxxxx]
> Sent: 23 November 2016 15:39
> To: Xen-devel <xen-devel@xxxxxxxxxxxxx>
> Cc: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>; Jan Beulich
> <JBeulich@xxxxxxxx>; Paul Durrant <Paul.Durrant@xxxxxxxxxx>; Jun
> Nakajima <jun.nakajima@xxxxxxxxx>; Kevin Tian <kevin.tian@xxxxxxxxx>;
> Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>; Suravee Suthikulpanit
> <suravee.suthikulpanit@xxxxxxx>
> Subject: [PATCH 04/15] x86/emul: Rename
> HVM_DELIVER_NO_ERROR_CODE to X86_EVENT_NO_EC
> 
> and move it to live with the other x86_event infrastructure in
> x86_emulate.h.
> Switch it and x86_event.error_code to being signed, matching the rest of the
> code.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

Reviewed-by: Paul Durrant <paul.durrant@xxxxxxxxxx>

> ---
> CC: Jan Beulich <JBeulich@xxxxxxxx>
> CC: Paul Durrant <paul.durrant@xxxxxxxxxx>
> CC: Jun Nakajima <jun.nakajima@xxxxxxxxx>
> CC: Kevin Tian <kevin.tian@xxxxxxxxx>
> CC: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
> CC: Suravee Suthikulpanit <suravee.suthikulpanit@xxxxxxx>
> ---
>  xen/arch/x86/hvm/emulate.c             |  2 +-
>  xen/arch/x86/hvm/hvm.c                 |  6 +++---
>  xen/arch/x86/hvm/nestedhvm.c           |  2 +-
>  xen/arch/x86/hvm/svm/nestedsvm.c       |  6 +++---
>  xen/arch/x86/hvm/svm/svm.c             | 22 +++++++++++-----------
>  xen/arch/x86/hvm/vmx/intr.c            |  2 +-
>  xen/arch/x86/hvm/vmx/vmx.c             | 23 ++++++++++++-----------
>  xen/arch/x86/hvm/vmx/vvmx.c            |  2 +-
>  xen/arch/x86/x86_emulate/x86_emulate.h |  3 ++-
>  xen/include/asm-x86/hvm/support.h      |  2 --
>  10 files changed, 35 insertions(+), 35 deletions(-)
> 
> diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
> index d0c3185..790e9c1 100644
> --- a/xen/arch/x86/hvm/emulate.c
> +++ b/xen/arch/x86/hvm/emulate.c
> @@ -1609,7 +1609,7 @@ static int hvmemul_inject_sw_interrupt(
> 
>      hvmemul_ctxt->exn_pending = 1;
>      hvmemul_ctxt->trap.vector = vector;
> -    hvmemul_ctxt->trap.error_code = HVM_DELIVER_NO_ERROR_CODE;
> +    hvmemul_ctxt->trap.error_code = X86_EVENT_NO_EC;
>      hvmemul_ctxt->trap.insn_len = insn_len;
> 
>      return X86EMUL_OKAY;
> diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
> index 7b434aa..b950842 100644
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -502,7 +502,7 @@ void hvm_do_resume(struct vcpu *v)
>                  kind = EMUL_KIND_SET_CONTEXT_INSN;
> 
>              hvm_emulate_one_vm_event(kind, TRAP_invalid_op,
> -                                     HVM_DELIVER_NO_ERROR_CODE);
> +                                     X86_EVENT_NO_EC);
> 
>              v->arch.vm_event->emulate_flags = 0;
>          }
> @@ -3054,7 +3054,7 @@ void hvm_task_switch(
>      }
> 
>      if ( (tss.trace & 1) && !exn_raised )
> -        hvm_inject_hw_exception(TRAP_debug,
> HVM_DELIVER_NO_ERROR_CODE);
> +        hvm_inject_hw_exception(TRAP_debug, X86_EVENT_NO_EC);
> 
>   out:
>      hvm_unmap_entry(optss_desc);
> @@ -4073,7 +4073,7 @@ void hvm_ud_intercept(struct cpu_user_regs
> *regs)
>      switch ( hvm_emulate_one(&ctxt) )
>      {
>      case X86EMUL_UNHANDLEABLE:
> -        hvm_inject_hw_exception(TRAP_invalid_op,
> HVM_DELIVER_NO_ERROR_CODE);
> +        hvm_inject_hw_exception(TRAP_invalid_op, X86_EVENT_NO_EC);
>          break;
>      case X86EMUL_EXCEPTION:
>          if ( ctxt.exn_pending )
> diff --git a/xen/arch/x86/hvm/nestedhvm.c
> b/xen/arch/x86/hvm/nestedhvm.c
> index caad525..c4671d8 100644
> --- a/xen/arch/x86/hvm/nestedhvm.c
> +++ b/xen/arch/x86/hvm/nestedhvm.c
> @@ -17,7 +17,7 @@
>   */
> 
>  #include <asm/msr.h>
> -#include <asm/hvm/support.h> /* for
> HVM_DELIVER_NO_ERROR_CODE */
> +#include <asm/hvm/support.h>
>  #include <asm/hvm/hvm.h>
>  #include <asm/p2m.h>    /* for struct p2m_domain */
>  #include <asm/hvm/nestedhvm.h>
> diff --git a/xen/arch/x86/hvm/svm/nestedsvm.c
> b/xen/arch/x86/hvm/svm/nestedsvm.c
> index b6b8526..8c9b073 100644
> --- a/xen/arch/x86/hvm/svm/nestedsvm.c
> +++ b/xen/arch/x86/hvm/svm/nestedsvm.c
> @@ -756,7 +756,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_hw_exception(TRAP_invalid_op,
> HVM_DELIVER_NO_ERROR_CODE);
> +        hvm_inject_hw_exception(TRAP_invalid_op, X86_EVENT_NO_EC);
>          /* Must happen after hvm_inject_hw_exception or it doesn't work
> right. */
>          nv->nv_vmswitch_in_progress = 0;
>          return 1;
> @@ -1581,7 +1581,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_hw_exception(TRAP_invalid_op,
> HVM_DELIVER_NO_ERROR_CODE);
> +        hvm_inject_hw_exception(TRAP_invalid_op, X86_EVENT_NO_EC);
>          return;
>      }
> 
> @@ -1601,7 +1601,7 @@ void svm_vmexit_do_clgi(struct cpu_user_regs
> *regs, struct vcpu *v)
>      vintr_t intr;
> 
>      if ( !nestedhvm_enabled(v->domain) ) {
> -        hvm_inject_hw_exception(TRAP_invalid_op,
> HVM_DELIVER_NO_ERROR_CODE);
> +        hvm_inject_hw_exception(TRAP_invalid_op, X86_EVENT_NO_EC);
>          return;
>      }
> 
> diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
> index 66eb30b..fb4fd0b 100644
> --- a/xen/arch/x86/hvm/svm/svm.c
> +++ b/xen/arch/x86/hvm/svm/svm.c
> @@ -89,7 +89,7 @@ static DEFINE_SPINLOCK(osvw_lock);
>  static void svm_crash_or_fault(struct vcpu *v)
>  {
>      if ( vmcb_get_cpl(v->arch.hvm_svm.vmcb) )
> -        hvm_inject_hw_exception(TRAP_invalid_op,
> HVM_DELIVER_NO_ERROR_CODE);
> +        hvm_inject_hw_exception(TRAP_invalid_op, X86_EVENT_NO_EC);
>      else
>          domain_crash(v->domain);
>  }
> @@ -116,7 +116,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_hw_exception(TRAP_debug,
> HVM_DELIVER_NO_ERROR_CODE);
> +        hvm_inject_hw_exception(TRAP_debug, X86_EVENT_NO_EC);
>  }
> 
>  static void svm_cpu_down(void)
> @@ -1285,7 +1285,7 @@ static void svm_inject_event(const struct
> x86_event *event)
> 
>      default:
>          eventinj.fields.type = X86_EVENTTYPE_HW_EXCEPTION;
> -        eventinj.fields.ev = (_event.error_code !=
> HVM_DELIVER_NO_ERROR_CODE);
> +        eventinj.fields.ev = (_event.error_code != X86_EVENT_NO_EC);
>          eventinj.fields.errorcode = _event.error_code;
>          break;
>      }
> @@ -1553,7 +1553,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_hw_exception(TRAP_no_device,
> HVM_DELIVER_NO_ERROR_CODE);
> +           hvm_inject_hw_exception(TRAP_no_device, X86_EVENT_NO_EC);
>         else
>             vmcb_set_cr0(n1vmcb, vmcb_get_cr0(n1vmcb) & ~X86_CR0_TS);
>         return;
> @@ -2022,14 +2022,14 @@ svm_vmexit_do_vmrun(struct cpu_user_regs
> *regs,
>      if ( !nsvm_efer_svm_enabled(v) )
>      {
>          gdprintk(XENLOG_ERR, "VMRUN: nestedhvm disabled, injecting
> #UD\n");
> -        hvm_inject_hw_exception(TRAP_invalid_op,
> HVM_DELIVER_NO_ERROR_CODE);
> +        hvm_inject_hw_exception(TRAP_invalid_op, X86_EVENT_NO_EC);
>          return;
>      }
> 
>      if ( !nestedsvm_vmcb_map(v, vmcbaddr) )
>      {
>          gdprintk(XENLOG_ERR, "VMRUN: mapping vmcb failed, injecting
> #GP\n");
> -        hvm_inject_hw_exception(TRAP_gp_fault,
> HVM_DELIVER_NO_ERROR_CODE);
> +        hvm_inject_hw_exception(TRAP_gp_fault, X86_EVENT_NO_EC);
>          return;
>      }
> 
> @@ -2101,7 +2101,7 @@ svm_vmexit_do_vmload(struct vmcb_struct
> *vmcb,
>      return;
> 
>   inject:
> -    hvm_inject_hw_exception(ret, HVM_DELIVER_NO_ERROR_CODE);
> +    hvm_inject_hw_exception(ret, X86_EVENT_NO_EC);
>      return;
>  }
> 
> @@ -2139,7 +2139,7 @@ svm_vmexit_do_vmsave(struct vmcb_struct
> *vmcb,
>      return;
> 
>   inject:
> -    hvm_inject_hw_exception(ret, HVM_DELIVER_NO_ERROR_CODE);
> +    hvm_inject_hw_exception(ret, X86_EVENT_NO_EC);
>      return;
>  }
> 
> @@ -2428,7 +2428,7 @@ void svm_vmexit_handler(struct cpu_user_regs
> *regs)
> 
>      case VMEXIT_EXCEPTION_DB:
>          if ( !v->domain->debugger_attached )
> -            hvm_inject_hw_exception(TRAP_debug,
> HVM_DELIVER_NO_ERROR_CODE);
> +            hvm_inject_hw_exception(TRAP_debug, X86_EVENT_NO_EC);
>          else
>              domain_pause_for_debugger();
>          break;
> @@ -2616,7 +2616,7 @@ void svm_vmexit_handler(struct cpu_user_regs
> *regs)
> 
>      case VMEXIT_MONITOR:
>      case VMEXIT_MWAIT:
> -        hvm_inject_hw_exception(TRAP_invalid_op,
> HVM_DELIVER_NO_ERROR_CODE);
> +        hvm_inject_hw_exception(TRAP_invalid_op, X86_EVENT_NO_EC);
>          break;
> 
>      case VMEXIT_VMRUN:
> @@ -2635,7 +2635,7 @@ void svm_vmexit_handler(struct cpu_user_regs
> *regs)
>          svm_vmexit_do_clgi(regs, v);
>          break;
>      case VMEXIT_SKINIT:
> -        hvm_inject_hw_exception(TRAP_invalid_op,
> HVM_DELIVER_NO_ERROR_CODE);
> +        hvm_inject_hw_exception(TRAP_invalid_op, X86_EVENT_NO_EC);
>          break;
> 
>      case VMEXIT_XSETBV:
> diff --git a/xen/arch/x86/hvm/vmx/intr.c b/xen/arch/x86/hvm/vmx/intr.c
> index 8fca08c..639a705 100644
> --- a/xen/arch/x86/hvm/vmx/intr.c
> +++ b/xen/arch/x86/hvm/vmx/intr.c
> @@ -302,7 +302,7 @@ void vmx_intr_assist(void)
>      }
>      else if ( intack.source == hvm_intsrc_mce )
>      {
> -        hvm_inject_hw_exception(TRAP_machine_check,
> HVM_DELIVER_NO_ERROR_CODE);
> +        hvm_inject_hw_exception(TRAP_machine_check,
> X86_EVENT_NO_EC);
>      }
>      else if ( cpu_has_vmx_virtual_intr_delivery &&
>                intack.source != hvm_intsrc_pic &&
> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
> index b1d8a0b..eb7c902 100644
> --- a/xen/arch/x86/hvm/vmx/vmx.c
> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> @@ -1646,7 +1646,8 @@ static void __vmx_inject_exception(int trap, int
> type, int error_code)
>      intr_fields = INTR_INFO_VALID_MASK |
>                    MASK_INSR(type, INTR_INFO_INTR_TYPE_MASK) |
>                    MASK_INSR(trap, INTR_INFO_VECTOR_MASK);
> -    if ( error_code != HVM_DELIVER_NO_ERROR_CODE ) {
> +    if ( error_code != X86_EVENT_NO_EC )
> +    {
>          __vmwrite(VM_ENTRY_EXCEPTION_ERROR_CODE, error_code);
>          intr_fields |= INTR_INFO_DELIVER_CODE_MASK;
>      }
> @@ -1671,12 +1672,12 @@ void vmx_inject_extint(int trap, uint8_t source)
>                 INTR_INFO_VALID_MASK |
>                 MASK_INSR(X86_EVENTTYPE_EXT_INTR,
> INTR_INFO_INTR_TYPE_MASK) |
>                 MASK_INSR(trap, INTR_INFO_VECTOR_MASK),
> -               HVM_DELIVER_NO_ERROR_CODE, source);
> +               X86_EVENT_NO_EC, source);
>              return;
>          }
>      }
>      __vmx_inject_exception(trap, X86_EVENTTYPE_EXT_INTR,
> -                           HVM_DELIVER_NO_ERROR_CODE);
> +                           X86_EVENT_NO_EC);
>  }
> 
>  void vmx_inject_nmi(void)
> @@ -1691,12 +1692,12 @@ void vmx_inject_nmi(void)
>                 INTR_INFO_VALID_MASK |
>                 MASK_INSR(X86_EVENTTYPE_NMI, INTR_INFO_INTR_TYPE_MASK) |
>                 MASK_INSR(TRAP_nmi, INTR_INFO_VECTOR_MASK),
> -               HVM_DELIVER_NO_ERROR_CODE, hvm_intsrc_nmi);
> +               X86_EVENT_NO_EC, hvm_intsrc_nmi);
>              return;
>          }
>      }
>      __vmx_inject_exception(2, X86_EVENTTYPE_NMI,
> -                           HVM_DELIVER_NO_ERROR_CODE);
> +                           X86_EVENT_NO_EC);
>  }
> 
>  /*
> @@ -2111,7 +2112,7 @@ static bool_t vmx_vcpu_emulate_ve(struct vcpu
> *v)
>      vmx_vmcs_exit(v);
> 
>      hvm_inject_hw_exception(TRAP_virtualisation,
> -                            HVM_DELIVER_NO_ERROR_CODE);
> +                            X86_EVENT_NO_EC);
> 
>   out:
>      hvm_unmap_guest_frame(veinfo, 0);
> @@ -2387,7 +2388,7 @@ void update_guest_eip(void)
>      }
> 
>      if ( regs->eflags & X86_EFLAGS_TF )
> -        hvm_inject_hw_exception(TRAP_debug,
> HVM_DELIVER_NO_ERROR_CODE);
> +        hvm_inject_hw_exception(TRAP_debug, X86_EVENT_NO_EC);
>  }
> 
>  static void vmx_fpu_dirty_intercept(void)
> @@ -3213,7 +3214,7 @@ static void vmx_propagate_intr(unsigned long intr)
>          event.error_code = tmp;
>      }
>      else
> -        event.error_code = HVM_DELIVER_NO_ERROR_CODE;
> +        event.error_code = X86_EVENT_NO_EC;
> 
>      if ( event.type >= X86_EVENTTYPE_SW_INTERRUPT )
>      {
> @@ -3770,7 +3771,7 @@ void vmx_vmexit_handler(struct cpu_user_regs
> *regs)
> 
>      case EXIT_REASON_VMFUNC:
>          if ( vmx_vmfunc_intercept(regs) != X86EMUL_OKAY )
> -            hvm_inject_hw_exception(TRAP_invalid_op,
> HVM_DELIVER_NO_ERROR_CODE);
> +            hvm_inject_hw_exception(TRAP_invalid_op, X86_EVENT_NO_EC);
>          else
>              update_guest_eip();
>          break;
> @@ -3784,7 +3785,7 @@ void vmx_vmexit_handler(struct cpu_user_regs
> *regs)
>           * as far as vmexit.
>           */
>          WARN_ON(exit_reason == EXIT_REASON_GETSEC);
> -        hvm_inject_hw_exception(TRAP_invalid_op,
> HVM_DELIVER_NO_ERROR_CODE);
> +        hvm_inject_hw_exception(TRAP_invalid_op, X86_EVENT_NO_EC);
>          break;
> 
>      case EXIT_REASON_TPR_BELOW_THRESHOLD:
> @@ -3909,7 +3910,7 @@ void vmx_vmexit_handler(struct cpu_user_regs
> *regs)
>              vmx_get_segment_register(v, x86_seg_ss, &ss);
>              if ( ss.attr.fields.dpl )
>                  hvm_inject_hw_exception(TRAP_invalid_op,
> -                                        HVM_DELIVER_NO_ERROR_CODE);
> +                                        X86_EVENT_NO_EC);
>              else
>                  domain_crash(v->domain);
>          }
> diff --git a/xen/arch/x86/hvm/vmx/vvmx.c
> b/xen/arch/x86/hvm/vmx/vvmx.c
> index b5837d4..efaf54c 100644
> --- a/xen/arch/x86/hvm/vmx/vvmx.c
> +++ b/xen/arch/x86/hvm/vmx/vvmx.c
> @@ -380,7 +380,7 @@ static int vmx_inst_check_privilege(struct
> cpu_user_regs *regs, int vmxop_check)
> 
>  invalid_op:
>      gdprintk(XENLOG_ERR, "vmx_inst_check_privilege: invalid_op\n");
> -    hvm_inject_hw_exception(TRAP_invalid_op,
> HVM_DELIVER_NO_ERROR_CODE);
> +    hvm_inject_hw_exception(TRAP_invalid_op, X86_EVENT_NO_EC);
>      return X86EMUL_EXCEPTION;
> 
>  gp_fault:
> diff --git a/xen/arch/x86/x86_emulate/x86_emulate.h
> b/xen/arch/x86/x86_emulate/x86_emulate.h
> index b0d8e6f..9df083e 100644
> --- a/xen/arch/x86/x86_emulate/x86_emulate.h
> +++ b/xen/arch/x86/x86_emulate/x86_emulate.h
> @@ -80,12 +80,13 @@ enum x86_event_type {
>      X86_EVENTTYPE_PRI_SW_EXCEPTION, /* ICEBP (F1) */
>      X86_EVENTTYPE_SW_EXCEPTION,     /* INT3 (CC), INTO (CE) */
>  };
> +#define X86_EVENT_NO_EC (-1)        /* No error code. */
> 
>  struct x86_event {
>      int16_t       vector;
>      uint8_t       type;         /* X86_EVENTTYPE_* */
>      uint8_t       insn_len;     /* Instruction length */
> -    uint32_t      error_code;   /* HVM_DELIVER_NO_ERROR_CODE if n/a */
> +    int32_t       error_code;   /* X86_EVENT_NO_EC if n/a */
>      unsigned long cr2;          /* Only for TRAP_page_fault h/w exception */
>  };
> 
> diff --git a/xen/include/asm-x86/hvm/support.h b/xen/include/asm-
> x86/hvm/support.h
> index 2984abc..9938450 100644
> --- a/xen/include/asm-x86/hvm/support.h
> +++ b/xen/include/asm-x86/hvm/support.h
> @@ -25,8 +25,6 @@
>  #include <xen/hvm/save.h>
>  #include <asm/processor.h>
> 
> -#define HVM_DELIVER_NO_ERROR_CODE  (~0U)
> -
>  #ifndef NDEBUG
>  #define DBG_LEVEL_0                 (1 << 0)
>  #define DBG_LEVEL_1                 (1 << 1)
> --
> 2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.