blob: 943afdee3a5e8540de6f42e6e2d226b3e0ef78bd [file] [log] [blame]
Brad Bishopbec4ebc2022-08-03 09:55:16 -04001From 6dfc937d1ae54d2ae9f8c60ca29ba73ca14dc8c4 Mon Sep 17 00:00:00 2001
2From: Jaxson Han <jaxson.han@arm.com>
3Date: Wed, 29 Dec 2021 15:33:17 +0800
4Subject: [PATCH] boot: Enable firmware node initialization
5
6Enable the firmware node initialization, so that the next stage
7(hypervisor) could share the EL2 with firmware (boot-wrapper). The next
8stage (hypervisor) get the smccc entry point, code/data sections, the
9sections attrs and firmware node version and so on.
10It is worth noting that this EL2 sharing mechanism is only for Armv8R
11AArch64, thus add flag_v8r to record if the arch is Armv8R AArch64.
12Enable the firmware node initialization only if it is Armv8R AArch64.
13Also, we increase the stack size to 1024 to fix the stack overflow issue
14when using the libfdt.
15
16Add -fno-builtin options to CFLAGS to avoid the issue that the 'memset'
17in common/lib.c conflicts with builtin 'memset' function. GCC version
18>= 10 will have an incorrect compilation without -fno-builtin;
19
20Issue-Id: SCM-3816
21Upstream-Status: Inappropriate [other]
22 Implementation pending further discussion
23Signed-off-by: Jaxson Han <jaxson.han@arm.com>
24Change-Id: Ib274485a34d26215595fd0cd737be86610289817
25---
26 Makefile.am | 4 ++--
27 arch/aarch64/boot.S | 6 ++++++
28 common/boot.c | 4 ++++
29 3 files changed, 12 insertions(+), 2 deletions(-)
30
31diff --git a/Makefile.am b/Makefile.am
32index 054becd..b01809c 100644
33--- a/Makefile.am
34+++ b/Makefile.am
35@@ -23,7 +23,7 @@ DEFINES += -DCPU_IDS=$(CPU_IDS)
36 DEFINES += -DNR_CPUS=$(NR_CPUS)
37 DEFINES += $(if $(SYSREGS_BASE), -DSYSREGS_BASE=$(SYSREGS_BASE), )
38 DEFINES += -DUART_BASE=$(UART_BASE)
39-DEFINES += -DSTACK_SIZE=256
40+DEFINES += -DSTACK_SIZE=1024
41
42 if KERNEL_32
43 DEFINES += -DKERNEL_32
44@@ -132,7 +132,7 @@ CHOSEN_NODE := chosen { \
45 CPPFLAGS += $(INITRD_FLAGS)
46 CFLAGS += -I$(top_srcdir)/include/ -I$(top_srcdir)/$(ARCH_SRC)/include/
47 CFLAGS += -Wall -fomit-frame-pointer
48-CFLAGS += -fno-stack-protector
49+CFLAGS += -fno-stack-protector -fno-builtin
50 CFLAGS += -ffunction-sections -fdata-sections
51 CFLAGS += -fno-pic -fno-pie
52 LDFLAGS += --gc-sections
53diff --git a/arch/aarch64/boot.S b/arch/aarch64/boot.S
54index 157c097..f310387 100644
55--- a/arch/aarch64/boot.S
56+++ b/arch/aarch64/boot.S
57@@ -240,6 +240,10 @@ el2_init:
58 #endif
59 ldr x1, =spsr_to_elx
60 str w0, [x1]
61+
62+ mov w0, #1
63+ ldr x1, =flag_v8r
64+ str w0, [x1]
65 // fall through
66
67 el_max_init:
68@@ -319,3 +323,5 @@ flag_keep_el:
69 .long 0
70 ASM_DATA(spsr_to_elx)
71 .long 0
72+ASM_DATA(flag_v8r)
73+ .long 0
74diff --git a/common/boot.c b/common/boot.c
75index ee2bea0..38b2dca 100644
76--- a/common/boot.c
77+++ b/common/boot.c
78@@ -11,6 +11,9 @@
79
80 extern unsigned long entrypoint;
81 extern unsigned long dtb;
82+extern unsigned int flag_v8r;
83+
84+extern void dt_fw_node_init(int enable);
85
86 void init_platform(void);
87
88@@ -64,6 +67,7 @@ void __noreturn first_spin(unsigned int cpu, unsigned long *mbox,
89 if (cpu == 0) {
90 init_platform();
91 dt_add_memreserve();
92+ dt_fw_node_init(flag_v8r == 1);
93
94 *mbox = (unsigned long)&entrypoint;
95 sevl();
96--
972.25.1
98