From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 825532629F; Mon, 24 Feb 2025 14:36:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740407819; cv=none; b=DMCHXKXmgcUC0fgs2hyyGmJJiCml1inyHAh1XXqWDyynrDVoVfdPKYmYrbb0UJflGFtdy+B8p3rl8Wi15Fvv07LpN3XbTz5dBQRqrb1hN4ts6yjrm/JykVKFkJs706FocPkLUToQF9CULAgaaY2qBhWKMDcSj5oKSTvxLrLA25w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740407819; c=relaxed/simple; bh=ZPkqFHkfpEEXBvv/JiiAXJD73VY1MQPjnfI68AzNmMg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=g7AMyIuI5fRanzd7OIL+A/VQ94kmsJ9JyZX9S0reG8ia6odXxQiJw1N9kUKcnE8XiY8pv317dnmwGTfvrZuX7zEmYr16kfN4yGaKc7eFY2yoeh5wNwgVwsUr3Vu9gKuvtw08a1I9XAoRaFnoYPARXVCBFvgI05zLveINtf6FeD0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HMR9ZyF5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HMR9ZyF5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C36ADC4CEE6; Mon, 24 Feb 2025 14:36:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740407819; bh=ZPkqFHkfpEEXBvv/JiiAXJD73VY1MQPjnfI68AzNmMg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HMR9ZyF51+gCTr5O6+tVcp768/JhJHldAdQMuQdHABvUY7CdUug/Ab1wT3ObgQGAC 7NzdY7UbKVP+eM8BgNncEZMMwXw3Wso7TJk0q2VyeryHtrjfnrTE2e5UNcbDKvPLhE 5rK+17rtGXNWyA/lMLkVwP2uxrzQbGpoqpM86P+xp+fCHrb56wfT+YG6s+mEWHlMq7 +kkYVhJASr3nwSzp8WJx6sGZ3GtEKDCIWteAIxOWx0XP2wkAbG4nWMVBfM/fSU2Vi1 69Xel5I0sX2/L5q0XRAaPHw5kaC8vo10XnIAcPaeS8jvBssTAmWVUTy3s4cxy0sDjX NCx7zo+hSuMbw== Date: Mon, 24 Feb 2025 16:36:38 +0200 From: Mike Rapoport To: Wei Yang Cc: linux-kernel@vger.kernel.org, Alexander Graf , Andrew Morton , Andy Lutomirski , Anthony Yznaga , Arnd Bergmann , Ashish Kalra , Benjamin Herrenschmidt , Borislav Petkov , Catalin Marinas , Dave Hansen , David Woodhouse , Eric Biederman , Ingo Molnar , James Gowans , Jonathan Corbet , Krzysztof Kozlowski , Mark Rutland , Paolo Bonzini , Pasha Tatashin , "H. Peter Anvin" , Peter Zijlstra , Pratyush Yadav , Rob Herring , Rob Herring , Saravana Kannan , Stanislav Kinsburskii , Steven Rostedt , Thomas Gleixner , Tom Lendacky , Usama Arif , Will Deacon , devicetree@vger.kernel.org, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: Re: [PATCH v4 12/14] x86: Add KHO support Message-ID: References: <20250206132754.2596694-1-rppt@kernel.org> <20250206132754.2596694-13-rppt@kernel.org> <20250224071355.xsl2dbupda4dhfzl@master> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250224071355.xsl2dbupda4dhfzl@master> On Mon, Feb 24, 2025 at 07:13:55AM +0000, Wei Yang wrote: > On Thu, Feb 06, 2025 at 03:27:52PM +0200, Mike Rapoport wrote: > >From: Alexander Graf > [...] > >diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c > >index 82b96ed9890a..0b81cd70b02a 100644 > >--- a/arch/x86/kernel/e820.c > >+++ b/arch/x86/kernel/e820.c > >@@ -1329,6 +1329,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 > >+ * 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); > >+ > > At the beginning of e820__memblock_setup() we call memblock_allow_resize(), > which means during adding memory region it could double the array. And the > memory used here is from some region just added. There are large KHO scratch areas that will be used for most allocations. Marking the memory below ISA_END_ADDRESS as KHO scratch is required to satisfy allocations that explicitly limit the allocation to ISA_END_ADDRESS, e.g the real time trampoline. > But with KHO, I am afraid it would fail? > > > /* Throw away partial pages: */ > > memblock_trim_memory(PAGE_SIZE); > > > > -- > Wei Yang > Help you, Help me -- Sincerely yours, Mike.