[PATCH 6/6] bsps/aarch64: add non-secure mode and versal support
Gedare Bloom
gedare at rtems.org
Wed Jun 23 04:29:57 UTC 2021
---
bsps/aarch64/shared/start/start.S | 11 +++++++++
bsps/shared/dev/irq/arm-gicv3.c | 23 +++++++++++++++++--
spec/build/bsps/aarch64/a53/grp.yml | 2 ++
spec/build/bsps/aarch64/a72/grp.yml | 2 ++
spec/build/bsps/aarch64/optisns.yml | 20 ++++++++++++++++
.../aarch64/xilinx-versal/bspqemuilp32.yml | 4 +---
.../aarch64/xilinx-versal/bspqemulp64.yml | 4 +---
spec/build/bsps/aarch64/xilinx-versal/grp.yml | 6 +++++
.../bsps/aarch64/xilinx-versal/grp_qemu.yml | 18 +++++++++++++++
spec/build/bsps/aarch64/xilinx-zynqmp/grp.yml | 2 ++
spec/build/bsps/optstartmon.yml | 16 +++++++++++++
11 files changed, 100 insertions(+), 8 deletions(-)
create mode 100644 spec/build/bsps/aarch64/optisns.yml
create mode 100644 spec/build/bsps/aarch64/xilinx-versal/grp_qemu.yml
create mode 100644 spec/build/bsps/optstartmon.yml
diff --git a/bsps/aarch64/shared/start/start.S b/bsps/aarch64/shared/start/start.S
index d0d9c2160a..aa137a05ea 100644
--- a/bsps/aarch64/shared/start/start.S
+++ b/bsps/aarch64/shared/start/start.S
@@ -108,16 +108,27 @@ _start:
mrs x0, SCR_EL3
/* Set EL2 to AArch64 */
orr x0, x0, #(1<<10)
+#ifdef AARCH64_IS_NONSECURE
/* Set EL1 to NS */
orr x0, x0, #1
+#endif
msr SCR_EL3, x0
/* set EL2h mode for eret */
+#ifdef AARCH64_IS_NONSECURE
mov x0, #0b01001
+#else
+ mov x0, #0b00101
+#endif
+
msr SPSR_EL3, x0
/* Set EL2 entry point */
+#ifdef AARCH64_IS_NONSECURE
adr x0, _el2_start
+#else
+ adr x0, _el1_start
+#endif
msr ELR_EL3, x0
eret
#endif
diff --git a/bsps/shared/dev/irq/arm-gicv3.c b/bsps/shared/dev/irq/arm-gicv3.c
index 7a0d42b27b..d216f4f5f7 100644
--- a/bsps/shared/dev/irq/arm-gicv3.c
+++ b/bsps/shared/dev/irq/arm-gicv3.c
@@ -175,6 +175,15 @@ void bsp_interrupt_vector_enable(rtems_vector_number vector)
} else {
volatile gic_sgi_ppi *sgi_ppi =
gicv3_get_sgi_ppi(_SMP_Get_current_processor());
+ /* Set interrupt group to 1 in the current security mode */
+#if defined(AARCH64_IS_NONSECURE)
+ sgi_ppi->icspigrpr[0] |= 1 << (vector % 32);
+ sgi_ppi->icspigrpmodr[0] &= ~(1 << (vector % 32));
+#else
+ sgi_ppi->icspigrpr[0] &= ~(1 << (vector % 32));
+ sgi_ppi->icspigrpmodr[0] |= 1 << (vector % 32);
+#endif
+ /* Set enable */
sgi_ppi->icspiser[0] = 1 << (vector % 32);
}
}
@@ -217,10 +226,15 @@ static void gicv3_init_cpu_interface(void)
waker &= ~waker_mask;
redist->icrwaker = waker;
- /* Set interrupt group to 1NS for SGI/PPI interrupts routed through the redistributor */
volatile gic_sgi_ppi *sgi_ppi = gicv3_get_sgi_ppi(cpu_index);
+ /* Set interrupt group to 1 in the current security mode */
+#if defined(AARCH64_IS_NONSECURE)
sgi_ppi->icspigrpr[0] = 0xffffffff;
sgi_ppi->icspigrpmodr[0] = 0;
+#else
+ sgi_ppi->icspigrpr[0] = 0x0;
+ sgi_ppi->icspigrpmodr[0] = 0xffffffff;
+#endif
for (int id = 0; id < 32; id++) {
sgi_ppi->icspiprior[id] = PRIORITY_DEFAULT;
}
@@ -247,9 +261,14 @@ rtems_status_code bsp_interrupt_facility_initialize(void)
/* Disable all interrupts */
dist->icdicer[id / 32] = 0xffffffff;
- /* Set interrupt group to 1NS for all interrupts */
+ /* Set interrupt group to 1 in the current security mode */
+#if defined(AARCH64_IS_NONSECURE)
dist->icdigr[id / 32] = 0xffffffff;
dist->icdigmr[id / 32] = 0;
+#else
+ dist->icdigr[id / 32] = 0;
+ dist->icdigmr[id / 32] = 0xffffffff;
+#endif
}
for (id = 0; id < id_count; ++id) {
diff --git a/spec/build/bsps/aarch64/a53/grp.yml b/spec/build/bsps/aarch64/a53/grp.yml
index 19935d5a7a..9853c6deb7 100644
--- a/spec/build/bsps/aarch64/a53/grp.yml
+++ b/spec/build/bsps/aarch64/a53/grp.yml
@@ -11,6 +11,8 @@ links:
uid: ../grp
- role: build-dependency
uid: ../start
+- role: build-dependency
+ uid: ../optisns
- role: build-dependency
uid: abi
- role: build-dependency
diff --git a/spec/build/bsps/aarch64/a72/grp.yml b/spec/build/bsps/aarch64/a72/grp.yml
index 0f3e717a94..7544a47f9f 100644
--- a/spec/build/bsps/aarch64/a72/grp.yml
+++ b/spec/build/bsps/aarch64/a72/grp.yml
@@ -11,6 +11,8 @@ links:
uid: ../grp
- role: build-dependency
uid: ../start
+- role: build-dependency
+ uid: ../optisns
- role: build-dependency
uid: abi
- role: build-dependency
diff --git a/spec/build/bsps/aarch64/optisns.yml b/spec/build/bsps/aarch64/optisns.yml
new file mode 100644
index 0000000000..8db901604b
--- /dev/null
+++ b/spec/build/bsps/aarch64/optisns.yml
@@ -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) 2021 Gedare Bloom <gedare at rtems.org>
+default: true
+default-by-variant:
+- value: false
+ variants:
+ - aarch64/xilinx_versal_lp64_qemu
+ - aarch64/xilinx_versal_ilp32_qemu
+description: |
+ If set to true, then the processor starts and stays in the non-secure mode,
+ otherwise it will be in the secure mode.
+enabled-by: true
+links: []
+name: AARCH64_IS_NONSECURE
+type: build
diff --git a/spec/build/bsps/aarch64/xilinx-versal/bspqemuilp32.yml b/spec/build/bsps/aarch64/xilinx-versal/bspqemuilp32.yml
index 85d508a6f4..cdad919b1c 100644
--- a/spec/build/bsps/aarch64/xilinx-versal/bspqemuilp32.yml
+++ b/spec/build/bsps/aarch64/xilinx-versal/bspqemuilp32.yml
@@ -12,9 +12,7 @@ includes: []
install: []
links:
- role: build-dependency
- uid: grp
-- role: build-dependency
- uid: tstqemu
+ uid: grp_qemu
- role: build-dependency
uid: linkcmds_ilp32
source: []
diff --git a/spec/build/bsps/aarch64/xilinx-versal/bspqemulp64.yml b/spec/build/bsps/aarch64/xilinx-versal/bspqemulp64.yml
index 5df2483d34..bd8dab6a6e 100644
--- a/spec/build/bsps/aarch64/xilinx-versal/bspqemulp64.yml
+++ b/spec/build/bsps/aarch64/xilinx-versal/bspqemulp64.yml
@@ -12,9 +12,7 @@ includes: []
install: []
links:
- role: build-dependency
- uid: grp
-- role: build-dependency
- uid: tstqemu
+ uid: grp_qemu
- role: build-dependency
uid: linkcmds_lp64
source: []
diff --git a/spec/build/bsps/aarch64/xilinx-versal/grp.yml b/spec/build/bsps/aarch64/xilinx-versal/grp.yml
index 7c7dea0fef..977c732506 100644
--- a/spec/build/bsps/aarch64/xilinx-versal/grp.yml
+++ b/spec/build/bsps/aarch64/xilinx-versal/grp.yml
@@ -13,6 +13,12 @@ links:
uid: ../start
- role: build-dependency
uid: ../optmmupages
+- role: build-dependency
+ uid: ../optisns
+- role: build-dependency
+ uid: ../optgtusevirt
+- role: build-dependency
+ uid: ../optgtuseps
- role: build-dependency
uid: abi
- role: build-dependency
diff --git a/spec/build/bsps/aarch64/xilinx-versal/grp_qemu.yml b/spec/build/bsps/aarch64/xilinx-versal/grp_qemu.yml
new file mode 100644
index 0000000000..71d8c9ac49
--- /dev/null
+++ b/spec/build/bsps/aarch64/xilinx-versal/grp_qemu.yml
@@ -0,0 +1,18 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+build-type: group
+copyrights:
+- Copyright (C) 2021 Gedare Bloom <gedare at rtems.org>
+enabled-by: true
+includes: []
+install: []
+ldflags: []
+links:
+- role: build-dependency
+ uid: grp
+- role: build-dependency
+ uid: ../../optstartmon
+- role: build-dependency
+ uid: tstqemu
+type: build
+use-after: []
+use-before: []
diff --git a/spec/build/bsps/aarch64/xilinx-zynqmp/grp.yml b/spec/build/bsps/aarch64/xilinx-zynqmp/grp.yml
index 16e2b8a7e9..03ccdbbc8b 100644
--- a/spec/build/bsps/aarch64/xilinx-zynqmp/grp.yml
+++ b/spec/build/bsps/aarch64/xilinx-zynqmp/grp.yml
@@ -13,6 +13,8 @@ links:
uid: ../start
- role: build-dependency
uid: ../optmmupages
+- role: build-dependency
+ uid: ../optisns
- role: build-dependency
uid: abi
- role: build-dependency
diff --git a/spec/build/bsps/optstartmon.yml b/spec/build/bsps/optstartmon.yml
new file mode 100644
index 0000000000..49b46a1d08
--- /dev/null
+++ b/spec/build/bsps/optstartmon.yml
@@ -0,0 +1,16 @@
+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) 2021 Gedare Bloom <gedare at rtems.org>
+default: true
+default-by-variant: []
+description: |
+ If set to true, then the a system start in monitor mode (EL3) is
+ supported, otherwise it is unsupported.
+enabled-by: true
+links: []
+name: BSP_START_IN_MON_SUPPORT
+type: build
--
2.25.1
More information about the devel
mailing list