Skip to content

Commit 7924b69

Browse files
manish-pandey-armTrustedFirmware Code Review
authored andcommitted
Merge "feat(arm): unify Linux kernel as BL33 handling" into integration
2 parents 168d78c + 2f5fd82 commit 7924b69

File tree

8 files changed

+38
-24
lines changed

8 files changed

+38
-24
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,7 @@ $(eval $(call add_defines,\
898898
EARLY_CONSOLE \
899899
PRESERVE_DSU_PMU_REGS \
900900
HOB_LIST \
901+
HW_CONFIG_BASE \
901902
LFA_SUPPORT \
902903
)))
903904

docs/getting_started/build-options.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,9 @@ Common build options
794794
algorithm. It accepts 3 values: ``sha256``, ``sha384`` and ``sha512``.
795795
The default value of this flag is ``sha256``.
796796

797+
- ``HW_CONFIG_BASE``: This option specifies the location in memory where the DTB
798+
should either be loaded by BL2 or can be found by later stages.
799+
797800
- ``LDFLAGS``: Extra user options appended to the linkers' command line in
798801
addition to the one set by the build system.
799802

docs/plat/arm/arm-build-options.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ Arm Platform Build Options
3333
- ``ARM_LINUX_KERNEL_AS_BL33``: The Linux kernel expects registers x0-x3 to
3434
have specific values at boot. This boolean option allows the Trusted Firmware
3535
to have a Linux kernel image as BL33 by preparing the registers to these
36-
values before jumping to BL33. This option defaults to 0 (disabled). For
37-
AArch64 ``RESET_TO_BL31`` and for AArch32 ``RESET_TO_SP_MIN`` must be 1 when
38-
using it. If this option is set to 1, ``ARM_PRELOADED_DTB_BASE`` must be set
39-
to the location of a device tree blob (DTB) already loaded in memory. The
40-
Linux Image address must be specified using the ``PRELOADED_BL33_BASE``
41-
option.
36+
values before jumping to BL33. This option defaults to 0 (disabled). When
37+
enabled (1), the address of the Linux image must be provided via the
38+
``PRELOADED_BL33_BASE`` option. Additionally, either the ``HW_CONFIG_BASE``
39+
or ``ARM_PRELOADED_DTB_BASE`` option must specify the memory location of a
40+
preloaded device tree blob (DTB). This option implies
41+
``USE_KERNEL_DT_CONVENTION``.
4242

4343
- ``ARM_PLAT_MT``: This flag determines whether the Arm platform layer has to
4444
cater for the multi-threading ``MT`` bit when accessing MPIDR. When this flag
@@ -167,4 +167,4 @@ Arm Neoverse RD Platform Build Options
167167

168168
.. |FIP in a GPT image| image:: ../../resources/diagrams/FIP_in_a_GPT_image.png
169169

170-
*Copyright (c) 2019-2024, Arm Limited. All rights reserved.*
170+
*Copyright (c) 2019-2025, Arm Limited. All rights reserved.*

docs/plat/arm/fvp/fvp-build-options.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ Arm FVP Platform Specific Build Options
4242
HW_CONFIG blob instead of the DTS file. This option is useful to override
4343
the default HW_CONFIG selected by the build system.
4444

45-
- ``FVP_HW_CONFIG_ADDR`` : Specify the memory address in which to load the
46-
HW_CONFIG. The default value is ``0x82000000``.
47-
4845
- ``FVP_GICR_REGION_PROTECTION``: Mark the redistributor pages of
4946
inactive/fused CPU cores as read-only. The default value of this option
5047
is ``0``, which means the redistributor pages of all CPU cores are marked

plat/arm/board/fvp/fdts/fvp_fw_config.dts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
load-address = <0x0 0x07f00000>;
2828
max-size = <PLAT_ARM_HW_CONFIG_SIZE>;
2929
id = <HW_CONFIG_ID>;
30-
secondary-load-address = <0x0 FVP_HW_CONFIG_ADDR>;
30+
secondary-load-address = <0x0 HW_CONFIG_BASE>;
3131
};
3232

