From: Roger Pau Monne Date: Tue, 11 Apr 2017 07:41:10 +0000 (+0100) Subject: x86/vioapic: bind interrupts to PVH Dom0 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=665196c037b4172430023184f7d64b92c2cc3e18;p=people%2Froyger%2Fxen.git x86/vioapic: bind interrupts to PVH Dom0 Add the glue in order to bind the PVH Dom0 GSI from bare metal. This is done when Dom0 unmasks the vIO APIC pins, by fetching the current pin settings and setting up the PIRQ, which will then be bound to Dom0 using the newly introduced PT_IRQ_TYPE_GSI bind type. Signed-off-by: Roger Pau Monné --- Cc: Jan Beulich Cc: Andrew Cooper --- diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c index 52555cd328..527ac2aadd 100644 --- a/xen/arch/x86/hvm/vioapic.c +++ b/xen/arch/x86/hvm/vioapic.c @@ -202,6 +202,34 @@ static void vioapic_write_redirent( unmasked = unmasked && !ent.fields.mask; } + if ( is_hardware_domain(d) && unmasked ) + { + xen_domctl_bind_pt_irq_t pt_irq_bind = { + .irq_type = PT_IRQ_TYPE_GSI, + .machine_irq = gsi, + .u.gsi.gsi = gsi, + .hvm_domid = DOMID_SELF, + }; + int ret, pirq = gsi; + + /* Interrupt has been unmasked, bind it now. */ + ret = mp_register_gsi(gsi, ent.fields.trig_mode, ent.fields.polarity); + if ( ret && ret != -EEXIST ) + { + gdprintk(XENLOG_WARNING, + "%s: error registering GSI %u: %d\n", __func__, gsi, ret); + } + if ( !ret ) + { + ret = physdev_map_pirq(DOMID_SELF, MAP_PIRQ_TYPE_GSI, &pirq, &pirq, + NULL); + BUG_ON(ret); + + ret = pt_irq_create_bind(d, &pt_irq_bind); + BUG_ON(ret); + } + } + *pent = ent; if ( gsi == 0 )