From patchwork Mon Sep 11 04:37:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9946559 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 68F976035D for ; Mon, 11 Sep 2017 04:41:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F8F0289DE for ; Mon, 11 Sep 2017 04:41:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54A3828AD7; Mon, 11 Sep 2017 04:41:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0702E289DE for ; Mon, 11 Sep 2017 04:41:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drGUj-00015s-Gp; Mon, 11 Sep 2017 04:38:49 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drGUi-00015h-2t for xen-devel@lists.xen.org; Mon, 11 Sep 2017 04:38:48 +0000 Received: from [193.109.254.147] by server-10.bemta-6.messagelabs.com id 91/78-03642-75316B95; Mon, 11 Sep 2017 04:38:47 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPLMWRWlGSWpSXmKPExsXS1tYhohsmvC3 S4NI7Y4slHxezODB6HN39mymAMYo1My8pvyKBNePTD6WCYxwV5z61MTUwfmTrYuTiEBKYziix +cFp1i5GTg4JAV6JI8tmQNkBEqt+7AezhQR6GSWOPw4DsdkE9CVWPD4IFhcRkJa49vkyI4jNL NDAJPH2bxGILSwQJXFj/3SwGhYBVYkFnatZQGxeAVuJQ3fmQ82Xl9jVdhHM5hSwkzj48h0zxC 5biQWnF7BOYORdwMiwilGjOLWoLLVI19hYL6koMz2jJDcxM0fX0MBMLze1uDgxPTUnMalYLzk /dxMjMBgYgGAH4871gYcYJTmYlER53x3fEinEl5SfUpmRWJwRX1Sak1p8iFGGg0NJgldFaFuk kGBRanpqRVpmDjAsYdISHDxKIryLBIHSvMUFibnFmekQqVOMxhyPbtz9w8TRcRNICrHk5eelS onzyoFMEgApzSjNgxsEi5dLjLJSwryMQKcJ8RSkFuVmlqDKv2IU52BUEua9B7KQJzOvBG7fK6 BTmIBO4bm0BeSUkkSElFQDo+cG4/O2dZXsco+TrfvdPe/mKCcWnSsvSNS2fC3e8iPstd0uyVa JJUsK2xvzlnpUCx3p/2s668YJG8moe9ye8SciLs/QX/EqU1T8X164+J+zfF7cb+59sGFYaLes 4tCb3ddeFrJGPvwndbWORS5V/9KuO7ZPRLI3HHNfZThj67ubcyb7d67OUWIpzkg01GIuKk4EA Hr3u7OSAgAA X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1505104724!103626684!1 X-Originating-IP: [134.134.136.20] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjAgPT4gMzU1MzU4\n X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 64104 invoked from network); 11 Sep 2017 04:38:46 -0000 Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by server-14.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 11 Sep 2017 04:38:46 -0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Sep 2017 21:38:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.42,376,1500966000"; d="scan'208"; a="1217078232" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.159.142]) by fmsmga002.fm.intel.com with ESMTP; 10 Sep 2017 21:38:42 -0700 From: Haozhong Zhang To: xen-devel@lists.xen.org Date: Mon, 11 Sep 2017 12:37:42 +0800 Message-Id: <20170911043820.14617-2-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170911043820.14617-1-haozhong.zhang@intel.com> References: <20170911043820.14617-1-haozhong.zhang@intel.com> Cc: Haozhong Zhang , Andrew Cooper , Jan Beulich , Chao Peng , Dan Williams Subject: [Xen-devel] [RFC XEN PATCH v3 01/39] x86_64/mm: fix the PDX group check in mem_hotadd_check() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The current check refuses the hot-plugged memory that falls in one unused PDX group, which should be allowed. Signed-off-by: Haozhong Zhang --- Cc: Jan Beulich Cc: Andrew Cooper --- xen/arch/x86/x86_64/mm.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 11746730b4..6c5221f90c 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -1296,12 +1296,8 @@ static int mem_hotadd_check(unsigned long spfn, unsigned long epfn) return 0; /* Make sure the new range is not present now */ - sidx = ((pfn_to_pdx(spfn) + PDX_GROUP_COUNT - 1) & ~(PDX_GROUP_COUNT - 1)) - / PDX_GROUP_COUNT; + sidx = (pfn_to_pdx(spfn) & ~(PDX_GROUP_COUNT - 1)) / PDX_GROUP_COUNT; eidx = (pfn_to_pdx(epfn - 1) & ~(PDX_GROUP_COUNT - 1)) / PDX_GROUP_COUNT; - if (sidx >= eidx) - return 0; - s = find_next_zero_bit(pdx_group_valid, eidx, sidx); if ( s > eidx ) return 0;