qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH for-8.1] accel/tcg: Avoid reading too much in load_atom_{2, 4


From: Peter Maydell
Subject: Re: [PATCH for-8.1] accel/tcg: Avoid reading too much in load_atom_{2, 4}
Date: Thu, 10 Aug 2023 16:56:27 +0100

On Thu, 10 Aug 2023 at 16:49, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> When load_atom_extract_al16_or_al8 is inexpensive, we want to use
> it early, in order to avoid the overhead of required_atomicity.
> However, we must not read past the end of the page.
>
> Reported-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---



>      if (HAVE_ATOMIC128_RO) {
> -        return load_atom_extract_al16_or_al8(pv, 2);
> +        intptr_t left_in_page = pi | TARGET_PAGE_MASK;

isn't left_in_page actually -(pi | TARGET_PAGE_MASK) ?
I feel like that would be clearer than leaving it
the negative of the number of bytes left in the page
and comparing against -16 (and assume the compiler
generates equivalent code).

(I always have trouble with expressions that combine
boolean operations and 2s-complement arithmetic, though.)

> +        if (likely(left_in_page <= -16)) {
> +            return load_atom_extract_al16_or_al8(pv, 2);
> +        }
>      }

Either way
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM



reply via email to

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