Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp458167lqt; Thu, 6 Jun 2024 08:28:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVTzoJKN3cQZFHqAsM7oMMWAcHy9O7qN+Pq2GrKhA8LpJkLbUCPbaasqx4HkgzJDUTFdfLms6fqUTtl6PiBbsANVM2bJn6WukDfsC35tA== X-Google-Smtp-Source: AGHT+IH0P+4PPrckqKTurDhcDPsBhWZrVMLOdfGNY3Rp7dFi0DvqLCmJqgAG3/KQ+FfXNuUyGv7R X-Received: by 2002:a17:902:da8e:b0:1f4:7bf1:71f8 with SMTP id d9443c01a7336-1f6a590aa23mr73154745ad.5.1717687687687; Thu, 06 Jun 2024 08:28:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717687687; cv=pass; d=google.com; s=arc-20160816; b=hnEm9Ck0BBVHjqmEwMnRPyzr+snVmkaCUK03Ks1TE3+84N1eclhXxeeUGSLs+yw1m2 e/LyBMDLTXuDR8eafv4KXztYQNEKP3x3cf2F/l74x+EQnbNUQ0vgIoE+uJlZVf08X9o3 6DziVuyyEpfLcDSgXQdnFKeU7HSgCSmRj8fC9Hf/wsmYHec7Gvz4bsECGxBIJpFHmdmi /Vd3V2gXW4u9yKePxD0fkZGajTnjQlCfz5DEzyjRB9hiX4A3aMMVSV2+t3upnUwgEEMA jfMxaF/Hfrdxi/phDu2pCXHJR3578YyMM4PQmxVAwWroI+jR+DJDKAWVq1XBUp8nEpMo yYdA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id; bh=xapNGQqKfEru3jh7TqXuFOGf9SCicNaIgntC5Hp7brU=; fh=QORXSiDV/x9VWq4RcqWjO5bZNJ5t7To8OgD4cz5pN8M=; b=yBLRq+BXEtzogFE+uZnMlE0PfhjQ04pyFMiBDjcyfviSTGSkyO+dpHkL+M8/HCh6Sd //LRenrKuBC7wa1z3vw73rW3mpqdscq+EDSzQyZ0WgbVHh/YfadhTAcwvCm52vOQlGvu c3CjR1sa1c6RANG5KBWKz4FezfuTessn746vUwkh6+oL8IR5uVp17zh3dTTXQjTHRxzZ VsT59vOtshn4k1P0g6Jd540OKV7W6L7Ur5xw/AvlNoHTVBmuy3P9V5M3LofbD/AGc1EK CLxI306LbQAPPrsuuGpIlQ86VKU6Uarz6Fl5//VW41S2eIEI8AsAcEA8wL39dKBTjGxk xp3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-204545-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204545-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f6bd7609a0si9743555ad.124.2024.06.06.08.28.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 08:28:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204545-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-204545-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204545-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5F1AD28A5B0 for ; Thu, 6 Jun 2024 15:18:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 461DD19AD70; Thu, 6 Jun 2024 15:03:13 +0000 (UTC) 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 7C3CE19307E; Thu, 6 Jun 2024 15:03:12 +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=1717686192; cv=none; b=tWOuqlt1ILyYk68TAukXERgV5M/ey5I0ujuh25kHB9EmInSPPa5gf+JZnIVGZiUAM+LhxUJMrCbmV5EoYLrpmW9nsdy7aI+VxT/4WBdKyPKk7OsVc5YjK19YtZQyHSIixMvIYQpas2ct/PPnrleILGcMhsykRLDCmdPOy6QTEes= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717686192; c=relaxed/simple; bh=xs5J20Qut3DYk5X4qb3dX8ARaN02QrksOWuKtXawG3I=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=sRxYwkkbD9IECaqApxfXoqfGvRlr7dJX9LDsAUCj2Q8Jel32/f08Qh+FF4imxeeJ8fIqAfFDptI3QpmU6yDfx+vCfq9Rk8LqMftaOmOMylYkGZh2MU29dGWxwobYfyWrL2PqTgaL6hh59aQqBev+9Fj3kBhScVgCAyHnPnDKONE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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]::