RE: [PATCH] kvm/mmu: small fix for reserved bits check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Thanks for clarification.

> If anything, as David said (and if the compiled code changes at all), the "!= 0"
> is superfluous.
> 

Yes, it makes the code looks strange. 

> Paolo
> 
> > Signed-off-by: Liang Li <liang.z.li@xxxxxxxxx>
> > ---
> >  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);  }

��.n��������+%������w��{.n�����o�^n�r������&��z�ޗ�zf���h���~����������_��+v���)ߣ�

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux