qemu-ppc
[Top][All Lists]
Advanced

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

Re: [PATCH] ppc/xive: Fix uint32_t overflow


From: Peter Maydell
Subject: Re: [PATCH] ppc/xive: Fix uint32_t overflow
Date: Thu, 14 Sep 2023 15:42:53 +0100

On Wed, 13 Sept 2023 at 06:57, Cédric Le Goater <clg@kaod.org> wrote:
>
> As reported by Coverity, "idx << xive->pc_shift" is evaluated using
> 32-bit arithmetic, and then used in a context expecting a "uint64_t".
> Add a uint64_t cast.
>
> Fixes: Coverity CID 1519049
> Fixes: b68147b7a5bf ("ppc/xive: Add support for the PC MMIOs")
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  hw/intc/pnv_xive.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/intc/pnv_xive.c b/hw/intc/pnv_xive.c
> index 9b10e905195a..a36b3bf08c92 100644
> --- a/hw/intc/pnv_xive.c
> +++ b/hw/intc/pnv_xive.c
> @@ -210,7 +210,7 @@ static uint64_t pnv_xive_vst_addr_remote(PnvXive *xive, 
> uint32_t type,
>          return 0;
>      }
>
> -    remote_addr |= idx << xive->pc_shift;
> +    remote_addr |= ((uint64_t) idx) << xive->pc_shift;

Nit: our coding style doesn't want a space after the '(uint64_t)'.

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]