From patchwork Thu Jun 6 15:01:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 13688660 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 ABE9E1990A1; 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=bZBIZOs/+wsPmbLrBuGIVawq0FWDuVGgXIOXtC8bAusfziLkA7heQerbc+wGO/6H1VJ8ZJnBu1dviPp5fZIG4hweSOydknhrnzuyisS3nlh2KBsWi5v4taB/ltBbU88hbbOxccMgKA1/j5zYKWzVAlWF8Q+efiJn0EWsFI0vxos= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717686192; c=relaxed/simple; bh=E4KMQm1Ogt1CyuBV5VilL6zJcZs1kYG26oi9sWfoFBA=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=WwWHus5C5muZ+3WVD03t5q+pKRmkCaiwK3XsRkte0tzEz1AyDOYEAq7ZpAq2+f5SPoeXS2aV0lCHQYB/72HjkAZEqbuDDdXqdkDjsdKJo8L0eF5MApkj7xnKUufm4Uaw+vgbfWjlqhsBigurCt0LOoBd8LgSgeqRT5LRyNcUAVo= 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 42FC5C32782; Thu, 6 Jun 2024 15:03:12 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sFEe5-00000000oRl-0FPv; Thu, 06 Jun 2024 11:03:17 -0400 Message-ID: <20240606150316.916395285@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 06 Jun 2024 11:01:45 -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 Subject: [PATCH v2 2/2] pstore/ramoops: Add ramoops.mem_name= command line option References: <20240606150143.876469296@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 reserve_mem=nn:align:name for ramoops. Adding a kernel command line parameter: reserve_mem=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 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index b1a455f42e93..bae8486045eb 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,16 @@ static void __init ramoops_register_dummy(void) { struct ramoops_platform_data pdata; + if (mem_name) { + unsigned long start; + unsigned long size; + + if (reserve_mem_find_by_name(mem_name, &start, &size)) { + mem_address = start; + mem_size = size; + } + } + /* * Prepare a dummy platform data structure to carry the module * parameters. If mem_size isn't set, then there are no module