# HG changeset patch
# User Kouya Shimura <kouya@xxxxxxxxxxxxxx>
# Date 1246862381 -32400
# Node ID a0d51bbdca910b3ea25cdb8e6f533a01af332a8e
# Parent 73e220236f6e50ac8de2470e88e91b75e3c2d01f
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@xxxxxxxxxxxxxx>
diff -r 73e220236f6e -r a0d51bbdca91 xen/arch/x86/hvm/hpet.c
--- a/xen/arch/x86/hvm/hpet.c Mon Jul 06 14:54:09 2009 +0900
+++ b/xen/arch/x86/hvm/hpet.c Mon Jul 06 15:39:41 2009 +0900
@@ -28,7 +28,7 @@
#define vcpu_vhpet(vcpu) (domain_vhpet((vcpu)->domain))
#define vhpet_domain(hpet) (container_of((hpet), struct domain, \
arch.hvm_domain.pl_time.vhpet))
-#define vhpet_vcpu(hpet) (vhpet_domain(hpet)->vcpu[0])
+#define vhpet_vcpu(hpet) (pt_i8259_target(vhpet_domain(hpet)))
#define HPET_BASE_ADDRESS 0xfed00000ULL
#define HPET_MMAP_SIZE 1024
diff -r 73e220236f6e -r a0d51bbdca91 xen/arch/x86/hvm/i8254.c
--- a/xen/arch/x86/hvm/i8254.c Mon Jul 06 14:54:09 2009 +0900
+++ b/xen/arch/x86/hvm/i8254.c Mon Jul 06 15:39:41 2009 +0900
@@ -42,7 +42,7 @@
#define vcpu_vpit(vcpu) (domain_vpit((vcpu)->domain))
#define vpit_domain(pit) (container_of((pit), struct domain, \
arch.hvm_domain.pl_time.vpit))
-#define vpit_vcpu(pit) (vpit_domain(pit)->vcpu[0])
+#define vpit_vcpu(pit) (pt_i8259_target(vpit_domain(pit)))
#define RW_STATE_LSB 1
#define RW_STATE_MSB 2
diff -r 73e220236f6e -r a0d51bbdca91 xen/arch/x86/hvm/rtc.c
--- a/xen/arch/x86/hvm/rtc.c Mon Jul 06 14:54:09 2009 +0900
+++ b/xen/arch/x86/hvm/rtc.c Mon Jul 06 15:39:41 2009 +0900
@@ -32,7 +32,7 @@
#define vcpu_vrtc(vcpu) (domain_vrtc((vcpu)->domain))
#define vrtc_domain(rtc) (container_of((rtc), struct domain, \
arch.hvm_domain.pl_time.vrtc))
-#define vrtc_vcpu(rtc) (vrtc_domain(rtc)->vcpu[0])
+#define vrtc_vcpu(rtc) (pt_i8259_target(vrtc_domain(rtc)))
static void rtc_periodic_cb(struct vcpu *v, void *opaque)
{
diff -r 73e220236f6e -r a0d51bbdca91 xen/arch/x86/hvm/vlapic.c
--- a/xen/arch/x86/hvm/vlapic.c Mon Jul 06 14:54:09 2009 +0900
+++ b/xen/arch/x86/hvm/vlapic.c Mon Jul 06 15:39:41 2009 +0900
@@ -814,7 +814,11 @@ void vlapic_adjust_i8259_target(struct d
v = d->vcpu ? d->vcpu[0] : NULL;
found:
- d->arch.hvm_domain.i8259_target = v;
+ if ( d->arch.hvm_domain.i8259_target != v )
+ {
+ d->arch.hvm_domain.i8259_target = v;
+ pt_adjust_i8259_target(v);
+ }
}
int vlapic_has_pending_irq(struct vcpu *v)
diff -r 73e220236f6e -r a0d51bbdca91 xen/arch/x86/hvm/vpt.c
--- a/xen/arch/x86/hvm/vpt.c Mon Jul 06 14:54:09 2009 +0900
+++ b/xen/arch/x86/hvm/vpt.c Mon Jul 06 15:39:41 2009 +0900
@@ -437,3 +437,53 @@ void destroy_periodic_time(struct period
*/
kill_timer(&pt->timer);
}
+
+static void pt_adjust_vcpu(struct periodic_time *pt, struct vcpu *v)
+{
+ int on_list;
+
+ ASSERT(pt->source == PTSRC_isa);
+
+ if ( pt->vcpu == NULL )
+ return;
+
+ pt_lock(pt);
+ on_list = pt->on_list;
+ if ( pt->on_list )
+ list_del(&pt->list);
+ pt->on_list = 0;
+ pt_unlock(pt);
+
+ spin_lock(&v->arch.hvm_vcpu.tm_lock);
+ pt->vcpu = v;
+ if ( on_list )
+ {
+ pt->on_list = 1;
+ list_add(&pt->list, &v->arch.hvm_vcpu.tm_list);
+
+ migrate_timer(&pt->timer, v->processor);
+ }
+ spin_unlock(&v->arch.hvm_vcpu.tm_lock);
+}
+
+void pt_adjust_i8259_target(struct vcpu *v)
+{
+ struct pl_time *pl_time = &v->domain->arch.hvm_domain.pl_time;
+ int i;
+
+ if ( v == NULL )
+ return;
+
+ spin_lock(&pl_time->vpit.lock);
+ pt_adjust_vcpu(&pl_time->vpit.pt0, v);
+ spin_unlock(&pl_time->vpit.lock);
+
+ spin_lock(&pl_time->vrtc.lock);
+ pt_adjust_vcpu(&pl_time->vrtc.pt, v);
+ spin_unlock(&pl_time->vrtc.lock);
+
+ spin_lock(&pl_time->vhpet.lock);
+ for ( i = 0; i < HPET_TIMER_NUM; i++ )
+ pt_adjust_vcpu(&pl_time->vhpet.pt[i], v);
+ spin_unlock(&pl_time->vhpet.lock);
+}
diff -r 73e220236f6e -r a0d51bbdca91 xen/include/asm-x86/hvm/vpt.h
--- a/xen/include/asm-x86/hvm/vpt.h Mon Jul 06 14:54:09 2009 +0900
+++ b/xen/include/asm-x86/hvm/vpt.h Mon Jul 06 15:39:41 2009 +0900
@@ -141,6 +141,10 @@ void pt_intr_post(struct vcpu *v, struct
void pt_intr_post(struct vcpu *v, struct hvm_intack intack);
void pt_reset(struct vcpu *v);
void pt_migrate(struct vcpu *v);
+void pt_adjust_i8259_target(struct vcpu *v);
+
+#define pt_i8259_target(d) \
+ ((d)->arch.hvm_domain.i8259_target ? : (d)->vcpu[0])
/* Is given periodic timer active? */
#define pt_active(pt) ((pt)->on_list)
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|