Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

pstore/ramoops: Add ramoops.mem_name= command line option

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.

Tested-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Acked-by: Kees Cook <kees@kernel.org>
Link: https://lore.kernel.org/r/20240613155527.591647061@goodmis.org
Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org>

authored by

Steven Rostedt (Google) and committed by
Mike Rapoport (IBM)
d9d814ee 1e4c64b7

+27
+13
Documentation/admin-guide/ramoops.rst
··· 23 23 * ``mem_size`` for the size. The memory size will be rounded down to a 24 24 power of two. 25 25 * ``mem_type`` to specify if the memory type (default is pgprot_writecombine). 26 + * ``mem_name`` to specify a memory region defined by ``reserve_mem`` command 27 + line parameter. 26 28 27 29 Typically the default value of ``mem_type=0`` should be used as that sets the pstore 28 30 mapping to pgprot_writecombine. Setting ``mem_type=1`` attempts to use ··· 119 117 printk(KERN_ERR "unable to register platform device\n"); 120 118 return ret; 121 119 } 120 + 121 + D. Using a region of memory reserved via ``reserve_mem`` command line 122 + parameter. The address and size will be defined by the ``reserve_mem`` 123 + parameter. Note, that ``reserve_mem`` may not always allocate memory 124 + in the same location, and cannot be relied upon. Testing will need 125 + to be done, and it may not work on every machine, nor every kernel. 126 + Consider this a "best effort" approach. The ``reserve_mem`` option 127 + takes a size, alignment and name as arguments. The name is used 128 + to map the memory to a label that can be retrieved by ramoops. 129 + 130 + reserver_mem=2M:4096:oops ramoops.mem_name=oops 122 131 123 132 You can specify either RAM memory or peripheral devices' memory. However, when 124 133 specifying RAM, be sure to reserve the memory by issuing memblock_reserve()
+14
fs/pstore/ram.c
··· 50 50 MODULE_PARM_DESC(mem_address, 51 51 "start of reserved RAM used to store oops/panic logs"); 52 52 53 + static char *mem_name; 54 + module_param_named(mem_name, mem_name, charp, 0400); 55 + MODULE_PARM_DESC(mem_name, "name of kernel param that holds addr"); 56 + 53 57 static ulong mem_size; 54 58 module_param(mem_size, ulong, 0400); 55 59 MODULE_PARM_DESC(mem_size, ··· 917 913 static void __init ramoops_register_dummy(void) 918 914 { 919 915 struct ramoops_platform_data pdata; 916 + 917 + if (mem_name) { 918 + phys_addr_t start; 919 + phys_addr_t size; 920 + 921 + if (reserve_mem_find_by_name(mem_name, &start, &size)) { 922 + mem_address = start; 923 + mem_size = size; 924 + } 925 + } 920 926 921 927 /* 922 928 * Prepare a dummy platform data structure to carry the module