qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 1/7] hw/misc: mips_itu: Fix 32/64 bit issue in a


From: Philippe Mathieu-Daudé
Subject: Re: [Qemu-devel] [PATCH 1/7] hw/misc: mips_itu: Fix 32/64 bit issue in a line involving shift operator
Date: Mon, 18 Feb 2019 22:43:05 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0

On 2/18/19 4:31 PM, Aleksandar Markovic wrote:
> From: Aleksandar Markovic <address@hidden>
> 
> Fix 32/64 bit issue in a line involving shift operator. "1 << ..."
> calculation of size is done as a 32-bit signed integer which may
> then be unintentionally sign-extended into the 64-bit result. The
> problem was discovered by Coverity (CID 1398648). Using "1ULL"
> instead of "1" on the LHS of the shift fixes this problem.
> 
> Reproted-by: Peter Maydell <address@hidden>

Reported-by

> Signed-off-by: Aleksandar Markovic <address@hidden>

Reviewed-by: Philippe Mathieu-Daudé <address@hidden>

> ---
>  hw/misc/mips_itu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/misc/mips_itu.c b/hw/misc/mips_itu.c
> index 1257d8f..3afdbe6 100644
> --- a/hw/misc/mips_itu.c
> +++ b/hw/misc/mips_itu.c
> @@ -94,7 +94,7 @@ void itc_reconfigure(MIPSITUState *tag)
>  
>      if (tag->saar_present) {
>          address = ((*(uint64_t *) tag->saar) & 0xFFFFFFFFE000ULL) << 4;
> -        size = 1 << ((*(uint64_t *) tag->saar >> 1) & 0x1f);
> +        size = 1ULL << ((*(uint64_t *) tag->saar >> 1) & 0x1f);
>          is_enabled = *(uint64_t *) tag->saar & 1;
>      }
>  
> 



reply via email to

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