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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1A82FC021A4 for ; Mon, 24 Feb 2025 15:07:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=U2kxLp8PGsF6no9olkoxvVLRBxQRM1JnR8fdH/vpckg=; b=orbmnWGzG0+lDoPV3US3zkSopa e2BeDIcE9oOniNkUk/e3isht2Yof9dyJ2VXnEJ1XtQCFeYMJ9jUx7/6tf4f3FvzIkiKCH/mW6y6F/ 5Fyn75qb9iRqsl+0UEZjWQjT7FPfqUzlv/uhgfvQ0ecDU4ZVbDcIPReioiHSg6CBA4TIkEp7a/Nbm OMqQBFg66fLId0JtyyE2XvzncP7DOzrF9fLIRGuF9ZgZGlkCG+JBmOfOe3Z38RWg4MET7KDZAyp3s GBfnp1ChuubYtchFKQ9Zv5jVH8MmACj8qDkC191yzNBL3OJgWhpSxGPczNyyBfiYiC0DPnoC0aZJv tYBeubQw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tma3B-0000000EDkm-34Ux; Mon, 24 Feb 2025 15:07:17 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tmZZs-0000000E7Pt-0ZQZ; Mon, 24 Feb 2025 14:37:00 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 71174611B9; Mon, 24 Feb 2025 14:36:53 +0000 (UTC) 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250224071355.xsl2dbupda4dhfzl@master> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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.