Skip to content

Commit d9d814e

Browse files
rostedtrppt
authored andcommitted
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 <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]> Acked-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mike Rapoport (IBM) <[email protected]>
1 parent 1e4c64b commit d9d814e

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

Documentation/admin-guide/ramoops.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ and type of the memory area are set using three variables:
2323
* ``mem_size`` for the size. The memory size will be rounded down to a
2424
power of two.
2525
* ``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.
2628

2729
Typically the default value of ``mem_type=0`` should be used as that sets the pstore
2830
mapping to pgprot_writecombine. Setting ``mem_type=1`` attempts to use
@@ -118,6 +120,17 @@ Setting the ramoops parameters can be done in several different manners:
118120
return ret;
119121
}
120122

123+
D. Using a region of memory reserved via ``reserve_mem`` command line
124+
parameter. The address and size will be defined by the ``reserve_mem``
125+
parameter. Note, that ``reserve_mem`` may not always allocate memory
126+
in the same location, and cannot be relied upon. Testing will need
127+
to be done, and it may not work on every machine, nor every kernel.
128+
Consider this a "best effort" approach. The ``reserve_mem`` option
129+
takes a size, alignment and name as arguments. The name is used
130+
to map the memory to a label that can be retrieved by ramoops.
131+
132+
reserver_mem=2M:4096:oops ramoops.mem_name=oops
133+
121134
You can specify either RAM memory or peripheral devices' memory. However, when
122135
specifying RAM, be sure to reserve the memory by issuing memblock_reserve()
123136
very early in the architecture code, e.g.::

fs/pstore/ram.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ module_param_hw(mem_address, ullong, other, 0400);
5050
MODULE_PARM_DESC(mem_address,
5151
"start of reserved RAM used to store oops/panic logs");
5252

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+
5357
static ulong mem_size;
5458
module_param(mem_size, ulong, 0400);
5559
MODULE_PARM_DESC(mem_size,
@@ -914,6 +918,16 @@ static void __init ramoops_register_dummy(void)
914918
{
915919
struct ramoops_platform_data pdata;
916920

921+
if (mem_name) {
922+
phys_addr_t start;
923+
phys_addr_t size;
924+
925+
if (reserve_mem_find_by_name(mem_name, &start, &size)) {
926+
mem_address = start;
927+
mem_size = size;
928+
}
929+
}
930+
917931
/*
918932
* Prepare a dummy platform data structure to carry the module
919933
* parameters. If mem_size isn't set, then there are no module

0 commit comments

Comments
 (0)