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 D84D4770FE for ; Sat, 10 May 2025 00:37:29 +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=1746837449; cv=none; b=ay/23FMTMSPpG1mEQqtWba58N9hKhzdwdjFJBVoJ9ThGoksWtWim1Qd68VTaE7tQbJTR+P4sNJNdmJvPraDGET3XmhQD5akjBK6qkfLRYsHNQA7ppsaTXOz7GctTvOy2Gzcn9mKid9LaaxO1pZjVBrKhkYPdQ1vDN0DNafxX31A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746837449; c=relaxed/simple; bh=fdHl4D8dNKp4dz47vp+qzHkMCQnXA5fx1c2iwTvZALQ=; h=Date:To:From:Subject:Message-Id; b=DL/gvIP2VStDzCAeCFMSlwUfS0HNf6p0203NbSnN3DUwMEC3YNOgaWURKaSZeDCuAoN9DqwXP8RtSobmIjAd4tI7Yoc207BWGlyzndQs8+esTwRreX8+4g22b/2RiPxyC3gEFfkXhLR61cOGfO4Z8gJWu5aQEQcGjc7xLh7tgbw= 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=Pn164fVF; 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="Pn164fVF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 449DDC4CEE4; Sat, 10 May 2025 00:37:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1746837449; bh=fdHl4D8dNKp4dz47vp+qzHkMCQnXA5fx1c2iwTvZALQ=; h=Date:To:From:Subject:From; b=Pn164fVFatbKllfGsmNV9mncOv3QlC655tlgosV3D5Ai5URJ/D0XrLk9dVgNfK/1y 2KofkMZ2McYkabgrREJzRVcMfHxosr9B8DFn8oTcEsAt3Af5lNH33wplO5yUNMW9B7 aLFOq1pOQKiB8gp6ieSiRVeRWiZMIrJGMFp/B7gY= Date: Fri, 09 May 2025 17:37:28 -0700 To: mm-commits@vger.kernel.org,will@kernel.org,thomas.lendacky@amd.com,tglx@linutronix.de,skinsburskii@linux.microsoft.com,saravanak@google.com,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,graf@amazon.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,rppt@kernel.org,akpm@linux-foundation.org From: Andrew Morton Subject: + x86-setup-use-memblock_reserve_kern-for-memory-used-by-kernel.patch added to mm-unstable branch Message-Id: <20250510003729.449DDC4CEE4@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: x86/setup: use memblock_reserve_kern for memory used by kernel has been added to the -mm mm-unstable branch. Its filename is x86-setup-use-memblock_reserve_kern-for-memory-used-by-kernel.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/x86-setup-use-memblock_reserve_kern-for-memory-used-by-kernel.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: "Mike Rapoport (Microsoft)" Subject: x86/setup: use memblock_reserve_kern for memory used by kernel Date: Fri, 9 May 2025 00:46:28 -0700 memblock_reserve() does not distinguish memory used by firmware from memory used by kernel. The distinction is nice to have for accounting of early memory allocations and reservations, but it is essential for kexec handover (kho) to know how much memory kernel consumes during boot. Use memblock_reserve_kern() to reserve kernel memory, such as kernel image, initrd and setup data. Link: https://lkml.kernel.org/r/20250509074635.3187114-11-changyuanl@google.com Signed-off-by: Mike Rapoport (Microsoft) Signed-off-by: Changyuan Lyu Acked-by: Dave Hansen Cc: Alexander Graf 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/setup.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) --- a/arch/x86/kernel/setup.c~x86-setup-use-memblock_reserve_kern-for-memory-used-by-kernel +++ a/arch/x86/kernel/setup.c @@ -286,8 +286,8 @@ static void __init cleanup_highmap(void) static void __init reserve_brk(void) { if (_brk_end > _brk_start) - memblock_reserve(__pa_symbol(_brk_start), - _brk_end - _brk_start); + memblock_reserve_kern(__pa_symbol(_brk_start), + _brk_end - _brk_start); /* Mark brk area as locked down and no longer taking any new allocations */ @@ -360,7 +360,7 @@ static void __init early_reserve_initrd( !ramdisk_image || !ramdisk_size) return; /* No initrd provided by bootloader */ - memblock_reserve(ramdisk_image, ramdisk_end - ramdisk_image); + memblock_reserve_kern(ramdisk_image, ramdisk_end - ramdisk_image); } static void __init reserve_initrd(void) @@ -413,7 +413,7 @@ static void __init add_early_ima_buffer( } if (data->size) { - memblock_reserve(data->addr, data->size); + memblock_reserve_kern(data->addr, data->size); ima_kexec_buffer_phys = data->addr; ima_kexec_buffer_size = data->size; } @@ -553,7 +553,7 @@ static void __init memblock_x86_reserve_ len = sizeof(*data); pa_next = data->next; - memblock_reserve(pa_data, sizeof(*data) + data->len); + memblock_reserve_kern(pa_data, sizeof(*data) + data->len); if (data->type == SETUP_INDIRECT) { len += data->len; @@ -567,7 +567,7 @@ static void __init memblock_x86_reserve_ indirect = (struct setup_indirect *)data->data; if (indirect->type != SETUP_INDIRECT) - memblock_reserve(indirect->addr, indirect->len); + memblock_reserve_kern(indirect->addr, indirect->len); } pa_data = pa_next; @@ -770,8 +770,8 @@ static void __init early_reserve_memory( * __end_of_kernel_reserve symbol must be explicitly reserved with a * separate memblock_reserve() or they will be discarded. */ - memblock_reserve(__pa_symbol(_text), - (unsigned long)__end_of_kernel_reserve - (unsigned long)_text); + memblock_reserve_kern(__pa_symbol(_text), + (unsigned long)__end_of_kernel_reserve - (unsigned long)_text); /* * The first 4Kb of memory is a BIOS owned area, but generally it is _ Patches currently in -mm which might be from rppt@kernel.org are execmem-enforce-allocation-size-aligment-to-page_size.patch memblock-add-memblock_rsrv_kern-flag.patch memblock-introduce-memmap_init_kho_scratch.patch kexec-enable-kho-support-for-memory-preservation.patch x86-setup-use-memblock_reserve_kern-for-memory-used-by-kernel.patch documentation-kho-add-memblock-bindings.patch