Skip to content

Commit 85cc2db

Browse files
jenswi-linarojforissier
authored andcommitted
qemu_v8: add Trusted Services support
Add support for building the SPMC test Secure Partitions (SPs) implemented by the Trusted Services project. The build system is configured to build SPs with SEL0_SPS=y: - the SPs are embedded into the OP-TEE binary - the ffa_spmc testsuite is enabled in in xtest - the out-of-tree linux-arm-ffa-user kernel module is build - a S30test-arm-ffa-user init-script loads the kernel module during boot Signed-off-by: Jens Wiklander <[email protected]> Acked-by: Jerome Forissier <[email protected]> Tested-by: Jerome Forissier <[email protected]> (vexpress-qemu_armv8a)
1 parent 9cd5e40 commit 85cc2db

File tree

3 files changed

+85
-3
lines changed

3 files changed

+85
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/sh
2+
3+
ARM_FFA_USER_DIR=/mnt/host/out/linux-arm-ffa-user
4+
5+
start() {
6+
if [ -x $ARM_FFA_USER_DIR/load_module.sh ]; then
7+
if ! grep -qs arm_ffa_user /proc/modules; then
8+
echo "Loading arm-ffa-user kernel module"
9+
$ARM_FFA_USER_DIR/load_module.sh
10+
# Needed to test as non-root
11+
chmod 755 /sys/kernel/debug
12+
chmod 666 /sys/kernel/debug/arm_ffa_user
13+
fi
14+
fi
15+
16+
return $?
17+
}
18+
19+
stop() {
20+
if [ -x $ARM_FFA_USER_DIR/load_module.sh ]; then
21+
if grep -qs arm_ffa_user /proc/modules; then
22+
echo "Unloading arm-ffa-user kernel module"
23+
rmmod arm-ffa-user
24+
fi
25+
fi
26+
27+
return $?
28+
}
29+
30+
restart() {
31+
stop
32+
sleep 1
33+
start
34+
}
35+
36+
case "$1" in
37+
start|stop|restart)
38+
"$1";;
39+
reload)
40+
# Restart, since there is no "reload" feature
41+
restart;;
42+
*)
43+
echo "Usage: $0 {start|stop|restart|reload}"
44+
exit 1
45+
esac

br-ext/package/optee_test_ext/optee_test_ext.mk

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ ifneq ($(BR2_PACKAGE_OPTEE_TEST_EXT_WITH_CXX_TESTS),)
2323
TARGET_CONFIGURE_OPTS += WITH_CXX_TESTS=$(BR2_PACKAGE_OPTEE_TEST_EXT_WITH_CXX_TESTS)
2424
endif
2525

26+
define OPTEE_TEST_EXT_INSTALL_INIT_SYSV
27+
$(INSTALL) -m 0755 -D $(OPTEE_TEST_EXT_PKGDIR)/S30test-arm-ffa-user \
28+
$(TARGET_DIR)/etc/init.d/S30test-arm-ffa-user
29+
endef
30+
2631
define OPTEE_TEST_EXT_PREPARE_GP_SUITE
2732
sh $(@D)/host/xtest/gp/prepare_suite.sh $(@D) \
2833
$(BR2_PACKAGE_OPTEE_TEST_EXT_GP_PACKAGE)

qemu_v8.mk

+35-3
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,23 @@ endif
3838
# Enable fTPM
3939
MEASURED_BOOT_FTPM ?= y
4040

41-
include common.mk
42-
4341
DEBUG ?= 1
4442

4543
# Option to build with GICV3 enabled
4644
GICV3 ?= y
4745

46+
47+
SEL0_SPS ?= n
48+
ifeq ($(SEL0_SPS),y)
49+
SPMC_AT_EL = 1
50+
ifneq ($(SPMC_AT_EL),1)
51+
$(error Unsupported SPMC_AT_EL value $(SPMC_AT_EL) for SEL0_SPS=y)
52+
endif
53+
# Needed for arm-ffa-user.ko
54+
QEMU_VIRTFS_AUTOMOUNT = y
55+
LINUX_COMMON_TARGETS += modules
56+
endif
57+
4858
# Option to configure FF-A and SPM:
4959
# n: disabled
5060
# 3: SPMC and SPMD at EL3 (in TF-A)
@@ -61,11 +71,14 @@ PAUTH ?= n
6171
# Option to configure Memory Tagging Extension
6272
MEMTAG ?= n
6373

74+
include common.mk
75+
6476
################################################################################
6577
# Paths to git projects and various binaries
6678
################################################################################
6779
TF_A_PATH ?= $(ROOT)/trusted-firmware-a
68-
BINARIES_PATH ?= $(ROOT)/out/bin
80+
OUT_PATH ?= $(ROOT)/out
81+
BINARIES_PATH ?= $(OUT_PATH)/bin
6982
QEMU_PATH ?= $(ROOT)/qemu
7083
QEMU_BUILD ?= $(QEMU_PATH)/build
7184
MODULE_OUTPUT ?= $(ROOT)/out/kernel_modules
@@ -348,6 +361,25 @@ LINUX_CLEANER_COMMON_FLAGS += ARCH=arm64
348361

349362
linux-cleaner: linux-cleaner-common
350363

364+
################################################################################
365+
# Trusted Services
366+
################################################################################
367+
ifeq ($(SEL0_SPS),y)
368+
SP_PACKAGING_METHOD = embedded
369+
SPMC_TESTS=y
370+
include trusted-services.mk
371+
372+
# SPMC test SPs
373+
OPTEE_OS_COMMON_EXTRA_FLAGS += CFG_SPMC_TESTS=y CFG_SECURE_PARTITION=y
374+
OPTEE_OS_COMMON_EXTRA_FLAGS += CFG_SP_SKIP_FAILED=y
375+
OPTEE_OS_COMMON_EXTRA_FLAGS += CFG_DT=y CFG_MAP_EXT_DT_SECURE=y
376+
SP_SPMC_TEST_EXTRA_FLAGS += -DCFG_TEST_MEM_REGION_ADDRESS=0x0efff000
377+
$(eval $(call build-sp,spm-test1,opteesp,5c9edbc3-7b3a-4367-9f83-7c191ae86a37,$(SP_SPMC_TEST_EXTRA_FLAGS)))
378+
$(eval $(call build-sp,spm-test2,opteesp,7817164c-c40c-4d1a-867a-9bb2278cf41a,$(SP_SPMC_TEST_EXTRA_FLAGS)))
379+
$(eval $(call build-sp,spm-test3,opteesp,23eb0100-e32a-4497-9052-2f11e584afa6,$(SP_SPMC_TEST_EXTRA_FLAGS)))
380+
$(eval $(call build-sp,spm-test4,opteesp,423762ed-7772-406f-99d8-0c27da0abbf8,$(SP_SPMC_TEST_EXTRA_FLAGS)))
381+
endif
382+
351383
################################################################################
352384
# OP-TEE
353385
################################################################################

0 commit comments

Comments
 (0)