xen: fix arm64 build with gcc14

gcc14 isn't properly tracking if the irq array index is
greater than zero, and hence generates a warning that
chains to a build error.

This is a temporary patch to ensure that the variable
is greater than zero and hence keeps the warning from
happening. If it was less than zero, a different way
of dealing with it "officially" would be better, but we
lack the insight to know what to do in this case (plus,
it really isn't less than zero as it has never caused
an issue before)

Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
This commit is contained in:
Bruce Ashfield 2024-05-31 14:54:41 +00:00
parent acb0653af0
commit 79a282078f
2 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,68 @@
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(-)
diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
index ae69fb4aeb..dcac86bd84 100644
--- a/xen/arch/arm/irq.c
+++ b/xen/arch/arm/irq.c
@@ -58,8 +58,13 @@ hw_irq_controller no_irq_type = {
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];
@@ -723,16 +728,16 @@ int platform_get_irq(const struct dt_device_node *device, int index)
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);
}
/*
--
2.39.2

View File

@ -7,6 +7,7 @@ XEN_BRANCH ?= "stable-4.18"
SRC_URI = " \
git://xenbits.xen.org/xen.git;branch=${XEN_BRANCH} \
file://0001-menuconfig-mconf-cfg-Allow-specification-of-ncurses-location.patch \
file://0001-arm-silence-gcc14-warning-error-on-irq-bounds-check.patch \
"
LIC_FILES_CHKSUM ?= "file://COPYING;md5=d1a1e216f80b6d8da95fec897d0dbec9"