mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Valdis.Kletnieks@vt.edu
To: Aurelien Jarno <aurelien@aurel32.net>
Cc: Gleb Natapov <gleb@kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	x86@kernel.org, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Aruna Hewapathirane <aruna.hewapathirane@gmail.com>
Subject: Re: Silence compiler warning in arch/x86/kvm/emulate.c
Date: Fri, 19 Feb 2016 12:54:00 -0500	[thread overview]
Message-ID: <10537.1455904440@turing-police.cc.vt.edu> (raw)
In-Reply-To: <20160219164548.GA28630@aurel32.net>

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

On Fri, 19 Feb 2016 17:45:48 +0100, Aurelien Jarno said:
> On 2016-02-19 12:11, Aurelien Jarno wrote:


> Actually the same patch with a bit more context shows the issue:
>
> > diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> > index e7a4fde..b372a75 100644
> > --- a/arch/x86/kvm/emulate.c
> > +++ b/arch/x86/kvm/emulate.c
> > @@ -647,12 +647,13 @@ static __always_inline int __linearize(struct x86_emu
late_ctxt *ctxt,
> >  	bool usable;
> >  	ulong la;
> >  	u32 lim;
> >  	u16 sel;
> >
> >  	la = seg_base(ctxt, addr.seg) + addr.ea;
> > +	*linear = la;
>
> The assignation is moved here...
>
> >  	*max_size = 0;
> >  	switch (mode) {
> >  	case X86EMUL_MODE_PROT64:
> >  		if (is_noncanonical_address(la))
> >  			goto bad;
> >
> > @@ -690,13 +691,12 @@ static __always_inline int __linearize(struct x86_emulate_ctxt *ctxt,
> >  		}
> >  		la &= (u32)-1;
>
> ... while the value of la might be modified in between.

(trying to reconstruct my thought process from 6 months ago.  I remember
staring at that, and I convinced myself it was still OK to move the assignment.)

la can get changed here - but there's 2 cases to consider.  If it's in a 32-bit
kernel, anding with -1 is a no-op.

Now if we're on a 64-bit kernel, the 'and' clears the high 32 bits.

But under what conditions is 'la' a 64-bit quantity that has
any bits set in the high 32 bits (meaning it's a pointer to something
over the 4G line) - but it's still valid to smash those bits?



[-- Attachment #2: Type: application/pgp-signature, Size: 848 bytes --]

  reply	other threads:[~2016-02-19 17:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-29 21:49 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 [this message]
2016-02-19 17:56       ` Paolo Bonzini
2016-02-20  0:33         ` Valdis.Kletnieks

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=10537.1455904440@turing-police.cc.vt.edu \
    --to=valdis.kletnieks@vt.edu \
    --cc=aruna.hewapathirane@gmail.com \
    --cc=aurelien@aurel32.net \
    --cc=gleb@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=x86@kernel.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

all inboxes | Powered by JetHome®