Message ID | 1481266943-27827-1-git-send-email-liang.z.li@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Am 09.12.2016 um 08:02 schrieb Liang Li: > Use '||' is more efficient than '|' at this point. > > Signed-off-by: Liang Li <liang.z.li@intel.com> > --- > arch/x86/kvm/mmu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c > index d9c7e98..16c0b00 100644 > --- a/arch/x86/kvm/mmu.c > +++ b/arch/x86/kvm/mmu.c > @@ -3315,7 +3315,7 @@ static gpa_t nonpaging_gva_to_gpa_nested(struct kvm_vcpu *vcpu, gva_t vaddr, > { > 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); > } > > This isn't really a fix as given in the subject, is it? The != 0 is also superfluous, but not sure if these two things are really worth touching it.
> Am 09.12.2016 um 08:02 schrieb Liang Li: > > Use '||' is more efficient than '|' at this point. > > > > Signed-off-by: Liang Li <liang.z.li@intel.com> > > --- > > arch/x86/kvm/mmu.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index > > d9c7e98..16c0b00 100644 > > --- a/arch/x86/kvm/mmu.c > > +++ b/arch/x86/kvm/mmu.c > > @@ -3315,7 +3315,7 @@ static gpa_t > nonpaging_gva_to_gpa_nested(struct > > kvm_vcpu *vcpu, gva_t vaddr, { > > 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); } > > > > > > This isn't really a fix as given in the subject, is it? > > The != 0 is also superfluous, but not sure if these two things are > really worth touching it. Yes. And it's not in the critical code patch. > > -- > > David -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 09/12/2016 08:02, Liang Li wrote: > Use '||' is more efficient than '|' at this point. No, it's not, because the check is going to be always false in practice, so the || is going to evaluate both branches anyway. So, depending on the compiler, either it's the same or it's worse (because a branch is worse than an OR instruction). If anything, as David said (and if the compiled code changes at all), the "!= 0" is superfluous. Paolo > Signed-off-by: Liang Li <liang.z.li@intel.com> > --- > arch/x86/kvm/mmu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c > index d9c7e98..16c0b00 100644 > --- a/arch/x86/kvm/mmu.c > +++ b/arch/x86/kvm/mmu.c > @@ -3315,7 +3315,7 @@ static gpa_t nonpaging_gva_to_gpa_nested(struct kvm_vcpu *vcpu, gva_t vaddr, > { > 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); > } -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
PiANCj4gDQo+IE9uIDA5LzEyLzIwMTYgMDg6MDIsIExpYW5nIExpIHdyb3RlOg0KPiA+IFVzZSAn fHwnIGlzIG1vcmUgZWZmaWNpZW50IHRoYW4gJ3wnIGF0IHRoaXMgcG9pbnQuDQo+IA0KPiBObywg aXQncyBub3QsIGJlY2F1c2UgdGhlIGNoZWNrIGlzIGdvaW5nIHRvIGJlIGFsd2F5cyBmYWxzZSBp biBwcmFjdGljZSwgc28gdGhlDQo+IHx8IGlzIGdvaW5nIHRvIGV2YWx1YXRlIGJvdGggYnJhbmNo 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vdzYgPSBwdGUg JiAweDNmOw0KPiA+DQo+ID4gLQlyZXR1cm4gKHB0ZSAmIHJzdmRfY2hlY2stPnJzdmRfYml0c19t YXNrW2JpdDddW2xldmVsLTFdKSB8DQo+ID4gKwlyZXR1cm4gKHB0ZSAmIHJzdmRfY2hlY2stPnJz dmRfYml0c19tYXNrW2JpdDddW2xldmVsLTFdKSB8fA0KPiA+ICAJCSgocnN2ZF9jaGVjay0+YmFk X210X3h3ciAmICgxdWxsIDw8IGxvdzYpKSAhPSAwKTsgIH0NCg0K -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index d9c7e98..16c0b00 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -3315,7 +3315,7 @@ static gpa_t nonpaging_gva_to_gpa_nested(struct kvm_vcpu *vcpu, gva_t vaddr, { 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); }
Use '||' is more efficient than '|' at this point. Signed-off-by: Liang Li <liang.z.li@intel.com> --- arch/x86/kvm/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)