1Running user-space programs on FVP
2==================================
3
4This page explains how to load and run user space programs on a Linux image running in FVP simulation.
5The loaded programs may use any trusted services that are available as part of the image firmware.
6
7To prepare and run an image that includes trusted services running in S-EL0 secure partitions under
8OP-TEE see: :ref:`Deploying trusted services in S-EL0 Secure Partitions under OP-TEE`
9
10The example assumes that the FVP model has been installed in the following
11directory relative to the OP-TEE build directory::
12
13    ../Base_RevC_AEMvA_pkg/models/Linux64_GCC-9.3
14
15
16Shared directory
17----------------
18
19The AEM FVP supports directory sharing between the target and the host OS. This provides a
20convenient way to transfer files between the host and the device simulation.  When the FVP is run
21using the *run-only* target from the *op-tee/build* repository, the shared directory is set-up
22automatically. The whole "workspace" is shared to the FVP and mounted under ``/mnt/host``.
23
24
25Running service level tests
26---------------------------
27
28Most test and demo applications are integrated into the OP-TEE build flow, and can be build using
29the makefiles in the ``op-tee/build`` repository.
30
31To build all such binaries build the ``ffa-test-all`` target. For available targets please refer to
32`fvp-psa-sp.mk`. As an example to build the ``ts-service-test`` application execute the following
33commands from the root of the workspace::
34
35    make -C build ffa-ts-service-test
36
37The executable includes service level test cases that exercise trusted services via their
38standard interfaces.  Test cases use *libts* for locating services and establishing RPC
39sessions.  *ts-service-test* provides a useful reference for understanding how *libts* may
40be used for accessing trusted services.
41
42Build output will be copied to ``out/ts-install``.
43
44To build the applications without using the ``op-tee/build`` files refer to the instructions here:
45:ref:`Build Instructions`
46
47Run *ts-service-test*
48'''''''''''''''''''''
49
50To start the FVP, from the root directory of the workspace, enter::
51
52  FVP_PATH=../Base_RevC_AEMvA_pkg/models/Linux64_GCC-9.3 make -C build run-only
53
54Once it boots to the login prompt, log in as root and from the FVP terminal, enter::
55
56  # Enter the mount target for the shared directory
57  cd /mnt/host
58
59  # Install the shared library and executables
60  cp -vat /usr out/ts-install/arm-linux/lib out/ts-install/arm-linux/bin
61
62  # Load the kernel module
63  out/linux-arm-ffa-user/load_module.sh
64
65  # Run the test application
66  ts-service-test -v
67
68Use the same flow for other user-space programs. Check the output of the ``cp`` command executed to see
69executables copied under ``/usr/bin``.
70
71If all is well, you should see something like::
72
73    TEST(PsServiceTests, createAndSetExtended) - 0 ms
74    TEST(PsServiceTests, createAndSet) - 0 ms
75    TEST(PsServiceTests, storeNewItem) - 0 ms
76    TEST(ItsServiceTests, storeNewItem) - 0 ms
77    TEST(AttestationProvisioningTests, provisionedIak) - 1 ms
78    TEST(AttestationProvisioningTests, selfGeneratedIak) - 1 ms
79    TEST(AttestationServiceTests, repeatedOperation) - 75 ms
80    TEST(AttestationServiceTests, invalidChallengeLen) - 0 ms
81    TEST(AttestationServiceTests, checkTokenSize) - 2 ms
82    TEST(CryptoKeyDerivationServicePackedcTests, deriveAbort) - 0 ms
83    TEST(CryptoKeyDerivationServicePackedcTests, hkdfDeriveBytes) - 0 ms
84    TEST(CryptoKeyDerivationServicePackedcTests, hkdfDeriveKey) - 0 ms
85    TEST(CryptoMacServicePackedcTests, macAbort) - 0 ms
86    TEST(CryptoMacServicePackedcTests, signAndVerify) - 1 ms
87    TEST(CryptoCipherServicePackedcTests, cipherAbort) - 0 ms
88    TEST(CryptoCipherServicePackedcTests, encryptDecryptRoundtrip) - 0 ms
89    TEST(CryptoHashServicePackedcTests, hashAbort) - 0 ms
90    TEST(CryptoHashServicePackedcTests, hashAndVerify) - 0 ms
91    TEST(CryptoHashServicePackedcTests, calculateHash) - 0 ms
92    TEST(CryptoServicePackedcTests, generateRandomNumbers) - 0 ms
93    TEST(CryptoServicePackedcTests, asymEncryptDecryptWithSalt) - 14 ms
94    TEST(CryptoServicePackedcTests, asymEncryptDecrypt) - 1 ms
95    TEST(CryptoServicePackedcTests, signAndVerifyEat) - 4 ms
96    TEST(CryptoServicePackedcTests, signAndVerifyMessage) - 4 ms
97    TEST(CryptoServicePackedcTests, signAndVerifyHash) - 4 ms
98    TEST(CryptoServicePackedcTests, exportAndImportKeyPair) - 1 ms
99    TEST(CryptoServicePackedcTests, exportPublicKey) - 1 ms
100    TEST(CryptoServicePackedcTests, purgeKey) - 0 ms
101    TEST(CryptoServicePackedcTests, copyKey) - 1 ms
102    TEST(CryptoServicePackedcTests, generatePersistentKeys) - 1 ms
103    TEST(CryptoServicePackedcTests, generateVolatileKeys) - 0 ms
104    TEST(CryptoServiceProtobufTests, generateRandomNumbers) - 1 ms
105    TEST(CryptoServiceProtobufTests, asymEncryptDecryptWithSalt) - 15 ms
106    TEST(CryptoServiceProtobufTests, asymEncryptDecrypt) - 1 ms
107    TEST(CryptoServiceProtobufTests, signAndVerifyMessage) - 4 ms
108    TEST(CryptoServiceProtobufTests, signAndVerifyHash) - 4 ms
109    TEST(CryptoServiceProtobufTests, exportAndImportKeyPair) - 1 ms
110    TEST(CryptoServiceProtobufTests, exportPublicKey) - 0 ms
111    TEST(CryptoServiceProtobufTests, generatePersistentKeys) - 1 ms
112    TEST(CryptoServiceProtobufTests, generateVolatileKeys) - 1 ms
113    TEST(CryptoServiceLimitTests, volatileRsaKeyPairLimit) - 99 ms
114    TEST(CryptoServiceLimitTests, volatileEccKeyPairLimit) - 22 ms
115    TEST(DiscoveryServiceTests, checkServiceInfo) - 0 ms
116    TEST(SmmVariableAttackTests, getCheckPropertyWithMaxSizeName) - 0 ms
117    TEST(SmmVariableAttackTests, getCheckPropertyWithOversizeName) - 0 ms
118    TEST(SmmVariableAttackTests, setCheckPropertyWithMaxSizeName) - 0 ms
119    TEST(SmmVariableAttackTests, setCheckPropertyWithOversizeName) - 0 ms
120    TEST(SmmVariableAttackTests, enumerateWithSizeMaxNameSize) - 0 ms
121    TEST(SmmVariableAttackTests, enumerateWithOversizeName) - 0 ms
122    TEST(SmmVariableAttackTests, setAndGetWithSizeMaxNameSize) - 0 ms
123    TEST(SmmVariableAttackTests, setAndGetWithOversizeName) - 0 ms
124    TEST(SmmVariableAttackTests, setWithSizeMaxNameSize) - 0 ms
125    TEST(SmmVariableAttackTests, setWithOversizeName) - 0 ms
126    TEST(SmmVariableAttackTests, setWithSizeMaxDataSize) - 0 ms
127    TEST(SmmVariableAttackTests, setWithOversizeData) - 0 ms
128    TEST(SmmVariableServiceTests, checkMaxVariablePayload) - 0 ms
129    TEST(SmmVariableServiceTests, setSizeConstraint) - 0 ms
130    TEST(SmmVariableServiceTests, enumerateStoreContents) - 0 ms
131    TEST(SmmVariableServiceTests, getVarSizeNv) - 0 ms
132    TEST(SmmVariableServiceTests, getVarSize) - 0 ms
133    TEST(SmmVariableServiceTests, setAndGetNv) - 1 ms
134    TEST(SmmVariableServiceTests, setAndGet) - 0 ms
135    TEST(TestRunnerServiceTests, runSpecificTest) - 0 ms
136    TEST(TestRunnerServiceTests, runConfigTests) - 0 ms
137    TEST(TestRunnerServiceTests, listPlatformTests) - 0 ms
138    TEST(TestRunnerServiceTests, runAllTests) - 0 ms
139    TEST(TestRunnerServiceTests, listAllTests) - 0 ms
140
141    OK (67 tests, 67 ran, 977 checks, 0 ignored, 0 filtered out, 261 ms)
142
143--------------
144
145.. _fvp-psa-sp.mk: https://github.com/OP-TEE/build/blob/master/fvp-psa-sp.mk
146
147*Copyright (c) 2020-2023, Arm Limited and Contributors. All rights reserved.*
148
149SPDX-License-Identifier: BSD-3-Clause
150