ia64/xen-unstable

changeset 12059:ceedd98b9afb

[HVM] vlapic: Synchronously determine PPR register value whenevr it is needed.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Oct 31 14:39:50 2006 +0000 (2006-10-31)
parents 1c506820c468
children ada9ee6ce078
files xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/vlapic.c xen/arch/x86/hvm/vmx/vmx.c xen/include/asm-x86/hvm/vlapic.h
line diff
     1.1 --- a/xen/arch/x86/hvm/svm/svm.c	Tue Oct 31 13:26:49 2006 +0000
     1.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Tue Oct 31 14:39:50 2006 +0000
     1.3 @@ -56,7 +56,6 @@
     1.4  
     1.5  extern int inst_copy_from_guest(unsigned char *buf, unsigned long guest_eip,
     1.6                                  int inst_len);
     1.7 -extern uint32_t vlapic_update_ppr(struct vlapic *vlapic);
     1.8  extern asmlinkage void do_IRQ(struct cpu_user_regs *);
     1.9  extern void svm_dump_inst(unsigned long eip);
    1.10  extern int svm_dbg_on;
    1.11 @@ -1838,7 +1837,6 @@ static int mov_to_cr(int gpreg, int cr, 
    1.12          if ( vlapic == NULL )
    1.13              break;
    1.14          vlapic_set_reg(vlapic, APIC_TASKPRI, ((value & 0x0F) << 4));
    1.15 -        vlapic_update_ppr(vlapic);
    1.16          break;
    1.17      }
    1.18  
     2.1 --- a/xen/arch/x86/hvm/vlapic.c	Tue Oct 31 13:26:49 2006 +0000
     2.2 +++ b/xen/arch/x86/hvm/vlapic.c	Tue Oct 31 14:39:50 2006 +0000
     2.3 @@ -181,26 +181,19 @@ int vlapic_find_highest_isr(struct vlapi
     2.4      return result;
     2.5  }
     2.6  
     2.7 -uint32_t vlapic_update_ppr(struct vlapic *vlapic)
     2.8 +uint32_t vlapic_get_ppr(struct vlapic *vlapic)
     2.9  {
    2.10      uint32_t tpr, isrv, ppr;
    2.11      int isr;
    2.12  
    2.13 -    tpr = vlapic_get_reg(vlapic, APIC_TASKPRI);
    2.14 -
    2.15 -    isr = vlapic_find_highest_isr(vlapic);
    2.16 +    tpr  = vlapic_get_reg(vlapic, APIC_TASKPRI);
    2.17 +    isr  = vlapic_find_highest_isr(vlapic);
    2.18 +    isrv = (isr != -1) ? isr : 0;
    2.19  
    2.20 -    if ( isr != -1 )
    2.21 -        isrv = (isr >> 4) & 0xf;   /* ditto */
    2.22 -    else
    2.23 -        isrv = 0;
    2.24 -
    2.25 -    if ( (tpr >> 4) >= isrv )
    2.26 +    if ( (tpr & 0xf0) >= (isrv & 0xf0) )
    2.27          ppr = tpr & 0xff;
    2.28      else
    2.29 -        ppr = isrv << 4;  /* low 4 bits of PPR have to be cleared */
    2.30 -
    2.31 -    vlapic_set_reg(vlapic, APIC_PROCPRI, ppr);
    2.32 +        ppr = isrv & 0xf0;
    2.33  
    2.34      HVM_DBG_LOG(DBG_LEVEL_VLAPIC_INTERRUPT,
    2.35                  "vlapic %p, ppr 0x%x, isr 0x%x, isrv 0x%x.",
    2.36 @@ -444,7 +437,6 @@ void vlapic_EOI_set(struct vlapic *vlapi
    2.37          return ;
    2.38  
    2.39      vlapic_clear_vector(vector, vlapic->regs + APIC_ISR);
    2.40 -    vlapic_update_ppr(vlapic);
    2.41  
    2.42      if ( vlapic_test_and_clear_vector(vector, vlapic->regs + APIC_TMR) )
    2.43          ioapic_update_EOI(vlapic->domain, vector);
    2.44 @@ -555,8 +547,7 @@ static void vlapic_read_aligned(struct v
    2.45  
    2.46      switch ( offset ) {
    2.47      case APIC_PROCPRI:
    2.48 -        vlapic_update_ppr(vlapic);
    2.49 -        *result = vlapic_get_reg(vlapic, offset);
    2.50 +        *result = vlapic_get_ppr(vlapic);
    2.51          break;
    2.52  
    2.53      case APIC_ARBPRI:
    2.54 @@ -683,7 +674,6 @@ static void vlapic_write(struct vcpu *v,
    2.55  
    2.56      case APIC_TASKPRI:
    2.57          vlapic_set_reg(vlapic, APIC_TASKPRI, val & 0xff);
    2.58 -        vlapic_update_ppr(vlapic);
    2.59          vlapic->flush_tpr_threshold = 1;
    2.60          break;
    2.61  
    2.62 @@ -912,7 +902,7 @@ int cpu_get_apic_interrupt(struct vcpu *
    2.63  
    2.64      highest_irr = vlapic_find_highest_irr(vlapic);
    2.65      if ( (highest_irr == -1) ||
    2.66 -         ((highest_irr & 0xF0) <= vlapic_get_reg(vlapic, APIC_PROCPRI)) )
    2.67 +         ((highest_irr & 0xF0) <= vlapic_get_ppr(vlapic)) )
    2.68          return -1;
    2.69  
    2.70      *mode = APIC_DM_FIXED;
    2.71 @@ -949,7 +939,6 @@ void vlapic_post_injection(struct vcpu *
    2.72      case APIC_DM_LOWEST:
    2.73          vlapic_set_vector(vector, vlapic->regs + APIC_ISR);
    2.74          vlapic_clear_irr(vector, vlapic);
    2.75 -        vlapic_update_ppr(vlapic);
    2.76          if ( (vector == vlapic_lvt_vector(vlapic, APIC_LVTT)) &&
    2.77               (vlapic->timer_pending_count != 0) )
    2.78          {
     3.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Tue Oct 31 13:26:49 2006 +0000
     3.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Tue Oct 31 14:39:50 2006 +0000
     3.3 @@ -47,8 +47,6 @@
     3.4  #include <asm/hvm/vlapic.h>
     3.5  #include <asm/x86_emulate.h>
     3.6  
     3.7 -extern uint32_t vlapic_update_ppr(struct vlapic *vlapic);
     3.8 -
     3.9  static DEFINE_PER_CPU(unsigned long, trace_values[5]);
    3.10  #define TRACE_VMEXIT(index,value) this_cpu(trace_values)[index]=value
    3.11  
    3.12 @@ -1808,7 +1806,6 @@ static int mov_to_cr(int gp, int cr, str
    3.13          if ( vlapic == NULL )
    3.14              break;
    3.15          vlapic_set_reg(vlapic, APIC_TASKPRI, ((value & 0x0F) << 4));
    3.16 -        vlapic_update_ppr(vlapic);
    3.17          break;
    3.18      }
    3.19      default:
    3.20 @@ -2410,7 +2407,6 @@ asmlinkage void vmx_vmexit_handler(struc
    3.21          break;
    3.22  
    3.23      case EXIT_REASON_TPR_BELOW_THRESHOLD:
    3.24 -        vlapic_update_ppr(VLAPIC(v));
    3.25          VLAPIC(v)->flush_tpr_threshold = 1;
    3.26          break;
    3.27  
     4.1 --- a/xen/include/asm-x86/hvm/vlapic.h	Tue Oct 31 13:26:49 2006 +0000
     4.2 +++ b/xen/include/asm-x86/hvm/vlapic.h	Tue Oct 31 14:39:50 2006 +0000
     4.3 @@ -81,8 +81,6 @@ int vlapic_init(struct vcpu *vc);
     4.4  
     4.5  void vlapic_msr_set(struct vlapic *vlapic, uint64_t value);
     4.6  
     4.7 -uint32_t vlapic_update_ppr(struct vlapic *vlapic);
     4.8 -
     4.9  int vlapic_accept_pic_intr(struct vcpu *v);
    4.10  
    4.11  struct vlapic *apic_round_robin(struct domain *d,