qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>, qemu-devel@nongnu.org
Cc: "Cédric Le Goater" <clg@kaod.org>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Daniel Henrique Barboza" <danielhb413@gmail.com>,
	qemu-ppc@nongnu.org, "Daniel P . Berrangé" <berrange@redhat.com>
Subject: Re: [RFC PATCH] target/ppc/mmu: Silent maybe-uninitialized error in ppc_hash64_xlate()
Date: Mon, 26 Feb 2024 08:43:40 +0100	[thread overview]
Message-ID: <be8a82b0-cc82-4acc-997e-753c030cb286@redhat.com> (raw)
In-Reply-To: <20240223083245.80175-1-philmd@linaro.org>

On 23/02/2024 09.32, Philippe Mathieu-Daudé wrote:
> Initialize apshift to avoid a maybe-uninitialized error:
> 
>    C compiler for the host machine: cc -m64 -mbig-endian (gcc 13.2.0 "cc (Debian 13.2.0-10) 13.2.0")
>    C linker for the host machine: cc -m64 -mbig-endian ld.bfd 2.41.90.20240115
>    Host machine cpu family: ppc64
>    Host machine cpu: ppc64
>    ...
>    target/ppc/mmu-hash64.c: In function 'ppc_hash64_xlate':
>    target/ppc/mmu-hash64.c:1154:15: error: 'apshift' may be used uninitialized [-Werror=maybe-uninitialized]
>     1154 |     *raddrp = deposit64(pte.pte1 & HPTE64_R_RPN, 0, apshift, eaddr);
>          |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    target/ppc/mmu-hash64.c:947:14: note: 'apshift' was declared here
>      947 |     unsigned apshift;
>          |              ^~~~~~~
> 
> The call chain is:
> 
>    ppc_hash64_xlate -> ppc_hash64_htab_lookup -> ppc_hash64_pteg_search
> 
> ppc_hash64_pteg_search() either sets *pshift or returns -1,
> 
> ppc_hash64_htab_lookup() returns if ppc_hash64_pteg_search()
> returned -1:
> 
>    1068:    ptex = ppc_hash64_htab_lookup(cpu, slb, eaddr, &pte, &apshift);
>    1069:    if (ptex == -1) {
>    1070:        if (!guest_visible) {
>    1071:            return false;
>    1072:        }
>                 ...
>    1087:        return false;
> 
> So IIUC this "uninitialized use" can not happens.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> I had this in an old branch (2 months old) I just rebased,
> and don't get why nobody else got this error yet.

That's weird, indeed. Did you maybe compile without optimizations when you 
hit the error?

  Thomas




      reply	other threads:[~2024-02-26  7:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-23  8:32 [RFC PATCH] target/ppc/mmu: Silent maybe-uninitialized error in ppc_hash64_xlate() Philippe Mathieu-Daudé
2024-02-26  7:43 ` Thomas Huth [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=be8a82b0-cc82-4acc-997e-753c030cb286@redhat.com \
    --to=thuth@redhat.com \
    --cc=berrange@redhat.com \
    --cc=clg@kaod.org \
    --cc=danielhb413@gmail.com \
    --cc=npiggin@gmail.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).