summaryrefslogtreecommitdiffstats
path: root/recipes-extended/xen/files/0001-arm-silence-gcc14-warning-error-on-irq-bounds-check.patch
blob: 637d6fe531ec49adcc9c3cef80be13a0777e699f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
From 2258853a19b2d0b1fafd901cddf69f730c38d450 Mon Sep 17 00:00:00 2001
From: Bruce Ashfield <bruce.ashfield@gmail.com>
Date: Fri, 31 May 2024 14:50:33 +0000
Subject: [PATCH] arm: silence gcc14 warning (error) on irq bounds check

While we wait for upstream to update to gcc14, we add a quick
check to avoid gcc14 not being able to confirm that IRQ is
greater than 0 and hence throws a warning, which leads to an
error.

| In function '__irq_to_desc',
|     inlined from 'route_irq_to_guest' at arch/arm/irq.c:467:12:
| arch/arm/irq.c:65:16: error: array subscript -2 is below array bounds of 'irq_desc_t[32]' {aka 'struct irq_desc[32]'} [-Werror=array-bounds=]
|    65 |         return &this_cpu(local_irq_desc)[irq];
|       |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Upstream-Status: Pending [the xen folks understand the code and the right fix .. I don't]

Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
---
 xen/arch/arm/irq.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

Index: git/xen/arch/arm/irq.c
===================================================================
--- git.orig/xen/arch/arm/irq.c
+++ git/xen/arch/arm/irq.c
@@ -48,8 +48,13 @@ void irq_end_none(struct irq_desc *irq)
 static irq_desc_t irq_desc[NR_IRQS];
 static DEFINE_PER_CPU(irq_desc_t[NR_LOCAL_IRQS], local_irq_desc);
 
+
 struct irq_desc *__irq_to_desc(int irq)
 {
+    /* silence gcc14 warning */
+    if ( irq < 0 )
+        return &this_cpu(local_irq_desc)[0];
+
     if ( irq < NR_LOCAL_IRQS )
         return &this_cpu(local_irq_desc)[irq];
 
@@ -722,16 +727,16 @@ int platform_get_irq(const struct dt_dev
 
 int platform_get_irq_byname(const struct dt_device_node *np, const char *name)
 {
-	int index;
+        int index;
 
-	if ( unlikely(!name) )
-		return -EINVAL;
+        if ( unlikely(!name) )
+                return -EINVAL;
 
-	index = dt_property_match_string(np, "interrupt-names", name);
-	if ( index < 0 )
-		return index;
+        index = dt_property_match_string(np, "interrupt-names", name);
+        if ( index < 0 )
+                return index;
 
-	return platform_get_irq(np, index);
+        return platform_get_irq(np, index);
 }
 
 /*