Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1699416rwb; Tue, 29 Nov 2022 18:04:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf5f+yQi3sN9r19SNmkSZ+RR5KTp/U/cg0aU4RcB8tAxzbHpx5TRuC0cW3bEAJQq8KrUg2/P X-Received: by 2002:a05:6402:5007:b0:44e:baab:54e7 with SMTP id p7-20020a056402500700b0044ebaab54e7mr37996100eda.265.1669773865636; Tue, 29 Nov 2022 18:04:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669773865; cv=none; d=google.com; s=arc-20160816; b=KG4M6jGgx4yRBId4JrPOMQnZRh2a4X2Q+00OQ11j3OCpgpo4vW0uMH7OVGpgWQbN0M U+a8d75FbIv5Peyp9dfvX0Pci2UsA5gxnFFQiiyXNlreZ7jqEk80W9s8+vnXVJ03e+k+ 4P3Ze9Ph7MgRDYfLD6/KfiUDOftOTSDF5OVFlsYSGWH0q1lj9rwBAOTh0ZL6npZ3mYlU I6Z2pUQBCH3ggsFPfvDdpJysLvG7TPtVAz74RMUoWuIkU/p2mIZVAnL+D+ICMXdZ02Ih 8QEJavrLf5TKZjlWEk48KjrlWLNIQpcvESUOzKR6AlreUS8M7EI3nRLFTYqyAqp5NsJz oMZA== 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:feedback-id :dkim-signature:dkim-signature; bh=N3PhtsYK5SSpRrnjY3chFLqAm0o6zorAXR4hySwwKpU=; b=zotGzncQ6FHxV0sGhbnN5t5vkO5sYIL0CpjYeZzZw9QhpwW2wAfkRfb5avGoovYVd1 gXdqnxBbFvm5N3OG0xgA/KxN30AOuHBp6weYKVVdcjjZpk/T6LwopH50rVZiwNHXkadP RHYIrjvQSOtJvtmNYJHNSFr5/huEaFQMBOiC9zLFaxsqwW37HL8EOXYGZHQ9rCB9PTLq vlV78BB4mCNkhLCP9Oefs4OYCj8mZtsOokK4y57+iJ/Flt4k/boOtfGNjZMNWpNKgThd 59m+YSIdhT5Fxms4c1U0i8oqKGNsLX6RboYjSQsr7CB8bNAt0dyc3yL/ZQr5I1mmQvas +fnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm3 header.b=rdL3sbh9; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=Nelvuy4D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cr16-20020a170906d55000b00730aa841c5bsi151246ejc.964.2022.11.29.18.04.04; Tue, 29 Nov 2022 18:04:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm3 header.b=rdL3sbh9; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=Nelvuy4D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231489AbiK3B24 (ORCPT + 85 others); Tue, 29 Nov 2022 20:28:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229565AbiK3B2t (ORCPT ); Tue, 29 Nov 2022 20:28:49 -0500 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A73F5F46; Tue, 29 Nov 2022 17:28:48 -0800 (PST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id EA4765C0095; Tue, 29 Nov 2022 20:28:44 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 29 Nov 2022 20:28:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov.name; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1669771724; x=1669858124; bh=N3 PhtsYK5SSpRrnjY3chFLqAm0o6zorAXR4hySwwKpU=; b=rdL3sbh9Z+Gu6G6+xq Uk8Jrg76SkC24pupDzOkg3w4h7iV0y3m98HRrliySxdtKfeFfmxhWeLLlMtQKaxt VvjiRqUcgUj3od4l5HVR0VxkSFRJ/q7aebkYjm7SFmgZN4uJwYeLZOCVtXOxhmbg LbsnN+TjJUNU/vOoLIJffxVd52VydTHtv98F3kLMClETo/dITSLPQuh7GISrKCmv 2SqmSv+YwP5vvNLHgTlR90GylsTLb1sPA5ttHZilIbnGBCu5xSndoYtLEfBPDtQh ia2Sfp4s9SblGeOfjTvVtirAYPamyzdWYRzJ8OWTncg7SSMEMAYH0WJUguQRElBP nNbw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1669771724; x=1669858124; bh=N3PhtsYK5SSpRrnjY3chFLqAm0o6 zorAXR4hySwwKpU=; b=Nelvuy4D1HjsnimfhXJhbyrSXUjm5UPHrBdOi2vwjEc7 3b2nQFrE5iQmzzVOLlYIbJjQ6lsZjZn5F9XGBLXIzrorV1iAVYMfyLRxg3y9wuzh LNj+RpiFLctbQ73AzV7R1jDH7tvh72AJJQ2aKsxfIPDjJiR5HH/JwYWB5NjpTwrN 3ZkO56oGzAg/Ef+J2KZzyE/xErAqJsBwYTMtR+vnnGpwwHRnKZpvI6VzLa9ePBn7 auVy7ubpmlnvWN5ARgNDgDJLb9TQ6RCYVdJEqdHaujVFwlv11YLep2JanRAbbeAR 11NyWs7pxBAl6JOjtBVa8VvFnPkNkwaNwhv8/DO++Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrtddvgdefgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehttddttddttddvnecuhfhrohhmpedfmfhirhhi lhhlucetrdcuufhhuhhtvghmohhvfdcuoehkihhrihhllhesshhhuhhtvghmohhvrdhnrg hmvgeqnecuggftrfgrthhtvghrnhephfeigefhtdefhedtfedthefghedutddvueehtedt tdehjeeukeejgeeuiedvkedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepkhhirhhilhhlsehshhhuthgvmhhovhdrnhgrmhgv X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 29 Nov 2022 20:28:43 -0500 (EST) Received: by box.shutemov.name (Postfix, from userid 1000) id 73174103BF4; Wed, 30 Nov 2022 04:28:40 +0300 (+03) Date: Wed, 30 Nov 2022 04:28:40 +0300 From: "Kirill A. Shutemov" To: Borislav Petkov Cc: "Kirill A. Shutemov" , 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 , Dave Hansen , Mike Rapoport , David Hildenbrand , marcelo.cerri@canonical.com, tim.gardner@canonical.com, khalid.elmously@canonical.com, philip.cox@canonical.com, x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Mike Rapoport Subject: Re: [PATCHv7 08/14] x86/mm: Reserve unaccepted memory bitmap Message-ID: <20221130012840.sf4rvddzc4ev7bj5@box.shutemov.name> References: <20220614120231.48165-1-kirill.shutemov@linux.intel.com> <20220614120231.48165-9-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 26, 2022 at 11:07:14AM +0200, Borislav Petkov wrote: > On Tue, Jun 14, 2022 at 03:02:25PM +0300, Kirill A. Shutemov wrote: > > diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c > > index f267205f2d5a..22d1fe48dcba 100644 > > --- a/arch/x86/kernel/e820.c > > +++ b/arch/x86/kernel/e820.c > > @@ -1316,6 +1316,16 @@ void __init e820__memblock_setup(void) > > int i; > > u64 end; > > > > + /* 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); > > + } > > + > > Hmm, I don't like how this is dropped right in the middle of a unrelated > function. > > You're adding arch/x86/mm/unaccepted_memory.c later. Why don't you put > that chunk in a function there which is called by early_reserve_memory() > which does exactly what you want - reserve memory early, before memblock > allocations? early_reserve_memory() specifically called before e820__memory_setup() (see comment in setup_arch()), so we don't have e820_table finalized and we need it to get correct RAM size from e820__end_of_ram_pfn(). I guess we can hide the chunk in a function in unaccepted_memory.c and call it from here, but it would require #ifdeffery in a header file as the .c is only compiled for CONFIG_UNACCEPTED_MEMORY=y. Looks like an overkill to me, no? -- Kiryl Shutsemau / Kirill A. Shutemov