ia64/xen-unstable

changeset 13798:588dd80b56b5

[HVM][SVM] Updated the SVM V_TPR register on MMIO writes to the VLAPIC TPR

The SVM architecture includes a virtual TPR register. This patch
updates this register on MMIO writes to the HVM Virtual APIC.

VT does not have this register as far as I know so a stub is added in
the VT code.

Signed-off-by: Travis Betak <travis.betak@amd.com>
author Travis Betak <travis.betak@amd.com>
date Wed Jan 31 19:37:44 2007 +0000 (2007-01-31)
parents b998ae45c076
children 8132bf3ddbef 7b72e2536065
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/hvm.h
line diff
     1.1 --- a/xen/arch/x86/hvm/svm/svm.c	Wed Jan 31 18:15:48 2007 +0000
     1.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Wed Jan 31 19:37:44 2007 +0000
     1.3 @@ -660,6 +660,13 @@ void svm_update_guest_cr3(struct vcpu *v
     1.4      v->arch.hvm_svm.vmcb->cr3 = v->arch.hvm_vcpu.hw_cr3; 
     1.5  }
     1.6  
     1.7 +static void svm_update_vtpr(struct vcpu *v, unsigned long value)
     1.8 +{
     1.9 +    struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
    1.10 +
    1.11 +    vmcb->vintr.fields.tpr = value & 0x0f;
    1.12 +}
    1.13 +
    1.14  unsigned long svm_get_ctrl_reg(struct vcpu *v, unsigned int num)
    1.15  {
    1.16      switch ( num )
    1.17 @@ -1048,6 +1055,8 @@ int start_svm(void)
    1.18      hvm_funcs.update_host_cr3 = svm_update_host_cr3;
    1.19      hvm_funcs.update_guest_cr3 = svm_update_guest_cr3;
    1.20      
    1.21 +    hvm_funcs.update_vtpr = svm_update_vtpr;
    1.22 +
    1.23      hvm_funcs.stts = svm_stts;
    1.24      hvm_funcs.set_tsc_offset = svm_set_tsc_offset;
    1.25  
    1.26 @@ -1939,6 +1948,7 @@ static int mov_to_cr(int gpreg, int cr, 
    1.27  
    1.28      case 8:
    1.29          vlapic_set_reg(vlapic, APIC_TASKPRI, ((value & 0x0F) << 4));
    1.30 +        vmcb->vintr.fields.tpr = value & 0x0F;
    1.31          break;
    1.32  
    1.33      default:
     2.1 --- a/xen/arch/x86/hvm/vlapic.c	Wed Jan 31 18:15:48 2007 +0000
     2.2 +++ b/xen/arch/x86/hvm/vlapic.c	Wed Jan 31 19:37:44 2007 +0000
     2.3 @@ -593,6 +593,7 @@ static void vlapic_write(struct vcpu *v,
     2.4      {
     2.5      case APIC_TASKPRI:
     2.6          vlapic_set_reg(vlapic, APIC_TASKPRI, val & 0xff);
     2.7 +        hvm_update_vtpr(v, (val >> 4) & 0x0f);
     2.8          break;
     2.9  
    2.10      case APIC_EOI:
     3.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Wed Jan 31 18:15:48 2007 +0000
     3.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Wed Jan 31 19:37:44 2007 +0000
     3.3 @@ -986,6 +986,11 @@ static void vmx_inject_exception(
     3.4          v->arch.hvm_vmx.cpu_cr2 = cr2;
     3.5  }
     3.6  
     3.7 +static void vmx_update_vtpr(struct vcpu *v, unsigned long value)
     3.8 +{
     3.9 +    /* VMX doesn't have a V_TPR field */
    3.10 +}
    3.11 +
    3.12  /* Setup HVM interfaces */
    3.13  static void vmx_setup_hvm_funcs(void)
    3.14  {
    3.15 @@ -1011,6 +1016,8 @@ static void vmx_setup_hvm_funcs(void)
    3.16      hvm_funcs.update_host_cr3 = vmx_update_host_cr3;
    3.17      hvm_funcs.update_guest_cr3 = vmx_update_guest_cr3;
    3.18  
    3.19 +    hvm_funcs.update_vtpr = vmx_update_vtpr;
    3.20 +
    3.21      hvm_funcs.stts = vmx_stts;
    3.22      hvm_funcs.set_tsc_offset = vmx_set_tsc_offset;
    3.23  
     4.1 --- a/xen/include/asm-x86/hvm/hvm.h	Wed Jan 31 18:15:48 2007 +0000
     4.2 +++ b/xen/include/asm-x86/hvm/hvm.h	Wed Jan 31 19:37:44 2007 +0000
     4.3 @@ -115,6 +115,11 @@ struct hvm_function_table {
     4.4      void (*update_guest_cr3)(struct vcpu *v);
     4.5  
     4.6      /*
     4.7 +     * Reflect the virtual APIC's value in the guest's V_TPR register
     4.8 +     */
     4.9 +    void (*update_vtpr)(struct vcpu *v, unsigned long value);
    4.10 +
    4.11 +    /*
    4.12       * Update specifics of the guest state:
    4.13       * 1) TS bit in guest cr0 
    4.14       * 2) TSC offset in guest
    4.15 @@ -203,6 +208,12 @@ hvm_update_host_cr3(struct vcpu *v)
    4.16      hvm_funcs.update_host_cr3(v);
    4.17  }
    4.18  
    4.19 +static inline void
    4.20 +hvm_update_vtpr(struct vcpu *v, unsigned long value)
    4.21 +{
    4.22 +    hvm_funcs.update_vtpr(v, value);
    4.23 +}
    4.24 +
    4.25  void hvm_update_guest_cr3(struct vcpu *v, unsigned long guest_cr3);
    4.26  
    4.27  void hvm_hypercall_page_initialise(struct domain *d,