Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1338109

Re: Silence compiler warning in arch/x86/kvm/emulate.c

From Aurelien Jarno <aurelien@aurel32.net>
Newsgroups linux.kernel
Subject Re: Silence compiler warning in arch/x86/kvm/emulate.c
Date 2016-02-19 13:00 +0100
Message-ID <r3RT5-4A8-47@gated-at.bofh.it> (permalink)
References <q2Wkj-67e-27@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 2015-08-29 17:49, Valdis Kletnieks wrote:
> 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)
> 

Unfortunately this patch broke GNU/Hurd when running under KVM. It fails
to boot almost immediately. I haven't debug it more, but it looks like
*linear should not always be written. This can easily be reproduced by
trying to boot Debian Installer from this ISO:

http://ftp.debian-ports.org/debian-cd/hurd-i386/debian-hurd-2015/debian-hurd-2015-i386-CD-1.iso

Aurelien

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                 http://www.aurel32.net

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Silence compiler warning in  arch/x86/kvm/emulate.c Aurelien Jarno <aurelien@aurel32.net> - 2016-02-19 13:00 +0100
  Re: Silence compiler warning in arch/x86/kvm/emulate.c Paolo Bonzini <pbonzini@redhat.com> - 2016-02-19 13:10 +0100
    Re: Silence compiler warning in arch/x86/kvm/emulate.c Aurelien Jarno <aurelien@aurel32.net> - 2016-02-19 18:10 +0100
  Re: Silence compiler warning in  arch/x86/kvm/emulate.c Aurelien Jarno <aurelien@aurel32.net> - 2016-02-19 17:50 +0100
    Re: Silence compiler warning in arch/x86/kvm/emulate.c Valdis.Kletnieks@vt.edu - 2016-02-19 19:00 +0100
      Re: Silence compiler warning in arch/x86/kvm/emulate.c Paolo Bonzini <pbonzini@redhat.com> - 2016-02-19 19:00 +0100
        Re: Silence compiler warning in arch/x86/kvm/emulate.c Valdis.Kletnieks@vt.edu - 2016-02-20 01:40 +0100

csiph-web