[PATCH] xen/arm: Fix unreachable panic for vpl011 vIRQ

Michal Orzel posted 1 patch 1 year, 4 months ago
Test gitlab-ci failed
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20221123143913.6527-1-michal.orzel@amd.com
xen/arch/arm/domain_build.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] xen/arm: Fix unreachable panic for vpl011 vIRQ
Posted by Michal Orzel 1 year, 4 months ago
When creating direct mapped domU, the vIRQ for vpl011 is taken from
the SERHND_DTUART serial port using serial_irq. This function can return
-1 (i.e. no interrupt found) in which case we should call a panic.
However, vpl011_virq is defined as unsigned int which causes the panic
to be unreachable, because less than zero comparison of an unsigned value
can never be true. Fix it by defining vpl011_virq as int.

Fixes: 3580c8b2dfc3 ("xen/arm: if direct-map domain use native UART address and IRQ number for vPL011")
Signed-off-by: Michal Orzel <michal.orzel@amd.com>
---
To be considered to be taken for 4.17, although direct-map depends on
CONFIG_STATIC_MEMORY which is marked as unsupported.
---
 xen/arch/arm/domain_build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index bd30d3798c9a..71a3243f48c5 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -3897,7 +3897,7 @@ void __init create_domUs(void)
 
         if ( !dt_property_read_u32(node, "nr_spis", &d_cfg.arch.nr_spis) )
         {
-            unsigned int vpl011_virq = GUEST_VPL011_SPI;
+            int vpl011_virq = GUEST_VPL011_SPI;
 
             d_cfg.arch.nr_spis = gic_number_lines() - 32;
 
-- 
2.25.1
Re: [PATCH] xen/arm: Fix unreachable panic for vpl011 vIRQ
Posted by Bertrand Marquis 1 year, 4 months ago
Hi Michal,

> On 23 Nov 2022, at 14:39, Michal Orzel <michal.orzel@amd.com> wrote:
> 
> When creating direct mapped domU, the vIRQ for vpl011 is taken from
> the SERHND_DTUART serial port using serial_irq. This function can return
> -1 (i.e. no interrupt found) in which case we should call a panic.
> However, vpl011_virq is defined as unsigned int which causes the panic
> to be unreachable, because less than zero comparison of an unsigned value
> can never be true. Fix it by defining vpl011_virq as int.
> 
> Fixes: 3580c8b2dfc3 ("xen/arm: if direct-map domain use native UART address and IRQ number for vPL011")
> Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>


> ---
> To be considered to be taken for 4.17, although direct-map depends on
> CONFIG_STATIC_MEMORY which is marked as unsupported.

At this stage I do not think we should back port it for the release.
We should consider this as candidate for 4.17.1

Cheers
Bertrand

> ---
> xen/arch/arm/domain_build.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index bd30d3798c9a..71a3243f48c5 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -3897,7 +3897,7 @@ void __init create_domUs(void)
> 
>         if ( !dt_property_read_u32(node, "nr_spis", &d_cfg.arch.nr_spis) )
>         {
> -            unsigned int vpl011_virq = GUEST_VPL011_SPI;
> +            int vpl011_virq = GUEST_VPL011_SPI;
> 
>             d_cfg.arch.nr_spis = gic_number_lines() - 32;
> 
> -- 
> 2.25.1
> 
Re: [PATCH] xen/arm: Fix unreachable panic for vpl011 vIRQ
Posted by Julien Grall 1 year, 4 months ago
Hi,

On 23/11/2022 16:22, Bertrand Marquis wrote:
>> On 23 Nov 2022, at 14:39, Michal Orzel <michal.orzel@amd.com> wrote:
>>
>> When creating direct mapped domU, the vIRQ for vpl011 is taken from
>> the SERHND_DTUART serial port using serial_irq. This function can return
>> -1 (i.e. no interrupt found) in which case we should call a panic.
>> However, vpl011_virq is defined as unsigned int which causes the panic
>> to be unreachable, because less than zero comparison of an unsigned value
>> can never be true. Fix it by defining vpl011_virq as int.
>>
>> Fixes: 3580c8b2dfc3 ("xen/arm: if direct-map domain use native UART address and IRQ number for vPL011")
>> Signed-off-by: Michal Orzel <michal.orzel@amd.com>
> Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>

I have committed it in a branch for-next/4.18 which will be merged once 
the tree reopened.

Cheers,

-- 
Julien Grall
Re: [PATCH] xen/arm: Fix unreachable panic for vpl011 vIRQ
Posted by Julien Grall 1 year, 4 months ago

On 23/11/2022 15:22, Bertrand Marquis wrote:
> Hi Michal,
> 
>> On 23 Nov 2022, at 14:39, Michal Orzel <michal.orzel@amd.com> wrote:
>>
>> When creating direct mapped domU, the vIRQ for vpl011 is taken from
>> the SERHND_DTUART serial port using serial_irq. This function can return
>> -1 (i.e. no interrupt found) in which case we should call a panic.
>> However, vpl011_virq is defined as unsigned int which causes the panic
>> to be unreachable, because less than zero comparison of an unsigned value
>> can never be true. Fix it by defining vpl011_virq as int.
>>
>> Fixes: 3580c8b2dfc3 ("xen/arm: if direct-map domain use native UART address and IRQ number for vPL011")
>> Signed-off-by: Michal Orzel <michal.orzel@amd.com>
> Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
> 
> 
>> ---
>> To be considered to be taken for 4.17, although direct-map depends on
>> CONFIG_STATIC_MEMORY which is marked as unsupported.
> 
> At this stage I do not think we should back port it for the release.
> We should consider this as candidate for 4.17.1

We don't usually backport fixes for tech preview feature.

Cheers,

-- 
Julien Grall