From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Arvind Sankar <nivedita@alum.mit.edu>
Cc: David Laight <David.Laight@ACULAB.COM>,
Paolo Bonzini <pbonzini@redhat.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] KVM: x86/mmu: Fix a benign Bitwise vs. Logical OR mixup
Date: Thu, 9 Jan 2020 09:24:14 -0800 [thread overview]
Message-ID: <20200109172414.GB15001@linux.intel.com> (raw)
In-Reply-To: <20200109163624.GA15001@linux.intel.com>
On Thu, Jan 09, 2020 at 08:36:24AM -0800, Sean Christopherson wrote:
> On Thu, Jan 09, 2020 at 10:26:30AM -0500, Arvind Sankar wrote:
> > On Thu, Jan 09, 2020 at 02:13:48PM +0000, David Laight wrote:
> > > From: Sean Christopherson
> > > > Sent: 08 January 2020 00:19
> > > >
> > > > Use a Logical OR in __is_rsvd_bits_set() to combine the two reserved bit
> > > > checks, which are obviously intended to be logical statements. Switching
> > > > to a Logical OR is functionally a nop, but allows the compiler to better
> > > > optimize the checks.
> > > >
> > > > Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> > > > ---
> > > > arch/x86/kvm/mmu/mmu.c | 2 +-
> > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> > > > index 7269130ea5e2..72e845709027 100644
> > > > --- a/arch/x86/kvm/mmu/mmu.c
> > > > +++ b/arch/x86/kvm/mmu/mmu.c
> > > > @@ -3970,7 +3970,7 @@ __is_rsvd_bits_set(struct rsvd_bits_validate *rsvd_check, u64 pte, int level)
> > > > {
> > > > int bit7 = (pte >> 7) & 1, low6 = pte & 0x3f;
> > > >
> > > > - return (pte & rsvd_check->rsvd_bits_mask[bit7][level-1]) |
> > > > + return (pte & rsvd_check->rsvd_bits_mask[bit7][level-1]) ||
> > > > ((rsvd_check->bad_mt_xwr & (1ull << low6)) != 0);
> > >
> > > Are you sure this isn't deliberate?
> > > The best code almost certainly comes from also removing the '!= 0'.
>
> The '!= 0' is truly superfluous, removing it doesn't affect code
> generation.
Actually, it's not completely superfluous. Functionally the code is
identical, but ordered slightly differently for whatever reason.
next prev parent reply other threads:[~2020-01-09 17:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-08 0:18 [PATCH] KVM: x86/mmu: Fix a benign Bitwise vs. Logical OR mixup Sean Christopherson
2020-01-08 10:13 ` Vitaly Kuznetsov
2020-01-08 17:50 ` Jim Mattson
2020-01-09 14:13 ` David Laight
2020-01-09 15:26 ` Arvind Sankar
2020-01-09 16:36 ` Sean Christopherson
2020-01-09 17:24 ` Sean Christopherson [this message]
2020-01-15 18:20 ` Paolo Bonzini
2020-01-08 8:37 linmiaohe
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=20200109172414.GB15001@linux.intel.com \
--to=sean.j.christopherson@intel.com \
--cc=David.Laight@ACULAB.COM \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nivedita@alum.mit.edu \
--cc=pbonzini@redhat.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
/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).