debuggers.hg

changeset 19945:a29bb4efff00

x86,hvm: Allow delivery of timer interrupts to VCPUs != 0

This patch is needed for kexec/kdump since VCPU#0 is halted.

Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jul 07 14:21:16 2009 +0100 (2009-07-07)
parents 2fadef1b008f
children 01ae7dc043ba
files xen/arch/x86/hvm/hpet.c xen/arch/x86/hvm/i8254.c xen/arch/x86/hvm/rtc.c xen/arch/x86/hvm/vlapic.c xen/arch/x86/hvm/vpt.c xen/include/asm-x86/hvm/vpt.h
line diff
     1.1 --- a/xen/arch/x86/hvm/hpet.c	Tue Jul 07 14:08:47 2009 +0100
     1.2 +++ b/xen/arch/x86/hvm/hpet.c	Tue Jul 07 14:21:16 2009 +0100
     1.3 @@ -28,7 +28,7 @@
     1.4  #define vcpu_vhpet(vcpu)   (domain_vhpet((vcpu)->domain))
     1.5  #define vhpet_domain(hpet) (container_of((hpet), struct domain, \
     1.6                                           arch.hvm_domain.pl_time.vhpet))
     1.7 -#define vhpet_vcpu(hpet)   (vhpet_domain(hpet)->vcpu[0])
     1.8 +#define vhpet_vcpu(hpet)   (pt_global_vcpu_target(vhpet_domain(hpet)))
     1.9  
    1.10  #define HPET_BASE_ADDRESS   0xfed00000ULL
    1.11  #define HPET_MMAP_SIZE      1024
     2.1 --- a/xen/arch/x86/hvm/i8254.c	Tue Jul 07 14:08:47 2009 +0100
     2.2 +++ b/xen/arch/x86/hvm/i8254.c	Tue Jul 07 14:21:16 2009 +0100
     2.3 @@ -42,7 +42,7 @@
     2.4  #define vcpu_vpit(vcpu)  (domain_vpit((vcpu)->domain))
     2.5  #define vpit_domain(pit) (container_of((pit), struct domain, \
     2.6                                         arch.hvm_domain.pl_time.vpit))
     2.7 -#define vpit_vcpu(pit)   (vpit_domain(pit)->vcpu[0])
     2.8 +#define vpit_vcpu(pit)   (pt_global_vcpu_target(vpit_domain(pit)))
     2.9  
    2.10  #define RW_STATE_LSB 1
    2.11  #define RW_STATE_MSB 2
     3.1 --- a/xen/arch/x86/hvm/rtc.c	Tue Jul 07 14:08:47 2009 +0100
     3.2 +++ b/xen/arch/x86/hvm/rtc.c	Tue Jul 07 14:21:16 2009 +0100
     3.3 @@ -32,7 +32,7 @@
     3.4  #define vcpu_vrtc(vcpu)  (domain_vrtc((vcpu)->domain))
     3.5  #define vrtc_domain(rtc) (container_of((rtc), struct domain, \
     3.6                                         arch.hvm_domain.pl_time.vrtc))
     3.7 -#define vrtc_vcpu(rtc)   (vrtc_domain(rtc)->vcpu[0])
     3.8 +#define vrtc_vcpu(rtc)   (pt_global_vcpu_target(vrtc_domain(rtc)))
     3.9  
    3.10  static void rtc_periodic_cb(struct vcpu *v, void *opaque)
    3.11  {
     4.1 --- a/xen/arch/x86/hvm/vlapic.c	Tue Jul 07 14:08:47 2009 +0100
     4.2 +++ b/xen/arch/x86/hvm/vlapic.c	Tue Jul 07 14:21:16 2009 +0100
     4.3 @@ -814,7 +814,10 @@ void vlapic_adjust_i8259_target(struct d
     4.4      v = d->vcpu ? d->vcpu[0] : NULL;
     4.5  
     4.6   found:
     4.7 +    if ( d->arch.hvm_domain.i8259_target == v )
     4.8 +        return;
     4.9      d->arch.hvm_domain.i8259_target = v;
    4.10 +    pt_adjust_global_vcpu_target(v);
    4.11  }
    4.12  
    4.13  int vlapic_has_pending_irq(struct vcpu *v)
     5.1 --- a/xen/arch/x86/hvm/vpt.c	Tue Jul 07 14:08:47 2009 +0100
     5.2 +++ b/xen/arch/x86/hvm/vpt.c	Tue Jul 07 14:21:16 2009 +0100
     5.3 @@ -437,3 +437,53 @@ void destroy_periodic_time(struct period
     5.4       */
     5.5      kill_timer(&pt->timer);
     5.6  }
     5.7 +
     5.8 +static void pt_adjust_vcpu(struct periodic_time *pt, struct vcpu *v)
     5.9 +{
    5.10 +    int on_list;
    5.11 +
    5.12 +    ASSERT(pt->source == PTSRC_isa);
    5.13 +
    5.14 +    if ( pt->vcpu == NULL )
    5.15 +        return;
    5.16 +
    5.17 +    pt_lock(pt);
    5.18 +    on_list = pt->on_list;
    5.19 +    if ( pt->on_list )
    5.20 +        list_del(&pt->list);
    5.21 +    pt->on_list = 0;
    5.22 +    pt_unlock(pt);
    5.23 +
    5.24 +    spin_lock(&v->arch.hvm_vcpu.tm_lock);
    5.25 +    pt->vcpu = v;
    5.26 +    if ( on_list )
    5.27 +    {
    5.28 +        pt->on_list = 1;
    5.29 +        list_add(&pt->list, &v->arch.hvm_vcpu.tm_list);
    5.30 +
    5.31 +        migrate_timer(&pt->timer, v->processor);
    5.32 +    }
    5.33 +    spin_unlock(&v->arch.hvm_vcpu.tm_lock);
    5.34 +}
    5.35 +
    5.36 +void pt_adjust_global_vcpu_target(struct vcpu *v)
    5.37 +{
    5.38 +    struct pl_time *pl_time = &v->domain->arch.hvm_domain.pl_time;
    5.39 +    int i;
    5.40 +
    5.41 +    if ( v == NULL )
    5.42 +        return;
    5.43 +
    5.44 +    spin_lock(&pl_time->vpit.lock);
    5.45 +    pt_adjust_vcpu(&pl_time->vpit.pt0, v);
    5.46 +    spin_unlock(&pl_time->vpit.lock);
    5.47 +
    5.48 +    spin_lock(&pl_time->vrtc.lock);
    5.49 +    pt_adjust_vcpu(&pl_time->vrtc.pt, v);
    5.50 +    spin_unlock(&pl_time->vrtc.lock);
    5.51 +
    5.52 +    spin_lock(&pl_time->vhpet.lock);
    5.53 +    for ( i = 0; i < HPET_TIMER_NUM; i++ )
    5.54 +        pt_adjust_vcpu(&pl_time->vhpet.pt[i], v);
    5.55 +    spin_unlock(&pl_time->vhpet.lock);
    5.56 +}
     6.1 --- a/xen/include/asm-x86/hvm/vpt.h	Tue Jul 07 14:08:47 2009 +0100
     6.2 +++ b/xen/include/asm-x86/hvm/vpt.h	Tue Jul 07 14:21:16 2009 +0100
     6.3 @@ -142,6 +142,10 @@ void pt_intr_post(struct vcpu *v, struct
     6.4  void pt_reset(struct vcpu *v);
     6.5  void pt_migrate(struct vcpu *v);
     6.6  
     6.7 +void pt_adjust_global_vcpu_target(struct vcpu *v);
     6.8 +#define pt_global_vcpu_target(d) \
     6.9 +    ((d)->arch.hvm_domain.i8259_target ? : (d)->vcpu ? (d)->vcpu[0] : NULL)
    6.10 +
    6.11  /* Is given periodic timer active? */
    6.12  #define pt_active(pt) ((pt)->on_list)
    6.13