qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v2 1/1] target/ppc: fix unreachable code in do_ldst_quad()


From: Peter Maydell
Subject: Re: [PATCH v2 1/1] target/ppc: fix unreachable code in do_ldst_quad()
Date: Thu, 4 Aug 2022 19:05:40 +0100

On Mon, 25 Jul 2022 at 21:24, Daniel Henrique Barboza
<danielhb413@gmail.com> wrote:
>
> Coverity reports that commit fc34e81acd51 ("target/ppc: add macros to
> check privilege level") turned the following code unreachable:
>
> if (!prefixed && !(ctx->insns_flags2 & PPC2_LSQ_ISA207)) {
>     /* lq and stq were privileged prior to V. 2.07 */
>     REQUIRE_SV(ctx);
>
> >>>     CID 1490757:  Control flow issues  (UNREACHABLE)
> >>>     This code cannot be reached: "if (ctx->le_mode) {
>     if (ctx->le_mode) {
>         gen_align_no_le(ctx);
>         return true;
>     }
> }
>
> This happens because the macro REQUIRE_SV(), in CONFIG_USER_MODE, will
> always result in a 'return true' statement. In fact, all REQUIRE_*
> macros for target/ppc/translate.c behave the same way: if a condition
> isn't met, an exception is generated and a 'return' statement is issued.
>
> The difference is that all other callers are using it in insns that are
> not implemented in user mode. do_ldst_quad(), on the other hand, is user
> mode compatible.

This is a Coverity false positive, and I'd already marked it that way
in the Coverity UI back on the 20th. Coverity gets confused sometimes
by ifdeffery.

So you don't need this patch, unless you think the code is genuinely
better (more readable to humans, etc) this way.

thanks
-- PMM



reply via email to

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