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 3823DC369CB for ; Tue, 29 Apr 2025 08:06:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 212DE8E0002; Tue, 29 Apr 2025 04:06:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1E9FF8E0001; Tue, 29 Apr 2025 04:06:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 063BB8E0002; Tue, 29 Apr 2025 04:06:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id CE2808E0001 for ; Tue, 29 Apr 2025 04:06:45 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D92961413DD for ; Tue, 29 Apr 2025 08:06:46 +0000 (UTC) X-FDA: 83386350012.28.93F9CB1 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id 2FA7680010 for ; Tue, 29 Apr 2025 08:06:45 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=g4MP1qWh; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf02.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=1745914005; a=rsa-sha256; cv=none; b=SJOOyBJRgAfA2tX2viAEYV7JNGYOPtmm3t+tM2RRXNMf+xBSGqc00pmKwgk3Q1PHZiG7hs ACPWAH4eqAhx1RTbrAdFU+xMycNbmiOs6oe3J/vFbG8yoSYdk0UJktVzU3zTd5qzWfDAJi P+0BAsOfXFYDckWg4qpZboiYCzGPHSw= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=g4MP1qWh; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf02.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=1745914005; 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=97/XTbBVa/VhLqAzcVmPdfXdxwWdIcyYHBaxl2j9mtY=; b=oTk1N0NJd8dREvjxf1+xw3ALrCiT2ysj/SkH0yN+UiRC+d9mxNZCl4lfAnPtcoCkxD30h6 3ZUTnfhxRoo5cTq+EAG8tKuDdOviMgJtkGTdjU5aZ6d+F3Ec32EORB8M+HazAMDZunYTRS JdTOC2SS459Y6oXuluvIWPqdDZS44J8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id C797F5C4D8E; Tue, 29 Apr 2025 08:04:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D988C4CEE3; Tue, 29 Apr 2025 08:06:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745914003; bh=T+OFZKl+3KvYwlqOnSAJknFTlFAGkXBm4R7faZdxC7g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=g4MP1qWhXsNl/uB3rPYca9oL1jVE0ekWEV6gfciWYbB1+dqLQ9mMLhKCeQ4kEML3r bJyb0LeyWTmqcsUmRVfFDi6VMDW5WBeVc88je0PluGWeRS97AYRHNXEXRaWe2ZBNUR h2P24d0Nb3ya3adWViA9y0dL9GADK0WkUOludE9eaO59e5mCjZo+20Kkb33rkTCZ3T joUB021ZBtmCwCwJ8IZUTlrvA217Wsdkv6riqQodhqkESfxv93/qyLqVSaXCE995Qd adxuArH/4q+RMu7lWE/6XP1SpcSbdgr9HJnDqYvJZCKjQED2Lf6yl72MdWWvLKHiTL 2/8qg6TYlg6Ig== Date: Tue, 29 Apr 2025 11:06:29 +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: <35c58191-f774-40cf-8d66-d1e2aaf11a62@intel.com> X-Rspamd-Queue-Id: 2FA7680010 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: 1csqe3jghbtmzooi4bx8t3zep489ebdx X-HE-Tag: 1745914005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pxBPP8vas0Qcrqlcz8jmMlpPQB9DthBMAI+jc35tXf1ZL2OCHhtjdQs17ubzzDX/ju4vCOGvEDjTGLe3F4QoqmZiBWZngF07xRAJgNXARBzM68Wsft/f0cp4M7GJaArWHR+FaLjGfjMfTVlIXiEx2/o+AkE9vzbPj9Ylh1mRcpUZhIE6cieQWhJhpUEEULMMJm15p3fzo1j3Q== 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 Mon, Apr 28, 2025 at 03:05:55PM -0700, Dave Hansen wrote: > On 4/10/25 22:37, Changyuan Lyu wrote: > > From: Alexander Graf > > > > +/* > > + * If KHO is active, only process its scratch areas to ensure we are not > > + * stepping onto preserved memory. > > + */ > > Same thing on the imperative voice here. > > I'm also not fully understanding the comment. Do these "scratch" regions > basically represent all the memory that's not being handed over? It's > not obvious. Scratch memory represents areas created at the boot of the first kernel and it's known that scratch areas won't contain any memory that's being handed over. > > diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c > > index 57120f0749cc3..c314212a5ecd5 100644 > > --- a/arch/x86/kernel/e820.c > > +++ b/arch/x86/kernel/e820.c > > @@ -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 :) -- Sincerely yours, Mike.