diff mbox series

[1/9] hw/arm/raspi: Don't do board-setup or secure-boot for raspi3

Message ID 20180313153458.26822-2-peter.maydell@linaro.org
State New
Headers show
Series raspi3: various fixes for Linux booting | expand

Commit Message

Peter Maydell March 13, 2018, 3:34 p.m. UTC
For the rpi1 and 2 we want to boot the Linux kernel via some
custom setup code that makes sure that the SMC instruction
acts as a no-op, because it's used for cache maintenance.
The rpi3 boots AArch64 kernels, which don't need SMC for
cache maintenance and always expect to be booted non-secure.
Don't fill in the aarch32-specific parts of the binfo struct.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/arm/raspi.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

Comments

Cameron Esfahani via March 13, 2018, 4:34 p.m. UTC | #1
> From: Qemu-devel <qemu-devel-
> bounces+andrew.baumann=microsoft.com@nongnu.org> On Behalf Of Peter
> Maydell
> Sent: Tuesday, 13 March 2018 08:35
> 
> For the rpi1 and 2 we want to boot the Linux kernel via some
> custom setup code that makes sure that the SMC instruction
> acts as a no-op, because it's used for cache maintenance.
> The rpi3 boots AArch64 kernels, which don't need SMC for
> cache maintenance and always expect to be booted non-secure.
> Don't fill in the aarch32-specific parts of the binfo struct.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  hw/arm/raspi.c | 17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
> index a37881433c..1ac0737149 100644
> --- a/hw/arm/raspi.c
> +++ b/hw/arm/raspi.c
> @@ -82,10 +82,19 @@ static void setup_boot(MachineState *machine, int
> version, size_t ram_size)
>      binfo.board_id = raspi_boardid[version];
>      binfo.ram_size = ram_size;
>      binfo.nb_cpus = smp_cpus;
> -    binfo.board_setup_addr = BOARDSETUP_ADDR;
> -    binfo.write_board_setup = write_board_setup;
> -    binfo.secure_board_setup = true;
> -    binfo.secure_boot = true;
> +
> +    if (version <= 2) {
> +        /* The rpi1 and 2 require some custom setup code to run in Secure
> +         * mode before booting a kernel (to set up the SMC vectors so
> +         * that we get a no-op SMC; this is used by Linux to call the
> +         * firmware for some cache maintenance operations.
> +         * The rpi3 doesn't need this.
> +         */
> +        binfo.board_setup_addr = BOARDSETUP_ADDR;
> +        binfo.write_board_setup = write_board_setup;
> +        binfo.secure_board_setup = true;
> +        binfo.secure_boot = true;
> +    }
> 
>      /* Pi2 and Pi3 requires SMP setup */
>      if (version >= 2) {

Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
Philippe Mathieu-Daudé March 13, 2018, 11:20 p.m. UTC | #2
On 03/13/2018 04:34 PM, Peter Maydell wrote:
> For the rpi1 and 2 we want to boot the Linux kernel via some
> custom setup code that makes sure that the SMC instruction
> acts as a no-op, because it's used for cache maintenance.
> The rpi3 boots AArch64 kernels, which don't need SMC for
> cache maintenance and always expect to be booted non-secure.
> Don't fill in the aarch32-specific parts of the binfo struct.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  hw/arm/raspi.c | 17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
> index a37881433c..1ac0737149 100644
> --- a/hw/arm/raspi.c
> +++ b/hw/arm/raspi.c
> @@ -82,10 +82,19 @@ static void setup_boot(MachineState *machine, int version, size_t ram_size)
>      binfo.board_id = raspi_boardid[version];
>      binfo.ram_size = ram_size;
>      binfo.nb_cpus = smp_cpus;
> -    binfo.board_setup_addr = BOARDSETUP_ADDR;
> -    binfo.write_board_setup = write_board_setup;
> -    binfo.secure_board_setup = true;
> -    binfo.secure_boot = true;
> +
> +    if (version <= 2) {
> +        /* The rpi1 and 2 require some custom setup code to run in Secure
> +         * mode before booting a kernel (to set up the SMC vectors so
> +         * that we get a no-op SMC; this is used by Linux to call the
> +         * firmware for some cache maintenance operations.
> +         * The rpi3 doesn't need this.
> +         */

I was expecting a much complicated fix... neat.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> +        binfo.board_setup_addr = BOARDSETUP_ADDR;
> +        binfo.write_board_setup = write_board_setup;
> +        binfo.secure_board_setup = true;
> +        binfo.secure_boot = true;
> +    }
>  
>      /* Pi2 and Pi3 requires SMP setup */
>      if (version >= 2) {
>
diff mbox series

Patch

diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index a37881433c..1ac0737149 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -82,10 +82,19 @@  static void setup_boot(MachineState *machine, int version, size_t ram_size)
     binfo.board_id = raspi_boardid[version];
     binfo.ram_size = ram_size;
     binfo.nb_cpus = smp_cpus;
-    binfo.board_setup_addr = BOARDSETUP_ADDR;
-    binfo.write_board_setup = write_board_setup;
-    binfo.secure_board_setup = true;
-    binfo.secure_boot = true;
+
+    if (version <= 2) {
+        /* The rpi1 and 2 require some custom setup code to run in Secure
+         * mode before booting a kernel (to set up the SMC vectors so
+         * that we get a no-op SMC; this is used by Linux to call the
+         * firmware for some cache maintenance operations.
+         * The rpi3 doesn't need this.
+         */
+        binfo.board_setup_addr = BOARDSETUP_ADDR;
+        binfo.write_board_setup = write_board_setup;
+        binfo.secure_board_setup = true;
+        binfo.secure_boot = true;
+    }
 
     /* Pi2 and Pi3 requires SMP setup */
     if (version >= 2) {