All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/prom: Fix "ibm,arch-vec-5-platform-support" scan
@ 2021-01-22  7:50 ` Cédric Le Goater
  0 siblings, 0 replies; 4+ messages in thread
From: Cédric Le Goater @ 2021-01-22  7:50 UTC (permalink / raw
  To: linuxppc-dev; +Cc: Michael Ellerman, Cédric Le Goater, stable

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: stable@vger.kernel.org # v4.20+
Fixes: ab91239942a9 ("powerpc/prom: Remove VLA in prom_check_platform_support()")
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 arch/powerpc/kernel/prom_init.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index e9d4eb6144e1..ccf77b985c8f 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -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.26.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] powerpc/prom: Fix "ibm,arch-vec-5-platform-support" scan
@ 2021-01-22  7:50 ` Cédric Le Goater
  0 siblings, 0 replies; 4+ messages in thread
From: Cédric Le Goater @ 2021-01-22  7:50 UTC (permalink / raw
  To: linuxppc-dev; +Cc: Cédric Le Goater, stable

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: stable@vger.kernel.org # v4.20+
Fixes: ab91239942a9 ("powerpc/prom: Remove VLA in prom_check_platform_support()")
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 arch/powerpc/kernel/prom_init.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index e9d4eb6144e1..ccf77b985c8f 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -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.26.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] powerpc/prom: Fix "ibm,arch-vec-5-platform-support" scan
  2021-01-22  7:50 ` Cédric Le Goater
  (?)
@ 2021-01-22 13:25 ` Fabiano Rosas
  -1 siblings, 0 replies; 4+ messages in thread
From: Fabiano Rosas @ 2021-01-22 13:25 UTC (permalink / raw
  To: Cédric Le Goater, linuxppc-dev; +Cc: Cédric Le Goater, stable

Cédric Le Goater <clg@kaod.org> writes:

> 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: stable@vger.kernel.org # v4.20+
> Fixes: ab91239942a9 ("powerpc/prom: Remove VLA in prom_check_platform_support()")
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

Reviewed-by: Fabiano Rosas <farosas@linux.ibm.com>

> ---
>  arch/powerpc/kernel/prom_init.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
> index e9d4eb6144e1..ccf77b985c8f 100644
> --- a/arch/powerpc/kernel/prom_init.c
> +++ b/arch/powerpc/kernel/prom_init.c
> @@ -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);
>  		}
>  	}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] powerpc/prom: Fix "ibm,arch-vec-5-platform-support" scan
  2021-01-22  7:50 ` Cédric Le Goater
  (?)
  (?)
@ 2021-02-03 11:40 ` Michael Ellerman
  -1 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2021-02-03 11:40 UTC (permalink / raw
  To: linuxppc-dev, Cédric Le Goater; +Cc: stable

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 940 bytes --]

On Fri, 22 Jan 2021 08:50:29 +0100, Cédric Le Goater wrote:
> 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.
> 
> [...]

Applied to powerpc/next.

[1/1] powerpc/prom: Fix "ibm,arch-vec-5-platform-support" scan
      https://git.kernel.org/powerpc/c/ed5b00a05c2ae95b59adc3442f45944ec632e794

cheers

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-02-03 12:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-22  7:50 [PATCH] powerpc/prom: Fix "ibm,arch-vec-5-platform-support" scan Cédric Le Goater
2021-01-22  7:50 ` Cédric Le Goater
2021-01-22 13:25 ` Fabiano Rosas
2021-02-03 11:40 ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.