pstore/ram: Improve backward compatibility with older Chromebooks
Subsystems (2)
PATCH 1/1 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.
---
fs/pstore/ram.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
fs/pstore/ram.c +18 -0
@@ -669,6 +669,7 @@ static int ramoops_parse_dt(struct platform_device *pdev, struct ramoops_platform_data *pdata) {struct device_node *of_node = pdev->dev.of_node; +struct device_node *parent_node;struct resource *res;u32 value;int ret;
@@ -703,6 +704,23 @@ static int ramoops_parse_dt(struct platform_device *pdev,#undef parse_size +/* +* Some old Chromebooks relied on the kernel setting the console_size +* and pmsg_size to the record size since that's what the downstream +* kernel did. These same Chromebooks had "ramoops" straight under +* the root node which isn't according to the upstream bindings. Let's +* make those old Chromebooks work by detecting this and mimicing the +* expected behavior. +*/ + parent_node =of_get_parent (of_node); +if (of_node_is_root (parent_node) && + !pdata->console_size && !pdata->ftrace_size && + !pdata->pmsg_size && !pdata->ecc_info.ecc_size) { + pdata->console_size = pdata->record_size; + pdata->pmsg_size = pdata->record_size; + } +of_node_put (parent_node); +return 0 ; }
Signature · 1 line
2.21.0.1020.gf2820cf01a-goog
Quoted 25 lines · Douglas Anderson
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_sizematch 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.
Quoted 5 lines
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 <[email protected]>
Quoted 44 lines
---
fs/pstore/ram.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)fs/pstore/ram.c +18
-1@@ -669,6 +669,7 @@ static int ramoops_parse_dt(struct platform_device *pdev, struct ramoops_platform_data *pdata) {struct device_node *of_node = pdev->dev.of_node; +struct device_node *parent_node;struct resource *res;u32 value;int ret;@@ -703,6 +704,23 @@ static int ramoops_parse_dt(struct platform_device *pdev,#undef parse_size +/* +* Some old Chromebooks relied on the kernel setting the console_size +* and pmsg_size to the record size since that's what the downstream +* kernel did. These same Chromebooks had "ramoops" straight under +* the root node which isn't according to the upstream bindings. Let's +* make those old Chromebooks work by detecting this and mimicing the +* expected behavior. +*/ + parent_node =of_get_parent (of_node); +if (of_node_is_root (parent_node) && + !pdata->console_size && !pdata->ftrace_size && + !pdata->pmsg_size && !pdata->ecc_info.ecc_size) { + pdata->console_size = pdata->record_size; + pdata->pmsg_size = pdata->record_size; + } +of_node_put (parent_node); +return 0 ; } --2.21.0.1020.gf2820cf01a-goog
From: Douglas Anderson <[email protected]>
Date: Fri, May 3, 2019 at 10:48 AM
To: Kees Cook, Anton Vorontsov
Cc: <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, Douglas Anderson, Colin Cross, Tony Luck, <[email protected]>
Quoted 24 lines
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_sizematch 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.
Quoted 5 lines
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 <[email protected]>
I like this; thanks! Rob is this okay by you? I just want to double-check since it's part of the DT parsing logic.
I'll pick it up and add a Cc: stable.
-Kees
Quoted 44 lines
---
fs/pstore/ram.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)fs/pstore/ram.c +18
-1@@ -669,6 +669,7 @@ static int ramoops_parse_dt(struct platform_device *pdev, struct ramoops_platform_data *pdata) {struct device_node *of_node = pdev->dev.of_node; +struct device_node *parent_node;struct resource *res;u32 value;int ret;@@ -703,6 +704,23 @@ static int ramoops_parse_dt(struct platform_device *pdev,#undef parse_size +/* +* Some old Chromebooks relied on the kernel setting the console_size +* and pmsg_size to the record size since that's what the downstream +* kernel did. These same Chromebooks had "ramoops" straight under +* the root node which isn't according to the upstream bindings. Let's +* make those old Chromebooks work by detecting this and mimicing the +* expected behavior. +*/ + parent_node =of_get_parent (of_node); +if (of_node_is_root (parent_node) && + !pdata->console_size && !pdata->ftrace_size && + !pdata->pmsg_size && !pdata->ecc_info.ecc_size) { + pdata->console_size = pdata->record_size; + pdata->pmsg_size = pdata->record_size; + } +of_node_put (parent_node); +return 0 ; } --2.21.0.1020.gf2820cf01a-goog
Signature · 1 line
Kees Cook
Quoted 33 lines · Kees Cook
From: Douglas Anderson <[email protected]>
Date: Fri, May 3, 2019 at 10:48 AM
To: Kees Cook, Anton Vorontsov
Cc: <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, Douglas Anderson, Colin Cross, Tony Luck, <[email protected]>Quoted 24 lines
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_sizematch 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.
Quoted 8 lines
Quoted 5 lines
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 <[email protected]>I like this; thanks! Rob is this okay by you? I just want to double-check since it's part of the DT parsing logic.
I'll leave it to you. It does fall into the case of supporting downstream bindings that weren't reviewed (IIRC reviewed maybe, but not accepted) which isn't great precedent. OTOH, it's a small change for a largish number of devices.
Rob
Hi,
Quoted 37 lines · Kees Cook
From: Douglas Anderson <[email protected]>
Date: Fri, May 3, 2019 at 10:48 AM
To: Kees Cook, Anton Vorontsov
Cc: <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, Douglas Anderson, Colin Cross, Tony Luck, <[email protected]>Quoted 28 lines
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_sizematch 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.
Quoted 6 lines
Quoted 1 line
Signed-off-by Douglas Anderson <[email protected]>I like this; thanks! Rob is this okay by you? I just want to double-check since it's part of the DT parsing logic.
I'll pick it up and add a Cc: stable.
Hold off a second--I may need to send out a v2 but out of time for the day. I think I need a #include file to fix errors on x86:
Quoted 1 line
implicit declaration of function '
of_node_is_root' [-Werror,-Wimplicit-function-declaration
I'm unfortunately out of time for now, but I'll post a v2 within the next day.
-Doug
Hi,
Quoted 46 lines · Doug Anderson
Hi,
Quoted 42 lines · Kees Cook
From: Douglas Anderson <[email protected]>
Date: Fri, May 3, 2019 at 10:48 AM
To: Kees Cook, Anton Vorontsov
Cc: <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, Douglas Anderson, Colin Cross, Tony Luck, <[email protected]>Quoted 24 lines
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_sizematch 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.
Quoted 5 lines
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 <[email protected]>I like this; thanks! Rob is this okay by you? I just want to double-check since it's part of the DT parsing logic.
Quoted 8 lines
Quoted 1 line
I'll pick it up and add a Cc: stable.
Hold off a second--I may need to send out a v2 but out of time for the day. I think I need a #include file to fix errors on x86:
Quoted 1 line
implicit declaration of function '
of_node_is_root' [-Werror,-Wimplicit-function-declarationI'm unfortunately out of time for now, but I'll post a v2 within the next day.
OK, it needs this to land first:
https://lore.kernel.org/lkml/[email protected]/T/#u
I thought it'd be OK to just send a separate patch.
-Doug
Quoted 42 lines · Doug Anderson
Hi,
Quoted 39 lines · Kees Cook
From: Douglas Anderson <[email protected]>
Date: Fri, May 3, 2019 at 10:48 AM
To: Kees Cook, Anton Vorontsov
Cc: <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, Douglas Anderson, Colin Cross, Tony Luck, <[email protected]>Quoted 29 lines
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_sizematch 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 <[email protected]>
Quoted 9 lines
Quoted 4 lines
I like this; thanks! Rob is this okay by you? I just want to double-check since it's part of the DT parsing logic.
I'll pick it up and add a Cc: stable.
Hold off a second--I may need to send out a v2 but out of time for the day. I think I need a #include file to fix errors on x86:
Quoted 1 line
implicit declaration of function '
of_node_is_root' [-Werror,-Wimplicit-function-declaration
Instead of checking "of_node_is_root(parent_node)" the patch could check for parent_node not "/reserved-memory". Then the x86 error would not occur.
The check I am suggesting is not as precise, but it should be good enough for this case, correct?
-Frank
Quoted 6 lines
I'm unfortunately out of time for now, but I'll post a v2 within the next day.
-Doug
Hi,
Quoted 52 lines · Frank Rowand
Quoted 50 lines · Doug Anderson
Hi,
Quoted 37 lines · Kees Cook
From: Douglas Anderson <[email protected]>
Date: Fri, May 3, 2019 at 10:48 AM
To: Kees Cook, Anton Vorontsov
Cc: <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, Douglas Anderson, Colin Cross, Tony Luck, <[email protected]>Quoted 28 lines
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_sizematch 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.
Quoted 6 lines
Quoted 1 line
Signed-off-by Douglas Anderson <[email protected]>I like this; thanks! Rob is this okay by you? I just want to double-check since it's part of the DT parsing logic.
I'll pick it up and add a Cc: stable.
Hold off a second--I may need to send out a v2 but out of time for the day. I think I need a #include file to fix errors on x86:
Quoted 8 lines
Quoted 1 line
Quoted 1 line
implicit declaration of function '
of_node_is_root' [-Werror,-Wimplicit-function-declarationInstead of checking "
of_node_is_root(parent_node)" the patch could check forparent_nodenot "/reserved-memory". Then the x86 error would not occur.The check I am suggesting is not as precise, but it should be good enough for this case, correct?
Sure, there are a million different ways to slice it. If you prefer that instead of adding a dummy of_node_is_root() I'm happy to do that.
-Doug
Hi Doug,
Quoted 61 lines · Doug Anderson
Hi,
Quoted 58 lines · Frank Rowand
Quoted 42 lines · Doug Anderson
Hi,
Quoted 39 lines · Kees Cook
From: Douglas Anderson <[email protected]>
Date: Fri, May 3, 2019 at 10:48 AM
To: Kees Cook, Anton Vorontsov
Cc: <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, Douglas Anderson, Colin Cross, Tony Luck, <[email protected]>Quoted 29 lines
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_sizematch 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 <[email protected]>Quoted 9 lines
Quoted 4 lines
I like this; thanks! Rob is this okay by you? I just want to double-check since it's part of the DT parsing logic.
I'll pick it up and add a Cc: stable.
Hold off a second--I may need to send out a v2 but out of time for the day. I think I need a #include file to fix errors on x86:
Quoted 1 line
implicit declaration of function '
of_node_is_root' [-Werror,-Wimplicit-function-declarationInstead of checking "
of_node_is_root(parent_node)" the patch could check forparent_nodenot "/reserved-memory". Then the x86 error would not occur.
Quoted 5 lines
Quoted 2 lines
The check I am suggesting is not as precise, but it should be good enough for this case, correct?
Sure, there are a million different ways to slice it. If you prefer that instead of adding a dummy
of_node_is_root()I'm happy to do that.
Yes, I would prefer to avoid adding a dummy of_node_is_root() if the alternative is reasonable (and if I understand, you are saying the alternative is reasonable).
Thanks,
Frank
Quoted 2 lines · Douglas Anderson
When you try to run an upstream kernel on an old ARM-based Chromebook you'll find that console-ramoops doesn't work.
Ooh, nice! I still get annoyed by old depthcharge firmware. It's almost as if we should have gotten an upstream binding approved before baking it into firmware...
fs/pstore/ram.c static int ramoops_parse_dt(struct platform_device *pdev, · line 711
Quoted 12 lines
fs/pstore/ram.c +5
-0@@ -703,6 +704,23 @@ static int ramoops_parse_dt(struct platform_device *pdev,#undef parse_size +/* +* Some old Chromebooks relied on the kernel setting the console_size +* and pmsg_size to the record size since that's what the downstream +* kernel did. These same Chromebooks had "ramoops" straight under +* the root node which isn't according to the upstream bindings.
The last part of the sentence technically isn't true -- the original bindings (notably, with no DT maintainer Reviewed-by) didn't specify where such a node should be found:
35da60941e44 pstore/ram: add Device Tree bindings
so child-of-root used to be a valid location. But anyway, this code is just part of a heuristic for "old DT" (where later bindings clarified this), so it still seems valid.
fs/pstore/ram.c static int ramoops_parse_dt(struct platform_device *pdev, · line 713
Quoted 2 lines
fs/pstore/ram.c +1
-0Let's + * make those old Chromebooks work by detecting this and mimicing the
s/mimicing/mimicking/
Quoted 4 lines
fs/pstore/ram.c +3
-0+* expected behavior. +*/ + parent_node =of_get_parent (of_node);
fs/pstore/ram.c static int ramoops_parse_dt(struct platform_device *pdev, · line 725
Quoted 10 lines
fs/pstore/ram.c +8
-0+if (of_node_is_root (parent_node) && + !pdata->console_size && !pdata->ftrace_size && + !pdata->pmsg_size && !pdata->ecc_info.ecc_size) { + pdata->console_size = pdata->record_size; + pdata->pmsg_size = pdata->record_size; + } +of_node_put (parent_node); +return 0 ; }
Otherwise, looks good to me:
Hi,
Quoted 26 lines · Brian Norris
Quoted 2 lines · Douglas Anderson
When you try to run an upstream kernel on an old ARM-based Chromebook you'll find that console-ramoops doesn't work.
Ooh, nice! I still get annoyed by old depthcharge firmware. It's almost as if we should have gotten an upstream binding approved before baking it into firmware...
fs/pstore/ram.c static int ramoops_parse_dt(struct platform_device *pdev, · line 711
Quoted 12 lines
fs/pstore/ram.c +5
-0@@ -703,6 +704,23 @@ static int ramoops_parse_dt(struct platform_device *pdev,#undef parse_size +/* +* Some old Chromebooks relied on the kernel setting the console_size +* and pmsg_size to the record size since that's what the downstream +* kernel did. These same Chromebooks had "ramoops" straight under +* the root node which isn't according to the upstream bindings. The last part of the sentence technically isn't true -- the original bindings (notably, with no DT maintainer Reviewed-by) didn't specify where such a node should be found:
Quoted 5 lines
35da60941e44pstore/ram: add Device Tree bindingsso child-of-root used to be a valid location. But anyway, this code is just part of a heuristic for "old DT" (where later bindings clarified this), so it still seems valid.
I agree that it was unclear in the past, but it is true that being under the root node is not according to the _current_ upstream bindings, right? ;-)
Quoted 4 lines
fs/pstore/ram.c static int ramoops_parse_dt(struct platform_device *pdev, · line 713
Quoted 2 lines
fs/pstore/ram.c +1
-0Let's + * make those old Chromebooks work by detecting this and mimicing thes/mimicing/mimicking/
Kees: if you want me to spin with this typo fix then please let me know. Otherwise I'll assume it's less work for you to just fix it yourself when applying.
-Doug
Quoted 7 lines · Doug Anderson
Quoted 6 lines · Brian Norris
The last part of the sentence technically isn't true -- the original bindings (notably, with no DT maintainer Reviewed-by) didn't specify where such a node should be found:
35da60941e44pstore/ram: add Device Tree bindings
Quoted 7 lines
Quoted 3 lines
so child-of-root used to be a valid location. But anyway, this code is just part of a heuristic for "old DT" (where later bindings clarified this), so it still seems valid.
I agree that it was unclear in the past, but it is true that being under the root node is not according to the _current_ upstream bindings, right? ;-)
Sure, I suppose. Although, given the general ABI policy around DT, it seems to me that something that was "according to" an old binding cannot really be made "no longer" according to the binding. It can be discouraged, and removed from new DTs, but it doesn't really become *wrong*.
But our DT was definitely *not* according to even the (un-reviewed) merged binding. So I'm mostly mincing words here.
Brian