From: Keir Fraser Subject: Re: [PATCH] MP interrupt delivery fix for xen-3.4 Date: Fri, 14 Jan 2011 12:24:20 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: George Dunlap Cc: xen-devel@lists.xensource.com, IWAMOTO Toshihiro List-Id: xen-devel@lists.xenproject.org Sure, if someone we deem competent wants to step up, that'd be absolutely fine. -- Keir On 14/01/2011 12:13, "George Dunlap" wrote: > Would it be reasonable to ask if anyone is willing to step up as a > "legacy/stable maintainer"? Given that 3.4 is still in the > just-released Citrix product, it's hardly at the end of its life yet. > :-) >=20 > -George >=20 > On Thu, Jan 13, 2011 at 12:33 PM, Keir Fraser wrote: >> On 13/01/2011 05:19, "IWAMOTO Toshihiro" wrote: >>=20 >>> Please backport the following xen-4.0-testing.hg changesets to >>> xen-3.4. =A0They are necessary for kexec/kdump to work on MP guests. >>> Backporting is mostly obvious but the changeset =A019691:c4b2a3c9a61a, >>> which is slightly different from 19912:721c14d7f60b, will cause a >>> conflict. >>=20 >> I no longer maintain 3.4 and I'm not accepting patches to it. >>=20 >> =A0-- Keir >>=20 >>> A combined diff which is ready to be applyed on xen-3.4-testing.hg is >>> also attached. >>>=20 >>> changeset: =A0 19877:80839a223746 >>> user: =A0 =A0 =A0 =A0Keir Fraser >>> date: =A0 =A0 =A0 =A0Wed Jul 01 20:22:29 2009 +0100 >>> files: =A0 =A0 =A0 tools/firmware/hvmloader/hvmloader.c >>> tools/firmware/hvmloader/mp_tables.c xen/arch/x86/hvm/vioapic.c >>> xen/arch/x86/hvm/vlapic.c xen/arch/x86/hvm/vpic.c >>> xen/include/asm-x86/hvm/domain.h xen/include/asm-x86/hvm/vlapic.h >>> description: >>> x86 hvm: Allow delivery of legacy 8259 interrupts to VCPUs !=3D 0. >>>=20 >>> changeset: =A0 19906:2fadef1b008f >>> user: =A0 =A0 =A0 =A0Keir Fraser >>> date: =A0 =A0 =A0 =A0Tue Jul 07 14:08:47 2009 +0100 >>> files: =A0 =A0 =A0 xen/arch/x86/hvm/hpet.c xen/include/asm-x86/hvm/vpt.h >>> description: >>> x86,hvm: cleanup hpet.c vcpu handling same as i8254.c/rtc.c >>>=20 >>> - introduce macros: domain_vhpet, vcpu_vhpet, vhpet_domain, vhpet_vcpu >>> - remove *vcpu field from struct HPETState >>> - modify guest_time_hpet() takes *vhpet instead of *vcpu as 1st >>> - argument >>>=20 >>> changeset: =A0 19907:a29bb4efff00 >>> user: =A0 =A0 =A0 =A0Keir Fraser >>> date: =A0 =A0 =A0 =A0Tue Jul 07 14:21:16 2009 +0100 >>> files: =A0 =A0 =A0 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 >>> description: >>> x86,hvm: Allow delivery of timer interrupts to VCPUs !=3D 0 >>>=20 >>> This patch is needed for kexec/kdump since VCPU#0 is halted. >>>=20 >>> changeset: =A0 19912:721c14d7f60b >>> user: =A0 =A0 =A0 =A0Keir Fraser >>> date: =A0 =A0 =A0 =A0Wed Jul 08 14:22:00 2009 +0100 >>> files: =A0 =A0 =A0 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/include/asm-x86/hvm/vlapic.h >>> description: >>> x86 hvm: Use 'x' as parameter name for macros converting between >>> {vcpu,domain} and {vlapic,vpic,vrtc,hpet}. Completely avoids >>> accidental aliasing. >>>=20 >>>=20 >>>=20 >>> diff -r 14709d196e43 tools/firmware/hvmloader/hvmloader.c >>> --- a/tools/firmware/hvmloader/hvmloader.c Wed Jun 30 18:26:13 2010 +01= 00 >>> +++ b/tools/firmware/hvmloader/hvmloader.c Thu Jan 13 14:17:37 2011 +09= 00 >>> @@ -141,13 +141,17 @@ >>>=20 >>> =A0static void apic_setup(void) >>> =A0{ >>> - =A0 =A0/* Set the IOAPIC ID to tha static value used in the MP/ACPI table= s. */ >>> + =A0 =A0/* Set the IOAPIC ID to the static value used in the MP/ACPI table= s. */ >>> =A0 =A0 =A0ioapic_write(0x00, IOAPIC_ID); >>>=20 >>> - =A0 =A0/* Set up Virtual Wire mode. */ >>> + =A0 =A0/* NMIs are delivered direct to the BSP. */ >>> =A0 =A0 =A0lapic_write(APIC_SPIV, APIC_SPIV_APIC_ENABLED | 0xFF); >>> - =A0 =A0lapic_write(APIC_LVT0, APIC_MODE_EXTINT << 8); >>> - =A0 =A0lapic_write(APIC_LVT1, APIC_MODE_NMI =A0 =A0<< 8); >>> + =A0 =A0lapic_write(APIC_LVT0, (APIC_MODE_EXTINT << 8) | APIC_LVT_MASKED); >>> + =A0 =A0lapic_write(APIC_LVT1, APIC_MODE_NMI << 8); >>> + >>> + =A0 =A0/* 8259A ExtInts are delivered through IOAPIC pin 0 (Virtual Wire >>> Mode). >>> */ >>> + =A0 =A0ioapic_write(0x10, APIC_DM_EXTINT); >>> + =A0 =A0ioapic_write(0x11, SET_APIC_ID(LAPIC_ID(0))); >>> =A0} >>>=20 >>> =A0static void pci_setup(void) >>> diff -r 14709d196e43 tools/firmware/hvmloader/mp_tables.c >>> --- a/tools/firmware/hvmloader/mp_tables.c Wed Jun 30 18:26:13 2010 +01= 00 >>> +++ b/tools/firmware/hvmloader/mp_tables.c Thu Jan 13 14:17:37 2011 +09= 00 >>> @@ -233,21 +233,6 @@ >>> =A0} >>>=20 >>>=20 >>> -/* fills in an IO interrupt entry for IOAPIC 'ioapic_id' */ >>> -static void fill_mp_io_intr_entry( >>> - =A0 =A0struct mp_io_intr_entry *mpiie, >>> - =A0 =A0int src_bus_id, int src_bus_irq, int ioapic_id, int dst_ioapic_int= in) >>> -{ >>> - =A0 =A0mpiie->type =3D ENTRY_TYPE_IO_INTR; >>> - =A0 =A0mpiie->intr_type =3D INTR_TYPE_INT; >>> - =A0 =A0mpiie->io_intr_flags =3D (PCI_ISA_IRQ_MASK & (1U<>> 0x0; >>> - =A0 =A0mpiie->src_bus_id =3D src_bus_id; >>> - =A0 =A0mpiie->src_bus_irq =3D src_bus_irq; >>> - =A0 =A0mpiie->dst_ioapic_id =3D ioapic_id; >>> - =A0 =A0mpiie->dst_ioapic_intin =3D dst_ioapic_intin; >>> -} >>> - >>> - >>> =A0/* fill in the mp floating processor structure */ >>> =A0static void fill_mpfps(struct mp_floating_pointer_struct *mpfps, uint3= 2_t >>> mpct) >>> =A0{ >>> @@ -316,6 +301,7 @@ >>> =A0 =A0 =A0void *mp_table_base; >>> =A0 =A0 =A0char *p; >>> =A0 =A0 =A0int vcpu_nr, i, length; >>> + =A0 =A0struct mp_io_intr_entry *mpiie; >>>=20 >>> =A0 =A0 =A0vcpu_nr =3D hvm_info->nr_vcpus; >>>=20 >>> @@ -343,12 +329,28 @@ >>> =A0 =A0 =A0fill_mp_ioapic_entry((struct mp_ioapic_entry *)p); >>> =A0 =A0 =A0p +=3D sizeof(struct mp_ioapic_entry); >>>=20 >>> + =A0 =A0/* I/O interrupt assignment: IOAPIC pin 0 is connected to 8259 Ext= Int. >>> */ >>> + =A0 =A0mpiie =3D (struct mp_io_intr_entry *)p; >>> + =A0 =A0memset(mpiie, 0, sizeof(*mpiie)); >>> + =A0 =A0mpiie->type =3D ENTRY_TYPE_IO_INTR; >>> + =A0 =A0mpiie->intr_type =3D INTR_TYPE_EXTINT; >>> + =A0 =A0mpiie->dst_ioapic_id =3D IOAPIC_ID; >>> + =A0 =A0p +=3D sizeof(*mpiie); >>> + >>> + =A0 =A0/* I/O interrupt assignment for every legacy 8259 interrupt source= . */ >>> =A0 =A0 =A0for ( i =3D 0; i < 16; i++ ) >>> =A0 =A0 =A0{ >>> - =A0 =A0 =A0 =A0if ( i =3D=3D 2 ) continue; /* skip the slave PIC connection */ >>> - =A0 =A0 =A0 =A0fill_mp_io_intr_entry((struct mp_io_intr_entry *)p, >>> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0BUS_ID_ISA, i, IOAPIC_ID, (i =3D=3D 0) ? 2 := i); >>> - =A0 =A0 =A0 =A0p +=3D sizeof(struct mp_io_intr_entry); >>> + =A0 =A0 =A0 =A0if ( i =3D=3D 2 ) >>> + =A0 =A0 =A0 =A0 =A0 =A0continue; /* skip the slave PIC connection */ >>> + =A0 =A0 =A0 =A0mpiie =3D (struct mp_io_intr_entry *)p; >>> + =A0 =A0 =A0 =A0mpiie->type =3D ENTRY_TYPE_IO_INTR; >>> + =A0 =A0 =A0 =A0mpiie->intr_type =3D INTR_TYPE_EXTINT; >>> + =A0 =A0 =A0 =A0mpiie->io_intr_flags =3D (PCI_ISA_IRQ_MASK & (1U << i)) ? 0xf : = 0x0; >>> + =A0 =A0 =A0 =A0mpiie->src_bus_id =3D BUS_ID_ISA; >>> + =A0 =A0 =A0 =A0mpiie->src_bus_irq =3D i; >>> + =A0 =A0 =A0 =A0mpiie->dst_ioapic_id =3D IOAPIC_ID; >>> + =A0 =A0 =A0 =A0mpiie->dst_ioapic_intin =3D (i =3D=3D 0) ? 2 : i; >>> + =A0 =A0 =A0 =A0p +=3D sizeof(*mpiie); >>> =A0 =A0 =A0} >>>=20 >>> =A0 =A0 =A0length =3D p - (char *)mp_table_base; >>> diff -r 14709d196e43 xen/arch/x86/hvm/hpet.c >>> --- a/xen/arch/x86/hvm/hpet.c Wed Jun 30 18:26:13 2010 +0100 >>> +++ b/xen/arch/x86/hvm/hpet.c Thu Jan 13 14:17:37 2011 +0900 >>> @@ -24,6 +24,12 @@ >>> =A0#include >>> =A0#include >>>=20 >>> +#define domain_vhpet(x) (&(x)->arch.hvm_domain.pl_time.vhpet) >>> +#define vcpu_vhpet(x) =A0 (domain_vhpet((x)->domain)) >>> +#define vhpet_domain(x) (container_of((x), struct domain, \ >>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0arch.hvm_domain.pl_time.vhpet)) >>> +#define vhpet_vcpu(x) =A0 (pt_global_vcpu_target(vhpet_domain(x))) >>> + >>> =A0#define HPET_BASE_ADDRESS =A0 0xfed00000ULL >>> =A0#define HPET_MMAP_SIZE =A0 =A0 =A01024 >>> =A0#define S_TO_NS =A01000000000ULL =A0 =A0 =A0 =A0 =A0 /* 1s =A0=3D 10^9 =A0ns */ >>> @@ -31,7 +37,8 @@ >>>=20 >>> =A0/* Frequency_of_Xen_systeme_time / frequency_of_HPET =3D 16 */ >>> =A0#define STIME_PER_HPET_TICK 16 >>> -#define guest_time_hpet(v) (hvm_get_guest_time(v) / STIME_PER_HPET_TIC= K) >>> +#define guest_time_hpet(hpet) \ >>> + =A0 =A0(hvm_get_guest_time(vhpet_vcpu(hpet)) / STIME_PER_HPET_TICK) >>>=20 >>> =A0#define HPET_ID =A0 =A0 =A0 =A0 0x000 >>> =A0#define HPET_PERIOD =A0 =A0 0x004 >>> @@ -94,7 +101,7 @@ >>> =A0 =A0 =A0ASSERT(spin_is_locked(&h->lock)); >>>=20 >>> =A0 =A0 =A0if ( hpet_enabled(h) ) >>> - =A0 =A0 =A0 =A0return guest_time_hpet(h->vcpu) + h->mc_offset; >>> + =A0 =A0 =A0 =A0return guest_time_hpet(h) + h->mc_offset; >>> =A0 =A0 =A0else >>> =A0 =A0 =A0 =A0 =A0return h->hpet.mc64; >>> =A0} >>> @@ -176,7 +183,7 @@ >>> =A0 =A0 =A0struct vcpu *v, unsigned long addr, unsigned long length, >>> =A0 =A0 =A0unsigned long *pval) >>> =A0{ >>> - =A0 =A0HPETState *h =3D &v->domain->arch.hvm_domain.pl_time.vhpet; >>> + =A0 =A0HPETState *h =3D vcpu_vhpet(v); >>> =A0 =A0 =A0unsigned long result; >>> =A0 =A0 =A0uint64_t val; >>>=20 >>> @@ -230,7 +237,7 @@ >>> =A0 =A0 =A0{ >>> =A0 =A0 =A0 =A0 =A0/* HPET specification requires PIT shouldn't generate >>> =A0 =A0 =A0 =A0 =A0 * interrupts if LegacyReplacementRoute is set for timer0 */ >>> - =A0 =A0 =A0 =A0PITState *pit =3D &h->vcpu->domain->arch.hvm_domain.pl_time.vpit= ; >>> + =A0 =A0 =A0 =A0PITState *pit =3D &vhpet_domain(h)->arch.hvm_domain.pl_time.vpit= ; >>> =A0 =A0 =A0 =A0 =A0pit_stop_channel0_irq(pit); >>> =A0 =A0 =A0} >>>=20 >>> @@ -272,7 +279,7 @@ >>> =A0 =A0 =A0 * being enabled (now). >>> =A0 =A0 =A0 */ >>> =A0 =A0 =A0oneshot =3D !timer_is_periodic(h, tn); >>> - =A0 =A0create_periodic_time(h->vcpu, &h->pt[tn], >>> + =A0 =A0create_periodic_time(vhpet_vcpu(h), &h->pt[tn], >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 hpet_tick_to_ns(h, diff), >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 oneshot ? 0 : hpet_tick_to_ns(h, >>> h->hpet.period[tn]), >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 irq, NULL, NULL); >>> @@ -290,7 +297,7 @@ >>> =A0 =A0 =A0struct vcpu *v, unsigned long addr, >>> =A0 =A0 =A0unsigned long length, unsigned long val) >>> =A0{ >>> - =A0 =A0HPETState *h =3D &v->domain->arch.hvm_domain.pl_time.vhpet; >>> + =A0 =A0HPETState *h =3D vcpu_vhpet(v); >>> =A0 =A0 =A0uint64_t old_val, new_val; >>> =A0 =A0 =A0int tn, i; >>>=20 >>> @@ -323,7 +330,7 @@ >>> =A0 =A0 =A0 =A0 =A0if ( !(old_val & HPET_CFG_ENABLE) && (new_val & HPET_CFG_ENABL= E) ) >>> =A0 =A0 =A0 =A0 =A0{ >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0/* Enable main counter and interrupt generation. */ >>> - =A0 =A0 =A0 =A0 =A0 =A0h->mc_offset =3D h->hpet.mc64 - guest_time_hpet(h->vcpu); >>> + =A0 =A0 =A0 =A0 =A0 =A0h->mc_offset =3D h->hpet.mc64 - guest_time_hpet(h); >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0for ( i =3D 0; i < HPET_TIMER_NUM; i++ ) >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0{ >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0h->hpet.comparator64[i] =3D >>> @@ -337,7 +344,7 @@ >>> =A0 =A0 =A0 =A0 =A0else if ( (old_val & HPET_CFG_ENABLE) && !(new_val & >>> HPET_CFG_ENABLE) >>> ) >>> =A0 =A0 =A0 =A0 =A0{ >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0/* Halt main counter and disable interrupt generation. */ >>> - =A0 =A0 =A0 =A0 =A0 =A0h->hpet.mc64 =3D h->mc_offset + guest_time_hpet(h->vcpu); >>> + =A0 =A0 =A0 =A0 =A0 =A0h->hpet.mc64 =3D h->mc_offset + guest_time_hpet(h); >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0for ( i =3D 0; i < HPET_TIMER_NUM; i++ ) >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if ( timer_enabled(h, i) ) >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0set_stop_timer(i); >>> @@ -487,13 +494,13 @@ >>>=20 >>> =A0static int hpet_save(struct domain *d, hvm_domain_context_t *h) >>> =A0{ >>> - =A0 =A0HPETState *hp =3D &d->arch.hvm_domain.pl_time.vhpet; >>> + =A0 =A0HPETState *hp =3D domain_vhpet(d); >>> =A0 =A0 =A0int rc; >>>=20 >>> =A0 =A0 =A0spin_lock(&hp->lock); >>>=20 >>> =A0 =A0 =A0/* Write the proper value into the main counter */ >>> - =A0 =A0hp->hpet.mc64 =3D hp->mc_offset + guest_time_hpet(hp->vcpu); >>> + =A0 =A0hp->hpet.mc64 =3D hp->mc_offset + guest_time_hpet(hp); >>>=20 >>> =A0 =A0 =A0/* Save the HPET registers */ >>> =A0 =A0 =A0rc =3D _hvm_init_entry(h, HVM_SAVE_CODE(HPET), 0, HVM_SAVE_LENGTH(HP= ET)); >>> @@ -531,7 +538,7 @@ >>>=20 >>> =A0static int hpet_load(struct domain *d, hvm_domain_context_t *h) >>> =A0{ >>> - =A0 =A0HPETState *hp =3D &d->arch.hvm_domain.pl_time.vhpet; >>> + =A0 =A0HPETState *hp =3D domain_vhpet(d); >>> =A0 =A0 =A0struct hvm_hw_hpet *rec; >>> =A0 =A0 =A0uint64_t cmp; >>> =A0 =A0 =A0int i; >>> @@ -572,7 +579,7 @@ >>> =A0#undef C >>>=20 >>> =A0 =A0 =A0/* Recalculate the offset between the main counter and guest time = */ >>> - =A0 =A0hp->mc_offset =3D hp->hpet.mc64 - guest_time_hpet(hp->vcpu); >>> + =A0 =A0hp->mc_offset =3D hp->hpet.mc64 - guest_time_hpet(hp); >>>=20 >>> =A0 =A0 =A0/* restart all timers */ >>>=20 >>> @@ -590,14 +597,13 @@ >>>=20 >>> =A0void hpet_init(struct vcpu *v) >>> =A0{ >>> - =A0 =A0HPETState *h =3D &v->domain->arch.hvm_domain.pl_time.vhpet; >>> + =A0 =A0HPETState *h =3D vcpu_vhpet(v); >>> =A0 =A0 =A0int i; >>>=20 >>> =A0 =A0 =A0memset(h, 0, sizeof(HPETState)); >>>=20 >>> =A0 =A0 =A0spin_lock_init(&h->lock); >>>=20 >>> - =A0 =A0h->vcpu =3D v; >>> =A0 =A0 =A0h->stime_freq =3D S_TO_NS; >>>=20 >>> =A0 =A0 =A0h->hpet_to_ns_scale =3D ((S_TO_NS * STIME_PER_HPET_TICK) << 10) / >>> h->stime_freq; >>> @@ -622,7 +628,7 @@ >>> =A0void hpet_deinit(struct domain *d) >>> =A0{ >>> =A0 =A0 =A0int i; >>> - =A0 =A0HPETState *h =3D &d->arch.hvm_domain.pl_time.vhpet; >>> + =A0 =A0HPETState *h =3D domain_vhpet(d); >>>=20 >>> =A0 =A0 =A0spin_lock(&h->lock); >>>=20 >>> diff -r 14709d196e43 xen/arch/x86/hvm/i8254.c >>> --- a/xen/arch/x86/hvm/i8254.c Wed Jun 30 18:26:13 2010 +0100 >>> +++ b/xen/arch/x86/hvm/i8254.c Thu Jan 13 14:17:37 2011 +0900 >>> @@ -42,7 +42,7 @@ >>> =A0#define vcpu_vpit(x) =A0 (domain_vpit((x)->domain)) >>> =A0#define vpit_domain(x) (container_of((x), struct domain, \ >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 arch.hvm_domain.pl_time.vpit)) >>> -#define vpit_vcpu(x) =A0 (vpit_domain(x)->vcpu[0]) >>> +#define vpit_vcpu(x) =A0 (pt_global_vcpu_target(vpit_domain(x))) >>>=20 >>> =A0#define RW_STATE_LSB 1 >>> =A0#define RW_STATE_MSB 2 >>> diff -r 14709d196e43 xen/arch/x86/hvm/rtc.c >>> --- a/xen/arch/x86/hvm/rtc.c Wed Jun 30 18:26:13 2010 +0100 >>> +++ b/xen/arch/x86/hvm/rtc.c Thu Jan 13 14:17:37 2011 +0900 >>> @@ -32,7 +32,7 @@ >>> =A0#define vcpu_vrtc(x) =A0 (domain_vrtc((x)->domain)) >>> =A0#define vrtc_domain(x) (container_of((x), struct domain, \ >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 arch.hvm_domain.pl_time.vrtc)) >>> -#define vrtc_vcpu(x) =A0 (vrtc_domain(x)->vcpu[0]) >>> +#define vrtc_vcpu(x) =A0 (pt_global_vcpu_target(vrtc_domain(x))) >>>=20 >>> =A0static void rtc_periodic_cb(struct vcpu *v, void *opaque) >>> =A0{ >>> diff -r 14709d196e43 xen/arch/x86/hvm/vioapic.c >>> --- a/xen/arch/x86/hvm/vioapic.c Wed Jun 30 18:26:13 2010 +0100 >>> +++ b/xen/arch/x86/hvm/vioapic.c Thu Jan 13 14:17:37 2011 +0900 >>> @@ -146,10 +146,14 @@ >>>=20 >>> =A0 =A0 =A0*pent =3D ent; >>>=20 >>> - =A0 =A0if ( (ent.fields.trig_mode =3D=3D VIOAPIC_LEVEL_TRIG) && >>> - =A0 =A0 =A0 =A0 !ent.fields.mask && >>> - =A0 =A0 =A0 =A0 !ent.fields.remote_irr && >>> - =A0 =A0 =A0 =A0 hvm_irq->gsi_assert_count[idx] ) >>> + =A0 =A0if ( idx =3D=3D 0 ) >>> + =A0 =A0{ >>> + =A0 =A0 =A0 =A0vlapic_adjust_i8259_target(d); >>> + =A0 =A0} >>> + =A0 =A0else if ( (ent.fields.trig_mode =3D=3D VIOAPIC_LEVEL_TRIG) && >>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0!ent.fields.mask && >>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0!ent.fields.remote_irr && >>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0hvm_irq->gsi_assert_count[idx] ) >>> =A0 =A0 =A0{ >>> =A0 =A0 =A0 =A0 =A0pent->fields.remote_irr =3D 1; >>> =A0 =A0 =A0 =A0 =A0vioapic_deliver(vioapic, idx); >>> @@ -159,8 +163,7 @@ >>> =A0} >>>=20 >>> =A0static void vioapic_write_indirect( >>> - =A0 =A0struct hvm_hw_vioapic *vioapic, unsigned long addr, >>> - =A0 =A0unsigned long length, unsigned long val) >>> + =A0 =A0struct hvm_hw_vioapic *vioapic, unsigned long length, unsigned lon= g >>> val) >>> =A0{ >>> =A0 =A0 =A0switch ( vioapic->ioregsel ) >>> =A0 =A0 =A0{ >>> @@ -213,7 +216,7 @@ >>> =A0 =A0 =A0 =A0 =A0break; >>>=20 >>> =A0 =A0 =A0case VIOAPIC_REG_WINDOW: >>> - =A0 =A0 =A0 =A0vioapic_write_indirect(vioapic, addr, length, val); >>> + =A0 =A0 =A0 =A0vioapic_write_indirect(vioapic, length, val); >>> =A0 =A0 =A0 =A0 =A0break; >>>=20 >>> =A0#if VIOAPIC_IS_IOSAPIC >>> diff -r 14709d196e43 xen/arch/x86/hvm/vlapic.c >>> --- a/xen/arch/x86/hvm/vlapic.c Wed Jun 30 18:26:13 2010 +0100 >>> +++ b/xen/arch/x86/hvm/vlapic.c Thu Jan 13 14:17:37 2011 +0900 >>> @@ -697,6 +697,8 @@ >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0val |=3D APIC_LVT_MASKED; >>> =A0 =A0 =A0 =A0 =A0val &=3D vlapic_lvt_mask[(offset - APIC_LVTT) >> 4]; >>> =A0 =A0 =A0 =A0 =A0vlapic_set_reg(vlapic, offset, val); >>> + =A0 =A0 =A0 =A0if ( offset =3D=3D APIC_LVT0 ) >>> + =A0 =A0 =A0 =A0 =A0 =A0vlapic_adjust_i8259_target(v->domain); >>> =A0 =A0 =A0 =A0 =A0break; >>>=20 >>> =A0 =A0 =A0case APIC_TMICT: >>> @@ -776,18 +778,46 @@ >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"apic base msr is 0x%016"PRIx64, vlapic->hw.apic_base_= msr); >>> =A0} >>>=20 >>> +static int __vlapic_accept_pic_intr(struct vcpu *v) >>> +{ >>> + =A0 =A0struct domain *d =3D v->domain; >>> + =A0 =A0struct vlapic *vlapic =3D vcpu_vlapic(v); >>> + =A0 =A0uint32_t lvt0 =3D vlapic_get_reg(vlapic, APIC_LVT0); >>> + =A0 =A0union vioapic_redir_entry redir0 =3D domain_vioapic(d)->redirtbl[0]; >>> + >>> + =A0 =A0/* We deliver 8259 interrupts to the appropriate CPU as follows. *= / >>> + =A0 =A0return ((/* IOAPIC pin0 is unmasked and routing to this LAPIC? */ >>> + =A0 =A0 =A0 =A0 =A0 =A0 ((redir0.fields.delivery_mode =3D=3D dest_ExtINT) && >>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0!redir0.fields.mask && >>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0redir0.fields.dest_id =3D=3D VLAPIC_ID(vlapic) && >>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0!vlapic_disabled(vlapic)) || >>> + =A0 =A0 =A0 =A0 =A0 =A0 /* LAPIC has LVT0 unmasked for ExtInts? */ >>> + =A0 =A0 =A0 =A0 =A0 =A0 ((lvt0 & (APIC_MODE_MASK|APIC_LVT_MASKED)) =3D=3D APIC_DM_EXT= INT) >>> || >>> + =A0 =A0 =A0 =A0 =A0 =A0 /* LAPIC is fully disabled? */ >>> + =A0 =A0 =A0 =A0 =A0 =A0 vlapic_hw_disabled(vlapic))); >>> +} >>> + >>> =A0int vlapic_accept_pic_intr(struct vcpu *v) >>> =A0{ >>> - =A0 =A0struct vlapic *vlapic =3D vcpu_vlapic(v); >>> - =A0 =A0uint32_t lvt0 =3D vlapic_get_reg(vlapic, APIC_LVT0); >>> + =A0 =A0return ((v =3D=3D v->domain->arch.hvm_domain.i8259_target) && >>> + =A0 =A0 =A0 =A0 =A0 =A0__vlapic_accept_pic_intr(v)); >>> +} >>>=20 >>> - =A0 =A0/* >>> - =A0 =A0 * Only CPU0 is wired to the 8259A. INTA cycles occur if LINT0 is = set >>> up >>> - =A0 =A0 * accept ExtInts, or if the LAPIC is disabled (so LINT0 behaves a= s >>> INTR). >>> - =A0 =A0 */ >>> - =A0 =A0return ((v->vcpu_id =3D=3D 0) && >>> - =A0 =A0 =A0 =A0 =A0 =A0(((lvt0 & (APIC_MODE_MASK|APIC_LVT_MASKED)) =3D=3D APIC_DM_EXT= INT) >>> || >>> - =A0 =A0 =A0 =A0 =A0 =A0 vlapic_hw_disabled(vlapic))); >>> +void vlapic_adjust_i8259_target(struct domain *d) >>> +{ >>> + =A0 =A0struct vcpu *v; >>> + >>> + =A0 =A0for_each_vcpu ( d, v ) >>> + =A0 =A0 =A0 =A0if ( __vlapic_accept_pic_intr(v) ) >>> + =A0 =A0 =A0 =A0 =A0 =A0goto found; >>> + >>> + =A0 =A0v =3D d->vcpu ? d->vcpu[0] : NULL; >>> + >>> + found: >>> + =A0 =A0if ( d->arch.hvm_domain.i8259_target =3D=3D v ) >>> + =A0 =A0 =A0 =A0return; >>> + =A0 =A0d->arch.hvm_domain.i8259_target =3D v; >>> + =A0 =A0pt_adjust_global_vcpu_target(v); >>> =A0} >>>=20 >>> =A0int vlapic_has_pending_irq(struct vcpu *v) >>> @@ -946,6 +976,7 @@ >>> =A0 =A0 =A0if ( hvm_load_entry(LAPIC_REGS, h, s->regs) !=3D 0 ) >>> =A0 =A0 =A0 =A0 =A0return -EINVAL; >>>=20 >>> + =A0 =A0vlapic_adjust_i8259_target(d); >>> =A0 =A0 =A0lapic_rearm(s); >>> =A0 =A0 =A0return 0; >>> =A0} >>> diff -r 14709d196e43 xen/arch/x86/hvm/vpic.c >>> --- a/xen/arch/x86/hvm/vpic.c Wed Jun 30 18:26:13 2010 +0100 >>> +++ b/xen/arch/x86/hvm/vpic.c Thu Jan 13 14:17:37 2011 +0900 >>> @@ -109,9 +109,9 @@ >>> =A0 =A0 =A0{ >>> =A0 =A0 =A0 =A0 =A0if ( vpic->is_master ) >>> =A0 =A0 =A0 =A0 =A0{ >>> - =A0 =A0 =A0 =A0 =A0 =A0/* Master INT line is connected to VCPU0's VLAPIC LVT0. */ >>> - =A0 =A0 =A0 =A0 =A0 =A0struct vcpu *v =3D vpic_domain(vpic)->vcpu[0]; >>> - =A0 =A0 =A0 =A0 =A0 =A0if ( (v !=3D NULL) && vlapic_accept_pic_intr(v) ) >>> + =A0 =A0 =A0 =A0 =A0 =A0/* Master INT line is connected in Virtual Wire Mode. */ >>> + =A0 =A0 =A0 =A0 =A0 =A0struct vcpu *v =3D >>> vpic_domain(vpic)->arch.hvm_domain.i8259_target; >>> + =A0 =A0 =A0 =A0 =A0 =A0if ( v !=3D NULL ) >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0vcpu_kick(v); >>> =A0 =A0 =A0 =A0 =A0} >>> =A0 =A0 =A0 =A0 =A0else >>> diff -r 14709d196e43 xen/arch/x86/hvm/vpt.c >>> --- a/xen/arch/x86/hvm/vpt.c Wed Jun 30 18:26:13 2010 +0100 >>> +++ b/xen/arch/x86/hvm/vpt.c Thu Jan 13 14:17:37 2011 +0900 >>> @@ -434,3 +434,53 @@ >>> =A0 =A0 =A0 */ >>> =A0 =A0 =A0kill_timer(&pt->timer); >>> =A0} >>> + >>> +static void pt_adjust_vcpu(struct periodic_time *pt, struct vcpu *v) >>> +{ >>> + =A0 =A0int on_list; >>> + >>> + =A0 =A0ASSERT(pt->source =3D=3D PTSRC_isa); >>> + >>> + =A0 =A0if ( pt->vcpu =3D=3D NULL ) >>> + =A0 =A0 =A0 =A0return; >>> + >>> + =A0 =A0pt_lock(pt); >>> + =A0 =A0on_list =3D pt->on_list; >>> + =A0 =A0if ( pt->on_list ) >>> + =A0 =A0 =A0 =A0list_del(&pt->list); >>> + =A0 =A0pt->on_list =3D 0; >>> + =A0 =A0pt_unlock(pt); >>> + >>> + =A0 =A0spin_lock(&v->arch.hvm_vcpu.tm_lock); >>> + =A0 =A0pt->vcpu =3D v; >>> + =A0 =A0if ( on_list ) >>> + =A0 =A0{ >>> + =A0 =A0 =A0 =A0pt->on_list =3D 1; >>> + =A0 =A0 =A0 =A0list_add(&pt->list, &v->arch.hvm_vcpu.tm_list); >>> + >>> + =A0 =A0 =A0 =A0migrate_timer(&pt->timer, v->processor); >>> + =A0 =A0} >>> + =A0 =A0spin_unlock(&v->arch.hvm_vcpu.tm_lock); >>> +} >>> + >>> +void pt_adjust_global_vcpu_target(struct vcpu *v) >>> +{ >>> + =A0 =A0struct pl_time *pl_time =3D &v->domain->arch.hvm_domain.pl_time; >>> + =A0 =A0int i; >>> + >>> + =A0 =A0if ( v =3D=3D NULL ) >>> + =A0 =A0 =A0 =A0return; >>> + >>> + =A0 =A0spin_lock(&pl_time->vpit.lock); >>> + =A0 =A0pt_adjust_vcpu(&pl_time->vpit.pt0, v); >>> + =A0 =A0spin_unlock(&pl_time->vpit.lock); >>> + >>> + =A0 =A0spin_lock(&pl_time->vrtc.lock); >>> + =A0 =A0pt_adjust_vcpu(&pl_time->vrtc.pt, v); >>> + =A0 =A0spin_unlock(&pl_time->vrtc.lock); >>> + >>> + =A0 =A0spin_lock(&pl_time->vhpet.lock); >>> + =A0 =A0for ( i =3D 0; i < HPET_TIMER_NUM; i++ ) >>> + =A0 =A0 =A0 =A0pt_adjust_vcpu(&pl_time->vhpet.pt[i], v); >>> + =A0 =A0spin_unlock(&pl_time->vhpet.lock); >>> +} >>> diff -r 14709d196e43 xen/include/asm-x86/hvm/domain.h >>> --- a/xen/include/asm-x86/hvm/domain.h Wed Jun 30 18:26:13 2010 +0100 >>> +++ b/xen/include/asm-x86/hvm/domain.h Thu Jan 13 14:17:37 2011 +0900 >>> @@ -56,6 +56,9 @@ >>> =A0 =A0 =A0struct hvm_vioapic =A0 =A0*vioapic; >>> =A0 =A0 =A0struct hvm_hw_stdvga =A0 stdvga; >>>=20 >>> + =A0 =A0/* VCPU which is current target for 8259 interrupts. */ >>> + =A0 =A0struct vcpu =A0 =A0 =A0 =A0 =A0 *i8259_target; >>> + >>> =A0 =A0 =A0/* hvm_print_line() logging. */ >>> =A0 =A0 =A0char =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pbuf[80]; >>> =A0 =A0 =A0int =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0pbuf_idx; >>> diff -r 14709d196e43 xen/include/asm-x86/hvm/vlapic.h >>> --- a/xen/include/asm-x86/hvm/vlapic.h Wed Jun 30 18:26:13 2010 +0100 >>> +++ b/xen/include/asm-x86/hvm/vlapic.h Thu Jan 13 14:17:37 2011 +0900 >>> @@ -92,6 +92,8 @@ >>>=20 >>> =A0int vlapic_accept_pic_intr(struct vcpu *v); >>>=20 >>> +void vlapic_adjust_i8259_target(struct domain *d); >>> + >>> =A0struct vlapic *apic_lowest_prio(struct domain *d, uint32_t bitmap); >>>=20 >>> =A0int vlapic_match_logical_addr(struct vlapic *vlapic, uint8_t mda); >>> diff -r 14709d196e43 xen/include/asm-x86/hvm/vpt.h >>> --- a/xen/include/asm-x86/hvm/vpt.h Wed Jun 30 18:26:13 2010 +0100 >>> +++ b/xen/include/asm-x86/hvm/vpt.h Thu Jan 13 14:17:37 2011 +0900 >>> @@ -92,7 +92,6 @@ >>>=20 >>> =A0typedef struct HPETState { >>> =A0 =A0 =A0struct hpet_registers hpet; >>> - =A0 =A0struct vcpu *vcpu; >>> =A0 =A0 =A0uint64_t stime_freq; >>> =A0 =A0 =A0uint64_t hpet_to_ns_scale; /* hpet ticks to ns (multiplied by 2^10= ) */ >>> =A0 =A0 =A0uint64_t hpet_to_ns_limit; /* max hpet ticks convertable to ns =A0 =A0= =A0*/ >>> @@ -145,6 +144,10 @@ >>> =A0void pt_reset(struct vcpu *v); >>> =A0void pt_migrate(struct vcpu *v); >>>=20 >>> +void pt_adjust_global_vcpu_target(struct vcpu *v); >>> +#define pt_global_vcpu_target(d) \ >>> + =A0 =A0((d)->arch.hvm_domain.i8259_target ? : (d)->vcpu ? (d)->vcpu[0] : = NULL) >>> + >>> =A0/* Is given periodic timer active? */ >>> =A0#define pt_active(pt) ((pt)->on_list) >>>=20 >>>=20 >>> _______________________________________________ >>> Xen-devel mailing list >>> Xen-devel@lists.xensource.com >>> http://lists.xensource.com/xen-devel >>=20 >>=20 >>=20 >> _______________________________________________ >> Xen-devel mailing list >> Xen-devel@lists.xensource.com >> http://lists.xensource.com/xen-devel >>=20