From patchwork Tue Jun 11 21:56:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 13694219 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 7A242C27C78 for ; Tue, 11 Jun 2024 21:57:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 76A836B00DA; Tue, 11 Jun 2024 17:57:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F0986B00DB; Tue, 11 Jun 2024 17:57:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 56CC06B00DD; Tue, 11 Jun 2024 17:57:52 -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 3A4226B00DB for ; Tue, 11 Jun 2024 17:57:52 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E4D6E16059C for ; Tue, 11 Jun 2024 21:57:51 +0000 (UTC) X-FDA: 82219970742.08.5E4F2C3 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf10.hostedemail.com (Postfix) with ESMTP id AC942C0003 for ; Tue, 11 Jun 2024 21:57:49 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of "SRS0=hOOK=NN=goodmis.org=rostedt@kernel.org" designates 145.40.73.55 as permitted sender) smtp.mailfrom="SRS0=hOOK=NN=goodmis.org=rostedt@kernel.org"; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718143070; a=rsa-sha256; cv=none; b=UVfdG1T61P95BzzOBjZMtXZFDP7y1pt8p0c+aWjbqlDa4/4yHr6aQ4VlBW2VTThuMNjaVE 6zIGQkOOJZTPdosR3fbQjdRgcoUGSJEoQbN89SaO0v8tyQBNnRpyCWjDuIZSPYB6X/CVi5 ly7T6qOALIZpe88dmDpdy3bN8kgCL+c= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of "SRS0=hOOK=NN=goodmis.org=rostedt@kernel.org" designates 145.40.73.55 as permitted sender) smtp.mailfrom="SRS0=hOOK=NN=goodmis.org=rostedt@kernel.org"; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718143070; 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=wNHrip7Acg7RXDhGz073bCFMh8j39WHtPzy1FVePtJE=; b=YR1LE6X1RZfuIwUERoLFKakI+eQLGdnmWZ3LzBj7glpbBSaTt3vVKAFv1Prx9T1koGs2O2 PpsJt4fLNOo8ElKJKzzKezzqW+6JXmTpgJIsk+j/1RXAOKYQRxnCemWJqpMrTLXDGVFokE TWQGkoEOiDyS1PpwBmsRivKYAY46O3E= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id E5DE8CE1E78; Tue, 11 Jun 2024 21:57:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4B85C4AF50; Tue, 11 Jun 2024 21:57:44 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sH9VB-00000001VTR-2SZL; Tue, 11 Jun 2024 17:58:01 -0400 Message-ID: <20240611215801.443593152@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 11 Jun 2024 17:56:11 -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 v4 1/2] mm/memblock: Add "reserve_mem" to reserved named memory at boot up References: <20240611215610.548854415@goodmis.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: AC942C0003 X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: dhkpfge5k67oeeda8dkz6g4ck5gcn69h X-HE-Tag: 1718143069-353817 X-HE-Meta: U2FsdGVkX18tGI+ZPtHK+yNQQwfV1ztoDDSGNAbwuOrU8Ay/lhFaVdZRpFeEW4Vn1APsYff4CZZFtVQwnJw1F1NWQPXA3xcP7Va2y1Qc/qRuLGpvgv2Z2H72nK5LCiq5qMwWWZiC/0NrZeLx1HCJkqvS286rdrrEL3ryypf3J5ukVIcOJnwWrq4hcTTx+hBI7YrLEgUP/SlCkBJJZx416nGclgeAOBth8VEugeaKqEdIrexJh1Xjp1C+DkBy+E2heNwz2KNBGflUKamhFq+aqAo02h47MuuTcAvrVSq4znc6GwRd5smfp76kmANvRoKNRZqDXIxjByBuAkN7ITEMI2kN4usb3rjzOOaqYuym/4n+F+/+5jkxlflhMXYvDbZKWXm3eY7JKx37bIiY+mE3DrbK3o7GeXu5FoB+66aeK9l59eAbwW1l33y+41632tj2lTeLj1F8TxU3Mn6RVaLxBvEI+B8QikJQ6NbGl5yn2Hu/J/EFp5WiObl5C9LmrOCHn9kh7J4uLWIYHxea6MbmADCKbG1qav0jso7AdiaoOMVxF9epKpoucv0TaNUAAN8w3GDO/3feFVY3GQVlfurliA7gm/IFIXapJq0xVtZuDQBQ3YCkR/PrtzASmlGH2LwyZYwXS7BGdNTv0bkRYda9FU8EstUK2Q2JHooeVYq/eawqfA9syrL4kXg4XJ+4Euee7bT/pIS7VlCbisn/7ry+BokTmCmnHPn9Th0o26i7uyk0d8Na6V2qFgs86eLCVpiY1lhyAN8ea6CCfAxofKnnlAsdQQk75OrH0pXEXv5TO5IQr5CaC4k0/6eGaR1g5PE5iykMmjRjfxCm9MafAZeITViLXpcClqn9BvD2KRz3MrDZqHX23yYdohfqbSuXdezGFtpS+yBf6469Pbe8Dd/O06+9dJleQIWjnoxRA5n31P4471MbNqMySe0033kimPVBHGFbnn9QlLp4nzPZ4mM rdUjbej3 yYhL817vaE1iBYZaJ5Lbh9gWMfo7IOP4TGEwvi5isPRCbVmIR+Rwhq6uezI0j621QNi6qXBRazXgEEJltP1iR+TXRpLez9QIHoSjM9QddIaWEioqeBajtB0Yq0tpGwdq7jhGN5nCfdBVxG3/XejzntkpEU2DpM2JcPPlC0FL4sR2hPM8ujl12mtEYrJylKdOIQ0itinR4XWyImbHKGok3HxVTai1mFRRpH9AL4y885HykILA2E09U2zRGEbU80kc5zovSouIcOVd4jONIYwAnXyHu3LbuTj2iycHeYtRjNECvzbbeY5OYJbf9y8h+wRkF5nek9MkLqB9RZ7aRlQ6sEUw0gf3jJ160Clu0BQt3kOSwSwoDvdwamZ5IbRqpWDVMsk7R1sdU8EttfNVr7bCDVAbuZx1JCqiJADAiimWhQvQ6c0V23JJLXZ1jEG1KsGOjPzyE30MkzNdL6q0= 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 v3: https://lore.kernel.org/linux-trace-kernel/20240606150316.751642266@goodmis.org - Changed table type of start and size from unsigned long to phys_addr_t (as well as the parameters to the functions that use them) - Changed old reference to "early_reserve_mem" to "reserve_mem" - Check before reservering memory: o Size is non-zero o name has text in it - If align is less than SMP_CACHE_BYTES, make it SMP_CACHE_BYTES - Remove the silly check of testing *p == '\0' after a p += strlen(p) .../admin-guide/kernel-parameters.txt | 20 +++ include/linux/mm.h | 2 + mm/memblock.c | 115 ++++++++++++++++++ 3 files changed, 137 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]::