test(vhe): add vhe test setup with SPs
Created test setup based on "primary_with_secondaries" that deploys
both the SPMC with VHE enabled and the hypervisor:
- Primary VM controls test execution and communicates with an S-EL0
partition.
- S-EL0 partition added to replace "Secure Service1" (of the equivalent
setup without VHE enabled).
For the time being including only the indirect messaging test suite.
Change-Id: Ib9c58bf010bcfacfb8126afdeaccafae105d74e4
Signed-off-by: J-Alves <joao.alves@arm.com>
diff --git a/kokoro/test_spmc.sh b/kokoro/test_spmc.sh
index 5aa13d2..e22e726 100755
--- a/kokoro/test_spmc.sh
+++ b/kokoro/test_spmc.sh
@@ -35,4 +35,7 @@
--partitions_json test/vmapi/primary_with_secondaries/primary_with_sp.json
${HFTEST_VHE[@]} --hypervisor "$HYPERVISOR_PATH/hafnium.bin" \
+ --partitions_json test/vmapi/primary_with_secondaries/primary_with_sp_vhe.json
+
+${HFTEST_VHE[@]} --hypervisor "$HYPERVISOR_PATH/hafnium.bin" \
--partitions_json test/vmapi/ffa_secure_partitions/ffa_both_world_partitions_vhe_test.json
diff --git a/test/hftest/BUILD.gn b/test/hftest/BUILD.gn
index 24b7b0f..c64d5e3 100644
--- a/test/hftest/BUILD.gn
+++ b/test/hftest/BUILD.gn
@@ -64,6 +64,7 @@
sources = [
"sel0_secure_service.c",
+ "service_common.c",
]
deps = [
diff --git a/test/hftest/sel0_secure_service.c b/test/hftest/sel0_secure_service.c
index 6eca211..a5913a0 100644
--- a/test/hftest/sel0_secure_service.c
+++ b/test/hftest/sel0_secure_service.c
@@ -15,37 +15,27 @@
#include "vmapi/hf/call.h"
+#include "test/abort.h"
#include "test/hftest.h"
#include "test/vmapi/ffa.h"
alignas(4096) uint8_t kstack[4096];
-HFTEST_ENABLE();
-
-static struct hftest_context global_context;
-
-struct hftest_context *hftest_get_context(void)
-{
- return &global_context;
-}
-
bool sel1_secure_service = false;
+static struct ffa_boot_info_header* boot_info_header;
+
+struct ffa_boot_info_header* get_boot_info_header(void)
+{
+ return boot_info_header;
+}
+
void test_main_sp(bool);
-noreturn void abort(void)
+noreturn void kmain(struct ffa_boot_info_header* boot_info_blob)
{
- HFTEST_LOG("Service contained failures.");
- /* Cause a fault, as a secondary can't power down the machine. */
- *((volatile uint8_t *)1) = 1;
+ boot_info_header = boot_info_blob;
- /* This should never be reached, but to make the compiler happy... */
- for (;;) {
- }
-}
-
-noreturn void kmain(void)
-{
/* Register RX/TX buffers via FFA_RXTX_MAP */
set_up_mailbox();
diff --git a/test/vmapi/BUILD.gn b/test/vmapi/BUILD.gn
index 3a226bd..3c069da 100644
--- a/test/vmapi/BUILD.gn
+++ b/test/vmapi/BUILD.gn
@@ -16,6 +16,7 @@
"ffa_secure_partitions:ffa_both_world_partitions_test",
"ffa_secure_partitions:ffa_both_world_partitions_vhe_test",
"primary_with_secondaries:primary_with_sp",
+ "primary_with_secondaries:primary_with_sp_vhe",
]
}
diff --git a/test/vmapi/primary_with_secondaries/BUILD.gn b/test/vmapi/primary_with_secondaries/BUILD.gn
index 6f0b28e..7dc59bd 100644
--- a/test/vmapi/primary_with_secondaries/BUILD.gn
+++ b/test/vmapi/primary_with_secondaries/BUILD.gn
@@ -259,3 +259,70 @@
json_file = "primary_with_sp.json"
}
+
+# The primary VM target links together all test suites.
+# Defining a new primary VM for the VHE enabled setup below,
+# because the level of support of certain features might differ for S-EL0 and
+# S-EL1 partitions.
+# A test suite is expected to be fully functional with S-EL0 partitions when
+# adding the respective source file to the 'sources' field of the target below.
+vm_kernel("primary_with_sp_vhe_test_vm") {
+ testonly = true
+ public_configs = [
+ ":config",
+ "//src/arch/aarch64:config",
+ ]
+
+ sources = [
+ "indirect_messaging.c",
+ ]
+
+ deps = [
+ ":primary_with_secondaries",
+ "//src/arch/${plat_arch}/hftest:registers",
+ "//test/hftest:hftest_primary_vm",
+ "//test/vmapi/common",
+ "//vmlib",
+ ]
+}
+
+partition_package("primary_with_sp_vhe_test_package") {
+ testonly = true
+ pm_offset = "0x1000"
+ img_offset = "0x2000"
+ files = [ [
+ "partition_manifest_nwd_primary.dtb",
+ "primary_with_sp_vhe_test_vm.bin",
+ ":primary_with_sp_manifest",
+ ":primary_with_sp_vhe_test_vm",
+ ] ]
+ output = "primary_with_sp_vhe_test_package.img"
+}
+
+partitions_json("primary_with_sp_vhe") {
+ testonly = true
+
+ sps = [
+ [
+ "service_sp1_partition_package.img",
+ "services/arch/aarch64/secure/el0/manifest_secure_service1.dts",
+ "services/arch/aarch64/secure/el0:service_sp1_partition_package",
+ "services/arch/aarch64/secure/el0:partition_manifest_service_sp1",
+ ],
+ [
+ "service_sp2_partition_package.img",
+ "services/arch/aarch64/secure/manifest_secure_service2.dts",
+ "services/arch/aarch64/secure:service_sp2_partition_package",
+ "services/arch/aarch64/secure:partition_manifest_service_sp2",
+ ],
+ ]
+
+ vms = [ [
+ "primary_with_sp_vhe_test_package.img",
+ "manifest_vm_sp.dts",
+ ":primary_with_sp_vhe_test_package",
+ ":primary_with_sp_manifest",
+ ] ]
+
+ json_file = "primary_with_sp_vhe.json"
+}
diff --git a/test/vmapi/primary_with_secondaries/services/arch/aarch64/secure/el0/BUILD.gn b/test/vmapi/primary_with_secondaries/services/arch/aarch64/secure/el0/BUILD.gn
new file mode 100644
index 0000000..71b5f4a
--- /dev/null
+++ b/test/vmapi/primary_with_secondaries/services/arch/aarch64/secure/el0/BUILD.gn
@@ -0,0 +1,36 @@
+# Copyright 2022 The Hafnium Authors.
+#
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/BSD-3-Clause.
+
+import("//build/image/image.gni")
+import("//test/hftest/args.gni")
+
+vm_kernel("secure_service") {
+ testonly = true
+ deps = [
+ "//test/hftest:hftest_sel0_partition_base",
+ "//test/vmapi/primary_with_secondaries/services:echo",
+ "//test/vmapi/primary_with_secondaries/services:ffa_check",
+ "//test/vmapi/primary_with_secondaries/services/arch/aarch64/secure:message_loop",
+ ]
+}
+
+manifest("partition_manifest_service_sp1") {
+ source = "partition_manifest_service_sp1.dts"
+ output = "partition_manifest_service_sp1.dtb"
+}
+
+partition_package("service_sp1_partition_package") {
+ testonly = true
+ pm_offset = "0x1000"
+ img_offset = "0x2000"
+ files = [ [
+ "partition_manifest_service_sp1.dtb",
+ "secure_service.bin",
+ ":partition_manifest_service_sp1",
+ ":secure_service",
+ ] ]
+ output = "service_sp1_partition_package.img"
+}
diff --git a/test/vmapi/primary_with_secondaries/services/arch/aarch64/secure/el0/manifest_secure_service1.dts b/test/vmapi/primary_with_secondaries/services/arch/aarch64/secure/el0/manifest_secure_service1.dts
new file mode 100644
index 0000000..87d13be
--- /dev/null
+++ b/test/vmapi/primary_with_secondaries/services/arch/aarch64/secure/el0/manifest_secure_service1.dts
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2022 The Hafnium Authors.
+ *
+ * Use of this source code is governed by a BSD-style
+ * license that can be found in the LICENSE file or at
+ * https://opensource.org/licenses/BSD-3-Clause.
+ */
+
+/ {
+ hypervisor {
+ compatible = "hafnium,hafnium";
+ vm1 {
+ is_ffa_partition;
+ load_address = <0x6480000>;
+ debug_name = "Secure Service1 EL0";
+ vcpu_count = <1>;
+ mem_size = <0x100000>;
+ };
+ };
+};
diff --git a/test/vmapi/primary_with_secondaries/services/arch/aarch64/secure/el0/partition_manifest_service_sp1.dts b/test/vmapi/primary_with_secondaries/services/arch/aarch64/secure/el0/partition_manifest_service_sp1.dts
new file mode 100644
index 0000000..4538181
--- /dev/null
+++ b/test/vmapi/primary_with_secondaries/services/arch/aarch64/secure/el0/partition_manifest_service_sp1.dts
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2022 The Hafnium Authors.
+ *
+ * Use of this source code is governed by a BSD-style
+ * license that can be found in the LICENSE file or at
+ * https://opensource.org/licenses/BSD-3-Clause.
+ */
+
+/dts-v1/;
+
+/ {
+ compatible = "arm,ffa-manifest-1.0";
+ debug_name = "Secure Service1 EL0";
+
+ /* Properties */
+ ffa-version = <0x00010001>; /* 31:16 - Major, 15:0 - Minor */
+ uuid = <0xb4b5671e 0x4a904fe1 0xb81ffb13 0xdae1dacb>;
+ execution-ctx-count = <1>;
+ exception-level = <1>; /* S-EL0 */
+ execution-state = <0>; /* AARCH64 */
+ load-address = <0x6480000>;
+ entrypoint-offset = <0x2000>;
+ xlat-granule = <0>; /* 4KiB */
+ messaging-method = <0x7>; /* Supports direct and indirect requests. */
+ boot-order = <1>;
+ notification-support; /* Receipt of notifications. */
+ gp-register-num = <0>;
+
+ /* Boot Info */
+ boot-info {
+ compatible = "arm,ffa-manifest-boot-info";
+ ffa_manifest;
+ };
+};