All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
To: u-boot@lists.denx.de
Subject: [PATCH v3 05/15] board: ns3: add api to save boot parameters passed from BL31
Date: Wed, 10 Jun 2020 16:11:10 +0530	[thread overview]
Message-ID: <20200610104120.30668-6-rayagonda.kokatanur@broadcom.com> (raw)
In-Reply-To: <20200610104120.30668-1-rayagonda.kokatanur@broadcom.com>

From: Abhishek Shah <abhishek.shah@broadcom.com>

Add API to save boot parameters passed from BL31

Use assembly implementation of save_boot_params instead of c function.
Because generally ATF does not set up SP_EL2 on exiting.
Thus, usage of a C function immediately after exiting with no stack
setup done by ATF explicitly, may cause SP_EL2 to be not sane,
which in turn causes a crash if this boot was not lucky to get
an SP_EL2 in valid range. Replace C implementation with assembly one
which does not use stack this early, and let u-boot to set up its stack
later.

Signed-off-by: Abhishek Shah <abhishek.shah@broadcom.com>
Signed-off-by: Rajesh Ravi <rajesh.ravi@broadcom.com>
Signed-off-by: Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>
Signed-off-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
---
 arch/arm/cpu/armv8/bcmns3/lowlevel.S         |  9 +++++++
 arch/arm/include/asm/arch-bcmns3/bl33_info.h | 26 ++++++++++++++++++++
 board/broadcom/bcmns3/ns3.c                  | 10 ++++++++
 3 files changed, 45 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-bcmns3/bl33_info.h

diff --git a/arch/arm/cpu/armv8/bcmns3/lowlevel.S b/arch/arm/cpu/armv8/bcmns3/lowlevel.S
index 202286248e..9d8eb7f117 100644
--- a/arch/arm/cpu/armv8/bcmns3/lowlevel.S
+++ b/arch/arm/cpu/armv8/bcmns3/lowlevel.S
@@ -88,3 +88,12 @@ ENTRY(__asm_flush_l3_dcache)
 	mov	lr, x29
 	ret
 ENDPROC(__asm_flush_l3_dcache)
+
+ENTRY(save_boot_params)
+/*
+ * void set_boot_params(uint64_t x0, uint64_t x1, uint64_t x2, uint64_t x3)
+ */
+	adr	x4, bl33_info
+	str	x0, [x4]
+	b	save_boot_params_ret
+ENDPROC(save_boot_params)
diff --git a/arch/arm/include/asm/arch-bcmns3/bl33_info.h b/arch/arm/include/asm/arch-bcmns3/bl33_info.h
new file mode 100644
index 0000000000..bbc95b0186
--- /dev/null
+++ b/arch/arm/include/asm/arch-bcmns3/bl33_info.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2020 Broadcom.
+ *
+ */
+
+#ifndef BL33_INFO_H
+#define BL33_INFO_H
+#include <asm/io.h>
+
+/* Increase version number each time this file is modified */
+#define BL33_INFO_VERSION	1
+
+struct chip_info {
+	unsigned int chip_id;
+	unsigned int rev_id;
+};
+
+struct bl33_info {
+	unsigned int version;
+	struct chip_info chip;
+};
+
+extern struct bl33_info *bl33_info;
+
+#endif
diff --git a/board/broadcom/bcmns3/ns3.c b/board/broadcom/bcmns3/ns3.c
index e38156723c..5e644bd466 100644
--- a/board/broadcom/bcmns3/ns3.c
+++ b/board/broadcom/bcmns3/ns3.c
@@ -8,6 +8,7 @@
 #include <asm/io.h>
 #include <asm/system.h>
 #include <asm/armv8/mmu.h>
