ia64/xen-unstable

changeset 11536:33955ca54ec1

[HVM][SVM] Add cr8 intercept to/from code for SVM.
Add proper vlapic unmapping and freeing in the svm relinquish
resources.

Signed-off-by: Tom Woller <thomas.woller@amd.com>=20
author kfraser@localhost.localdomain
date Tue Sep 19 11:03:36 2006 +0100 (2006-09-19)
parents 7c6aaa106f15
children e5d29225a8d1
files xen/arch/x86/hvm/svm/svm.c
line diff
     1.1 --- a/xen/arch/x86/hvm/svm/svm.c	Tue Sep 19 11:03:12 2006 +0100
     1.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Tue Sep 19 11:03:36 2006 +0100
     1.3 @@ -56,6 +56,7 @@
     1.4  extern void do_nmi(struct cpu_user_regs *, unsigned long);
     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 send_pio_req(struct cpu_user_regs *regs, unsigned long port,
    1.10                           unsigned long count, int size, long value, int dir, int pvalid);
    1.11 @@ -896,8 +897,11 @@ static void svm_relinquish_guest_resourc
    1.12          if ( hvm_apic_support(v->domain) && (VLAPIC(v) != NULL) ) 
    1.13          {
    1.14              kill_timer( &(VLAPIC(v)->vlapic_timer) );
    1.15 +            unmap_domain_page_global(VLAPIC(v)->regs);
    1.16 +            free_domheap_page(VLAPIC(v)->regs_page);
    1.17              xfree(VLAPIC(v));
    1.18          }
    1.19 +        hvm_release_assist_channel(v);
    1.20      }
    1.21  
    1.22      kill_timer(&d->arch.hvm_domain.pl_time.periodic_tm.timer);
    1.23 @@ -1599,6 +1603,7 @@ static void mov_from_cr(int cr, int gp, 
    1.24  {
    1.25      unsigned long value = 0;
    1.26      struct vcpu *v = current;
    1.27 +    struct vlapic *vlapic = VLAPIC(v);
    1.28      struct vmcb_struct *vmcb;
    1.29  
    1.30      vmcb = v->arch.hvm_svm.vmcb;
    1.31 @@ -1625,11 +1630,8 @@ static void mov_from_cr(int cr, int gp, 
    1.32              printk( "CR4 read=%lx\n", value );
    1.33          break;
    1.34      case 8:
    1.35 -#if 0
    1.36 -        value = vmcb->m_cr8;
    1.37 -#else
    1.38 -        ASSERT(0);
    1.39 -#endif
    1.40 +        value = (unsigned long)vlapic_get_reg(vlapic, APIC_TASKPRI);
    1.41 +        value = (value & 0xF0) >> 4;
    1.42          break;
    1.43          
    1.44      default:
    1.45 @@ -1656,6 +1658,7 @@ static int mov_to_cr(int gpreg, int cr, 
    1.46      unsigned long value;
    1.47      unsigned long old_cr;
    1.48      struct vcpu *v = current;
    1.49 +    struct vlapic *vlapic = VLAPIC(v);
    1.50      struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
    1.51  
    1.52      ASSERT(vmcb);
    1.53 @@ -1802,6 +1805,13 @@ static int mov_to_cr(int gpreg, int cr, 
    1.54          break;
    1.55      }
    1.56  
    1.57 +    case 8:
    1.58 +    {
    1.59 +        vlapic_set_reg(vlapic, APIC_TASKPRI, ((value & 0x0F) << 4));
    1.60 +        vlapic_update_ppr(vlapic);
    1.61 +        break;
    1.62 +    }
    1.63 +
    1.64      default:
    1.65          printk("invalid cr: %d\n", cr);
    1.66          __hvm_bug(regs);