Skip to content

Commit 1614e92

Browse files
dianderskees
authored andcommitted
pstore/ram: Improve backward compatibility with older Chromebooks
When you try to run an upstream kernel on an old ARM-based Chromebook you'll find that console-ramoops doesn't work. Old ARM-based Chromebooks, before <https://crrev.com/c/439792> ("ramoops: support upstream {console,pmsg,ftrace}-size properties") used to create a "ramoops" node at the top level that looked like: / { ramoops { compatible = "ramoops"; reg = <...>; record-size = <...>; dump-oops; }; }; ...and these Chromebooks assumed that the downstream kernel would make console_size / pmsg_size match the record size. The above ramoops node was added by the firmware so it's not easy to make any changes. Let's match the expected behavior, but only for those using the old backward-compatible way of working where ramoops is right under the root node. NOTE: if there are some out-of-tree devices that had ramoops at the top level, left everything but the record size as 0, and somehow doesn't want this behavior, we can try to add more conditions here. Signed-off-by: Douglas Anderson <dianders@chromium.org> Signed-off-by: Kees Cook <keescook@chromium.org>
1 parent d1fdb6d commit 1614e92

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

fs/pstore/ram.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,7 @@ static int ramoops_parse_dt(struct platform_device *pdev,
655655
struct ramoops_platform_data *pdata)
656656
{
657657
struct device_node *of_node = pdev->dev.of_node;
658+
struct device_node *parent_node;
658659
struct resource *res;
659660
u32 value;
660661
int ret;
@@ -689,6 +690,26 @@ static int ramoops_parse_dt(struct platform_device *pdev,
689690

690691
#undef parse_size
691692

693+
/*
694+
* Some old Chromebooks relied on the kernel setting the
695+
* console_size and pmsg_size to the record size since that's
696+
* what the downstream kernel did. These same Chromebooks had
697+
* "ramoops" straight under the root node which isn't
698+
* according to the current upstream bindings (though it was
699+
* arguably acceptable under a prior version of the bindings).
700+
* Let's make those old Chromebooks work by detecting that
701+
* we're not a child of "reserved-memory" and mimicking the
702+
* expected behavior.
703+
*/
704+
parent_node = of_get_parent(of_node);
705+
if (!of_node_name_eq(parent_node, "reserved-memory") &&
706+
!pdata->console_size && !pdata->ftrace_size &&
707+
!pdata->pmsg_size && !pdata->ecc_info.ecc_size) {
708+
pdata->console_size = pdata->record_size;
709+
pdata->pmsg_size = pdata->record_size;
710+
}
711+
of_node_put(parent_node);
712+
692713
return 0;
693714
}
694715

0 commit comments

Comments
 (0)