From patchwork Tue Apr 9 21:02:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 13623258 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 D8D982905; Tue, 9 Apr 2024 21:11:15 +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=1712697075; cv=none; b=CLii9lW3Z3MTOFyLAE96hkSgzG2lLA0GW08xdMHN3LBOYGkJJdCnI93N7sFartalOzomy87K2fj+1Q05EFEIf60hOQpOxGDnrVnzvurV5c3gBsKlaMuKyIsH7cp8hnRRt7to6kGzO+0fPszx5/rPPA/1gt69DeO4Rx5BnSPOShI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712697075; c=relaxed/simple; bh=ElVDNmYvP/wbcQKWFCeHfImQrTWe9WSMoe1E90/HAHY=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=rOqHv2AXLYXo1rmjNx5BMSAUPxTUBtn/9uIR9lgLUHj8IJ/k/zV0v/cob4CnL3uob4yVpCKOhe6xsa3Yp86w3EP7A7hGN2TX+ngPqQhnPb+TlNFVgKnNfzeS7yrAYSjjfCuXH3qCkbZ+l1ow++zdqhdpFktLViQGFFopA9Yg2KY= 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 BB506C43399; Tue, 9 Apr 2024 21:11:15 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1ruImt-00000000d2d-1ZXv; Tue, 09 Apr 2024 17:13:51 -0400 Message-ID: <20240409211351.234897475@goodmis.org> User-Agent: quilt/0.67 Date: Tue, 09 Apr 2024 17:02:56 -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 Subject: [POC][RFC][PATCH 2/2] pstore/ramoops: Add ramoops.mem_name= command line option References: <20240409210254.660888920@goodmis.org> Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Steven Rostedt (Google)" Add a method to find a region specified by memmap=nn*align:name for ramoops. Adding a kernel command line parameter: memmap=12M*4096:oops ramoops.mem_name=oops Will use the size and location defined by the memmap parameter where it finds the memory and labels it "oops". The "oops" in the ramoops option is used to search for it. This allows for arbitrary RAM to be used for ramoops if it is known that the memory is not cleared on kernel crashes or soft reboots. Signed-off-by: Steven Rostedt (Google) --- fs/pstore/ram.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index b1a455f42e93..c200388399fb 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -50,6 +50,11 @@ module_param_hw(mem_address, ullong, other, 0400); MODULE_PARM_DESC(mem_address, "start of reserved RAM used to store oops/panic logs"); +static char *mem_name; +module_param_named(mem_name, mem_name, charp, 0400); +MODULE_PARM_DESC(mem_name, + "name of kernel param that holds addr (builtin only)"); + static ulong mem_size; module_param(mem_size, ulong, 0400); MODULE_PARM_DESC(mem_size, @@ -914,6 +919,19 @@ static void __init ramoops_register_dummy(void) { struct ramoops_platform_data pdata; +#ifndef MODULE + /* Only allowed when builtin */ + if (mem_name) { + u64 start; + u64 size; + + if (memmap_named(mem_name, &start, &size)) { + mem_address = start; + mem_size = size; + } + } +#endif + /* * Prepare a dummy platform data structure to carry the module * parameters. If mem_size isn't set, then there are no module