Skip to contentSkip to conversation

powerpc/prom: Fix "ibm,arch-vec-5-platform-support" scan

PATCH Applied Cédric Le Goater 3 participants 3 messages Jan 22, 2021 – Feb 3, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/prom: Fix "ibm,arch-vec-5-platform-support" scan

The "ibm,arch-vec-5-platform-support" property is a list of pairs of bytes representing the options and values supported by the platform firmware. At boot time, Linux scans this list and activates the available features it recognizes : Radix and XIVE.

A recent change modified the number of entries to loop on and 8 bytes, 4 pairs of { options, values } entries are always scanned. This is fine on KVM but not on PowerVM which can advertises less. As a consequence on this platform, Linux reads extra entries pointing to random data, interprets these as available features and tries to activate them, leading to a firmware crash in ibm,client-architecture-support.

Fix that by using the property length of "ibm,arch-vec-5-platform-support".

Cc [email protected] # v4.20+
Fixes ab91239942a9 ("powerpc/prom: Remove VLA in prom_check_platform_support()")
---
 arch/powerpc/kernel/prom_init.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
arch/powerpc/kernel/prom_init.c +4 -8
index e9d4eb6144e1..ccf77b985c8f 100644
@@ -1331,14 +1331,10 @@ static void __init prom_check_platform_support(void)
 		if (prop_len > sizeof(vec))
 			prom_printf("WARNING: ibm,arch-vec-5-platform-support longer than expected (len: %d)\n",
 				    prop_len);
-		prom_getprop(prom.chosen, "ibm,arch-vec-5-platform-support",
-			     &vec, sizeof(vec));
-		for (i = 0; i < sizeof(vec); i += 2) {
-			prom_debug("%d: index = 0x%x val = 0x%x\n", i / 2
-								  , vec[i]
-								  , vec[i + 1]);
-			prom_parse_platform_support(vec[i], vec[i + 1],
-						    &supported);
+		prom_getprop(prom.chosen, "ibm,arch-vec-5-platform-support", &vec, sizeof(vec));
+		for (i = 0; i < prop_len; i += 2) {
+			prom_debug("%d: index = 0x%x val = 0x%x\n", i / 2, vec[i], vec[i + 1]);
+			prom_parse_platform_support(vec[i], vec[i + 1], &supported);
 		}
 	}
 
Signature · 1 line
2.26.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Cédric Le Goater

The "ibm,arch-vec-5-platform-support" property is a list of pairs of bytes representing the options and values supported by the platform firmware. At boot time, Linux scans this list and activates the available features it recognizes : Radix and XIVE.

A recent change modified the number of entries to loop on and 8 bytes, 4 pairs of { options, values } entries are always scanned. This is fine on KVM but not on PowerVM which can advertises less. As a consequence on this platform, Linux reads extra entries pointing to random data, interprets these as available features and tries to activate them, leading to a firmware crash in ibm,client-architecture-support.

Quoted 5 lines

Fix that by using the property length of "ibm,arch-vec-5-platform-support".

Cc [email protected] # v4.20+
Fixes ab91239942a9 ("powerpc/prom: Remove VLA in prom_check_platform_support()")
Quoted 26 lines
---
 arch/powerpc/kernel/prom_init.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
arch/powerpc/kernel/prom_init.c +4 -8
index e9d4eb6144e1..ccf77b985c8f 100644
@@ -1331,14 +1331,10 @@ static void __init prom_check_platform_support(void)
 		if (prop_len > sizeof(vec))
 			prom_printf("WARNING: ibm,arch-vec-5-platform-support longer than expected (len: %d)\n",
 				    prop_len);
-		prom_getprop(prom.chosen, "ibm,arch-vec-5-platform-support",
-			     &vec, sizeof(vec));
-		for (i = 0; i < sizeof(vec); i += 2) {
-			prom_debug("%d: index = 0x%x val = 0x%x\n", i / 2
-								  , vec[i]
-								  , vec[i + 1]);
-			prom_parse_platform_support(vec[i], vec[i + 1],
-						    &supported);
+		prom_getprop(prom.chosen, "ibm,arch-vec-5-platform-support", &vec, sizeof(vec));
+		for (i = 0; i < prop_len; i += 2) {
+			prom_debug("%d: index = 0x%x val = 0x%x\n", i / 2, vec[i], vec[i + 1]);
+			prom_parse_platform_support(vec[i], vec[i + 1], &supported);
 		}
 	}
#2 lore raw
In reply to Cédric Le Goater
Quoted 13 lines · Cédric Le Goater

The "ibm,arch-vec-5-platform-support" property is a list of pairs of bytes representing the options and values supported by the platform firmware. At boot time, Linux scans this list and activates the available features it recognizes : Radix and XIVE.

A recent change modified the number of entries to loop on and 8 bytes, 4 pairs of { options, values } entries are always scanned. This is fine on KVM but not on PowerVM which can advertises less. As a consequence on this platform, Linux reads extra entries pointing to random data, interprets these as available features and tries to activate them, leading to a firmware crash in ibm,client-architecture-support.

Quoted 1 line

[...]

Applied to powerpc/next.

[1/1] powerpc/prom: Fix "ibm,arch-vec-5-platform-support" scan

      https://git.kernel.org/powerpc/c/ed5b00a05c2ae95b59adc3442f45944ec632e794

cheers