From patchwork Fri Nov 14 09:31:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiejun Chen X-Patchwork-Id: 5304321 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1654EC11AC for ; Fri, 14 Nov 2014 09:36:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5401220149 for ; Fri, 14 Nov 2014 09:36:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6DA432010F for ; Fri, 14 Nov 2014 09:36:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754896AbaKNJgi (ORCPT ); Fri, 14 Nov 2014 04:36:38 -0500 Received: from mga11.intel.com ([192.55.52.93]:27734 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754643AbaKNJgg (ORCPT ); Fri, 14 Nov 2014 04:36:36 -0500 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 14 Nov 2014 01:36:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,384,1413270000"; d="scan'208";a="631878538" Received: from tchen0-linux.bj.intel.com ([10.238.135.72]) by fmsmga002.fm.intel.com with ESMTP; 14 Nov 2014 01:36:35 -0800 From: Tiejun Chen To: pbonzini@redhat.com Cc: kvm@vger.kernel.org Subject: [RFC][PATCH 1/2] kvm: x86: mmu: return zero if s > e in rsvd_bits() Date: Fri, 14 Nov 2014 17:31:27 +0800 Message-Id: <1415957488-27490-1-git-send-email-tiejun.chen@intel.com> X-Mailer: git-send-email 1.9.1 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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; }