ia64/xen-unstable

changeset 15675:66147ca8f9c4

hvm: Define common (across VMX and SVM) set of event types.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Jul 31 10:11:47 2007 +0100 (2007-07-31)
parents 9174a8cfb578
children 66055f773d19
files xen/arch/x86/hvm/svm/intr.c xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/vmx/intr.c xen/arch/x86/hvm/vmx/vmx.c xen/include/asm-x86/hvm/hvm.h xen/include/asm-x86/hvm/svm/vmcb.h xen/include/asm-x86/hvm/vmx/vmx.h
line diff
     1.1 --- a/xen/arch/x86/hvm/svm/intr.c	Tue Jul 31 09:47:11 2007 +0100
     1.2 +++ b/xen/arch/x86/hvm/svm/intr.c	Tue Jul 31 10:11:47 2007 +0100
     1.3 @@ -58,7 +58,7 @@ static void svm_inject_nmi(struct vcpu *
     1.4  
     1.5      event.bytes = 0;
     1.6      event.fields.v = 1;
     1.7 -    event.fields.type = EVENTTYPE_NMI;
     1.8 +    event.fields.type = X86_EVENTTYPE_NMI;
     1.9      event.fields.vector = 2;
    1.10  
    1.11      ASSERT(vmcb->eventinj.fields.v == 0);
    1.12 @@ -72,7 +72,7 @@ static void svm_inject_extint(struct vcp
    1.13  
    1.14      event.bytes = 0;
    1.15      event.fields.v = 1;
    1.16 -    event.fields.type = EVENTTYPE_INTR;
    1.17 +    event.fields.type = X86_EVENTTYPE_EXT_INTR;
    1.18      event.fields.vector = vector;
    1.19  
    1.20      ASSERT(vmcb->eventinj.fields.v == 0);
     2.1 --- a/xen/arch/x86/hvm/svm/svm.c	Tue Jul 31 09:47:11 2007 +0100
     2.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Tue Jul 31 10:11:47 2007 +0100
     2.3 @@ -71,8 +71,8 @@ static void *root_vmcb[NR_CPUS] __read_m
     2.4  /* hardware assisted paging bits */
     2.5  extern int opt_hap_enabled;
     2.6  
     2.7 -static void svm_inject_exception(struct vcpu *v, int trap, 
     2.8 -                                        int ev, int error_code)
     2.9 +static void svm_inject_exception(
    2.10 +    struct vcpu *v, int trap, int ev, int error_code)
    2.11  {
    2.12      eventinj_t event;
    2.13      struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
    2.14 @@ -84,7 +84,7 @@ static void svm_inject_exception(struct 
    2.15  
    2.16      event.bytes = 0;            
    2.17      event.fields.v = 1;
    2.18 -    event.fields.type = EVENTTYPE_EXCEPTION;
    2.19 +    event.fields.type = X86_EVENTTYPE_HW_EXCEPTION;
    2.20      event.fields.vector = trap;
    2.21      event.fields.ev = ev;
    2.22      event.fields.errorcode = error_code;
     3.1 --- a/xen/arch/x86/hvm/vmx/intr.c	Tue Jul 31 09:47:11 2007 +0100
     3.2 +++ b/xen/arch/x86/hvm/vmx/intr.c	Tue Jul 31 10:11:47 2007 +0100
     3.3 @@ -175,7 +175,8 @@ asmlinkage void vmx_intr_assist(void)
     3.4               * Clear NMI-blocking interruptibility info if an NMI delivery
     3.5               * faulted. Re-delivery will re-set it (see SDM 3B 25.7.1.2).
     3.6               */
     3.7 -            if ( (idtv_info_field&INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_NMI )
     3.8 +            if ( (idtv_info_field&INTR_INFO_INTR_TYPE_MASK) ==
     3.9 +                 (X86_EVENTTYPE_NMI << 8) )
    3.10                  __vmwrite(GUEST_INTERRUPTIBILITY_INFO,
    3.11                            __vmread(GUEST_INTERRUPTIBILITY_INFO) &
    3.12                            ~VMX_INTR_SHADOW_NMI);
     4.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Tue Jul 31 09:47:11 2007 +0100
     4.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Tue Jul 31 10:11:47 2007 +0100
     4.3 @@ -2965,7 +2965,8 @@ asmlinkage void vmx_vmexit_handler(struc
     4.4              vmx_inject_hw_exception(v, TRAP_page_fault, regs->error_code);
     4.5              break;
     4.6          case TRAP_nmi:
     4.7 -            if ( (intr_info & INTR_INFO_INTR_TYPE_MASK) != INTR_TYPE_NMI )
     4.8 +            if ( (intr_info & INTR_INFO_INTR_TYPE_MASK) !=
     4.9 +                 (X86_EVENTTYPE_NMI << 8) )
    4.10                  goto exit_and_crash;
    4.11              HVMTRACE_0D(NMI, v);
    4.12              vmx_store_cpu_guest_regs(v, regs, NULL);
     5.1 --- a/xen/include/asm-x86/hvm/hvm.h	Tue Jul 31 09:47:11 2007 +0100
     5.2 +++ b/xen/include/asm-x86/hvm/hvm.h	Tue Jul 31 10:11:47 2007 +0100
     5.3 @@ -323,6 +323,17 @@ static inline int hvm_event_injection_fa
     5.4  /* These exceptions must always be intercepted. */
     5.5  #define HVM_TRAP_MASK (1U << TRAP_machine_check)
     5.6  
     5.7 +/*
     5.8 + * x86 event types. This enumeration is valid for:
     5.9 + *  Intel VMX: {VM_ENTRY,VM_EXIT,IDT_VECTORING}_INTR_INFO[10:8]
    5.10 + *  AMD SVM: eventinj[10:8] and exitintinfo[10:8] (types 0-4 only)
    5.11 + */
    5.12 +#define X86_EVENTTYPE_EXT_INTR              0    /* external interrupt */
    5.13 +#define X86_EVENTTYPE_NMI                   2    /* NMI                */
    5.14 +#define X86_EVENTTYPE_HW_EXCEPTION          3    /* hardware exception */
    5.15 +#define X86_EVENTTYPE_SW_INTERRUPT          4    /* software interrupt */
    5.16 +#define X86_EVENTTYPE_SW_EXCEPTION          6    /* software exception */
    5.17 +
    5.18  static inline int hvm_cpu_up(void)
    5.19  {
    5.20      if ( hvm_funcs.cpu_up )
     6.1 --- a/xen/include/asm-x86/hvm/svm/vmcb.h	Tue Jul 31 09:47:11 2007 +0100
     6.2 +++ b/xen/include/asm-x86/hvm/svm/vmcb.h	Tue Jul 31 10:11:47 2007 +0100
     6.3 @@ -320,14 +320,6 @@ typedef union
     6.4      } fields;
     6.5  } __attribute__ ((packed)) eventinj_t;
     6.6  
     6.7 -enum EVENTTYPES
     6.8 -{
     6.9 -    EVENTTYPE_INTR = 0,
    6.10 -    EVENTTYPE_NMI = 2,
    6.11 -    EVENTTYPE_EXCEPTION = 3,
    6.12 -    EVENTTYPE_SWINT = 4,
    6.13 -};
    6.14 -
    6.15  typedef union 
    6.16  {
    6.17      u64 bytes;
     7.1 --- a/xen/include/asm-x86/hvm/vmx/vmx.h	Tue Jul 31 09:47:11 2007 +0100
     7.2 +++ b/xen/include/asm-x86/hvm/vmx/vmx.h	Tue Jul 31 10:11:47 2007 +0100
     7.3 @@ -94,11 +94,6 @@ void vmx_vlapic_msr_changed(struct vcpu 
     7.4  #define INTR_INFO_VALID_MASK            0x80000000      /* 31 */
     7.5  #define INTR_INFO_RESVD_BITS_MASK       0x7ffff000
     7.6  
     7.7 -#define INTR_TYPE_EXT_INTR              (0 << 8)    /* external interrupt */
     7.8 -#define INTR_TYPE_NMI                   (2 << 8)    /* NMI                */
     7.9 -#define INTR_TYPE_HW_EXCEPTION          (3 << 8)    /* hardware exception */
    7.10 -#define INTR_TYPE_SW_EXCEPTION          (6 << 8)    /* software exception */
    7.11 -
    7.12  /*
    7.13   * Exit Qualifications for MOV for Control Register Access
    7.14   */
    7.15 @@ -276,7 +271,7 @@ static inline void __vmx_inject_exceptio
    7.16       *   VM entry]", PRM Vol. 3, 22.6.1 (Interruptibility State).
    7.17       */
    7.18  
    7.19 -    intr_fields = (INTR_INFO_VALID_MASK | type | trap);
    7.20 +    intr_fields = (INTR_INFO_VALID_MASK | (type<<8) | trap);
    7.21      if ( error_code != VMX_DELIVER_NO_ERROR_CODE ) {
    7.22          __vmwrite(VM_ENTRY_EXCEPTION_ERROR_CODE, error_code);
    7.23          intr_fields |= INTR_INFO_DELIVER_CODE_MASK;
    7.24 @@ -294,18 +289,18 @@ static inline void vmx_inject_hw_excepti
    7.25      struct vcpu *v, int trap, int error_code)
    7.26  {
    7.27      v->arch.hvm_vmx.vector_injected = 1;
    7.28 -    __vmx_inject_exception(v, trap, INTR_TYPE_HW_EXCEPTION, error_code);
    7.29 +    __vmx_inject_exception(v, trap, X86_EVENTTYPE_HW_EXCEPTION, error_code);
    7.30  }
    7.31  
    7.32  static inline void vmx_inject_extint(struct vcpu *v, int trap)
    7.33  {
    7.34 -    __vmx_inject_exception(v, trap, INTR_TYPE_EXT_INTR,
    7.35 +    __vmx_inject_exception(v, trap, X86_EVENTTYPE_EXT_INTR,
    7.36                             VMX_DELIVER_NO_ERROR_CODE);
    7.37  }
    7.38  
    7.39  static inline void vmx_inject_nmi(struct vcpu *v)
    7.40  {
    7.41 -    __vmx_inject_exception(v, 2, INTR_TYPE_NMI,
    7.42 +    __vmx_inject_exception(v, 2, X86_EVENTTYPE_NMI,
    7.43                             VMX_DELIVER_NO_ERROR_CODE);
    7.44  }
    7.45