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 CAF5F770FE for ; Sat, 10 May 2025 00:37:35 +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=1746837456; cv=none; b=g0WSIWV9rW3TcuBgs0cJHX1WukNYArJmwuW9JYe4ThD7SYz+4CxQUtpM64WCzzG50s6aMOyOsBYOC8mBHe0zJsDBy9833T02//kLAs8hLta0qOdQy3Lyi14fDkKK/xxaJwL3P8HDtnHZf7flPt1p4LSZl/j8LY+YfRA9FNc5sUA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746837456; c=relaxed/simple; bh=U3KD1sgZ5P/6ZVC4ta+P1mOkPvY2ep/KGy9k9ehw1wE=; h=Date:To:From:Subject:Message-Id; b=RzLwpFZo8MqsKxD0T46YrgcJfNWYZnzSu97p3H1CFRPqPR28U5K+B0o/eLQX3siERSktkd+OsgVeQtWXw6uwIM/HlIHk0GZfBriVmAI/Q8ePlQxfaOrEV+bPyFWcsKDuskadv1X36Dbr0ws4DeX9JagpKn2Ub7SGvnLxn6Hu4Uw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=1/QwIhrt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="1/QwIhrt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26EDFC4CEE4; Sat, 10 May 2025 00:37:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1746837455; bh=U3KD1sgZ5P/6ZVC4ta+P1mOkPvY2ep/KGy9k9ehw1wE=; h=Date:To:From:Subject:From; b=1/QwIhrt+8DyCnUoyUBuELqTPBBMFDNdt5sF7F2wD/BV89BWtB0+nfZcYiTViQjOp cOj1R8C9ndmbzdfnj98m9eMjjesdyj3jrXWEST4PfyhlcOJL9YKmLXl485iyT0PpoJ 36O3Or552es4v4zYUy4tN3GdyUPB/S3eJlWCKI+I= Date: Fri, 09 May 2025 17:37:34 -0700 To: mm-commits@vger.kernel.org,will@kernel.org,thomas.lendacky@amd.com,tglx@linutronix.de,skinsburskii@linux.microsoft.com,saravanak@google.com,rppt@kernel.org,rostedt@goodmis.org,robh@kernel.org,ptyadav@amazon.de,peterz@infradead.org,pbonzini@redhat.com,pasha.tatashin@soleen.com,mingo@redhat.com,mark.rutland@arm.com,luto@kernel.org,krzk@kernel.org,jgowans@amazon.com,jgg@nvidia.com,hpa@zytor.com,ebiederm@xmission.com,dwmw2@infradead.org,dave.hansen@linux.intel.com,corbet@lwn.net,changyuanl@google.com,catalin.marinas@arm.com,bp@alien8.de,benh@kernel.crashing.org,ashish.kalra@amd.com,arnd@arndb.de,anthony.yznaga@oracle.com,graf@amazon.com,akpm@linux-foundation.org From: Andrew Morton Subject: + x86-e820-temporarily-enable-kho-scratch-for-memory-below-1m.patch added to mm-unstable branch Message-Id: <20250510003735.26EDFC4CEE4@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: x86/e820: temporarily enable KHO scratch for memory below 1M has been added to the -mm mm-unstable branch. Its filename is x86-e820-temporarily-enable-kho-scratch-for-memory-below-1m.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/x86-e820-temporarily-enable-kho-scratch-for-memory-below-1m.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Alexander Graf Subject: x86/e820: temporarily enable KHO scratch for memory below 1M Date: Fri, 9 May 2025 00:46:30 -0700 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, clear that scratch marking. Link: https://lkml.kernel.org/r/20250509074635.3187114-13-changyuanl@google.com Signed-off-by: Alexander Graf Co-developed-by: Mike Rapoport (Microsoft) Signed-off-by: Mike Rapoport (Microsoft) Co-developed-by: Changyuan Lyu Signed-off-by: Changyuan Lyu Acked-by: Dave Hansen Cc: Andy Lutomirski Cc: Anthony Yznaga Cc: Arnd Bergmann Cc: Ashish Kalra Cc: Ben Herrenschmidt Cc: Borislav Betkov Cc: Catalin Marinas Cc: David Woodhouse Cc: Eric Biederman Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: James Gowans Cc: Jason Gunthorpe Cc: Jonathan Corbet Cc: Krzysztof Kozlowski Cc: Marc Rutland Cc: Paolo Bonzini Cc: Pasha Tatashin Cc: Peter Zijlstra Cc: Pratyush Yadav Cc: Rob Herring Cc: Saravana Kannan Cc: Stanislav Kinsburskii Cc: Steven Rostedt Cc: Thomas Gleinxer Cc: Thomas Lendacky Cc: Will Deacon Signed-off-by: Andrew Morton --- arch/x86/kernel/e820.c | 18 ++++++++++++++++++ arch/x86/realmode/init.c | 2 ++ 2 files changed, 20 insertions(+) --- a/arch/x86/kernel/e820.c~x86-e820-temporarily-enable-kho-scratch-for-memory-below-1m +++ a/arch/x86/kernel/e820.c @@ -1300,6 +1300,24 @@ void __init e820__memblock_setup(void) } /* + * 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); + + /* * 32-bit systems are limited to 4BG of memory even with HIGHMEM and * to even less without it. * Discard memory after max_pfn - the actual limit detected at runtime. --- a/arch/x86/realmode/init.c~x86-e820-temporarily-enable-kho-scratch-for-memory-below-1m +++ a/arch/x86/realmode/init.c @@ -65,6 +65,8 @@ void __init reserve_real_mode(void) * setup_arch(). */ memblock_reserve(0, SZ_1M); + + memblock_clear_kho_scratch(0, SZ_1M); } static void __init sme_sev_setup_real_mode(struct trampoline_header *th) _ Patches currently in -mm which might be from graf@amazon.com are memblock-add-support-for-scratch-memory.patch kexec-add-kexec-handover-kho-generation-helpers.patch kexec-add-kho-parsing-support.patch kexec-add-kho-support-to-kexec-file-loads.patch kexec-add-config-option-for-kho.patch arm64-add-kho-support.patch x86-kexec-add-support-for-passing-kexec-handover-kho-data.patch x86-e820-temporarily-enable-kho-scratch-for-memory-below-1m.patch x86-boot-make-sure-kaslr-does-not-step-over-kho-preserved-memory.patch x86-kconfig-enable-kexec-handover-for-64-bits.patch memblock-add-kho-support-for-reserve_mem.patch documentation-add-documentation-for-kho.patch