linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] ARM: dts: bcm283x: Reserve first page for firmware
@ 2017-05-09  9:04 Phil Elwell
  2017-05-09 16:25 ` Florian Fainelli
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Phil Elwell @ 2017-05-09  9:04 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Russell King, Florian Fainelli,
	bcm-kernel-feedback-list, devicetree, linux-arm-kernel,
	linux-kernel, linux-rpi-kernel

The Raspberry Pi startup stub files for multi-core BCM27XX processors
make the secondary CPUs spin until the corresponding mailbox is
written. These stubs are loaded at physical address 0x00000xxx (as seen
by the ARMs), but this page will be reused by the kernel unless it is
explicitly reserved, causing the waiting cores to execute random code.

Use the /memreserve/ Device Tree directive to mark the first page as
off-limits to the kernel.

See: https://github.com/raspberrypi/linux/issues/1989

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
---

Changes in V2:
- Rebase against linux-next
- Drop downstream-only patch

 arch/arm/boot/dts/bcm283x.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi
index a3106aa..6d12c3e8 100644
--- a/arch/arm/boot/dts/bcm283x.dtsi
+++ b/arch/arm/boot/dts/bcm283x.dtsi
@@ -3,6 +3,8 @@
 #include <dt-bindings/clock/bcm2835-aux.h>
 #include <dt-bindings/gpio/gpio.h>
 
+/memreserve/ 0x00000000 0x00001000;
+
 /* This include file covers the common peripherals and configuration between
  * bcm2835 and bcm2836 implementations, leaving the CPU configuration to
  * bcm2835.dtsi and bcm2836.dtsi.
-- 
1.9.1

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

* Re: [PATCH V2] ARM: dts: bcm283x: Reserve first page for firmware
  2017-05-09  9:04 [PATCH V2] ARM: dts: bcm283x: Reserve first page for firmware Phil Elwell
@ 2017-05-09 16:25 ` Florian Fainelli
  2017-05-16 22:19   ` Eric Anholt
  2017-05-09 16:48 ` Eric Anholt
  2017-05-14 12:50 ` Andreas Färber
  2 siblings, 1 reply; 7+ messages in thread
From: Florian Fainelli @ 2017-05-09 16:25 UTC (permalink / raw)
  To: Phil Elwell, Rob Herring, Mark Rutland, Russell King,
	Florian Fainelli, bcm-kernel-feedback-list, devicetree,
	linux-arm-kernel, linux-kernel, linux-rpi-kernel

On 05/09/2017 02:04 AM, Phil Elwell wrote:
> The Raspberry Pi startup stub files for multi-core BCM27XX processors
> make the secondary CPUs spin until the corresponding mailbox is
> written. These stubs are loaded at physical address 0x00000xxx (as seen
> by the ARMs), but this page will be reused by the kernel unless it is
> explicitly reserved, causing the waiting cores to execute random code.
> 
> Use the /memreserve/ Device Tree directive to mark the first page as
> off-limits to the kernel.

This reserves a 4KB page here, is this good enough, or should we just go
directly to the maximum page granule size possible on an ARM64/Linux
system to be on the safe side?

> 
> See: https://github.com/raspberrypi/linux/issues/1989
> 
> Signed-off-by: Phil Elwell <phil@raspberrypi.org>
> ---
> 
> Changes in V2:
> - Rebase against linux-next
> - Drop downstream-only patch
> 
>  arch/arm/boot/dts/bcm283x.dtsi | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi
> index a3106aa..6d12c3e8 100644
> --- a/arch/arm/boot/dts/bcm283x.dtsi
> +++ b/arch/arm/boot/dts/bcm283x.dtsi
> @@ -3,6 +3,8 @@
>  #include <dt-bindings/clock/bcm2835-aux.h>
>  #include <dt-bindings/gpio/gpio.h>
>  
> +/memreserve/ 0x00000000 0x00001000;

Can you put a comment above this /memreserve entry here to remind about
what this is useful for?

Thanks!

> +
>  /* This include file covers the common peripherals and configuration between
>   * bcm2835 and bcm2836 implementations, leaving the CPU configuration to
>   * bcm2835.dtsi and bcm2836.dtsi.
> 


-- 
Florian

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

* Re: [PATCH V2] ARM: dts: bcm283x: Reserve first page for firmware
  2017-05-09  9:04 [PATCH V2] ARM: dts: bcm283x: Reserve first page for firmware Phil Elwell
  2017-05-09 16:25 ` Florian Fainelli
