linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Silence compiler warning in  arch/x86/kvm/emulate.c
@ 2015-08-29 21:49 Valdis Kletnieks
  2016-02-19 11:11 ` Aurelien Jarno
  0 siblings, 1 reply; 8+ messages in thread
From: Valdis Kletnieks @ 2015-08-29 21:49 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini; +Cc: x86, kvm, linux-kernel, Aruna Hewapathirane

Compiler warning:

 CC [M]  arch/x86/kvm/emulate.o
arch/x86/kvm/emulate.c: In function "__do_insn_fetch_bytes":
arch/x86/kvm/emulate.c:814:9: warning: "linear" may be used uninitialized in this function [-Wmaybe-uninitialized]

GCC is smart enough to realize that the inlined __linearize may return before
setting the value of linear, but not smart enough to realize the same
X86EMU_CONTINUE blocks actual use of the value.  However, the value of
'linear' can only be set to one value, so hoisting the one line of code
upwards makes GCC happy with the code.

Reported-by: Aruna Hewapathirane <aruna.hewapathirane@gmail.com>
Tested-by: Aruna Hewapathirane <aruna.hewapathirane@gmail.com>
Signed-off-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>

--- a/arch/x86/kvm/emulate.c.dist	2015-08-11 14:10:05.366061993 -0400
+++ b/arch/x86/kvm/emulate.c	2015-08-29 13:43:13.014163958 -0400
@@ -650,6 +650,7 @@ static __always_inline int __linearize(s
 	u16 sel;
 
 	la = seg_base(ctxt, addr.seg) + addr.ea;
+	*linear = la;
 	*max_size = 0;
 	switch (mode) {
 	case X86EMUL_MODE_PROT64:
@@ -693,7 +694,6 @@ static __always_inline int __linearize(s
 	}
 	if (insn_aligned(ctxt, size) && ((la & (size - 1)) != 0))
 		return emulate_gp(ctxt, 0);
-	*linear = la;
 	return X86EMUL_CONTINUE;
 bad:
 	if (addr.seg == VCPU_SREG_SS)


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

end of thread, other threads:[~2016-02-20  0:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-29 21:49 Silence compiler warning in arch/x86/kvm/emulate.c Valdis Kletnieks
2016-02-19 11:11 ` Aurelien Jarno
2016-02-19 12:05   ` Paolo Bonzini
2016-02-19 17:04     ` Aurelien Jarno
2016-02-19 16:45   ` Aurelien Jarno
2016-02-19 17:54     ` Valdis.Kletnieks
2016-02-19 17:56       ` Paolo Bonzini
2016-02-20  0:33         ` Valdis.Kletnieks

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