Message ID | 1506049330-11196-18-git-send-email-tianyu.lan@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Sep 21, 2017 at 11:01:58PM -0400, Lan Tianyu wrote: > From: Chao Gao <chao.gao@intel.com> > > Different platform may use different method to distinguish > remapping format interrupt and normal format interrupt. > > Intel uses one bit in IOAPIC RTE or MSI address register to > indicate the interrupt is remapping format. vvtd will handle > all the interrupts when .check_irq_remapping() return true. > > Signed-off-by: Chao Gao <chao.gao@intel.com> > Signed-off-by: Lan Tianyu <tianyu.lan@intel.com> > --- > xen/drivers/passthrough/vtd/vvtd.c | 25 ++++++++++++++++++++++++- > 1 file changed, 24 insertions(+), 1 deletion(-) > > diff --git a/xen/drivers/passthrough/vtd/vvtd.c b/xen/drivers/passthrough/vtd/vvtd.c > index 5e22ace..bd1cadd 100644 > --- a/xen/drivers/passthrough/vtd/vvtd.c > +++ b/xen/drivers/passthrough/vtd/vvtd.c > @@ -536,6 +536,28 @@ static int vvtd_get_irq_info(struct domain *d, > return 0; > } > > +/* Probe whether the interrupt request is an remapping format */ > +static bool vvtd_is_remapping(struct domain *d, > + struct arch_irq_remapping_request *irq) > +{ > + if ( irq->type == VIOMMU_REQUEST_IRQ_APIC ) > + { > + struct IO_APIC_route_remap_entry rte = { .val = irq->msg.rte }; > + > + return rte.format; > + } > + else if ( irq->type == VIOMMU_REQUEST_IRQ_MSI ) > + { > + struct msi_msg_remap_entry msi_msg = > + { .address_lo = { .val = irq->msg.msi.addr } }; > + > + return msi_msg.address_lo.format; > + } > + ASSERT_UNREACHABLE(); Switch please. Also there's a bunch of temporary IO_APIC_route_remap_entry and msi_msg_remap_entry local structures. Why don't you just create some kind of union in arch_irq_remapping_request so that you don't need to do this each time? Thanks, Roger.
diff --git a/xen/drivers/passthrough/vtd/vvtd.c b/xen/drivers/passthrough/vtd/vvtd.c index 5e22ace..bd1cadd 100644 --- a/xen/drivers/passthrough/vtd/vvtd.c +++ b/xen/drivers/passthrough/vtd/vvtd.c @@ -536,6 +536,28 @@ static int vvtd_get_irq_info(struct domain *d, return 0; } +/* Probe whether the interrupt request is an remapping format */ +static bool vvtd_is_remapping(struct domain *d, + struct arch_irq_remapping_request *irq) +{ + if ( irq->type == VIOMMU_REQUEST_IRQ_APIC ) + { + struct IO_APIC_route_remap_entry rte = { .val = irq->msg.rte }; + + return rte.format; + } + else if ( irq->type == VIOMMU_REQUEST_IRQ_MSI ) + { + struct msi_msg_remap_entry msi_msg = + { .address_lo = { .val = irq->msg.msi.addr } }; + + return msi_msg.address_lo.format; + } + ASSERT_UNREACHABLE(); + + return 0; +} + static void vvtd_reset(struct vvtd *vvtd, uint64_t capability) { uint64_t cap = cap_set_num_fault_regs(1ULL) | @@ -607,7 +629,8 @@ struct viommu_ops vvtd_hvm_vmx_ops = { .create = vvtd_create, .destroy = vvtd_destroy, .handle_irq_request = vvtd_handle_irq_request, - .get_irq_info = vvtd_get_irq_info + .get_irq_info = vvtd_get_irq_info, + .check_irq_remapping = vvtd_is_remapping }; static int vvtd_register(void)