qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Daniel Henrique Barboza <danielhb413@gmail.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	qemu-ppc@nongnu.org, qemu-devel@nongnu.org, clg@kaod.org
Subject: Re: [PATCH v2 2/4] target/ppc: init 'lpcr' in kvmppc_enable_cap_large_decr()
Date: Thu, 31 Mar 2022 12:25:29 +1100	[thread overview]
Message-ID: <YkUDCdUsjjmzFgJr@yekko> (raw)
In-Reply-To: <20220331001717.616938-3-danielhb413@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2378 bytes --]

On Wed, Mar 30, 2022 at 09:17:15PM -0300, Daniel Henrique Barboza wrote:
> 'lpcr' is used as an input of kvm_get_one_reg(). Valgrind doesn't
> understand that and it returns warnings as such for this function:
> 
> ==55240== Thread 1:
> ==55240== Conditional jump or move depends on uninitialised value(s)
> ==55240==    at 0xB011E4: kvmppc_enable_cap_large_decr (kvm.c:2546)
> ==55240==    by 0x92F28F: cap_large_decr_cpu_apply (spapr_caps.c:523)
> ==55240==    by 0x930C37: spapr_caps_cpu_apply (spapr_caps.c:921)
> ==55240==    by 0x955D3B: spapr_reset_vcpu (spapr_cpu_core.c:73)
> ==55240==    by 0x95612B: spapr_cpu_core_reset (spapr_cpu_core.c:209)
> ==55240==    by 0x95619B: spapr_cpu_core_reset_handler (spapr_cpu_core.c:218)
> ==55240==    by 0xD3605F: qemu_devices_reset (reset.c:69)
> ==55240==    by 0x92112B: spapr_machine_reset (spapr.c:1641)
> ==55240==    by 0x4FBD63: qemu_system_reset (runstate.c:444)
> ==55240==    by 0x62812B: qdev_machine_creation_done (machine.c:1247)
> ==55240==    by 0x5064C3: qemu_machine_creation_done (vl.c:2725)
> ==55240==    by 0x5065DF: qmp_x_exit_preconfig (vl.c:2748)
> ==55240==  Uninitialised value was created by a stack allocation
> ==55240==    at 0xB01158: kvmppc_enable_cap_large_decr (kvm.c:2540)
> 
> Init 'lpcr' to avoid this warning.

Hmm... this is seeming a bit like whack-a-mole.  Could we instead use
one of the valgrind hinting mechanisms to inform it that
kvm_get_one_reg() writes the variable at *target?

> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---
>  target/ppc/kvm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
> index 858866ecd4..42814e1b97 100644
> --- a/target/ppc/kvm.c
> +++ b/target/ppc/kvm.c
> @@ -2538,7 +2538,7 @@ int kvmppc_get_cap_large_decr(void)
>  int kvmppc_enable_cap_large_decr(PowerPCCPU *cpu, int enable)
>  {
>      CPUState *cs = CPU(cpu);
> -    uint64_t lpcr;
> +    uint64_t lpcr = 0;
>  
>      kvm_get_one_reg(cs, KVM_REG_PPC_LPCR_64, &lpcr);
>      /* Do we need to modify the LPCR? */

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2022-03-31  1:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-31  0:17 [PATCH v2 0/4] ppc: valgrind "uninitialized values" fixes Daniel Henrique Barboza
2022-03-31  0:17 ` [PATCH v2 1/4] target/ppc: initialize 'val' union in kvm_get_one_spr() Daniel Henrique Barboza
2022-03-31  1:20   ` David Gibson
2022-03-31  0:17 ` [PATCH v2 2/4] target/ppc: init 'lpcr' in kvmppc_enable_cap_large_decr() Daniel Henrique Barboza
2022-03-31  1:25   ` David Gibson [this message]
2022-03-31 17:17     ` Daniel Henrique Barboza
2022-03-31 17:36       ` Richard Henderson
2022-03-31 18:46         ` Daniel Henrique Barboza
2022-04-01  3:40           ` David Gibson
2022-04-05 19:37             ` Daniel Henrique Barboza
2022-04-01  3:38       ` David Gibson
2022-03-31  0:17 ` [PATCH v2 3/4] target/ppc: init 'sregs' in kvmppc_put_books_sregs() Daniel Henrique Barboza
2022-03-31  0:17 ` [PATCH v2 4/4] target/ppc: init 'rmmu_info' in kvm_get_radix_page_info() Daniel Henrique Barboza

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=YkUDCdUsjjmzFgJr@yekko \
    --to=david@gibson.dropbear.id.au \
    --cc=clg@kaod.org \
    --cc=danielhb413@gmail.com \
    --cc=f4bug@amsat.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).