bsps/aarch64: Customize EL2/EL3 start support

Make the support for starting in EL2/EL3 customizable.  A boot loader or
the Arm Trusted Firmware should start RTEMS in non-secure EL1 mode.

In start.S, use local labels.

For the aarch64/xilinx-zynqmp the support for starting in EL2/EL3 is
disabled by default.  For the Qemu xlnx-zcu102 machine, the default is
to start in non-secure EL1 mode.  This can be controlled by options, for
example "-machine xlnx-zcu102,secure=on,virtualization=on".
This commit is contained in:
Sebastian Huber
2024-10-04 03:48:18 +02:00
parent dd3bc5bfb7
commit 07217e3f5c
9 changed files with 71 additions and 10 deletions

View File

@@ -37,10 +37,12 @@
#include <bsp.h>
#include <bsp/start.h>
#ifdef BSP_START_ENABLE_EL3_START_SUPPORT
BSP_START_TEXT_SECTION void bsp_start_hook_0(void)
{
/* Do nothing */
}
#endif
BSP_START_TEXT_SECTION void bsp_start_hook_1(void)
{

View File

@@ -37,10 +37,12 @@
#include <bsp.h>
#include <bsp/start.h>
#ifdef BSP_START_ENABLE_EL3_START_SUPPORT
BSP_START_TEXT_SECTION void bsp_start_hook_0(void)
{
/* Do nothing */
}
#endif
BSP_START_TEXT_SECTION void bsp_start_hook_1(void)
{

View File

@@ -39,10 +39,12 @@
#include <bsp/start.h>
#include <rtems/score/cpu.h>
#ifdef BSP_START_ENABLE_EL3_START_SUPPORT
BSP_START_TEXT_SECTION void bsp_start_hook_0(void)
{
/* Do nothing */
}
#endif
BSP_START_TEXT_SECTION void bsp_start_hook_1(void)
{
@@ -50,4 +52,4 @@ BSP_START_TEXT_SECTION void bsp_start_hook_1(void)
bsp_start_copy_sections();
raspberrypi_4_setup_mmu_and_cache();
bsp_start_clear_bss();
}
}

View File

@@ -137,13 +137,18 @@ _start:
#endif
msr SCTLR_EL1, x0
#if defined(BSP_START_ENABLE_EL2_START_SUPPORT) || \
defined(BSP_START_ENABLE_EL3_START_SUPPORT)
mrs x0, CurrentEL
cmp x0, #(1<<2)
b.eq _el1_start
cmp x0, #(2<<2)
b.eq _el2_start
b.eq .L_el1_start
#endif
_el3_start:
#if defined(BSP_START_ENABLE_EL3_START_SUPPORT)
cmp x0, #(2<<2)
b.eq .L_el2_start
.L_el3_start:
/*
* Before leaving the Secure World, we need to initialize the GIC. We
* do that here in an early stack context in EL3. This will NOT work
@@ -189,11 +194,14 @@ _el3_start:
msr SPSR_EL3, x0
/* Set EL2 entry point */
adr x0, _el2_start
adr x0, .L_el2_start
msr ELR_EL3, x0
eret
#endif
_el2_start:
#if defined(BSP_START_ENABLE_EL2_START_SUPPORT) || \
defined(BSP_START_ENABLE_EL3_START_SUPPORT)
.L_el2_start:
/* Drop from EL2 to EL1 */
/* Configure HCR_EL2 */
@@ -212,11 +220,12 @@ _el2_start:
msr SPSR_EL2, x0
/* Set EL1 entry point */
adr x0, _el1_start
adr x0, .L_el1_start
msr ELR_EL2, x0
eret
_el1_start:
.L_el1_start:
#endif
#ifdef RTEMS_SMP
bl _AArch64_Get_current_processor_for_system_start

View File

@@ -38,10 +38,12 @@
#include <bsp/irq-generic.h>
#include <bsp/start.h>
#ifdef BSP_START_ENABLE_EL3_START_SUPPORT
BSP_START_TEXT_SECTION void bsp_start_hook_0(void)
{
bsp_interrupt_facility_initialize();
}
#endif
BSP_START_TEXT_SECTION void bsp_start_hook_1(void)
{

View File

@@ -45,10 +45,12 @@
#include <bsp/irq-generic.h>
#endif
#ifdef BSP_START_ENABLE_EL3_START_SUPPORT
BSP_START_TEXT_SECTION void bsp_start_hook_0( void )
{
/* do nothing */
}
#endif
BSP_START_TEXT_SECTION void bsp_start_hook_1( void )
{

View File

@@ -0,0 +1,18 @@
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
actions:
- get-boolean: null
- define-condition: null
build-type: option
copyrights:
- Copyright (C) 2024 embedded brains GmbH & Co. KG
default:
- enabled-by: true
value: true
description: |
If this option is defined, then starting the system in exception level 2
(EL2) is supported.
enabled-by: true
format: '{}'
links: []
name: BSP_START_ENABLE_EL2_START_SUPPORT
type: build

View File

@@ -0,0 +1,20 @@
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
actions:
- get-boolean: null
- define-condition: null
build-type: option
copyrights:
- Copyright (C) 2024 embedded brains GmbH & Co. KG
default:
- enabled-by: bsps/aarch64/xilinx-zynqmp
value: false
- enabled-by: true
value: true
description: |
If this option is defined, then starting the system in exception level 3
(EL3) is supported.
enabled-by: true
format: '{}'
links: []
name: BSP_START_ENABLE_EL3_START_SUPPORT
type: build

View File

@@ -7,7 +7,11 @@ cppflags: []
enabled-by: true
includes: []
install-path: ${BSP_LIBDIR}
links: []
links:
- role: build-dependency
uid: optstartel2
- role: build-dependency
uid: optstartel3
source:
- bsps/aarch64/shared/start/start.S
target: start.o