linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: PPC: Book3S HV: radix: Fix uninitialized var build error
@ 2019-01-01  3:55 Michael Ellerman
  2019-01-02 11:31 ` Michael Ellerman
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Ellerman @ 2019-01-01  3:55 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: paulus, kvm-ppc, sjitindarsingh

Old GCCs (4.6.3 at least), aren't able to follow the logic in
__kvmhv_copy_tofrom_guest_radix() and warn that old_pid is used
uninitialized:

  arch/powerpc/kvm/book3s_64_mmu_radix.c:75:3: error: 'old_pid' may be
  used uninitialized in this function

The logic is OK, we only use old_pid if quadrant == 1, and in that
case it has definitely be initialised, eg:

	if (quadrant == 1) {
		old_pid = mfspr(SPRN_PID);
	...
	if (quadrant == 1 && pid != old_pid)
		mtspr(SPRN_PID, old_pid);

Annotate it to fix the error.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/kvm/book3s_64_mmu_radix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c
index fb88167a402a..1b821c6efdef 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_radix.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c
@@ -33,8 +33,8 @@ unsigned long __kvmhv_copy_tofrom_guest_radix(int lpid, int pid,
 					      gva_t eaddr, void *to, void *from,
 					      unsigned long n)
 {
+	int uninitialized_var(old_pid), old_lpid;
 	unsigned long quadrant, ret = n;
-	int old_pid, old_lpid;
 	bool is_load = !!to;
 
 	/* Can't access quadrants 1 or 2 in non-HV mode, call the HV to do it */
-- 
2.17.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: KVM: PPC: Book3S HV: radix: Fix uninitialized var build error
  2019-01-01  3:55 [PATCH] KVM: PPC: Book3S HV: radix: Fix uninitialized var build error Michael Ellerman
@ 2019-01-02 11:31 ` Michael Ellerman
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2019-01-02 11:31 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev; +Cc: paulus, sjitindarsingh, kvm-ppc

On Tue, 2019-01-01 at 03:55:13 UTC, Michael Ellerman wrote:
> Old GCCs (4.6.3 at least), aren't able to follow the logic in
> __kvmhv_copy_tofrom_guest_radix() and warn that old_pid is used
> uninitialized:
> 
>   arch/powerpc/kvm/book3s_64_mmu_radix.c:75:3: error: 'old_pid' may be
>   used uninitialized in this function
> 
> The logic is OK, we only use old_pid if quadrant == 1, and in that
> case it has definitely be initialised, eg:
> 
> 	if (quadrant == 1) {
> 		old_pid = mfspr(SPRN_PID);
> 	...
> 	if (quadrant == 1 && pid != old_pid)
> 		mtspr(SPRN_PID, old_pid);
> 
> Annotate it to fix the error.
> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

Applied to powerpc fixes.

https://git.kernel.org/powerpc/c/f460772291f8171988b2b60141a457

cheers

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-02 11:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-01  3:55 [PATCH] KVM: PPC: Book3S HV: radix: Fix uninitialized var build error Michael Ellerman
2019-01-02 11:31 ` Michael Ellerman

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).