From patchwork Thu Jun 6 15:01:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 13688647 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 38E89C25B75 for ; Thu, 6 Jun 2024 15:03:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C3AE6B00A5; Thu, 6 Jun 2024 11:03:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5240B6B00A6; Thu, 6 Jun 2024 11:03:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 39E416B00A7; Thu, 6 Jun 2024 11:03:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 1E2C76B00A5 for ; Thu, 6 Jun 2024 11:03:19 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B6E1B161697 for ; Thu, 6 Jun 2024 15:03:18 +0000 (UTC) X-FDA: 82200782076.11.CA9655F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf19.hostedemail.com (Postfix) with ESMTP id 973E31A000F for ; Thu, 6 Jun 2024 15:03:13 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf19.hostedemail.com: domain of "SRS0=WH+2=NI=goodmis.org=rostedt@kernel.org" designates 139.178.84.217 as permitted sender) smtp.mailfrom="SRS0=WH+2=NI=goodmis.org=rostedt@kernel.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717686193; 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=xapNGQqKfEru3jh7TqXuFOGf9SCicNaIgntC5Hp7brU=; b=6duCOOaDtgeZiRtbFfdN/SX64jwvi11+FYer7OboMdeh/hWR4OcoZ0JwzV8gKC7Q0c2YGG QyJ26g3Zw/+KlZ9je95+P16/x10Eu4QYDOYTCgseKfPx19VA9zymSC+4hJrPyf7Pa/3Eqt D3fldTAl8fhL3P4AIyMcs0CxM4P5q/k= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf19.hostedemail.com: domain of "SRS0=WH+2=NI=goodmis.org=rostedt@kernel.org" designates 139.178.84.217 as permitted sender) smtp.mailfrom="SRS0=WH+2=NI=goodmis.org=rostedt@kernel.org" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717686193; a=rsa-sha256; cv=none; b=z/M8fF1d/8x8TWH25IcNj2INsqnGHw5qBXwP47oPErsp3/ACI6r2sYfFcG0GkhycmiCMk2 hQnfP1QQGu2aQy1WZP6JnE+tMOpR+AT0+ixODCoOzGDiLh/cgLhibAOMNqrbKqg2VZ6pJP 3LyLL4EWN5MkUacVFUIujunqLCXsDPU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B70AF61D59; Thu, 6 Jun 2024 15:03:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2368CC32781; Thu, 6 Jun 2024 15:03:12 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sFEe4-00000000oRH-3kir; Thu, 06 Jun 2024 11:03:16 -0400 Message-ID: <20240606150316.751642266@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 06 Jun 2024 11:01:44 -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 v2 1/2] mm/memblock: Add "reserve_mem" to reserved named memory at boot up References: <20240606150143.876469296@goodmis.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 973E31A000F X-Stat-Signature: 7fc9adknbzhzirsnmy8mndygx7sujm3z X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1717686193-198591 X-HE-Meta: U2FsdGVkX19S99e06rva5be7agqFYCTbEotR6X8nOZ/ztZowGzzWn3M0s0T0RBTA5xRGu4R62zwOc2jjlR5vlZvlrY9m+ODHRVTGkLP86gQuBcUgnHPEqD5sji7P2eumDqp3DbtVhvYMQq8rCIyQCT23iMLjlkMJvZP7HfrVDj4IdwShdNDF0TUowqgmBVAidvYnR/SocfV4Z05ahv7ViJMUEZy1Fq9r6ln7aIsfEa2XSfbl5Np3NZ1hkVvc/cYPpvJh/PJtDZzyu7CtNAfo0zl0C/rhVIymBVPZrDwqVWSsJzWnWzRWEzUg6mas2/3lUtdd5JpM25H/y/SgSX7x0c/KoYenetIPbxGwkQNkRmRfYIyxpmx/CKT8YHrwb4/Xvuf8lp0QEATR5UeGJ4kE6HN+rrH3GkokMKyCfDHLY5nsGiYZz/vZChv12gStSRtfISG4+B8xX+hoR9mGdSa12rAoqkG+8JBFB0IzFsMk/yLiQOtXfoNcYKTxvt+LGh3VZrRo3I5k6ZXPIn5ranh12thvxxMWXGtIw4K8F/9rIsEDb5GtM8HkQ9HRlH/8/fFsAEv3a1XxD9V4ETeu76gj/1r7au6GIHml3n2kmSJ3P5HQY2ycVInPLjP6kvEddqBgNrGxPAezvGjtiyRKQByLlXR6MQQ4wentrZ1iZgMub0lIqe9j53uIUezTtTkxCtBX1pYCl4x4jSAahwQdrFgufpKYV2C3kBj5TZdtJnzbU3LWcM7a2xzeTH+ULlfencER9bU5Jhi8PqH1qJKofPSV6y5+SZXzyPpCtcfUJmqdhKdCF9MtV1TEbo34jMdZRYJZKM0aaAxmPZZ67Q9AZpBtzBq3VPNnSNwPIA6KScCdGaM3jLakcFbQ+Et4d9dcVpptI1UpDUABcfv++xIiqrCEK45c/fRqfm/QT1/DZqyi4enLGySUc/v69na1kd5M0c+PCzw+sfC2px7CheptYWm CYfaqmYt joM3bO4Pir6E2VbSLSthOZP2kUqdQncl1itt8bsndqT3etblTsPBOmlFWudOdShDPvGKW5PDt+JppvCPlFr2RhXPrlfqpGlNreMiY7i8ZD6hnpEb+TKvSIHe7eOYQ+Kxry+CxoUhoOHrMLVrwkQPXQzcUkDRPKfnu1RkrypayjijpY/1ORhpGZGVaAdV9rKqY1/3TmjVlhH11Gs/Gl+4Epvlc8hMuEZ0v9OktbexMRNSD7VhQ4jjd6avbUmQys51XLc+QYn07MBfazcZPsgAbhp5XyPbbY/nOGbU1LOXYSuzuPlX6p3szaWI2p3Yf2STcGI5dam+S0+lN29eutn1bCC2aQpjiO8BT2Mte2QURDobrSzIfUnOuaL80EolwYyJVnv1bIzGAr2gJCOKVMapl1gOgq55WikTrVNsSzjl2aml+5o8+4b4rSDPns4wifAeuMgjO3Xxuz62MKDI= 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) --- .../admin-guide/kernel-parameters.txt | 20 ++++ include/linux/mm.h | 2 + mm/memblock.c | 97 +++++++++++++++++++ 3 files changed, 119 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index b600df82669d..4b2f7fb8de66 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]::