interrupt remapping in HVM guests
PATCH 1/1 interrupt remapping in HVM guests
Hi all,
this patch series implements the mechanisms needed by a PV on HVM guest to remap interrupts and MSIs into pirqs in order to receive those interrupts and MSIs as xen events.
This allows the guest to avoid any reads and writes to the emulated LAPIC.
The series consists of 4 patches, 2 patches for the hypervisor and 2 patches to qemu-xen; the changes are not interdependent.
Xen needs to export some pirq related physdev_op hypercalls to hvm guests and keep track of all the remapped interrupts, that can either be interrupts corresponding to emulated devices or passthrough devices. A new physdev_op hypercall has been added to export the number of pirq
available: considering that the guest is allowed to choose the pirq number, we can make sure the number it chooses is in the allowed range. The first patch to qemu-xen is to support MSI remapping: in order to remap an MSI into a pirq the guest enables the MSI passing 0 as vector number, in response qemu-xen reads the address and use it a pirq number for the following mapping request to xen.
Finally we avoid pirq conclicts letting xen pick the pirq number for us in qemu-xen.
The list of patches follows:
xen: interrupt remapping in HVM guests
xen: introduce PHYSDEVOP_get_nr_pirqs
qemu-xen: support PV on HVM MSI remapping
qemu-xen: qemu-xen: let xen choose the pirq number
Cheers,
Stefano Stabellini
PATCH 1/1 xen: interrupt remapping in HVM guests
This patch allows HVM guests to remap interrupts and MSIs into pirqs; once the mapping is in place the guest will receive the interrupt (or the MSI) as an event.
The interrupt to be remapped can either be an interrupt of an emulated device or an interrupt of a passthrough device and we keep track of that.
xen/arch/x86/domain.c +10 -0
@@ -490,6 +490,16 @@ int arch_domain_create(struct domain *d,if ( !IO_APIC_IRQ (i) ) d->arch.irq_pirq[i] = d->arch.pirq_irq[i] = i; + d->arch.pirq_emuirq =xmalloc_array (int, d->nr_pirqs); + d->arch.emuirq_pirq =xmalloc_array (int, nr_irqs); +if ( !d->arch.pirq_emuirq || !d->arch.emuirq_pirq ) + goto fail; +memset (d->arch.pirq_emuirq,IRQ_UNBOUND , + d->nr_pirqs *sizeof (*d->arch.pirq_emuirq)); +memset (d->arch.emuirq_pirq,IRQ_UNBOUND , + d->nr_pirqs *sizeof (*d->arch.emuirq_pirq)); + +if ( (rc =iommu_domain_init (d)) !=0 ) goto fail;
xen/arch/x86/hvm/hvm.c +34 -0
@@ -2281,6 +2281,20 @@ static long hvm_memory_op(int cmd, XEN_Greturn rc; } +static long hvm_physdev_op (int cmd,XEN_GUEST_HANDLE (void ) arg) +{ +switch ( cmd ) + { +case PHYSDEVOP_map_pirq: +case PHYSDEVOP_unmap_pirq: +case PHYSDEVOP_eoi: +case PHYSDEVOP_irq_status_query: +return do_physdev_op (cmd, arg); +default : +return -ENOSYS ; + } +} +static long hvm_vcpu_op (int cmd,int vcpuid,XEN_GUEST_HANDLE (void ) arg) {
@@ -2316,6 +2330,7 @@ static hvm_hypercall_t *hvm_hypercall32_ [ __HYPERVISOR_memory_op ] = (hvm_hypercall_t *)hvm_memory_op, [ __HYPERVISOR_grant_table_op ] = (hvm_hypercall_t *)hvm_grant_table_op, [ __HYPERVISOR_vcpu_op ] = (hvm_hypercall_t *)hvm_vcpu_op, + [ __HYPERVISOR_physdev_op ] = (hvm_hypercall_t *)hvm_physdev_op,HYPERCALL (xen_version),HYPERCALL (event_channel_op ), HYPERCALL(sched_op),
@@ -2366,10 +2381,28 @@ static long hvm_vcpu_op_compat32(return rc; } +static long hvm_physdev_op_compat32 ( +int cmd,XEN_GUEST_HANDLE (void ) arg) +{ +switch ( cmd ) + { +case PHYSDEVOP_map_pirq: +case PHYSDEVOP_unmap_pirq: +case PHYSDEVOP_eoi: +case PHYSDEVOP_irq_status_query: +return compat_physdev_op (cmd, arg); +break ; +default : +return -ENOSYS ; +break ; + } +} +static hvm_hypercall_t *hvm_hypercall64_table[NR_hypercalls] = { [ __HYPERVISOR_memory_op ] = (hvm_hypercall_t *)hvm_memory_op, [ __HYPERVISOR_grant_table_op ] = (hvm_hypercall_t *)hvm_grant_table_op, [ __HYPERVISOR_vcpu_op ] = (hvm_hypercall_t *)hvm_vcpu_op, + [ __HYPERVISOR_physdev_op ] = (hvm_hypercall_t *)hvm_physdev_op,HYPERCALL (xen_version),HYPERCALL (event_channel_op),HYPERCALL (sched_op),
@@ -2382,6 +2415,7 @@ static hvm_hypercall_t *hvm_hypercall32_ [ __HYPERVISOR_memory_op ] = (hvm_hypercall_t *)hvm_memory_op_compat32, [ __HYPERVISOR_grant_table_op ] = (hvm_hypercall_t *)hvm_grant_table_op_compat32, [ __HYPERVISOR_vcpu_op ] = (hvm_hypercall_t *)hvm_vcpu_op_compat32, + [ __HYPERVISOR_physdev_op ] = (hvm_hypercall_t *)hvm_physdev_op_compat32,HYPERCALL (xen_version),HYPERCALL (event_channel_op ), HYPERCALL(sched_op),
xen/arch/x86/hvm/irq.c +25 -10
@@ -23,9 +23,30 @@#include <xen/types.h> #include <xen/event.h> #include <xen/sched.h> +#include <xen/irq.h> #include <asm/hvm/domain.h> #include <asm/hvm/support.h> +/* Must be called with hvm_domain->irq_lock hold */ +static void assert_irq (struct domain *d,unsigned ioapic_gsi,unsigned pic_irq) +{ +int pirq =domain_emuirq_to_pirq (d, ioapic_gsi); +if ( pirq !=IRQ_UNBOUND ) + { +send_guest_pirq (d, pirq); +return ; + } +vioapic_irq_positive_edge (d, ioapic_gsi); +vpic_irq_positive_edge (d, pic_irq); +} + +/* Must be called with hvm_domain->irq_lock hold */ +static void deassert_irq (struct domain *d,unsigned isa_irq) +{ +if (domain_emuirq_to_pirq (d, isa_irq) !=IRQ_UNBOUND ) +vpic_irq_negative_edge (d, isa_irq); +} +static void __hvm_pci_intx_assert (struct domain *d,unsigned int device,unsigned int intx) {
@@ -45,10 +66,7 @@ static void __hvm_pci_intx_assert( isa_irq = hvm_irq->pci_link.route[link];if ( (hvm_irq->pci_link_assert_count[link]++ ==0 ) && isa_irq && (hvm_irq->gsi_assert_count[isa_irq]++ ==0 ) ) - { -vioapic_irq_positive_edge (d, isa_irq); -vpic_irq_positive_edge (d, isa_irq); - } +assert_irq (d, isa_irq, isa_irq); } void hvm_pci_intx_assert(
@@ -77,7 +95,7 @@ static void __hvm_pci_intx_deassert( isa_irq = hvm_irq->pci_link.route[link];if ( (--hvm_irq->pci_link_assert_count[link] ==0 ) && isa_irq && (--hvm_irq->gsi_assert_count[isa_irq] ==0 ) ) -vpic_irq_negative_edge (d, isa_irq); +deassert_irq (d, isa_irq); } void hvm_pci_intx_deassert(
@@ -100,10 +118,7 @@ void hvm_isa_irq_assert(if ( !__test_and_set_bit (isa_irq, &hvm_irq->isa_irq.i) && (hvm_irq->gsi_assert_count[gsi]++ ==0 ) ) - { -vioapic_irq_positive_edge (d, gsi); -vpic_irq_positive_edge (d, isa_irq); - } +assert_irq (d, gsi, isa_irq);spin_unlock (&d->arch.hvm_domain.irq_lock); }
@@ -120,7 +135,7 @@ void hvm_isa_irq_deassert(if (__test_and_clear_bit (isa_irq, &hvm_irq->isa_irq.i) && (--hvm_irq->gsi_assert_count[gsi] ==0 ) ) -vpic_irq_negative_edge (d, isa_irq); +deassert_irq (d, isa_irq);spin_unlock (&d->arch.hvm_domain.irq_lock); }
xen/arch/x86/irq.c +89 -2
106 lines not on this page · raw message
xen/arch/x86/physdev.c +77 -1
108 lines not on this page · raw message
xen/common/event_channel.c +21 -8
@@ -331,7 +331,7 @@ static long evtchn_bind_pirq(evtchn_bindif ( (pirq <0 ) || (pirq >= d->nr_pirqs) )return -EINVAL ; -if ( !irq_access_permitted (d, pirq) ) +if ( !is_hvm_domain (d) && !irq_access_permitted (d, pirq) )return -EPERM ;spin_lock (&d->event_lock);
@@ -345,12 +345,15 @@ static long evtchn_bind_pirq(evtchn_bind chn =evtchn_from_port (d, port); d->pirq_to_evtchn[pirq] = port; - rc =pirq_guest_bind (v, pirq, - !!(bind->flags &BIND_PIRQ__WILL_SHARE )); -if ( rc !=0 ) +if ( !is_hvm_domain (d) ) { - d->pirq_to_evtchn[pirq] =0 ; - goto out; + rc =pirq_guest_bind (v, pirq, + !!(bind->flags &BIND_PIRQ__WILL_SHARE )); +if ( rc !=0 ) + { + d->pirq_to_evtchn[pirq] =0 ; + goto out; + } } chn->state =ECS_PIRQ ;
@@ -403,7 +406,8 @@ static long __evtchn_close(struct domainbreak ;case ECS_PIRQ : -pirq_guest_unbind (d1, chn1->u.pirq.irq); +if ( !is_hvm_domain (d1) ) +pirq_guest_unbind (d1, chn1->u.pirq.irq); d1->pirq_to_evtchn[chn1->u.pirq.irq] =0 ;unlink_pirq_port (chn1, d1->vcpu[chn1->notify_vcpu_id]);break ;
@@ -664,8 +668,17 @@ int send_guest_pirq(struct domain *d, in/* * It should not be possible to race with __evtchn_close(): * The caller of this function must synchronise with pirq_guest_unbind(). +* +* In the HVM case port is 0 when the guest disable the +* emulated interrupt\evtchn. */ -ASSERT (port !=0 ); +if (!port) + { +if (is_hvm_domain (d) ) +return 0 ; +else +return -EINVAL ; + } chn =evtchn_from_port (d, port);return evtchn_set_pending (d->vcpu[chn->notify_vcpu_id], port);
xen/common/kernel.c +2 -1
@@ -261,7 +261,8 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDL (1U << XENFEAT_gnttab_map_avail_bits); else fi.submap |= (1U << XENFEAT_hvm_safe_pvclock) | - (1U << XENFEAT_hvm_callback_vector); + (1U << XENFEAT_hvm_callback_vector) | + (1U << XENFEAT_hvm_pirqs);#endif break ;default :
xen/drivers/passthrough/io.c +9 -2
@@ -373,6 +373,7 @@ int pt_irq_destroy_bind_vtd( hvm_irq_dpci->mirq[machine_gsi].dom =NULL ; hvm_irq_dpci->mirq[machine_gsi].flags =0 ;clear_bit (machine_gsi, hvm_irq_dpci->mapping); +unmap_domain_pirq_emuirq (d, machine_gsi); } }spin_unlock (&d->event_lock);
@@ -452,7 +453,10 @@ void hvm_dpci_msi_eoi(struct domain *d,extern int vmsi_deliver (struct domain *d,int pirq);static int hvm_pci_msi_assert (struct domain *d,int pirq) { -return vmsi_deliver (d, pirq); +if (hvm_domain_use_pirq (d, pirq) ) +return send_guest_pirq (d, pirq); +else +return vmsi_deliver (d, pirq); }#endif
@@ -486,7 +490,10 @@ static void hvm_dirq_assist(unsigned lon { device = digl->device; intx = digl->intx; -hvm_pci_intx_assert (d, device, intx); +if (hvm_domain_use_pirq (d, pirq) ) +send_guest_pirq (d, pirq); +else +hvm_pci_intx_assert (d, device, intx); hvm_irq_dpci->mirq[pirq].pending++;#ifdef SUPPORT_MSI_REMAPPING
xen/include/asm-x86/domain.h +3 -0
@@ -258,6 +258,9 @@ struct arch_domain/* NB. protected by d->event_lock and by irq_desc[irq].lock */ int *irq_pirq;int *pirq_irq; +/* pirq to emulated irq and vice versa */ +int *emuirq_pirq; +int *pirq_emuirq;/* Shared page for notifying that explicit PIRQ EOI is required. */ unsigned long *pirq_eoi_map;
xen/include/asm-x86/irq.h +7 -0
@@ -113,6 +113,9 @@ int map_domain_pirq(struct domain *d, inint unmap_domain_pirq (struct domain *d,int pirq);int get_free_pirq (struct domain *d,int type,int index);void free_domain_pirqs (struct domain *d); +int map_domain_emuirq_pirq (struct domain *d,int pirq,int irq); +int unmap_domain_pirq_emuirq (struct domain *d,int pirq); +int hvm_domain_use_pirq (struct domain *d,int irq);int init_irq_data (void );
@@ -146,5 +149,9 @@ void irq_set_affinity(struct irq_desc *,#define domain_pirq_to_irq (d, pirq) ((d)->arch.pirq_irq[pirq])#define domain_irq_to_pirq (d, irq) ((d)->arch.irq_pirq[irq]) +#define domain_pirq_to_emuirq (d, pirq) ((d)->arch.pirq_emuirq[pirq]) +#define domain_emuirq_to_pirq (d, emuirq) ((d)->arch.emuirq_pirq[emuirq]) +#define IRQ_UNBOUND -1 +#define IRQ_PT -2#endif /* _ASM_HW_IRQ_H */
xen/include/public/features.h +3 -0
@@ -74,6 +74,9 @@/* x86: pvclock algorithm is safe to use on HVM */ #define XENFEAT_hvm_safe_pvclock 9 +/* x86: pirq can be used by HVM guests */ +#define XENFEAT_hvm_pirqs 10 +#define XENFEAT_NR_SUBMAPS 1#endif /* __XEN_PUBLIC_FEATURES_H__ */
Re: [PATCH 1 of 4] xen: interrupt remapping in HVM guests
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 30.08.10 at 13:25, <[email protected]> wrote:
xen/arch/x86/domain.c +3
-0@@ -490,6 +490,16 @@ int arch_domain_create(struct domain *d,if ( !IO_APIC_IRQ (i) ) d->arch.irq_pirq[i] = d->arch.pirq_irq[i] = i; + d->arch.pirq_emuirq =xmalloc_array (int, d->nr_pirqs); + d->arch.emuirq_pirq =xmalloc_array (int, nr_irqs); +if ( !d->arch.pirq_emuirq || !d->arch.emuirq_pirq )
xen/arch/x86/domain.c int arch_domain_create(struct domain *d, · line 505
Quoted 10 lines
xen/arch/x86/domain.c +7
-0+ goto fail; +memset (d->arch.pirq_emuirq,IRQ_UNBOUND , + d->nr_pirqs *sizeof (*d->arch.pirq_emuirq)); +memset (d->arch.emuirq_pirq,IRQ_UNBOUND , + d->nr_pirqs *sizeof (*d->arch.emuirq_pirq)); + +if ( (rc =iommu_domain_init (d)) !=0 ) goto fail;
Shouldn't this be done for HVM domains only, and should you free these arrays both in the error path of that function and in e.g. arch_domain_destroy()?
Additionally, shouldn't you add a build time check making sure that IRQ_UNBOUND is actually suitable for initialization via memset() (or alternatively use a loop)?
Jan
Re: [PATCH 1 of 4] xen: interrupt remapping in HVM guests
Quoted 16 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 30.08.10 at 13:25, <[email protected]> wrote:
xen/arch/x86/domain.c +9
-0@@ -490,6 +490,16 @@ int arch_domain_create(struct domain *d,if ( !IO_APIC_IRQ (i) ) d->arch.irq_pirq[i] = d->arch.pirq_irq[i] = i; + d->arch.pirq_emuirq =xmalloc_array (int, d->nr_pirqs); + d->arch.emuirq_pirq =xmalloc_array (int, nr_irqs); +if ( !d->arch.pirq_emuirq || !d->arch.emuirq_pirq ) + goto fail; +memset (d->arch.pirq_emuirq,IRQ_UNBOUND , + d->nr_pirqs *sizeof (*d->arch.pirq_emuirq)); +memset (d->arch.emuirq_pirq,IRQ_UNBOUND , + d->nr_pirqs *sizeof (*d->arch.emuirq_pirq)); +
Quoted 8 lines
xen/arch/x86/domain.c int arch_domain_create(struct domain *d, · line 505
Quoted 4 lines
xen/arch/x86/domain.c +1
-0+if ( (rc =iommu_domain_init (d)) !=0 ) goto fail;Shouldn't this be done for HVM domains only, and should you free these arrays both in the error path of that function and in e.g.
arch_domain_destroy()?
Yes, you are right about that, I'll fix and resend.
Quoted 5 lines
Additionally, shouldn't you add a build time check making sure that
IRQ_UNBOUNDis actually suitable for initialization viamemset()(or alternatively use a loop)?
something like typeof?
Re: [PATCH 1 of 4] xen: interrupt remapping in HVM guests
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Stefano Stabellini
Quoted 4 lines · Jan Beulich
Additionally, shouldn't you add a build time check making sure that
IRQ_UNBOUNDis actually suitable for initialization viamemset()(or alternatively use a loop)?something like typeof?
No, something that makes sure all bytes of the int are identical (since of the int you pass to memset() only the low 8 bits actually get used). For the moment, checking the value is either 0 or -1 would probably do.
Jan
Re: [PATCH 1 of 4] xen: interrupt remapping in HVM guests
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · Stefano Stabellini
Quoted 4 lines · Jan Beulich
Additionally, shouldn't you add a build time check making sure that
IRQ_UNBOUNDis actually suitable for initialization viamemset()(or alternatively use a loop)?
Quoted 6 lines
Quoted 1 line
something like typeof?
No, something that makes sure all bytes of the int are identical (since of the int you pass to
memset()only the low 8 bits actually get used). For the moment, checking the value is either 0 or -1 would probably do.
I understand now, but I think I prefer to use a loop instead :)
PATCH 1/1 xen: introduce PHYSDEVOP_get_nr_pirqs
In reply to Stefano StabelliniIntroduce a new physdevop called PHYSDEVOP_get_nr_pirqs that allows PV and PV on HVM guests to get the number of pirqs available.
xen/arch/x86/hvm/hvm.c +3 -0
@@ -2290,6 +2290,7 @@ static long hvm_physdev_op(int cmd, XEN_case PHYSDEVOP_unmap_pirq:case PHYSDEVOP_eoi:case PHYSDEVOP_irq_status_query: +case PHYSDEVOP_get_nr_pirqs:return do_physdev_op (cmd, arg);default :return -ENOSYS ;
@@ -2393,6 +2394,8 @@ static long hvm_physdev_op_compat32(case PHYSDEVOP_eoi:case PHYSDEVOP_irq_status_query:return compat_physdev_op (cmd, arg); +case PHYSDEVOP_get_nr_pirqs: +return do_physdev_op (cmd, arg);break ;default :return -ENOSYS ;
xen/arch/x86/physdev.c +6 -0
@@ -572,6 +572,12 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H setup_gsi.polarity);break ; } +case PHYSDEVOP_get_nr_pirqs: { +struct physdev_nr_pirqs out; + out.nr_pirqs = v->domain->nr_pirqs; + ret =copy_to_guest (arg, &out,1 ) ? -EFAULT :0 ; +break ; + }default : ret = -ENOSYS ;break ;
xen/include/public/physdev.h +9 -0
@@ -240,6 +240,15 @@ struct physdev_setup_gsi {typedef struct physdev_setup_gsi physdev_setup_gsi_t ;DEFINE_XEN_GUEST_HANDLE (physdev_setup_gsi_t); +#define PHYSDEVOP_get_nr_pirqs 22 +struct physdev_nr_pirqs { +/* OUT */ +uint32_t nr_pirqs; +}; + +typedef struct physdev_nr_pirqs physdev_nr_pirqs_t ; +DEFINE_XEN_GUEST_HANDLE (physdev_nr_pirqs_t); +/* * Notify that some PIRQ-bound event channels have been unmasked. * ** This command is obsolete since interface version 0x00030202 and is **
Re: [PATCH 2 of 4] xen: introduce PHYSDEVOP_get_nr_pirqs
Useful why? What if we'd like nr_pirqs to be per-domain dynamic in future?
-- Keir
Quoted 65 lines · Stefano Stabellini
Introduce a new physdevop called
PHYSDEVOP_get_nr_pirqsthat allows PV and PV on HVM guests to get the number of pirqs available.Signed-off-by Stefano Stabellini <[email protected]>diff -r
f2dc396b92aaxen/arch/x86/hvm/hvm.cxen/arch/x86/hvm/hvm.c Fri Aug 20 14:49:52 2010 +0100 renamed from xen/arch/x86/hvm/hvm.c Wed Aug 18 14:14:23 2010 +0100 +3
-0@@ -2290,6 +2290,7 @@ static long hvm_physdev_op(int cmd, XEN_ case PHYSDEVOP_unmap_pirq: case PHYSDEVOP_eoi: case PHYSDEVOP_irq_status_query: + case PHYSDEVOP_get_nr_pirqs: return do_physdev_op(cmd, arg); default: return -ENOSYS;@@ -2393,6 +2394,8 @@ static long hvm_physdev_op_compat32( case PHYSDEVOP_eoi: case PHYSDEVOP_irq_status_query: return compat_physdev_op(cmd, arg); + case PHYSDEVOP_get_nr_pirqs: + return do_physdev_op(cmd, arg); break; default: return -ENOSYS;diff -r
f2dc396b92aaxen/arch/x86/physdev.cxen/arch/x86/physdev.c Fri Aug 20 14:49:52 2010 +0100 renamed from xen/arch/x86/physdev.c Wed Aug 18 14:14:23 2010 +0100 +6
-0@@ -572,6 +572,12 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H setup_gsi.polarity); break; } + case PHYSDEVOP_get_nr_pirqs: { + struct physdev_nr_pirqs out; + out.nr_pirqs = v->domain->nr_pirqs; + ret = copy_to_guest(arg, &out, 1) ? -EFAULT : 0; + break; + } default: ret = -ENOSYS; break;diff -r
f2dc396b92aaxen/include/public/physdev.hxen/include/public/physdev.h Fri Aug 20 14:49:52 2010 +0100 renamed from xen/include/public/physdev.h Wed Aug 18 14:14:23 2010 +0100 +9
-0@@ -240,6 +240,15 @@ struct physdev_setup_gsi { typedef struct physdev_setup_gsi physdev_setup_gsi_t; DEFINE_XEN_GUEST_HANDLE(physdev_setup_gsi_t); +#define PHYSDEVOP_get_nr_pirqs 22 +struct physdev_nr_pirqs { + /* OUT */ + uint32_t nr_pirqs; +}; + +typedef struct physdev_nr_pirqs physdev_nr_pirqs_t; +DEFINE_XEN_GUEST_HANDLE(physdev_nr_pirqs_t); + /* * Notify that some PIRQ-bound event channels have been unmasked. * ** This command is obsolete since interface version 0x00030202 and is **_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Re: [PATCH 2 of 4] xen: introduce PHYSDEVOP_get_nr_pirqs
Quoted 2 lines · Keir Fraser
Useful why? What if we'd like
nr_pirqsto be per-domain dynamic in future?
That wouldn't be a good idea considering that the current PHYSDEVOP_map_pirq interface allows the guest to choose the pirq number (unless the guest explicitely passes map.pirq == -1, but only PV on HVM guests and qemu do it, after my series).
Re: [PATCH 2 of 4] xen: introduce PHYSDEVOP_get_nr_pirqs
Quoted 7 lines · Stefano Stabellini
Quoted 2 lines · Keir Fraser
Useful why? What if we'd like
nr_pirqsto be per-domain dynamic in future?That wouldn't be a good idea considering that the current
PHYSDEVOP_map_pirqinterface allows the guest to choose the pirq number
So what significance does nr_pirqs have to the guest?
Quoted 3 lines
(unless the guest explicitely passes map.pirq == -1, but only PV on HVM guests and qemu do it, after my series).
Re: [PATCH 2 of 4] xen: introduce PHYSDEVOP_get_nr_pirqs
Quoted 4 lines · Keir Fraser
Quoted 1 line · Stefano Stabellini
On Tue, 31 Aug 2010, Keir Fraser wrote:
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Useful why? What if we'd like
nr_pirqsto be per-domain dynamic in future?That wouldn't be a good idea considering that the current
PHYSDEVOP_map_pirqinterface allows the guest to choose the pirq numberSo what significance does
nr_pirqshave to the guest?
the upper limit of the pirq number it might choose
Re: [PATCH 2 of 4] xen: introduce PHYSDEVOP_get_nr_pirqs
Quoted 7 lines · Stefano Stabellini
Quoted 5 lines
Quoted 3 lines
That wouldn't be a good idea considering that the current
PHYSDEVOP_map_pirqinterface allows the guest to choose the pirq numberSo what significance does
nr_pirqshave to the guest?the upper limit of the pirq number it might choose
Couldn't it, like, pick the smallest available? :-)
Re: [PATCH 2 of 4] xen: introduce PHYSDEVOP_get_nr_pirqs
Quoted 7 lines · Keir Fraser
Quoted 4 lines · Stefano Stabellini
Quoted 4 lines
Quoted 3 lines
That wouldn't be a good idea considering that the current
PHYSDEVOP_map_pirqinterface allows the guest to choose the pirq number
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
So what significance does
nr_pirqshave to the guest?the upper limit of the pirq number it might choose
Couldn't it, like, pick the smallest available? :-)
Well, it might still be useful to know the upper limit, besides linux tends to choose the pirq == irq and the irqs for MSIs are high. Xen does the same thing by the way.
Re: [PATCH 2 of 4] xen: introduce PHYSDEVOP_get_nr_pirqs
Quoted 6 lines · Stefano Stabellini
Quoted 2 lines
Couldn't it, like, pick the smallest available? :-)
Well, it might still be useful to know the upper limit, besides linux tends to choose the pirq == irq and the irqs for MSIs are high. Xen does the same thing by the way.
Well I'm just being fussy because it's yet another irq related interface and we seem to have so many already. Might-be-useful is different from must-have-now, and if you are allocating pirq==irq then that allocation strategy is not influenced by knowing nr_pirqs is it?
-- Keir
Re: [PATCH 2 of 4] xen: introduce PHYSDEVOP_get_nr_pirqs
Quoted 6 lines · Keir Fraser
Quoted 3 lines · Stefano Stabellini
Quoted 2 lines
Couldn't it, like, pick the smallest available? :-)
Quoted 8 lines
Quoted 3 lines
Well, it might still be useful to know the upper limit, besides linux tends to choose the pirq == irq and the irqs for MSIs are high. Xen does the same thing by the way.
Well I'm just being fussy because it's yet another irq related interface and we seem to have so many already. Might-be-useful is different from must-have-now, and if you are allocating pirq==irq then that allocation strategy is not influenced by knowing
nr_pirqsis it?
Knowing the pirq number upper limit is important for PV on HVM guests to be able to remap MSIs into pirqs minimizing the chances of conflicts. If we had another way of knowing the maximum pirq number from within the guest I would gladly use it.
It is also useful for dom0 that up to know just assumed that the pirq number is always identical to the irq number (that for MSIs might be actually higher than nr_pirq).
In other words: if the guest is allowed to choose the pirq number it must be able to know what the range is.
Could we initialize nr_pirq always to the same value in xen?
PATCH 1/1 qemu-xen: support PV on HVM MSI remapping
In reply to Stefano StabelliniIf the guest enables an MSI passing 0 as vector number, then read the address and use it as pirq number for the following mapping request to Xen.
hw/pt-msi.c +10 -0
@@ -65,6 +65,7 @@ static void msix_set_enable(struct pt_dev *dev, int en)int pt_msi_setup (struct pt_dev *dev) {int pirq =-1 ; +uint8_t gvec =0 ;if ( !(dev->msi->flags &MSI_FLAG_UNINIT ) ) {
@@ -72,6 +73,15 @@ int pt_msi_setup(struct pt_dev *dev)return -1 ; } + gvec = dev->msi->data &0xFF ; +if (!gvec) { +/* if gvec is 0, the guest is asking for a particular pirq that +* is passed as dest_id */ + pirq = (dev->msi->addr_hi &0xffffff00 ) | + ((dev->msi->addr_lo >>MSI_TARGET_CPU_SHIFT ) &0xff ); +PT_LOG ("pt_msi_setup requested pirq = %d\n" , pirq); + } + if ( xc_physdev_map_pirq_msi(xc_handle, domid, AUTO_ASSIGN, &pirq, PCI_DEVFN(dev->pci_dev->dev, ev->pci_dev->func),
PATCH 1/1 qemu-xen: let xen choose the pirq number
In reply to Stefano StabelliniWhen remapping an interrupt into the guest, let xen choose the pirq, otherwise we might have to handle possible conflicts.
hw/pass-through.c +1 -1
@@ -4265,7 +4265,7 @@ static struct pt_dev * register_real_device(PCIBus *e_bus,if (PT_MACHINE_IRQ_AUTO == machine_irq ) { -int pirq = pci_dev->irq; +int pirq =-1 ; machine_irq = pci_dev->irq; rc =xc_physdev_map_pirq (xc_handle, domid, machine_irq, &pirq);