From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Chen, Tiejun" Subject: Re: [RFC][PATCH 1/2] kvm: x86: mmu: return zero if s > e in rsvd_bits() Date: Mon, 17 Nov 2014 09:34:30 +0800 Message-ID: <546950A6.7050603@intel.com> References: <1415957488-27490-1-git-send-email-tiejun.chen@intel.com> <5465D42C.6080900@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Paolo Bonzini Return-path: Received: from mga11.intel.com ([192.55.52.93]:58310 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751946AbaKQBec (ORCPT ); Sun, 16 Nov 2014 20:34:32 -0500 In-Reply-To: <5465D42C.6080900@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 2014/11/14 18:06, Paolo Bonzini wrote: > > > On 14/11/2014 10:31, Tiejun Chen wrote: >> In some real scenarios 'start' may not be less than 'end' like >> maxphyaddr = 52. >> >> Signed-off-by: Tiejun Chen >> --- >> arch/x86/kvm/mmu.h | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h >> index bde8ee7..0e98b5e 100644 >> --- a/arch/x86/kvm/mmu.h >> +++ b/arch/x86/kvm/mmu.h >> @@ -58,6 +58,8 @@ >> >> static inline u64 rsvd_bits(int s, int e) >> { >> + if (unlikely(s > e)) >> + return 0; >> return ((1ULL << (e - s + 1)) - 1) << s; >> } >> >> > > s == e + 1 is supported: > > (1ULL << (e - (e + 1) + 1)) - 1) << s == (1ULL << (e - (e + 1) + 1)) - 1) << s = (1ULL << (e - e - 1) + 1)) - 1) << s = (1ULL << (-1) + 1)) - 1) << s = (1ULL << (0) - 1) << s = (1ULL << (- 1) << s Am I missing something? Thanks Tiejun > (1ULL << 0) << s == > 0 > > Is there any case where s is even bigger? > > Paolo > -- > 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 >