+#include <asm/arch-bcmns3/bl33_info.h>
 
 static struct mm_region ns3_mem_map[] = {
 	{
@@ -33,8 +34,17 @@ struct mm_region *mem_map = ns3_mem_map;
 
 DECLARE_GLOBAL_DATA_PTR;
 
+/*
+ * Force the bl33_info to the data-section, as .bss will not be valid
+ * when save_boot_params is invoked.
+ */
+struct bl33_info *bl33_info __section(".data");
+
 int board_init(void)
 {
+	if (bl33_info->version != BL33_INFO_VERSION)
+		printf("*** warning: ATF BL31 and u-boot not in sync! ***\n");
+
 	return 0;
 }
 
-- 
2.17.1

  parent reply	other threads:[~2020-06-10 10:41 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-10 10:41 [PATCH v3 00/15] add initial support for broadcom NS3 soc Rayagonda Kokatanur
2020-06-10 10:41 ` [PATCH v3 01/15] board: ns3: add support for Broadcom Northstar 3 Rayagonda Kokatanur
2020-06-17  3:11   ` Simon Glass
2020-06-10 10:41 ` [PATCH v3 02/15] arm: cpu: armv8: add L3 memory flush support Rayagonda Kokatanur
2020-06-17  3:11   ` Simon Glass
2020-06-19 16:55     ` Rayagonda Kokatanur
2020-06-26  1:43       ` Simon Glass
2020-06-26  9:06         ` Rayagonda Kokatanur
2020-06-10 10:41 ` [PATCH v3 03/15] configs: ns3: enable clock subsystem Rayagonda Kokatanur
2020-06-17  3:11   ` Simon Glass
2020-06-17  6:44     ` Rayagonda Kokatanur
2020-06-10 10:41 ` [PATCH v3 04/15] dt-bindings: memory: ns3: add memory definitions Rayagonda Kokatanur
2020-06-26  1:11   ` Simon Glass
2020-06-10 10:41 ` Rayagonda Kokatanur [this message]
2020-06-26  1:11   ` [PATCH v3 05/15] board: ns3: add api to save boot parameters passed from BL31 Simon Glass
2020-06-26 17:15     ` Rayagonda Kokatanur
2020-06-10 10:41 ` [PATCH v3 06/15] board: ns3: default reset type to L3 Rayagonda Kokatanur
2020-06-26  1:11   ` Simon Glass
2020-06-30  4:43     ` Rayagonda Kokatanur
2020-07-03  0:46       ` Simon Glass
2020-07-08  7:01         ` Rayagonda Kokatanur
2020-07-08 15:01           ` Simon Glass
2020-07-08 15:14             ` Rayagonda Kokatanur
2020-06-10 10:41 ` [PATCH v3 07/15] dt-bindings: memory: ns3: update GIC LPI address Rayagonda Kokatanur
2020-06-26  1:11   ` Simon Glass
2020-07-04  7:50     ` Rayagonda Kokatanur
2020-07-04 18:50       ` Rayagonda Kokatanur
2020-07-05 18:21         ` Rayagonda Kokatanur
2020-07-06  5:26           ` Simon Glass
2020-07-06  6:23             ` Rayagonda Kokatanur
2020-07-08 15:21               ` Rayagonda Kokatanur
2020-06-10 10:41 ` [PATCH v3 08/15] board: ns3: program GIC LPI tables Rayagonda Kokatanur
2020-06-26  1:11   ` Simon Glass
2020-07-05 18:14     ` Rayagonda Kokatanur
2020-06-10 10:41 ` [PATCH v3 09/15] configs: ns3: enable GIC ITS LPI table programing Rayagonda Kokatanur
2020-06-26  1:11   ` Simon Glass
2020-06-10 10:41 ` [PATCH v3 10/15] dt-bindings: memory: ns3: add ddr memory definition Rayagonda Kokatanur
2020-06-26  1:11   ` Simon Glass
2020-06-10 10:41 ` [PATCH v3 11/15] board: ns3: define ddr memory layout Rayagonda Kokatanur
2020-06-26  1:11   ` Simon Glass
2020-06-10 10:41 ` [PATCH v3 12/15] board: ns3: limit U-boot relocation within 16MB memory Rayagonda Kokatanur
2020-06-26  1:11   ` Simon Glass
2020-06-26 10:21     ` Rayagonda Kokatanur
2020-06-29 17:26       ` Simon Glass
2020-07-08  8:17         ` Rayagonda Kokatanur
2020-06-10 10:41 ` [PATCH v3 13/15] include/configs: ns3: add env variables for Linux boot Rayagonda Kokatanur
2020-06-26  1:11   ` Simon Glass
2020-06-26 18:08     ` Rayagonda Kokatanur
2020-06-10 10:41 ` [PATCH v3 14/15] include/configs: ns3: add support for flashing images Rayagonda Kokatanur
2020-06-26  1:11   ` Simon Glass
2020-06-10 10:41 ` [PATCH v3 15/15] MAINTAINERS: update maintainers for broadcom ns3 platform Rayagonda Kokatanur
2020-06-26  1:11   ` Simon Glass
2020-06-26 14:27   ` Peter Tyser
2020-06-26 14:30     ` Rayagonda Kokatanur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200610104120.30668-6-rayagonda.kokatanur@broadcom.com \
    --to=rayagonda.kokatanur@broadcom.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.