3333
/*

plat/arm/board/fvp/platform.mk

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,7 @@ FDT_SOURCES += ${FVP_HW_CONFIG_DTS}
377377
$(eval FVP_HW_CONFIG := ${BUILD_PLAT}/$(patsubst %.dts,%.dtb,$(FVP_HW_CONFIG_DTS)))
378378
HW_CONFIG := ${FVP_HW_CONFIG}
379379

380-
# Allow hw_config's secondary-load-address in the DT to be changed
381-
FVP_HW_CONFIG_ADDR ?= 0x82000000
382-
DTC_CPPFLAGS += -DFVP_HW_CONFIG_ADDR=$(FVP_HW_CONFIG_ADDR)
380+
HW_CONFIG_BASE ?= 0x82000000
383381

384382
# Set default initrd base 128MiB offset of the default kernel address in FVP
385383
INITRD_BASE ?= 0x90000000

plat/arm/common/arm_bl31_setup.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,6 @@ void __init arm_bl31_early_platform_setup(u_register_t arg0, u_register_t arg1,
254254
* is located and the entry state information
255255
*/
256256
bl33_image_ep_info.pc = plat_get_ns_image_entrypoint();
257-
258-
#if ARM_LINUX_KERNEL_AS_BL33
259-
bl33_image_ep_info.args.arg0 = ARM_PRELOADED_DTB_BASE;
260-
bl33_image_ep_info.args.arg1 = 0U;
261-
bl33_image_ep_info.args.arg2 = 0U;
262-
bl33_image_ep_info.args.arg3 = 0U;
263-
#endif /* ARM_LINUX_KERNEL_AS_BL33 */
264-
265257
bl33_image_ep_info.spsr = arm_get_spsr(BL33_IMAGE_ID);
266258
SET_SECURITY_STATE(bl33_image_ep_info.h.attr, NON_SECURE);
267259

@@ -337,6 +329,24 @@ void __init arm_bl31_early_platform_setup(u_register_t arg0, u_register_t arg1,
337329
panic();
338330
#endif
339331
#endif /* RESET_TO_BL31 */
332+
333+
#if USE_KERNEL_DT_CONVENTION
334+
/*
335+
* Only use the default DT base address if TF-A has not supplied one.
336+
* This can occur when the DT is side-loaded and its memory location
337+
* is unknown (e.g., RESET_TO_BL31).
338+
*/
339+
340+
if (bl33_image_ep_info.args.arg0 == 0U) {
341+
bl33_image_ep_info.args.arg0 = HW_CONFIG_BASE;
342+
}
343+
344+
#if ARM_LINUX_KERNEL_AS_BL33
345+
bl33_image_ep_info.args.arg1 = 0U;
346+
bl33_image_ep_info.args.arg2 = 0U;
347+
bl33_image_ep_info.args.arg3 = 0U;
348+
#endif
349+
#endif
340350
#endif /* TRANSFER_LIST */
341351
}
342352

plat/arm/common/arm_common.mk

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,20 @@ $(eval $(call assert_boolean,ARM_LINUX_KERNEL_AS_BL33))
112112
$(eval $(call add_define,ARM_LINUX_KERNEL_AS_BL33))
113113

114114
ifeq (${ARM_LINUX_KERNEL_AS_BL33},1)
115+
USE_KERNEL_DT_CONVENTION := 1
116+
115117
ifneq (${ARCH},aarch64)
116118
ifneq (${RESET_TO_SP_MIN},1)
117119
$(error ARM_LINUX_KERNEL_AS_BL33 is only available if RESET_TO_SP_MIN=1.)
118120
endif
119121
endif
120-
ifeq (${RESET_TO_BL31},1)
122+
ifndef HW_CONFIG_BASE
121123
ifndef ARM_PRELOADED_DTB_BASE
122-
$(error ARM_PRELOADED_DTB_BASE must be set if ARM_LINUX_KERNEL_AS_BL33 is used with RESET_TO_BL31.)
124+
$(error If ARM_LINUX_KERNEL_AS_BL33 is used, either HW_CONFIG_BASE or \
125+
ARM_PRELOADED_DTB_BASE must be set. )
123126
endif
127+
128+
HW_CONFIG_BASE := ${ARM_PRELOADED_DTB_BASE}
124129
$(eval $(call add_define,ARM_PRELOADED_DTB_BASE))
125130
endif
126131
endif

0 commit comments

Comments
 (0)