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

[Xen-devel] [PATCH v4 11/13] x86/IRQ: tighten vector checks


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <JBeulich@xxxxxxxx>
  • Date: Tue, 16 Jul 2019 07:43:57 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=suse.com;dmarc=pass action=none header.from=suse.com;dkim=pass header.d=suse.com;arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ud45kFB1sTD7uOcirFyzxBEkTNuKMogmsu4IJRPXpSg=; b=Gigrt7/xVxxo/DxbyCPUJNGKqGJaP7E1DFXF74k6+yYI+mv09Z6sZQc81/QU2rrrUTQ5/s/cnmm0lDii11G08t2YgWkTIb5qrKDECS9ZHWnPVskLa3p82OFLiYdj1ZeeZAgfO/swdQWdK1iFY/lSrPMojBoKblBW90OlRV9VcScqeciIeCI74hT4UGFF/uZN1uhRcJpBCPzgjOvF71N66HTxEx0GaEsOWE8/tx0yWmY//1hhl1RpBJdTuOyFeKnal9TIGDTIBcxNXr+BzI9la0f3R2HuotrrFmwhoD7BbekhPIfC8VMsOP1HuI60M90AY9d+Rjlf8vtPWniQNKpCJA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fwN9khupkO4lzBlsbDBwu+0GoL8JPuodopaf7rNvmjPR0JGOD8WZ6SLat8AnNWT+Ou4FW4ETOtmkUQ79/qy46lqUEoZ3rTC+ecLECaEkh/lJrjeNW+jS8hXqrXlJ5CUX0X1aN686dm7TAscodfOHaYA3nu+vaYsMpuK5jzfeL4CkkX+vnAt1ROZegsPZcuOsguh/a4V6axBiZwb0ROXF393atTFKbU+bJCahv/o2TrE/B8+re8aD3xKul6fsLAXpQbWVQlZtY2f+4a6RpIjtIswFHxZmoHFhgA7NYCJUr9fLofsOx3c3279Uj3q3lG4EgaE490hWzIyFdffqlPTvBA==
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=JBeulich@xxxxxxxx;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Tue, 16 Jul 2019 07:44:18 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHVO6o5tt4GSJMvYEi1iMuGZsabYw==
  • Thread-topic: [PATCH v4 11/13] x86/IRQ: tighten vector checks

Use valid_irq_vector() rather than "> 0".

Also replace an open-coded use of IRQ_VECTOR_UNASSIGNED.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
v3: New.

--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -342,7 +342,7 @@ void clear_irq_vector(int irq)
  
  int irq_to_vector(int irq)
  {
-    int vector = -1;
+    int vector = IRQ_VECTOR_UNASSIGNED;
  
      BUG_ON(irq >= nr_irqs || irq < 0);
  
@@ -452,15 +452,18 @@ static vmask_t *irq_get_used_vector_mask
              int vector;
              
              vector = irq_to_vector(irq);
-            if ( vector > 0 )
+            if ( valid_irq_vector(vector) )
              {
-                printk(XENLOG_INFO "IRQ %d already assigned vector %d\n",
+                printk(XENLOG_INFO "IRQ%d already assigned vector %02x\n",
                         irq, vector);
                  
                  ASSERT(!test_bit(vector, ret));
  
                  set_bit(vector, ret);
              }
+            else if ( vector != IRQ_VECTOR_UNASSIGNED )
+                printk(XENLOG_WARNING "IRQ%d mapped to bogus vector %02x\n",
+                       irq, vector);
          }
      }
      else if ( IO_APIC_IRQ(irq) &&
@@ -491,7 +494,7 @@ static int _assign_irq_vector(struct irq
      vmask_t *irq_used_vectors = NULL;
  
      old_vector = irq_to_vector(irq);
-    if ( old_vector > 0 )
+    if ( valid_irq_vector(old_vector) )
      {
          cpumask_t tmp_mask;
  
@@ -555,7 +558,7 @@ next:
          current_vector = vector;
          current_offset = offset;
  
-        if ( old_vector > 0 )
+        if ( valid_irq_vector(old_vector) )
          {
              cpumask_and(desc->arch.old_cpu_mask, desc->arch.cpu_mask,
                          &cpu_online_map);

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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