From patchwork Tue Jun 11 14:49:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 13693872 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 A3C80C27C75 for ; Tue, 11 Jun 2024 14:49:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8E6C96B00A4; Tue, 11 Jun 2024 10:49:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 894646B00A5; Tue, 11 Jun 2024 10:49:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E6E86B00A6; Tue, 11 Jun 2024 10:49:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4F8406B00A4 for ; Tue, 11 Jun 2024 10:49:38 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 03F941408F7 for ; Tue, 11 Jun 2024 14:49:37 +0000 (UTC) X-FDA: 82218891636.29.E109CB0 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf15.hostedemail.com (Postfix) with ESMTP id 3DCE1A0003 for ; Tue, 11 Jun 2024 14:49:35 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf15.hostedemail.com: domain of "SRS0=hOOK=NN=goodmis.org=rostedt@kernel.org" designates 139.178.84.217 as permitted sender) smtp.mailfrom="SRS0=hOOK=NN=goodmis.org=rostedt@kernel.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718117375; 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: references:references; bh=bSvhJ4Q1mzHI+U9+5/HN/kopc3HpcHLFPrC0sUaTll4=; b=OwK/3YvoIJMvAogUes2iBxONQO1EYwg3rIm39GLZ+aVqvMoE9su1MOf39QykwpddSn9ksw LZunm9bDZo8H2H03TWtTanbdt2zvwNo0IJ5qju++bwSVC9yeD+FeC+QlSegEqX15tmUwpv tsmzxOiRAN1kM6+jFtHwCuoR5lP5vv4= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf15.hostedemail.com: domain of "SRS0=hOOK=NN=goodmis.org=rostedt@kernel.org" designates 139.178.84.217 as permitted sender) smtp.mailfrom="SRS0=hOOK=NN=goodmis.org=rostedt@kernel.org" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718117375; a=rsa-sha256; cv=none; b=3iYGVA1PTTIi0SUgyxXcUqfv1vtypDFOwhJ9IKl0eRpC8uZpT9MgBczyOTvp6b7NT81BGX pxnI6T6RrqTTYwxIfBqmgIYB/0ny5dtgBmqom2YOU+vHU0AArzjL6e9XIoUYjrbUVmVv1U uJpEerPzL+gDOGT+YQ6955DBUiYwpLk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 184AE60EE0; Tue, 11 Jun 2024 14:49:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96C44C4AF49; Tue, 11 Jun 2024 14:49:33 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sH2on-00000001Onf-2roL; Tue, 11 Jun 2024 10:49:49 -0400 Message-ID: <20240611144949.544382280@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 11 Jun 2024 10:49:12 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , "Liam R. Howlett" , Vlastimil Babka , Lorenzo Stoakes , linux-mm@kvack.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Kees Cook , Tony Luck , "Guilherme G. Piccoli" , linux-hardening@vger.kernel.org, Guenter Roeck , Ross Zwisler , wklin@google.com, Vineeth Remanan Pillai , Joel Fernandes , Suleiman Souhlal , Linus Torvalds , Catalin Marinas , Will Deacon , Ard Biesheuvel , Mike Rapoport Subject: [PATCH v3 1/2] mm/memblock: Add "reserve_mem" to reserved named memory at boot up References: <20240611144911.327227285@goodmis.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 3DCE1A0003 X-Rspamd-Server: rspam10 X-Rspam-User: X-Stat-Signature: 7wqoy6uqpx7q5dcs1js3mton6q3tdwfd X-HE-Tag: 1718117375-318862 X-HE-Meta: U2FsdGVkX1+T/kf/jRMBZ1c7W04wSXJHMSAmrOcBUpY5D6I6OI8iRp7W4ohMPPSoxNEAlO8PjOO17vOhOVTkkEdwyRvF4WS4cIZj7o4+R65++APKSL+NRdDuiN0Gf/zId+5+3FKJCmWU30rBew8U6UwxHcbXqVgZMOMF2SfZz1P1+xAvgIMcSvhO172YhS3O8hXN7T4Hym7HiYmeMBBXsjZ+iGgXo1TfU0suvrcg8RKLONZN3BdDs5WtzRaBmPn6QTBuIyizG6qg2CrZoEu01BG1rWGHWnza41ZoKtJ2tHdYeR4nw2cnNcKO4S45X9YFV1X/XecnXPJhe25OzQu/0modEKq6TyJEBFl0GFeUqwyxtlqZhgTwZ6Bga/q4IwmhRZQi+hxP/HAuCzizeaOW3DOlhXMgtRRIQl2FHGcidy1BZxdgamCs2TEaS8vBi0vWEOAB2V0NvgpH66GA/SVAHIXugeLJ8CILemzzSXPe3JsGVlaFTQqSNEt0sTy3SPUHdd+9TLOylfC2wSEwCYOd268RtDkseE8N58OBaVANA1r7FB+xJH4BySWthTORIJVRydHmkCL25HIKwqi0Tdl5UT1FrJ4ZrImzvengnDsLPa4ycdI5/gK+bvzzc4imGEluWUDSPuo5jG6htVwLdXm9rtTnIJhGvOpeuj56qSxD3YGvJAHCwxI6G5IJAijoRAIBiqw+KXrKtB78SIfRPm+O8Vubv/0ADSIC1AdlFnXokds5fuMFL5otqc67n5bF9kmzZ4hjE0i7r9F6FgOwvN9p39U9bcO7PnxJQw2+Sl9nR9b5WV5gQgIjl814TbRudrwFlt5hWDmQUlb7TwGDZB00sJ518+SlbheVtH0MYVn9hrAKmgkUeDErLHnrRWZO2K7vBIflyS/HkcAUH6IaTW50GKkAhFA4dUuG0Ji/NznVP/j6yXM8frje2vReEGrJ9efBnhc0pE/nfNGBDhORCb2 RFNmhFyG VanxYm3AI8gBOCMRPJL7uPnm3mtUf7rsFJup3mlPHUG+pT5ONtcmJMVo5FMtbCgVsUD/PPM/HYZx/rRRiBzZXe5E8iwcueOzFoM+k3Yfg3zLUBONlbPpBlkB81dYX4bHZN5zXJXBJPDHadyy+ENo5j0pCHA9ZKFOznbeWB4Ugyyo0JA0spCGi6lgvEwConLLNh6XY/rsCfPlr3F7UtxmyFMah6s3or/noOoJebINbuoTqinRnPv0Qqb+emdTZwsz0tP6HyPp/Y/M9QSzXJnDGqSwOyIvd8CuEgKfh5yKaC7CYzXQ8+bcrj/itLGyn6QsFWYJ0zRh9x+nzlaSDM8CPdBaRCy4X51YIdF9U0ekTW6Mgh4J93yQN5LftFPZHU9EhWSoIjn+cJ6olIBc0yceGY6KwuEBKhpq/hSiTEtfcgI+9PCod6pc4B0Lqqm/UGp1jClTIyocJc6N04Q4= 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: From: "Steven Rostedt (Google)" In order to allow for requesting a memory region that can be used for things like pstore on multiple machines where the memory layout is not the same, add a new option to the kernel command line called "reserve_mem". The format is: reserve_mem=nn:align:name Where it will find nn amount of memory at the given alignment of align. The name field is to allow another subsystem to retrieve where the memory was found. For example: reserve_mem=12M:4096:oops ramoops.mem_name=oops Where ramoops.mem_name will tell ramoops that memory was reserved for it via the reserve_mem option and it can find it by calling: if (reserve_mem_find_by_name("oops", &start, &size)) { // start holds the start address and size holds the size given This is typically used for systems that do not wipe the RAM, and this command line will try to reserve the same physical memory on soft reboots. Note, it is not guaranteed to be the same location. For example, if KASLR places the kernel at the location of where the RAM reservation was from a previous boot, the new reservation will be at a different location. Any subsystem using this feature must add a way to verify that the contents of the physical memory is from a previous boot, as there may be cases where the memory will not be located at the same location. Not all systems may work either. There could be bit flips if the reboot goes through the BIOS. Using kexec to reboot the machine is likely to have better results in such cases. Link: https://lore.kernel.org/all/ZjJVnZUX3NZiGW6q@kernel.org/ Suggested-by: Mike Rapoport Signed-off-by: Steven Rostedt (Google) --- Changes since v2: https://lore.kernel.org/linux-trace-kernel/20240606150316.751642266@goodmis.org - Fixed typo "reserver" - Added EXPORT_SYMBOL_GPL() for reserve_mem_find_by_name() .../admin-guide/kernel-parameters.txt | 20 ++++ include/linux/mm.h | 2 + mm/memblock.c | 98 +++++++++++++++++++ 3 files changed, 120 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index b600df82669d..ce7de8136f2f 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -5710,6 +5710,26 @@ them. If is less than 0x10000, the region is assumed to be I/O ports; otherwise it is memory. + reserve_mem= [RAM] + Format: nn[KNG]::