@ 2017-05-09 16:48 ` Eric Anholt
  2017-05-09 16:52   ` Florian Fainelli
  2017-05-14 12:50 ` Andreas Färber
  2 siblings, 1 reply; 7+ messages in thread
From: Eric Anholt @ 2017-05-09 16:48 UTC (permalink / raw)
  To: Phil Elwell, Rob Herring, Mark Rutland, Russell King,
	Florian Fainelli, bcm-kernel-feedback-list, devicetree,
	linux-arm-kernel, linux-kernel, linux-rpi-kernel

[-- Attachment #1: Type: text/plain, Size: 790 bytes --]

Phil Elwell <phil@raspberrypi.org> writes:

> The Raspberry Pi startup stub files for multi-core BCM27XX processors
> make the secondary CPUs spin until the corresponding mailbox is
> written. These stubs are loaded at physical address 0x00000xxx (as seen
> by the ARMs), but this page will be reused by the kernel unless it is
> explicitly reserved, causing the waiting cores to execute random code.
>
> Use the /memreserve/ Device Tree directive to mark the first page as
> off-limits to the kernel.
>
> See: https://github.com/raspberrypi/linux/issues/1989
>
> Signed-off-by: Phil Elwell <phil@raspberrypi.org>

This looks great.  We're currently in the merge window, so I can't
generate a new bcm2835-dt-next yet, but I'll pick this patch up when I
do.

Thanks for submitting upstream!

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

* Re: [PATCH V2] ARM: dts: bcm283x: Reserve first page for firmware
  2017-05-09 16:48 ` Eric Anholt
@ 2017-05-09 16:52   ` Florian Fainelli
  2017-05-09 18:10     ` Eric Anholt
  0 siblings, 1 reply; 7+ messages in thread
From: Florian Fainelli @ 2017-05-09 16:52 UTC (permalink / raw)
  To: Eric Anholt, Phil Elwell, Rob Herring, Mark Rutland,
	Russell King, bcm-kernel-feedback-list, devicetree,
	linux-arm-kernel, linux-kernel, linux-rpi-kernel

On 05/09/2017 09:48 AM, Eric Anholt wrote:
> Phil Elwell <phil@raspberrypi.org> writes:
> 
>> The Raspberry Pi startup stub files for multi-core BCM27XX processors
>> make the secondary CPUs spin until the corresponding mailbox is
>> written. These stubs are loaded at physical address 0x00000xxx (as seen
>> by the ARMs), but this page will be reused by the kernel unless it is
>> explicitly reserved, causing the waiting cores to execute random code.
>>
>> Use the /memreserve/ Device Tree directive to mark the first page as
>> off-limits to the kernel.
>>
>> See: https://github.com/raspberrypi/linux/issues/1989
>>
>> Signed-off-by: Phil Elwell <phil@raspberrypi.org>
> 
> This looks great.  We're currently in the merge window, so I can't
> generate a new bcm2835-dt-next yet, but I'll pick this patch up when I
> do.
> 
> Thanks for submitting upstream!

Considering that this is a fix, we could actually squeeze it in the
devicetree/fixes branch and we could submit those as soon as v4.12-rc1
is tagged, your call.
-- 
Florian

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

* Re: [PATCH V2] ARM: dts: bcm283x: Reserve first page for firmware
  2017-05-09 16:52   ` Florian Fainelli
@ 2017-05-09 18:10     ` Eric Anholt
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Anholt @ 2017-05-09 18:10 UTC (permalink / raw)
  To: Florian Fainelli, Phil Elwell, Rob Herring, Mark Rutland,
	Russell King, bcm-kernel-feedback-list, devicetree,
	linux-arm-kernel, linux-kernel, linux-rpi-kernel

