Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2052750pxb; Sun, 16 Jan 2022 08:22:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHMne+l+rBajE0WGO9pUR7HprcvMaqGZA+bts1c5lFSPjyZKBK9mZHq6H5Wqgp+YAYreWL X-Received: by 2002:a65:66c5:: with SMTP id c5mr7145292pgw.126.1642350135297; Sun, 16 Jan 2022 08:22:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642350135; cv=none; d=google.com; s=arc-20160816; b=tL9xqprgMtV76n5+tlE+SM7+gW3f0iISXOvjmSfoSplPrSr+VzZwpCf5kO1S6grKHx Nq5MCeo3RlS0MmNT0fUlOVi8qMD1QQFRBmUuwsL3/VJjOl9xB3x19BsscpP8DVlyOAsY MsMwDSAycBFrwNksexO+Vevn4YLq94us8VKIhDjCkzKK39WSIJjstnYlCVf8viDT8ZN+ S5d0ATiWPVFbb9ZFwx5ZAHIY3Fv2PCFRuTeQyp8HHSxGlbxPUm0Iq154jdWOfHhVAGdR Dxo0BYbK6+EnJ/il2rS4cRwmYYxUic0VdklBcIb0nNBLxqJ8O29KFj+V3c650nlA66jG vZ+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=K+sh0I3FxifPGgTxWMv/sqyqlKaI4dFlHwHCyHR5xow=; b=EOUuFe1VIfPqYiRYiiXUpD5WujX+XbSGpfBd9aSmud7ysIs7Dz3lJTKMumqaOlyZiO 7PwiFlIu4s0Vke/B2lUwZW7ej0XTOsqiRjvHmu4nkGHEqekCH0qBwtld5DJOTRQYxKbE vFkHEezB6mvLy83Ru1Ks7XU5VRooy7wl2hLHc2Z2cWBm0aMpUZcIg80pbhHQNkP1fk9a yL6ik+d0wq7kuHBLSoTpDmjkb/xHGfNtpPRIsgqj+/0EGwPzBGZYQLboM+O+w3msktOY qTgrtU0LV7/1sTCNI7PJuIyVsfqc/DsNfAGfs9LymdEAslxnEoQ/71t4ZrrqVIMGeBeM zaVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QgOYeZ6Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bj16si17236771pjb.0.2022.01.16.08.22.03; Sun, 16 Jan 2022 08:22:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QgOYeZ6Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233437AbiAOSrl (ORCPT + 99 others); Sat, 15 Jan 2022 13:47:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229959AbiAOSri (ORCPT ); Sat, 15 Jan 2022 13:47:38 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 044CDC061574; Sat, 15 Jan 2022 10:47:38 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9926E60ECD; Sat, 15 Jan 2022 18:47:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E82A1C36AE5; Sat, 15 Jan 2022 18:47:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642272457; bh=PxfF8TCrDJEZRPlh4OejGOyk1YzIClKiOQC3iEvEi4w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QgOYeZ6YDGtDusiSwXekCP9ueSZ7jXs1HhzPRrtIPaIq7pXn8YdDIJ1VKicOJY59Y 5N5tWjCjuwvqXhZyaiUaueostvvaikTSyS1iEsT6jUJpN9eoVmgd3DnsXm69dr5DPB OUabH8whMSW8Wju1x05nG7aR8TmOFJPiw3SplQq4oHDY3oSLLRfKD13cBM9PlFsdAI 2wNt03PV9gEjZonlMlFQjHVJrgH8ybrkhyJD5jzNFaBQAM6R/lcFlrGjXGmkBOLtvp OEOed0ocnBp2fDWFhtwgh16/a/qa71tL2W0zZAV0bbPOf716SZctUw0ZdXhH8baHC2 ob4k+0VXJqTig== Date: Sat, 15 Jan 2022 20:46:57 +0200 From: Mike Rapoport To: Dave Hansen Cc: "Kirill A. Shutemov" , "Kirill A. Shutemov" , Borislav Petkov , Andy Lutomirski , Sean Christopherson , Andrew Morton , Joerg Roedel , Ard Biesheuvel , Andi Kleen , Kuppuswamy Sathyanarayanan , David Rientjes , Vlastimil Babka , Tom Lendacky , Thomas Gleixner , Peter Zijlstra , Paolo Bonzini , Ingo Molnar , Varad Gautam , Dario Faggioli , x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv2 5/7] x86/mm: Reserve unaccepted memory bitmap Message-ID: References: <20220111113314.27173-1-kirill.shutemov@linux.intel.com> <20220111113314.27173-6-kirill.shutemov@linux.intel.com> <3a361a1d-0e14-8884-c5bb-90aeb87e38ef@intel.com> <20220112194302.cyxhjypsptr4mtix@box.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 12, 2022 at 11:53:42AM -0800, Dave Hansen wrote: > On 1/12/22 11:43 AM, Kirill A. Shutemov wrote: > > On Tue, Jan 11, 2022 at 11:10:40AM -0800, Dave Hansen wrote: > >> On 1/11/22 03:33, Kirill A. Shutemov wrote: > >> > >>> + /* Mark unaccepted memory bitmap reserved */ > >>> + if (boot_params.unaccepted_memory) { > >>> + unsigned long size; > >>> + > >>> + /* One bit per 2MB */ > >>> + size = DIV_ROUND_UP(e820__end_of_ram_pfn() * PAGE_SIZE, > >>> + PMD_SIZE * BITS_PER_BYTE); > >>> + memblock_reserve(boot_params.unaccepted_memory, size); > >>> + } > >> > >> Is it OK that the size of the bitmap is inferred from > >> e820__end_of_ram_pfn()? Is this OK in the presence of mem= and other things > >> that muck with the e820? > > > > Good question. I think we are fine. If kernel is not able to allocate > > memory from a part of physical address space we don't need the bitmap for > > it either. > > That's a good point. If the e820 range does a one-way shrink it's > probably fine. The only problem would be if the bitmap had space for > for stuff past e820__end_of_ram_pfn() *and* it later needed to be accepted. It's unlikely, but e820 can grow because of EFI and because of memmap=. To be completely on the safe side, the unaccepted bitmap should be reserved after parse_early_param() and efi_memblock_x86_reserve_range(). Since we anyway do not have memblock allocations before e820__memblock_setup(), the simplest thing would be to put the reservation first thing in e820__memblock_setup(). -- Sincerely yours, Mike.