[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v6 1/3] x86/vioapic: make gsi_vioapic private



And introduce vioapic_get_{mask/vector} in order to replace it's
usage.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Cc: Jan Beulich <jbeulich@xxxxxxxx>
Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
Changes since v5:
 - New in this version.
---
 xen/arch/x86/hvm/vioapic.c        | 26 ++++++++++++++++++++++++--
 xen/arch/x86/hvm/vpt.c            | 20 ++++++++++----------
 xen/include/asm-x86/hvm/vioapic.h |  6 +++---
 3 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c
index abcc473c88..f2895cf57c 100644
--- a/xen/arch/x86/hvm/vioapic.c
+++ b/xen/arch/x86/hvm/vioapic.c
@@ -61,8 +61,8 @@ static struct hvm_vioapic *addr_vioapic(const struct domain 
*d,
     return NULL;
 }
 
-struct hvm_vioapic *gsi_vioapic(const struct domain *d, unsigned int gsi,
-                                unsigned int *pin)
+static struct hvm_vioapic *gsi_vioapic(const struct domain *d,
+                                       unsigned int gsi, unsigned int *pin)
 {
     unsigned int i;
 
@@ -476,6 +476,28 @@ void vioapic_update_EOI(struct domain *d, u8 vector)
     spin_unlock(&d->arch.hvm_domain.irq_lock);
 }
 
+int vioapic_get_mask(struct domain *d, unsigned int gsi)
+{
+    unsigned int pin;
+    const struct hvm_vioapic *vioapic = gsi_vioapic(d, gsi, &pin);
+
+    if ( !vioapic )
+        return -EINVAL;
+
+    return vioapic->redirtbl[pin].fields.mask;
+}
+
+int vioapic_get_vector(struct domain *d, unsigned int gsi)
+{
+    unsigned int pin;
+    const struct hvm_vioapic *vioapic = gsi_vioapic(d, gsi, &pin);
+
+    if ( !vioapic )
+        return -EINVAL;
+
+    return vioapic->redirtbl[pin].fields.vector;
+}
+
 static int ioapic_save(struct domain *d, hvm_domain_context_t *h)
 {
     struct hvm_vioapic *s;
diff --git a/xen/arch/x86/hvm/vpt.c b/xen/arch/x86/hvm/vpt.c
index e3f203915b..3841140be7 100644
--- a/xen/arch/x86/hvm/vpt.c
+++ b/xen/arch/x86/hvm/vpt.c
@@ -78,8 +78,8 @@ void hvm_set_guest_time(struct vcpu *v, u64 guest_time)
 static int pt_irq_vector(struct periodic_time *pt, enum hvm_intsrc src)
 {
     struct vcpu *v = pt->vcpu;
-    struct hvm_vioapic *vioapic;
-    unsigned int gsi, isa_irq, pin;
+    unsigned int gsi, isa_irq;
+    int vector;
 
     if ( pt->source == PTSRC_lapic )
         return pt->irq;
@@ -92,8 +92,8 @@ static int pt_irq_vector(struct periodic_time *pt, enum 
hvm_intsrc src)
                 + (isa_irq & 7));
 
     ASSERT(src == hvm_intsrc_lapic);
-    vioapic = gsi_vioapic(v->domain, gsi, &pin);
-    if ( !vioapic )
+    vector = vioapic_get_vector(v->domain, gsi);
+    if ( vector < 0 )
     {
         dprintk(XENLOG_WARNING, "d%u: invalid GSI (%u) for platform timer\n",
                 v->domain->domain_id, gsi);
@@ -101,14 +101,14 @@ static int pt_irq_vector(struct periodic_time *pt, enum 
hvm_intsrc src)
         return -1;
     }
 
-    return vioapic->redirtbl[pin].fields.vector;
+    return vector;
 }
 
 static int pt_irq_masked(struct periodic_time *pt)
 {
     struct vcpu *v = pt->vcpu;
-    unsigned int gsi, isa_irq, pin;
-    struct hvm_vioapic *vioapic;
+    unsigned int gsi, isa_irq;
+    int mask;
     uint8_t pic_imr;
 
     if ( pt->source == PTSRC_lapic )
@@ -121,8 +121,8 @@ static int pt_irq_masked(struct periodic_time *pt)
     isa_irq = pt->irq;
     gsi = hvm_isa_irq_to_gsi(isa_irq);
     pic_imr = v->domain->arch.hvm_domain.vpic[isa_irq >> 3].imr;
-    vioapic = gsi_vioapic(v->domain, gsi, &pin);
-    if ( !vioapic )
+    mask = vioapic_get_mask(v->domain, gsi);
+    if ( mask < 0 )
     {
         dprintk(XENLOG_WARNING, "d%u: invalid GSI (%u) for platform timer\n",
                 v->domain->domain_id, gsi);
@@ -131,7 +131,7 @@ static int pt_irq_masked(struct periodic_time *pt)
     }
 
     return (((pic_imr & (1 << (isa_irq & 7))) || !vlapic_accept_pic_intr(v)) &&
-            vioapic->redirtbl[pin].fields.mask);
+            mask);
 }
 
 static void pt_lock(struct periodic_time *pt)
diff --git a/xen/include/asm-x86/hvm/vioapic.h 
b/xen/include/asm-x86/hvm/vioapic.h
index 2ceb60eaef..5028bdcc48 100644
--- a/xen/include/asm-x86/hvm/vioapic.h
+++ b/xen/include/asm-x86/hvm/vioapic.h
@@ -61,13 +61,13 @@ struct hvm_vioapic {
 #define domain_vioapic(d, i) ((d)->arch.hvm_domain.vioapic[i])
 #define vioapic_domain(v) ((v)->domain)
 
-struct hvm_vioapic *gsi_vioapic(const struct domain *d, unsigned int gsi,
-                                unsigned int *pin);
-
 int vioapic_init(struct domain *d);
 void vioapic_deinit(struct domain *d);
 void vioapic_reset(struct domain *d);
 void vioapic_irq_positive_edge(struct domain *d, unsigned int irq);
 void vioapic_update_EOI(struct domain *d, u8 vector);
 
+int vioapic_get_mask(struct domain *d, unsigned int gsi);
+int vioapic_get_vector(struct domain *d, unsigned int gsi);
+
 #endif /* __ASM_X86_HVM_VIOAPIC_H__ */
-- 
2.11.0 (Apple Git-81)


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.