From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F632C4167B for ; Wed, 30 Nov 2022 01:28:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 83D6B6B0072; Tue, 29 Nov 2022 20:28:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7EC776B0073; Tue, 29 Nov 2022 20:28:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B4076B0074; Tue, 29 Nov 2022 20:28:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 5EF896B0072 for ; Tue, 29 Nov 2022 20:28:46 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 2929CA07DB for ; Wed, 30 Nov 2022 01:28:46 +0000 (UTC) X-FDA: 80188374252.05.BC95818 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by imf12.hostedemail.com (Postfix) with ESMTP id A636040013 for ; Wed, 30 Nov 2022 01:28:45 +0000 (UTC) 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: ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=shutemov.name header.s=fm3 header.b=rdL3sbh9; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=Nelvuy4D; spf=pass (imf12.hostedemail.com: domain of kirill@shutemov.name designates 66.111.4.28 as permitted sender) smtp.mailfrom=kirill@shutemov.name; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669771725; a=rsa-sha256; cv=none; b=q0eaDSOxL5qoCMwCBcSJjfz9QsuKuVJEBHhT8ACXHP/J4oNl/HO+yNyxJv/Q4XuzzKVrUm yNr3kzSR9SPzm+ILgX+OlchSByMHicNn2BvwPj5ktikeEsZhB0WxcJ41sk8Ea74FmPxF+I D6bFFAHiKb3YBQBzXi6srd2mb891gQM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669771725; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=N3PhtsYK5SSpRrnjY3chFLqAm0o6zorAXR4hySwwKpU=; b=p0jyConTcy5jXMXuTw9o/v3ilzNh3qC4enQvUvgSroupBmTP0ZbUemxwCd8ibfmHYrYETV BY5Cf6jnup7q44QwmWIHndI6JIbqxa9QRVGO16PH5ebnDF1nXYmSIO9FVarj0GvJtcpOcK +y2CGEi0QYFpPNmznKvPByEPn9CTaLU= Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=shutemov.name header.s=fm3 header.b=rdL3sbh9; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=Nelvuy4D; spf=pass (imf12.hostedemail.com: domain of kirill@shutemov.name designates 66.111.4.28 as permitted sender) smtp.mailfrom=kirill@shutemov.name; dmarc=none X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: A636040013 X-Stat-Signature: 9shuh9wpx8g7w5u8cwhdycapu9gsdhs7 X-Rspam-User: X-HE-Tag: 1669771725-620689 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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