ia64/xen-unstable

changeset 10082:b4361ae1aabc

SVM patch to cleanup guest event injection logic, remove unnecessary
event_injecting variable.

Signed-off-by: Tom Woller <thomas.woller@amd.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed May 17 23:53:01 2006 +0100 (2006-05-17)
parents 3d85f350a66a
children 0fbec6836905
files xen/arch/x86/hvm/svm/intr.c xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/svm/vmcb.c xen/include/asm-x86/hvm/svm/vmcb.h
line diff
     1.1 --- a/xen/arch/x86/hvm/svm/intr.c	Wed May 17 23:51:39 2006 +0100
     1.2 +++ b/xen/arch/x86/hvm/svm/intr.c	Wed May 17 23:53:01 2006 +0100
     1.3 @@ -132,17 +132,13 @@ asmlinkage void svm_intr_assist(void)
     1.4      ASSERT(vmcb);
     1.5  
     1.6      /* Check if an Injection is active */
     1.7 -    if (v->arch.hvm_svm.injecting_event) {
     1.8         /* Previous Interrupt delivery caused this Intercept? */
     1.9         if (vmcb->exitintinfo.fields.v && (vmcb->exitintinfo.fields.type == 0)) {
    1.10             v->arch.hvm_svm.saved_irq_vector = vmcb->exitintinfo.fields.vector;
    1.11  //           printk("Injecting PF#: saving IRQ from ExitInfo\n");
    1.12             vmcb->exitintinfo.bytes = 0;
    1.13 -
    1.14 -           /* bail out, we won't be injecting an interrupt this time */
    1.15 -           return;
    1.16 +           re_injecting = 1;
    1.17         }
    1.18 -    }
    1.19  
    1.20      /* Guest's interrputs masked? */
    1.21      rflags = vmcb->rflags;
    1.22 @@ -151,16 +147,9 @@ asmlinkage void svm_intr_assist(void)
    1.23         /* bail out, we won't be injecting an interrupt this time */
    1.24         return;
    1.25      }
    1.26 -
    1.27 -    /* Interrupt delivery caused an Intercept? */
    1.28 -    if (vmcb->exitintinfo.fields.v && (vmcb->exitintinfo.fields.type == 0)) {
    1.29 -//        printk("Re-injecting IRQ from ExitInfo\n");
    1.30 -        intr_vector = vmcb->exitintinfo.fields.vector;
    1.31 -        vmcb->exitintinfo.bytes = 0;
    1.32 -        re_injecting = 1;
    1.33 -    }
    1.34 +  
    1.35      /* Previous interrupt still pending? */
    1.36 -    else if (vmcb->vintr.fields.irq) {
    1.37 +    if (vmcb->vintr.fields.irq) {
    1.38  //        printk("Re-injecting IRQ from Vintr\n");
    1.39          intr_vector = vmcb->vintr.fields.vector;
    1.40          vmcb->vintr.bytes = 0;
     2.1 --- a/xen/arch/x86/hvm/svm/svm.c	Wed May 17 23:51:39 2006 +0100
     2.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Wed May 17 23:53:01 2006 +0100
     2.3 @@ -170,10 +170,10 @@ void asidpool_retire( struct vmcb_struct
     2.4     spin_unlock(&ASIDpool[core].asid_lock);
     2.5  }
     2.6  
     2.7 -static inline void svm_inject_exception(struct vmcb_struct *vmcb, 
     2.8 -                                        int trap, int ev, int error_code)
     2.9 +static inline void svm_inject_exception(struct vcpu *v, int trap, int ev, int error_code)
    2.10  {
    2.11      eventinj_t event;
    2.12 +    struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
    2.13  
    2.14      event.bytes = 0;            
    2.15      event.fields.v = 1;
    2.16 @@ -329,7 +329,7 @@ static inline int long_mode_do_msr_write
    2.17          if ( msr_content & ~(EFER_LME | EFER_LMA | EFER_NX | EFER_SCE) )
    2.18          {
    2.19              printk("trying to set reserved bit in EFER\n");
    2.20 -            svm_inject_exception(vmcb, TRAP_gp_fault, 1, 0);
    2.21 +            svm_inject_exception(vc, TRAP_gp_fault, 1, 0);
    2.22              return 0;
    2.23          }
    2.24  
    2.25 @@ -343,7 +343,7 @@ static inline int long_mode_do_msr_write
    2.26              {
    2.27                  printk("trying to set LME bit when "
    2.28                         "in paging mode or PAE bit is not set\n");
    2.29 -                svm_inject_exception(vmcb, TRAP_gp_fault, 1, 0);
    2.30 +                svm_inject_exception(vc, TRAP_gp_fault, 1, 0);
    2.31                  return 0;
    2.32              }
    2.33              set_bit(SVM_CPU_STATE_LME_ENABLED, &vc->arch.hvm_svm.cpu_state);
    2.34 @@ -367,7 +367,7 @@ static inline int long_mode_do_msr_write
    2.35          if (!IS_CANO_ADDRESS(msr_content))
    2.36          {
    2.37              HVM_DBG_LOG(DBG_LEVEL_1, "Not cano address of msr write\n");
    2.38 -            svm_inject_exception(vmcb, TRAP_gp_fault, 1, 0);
    2.39 +            svm_inject_exception(vc, TRAP_gp_fault, 1, 0);
    2.40          }
    2.41  
    2.42          if (regs->ecx == MSR_FS_BASE)
    2.43 @@ -900,7 +900,7 @@ static void svm_do_general_protection_fa
    2.44  
    2.45      
    2.46      /* Reflect it back into the guest */
    2.47 -    svm_inject_exception(vmcb, TRAP_gp_fault, 1, error_code);
    2.48 +    svm_inject_exception(v, TRAP_gp_fault, 1, error_code);
    2.49  }
    2.50  
    2.51  /* Reserved bits: [31:14], [12:1] */
    2.52 @@ -1191,7 +1191,7 @@ static void svm_get_prefix_info(struct v
    2.53  
    2.54  
    2.55  /* Get the address of INS/OUTS instruction */
    2.56 -static inline int svm_get_io_address(struct vmcb_struct *vmcb, 
    2.57 +static inline int svm_get_io_address(struct vcpu *v, 
    2.58  		struct cpu_user_regs *regs, unsigned int dir, 
    2.59          unsigned long *count, unsigned long *addr)
    2.60  {
    2.61 @@ -1201,6 +1201,7 @@ static inline int svm_get_io_address(str
    2.62      int                  long_mode;
    2.63      ioio_info_t          info;
    2.64      segment_selector_t  *seg = NULL;
    2.65 +    struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
    2.66  
    2.67      info.bytes = vmcb->exitinfo1;
    2.68  
    2.69 @@ -1244,7 +1245,7 @@ static inline int svm_get_io_address(str
    2.70      /* If the segment isn't present, give GP fault! */
    2.71      if (!long_mode && !seg->attributes.fields.p) 
    2.72      {
    2.73 -        svm_inject_exception(vmcb, TRAP_gp_fault, 1, seg->sel);
    2.74 +        svm_inject_exception(v, TRAP_gp_fault, 1, seg->sel);
    2.75          return 0;
    2.76      }
    2.77  
    2.78 @@ -1262,7 +1263,7 @@ static inline int svm_get_io_address(str
    2.79      if (!long_mode) {
    2.80          if (*addr > seg->limit) 
    2.81          {
    2.82 -            svm_inject_exception(vmcb, TRAP_gp_fault, 1, seg->sel);
    2.83 +            svm_inject_exception(v, TRAP_gp_fault, 1, seg->sel);
    2.84              return 0;
    2.85          } 
    2.86          else 
    2.87 @@ -1310,7 +1311,7 @@ static void svm_io_instruction(struct vc
    2.88          unsigned long addr, count;
    2.89          int sign = regs->eflags & EF_DF ? -1 : 1;
    2.90  
    2.91 -        if (!svm_get_io_address(vmcb, regs, dir, &count, &addr)) 
    2.92 +        if (!svm_get_io_address(v, regs, dir, &count, &addr)) 
    2.93          {
    2.94              /* We failed to get a valid address, so don't do the IO operation - 
    2.95               * it would just get worse if we do! Hopefully the guest is handing
    2.96 @@ -1415,7 +1416,7 @@ static int svm_set_cr0(unsigned long val
    2.97                      &v->arch.hvm_svm.cpu_state))
    2.98          {
    2.99              HVM_DBG_LOG(DBG_LEVEL_1, "Enable paging before PAE enable\n");
   2.100 -            svm_inject_exception(vmcb, TRAP_gp_fault, 1, 0);
   2.101 +            svm_inject_exception(v, TRAP_gp_fault, 1, 0);
   2.102          }
   2.103  
   2.104          if (test_bit(SVM_CPU_STATE_LME_ENABLED, &v->arch.hvm_svm.cpu_state))
   2.105 @@ -1489,7 +1490,7 @@ static int svm_set_cr0(unsigned long val
   2.106       */
   2.107      if ((value & X86_CR0_PE) == 0) {
   2.108      	if (value & X86_CR0_PG) {
   2.109 -            svm_inject_exception(vmcb, TRAP_gp_fault, 1, 0);
   2.110 +            svm_inject_exception(v, TRAP_gp_fault, 1, 0);
   2.111              return 0;
   2.112          }
   2.113  
   2.114 @@ -1736,7 +1737,7 @@ static int mov_to_cr(int gpreg, int cr, 
   2.115          } else {
   2.116              if (test_bit(SVM_CPU_STATE_LMA_ENABLED,
   2.117                           &v->arch.hvm_svm.cpu_state)) {
   2.118 -                svm_inject_exception(vmcb, TRAP_gp_fault, 1, 0);
   2.119 +                svm_inject_exception(v, TRAP_gp_fault, 1, 0);
   2.120              }
   2.121              clear_bit(SVM_CPU_STATE_PAE_ENABLED, &v->arch.hvm_svm.cpu_state);
   2.122          }
   2.123 @@ -2504,7 +2505,6 @@ asmlinkage void svm_vmexit_handler(struc
   2.124  
   2.125      exit_reason = vmcb->exitcode;
   2.126      save_svm_cpu_user_regs(v, &regs);
   2.127 -    v->arch.hvm_svm.injecting_event = 0;
   2.128  
   2.129      vmcb->tlb_control = 1;
   2.130  
   2.131 @@ -2668,7 +2668,7 @@ asmlinkage void svm_vmexit_handler(struc
   2.132          if ( test_bit(_DOMF_debugging, &v->domain->domain_flags) )
   2.133              domain_pause_for_debugger();
   2.134          else 
   2.135 -            svm_inject_exception(vmcb, TRAP_int3, 0, 0);
   2.136 +            svm_inject_exception(v, TRAP_int3, 0, 0);
   2.137  #endif
   2.138          break;
   2.139  
   2.140 @@ -2679,7 +2679,6 @@ asmlinkage void svm_vmexit_handler(struc
   2.141      case VMEXIT_EXCEPTION_GP:
   2.142          /* This should probably not be trapped in the future */
   2.143          regs.error_code = vmcb->exitinfo1;
   2.144 -        v->arch.hvm_svm.injecting_event = 1;
   2.145          svm_do_general_protection_fault(v, &regs);
   2.146          break;  
   2.147  
   2.148 @@ -2699,9 +2698,8 @@ asmlinkage void svm_vmexit_handler(struc
   2.149  //printk("PF1\n");
   2.150          if (!(error = svm_do_page_fault(va, &regs))) 
   2.151          {
   2.152 -            v->arch.hvm_svm.injecting_event = 1;
   2.153              /* Inject #PG using Interruption-Information Fields */
   2.154 -            svm_inject_exception(vmcb, TRAP_page_fault, 1, regs.error_code);
   2.155 +            svm_inject_exception(v, TRAP_page_fault, 1, regs.error_code);
   2.156  
   2.157              v->arch.hvm_svm.cpu_cr2 = va;
   2.158              vmcb->cr2 = va;
     3.1 --- a/xen/arch/x86/hvm/svm/vmcb.c	Wed May 17 23:51:39 2006 +0100
     3.2 +++ b/xen/arch/x86/hvm/svm/vmcb.c	Wed May 17 23:53:01 2006 +0100
     3.3 @@ -417,7 +417,6 @@ void svm_do_launch(struct vcpu *v)
     3.4  
     3.5      v->arch.schedule_tail = arch_svm_do_resume;
     3.6  
     3.7 -    v->arch.hvm_svm.injecting_event  = 0;
     3.8      v->arch.hvm_svm.saved_irq_vector = -1;
     3.9  
    3.10      svm_set_guest_time(v, 0);
     4.1 --- a/xen/include/asm-x86/hvm/svm/vmcb.h	Wed May 17 23:51:39 2006 +0100
     4.2 +++ b/xen/include/asm-x86/hvm/svm/vmcb.h	Wed May 17 23:53:01 2006 +0100
     4.3 @@ -440,7 +440,6 @@ struct arch_svm_struct {
     4.4      u32                 *iopm;
     4.5      u32                 *msrpm;
     4.6      u64                 vmexit_tsc; /* tsc read at #VMEXIT. for TSC_OFFSET */
     4.7 -    int                 injecting_event;
     4.8      int                 saved_irq_vector;
     4.9      u32                 launch_core;
    4.10      u32                 asid_core;