Patchwork [v4,19/28] x86/vioapic: extend vioapic_get_vector() to support remapping format RTE

login
register
mail settings
Submitter Chao Gao
Date Nov. 17, 2017, 6:22 a.m.
Message ID <1510899755-40237-20-git-send-email-chao.gao@intel.com>
Download mbox | patch
Permalink /patch/385515/
State New
Headers show

Comments

Chao Gao - Nov. 17, 2017, 6:22 a.m.
When IOAPIC RTE is in remapping format, it doesn't contain the vector of
interrupt. For this case, the RTE contains an index of interrupt remapping
table where the vector of interrupt is stored. This patchs gets the vector
through a vIOMMU interface.

Signed-off-by: Chao Gao <chao.gao@intel.com>
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
 xen/arch/x86/hvm/vioapic.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Patch

diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c
index 0f20e3f..8b34b21 100644
--- a/xen/arch/x86/hvm/vioapic.c
+++ b/xen/arch/x86/hvm/vioapic.c
@@ -560,11 +560,23 @@  int vioapic_get_vector(const struct domain *d, unsigned int gsi)
 {
     unsigned int pin;
     const struct hvm_vioapic *vioapic = gsi_vioapic(d, gsi, &pin);
+    struct arch_irq_remapping_request request;
 
     if ( !vioapic )
         return -EINVAL;
 
-    return vioapic->redirtbl[pin].fields.vector;
+    irq_request_ioapic_fill(&request, vioapic->id, vioapic->redirtbl[pin].bits);
+    if ( viommu_check_irq_remapping(vioapic->domain, &request) )
+    {
+        struct arch_irq_remapping_info info;
+
+        return unlikely(viommu_get_irq_info(vioapic->domain, &request, &info))
+                   ? : info.vector;
+    }
+    else
+    {
+        return vioapic->redirtbl[pin].fields.vector;
+    }
 }
 
 int vioapic_get_trigger_mode(const struct domain *d, unsigned int gsi)