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 D6180C369DC for ; Tue, 29 Apr 2025 16:32:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4AF7A6B0008; Tue, 29 Apr 2025 12:32:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4357B6B000A; Tue, 29 Apr 2025 12:32:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2D6176B000C; Tue, 29 Apr 2025 12:32:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0C1B86B0008 for ; Tue, 29 Apr 2025 12:32:51 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A50B31CDF3E for ; Tue, 29 Apr 2025 16:32:51 +0000 (UTC) X-FDA: 83387625342.13.91C7DEB Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf29.hostedemail.com (Postfix) with ESMTP id EAABF120013 for ; Tue, 29 Apr 2025 16:32:49 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gGIHmtRo; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1745944370; a=rsa-sha256; cv=none; b=dSDvnMLcJNgsNiBFfpH27/1zveMu9Lv07bO9Xi8DMnhttxWHYvJ1ENLBem/MeVcqyDGynP O67S/EjAhpnqU5AnH0R1n1Ml+1M9dqjH2jYedsCytNri0B49T09GehInDOaOmyQrDmeuM+ TMZsYgTtnFiS/zoFOGIVipd8fI6gle0= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gGIHmtRo; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1745944370; 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=Gj+lzkgRPCCF6n+yScpRzmM61Ws09xV++STXBmF59Ko=; b=M3b0nBe+SA/jPiFKskCporvMdYQp/TiC4zahHX9ANa3EIa1H83htTbRMn2vqv53Z0iZcj4 u7PG9tFYZ88SJ+5W7KiZrKKtU8BFRfVyf4s1xMejgLCPK4x3NHDZS0/FoK1s8B/qLzNT6H BNd98q54B1qYcXOzCNDhvAR0MYy2GXY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 86F795C1046; Tue, 29 Apr 2025 16:30:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54235C4CEE3; Tue, 29 Apr 2025 16:32:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745944368; bh=feUIYWjgsatR0wsDBnR320zo35FzttrKF/ike0EndGM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gGIHmtRoeMc5skK+Uret9+sNF7RFNy3BEWPrbyWSDJ+5SRrf7mtw1bAaMaUc6Xpj8 cYPvdk+7/ciq2q8+VgFYyN7TT6ImhpLntVfyBRLNgAZjSDnD9Id6MvYJbX/7QMkwCm OActXunbzjeRJyiT8rrBVDY9bRcxWjIjlkS79dq1HDDVQSGzoyxM2WU1eGEaBF3nEo Ov0OcO8fHJCJgb5p86Z9lkWvoV9LqaeYYsDCuW1pKfMqxL2G7G7BdHP0mkU+FKXbR4 cOVOWOMT+9kujdP/3J71kDyjtlIDIzSdgSPSHd7D6d+NXNL58zUquXaMgCAakyuoel J6QVYo/6Endyw== Date: Tue, 29 Apr 2025 19:32:33 +0300 From: Mike Rapoport To: Dave Hansen Cc: Changyuan Lyu , linux-kernel@vger.kernel.org, akpm@linux-foundation.org, anthony.yznaga@oracle.com, arnd@arndb.de, ashish.kalra@amd.com, benh@kernel.crashing.org, bp@alien8.de, catalin.marinas@arm.com, corbet@lwn.net, dave.hansen@linux.intel.com, devicetree@vger.kernel.org, dwmw2@infradead.org, ebiederm@xmission.com, graf@amazon.com, hpa@zytor.com, jgowans@amazon.com, kexec@lists.infradead.org, krzk@kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, luto@kernel.org, mark.rutland@arm.com, mingo@redhat.com, pasha.tatashin@soleen.com, pbonzini@redhat.com, peterz@infradead.org, ptyadav@amazon.de, robh@kernel.org, rostedt@goodmis.org, saravanak@google.com, skinsburskii@linux.microsoft.com, tglx@linutronix.de, thomas.lendacky@amd.com, will@kernel.org, x86@kernel.org Subject: Re: [PATCH v6 11/14] x86: add KHO support Message-ID: References: <20250411053745.1817356-1-changyuanl@google.com> <20250411053745.1817356-12-changyuanl@google.com> <35c58191-f774-40cf-8d66-d1e2aaf11a62@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Queue-Id: EAABF120013 X-Rspamd-Server: rspam04 X-Stat-Signature: r9j7fpt6f6o7ew4bokqtw1xdiakym3my X-HE-Tag: 1745944369-345334 X-HE-Meta: U2FsdGVkX1+d11EIHQqsg0/XSymb9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R9DbhFPZGiHwz+Xe+/kc8ggqE72N/FZmkj3kExR5zx/g+X1ncBMooxQ+f5tjHp7JgZ2OaAO8Kwehzzi5yCADSFzA0o/jIxVpFdEUUaey5cJE7LVZTHTkSvNRGFqa0gzhEOtGKTDoGkm+RZg6IL3MC2Dag== 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, Apr 29, 2025 at 09:06:19AM -0700, Dave Hansen wrote: > On 4/29/25 01:06, Mike Rapoport wrote: > > On Mon, Apr 28, 2025 at 03:05:55PM -0700, Dave Hansen wrote: > >> On 4/10/25 22:37, Changyuan Lyu wrote: > >>> From: Alexander Graf > >>> > >>> @@ -1300,6 +1300,24 @@ void __init e820__memblock_setup(void) > >>> memblock_add(entry->addr, entry->size); > >>> } > >>> > >>> + /* > >>> + * At this point with KHO we only allocate from scratch memory. > >>> + * At the same time, we configure memblock to only allow > >>> + * allocations from memory below ISA_END_ADDRESS which is not > >>> + * a natural scratch region, because Linux ignores memory below > >>> + * ISA_END_ADDRESS at runtime. Beside very few (if any) early > >>> + * allocations, we must allocate real-mode trapoline below > >> > >> trampoline ^ > >> > >>> + * ISA_END_ADDRESS. > >>> + * > >>> + * To make sure that we can actually perform allocations during > >>> + * this phase, let's mark memory below ISA_END_ADDRESS as scratch > >>> + * so we can allocate from there in a scratch-only world. > >>> + * > >>> + * After real mode trampoline is allocated, we clear scratch > >>> + * marking from the memory below ISA_END_ADDRESS > >>> + */ > >>> + memblock_mark_kho_scratch(0, ISA_END_ADDRESS); > >> > >> This isn't making a whole ton of sense to me. > >> > >> Is this *only* to facilitate possible users that need >> allocations? If so, please say that. > >> > >> I _think_ this is trying to say that KHO kernels are special and are > >> trying to only allocate from scratch areas. But >> allocations are both necessary and not marked by KHO _as_ a scratch area > >> which causes a problem. > > > > Yes :) > > So, on both of these, could the submitters please add or revise the > comments to make it more clear? Is this one clearer? /* * At this point memblock is only allowed to allocate from memory * below 1M (aka ISA_END_ADDRESS) up until direct map is completely set * up in init_mem_mapping(). * * KHO kernels are special and use only scratch memory for memblock * allocations, but memory below 1M is ignored by kernel after early * boot and cannot be naturally marked as scratch. * * To allow allocation of the real-mode trampoline and a few (if any) * other very early allocations from below 1M forcibly mark the memory * below 1M as scratch. * * After real mode trampoline is allocated, we clear that scratch * marking. */ memblock_mark_kho_scratch(0, SZ_1M); -- Sincerely yours, Mike.