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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 153F8E95385 for ; Wed, 4 Feb 2026 11:22:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4DD776B008A; Wed, 4 Feb 2026 06:22:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 48B536B0092; Wed, 4 Feb 2026 06:22:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 38A326B0093; Wed, 4 Feb 2026 06:22:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 233566B008A for ; Wed, 4 Feb 2026 06:22:48 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D5312D56F2 for ; Wed, 4 Feb 2026 11:22:47 +0000 (UTC) X-FDA: 84406536774.22.E987820 Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf22.hostedemail.com (Postfix) with ESMTP id AAF97C0005 for ; Wed, 4 Feb 2026 11:22:45 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PUXU4qbr; spf=pass (imf22.hostedemail.com: domain of kas@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=kas@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1770204165; 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=6iOfjMvdSX9wYIVLMns6yxQ+qZN1af5L7/jjD+Lknf0=; b=woCAKQF2MdCgxMfHcxE5dztJ4S93a8PvXcgNHpjxe8tQAry3ZeyQNERj7VMl3V8InhytHi JleVyi5YH+B0LAEQzyrgU4I19EKn2DjyuwggIRWH97c7oCRA4xjo6U3u13oUc7joYa03GH 7EArz7zqjmmJWmoHKgjx+2p3YoKXaZ4= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PUXU4qbr; spf=pass (imf22.hostedemail.com: domain of kas@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=kas@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1770204165; a=rsa-sha256; cv=none; b=n+mmwOESu77kTJwymFGDfjKLLrYJbDD/bj6JBBFKBqvVFPE5BRQZvwh+f6wv4ZWiT+99md kKMC3chtv0r7vBKqRxS5Q4c1yAOcrkXpwW2lMDY+zdzsoeSggoJ5awxdYzay0f8JWzq7E9 mYMPWi8N5EMQdkn9BzFpecDu6K3zeI4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 4B19B40BB8; Wed, 4 Feb 2026 11:22:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE5A7C4AF0B; Wed, 4 Feb 2026 11:22:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770204164; bh=BJIDXXgBuKxRtpxYGYjkSIboKZRBz0aB2ToXuvdwHfM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PUXU4qbrT3jzzDesvgUaNyGjY/3Fz9r72nTElF8l7MooBGYwo+p7AQ5u2o11tb2L9 KhTHkQZV79AmyjoGVpv10zw7Mpuuq8qLCXTeDeXpeaAc9OnVZEr1gtFxLTXXrbeiQJ RJg+XDSdIdQFD/jyRW+I+vAJNoWtFz4x2z6aDUwZJyFnC5lz6xaiTdud9TFXPO2/dc Z+QpST3IvSt45ihQE/yCWZtDBjDVA379pb7YrQjgFE1NhwBfFeBDy3F3a2/ingvgdc Swk69IZDawVQUhFnknf4Qn0ZACJXVp7fl9akV7Zsrx+yOna8pw/5n8Aj7lTCpwVOAf bnyq+lbfXxkaA== Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfauth.phl.internal (Postfix) with ESMTP id E2C4AF4006A; Wed, 4 Feb 2026 06:22:42 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Wed, 04 Feb 2026 06:22:42 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddukedvfeduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepmfhirhihlhcu ufhhuhhtshgvmhgruhcuoehkrghssehkvghrnhgvlhdrohhrgheqnecuggftrfgrthhtvg hrnhepueeijeeiffekheeffffftdekleefleehhfefhfduheejhedvffeluedvudefgfek necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepkhhirh hilhhlodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdduieduudeivdeiheeh qddvkeeggeegjedvkedqkhgrsheppehkvghrnhgvlhdrohhrghesshhhuhhtvghmohhvrd hnrghmvgdpnhgspghrtghpthhtohepfedtpdhmohguvgepshhmthhpohhuthdprhgtphht thhopehprhhsrghmphgrthesrghmugdrtghomhdprhgtphhtthhopehlihhnuhigqdhmmh eskhhvrggtkhdrohhrghdprhgtphhtthhopehlihhnuhigqdgtohgtoheslhhishhtshdr lhhinhhugidruggvvhdprhgtphhtthhopeigkeeisehkvghrnhgvlhdrohhrghdprhgtph htthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgt phhtthhopehtghhlgieslhhinhhuthhrohhnihigrdguvgdprhgtphhtthhopehmihhngh hosehrvgguhhgrthdrtghomhdprhgtphhtthhopegsphesrghlihgvnhekrdguvgdprhgt phhtthhopegurghvvgdrhhgrnhhsvghnsehlihhnuhigrdhinhhtvghlrdgtohhm X-ME-Proxy: Feedback-ID: i10464835:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 4 Feb 2026 06:22:40 -0500 (EST) Date: Wed, 4 Feb 2026 11:22:35 +0000 From: Kiryl Shutsemau To: "Pratik R. Sampat" Cc: linux-mm@kvack.org, linux-coco@lists.linux.dev, x86@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, ardb@kernel.org, akpm@linux-foundation.org, david@kernel.org, osalvador@suse.de, thomas.lendacky@amd.com, michael.roth@amd.com Subject: Re: [PATCH v4 1/2] mm/memory_hotplug: Add support to accept memory during hot-add Message-ID: References: <20260203174946.1198053-1-prsampat@amd.com> <20260203174946.1198053-2-prsampat@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260203174946.1198053-2-prsampat@amd.com> X-Stat-Signature: ewuqhpuo3jxfiqytk4xhrk8fmnybx4us X-Rspamd-Queue-Id: AAF97C0005 X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1770204165-416010 X-HE-Meta: U2FsdGVkX18dYA0PuyGUKxmvjxh1ptHWJmPUQhDHEa9GtgqrbxGHgG87HmRTfWZasVeu26o/+dpwH5HhlEXkxeDjhUpRE7TEsvnb89gH34OBVu2xKxkcrJtBlxe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BBSsi18pGial0lx55NfbVn85i3PNLW3oy8qVRxGwa6vDvw81GXGwKQgP4ersX1QOFovURhgzQlcT8pY+Q3j0MccYKLW9Ked9AIDYNE9MYR+WG8cUklRbic+A9h0tR7gk6U81ReqALBm 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: List-Subscribe: List-Unsubscribe: On Tue, Feb 03, 2026 at 11:49:45AM -0600, Pratik R. Sampat wrote: > Confidential computing guests require memory to be accepted before use. > The unaccepted memory bitmap maintained by firmware does not track > most hotplugged memory ranges apart from system memory annotated to be > cold plugged at boot. > > Explicitly validate and transition the newly added memory to a private > state, making it usable by the guest. > > Signed-off-by: Pratik R. Sampat > --- > drivers/firmware/efi/unaccepted_memory.c | 47 ++++++++++++++++++++++++ > include/linux/mm.h | 5 +++ > mm/memory_hotplug.c | 2 + > 3 files changed, 54 insertions(+) > > diff --git a/drivers/firmware/efi/unaccepted_memory.c b/drivers/firmware/efi/unaccepted_memory.c > index c2c067eff634..359779133cb4 100644 > --- a/drivers/firmware/efi/unaccepted_memory.c > +++ b/drivers/firmware/efi/unaccepted_memory.c > @@ -209,6 +209,53 @@ bool range_contains_unaccepted_memory(phys_addr_t start, unsigned long size) > return ret; > } > > +/* > + * Unaccepted memory bitmap only covers initial boot memory and not the > + * hotpluggable range that is part of SRAT parsing. However, some initial memory > + * with the attribute EFI_MEMORY_HOT_PLUGGABLE can indicate boot time memory > + * that can be hot-removed. Hence post acceptance, only for that range update > + * the unaccepted bitmap to reflect this change. > + */ > +void accept_hotplug_memory(phys_addr_t start, unsigned long size) > +{ > + struct efi_unaccepted_memory *unaccepted; > + unsigned long range_start, range_len; > + phys_addr_t end = start + size; > + u64 phys_base, unit_size; > + unsigned long flags; > + > + unaccepted = efi_get_unaccepted_table(); > + if (!unaccepted) > + return; This can be tricky. If we boot a VM with <4GiB of memory and all of it is pre-accepted by BIOS, the table will not be allocated. But it doesn't mean that hotplugged memory above should not be accepted. I don't think there is a way to detect such cases. Your check is probably the best we can do, but it means VMs are going to crash if memory accept is required by no table. This is ugly situation. -- Kiryl Shutsemau / Kirill A. Shutemov