[-- Attachment #1: Type: text/plain, Size: 1352 bytes --]

Florian Fainelli <f.fainelli@gmail.com> writes:

> On 05/09/2017 09:48 AM, Eric Anholt wrote:
>> Phil Elwell <phil@raspberrypi.org> writes:
>> 
>>> The Raspberry Pi startup stub files for multi-core BCM27XX processors
>>> make the secondary CPUs spin until the corresponding mailbox is
>>> written. These stubs are loaded at physical address 0x00000xxx (as seen
>>> by the ARMs), but this page will be reused by the kernel unless it is
>>> explicitly reserved, causing the waiting cores to execute random code.
>>>
>>> Use the /memreserve/ Device Tree directive to mark the first page as
>>> off-limits to the kernel.
>>>
>>> See: https://github.com/raspberrypi/linux/issues/1989
>>>
>>> Signed-off-by: Phil Elwell <phil@raspberrypi.org>
>> 
>> This looks great.  We're currently in the merge window, so I can't
>> generate a new bcm2835-dt-next yet, but I'll pick this patch up when I
>> do.
>> 
>> Thanks for submitting upstream!
>
> Considering that this is a fix, we could actually squeeze it in the
> devicetree/fixes branch and we could submit those as soon as v4.12-rc1
> is tagged, your call.

While the issue is a bit obscure, I know I've hit it as well.  I agree
that it's a good stable candidate, so unless you'd like to pick it
yourself and cc stable, I'll just send you a PR doing so when rc1 rolls
around.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

* Re: [PATCH V2] ARM: dts: bcm283x: Reserve first page for firmware
  2017-05-09  9:04 [PATCH V2] ARM: dts: bcm283x: Reserve first page for firmware Phil Elwell
  2017-05-09 16:25 ` Florian Fainelli
  2017-05-09 16:48 ` Eric Anholt
@ 2017-05-14 12:50 ` Andreas Färber
  2 siblings, 0 replies; 7+ messages in thread
From: Andreas Färber @ 2017-05-14 12:50 UTC (permalink / raw)
  To: Phil Elwell, linux-rpi-kernel
  Cc: Rob Herring, Mark Rutland, Russell King, Florian Fainelli,
	bcm-kernel-feedback-list, devicetree, linux-arm-kernel,
	linux-kernel, Stefan Wahren, Eric Anholt

Am 09.05.2017 um 11:04 schrieb Phil Elwell:
> The Raspberry Pi startup stub files for multi-core BCM27XX processors

Curiously, while this V2 was rebased to apply against the bcm283x rather
than bcm2710 file, it changed the text from BCM283X to BCM27XX.

> make the secondary CPUs spin until the corresponding mailbox is
> written. These stubs are loaded at physical address 0x00000xxx (as seen
> by the ARMs), but this page will be reused by the kernel unless it is
> explicitly reserved, causing the waiting cores to execute random code.
> 
> Use the /memreserve/ Device Tree directive to mark the first page as
> off-limits to the kernel.
> 
> See: https://github.com/raspberrypi/linux/issues/1989
> 
> Signed-off-by: Phil Elwell <phil@raspberrypi.org>
> ---
> 
> Changes in V2:
> - Rebase against linux-next
> - Drop downstream-only patch
> 
>  arch/arm/boot/dts/bcm283x.dtsi | 2 ++
>  1 file changed, 2 insertions(+)

Regards,
Andreas

-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)

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

* Re: [PATCH V2] ARM: dts: bcm283x: Reserve first page for firmware
  2017-05-09 16:25 ` Florian Fainelli
@ 2017-05-16 22:19   ` Eric Anholt
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Anholt @ 2017-05-16 22:19 UTC (permalink / raw)
  To: Florian Fainelli, Phil Elwell, Rob Herring, Mark Rutland,
	Russell King, Florian Fainelli, bcm-kernel-feedback-list,
	devicetree, linux-arm-kernel, linux-kernel, linux-rpi-kernel

[-- Attachment #1: Type: text/plain, Size: 1735 bytes --]

Florian Fainelli <f.fainelli@gmail.com> writes:

> On 05/09/2017 02:04 AM, Phil Elwell wrote:
>> The Raspberry Pi startup stub files for multi-core BCM27XX processors
>> make the secondary CPUs spin until the corresponding mailbox is
>> written. These stubs are loaded at physical address 0x00000xxx (as seen
>> by the ARMs), but this page will be reused by the kernel unless it is
>> explicitly reserved, causing the waiting cores to execute random code.
>> 
>> Use the /memreserve/ Device Tree directive to mark the first page as
>> off-limits to the kernel.
>
> This reserves a 4KB page here, is this good enough, or should we just go
> directly to the maximum page granule size possible on an ARM64/Linux
> system to be on the safe side?
>
>> 
>> See: https://github.com/raspberrypi/linux/issues/1989
>> 
>> Signed-off-by: Phil Elwell <phil@raspberrypi.org>
>> ---
>> 
>> Changes in V2:
>> - Rebase against linux-next
>> - Drop downstream-only patch
>> 
>>  arch/arm/boot/dts/bcm283x.dtsi | 2 ++
>>  1 file changed, 2 insertions(+)
>> 
>> diff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi
>> index a3106aa..6d12c3e8 100644
>> --- a/arch/arm/boot/dts/bcm283x.dtsi
>> +++ b/arch/arm/boot/dts/bcm283x.dtsi
>> @@ -3,6 +3,8 @@
>>  #include <dt-bindings/clock/bcm2835-aux.h>
>>  #include <dt-bindings/gpio/gpio.h>
>>  
>> +/memreserve/ 0x00000000 0x00001000;
>
> Can you put a comment above this /memreserve entry here to remind about
> what this is useful for?
>
> Thanks!

Phil, I chatted with Florian and added in:

+/* firmware-provided startup stubs live here, where the secondary CPUs are
+ * spinning.
+ */

and tagged and sent a PR for 4.12.  Thanks!

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

end of thread, other threads:[~2017-05-16 22:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-09  9:04 [PATCH V2] ARM: dts: bcm283x: Reserve first page for firmware Phil Elwell
2017-05-09 16:25 ` Florian Fainelli
2017-05-16 22:19   ` Eric Anholt
2017-05-09 16:48 ` Eric Anholt
2017-05-09 16:52   ` Florian Fainelli
2017-05-09 18:10     ` Eric Anholt
2017-05-14 12:50 ` Andreas Färber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).