From patchwork Mon Jun 3 22:02:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 10974023 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CAC56933 for ; Mon, 3 Jun 2019 22:04:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B721828710 for ; Mon, 3 Jun 2019 22:04:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A629E28736; Mon, 3 Jun 2019 22:04:16 +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=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1B65C28710 for ; Mon, 3 Jun 2019 22:04:16 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hXv2X-0003T1-9d; Mon, 03 Jun 2019 22:02:49 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hXv2W-0003Se-Ka for xen-devel@lists.xenproject.org; Mon, 03 Jun 2019 22:02:48 +0000 X-Inumbo-ID: 528f03cc-864b-11e9-b291-5f2b851eba2e Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 528f03cc-864b-11e9-b291-5f2b851eba2e; Mon, 03 Jun 2019 22:02:48 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0D81923E77; Mon, 3 Jun 2019 22:02:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559599367; bh=3CCUvl0LQ/WFZ3gY9nIlwyemZpPkp3hn2VdsDAJkuhI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hQZnlPB7u3xrrwHYCHjIg2oMgd6VeycOyuaItpE7H4MYIq8D92f/JYOYq9N5f33pO so4usxlrvoYXG6fN56jCknCGhF/ZxXRjKx1nsIGdvNeWU3G5ScBfMZJkiDi+vBPt4X wisH6HcKn6MvOKO/fAMIk3/6dzKAjoHrsL4/MzbI= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Mon, 3 Jun 2019 15:02:44 -0700 Message-Id: <20190603220245.22750-2-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v3 2/3] xen: actually skip the first MAX_ORDER bits in pfn_pdx_hole_setup X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , sstabellini@kernel.org, wei.liu2@citrix.com, konrad.wilk@oracle.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, tim@xen.org, julien.grall@arm.com, JBeulich@suse.com MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP pfn_pdx_hole_setup is meant to skip the first MAX_ORDER bits, but actually it only skips the first MAX_ORDER-1 bits. The issue was probably introduced by bdb5439c3f ("x86_64: Ensure frame-table compression leaves MAX_ORDER aligned"), when changing to loop to start from MAX_ORDER-1 an adjustment by 1 was needed in the call to find_next_bit() but not done. Fix the issue by passing j+1 and i+1 to find_next_zero_bit and find_next_bit. Also add a check for i >= BITS_PER_LONG because find_{,next_}zero_bit() are free to assume that their last argument is less than their middle one. Signed-off-by: Stefano Stabellini Signed-off-by: Jan Beulich CC: andrew.cooper3@citrix.com CC: JBeulich@suse.com CC: George.Dunlap@eu.citrix.com CC: ian.jackson@eu.citrix.com CC: konrad.wilk@oracle.com CC: tim@xen.org CC: wei.liu2@citrix.com Acked-by: Julien Grall --- Changes in v2: - add commit title of bdb5439c3f - more CC - update commit message --- xen/common/pdx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xen/common/pdx.c b/xen/common/pdx.c index 50c21b6bf8..bb7e437049 100644 --- a/xen/common/pdx.c +++ b/xen/common/pdx.c @@ -83,8 +83,10 @@ void __init pfn_pdx_hole_setup(unsigned long mask) */ for ( j = MAX_ORDER-1; ; ) { - i = find_next_zero_bit(&mask, BITS_PER_LONG, j); - j = find_next_bit(&mask, BITS_PER_LONG, i); + i = find_next_zero_bit(&mask, BITS_PER_LONG, j + 1); + if ( i >= BITS_PER_LONG ) + break; + j = find_next_bit(&mask, BITS_PER_LONG, i + 1); if ( j >= BITS_PER_LONG ) break; if ( j - i > hole_shift )