1
0
mirror of https://git.yoctoproject.org/meta-arm synced 2026-07-18 16:37:08 +00:00

Compare commits

...

116 Commits

Author SHA1 Message Date
Abdellatif El Khlifi 7410a7f621 kas: corstone1000: update the FVP script repo SHA
Setting the model script SHA to use the right FVP
options.

Change-Id: I7f92fb97466bf4f5f48b8d184a396bf87bdeb401
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-15 14:09:17 -05:00
Vishnu Banavath d34c55df6a arm-bsp/trusted-firmware-m: corstone1000: update TF-M SHA
This change is to update TF-M SHA which has fixes for capsule update.

Change-Id: I016381c2a95fcdd9629772671143a1e7332196e5
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-14 13:00:09 -05:00
Gowtham Suresh Kumar a5377f1569 arm-bsp/u-boot: corstone1000: Fix efi debug issue
This patch will fix the ffa mm communicate function behavior as
expected by efi_get_var() and also fix the com buffer size used by
u-boot.

Change-Id: I8ce28a2e51b8f52856d81ea6e3c1e2e72cfaa362
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-14 07:00:09 -05:00
Gowtham Suresh Kumar 5f7671d897 arm-bsp/u-boot: corstone1000: Remove GetVariable() fix
The efi_get_var() expects EFI_BUFFER_TOO_SMALL return value
from efi_get_variable_int() to just read the size of the data.
So when comm buffer is smaller than received buffer,
efi_get_variable_int is expected to return error code. This
functionality will be fixed in future patches.

Change-Id: I3e5119b1fdf18c965cc2ebc11056b6ca70d57e0f
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-14 07:00:09 -05:00
Vishnu Banavath bc8c92afab arm-bsp/secure-partitions: add capsule update interface to SE proxy SP
This change is to add capsule update interface to SE proxy SP.
This interface sends following events to secure enclave
* firmware update request - SE will read the capsule and will flash the
image to flash to previous active bank
* kernel boot event - SE will delete timer on reciption of this event and
marks all the images as accepted if in trial state

Change-Id: I7cf9b729128d1e07e891253661fcd891191e8024
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-14 07:00:09 -05:00
Gowtham Suresh Kumar fc6637b5e2 arm-bsp/secure-partitions: corstone1000: Increase SMM Gateway variable handling capacity
The maximum number of UEFI variables that can be supported by SMM
gateway is currently 40. When more than 40 variables are written,
or read SMM gateway returns error code. Currently this value is
increased to 100 to support more UEFI variables.

Change-Id: I3ebef8052fd01c5b1c19cdfe71ab3c02447a005b
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-14 07:00:09 -05:00
Emekcan Aras 075638cf00 arm-bsp/psa-arch-tests: corstone1000: configuring crypto and attestation test
This commit configures crypto and attestation tests for Corstone1000
platform.

It also fixes CMake issues on the current trusted-service CMake source
files to enable this configuration.

Change-Id: I334d661c1bc349e03f92611d6010360c08e6cc89
Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-14 07:00:09 -05:00
Emekcan Aras c4ed1d1c21 arm-bsp/trusted-firmware-m: corstone1000: Aligning with TF-M master
Setting the last master branch SHA for openamp changes.

Change-Id: I20dfb1c12091f58576898c2a17e74aa71bab5651
Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-14 07:00:09 -05:00
Satish Kumar 751ae8fe38 arm-bsp/secure-partitions: corstone1000: add psa ipc crypto backend
Add psa ipc crypto backend and attach it to se proxy
deployment.

Change-Id: I072cd3f0661be33773a2132c2222dc4c7b8c6cb4
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-14 07:00:09 -05:00
Satish Kumar 6e075adc0b arm-bsp/secure-partitions: corstone1000: Setup its backend
Setup its backend as openamp rpc using secure storage ipc
implementation.

Change-Id: I0329c87d11de7a721b3eaf004935befa6e7389c8
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-14 07:00:09 -05:00
Satish Kumar 9c83efa253 arm-bsp/secure-partitions: corstone1000: Add psa ipc attestation to se proxy
Implement attestation client API as psa ipc and include it to
se proxy deployment.

Change-Id: I0a1130d2013717c6499da5bb2cd6cd11a752bcce
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-14 07:00:09 -05:00
Satish Kumar 50304a2be6 arm-bsp/secure-partitions: corstone1000: Use address instead of pointers
Since secure enclave is 32bit and we 64bit there is an issue
in the protocol communication design that force us to handle
on our side the manipulation of address and pointers to make
this work.

Change-Id: Icb29fdec6928dba6da7e845b3a13d8a3560c5fe1
Signed-off-by: Rui Miguel Silva <rui.silva@arm.com>
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-14 07:00:09 -05:00
Satish Kumar 12a5fd5cd5 arm-bsp/secure-partitions: fixes required to run psa-arch-test
Fixes needed to run psa-arch-test

Change-Id: Iba090e151298a216f8f1bf81a72bba4587bec389
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-14 07:00:09 -05:00
Abdellatif El Khlifi 42347ebaa2 kas: corstone1000: update for new Kas include semantics in kas folder
With Kas 2.6 included YAML files need to be relative to the repository,
not the including file:

https://kas.readthedocs.io/en/latest/format-changelog.html#version-11

Change-Id: I851c9137d1f70f754d1a70a1fc14828c39ff3de7
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-13 18:14:31 -05:00
Abdellatif El Khlifi 1e3cea589d kas: corstone1000: update meta-arm-image SHA
Aligning to the last meta-arm-image version to
add psa-arch-tests to the rootfs.

Change-Id: I40e945f814df4b6f7c30772d3dd6f91e6b6fcafc
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-13 18:14:31 -05:00
Emekcan Aras a56fdf4333 arm-bsp/psa-arch-tests: corstone1000: build the test applications
This commit adds support for building/installing the test
application.

Also fixing CMake issues on the current trusted-service CMake source files.

Change-Id: Iae0fc9bf9362cf5b7d65cd7b9f0445f62f3b83eb
Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-13 18:14:31 -05:00
Abdellatif El Khlifi 0acbf59a8e arm/psa-arch-tests: introduce the recipe
This commit adds a recipe for psa-arch-tests linux
userspace application.

Included tests are; crypto, protected_storage,
internal_trusted_storage and attestation.

Change-Id: I6285aa2a6ae8fdd25f4327f1d301c59a88bce775
Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-13 18:14:31 -05:00
Abdellatif El Khlifi a68fa362d2 arm/secure-partitions: remove the use of EXTRA_OEMAKE
EXTRA_OEMAKE is not needed since we are using CMake.

Change-Id: Ifc0dcc9313fe4e473cbba8eb3b716e11cf8e45ee
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-13 18:14:31 -05:00
Abdellatif El Khlifi d206e22c08 arm-bsp/u-boot: corstone1000: add the header file for invalidate_dcache_all function
The invalidate_dcache_all function has been implicitly declared.
This commit fixes that.

Change-Id: I83e985e219af8687c0679045f6a979c91923be69
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-13 18:14:03 -05:00
Abdellatif El Khlifi aaad1117ab arm-bsp/u-boot: corstone1000: arm_ffa: removing the cast when using binary OR on FIELD_PREP macros
When the GENMASK used is above 16-bits wide a u16 cast will cause
loss of data.

This commit fixes that.

Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Change-Id: I72e5e42971a50ce167500a92cc529c5cb3ff781f
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-13 18:14:03 -05:00
Vishnu Banavath 4bb0d10188 arm-bsp/u-boot: corstone1000: make capsule guid check platform agnostic
This change is to delete a separate check for guid for corstone1000
target. Generic check of fmp guid check should suffice.

Change-Id: Idec92c9307f903e52985057404daac2e40d05295
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-13 18:14:03 -05:00
Vishnu Banavath c6de028d35 arm-bsp/u-boot: corstone1000: passing interface ID and event ID in register w4
Changing where to pass the SE Proxy interface and event IDs.

Now they are passed to the SE Proxy in register w4.

The events involved are kernel started and buffer ready
events.

Change-Id: Ib60897e9f01cd87b9923892198f8868e02cc830d
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-13 18:14:03 -05:00
Abdellatif El Khlifi 42061ba8ce arm-bsp/secure-partitions: corstone1000: using the default SHA
No need to set again the same SHA as the one provided
by the recipe.

Change-Id: I034aca31c1cc30868552be67a04400db20ad59b2
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-13 18:13:34 -05:00
Abdellatif El Khlifi b94c50d291 arm/secure-partitions: introducing a common file
Moving common settings that can be used by other
components to a common file: secure-partitions.inc

Change-Id: I81691ee52bef3dfbd72c59afe20b01a5cf2222ea
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-13 18:13:34 -05:00
Gowtham Suresh Kumar 37d646c3b9 arm-bsp/u-boot: corstone1000: Fix GetVariable data size issue
This patch fixes the GetVariable() issue which causes
mm_communicate failure when called with 0 data size. The comm buffer
is set to maximum size when 0 data size request is made to handle the
MM response from the secure world. This is a generic fix but used by
corstone1000.

Change-Id: Id50619816a924b4fa7597295f89d54827191fbb5
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-13 18:13:34 -05:00
Vishnu Banavath 9b0ddd606e arm-bsp/optee-os: cherry pick fixes from upstream integration branch
These changes are to fix missing error check during sp init
and add support for defining memory regions

Change-Id: I381ff9805288590809471494bdff5e7f62232f7c
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-13 18:13:34 -05:00
Vishnu Banavath e1c04fd924 arm-bsp/secure-partitions: rebase TS patches
These changes is to rebase patches to latest
SHA(a365a04f937b9b76ebb2e0eeade226f208cbc0d2) of integration branch.
Also cherry-picked other bug fixes with the exemption of adding
newlib changes. newlib changes brakes the build because of musl
libc, hence dropped those changes for now

Change-Id: If0131d00e63eb0f574fa41dd95cfee4351e696e8
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-13 18:13:34 -05:00
Abdellatif El Khlifi e53bc984f5 arm-bsp/optee-os: corstone1000: unpack sp_manifest_combined_se.dts in WORKDIR
When using devtool the S is no longer an unpack location.
Let's use the default unpack location WORKDIR that works
whether devtool is used or not.

Change-Id: I34dfb53feddddfba82ff68a43b6cfe89a60c7701
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-13 18:13:34 -05:00
Abdellatif El Khlifi 6ee207b520 arm-bsp/trusted-firmware-m: corstone1000: bump the version to 1.5
Setting TF-M version to 1.5

Change-Id: Ib04778ed46d5404f498ff4efd60f338e351e7ee9
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-13 18:13:34 -05:00
Jon Mason e0d2976011 CI: use matrix for more defined way of doing things and cleanup
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-12 10:36:48 -05:00
Ross Burton 97f9592eff CI: remove utility tasks
These tasks made some limited sense when there was only one runner, but
in a setup where there are N runners they arere pretty useless as you
can't control which runner is executing the jobs.

Disk usage should be managed out-of-band, so delete the jobs.

Signed-off-by: Ross Burton <ross.burton@arm.com>
2021-12-12 09:39:37 -05:00
Vishnu Banavath 8649420ff5 arm-bsp/secure-partitions: Use secure storage ipc and openamp for se_proxy
Remove mock up backend for secure storage in se proxy
deployment and use instead the secure storage ipc backend with
openamp as rpc to secure enclave side.

Change-Id: I5225966ec621be9fa126b5af6ede0a1f6bbf469b
Signed-off-by: Rui Miguel Silva <rui.silva@arm.com>
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-11 19:23:14 -05:00
Vishnu Banavath 1359423f0f arm-bsp/secure-partitions: add secure storage ipc backend
Add secure storage ipc ff-m implementation which may use
openamp as rpc to communicate with other processor.

Change-Id: I6707f3b0654fb255cacef930d9314662b106273c
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-11 19:23:14 -05:00
Vishnu Banavath 117dd9583a arm-bsp/secure-partitions: add common service component to ipc support
Add support for inter processor communication for PSA
including, the openamp client side structures lib.

Change-Id: Icb86045b7915c4b04d2ec73b88ed40a3d65be4af
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-11 19:23:14 -05:00
Vishnu Banavath fac6216f09 arm-bsp/secure-partitions: Add psa client definitions for ff-m
Add PSA client definitions in common include to add future
ff-m support.

Change-Id: I0860fa347fd882d6e99da136a4273a0ef5d7d684
Signed-off-by: Rui Miguel Silva <rui.silva@arm.com>
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-11 19:23:14 -05:00
Vishnu Banavath 24ecb7cf18 arm-bsp/optee-os: add openamp-virtio
Adding openamp-virtio node to the SP manifest

Change-Id: I1123eab65f2f05d00433b7d940b74766457ac7cf
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-11 19:23:14 -05:00
Vishnu Banavath 9b4cd95b8c arm-bsp/secure-partitions: add openamp rpc caller
Add openamp rpc caller

Change-Id: Ifb69f3ea3cf84fa01566033f82ed1657490ba87d
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-11 19:23:14 -05:00
Satish Kumar 6a175f4b1c arm-bsp/trusted-firmware-m: corstone1000: Aligning with TF-M master
Setting the last master branch SHA.

Change-Id: I668868f991bc090cf0720ac940fe658aa253ed56
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-11 19:23:14 -05:00
Abdellatif El Khlifi d83f7c7955 arm-bsp/u-boot: corstone1000: remove the use of fdt_addr_r
The device tree is embedded in the u-boot binary
and located at the end of the DDR. Its address
is specified in fdtcontroladdr environment variable.

No need to use fdt_addr_r anymore.

Change-Id: I58b17fbcab36c7236d57eb2498c41b5f4960b6eb
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-11 19:23:14 -05:00
Abdellatif El Khlifi 4a66446a51 arm-bsp/u-boot: corstone1000: setting the boot console output
Setting stdout-path in the chosen node.

Change-Id: Ie0a6b140492f0c5fc323690d2f6bc921cbe76cb3
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-11 19:23:14 -05:00
Vishnu Banavath 8a02bd6796 arm-bsp/optee-os: add MHU device regions in the SP manifest
Declaring the MHU device regions nodes.

Change-Id: Idc9faf570b8b97193f69ed32fa71a4a3ca359409
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-09 17:22:19 -05:00
Vishnu Banavath 360c498f1e arm-bsp/secure-partitions: Implement mhu driver
This commit adds mhu driver (v2.1 and v2) to the secure
partition se_proxy and a conversion layer to communicate with
the secure enclave using OpenAmp.

Change-Id: I3800ce108cabf7e3652f96e39b9fed2435c53ca9
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-09 17:22:19 -05:00
Vishnu Banavath 0112ab00a6 arm/secure-partitions: pass TS_PLATFORM in the configure task
This commit passes the platform name to CMake through the
configure task.

Change-Id: I7aaf10e3709507c65dd81c31e0301df57bbdf4fc
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-09 17:22:19 -05:00
Abdellatif El Khlifi e52c719925 arm-bsp/secure-partitions: corstone1000: add openamp support in SE proxy SP
This change is to fetch and build openamp and libmetal
as part of SE proxy secure partitions

Change-Id: I251525f830535ceb1e1fc9f994c22a8b149fe7b6
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-09 17:22:19 -05:00
Abdellatif El Khlifi 0231b19372 arm-bsp/secure-partitions: corstone1000: add mbed-crypto and nanopb to platform code
Moving dependencies to the BSP.

Change-Id: I32abd6c0568030550dda0442a2a4f624967b561c
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-09 17:22:19 -05:00
Abdellatif El Khlifi a7a2469888 arm/secure-partitions: remove platform specific dependencies
Keeping the recipe platform independent.

Additional components can be added at the platform level.

Change-Id: Ib1b0dd8d50486a037257dd99fea0d0ba2c80c7fb
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-09 17:22:19 -05:00
Vishnu Banavath 48a646b5eb arm/optee-spdevkit: add missing header file in optee-spdevkit
This change is to add following header file to optee-spdevkit
and these are required by openAMP:

* features.h
* error.h

Change-Id: I51b801911b5a0131bf938ac1d520c4818e416637
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-09 17:22:19 -05:00
Vishnu Banavath d93bd3a130 arm-bsp/optee-os: increase core heap size
This change is to increase optee core heap size to 131072 bytes
from its default value to accomodate openAMP and smm-gateway

Change-Id: I40912334f59a50bb3baf853bb5ff4b01c3b23966
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-09 17:22:19 -05:00
Hugo L'Hostis bba8a89e29 kas: Update include syntax to kas 2.6
Using a path relative to a kas yaml file to include another kas yaml
file won't be supported in the future. This patch also updates the
documentation for fvp-baser to set the minimal supported version of kas
to 2.6.

Signed-off-by: Hugo L'Hostis <hugo.lhostis@arm.com>
Change-Id: I757103c5433bca7af9ab024370cd1e994d59fe0e
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-09 12:08:07 -05:00
Satish Kumar 33a4153ca9 kas: corstone1000: update SE binary sizes
Update the size of bl2_signed.bin and tfm_s_signed.bin

Change-Id: I8312dd6d50faff53e1ca489cbf73c5f25671b21c
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-06 09:32:30 -05:00
Satish Kumar 7aed3db89a arm-bsp/u-boot: identify which bank to load kernel from
Secure enclave, based on the firmware update state of the
system, decides the boot bank. In this commit, u-boot
identifies the selected boot bank and loads the kernel
from it.

Change-Id: Ifcef126dc79c7808b30ef0319d83482d2d29fd13
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-06 09:32:30 -05:00
Satish Kumar 2a36efd547 arm-bsp/trusted-firmware-a: patch to identify which bank to load fip from
Secure enclave decide the boot bank based on the firmware update
state of the system and updated the boot bank information at a given
location in the flash. In this commit, bl2 reads the givev flash location
to indentify the bank from which it should load fip from.

Change-Id: I2f7518c82c1664355da2aa1596f4f65f7a49a53d
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-06 09:32:30 -05:00
Satish Kumar 6a4d8241de arm-bsp/u-boot: patch to change kernel flash address
More space in the flash is reserved up front for metadata
parser and UEFI variables. That requires change in the flash
base address of where images are present.

Change-Id: I2d23d06099ffbf15458afaeb21c5dd4bcc4ffecb
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-06 09:32:30 -05:00
Satish Kumar 6edb53ca86 arm-bsp/trusted-firmware-a: patch to change flash base address of FIP
More space in the flash is reserved up front for metadata
parser and UEFI variables. That requires change in the flash
base address of where images are present.

Change-Id: If6c048a6117023aae2e748c23ed52447857b0d04
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-06 09:32:30 -05:00
Satish Kumar a5f84f1174 arm-bsp/trusted-firmware-m: corstone1000: firmware update changes
The patchset perform the following changes:

a. Disable secure debug by default.
b. OTA Firmware Update Agent implementation.
c. Implementation of boot index propagation mechanism.
d. Openamp version/commit hash correction.
e. Implementation of host watchdog interrupt handler.

Change-Id: Ie5e1028bb29ce337d51ad8ef47d2bd8175187402
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-06 09:32:29 -05:00
Emekcan Aras 3866e8cf80 arm-bsp/u-boot: corstone1000: Implement autoboot storage device selection
This commit implements distro_bootcmd in config_bootcommand in u-boot.
This command traverses all the USB devices connected to the board and
finds a usb device that has bootable image to boot from it. If it cannot
find a usb device with the bootable image, it will boot the system using
the existing flash.

Change-Id: Ia05ca02d6f490a1b51fcf377afcc86ea0ed4e19c
Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-06 09:32:29 -05:00
Emekcan Aras cc7196deed arm-bsp/trusted firmware-a: corstone1000: implement EFI reset system
This commit implements efi_reset_system for corstone1000 platform. In
order to reset the system, the host uses secure host watchdog to assert
an interrupt (WS1) on the secure-enclave side, then secure-enclave
resets the system.

Change-Id: I772181cd43e789f1d6508aaa433eb109d8f85b5d
Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-06 09:32:29 -05:00
Emekcan Aras cf278f9ae8 arm-bsp/u-boot: corstone1000: Enable PSCI Reset
This commit enables PSCI Reset for corstone1000 platform. It configures
u-boot to use PSCI interfaces in efi_reset_system function.

Change-Id: I88ea55fde2b2c6e455a4b38e885e62a410b0b0e7
Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-06 09:32:29 -05:00
Harry Moulton e0e7256b5a arm-bsp/u-boot: corstone1000: Fix ISP1760 EFI boot issue
This patch does three things:
 - Add the CONFIG_EFI_PARTITION option to the corstone1000_defconfig
    to allow u-boot to detect EFI filesystems.
 - Add isp1760_get_max_xfer_size(), this fixes an issue where
    GPT partition info could not be loaded.
 - Fix the issue while detecting EFI filesystem, and loading GPT
    partition info.

Change-Id: Ic04c8710f4ea7e156aca196d7e54f090b9376c49
Signed-off-by: Harry Moulton <harry.moulton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-06 09:32:29 -05:00
Gowtham Suresh Kumar 40826eee73 arm-bsp/u-boot: corstone1000: Enable SMM gateway
This patch updates shared buffer address, disables get/set of NV
variables, and invalidates the cache after write to shared buffer as the
SPs have cache disabled.

Change-Id: Iead01edf3011e192df205236df098415e5bde9a5
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-06 09:32:29 -05:00
Satish Kumar eccb9a82d7 arm-bsp/imgtool: upgrade imgtool to 1.8.0
Change-Id: I6f24f058284d5bae244ea88989e922d92ff25d0a
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-06 09:32:29 -05:00
Ross Burton 1f79abb091 arm-toolchain: upgrade gcc-arm-none-eabi (GNU-RM) to 10.3-2021.10
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-06 09:32:29 -05:00
Maxim Uvarov d69ae1e000 optee: update optee-os.inc to support external TAs
Separate recipe for TA devkit is needed to solve
circular dependency to build TAs with the devkit
 and integrate it inside optee-os.

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-03 10:28:05 -05:00
Gowtham Suresh Kumar c519482ce6 arm-bsp/optee-os: corstone1000: enabling smm-gateway partition
This commit enables smm-gateway in optee-os by making the following changes:

- Updating the existing SP manifest file with a combined manifest file
  that includes information about both se-proxy and SMM gateway SP.
- Including the SMM gateway SP makefile in optee include file
  to embed smm gateway sp binary into optee image.

Change-Id: Iebcf2c534a9e9ced411c943ff583b522ad9d69fa
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
2021-12-01 13:36:49 +00:00
Gowtham Suresh Kumar d0bbfca5a2 arm-bsp/secure-partitions: corstone1000: add smm-gateway partition
smm-gateway secure partition is a slim version of StMM for low memory
devices.

This commit adds support for smm-gateway for corstone1000 at the
secure partitions level by making the following changes:

- Configure TS_DEPLOYMENTS to include SMM Gateway SP, SMM gateway to use
  device region for shared buffer, and set the NV store macro.
- Updating secure partitions recipe to point to HEAD of integration
 branch to fetch stmm-gateway changes.

Change-Id: I56ff325cca250749448364e12ac06e3ea289fa29
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
2021-12-01 13:36:49 +00:00
Ross Burton 523f921eca CI: build optee-spdevkit for qemuarm64
To ensure that optee-spdevkit works in all configurations, but it in the
CI for qemuarm64 not just corstone1000.

Signed-off-by: Ross Burton <ross.burton@arm.com>
2021-12-01 10:30:54 +00:00
Ross Burton a035205056 arm/optee-spdevkit: fix non-corstone1000 builds
This recipe was setting a default SRCREV which doesn't contain the
Secure Partition devkit, as this is only in the psa-development branch
on the trustedfirmware.org mirror which is set by the corstone1000
bbappend.

Use this branch/revision by default, and set the PV correctly: this
branch is currently based on optee-os 3.10 not 3.14.

Signed-off-by: Ross Burton <ross.burton@arm.com>
2021-12-01 10:30:54 +00:00
Ross Burton 60a8389331 CI: build optee-test in qemuarm64-secureboot
This recipe doesn't get built through dependencies, so add it explicitly.

Signed-off-by: Ross Burton <ross.burton@arm.com>
2021-12-01 10:30:54 +00:00
Ross Burton 26501daba0 arm/optee-test: change DEPENDS to optee-os-tadevkit
Now that the TA devkit has been split out of optee-os, the build
dependencies of optee-test need to be updated too.

Signed-off-by: Ross Burton <ross.burton@arm.com>
2021-12-01 10:30:54 +00:00
Ross Burton 30a46c3347 arm/optee-test: use precise BSD license
Signed-off-by: Ross Burton <ross.burton@arm.com>
2021-12-01 10:30:54 +00:00
Abdellatif El Khlifi 9eb24631da arm-bsp/linux: setting the FFA_VERSION compatibility checks
This commit introduces a new kernel patch that aligns the FF-A
versions checks according to the FF-A specification v1.0.

Without this fix, the FF-A bus fails to initialize when the FF-A
framework is version 1.1 (comes with the latest TF-A).

The bus driver which is v1.0 rejects the framework v1.1 despite
the fact they are compatible according to the specification.

This kernel patch changes the logic of the version checking based on
the specification.

Change-Id: If9d7b6c0d5e24e73d4f42c6532cd56ff2d05fcec
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
2021-12-01 10:30:54 +00:00
Abdellatif El Khlifi a38e919e49 arm-bsp/u-boot: corstone1000: adjust the environment and heap sizes
env size set to 64 KB
heap size 64 KB + 32 MB

Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Change-Id: I913862e855afa8864e91e0a7c0707279b7cbd987
2021-12-01 10:30:54 +00:00
Abdellatif El Khlifi 69dae93d84 arm-bsp/u-boot: corstone1000: introducing EFI capsule update
This commit implements capsule update for Corstone-1000.

Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Change-Id: I3031018eebb9aaae56c0823d24ee5c148857f2fa
2021-12-01 10:30:54 +00:00
Abdellatif El Khlifi d36a974ad3 arm-bsp/u-boot: corstone1000: introducing Arm FF-A and MM support
This commit provides these new generic u-boot features:

- The FF-A low-level driver implementing Arm Firmware Framework for Armv8-A (FF-A)
- MM communication using FF-A (compatible with StandaloneMM and smm-gateway)
- A new armffa command and a test module to test the FF-A helper functions to
  communicate with secure world.

It also enables FF-A and MM communication for the Corstone-1000 platform.

Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Change-Id: Ic71dcae2411aefae00557284c08be662bfe80b98
2021-12-01 10:30:54 +00:00
Vishnu Banavath 7d9d7603d7 arm-bsp/optee-os: add a rule in optee-os Makefile for secure partitions
These changes are to add a rule in optee-os Makefile to include
secure partitions as part of optee-os image

Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Change-Id: I2f6f93ffca9a2332cbe9ffe4e9903b8ec524df51
2021-12-01 10:30:54 +00:00
Abdellatif El Khlifi 6876e6e09c meta-arm-bsp/security: corstone1000: add trusted services support
These changes are to add support to build TrustedServices.
corstone1000 platfrom uses optee-sp option which will include
secure partitions into optee Image

Following changes are made to trusted-services code
* TS_PLATFORM should be set at the external build system level.
* fix EARLY_TA_PATHS environment variable
* se-proxy string and make it as child node

Change-Id: I58d76b5e25e7f285794c93dc92c1b93fdd77cfb9
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-29 11:30:24 -05:00
Abdellatif El Khlifi dcaa4c1ff2 arm/secure-partitions: introducing the recipe
Adding secure-partitions recipe.

Change-Id: I4320fb7087157a7c0f9305ce1d8f8574d4500fd0
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-29 11:30:24 -05:00
Abdellatif El Khlifi 79e699da13 arm/optee-spdevkit: introducing the recipe
Adding optee-spdevkit recipe.

Change-Id: Ib31d7f0a9fa2f72b71c2057f2752b1c52be6f890
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-29 11:30:24 -05:00
Arpita S.K cc63d474fd arm-bsp/u-boot: introducing corstone1000 MPS3 machine
Add support for corstone1000-mps3 machine which have a cortex-a35
aarch64, this will boot till u-boot prompt.

Change-Id: Ifdd81d35a5409cdd1563388a841885c14b748cad
Signed-off-by: Arpita S.K <Arpita.S.K@arm.com>
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-29 11:30:24 -05:00
Arpita S.K cb37d9391b arm-bsp/machine: introducing corstone1000 MPS3 machine
This commit adds the corstone1000-mps3 machine.

Change-Id: I99f657574a693527d7763cb4cc9b0b05218bb316
Signed-off-by: Arpita S.K <Arpita.S.K@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-29 11:30:24 -05:00
Arpita S.K 55ae0eb1a6 arm/trusted-firmware-a,fiptool-native: Fix fiptool execution wrt corstone1000
After http://git.yoctoproject.org/cgit/cgit.cgi/meta-arm/commit/?id=648571b113b39420735859461fcd69cfc6f66c76,
building the corstone1000-image fails with the below error.
    fiptool_platform.h:19:11: fatal error: openssl/sha.h: No such file or directory
    # include <openssl/sha.h>

Put back the inclusion of BUILD_LDFLAGS to fix this.

Change-Id: I57396eefe2c9a58e4c5c6a751b2ee7d32509cac5
Signed-off-by: Arpita S.K <Arpita.S.K@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-23 20:00:24 +05:30
Arpita S.K 3dbaa6528b corstone1000: Introducing ci and kas files
Adding ci and yaml files to support
corstone1000-fvp.

Change-Id: I74ebc3570d4b0c8abae58be5ef69064fc33e5bea
Signed-off-by: Arpita S.K <Arpita.S.K@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-23 19:59:22 +05:30
Abdellatif El Khlifi 601733b08c arm/ffa-debugfs: corstone1000: enabling FF-A Debugfs Linux driver
- This commit provides a recipe for the FF-A Debugfs Linux
   driver v2.1.0.

  The driver is an out-of-tree loadable modules. It exposes
  FF-A operations to user space and only used for development
  purposes.

- Create a dev package for ffa-debugfs-mod

  ffa-debugfs-mod recipe provides arm_ffa_user.h header for
  other recipes that need it at build time.
  The header is put in ffa-debugfs-mod-dev package.

Change-Id: I92f33e20b5fdfc9a32cff03ae2a137150d0328db
Signed-off-by: Arpita S.K <Arpita.S.K@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-22 16:25:58 +05:30
Abdellatif El Khlifi c64bdb3f09 arm-bsp/linux: corstone1000: integrating ARM_FFA_TRANSPORT in v5.10 kernel
This commit adds the Arm Firmware Framework for Armv8-A to the v5.10 kernel.

The integrated patches are cherry-picked from kernel v5.14-rc2 and
compatible with SMCCCv1.2

Change-Id: If8964b94ed83caa5e0fc5d2a8a9b6a21f8b378ec
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-22 16:25:58 +05:30
Abdellatif El Khlifi 7512fc87fd arm-bsp/trusted-firmware-m: corstone1000: signing trusted-firmware-a binaries
This commit allows to sign trusted-firmware-a BL2 and FIP using MCUBOOT
tools.

Change-Id: Ide3045982f5f8515c1ccd59b6b0d29816fbfdd68
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-22 16:25:58 +05:30
Abdellatif El Khlifi 16e585c6d8 arm-bsp/python3-imgtool: add the recipe
Until this is integrated into meta-python, hold a copy of
python3-imgtool in meta-arm-bsp used by trusted-firmware-m.

Change-Id: I2e86be503bee03de549f5714dc52921165afa2bf
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Arpita S.K <Arpita.S.K@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-22 16:25:58 +05:30
Rui Miguel Silva cdd0a9da56 arm-bsp/linux: corstone1000: enable efi
In an effort to setup capsule update and efi runtime service
handlers, enable the correspondent efi config options.

Signed-off-by: Rui Miguel Silva <rui.silva@arm.com>
Change-Id: Ib068448564268dcacb9bcad3667a3b293f177a83
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-22 16:25:58 +05:30
Vishnu Banavath 54446b5d80 arm-bsp/u-boot: corstone1000: extend efi support
enable efi boot including secure config options, add a
load command which integrate with efi subsystem.

And as at it, enable the efi capsule options for future
use.

Change-Id: Iced8ab2b9bca41805f6201150760692b4b716d7d
Signed-off-by: Arpita S.K <Arpita.S.K@arm.com>
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Rui Miguel Silva <rui.silva@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-22 16:25:58 +05:30
Vishnu Banavath d8cda67a95 arm-bsp/optee: introducing corstone1000 FVP machine
These changes are to add corstone1000-fvp machine
to optee-os.

Change-Id: I9ddfaca476234c0307a89d5444ae2d0e688a9b59
Signed-off-by: Arpita S.K <Arpita.S.K@arm.com>
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-22 16:25:58 +05:30
Abdellatif El Khlifi 4cb5f2ca10 arm-bsp/trusted-firmware-a: introducing corstone1000 FVP machine
This commit enables TF-A v2.5 with Trusted Board Boot support for the
Corstone1000 64-bit platform.

Disables Non-Volatile counters in the TBB.

Change-Id: Idb9e18df7066cb617df72b2e147147ce49db292c
Signed-off-by: Arpita S.K <Arpita.S.K@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-22 16:25:58 +05:30
Rui Miguel Silva 939b0856fc arm-bsp/u-boot: introducing corstone1000 FVP machine
Add support for corstone1000-fvp machine which have a cortex-a35
aarch64, this will boot till u-boot prompt.

Remove kernel devicetree configuration and add the devicetree here and
enable it in the diphda defconfig.

Adds the build options required to support an RTC emulator which in
turn is required to support the UEFI functions GetTime()
and SetTime().

Change-Id: I0d66ece1193494bd2f59a9800d802dff1c4a0db6
Signed-off-by: Arpita S.K <Arpita.S.K@arm.com>
Signed-off-by: Rui Miguel Silva <rui.silva@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-22 16:25:58 +05:30
Vishnu Banavath 20b0d476e5 arm-bsp/trusted-firmware-m: introducing corstone1000 FVP machine
Enables trusted-firmware-m on the corstone1000-fvp machine.

Change-Id: Id38d565e1f2b2d0a80cbd58740e64f56ddbc4cee
Signed-off-by: Drew Reed <drew.reed@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Arpita S.K <Arpita.S.K@arm.com>
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-22 16:25:58 +05:30
Abdellatif El Khlifi 430a482430 arm-bsp/linux: introducing corstone1000 FVP machine
This commit enables Linux kernel v5.10 for corstone1000-fvp
machine.

Change-Id: I882902bba273355428af06c29796358e17f9b379
Signed-off-by: Arpita S.K <Arpita.S.K@arm.com>
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Rui Miguel Silva <rui.silva@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-22 16:25:58 +05:30
Diego Sueiro 35fd34a134 arm/trusted-firmware-a,fiptool-native: Fix fiptool execution
After http://git.yoctoproject.org/cgit/cgit.cgi/meta-arm/commit/?id=648571b113b39420735859461fcd69cfc6f66c76
the fiptool create command fails with:
    tools/fiptool/fiptool: error while loading shared libraries: libcrypto.so.3: cannot open shared object file: No such file or directory

Put back the inclusion of BUILD_LDFLAGS to fix this.

Issue-Id: SCM-3548
Signed-off-by: Diego Sueiro <diego.sueiro@arm.com>
Change-Id: I8bfddd0528d5c4dbf5dfd87c9ae17db4e0071b1c
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-22 16:25:58 +05:30
Ross Burton bfe6da8c9b arm/trusted-firmware-a: improve OpenSSL build fix
Take a patch that is heading upstream to pass OPENSSL_DIR to the fiptool
build, removing the need to alter the Makefiles at build time.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-22 16:25:58 +05:30
Ross Burton 70bb3a0a3d arm/fiptool-native: improve OpenSSL build fix
Take a patch that is heading upstream to pass OPENSSL_DIR to the fiptool
build, removing the need to alter the Makefiles at build time.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-22 16:25:58 +05:30
Abdellatif El Khlifi 4556fe3d77 arm/fiptool-native: bumping the version to v2.5
The commit provides the v2.5 recipe for fiptool-native
and removes the older versions.

Change-Id: Ie87ca97bc63bfe7ba2337b1bf05d9658921bab83
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-22 16:25:58 +05:30
Abdellatif El Khlifi a166e092bf arm-bsp/trusted-firmware-a: remove TARGET_FPU build argument
TARGET_FPU passed to TF-A Makefile but is not used in TF-A source code.

Change-Id: I7c275711ed1e9fb9ee4e4df2b9c1606cacc4138c
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-22 16:25:57 +05:30
Satish Kumar 0e6eb300f8 arm/trusted-firmware-m: upgrade to 1.4.0
Update TF-M to version 1.4.0, mbed TLS to 3.0.0, TF-M tests to 1.4.0,
and MCUBoot to TF-Mv1.4-integ tag.

Change-Id: I9172ed9fbf6c6c2ed88303256ef2452dafc665be
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-22 16:25:35 +05:30
Ross Burton b46330d783 CI: disable use of Yocto sstate server
The public sstate server isn't up to the load just yet and often-enough
will take a very long time to respond, causing build failures.

Signed-off-by: Ross Burton <ross.burton@arm.com>
2021-11-16 12:49:14 +00:00
luca fancellu 27e102a430 arm-autonomy/xen-devicetree: change Xen dts and n1sdp dtsi
The current Xen dts produced by the layer is using an old
way to specify the dom0 kernel module that won't be supported
anymore in Xen 4.16 when booting through UEFI.

Change xen.dtsi.in to have the Dom0 kernel module as a
direct child of /chosen node.

For the n1sdp, Grub2 is responsible to create the Dom0
kernel node and properly setup the #address-cells and
the #size-cells properties, so modify the dynamic layer
dtsi for n1sdp to remove these node and properties from
the yocto generated dtb for Xen.

Issue-Id: SCM-3647
Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
Change-Id: I35236bbb3fe97e4237bc5c45fb521efdaa472ef1
Signed-off-by: Ross Burton <ross.burton@arm.com>
2021-11-11 15:48:56 +00:00
Ross Burton 57e683eb80 arm/hafnium: fix kernel tool linking
We need to be sure that the host linker flags are passed to the kernel
build, as otherwise it is possible that binaries are incorrectly linked.
For example:

HOSTCC scripts/extract-cert
ld: .../recipe-sysroot-native/usr/lib/pkgconfig/../../../usr/lib/libcrypto.so: undefined reference to `pthread_once@GLIBC_2.34'

Signed-off-by: Ross Burton <ross.burton@arm.com>
2021-11-10 15:52:11 +00:00
Ross Burton 3236ebeb89 arm/trusted-firmware-a: ensure native cert_create has -rpath
Patch in BUILD_LDFLAGS into the cert_create Makefile so that the -rpath
arguments are passed to the native build, meaning it can find libssl
correctly.  This somewhat worked previously as the host libssl and
sysroot libssl matched, but now that OE has OpenSSL 3 that often isn't
the case.

Signed-off-by: Ross Burton <ross.burton@arm.com>
2021-11-09 20:26:08 +00:00
Peter Hoyes 8bccb38744 runfvp: Ensure new process group is in the foreground
When a new process group is created, it is launched in the background
and any attempt to access the session terminal triggers a SIGTTIN (for
stdin) or SIGTTOU (for stdout) signal. These are ignored in an
interactive shell, but the default signal behavior in a new job is to
send a SIGTSTP to the whole process group. This causes runfvp to hang
when executed via a subprocess when stdin is accessed.

After creating a new process group, use tcsetpgrp to make the new group
the foreground process for the terminal associated with stdin/stdout,
but only if stdin is a tty.

The documentation for tcsetgrp states that tcsetpgrp itself raises a
SIGTTOU signal, so set this signal to SIG_IGN.

Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
Change-Id: I349a825df7fcb8a3cedb81762b901c6f50fa53b5
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-11-01 21:01:40 -04:00
Abdellatif El Khlifi 2e2dbc2587 arm/trusted-firmware-m: setting the toolchain file path in PACKAGECONFIG
Toolchain files toolchain_GNUARM.cmake and toolchain_ARMCLANG.cmake are
located at trusted-firmware-m source directory.

This commit sets that.

Change-Id: If9c26f65b0c8111a6ff1f1a7d56610563efd501b
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-10-20 14:07:18 -04:00
Abdellatif El Khlifi ab574b084e arm/trusted-firmware-m: enabling PACKAGECONFIG when using CMake
In case of CMake, PACKAGECONFIG configs take effect when passing
PACKAGECONFIG_CONFARGS to the configure task.

Change-Id: I126ba089c9a5db8e895b8a9545e96ef9fa98ce0d
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-10-20 14:07:18 -04:00
Ross Burton b4f52f2642 arm/lib/oeqa: fix module lookup
As multiple paths can and do provide modules under oeqa.controllers, all
of these paths need to call pkgutil.extend_path() so the lookup works
correctly.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-10-20 14:07:18 -04:00
Ross Burton 2d22a1f7ae CI: enable testimage for fvp-base
Inherit fvpboot so that the FVP binary is fetched and configuration
generated.

Configure the FVP to forward host port 8022 to port 22 locally, and
tell testimage to SSH to localhost:8022. This has the limitation that
only one testimage can run per machine, but this will be removed shortly.

Disable the parselogs test case, as there are some harmless warnings in
the dmesg which cause it to fail.  Currently meta-arm can't extend the
whitelist of ignorable warnings.

The FVP binaries are x86-64 only, so tag the job appropriately.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-10-20 14:07:11 -04:00
Ross Burton ba86aeb31f CI: install telnet into the images
runfvp currently needs telnet to communicate with the guest, so install
telnet into the image.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-10-20 14:07:11 -04:00
Ross Burton 48524c32d5 arm-bsp/fvp-common: set TEST_TARGET to OEFVPTarget
Set TEST_TARGET so that all FVP machines use the new FVP target out of
the box, instead of attempting to use qemu.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-10-20 14:07:11 -04:00
Ross Burton 4b1a0c7484 arm-bsp/fvp: enable virtio drivers
All FVPs can use virtio networking devices, so enable virtio in all of
the FVP kernels.

Remove our fvp/fvp-virtio.cfg as there's cfg/virtio.scc we can use.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-10-20 14:07:11 -04:00
Ross Burton 2824f6a58b arm/oeqa: add FVP testimage controller target
Add a new oeqa.core.target.OETarget subclass for testimage which starts
a FVP using runfvp. This uses --console to connect to the console so
telnet is needed on the host.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-10-20 14:07:11 -04:00
Ross Burton 0a64644bc9 runfvp: reset the process group on startup
So that it is easy to kill runfvp and everything it starts (such as
telnet or the FVP itself), reset the process group on startup.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-10-20 14:07:11 -04:00
Ross Burton 491cac17fe gem5/gem5-native: add missing m4-native DEPENDS
Latest oe-core has less implicit DEPENDS, so gem5 fails to configure:

Error: Can't find version of M4 macro processor.  Please install M4 and try again.

Explicitly add m4-native to DEPENDS.

Change-Id: I2e107ea6448eec399619e0d1922fd29930a95fd8
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-10-20 14:07:11 -04:00
Ross Burton 328d95e27d CI: use http: to access sstate mirror
The sstate mirrors are not available over HTTPS currently due to a
certificate problem, so use plain HTTP instead.

Change-Id: I5b974d67bc13f7c7234927c6bc62a8c733e454c3
Signed-off-by: Ross Burton <ross.burton@arm.com>
2021-10-19 16:39:48 +01:00
Hugo L'Hostis 99b9ee4470 kas/fvp-baser-aemv8r64: use honister as default branch
Issue-Id: SCM-3532
Signed-off-by: Hugo L'Hostis <hugo.lhostis@arm.com>
Change-Id: I05b529da0f5bbdcee038476d07c42f1b6ac0526f
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-10-15 10:16:14 -04:00
205 changed files with 35990 additions and 225 deletions
+1
View File
@@ -0,0 +1 @@
__pycache__
+60 -105
View File
@@ -1,9 +1,7 @@
image: ghcr.io/siemens/kas/kas
# First do a common bootstrap, and then build all the targets
stages:
- prep
- bootstrap
- build
# Common job fragment to get a worker ready
@@ -27,12 +25,13 @@ stages:
- mkdir --verbose --parents $KAS_WORK_DIR $KAS_REPO_REF_DIR $SSTATE_DIR $DL_DIR $TOOLCHAIN_DIR $TOOLCHAIN_LINK_DIR
# Must do this here, as it's the only way to make sure the toolchain is installed on the same builder
- ./ci/get-binary-toolchains $DL_DIR $TOOLCHAIN_DIR $TOOLCHAIN_LINK_DIR
- sudo apt update && sudo apt install telnet -y
# Generalised fragment to do a Kas build
.build:
extends: .setup
script:
- KASFILES=$(./ci/jobs-to-kas $CI_JOB_NAME)
- KASFILES=$(./ci/jobs-to-kas "$CI_JOB_NAME")
- kas shell --update --force-checkout $KASFILES -c 'cat conf/*.conf'
- kas build $KASFILES
- ./ci/check-warnings $KAS_WORK_DIR/build/warnings.log
@@ -41,7 +40,7 @@ stages:
.build_and_test:
extends: .setup
script:
- KASFILES=$(./ci/jobs-to-kas $CI_JOB_NAME)
- KASFILES=$(./ci/jobs-to-kas "$CI_JOB_NAME")
- kas shell --update --force-checkout $KASFILES -c 'cat conf/*.conf'
- kas build $KASFILES
- kas build $KASFILES -c testimage
@@ -57,23 +56,10 @@ update-repos:
script:
- flock --verbose --timeout 60 $KAS_REPO_REF_DIR ./ci/update-repos
#
# Bootstrap stage, bootstrap and machine coverage
#
# Build a number of native tools first to ensure the other builders don't race
# over them
n1sdp/bootstrap:
extends: .build
stage: bootstrap
n1sdp/clang/clang-bootstrap:
extends: .build
stage: bootstrap
# What percentage of machines in the layer do we build
machine-coverage:
stage: bootstrap
stage: build
interruptible: true
script:
- ./ci/check-machine-coverage
@@ -82,6 +68,11 @@ machine-coverage:
#
# Build stage, the actual build jobs
#
# Available options for building are
# TOOLCHAINS: [gcc, clang, armgcc, external-gccarm]
# TCLIBC: [glibc, musl]
# VIRT: [none, xen]
# TESTING: testimage
# Validate layers are Yocto Project Compatible
check-layers:
@@ -108,14 +99,25 @@ corstone700-fvp:
corstone700-mps3:
extends: .build
corstone1000-fvp:
extends: .build
corstone1000-mps3:
extends: .build
fvp-base:
extends: .build
parallel:
matrix:
- TESTING: testimage
tags:
- x86_64
fvp-base-arm32:
extends: .build
fvp-base-arm32/external-gccarm:
extends: .build
parallel:
matrix:
- TOOLCHAINS: [gcc, external-gccarm]
fvp-baser-aemv8r64:
extends: .build
@@ -125,9 +127,9 @@ fvps:
gem5-arm64:
extends: .build
gem5-arm64/xen:
extends: .build
parallel:
matrix:
- VIRT: [none, xen]
gem5-atp-arm64:
extends: .build
@@ -137,12 +139,15 @@ generic-arm64:
juno:
extends: .build
parallel:
matrix:
- TOOLCHAINS: [gcc, clang]
juno/clang:
extends: .build
microbit-v1/testimage-zephyr:
microbit-v1:
extends: .build_and_test
parallel:
matrix:
- TESTING: testimage-zephyr
musca-b1:
extends: .build
@@ -152,48 +157,49 @@ musca-s1:
n1sdp:
extends: .build
n1sdp/armgcc:
extends: .build
parallel:
matrix:
- TOOLCHAINS: [gcc, armgcc]
qemu-cortex-a53:
extends: .build
qemu-cortex-m3/testimage-zephyr:
qemu-cortex-m3:
extends: .build_and_test
parallel:
matrix:
- TESTING: testimage-zephyr
qemu-cortex-r5:
extends: .build
qemuarm64-sbsa:
qemuarm64-secureboot:
extends: .build
parallel:
matrix:
- TOOLCHAINS: [gcc, clang]
TCLIBC: [glibc, musl]
TESTING: testimage
qemuarm64-secureboot/testimage:
qemuarm64:
extends: .build
parallel:
matrix:
- VIRT: xen
qemuarm64-secureboot/clang/testimage:
qemuarm:
extends: .build
parallel:
matrix:
- TOOLCHAINS: [gcc, clang]
TESTING: testimage
- VIRT: xen
qemuarm64-secureboot/clang/musl/testimage:
extends: .build
qemuarm64-secureboot/musl/testimage:
extends: .build
qemuarm64/xen:
extends: .build
qemuarm/clang/testimage:
extends: .build
qemuarm/testimage:
extends: .build
qemuarm/xen:
extends: .build
qemuarmv5/testimage:
qemuarmv5:
extends: .build
parallel:
matrix:
- TESTING: testimage
sgi575:
extends: .build
@@ -210,54 +216,3 @@ tc1:
toolchains:
extends: .build
#
# Utility tasks, not executed automatically
#
delete-dl-dir:
extends: .setup
stage: prep
when: manual
script:
- rm -rf $DL_DIR/*
delete-repo-dir:
extends: .setup
stage: prep
when: manual
script:
- rm -rf $KAS_REPO_REF_DIR/*
# Delete all sstate
delete-sstate:
extends: .setup
stage: prep
when: manual
script:
- rm -rf $SSTATE_DIR/*
delete-toolchains:
extends: .setup
stage: prep
when: manual
script:
- rm -rf $TOOLCHAIN_DIR/*
# Wipe out old sstate
prune-sstate:
extends: .setup
stage: prep
when: manual
script:
- du -h -s $SSTATE_DIR
- find $SSTATE_DIR -type f -atime +30 -delete
- du -h -s $SSTATE_DIR
# Report on disk usage
usage:
extends: .setup
stage: prep
when: manual
script:
- du -h -s $DL_DIR $SSTATE_DIR $KAS_REPO_REF_DIR $TOOLCHAIN_DIR
-5
View File
@@ -37,11 +37,6 @@ local_conf_header:
PACKAGECONFIG:append:pn-perf = " coresight"
noptest: |
DISTRO_FEATURES:remove = "ptest"
sstate_mirror: |
BB_HASHSERVE_UPSTREAM = "typhoon.yocto.io:8687"
BB_HASHSERVE = "auto"
BB_SIGNATURE_HANDLER = "OEEquivHash"
SSTATE_MIRRORS = "file://.* https://sstate.yoctoproject.org/dev/PATH;downloadfilename=PATH"
machine: unset
-9
View File
@@ -1,9 +0,0 @@
header:
version: 9
target:
- binutils-cross-aarch64
- gcc-cross-aarch64
- python3-native
- opkg-native
- rpm-native
-10
View File
@@ -1,10 +0,0 @@
header:
version: 9
target:
- binutils-cross-aarch64
- clang-cross-aarch64
- clang-native
- python3-native
- opkg-native
- rpm-native
+12
View File
@@ -0,0 +1,12 @@
header:
version: 9
includes:
- base.yml
- meta-openembedded.yml
local_conf_header:
custom-local-conf: |
INITRAMFS_IMAGE_BUNDLE = "0"
INITRAMFS_IMAGE:remove = "corstone1000-initramfs-image"
machine: corstone1000-fvp
+12
View File
@@ -0,0 +1,12 @@
header:
version: 9
includes:
- base.yml
- meta-openembedded.yml
local_conf_header:
custom-local-conf: |
INITRAMFS_IMAGE_BUNDLE = "0"
INITRAMFS_IMAGE:remove = "corstone1000-initramfs-image"
machine: corstone1000-mps3
+9
View File
@@ -5,3 +5,12 @@ header:
machine: fvp-base
local_conf_header:
testimagefvp: |
INHERIT = "fvpboot"
# This fails but we can't add to the ignorelist from meta-arm yet
# https://bugzilla.yoctoproject.org/show_bug.cgi?id=14604
TEST_SUITES:remove = "parselogs"
# Tell testimage to connect to localhost:8022, and forward that to SSH in the FVP.
TEST_TARGET_IP = "localhost:8022"
FVP_CONFIG[bp.virtio_net.hostbridge.userNetPorts] ?= "8022=22"
+20 -12
View File
@@ -1,19 +1,27 @@
#! /bin/bash
# Read a GitLab CI job name on $1 and transform it to a
# list of Kas yaml files
# This script is expecting an input of machine name, optionally followed by a
# colon and a list of one or more parameters separated by commas between
# brackets. For example, the following are acceptable:
# corstone500
# fvp-base: [testimage]
# qemuarm64-secureboot: [clang, glibc, testimage]
#
# Turn this list into a series of yml files separated by colons to pass to kas
set -e -u
# Read Job namne from $1 and split on /
IFS=/ read -r -a PARTS<<<$1
FILES="ci/$(echo $1 | cut -d ':' -f 1).yml"
# Prefix each part with ci/
PARTS=("${PARTS[@]/#/ci/}")
for i in $(echo $1 | cut -s -d ':' -f 2 | sed 's/[][,]//g'); do
# Given that there are no yml files for gcc or glibc, as those are the
# defaults, we can simply ignore those parameters. They are necessary
# to pass in so that matrix can correctly setup all of the permutations
# of each individual run.
if [[ $i == 'none' || $i == 'gcc' || $i == 'glibc' ]]; then
continue
fi
FILES+=":ci/$i.yml"
done
# Suffix each part with .yml
PARTS=("${PARTS[@]/%/.yml}")
# Print colon-separated
IFS=":"
echo "${PARTS[*]}"
echo $FILES
+3
View File
@@ -14,3 +14,6 @@ target:
- core-image-base
- perf
- optee-examples
- optee-test
- optee-spdevkit
- optee-os-tadevkit
+48
View File
@@ -0,0 +1,48 @@
header:
version: 11
distro: poky-tiny
defaults:
repos:
refspec: honister
repos:
meta-arm:
layers:
meta-arm:
meta-arm-bsp:
meta-arm-toolchain:
poky:
url: https://git.yoctoproject.org/git/poky
refspec: b6b0af0889de9da0e4128cef8c9069b770b7d5a0
layers:
meta:
meta-poky:
meta-yocto-bsp:
meta-openembedded:
url: https://git.openembedded.org/meta-openembedded
refspec: ad52a41de8b4b7d619d1376d0a0090ebcfff56da
layers:
meta-oe:
meta-python:
meta-arm-image:
url: https://git.gitlab.arm.com/arm-reference-solutions/meta-arm-image.git
refspec: aeb0571e8bc935f3f8b15c3b27ab4275e2069b5b
local_conf_header:
base: |
CONF_VERSION = "2"
PACKAGE_CLASSES = "package_ipk"
LICENSE_FLAGS_WHITELIST += "armcompiler"
BB_NUMBER_THREADS ?= "16"
PARALLEL_MAKE ?= "-j16"
PACKAGECONFIG:append:pn-perf = " coresight"
machine: unset
target:
- corstone1000-image
+16
View File
@@ -0,0 +1,16 @@
header:
version: 11
includes:
- kas/corstone1000-base.yml
repos:
run-scripts:
url: https://git.gitlab.arm.com/arm-reference-solutions/model-scripts.git
refspec: 7ad7b6f33bbdb7ae10c7ecfd56820c03a71e9bdf
layers:
.: 'excluded'
machine: corstone1000-fvp
target:
- corstone1000-image
+6
View File
@@ -0,0 +1,6 @@
header:
version: 11
includes:
- kas/corstone1000-base.yml
machine: corstone1000-mps3
+1 -1
View File
@@ -6,7 +6,7 @@ machine: fvp-baser-aemv8r64
defaults:
repos:
refspec: master
refspec: honister
repos:
meta-arm:
+1 -1
View File
@@ -1,7 +1,7 @@
header:
version: 9
includes:
- fvp-baser-aemv8r64-bsp.yml
- kas/fvp-baser-aemv8r64-bsp.yml
local_conf_header:
base-rt: |
@@ -38,4 +38,14 @@
/delete-property/ iommu-map;
};
};
/*
* Delete module node for Dom0, #size-cells and #address-cells because Grub2
* is responsible to create them
*/
chosen {
/delete-property/ #size-cells;
/delete-property/ #address-cells;
/delete-node/ module@0;
};
};
@@ -1,16 +1,13 @@
/ {
chosen {
#size-cells = <0x00000001>;
#address-cells = <0x00000001>;
xen,dom0-bootargs = "###XEN_DOM0_BOOTARGS###";
xen,xen-bootargs = "###XEN_XEN_BOOTARGS###";
modules {
#size-cells = <0x00000001>;
#address-cells = <0x00000001>;
module@0 {
reg = <###XEN_DOM0_ADDR### ###XEN_DOM0_SIZE###>;
compatible = "multiboot,module";
};
module@0 {
reg = <###XEN_DOM0_ADDR### ###XEN_DOM0_SIZE###>;
compatible = "multiboot,module";
};
};
};
+1
View File
@@ -13,6 +13,7 @@ LAYERSERIES_COMPAT_meta-arm-bsp = "honister"
LAYERDEPENDS_meta-arm-bsp = "core meta-arm"
# This won't be used by layerindex-fetch, but works everywhere else
LAYERDEPENDS_meta-arm-bsp:append:corstone1000 = " meta-python openembedded-layer"
LAYERDEPENDS_meta-arm-bsp:append:musca-b1 = " meta-python"
LAYERDEPENDS_meta-arm-bsp:append:musca-s1 = " meta-python"
@@ -0,0 +1,9 @@
#@TYPE: Machine
#@NAME: corstone1000-fvp machine
#@DESCRIPTION: Machine configuration for Corstone1000 64-bit FVP
require conf/machine/include/corstone1000.inc
TFA_TARGET_PLATFORM = "fvp"
TFM_PLATFORM_IS_FVP = "TRUE"
@@ -0,0 +1,9 @@
#@TYPE: Machine
#@NAME: corstone1000-mps3 machine
#@DESCRIPTION: Machine configuration for Corstone1000 64-bit MPS3 FPGA board
require conf/machine/include/corstone1000.inc
TFA_TARGET_PLATFORM = "fpga"
PLATFORM_IS_FVP = "FALSE"
+2
View File
@@ -25,3 +25,5 @@ EXTRA_IMAGEDEPENDS += "virtual/trusted-firmware-a u-boot"
# initialise) and install the pre-generated keys.
PACKAGECONFIG:remove:pn-openssh = "rng-tools"
MACHINE_EXTRA_RRECOMMENDS += "ssh-pregen-hostkeys"
TEST_TARGET = "OEFVPTarget"
@@ -0,0 +1,66 @@
require conf/machine/include/arm/armv8a/tune-cortexa35.inc
MACHINEOVERRIDES =. "corstone1000:"
# TF-A
TFA_PLATFORM = "corstone1000"
PREFERRED_VERSION_trusted-firmware-a ?= "2.5%"
EXTRA_IMAGEDEPENDS += "virtual/trusted-firmware-a"
TFA_BL2_BINARY = "bl2-corstone1000.bin"
TFA_FIP_BINARY = "fip-corstone1000.bin"
# TF-M
PREFERRED_VERSION_trusted-firmware-m ?= "1.5%"
TFM_PLATFORM = "arm/corstone1000"
EXTRA_IMAGEDEPENDS += "virtual/trusted-firmware-m"
# TF-M settings for signing host images
TFA_BL2_RE_IMAGE_LOAD_ADDRESS = "0x62353000"
TFA_BL2_RE_SIGN_BIN_SIZE = "0x2d000"
TFA_FIP_RE_IMAGE_LOAD_ADDRESS = "0x68130000"
TFA_FIP_RE_SIGN_BIN_SIZE = "0x00200000"
RE_LAYOUT_WRAPPER_VERSION = "0.0.7"
TFM_SIGN_PRIVATE_KEY = "${S}/bl2/ext/mcuboot/root-RSA-3072_1.pem"
RE_IMAGE_OFFSET = "0x1000"
# u-boot
PREFERRED_VERSION_u-boot ?= "2021.07"
EXTRA_IMAGEDEPENDS += "u-boot"
UBOOT_CONFIG ??= "EFI"
UBOOT_CONFIG[EFI] = "corstone1000_defconfig"
UBOOT_ENTRYPOINT = "0x80000000"
UBOOT_LOADADDRESS = "0x80000000"
UBOOT_BOOTARGS = "earlycon=pl011,0x1a510000 console=ttyAMA0 loglevel=9"
UBOOT_ARCH = "arm"
UBOOT_EXTLINUX = "0"
# optee
EXTRA_IMAGEDEPENDS += "optee-os"
OPTEE_ARCH = "arm64"
OPTEE_BINARY = "tee-pager_v2.bin"
# Trusted Services(TS)
EXTRA_IMAGEDEPENDS += "secure-partitions"
# Linux kernel
PREFERRED_PROVIDER_virtual/kernel:forcevariable = "linux-yocto"
PREFERRED_VERSION_linux-yocto = "5.10%"
KERNEL_IMAGETYPE = "Image"
INITRAMFS_IMAGE_BUNDLE ?= "1"
#telling the build system which image is responsible of the generation of the initramfs rootfs
INITRAMFS_IMAGE = "corstone1000-initramfs-image"
# enable this feature for kernel debugging
# MACHINE_FEATURES += "corstone1000_kernel_debug"
# login terminal serial port settings
SERIAL_CONSOLES ?= "115200;ttyAMA0"
# making sure EXTRA_IMAGEDEPENDS will be used while creating the image
WKS_FILE_DEPENDS:append = " ${EXTRA_IMAGEDEPENDS}"
WKS_FILE ?= "corstone1000-image.corstone1000.wks"
@@ -44,7 +44,8 @@ Ubuntu 20.04.
Install the required packages for the build host:
https://docs.yoctoproject.org/singleindex.html#required-packages-for-the-build-host
Install the kas setup tool for bitbake based projects:
Kas is a setup tool for bitbake based projects. The minimal supported version
is 2.6, install it like so:
pip3 install --user kas
@@ -0,0 +1,587 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Arpita S.K <arpita.s.k@arm.com>
From b4d59c85d1045998275cd219efe5849803c2c616 Mon Sep 17 00:00:00 2001
From: "Arpita S.K" <Arpita.S.K@arm.com>
Date: Wed, 13 Oct 2021 18:05:11 +0530
Subject: [PATCH] Rename Diphda to corstone1000
Replace all the instances of Diphda as functions,
macros etc. with corstone1000
Signed-off-by: Arpita S.K <Arpita.S.K@arm.com>
---
docs/about/maintainers.rst | 2 +-
.../arm/{diphda => corstone1000}/index.rst | 6 +-
docs/plat/arm/index.rst | 2 +-
plat/arm/board/common/rotpk/arm_dev_rotpk.S | 2 +-
.../corstone1000_bl2_mem_params_desc.c} | 8 +-
.../common/corstone1000_err.c} | 2 +-
.../common/corstone1000_helpers.S} | 4 +-
.../common/corstone1000_plat.c} | 6 +-
.../common/corstone1000_pm.c} | 0
.../common/corstone1000_security.c} | 0
.../common/corstone1000_stack_protector.c} | 0
.../common/corstone1000_topology.c} | 12 +--
.../common/corstone1000_trusted_boot.c} | 2 +-
.../fdts/corstone1000_spmc_manifest.dts} | 0
.../common/include/platform_def.h | 52 ++++++------
.../include/plat_macros.S | 0
plat/arm/board/corstone1000/platform.mk | 83 +++++++++++++++++++
plat/arm/board/diphda/platform.mk | 83 -------------------
18 files changed, 132 insertions(+), 132 deletions(-)
rename docs/plat/arm/{diphda => corstone1000}/index.rst (93%)
rename plat/arm/board/{diphda/common/diphda_bl2_mem_params_desc.c => corstone1000/common/corstone1000_bl2_mem_params_desc.c} (92%)
rename plat/arm/board/{diphda/common/diphda_err.c => corstone1000/common/corstone1000_err.c} (89%)
rename plat/arm/board/{diphda/common/diphda_helpers.S => corstone1000/common/corstone1000_helpers.S} (94%)
rename plat/arm/board/{diphda/common/diphda_plat.c => corstone1000/common/corstone1000_plat.c} (92%)
rename plat/arm/board/{diphda/common/diphda_pm.c => corstone1000/common/corstone1000_pm.c} (100%)
rename plat/arm/board/{diphda/common/diphda_security.c => corstone1000/common/corstone1000_security.c} (100%)
rename plat/arm/board/{diphda/common/diphda_stack_protector.c => corstone1000/common/corstone1000_stack_protector.c} (100%)
rename plat/arm/board/{diphda/common/diphda_topology.c => corstone1000/common/corstone1000_topology.c} (77%)
rename plat/arm/board/{diphda/common/diphda_trusted_boot.c => corstone1000/common/corstone1000_trusted_boot.c} (97%)
rename plat/arm/board/{diphda/common/fdts/diphda_spmc_manifest.dts => corstone1000/common/fdts/corstone1000_spmc_manifest.dts} (100%)
rename plat/arm/board/{diphda => corstone1000}/common/include/platform_def.h (89%)
rename plat/arm/board/{diphda => corstone1000}/include/plat_macros.S (100%)
create mode 100644 plat/arm/board/corstone1000/platform.mk
delete mode 100644 plat/arm/board/diphda/platform.mk
diff --git a/docs/about/maintainers.rst b/docs/about/maintainers.rst
index 07f258c774..2d9eb1440d 100644
--- a/docs/about/maintainers.rst
+++ b/docs/about/maintainers.rst
@@ -399,7 +399,7 @@ Arm Rich IoT Platform ports
:|G|: `vishnu-banavath`_
:|F|: plat/arm/board/corstone700
:|F|: plat/arm/board/a5ds
-:|F|: plat/arm/board/diphda
+:|F|: plat/arm/board/corstone1000
Arm Reference Design platform ports
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/docs/plat/arm/diphda/index.rst b/docs/plat/arm/corstone1000/index.rst
similarity index 93%
rename from docs/plat/arm/diphda/index.rst
rename to docs/plat/arm/corstone1000/index.rst
index 27afda43f5..b889b7f2e9 100644
--- a/docs/plat/arm/diphda/index.rst
+++ b/docs/plat/arm/corstone1000/index.rst
@@ -1,7 +1,7 @@
-Diphda Platform
+Corstone1000 Platform
==========================
-Some of the features of the Diphda platform referenced in TF-A include:
+Some of the features of the Corstone1000 platform referenced in TF-A include:
- Cortex-A35 application processor (64-bit mode)
- Secure Enclave
@@ -37,7 +37,7 @@ Build Procedure (TF-A only)
CC=aarch64-none-elf-gcc \
V=1 \
BUILD_BASE=<path to the build folder> \
- PLAT=diphda \
+ PLAT=corstone1000 \
SPD=spmd \
SPMD_SPM_AT_SEL2=0 \
DEBUG=1 \
diff --git a/docs/plat/arm/index.rst b/docs/plat/arm/index.rst
index c834f6ae70..23c561ff57 100644
--- a/docs/plat/arm/index.rst
+++ b/docs/plat/arm/index.rst
@@ -12,7 +12,7 @@ Arm Development Platforms
arm_fpga/index
arm-build-options
morello/index
- diphda/index
+ corstone1000/index
This chapter holds documentation related to Arm's development platforms,
including both software models (FVPs) and hardware development boards
diff --git a/plat/arm/board/common/rotpk/arm_dev_rotpk.S b/plat/arm/board/common/rotpk/arm_dev_rotpk.S
index 38f91fe5f8..125ddf67c7 100644
--- a/plat/arm/board/common/rotpk/arm_dev_rotpk.S
+++ b/plat/arm/board/common/rotpk/arm_dev_rotpk.S
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-/* diphda platform provides custom values for the macros defined in
+/* corstone1000 platform provides custom values for the macros defined in
* arm_def.h , so only platform_def.h needs to be included
*/
#if !defined(TARGET_PLATFORM_FVP) && !defined(TARGET_PLATFORM_FPGA)
diff --git a/plat/arm/board/diphda/common/diphda_bl2_mem_params_desc.c b/plat/arm/board/corstone1000/common/corstone1000_bl2_mem_params_desc.c
similarity index 92%
rename from plat/arm/board/diphda/common/diphda_bl2_mem_params_desc.c
rename to plat/arm/board/corstone1000/common/corstone1000_bl2_mem_params_desc.c
index 916c868d21..7baa82d31b 100644
--- a/plat/arm/board/diphda/common/diphda_bl2_mem_params_desc.c
+++ b/plat/arm/board/corstone1000/common/corstone1000_bl2_mem_params_desc.c
@@ -44,7 +44,7 @@ static bl_mem_params_node_t bl2_mem_params_descs[] = {
SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
VERSION_2, entry_point_info_t, SECURE | EXECUTABLE),
.ep_info.pc = BL32_BASE,
- .ep_info.args.arg0 = DIPHDA_TOS_FW_CONFIG_BASE,
+ .ep_info.args.arg0 = CORSTONE1000_TOS_FW_CONFIG_BASE,
SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
VERSION_2, image_info_t, 0),
.image_info.image_base = BL32_BASE,
@@ -56,9 +56,9 @@ static bl_mem_params_node_t bl2_mem_params_descs[] = {
/* Fill TOS_FW_CONFIG related information */
{
.image_id = TOS_FW_CONFIG_ID,
- .image_info.image_base = DIPHDA_TOS_FW_CONFIG_BASE,
- .image_info.image_max_size = DIPHDA_TOS_FW_CONFIG_LIMIT - \
- DIPHDA_TOS_FW_CONFIG_BASE,
+ .image_info.image_base = CORSTONE1000_TOS_FW_CONFIG_BASE,
+ .image_info.image_max_size = CORSTONE1000_TOS_FW_CONFIG_LIMIT - \
+ CORSTONE1000_TOS_FW_CONFIG_BASE,
SET_STATIC_PARAM_HEAD(ep_info, PARAM_IMAGE_BINARY,
VERSION_2, entry_point_info_t, SECURE | NON_EXECUTABLE),
SET_STATIC_PARAM_HEAD(image_info, PARAM_IMAGE_BINARY,
diff --git a/plat/arm/board/diphda/common/diphda_err.c b/plat/arm/board/corstone1000/common/corstone1000_err.c
similarity index 89%
rename from plat/arm/board/diphda/common/diphda_err.c
rename to plat/arm/board/corstone1000/common/corstone1000_err.c
index 89a3b8249c..5f8e7da437 100644
--- a/plat/arm/board/diphda/common/diphda_err.c
+++ b/plat/arm/board/corstone1000/common/corstone1000_err.c
@@ -7,7 +7,7 @@
#include <plat/arm/common/plat_arm.h>
/*
- * diphda error handler
+ * corstone1000 error handler
*/
void __dead2 plat_arm_error_handler(int err)
{
diff --git a/plat/arm/board/diphda/common/diphda_helpers.S b/plat/arm/board/corstone1000/common/corstone1000_helpers.S
similarity index 94%
rename from plat/arm/board/diphda/common/diphda_helpers.S
rename to plat/arm/board/corstone1000/common/corstone1000_helpers.S
index c9d2a88de9..87122270b0 100644
--- a/plat/arm/board/diphda/common/diphda_helpers.S
+++ b/plat/arm/board/corstone1000/common/corstone1000_helpers.S
@@ -29,7 +29,7 @@ endfunc plat_secondary_cold_boot_setup
* unsigned long plat_get_my_entrypoint (void);
*
* Main job of this routine is to distinguish between a cold and warm
- * boot. On diphda, this information can be queried from the power
+ * boot. On corstone1000, this information can be queried from the power
* controller. The Power Control SYS Status Register (PSYSR) indicates
* the wake-up reason for the CPU.
*
@@ -61,7 +61,7 @@ func plat_is_my_cpu_primary
mrs x0, mpidr_el1
mov_imm x1, MPIDR_AFFINITY_MASK
and x0, x0, x1
- cmp x0, #DIPHDA_PRIMARY_CPU
+ cmp x0, #CORSTONE1000_PRIMARY_CPU
cset w0, eq
ret
endfunc plat_is_my_cpu_primary
diff --git a/plat/arm/board/diphda/common/diphda_plat.c b/plat/arm/board/corstone1000/common/corstone1000_plat.c
similarity index 92%
rename from plat/arm/board/diphda/common/diphda_plat.c
rename to plat/arm/board/corstone1000/common/corstone1000_plat.c
index 28d15a59e6..7a38b0b2ee 100644
--- a/plat/arm/board/diphda/common/diphda_plat.c
+++ b/plat/arm/board/corstone1000/common/corstone1000_plat.c
@@ -21,12 +21,12 @@ const mmap_region_t plat_arm_mmap[] = {
ARM_MAP_SHARED_RAM,
ARM_MAP_NS_SHARED_RAM,
ARM_MAP_NS_DRAM1,
- DIPHDA_MAP_DEVICE,
- DIPHDA_EXTERNAL_FLASH,
+ CORSTONE1000_MAP_DEVICE,
+ CORSTONE1000_EXTERNAL_FLASH,
{0}
};
-/* diphda only has one always-on power domain and there
+/* corstone1000 only has one always-on power domain and there
* is no power control present
*/
void __init plat_arm_pwrc_setup(void)
diff --git a/plat/arm/board/diphda/common/diphda_pm.c b/plat/arm/board/corstone1000/common/corstone1000_pm.c
similarity index 100%
rename from plat/arm/board/diphda/common/diphda_pm.c
rename to plat/arm/board/corstone1000/common/corstone1000_pm.c
diff --git a/plat/arm/board/diphda/common/diphda_security.c b/plat/arm/board/corstone1000/common/corstone1000_security.c
similarity index 100%
rename from plat/arm/board/diphda/common/diphda_security.c
rename to plat/arm/board/corstone1000/common/corstone1000_security.c
diff --git a/plat/arm/board/diphda/common/diphda_stack_protector.c b/plat/arm/board/corstone1000/common/corstone1000_stack_protector.c
similarity index 100%
rename from plat/arm/board/diphda/common/diphda_stack_protector.c
rename to plat/arm/board/corstone1000/common/corstone1000_stack_protector.c
diff --git a/plat/arm/board/diphda/common/diphda_topology.c b/plat/arm/board/corstone1000/common/corstone1000_topology.c
similarity index 77%
rename from plat/arm/board/diphda/common/diphda_topology.c
rename to plat/arm/board/corstone1000/common/corstone1000_topology.c
index 9dfd05d091..2a3b6913a1 100644
--- a/plat/arm/board/diphda/common/diphda_topology.c
+++ b/plat/arm/board/corstone1000/common/corstone1000_topology.c
@@ -7,8 +7,8 @@
#include <plat/arm/common/plat_arm.h>
#include <plat/common/platform.h>
-/* The diphda power domain tree descriptor */
-static unsigned char diphda_power_domain_tree_desc[PLAT_ARM_CLUSTER_COUNT
+/* The corstone1000 power domain tree descriptor */
+static unsigned char corstone1000_power_domain_tree_desc[PLAT_ARM_CLUSTER_COUNT
+ 2];
/*******************************************************************************
* This function dynamically constructs the topology according to
@@ -22,13 +22,13 @@ const unsigned char *plat_get_power_domain_tree_desc(void)
* The highest level is the system level. The next level is constituted
* by clusters and then cores in clusters.
*/
- diphda_power_domain_tree_desc[0] = 1;
- diphda_power_domain_tree_desc[1] = PLAT_ARM_CLUSTER_COUNT;
+ corstone1000_power_domain_tree_desc[0] = 1;
+ corstone1000_power_domain_tree_desc[1] = PLAT_ARM_CLUSTER_COUNT;
for (i = 0; i < PLAT_ARM_CLUSTER_COUNT; i++)
- diphda_power_domain_tree_desc[i + 2] = PLATFORM_CORE_COUNT;
+ corstone1000_power_domain_tree_desc[i + 2] = PLATFORM_CORE_COUNT;
- return diphda_power_domain_tree_desc;
+ return corstone1000_power_domain_tree_desc;
}
/******************************************************************************
diff --git a/plat/arm/board/diphda/common/diphda_trusted_boot.c b/plat/arm/board/corstone1000/common/corstone1000_trusted_boot.c
similarity index 97%
rename from plat/arm/board/diphda/common/diphda_trusted_boot.c
rename to plat/arm/board/corstone1000/common/corstone1000_trusted_boot.c
index ddb41faa6b..2e2e9475a5 100644
--- a/plat/arm/board/diphda/common/diphda_trusted_boot.c
+++ b/plat/arm/board/corstone1000/common/corstone1000_trusted_boot.c
@@ -38,7 +38,7 @@ int plat_get_rotpk_info(void *cookie, void **key_ptr, unsigned int *key_len,
*/
int plat_get_nv_ctr(void *cookie, unsigned int *nv_ctr)
{
- *nv_ctr = DIPHDA_FW_NVCTR_VAL;
+ *nv_ctr = CORSTONE1000_FW_NVCTR_VAL;
return 0;
}
diff --git a/plat/arm/board/diphda/common/fdts/diphda_spmc_manifest.dts b/plat/arm/board/corstone1000/common/fdts/corstone1000_spmc_manifest.dts
similarity index 100%
rename from plat/arm/board/diphda/common/fdts/diphda_spmc_manifest.dts
rename to plat/arm/board/corstone1000/common/fdts/corstone1000_spmc_manifest.dts
diff --git a/plat/arm/board/diphda/common/include/platform_def.h b/plat/arm/board/corstone1000/common/include/platform_def.h
similarity index 89%
rename from plat/arm/board/diphda/common/include/platform_def.h
rename to plat/arm/board/corstone1000/common/include/platform_def.h
index 37fd71b6aa..e36bb626ee 100644
--- a/plat/arm/board/diphda/common/include/platform_def.h
+++ b/plat/arm/board/corstone1000/common/include/platform_def.h
@@ -34,17 +34,17 @@
#define V2M_IOFPGA_UART0_CLK_IN_HZ 50000000
#define V2M_IOFPGA_UART1_CLK_IN_HZ 50000000
-/* Core/Cluster/Thread counts for diphda */
-#define DIPHDA_CLUSTER_COUNT U(1)
-#define DIPHDA_MAX_CPUS_PER_CLUSTER U(4)
-#define DIPHDA_MAX_PE_PER_CPU U(1)
-#define DIPHDA_PRIMARY_CPU U(0)
+/* Core/Cluster/Thread counts for corstone1000 */
+#define CORSTONE1000_CLUSTER_COUNT U(1)
+#define CORSTONE1000_MAX_CPUS_PER_CLUSTER U(4)
+#define CORSTONE1000_MAX_PE_PER_CPU U(1)
+#define CORSTONE1000_PRIMARY_CPU U(0)
-#define PLAT_ARM_CLUSTER_COUNT DIPHDA_CLUSTER_COUNT
+#define PLAT_ARM_CLUSTER_COUNT CORSTONE1000_CLUSTER_COUNT
#define PLATFORM_CORE_COUNT (PLAT_ARM_CLUSTER_COUNT * \
- DIPHDA_MAX_CPUS_PER_CLUSTER * \
- DIPHDA_MAX_PE_PER_CPU)
+ CORSTONE1000_MAX_CPUS_PER_CLUSTER * \
+ CORSTONE1000_MAX_PE_PER_CPU)
/* UART related constants */
#define PLAT_ARM_BOOT_UART_BASE 0x1a510000
@@ -85,7 +85,7 @@
*
* BL32 (optee-os)
*
- * <DIPHDA_TOS_FW_CONFIG_BASE> = 0x20ae000
+ * <CORSTONE1000_TOS_FW_CONFIG_BASE> = 0x20ae000
*
* partition size: 8 KB
*
@@ -132,7 +132,7 @@
#define ARM_DRAM1_END (ARM_DRAM1_BASE + \
ARM_DRAM1_SIZE - 1)
-/* DRAM1 and DRAM2 are the same for diphda */
+/* DRAM1 and DRAM2 are the same for corstone1000 */
#define ARM_DRAM2_BASE ARM_DRAM1_BASE
#define ARM_DRAM2_SIZE ARM_DRAM1_SIZE
#define ARM_DRAM2_END ARM_DRAM1_END
@@ -173,13 +173,13 @@
PLAT_ARM_MAX_BL31_SIZE)
#define BL31_LIMIT BL2_SIGNATURE_BASE
-#define DIPHDA_TOS_FW_CONFIG_BASE (BL31_BASE - \
- DIPHDA_TOS_FW_CONFIG_SIZE)
-#define DIPHDA_TOS_FW_CONFIG_SIZE UL(0x00002000) /* 8 KB */
-#define DIPHDA_TOS_FW_CONFIG_LIMIT BL31_BASE
+#define CORSTONE1000_TOS_FW_CONFIG_BASE (BL31_BASE - \
+ CORSTONE1000_TOS_FW_CONFIG_SIZE)
+#define CORSTONE1000_TOS_FW_CONFIG_SIZE UL(0x00002000) /* 8 KB */
+#define CORSTONE1000_TOS_FW_CONFIG_LIMIT BL31_BASE
#define BL32_BASE ARM_BL_RAM_BASE
-#define PLAT_ARM_MAX_BL32_SIZE (DIPHDA_TOS_FW_CONFIG_BASE - \
+#define PLAT_ARM_MAX_BL32_SIZE (CORSTONE1000_TOS_FW_CONFIG_BASE - \
BL32_BASE) /* 688 KB */
#define BL32_LIMIT (BL32_BASE + \
PLAT_ARM_MAX_BL32_SIZE)
@@ -220,7 +220,7 @@
/*
* Define FW_CONFIG area base and limit. Leave enough space for BL2 meminfo.
* FW_CONFIG is intended to host the device tree. Currently, This area is not
- * used because diphda platform doesn't use a device tree at TF-A level.
+ * used because corstone1000 platform doesn't use a device tree at TF-A level.
*/
#define ARM_FW_CONFIG_BASE (ARM_SHARED_RAM_BASE \
+ sizeof(meminfo_t))
@@ -261,8 +261,8 @@
#define SYS_COUNTER_FREQ_IN_TICKS UL(50000000) /* 50MHz */
-#define DIPHDA_IRQ_TZ_WDOG 32
-#define DIPHDA_IRQ_SEC_SYS_TIMER 34
+#define CORSTONE1000_IRQ_TZ_WDOG 32
+#define CORSTONE1000_IRQ_SEC_SYS_TIMER 34
#define PLAT_MAX_PWR_LVL 2
/*
@@ -308,7 +308,7 @@
#define PLATFORM_STACK_SIZE UL(0x440)
-#define DIPHDA_EXTERNAL_FLASH MAP_REGION_FLAT( \
+#define CORSTONE1000_EXTERNAL_FLASH MAP_REGION_FLAT( \
PLAT_ARM_NVM_BASE, \
PLAT_ARM_NVM_SIZE, \
MT_DEVICE | MT_RO | MT_SECURE)
@@ -356,11 +356,11 @@
ARM_FW_CONFIG_BASE), \
MT_MEMORY | MT_RW | MT_SECURE)
-#define DIPHDA_DEVICE_BASE (0x1A000000)
-#define DIPHDA_DEVICE_SIZE (0x26000000)
-#define DIPHDA_MAP_DEVICE MAP_REGION_FLAT( \
- DIPHDA_DEVICE_BASE, \
- DIPHDA_DEVICE_SIZE, \
+#define CORSTONE1000_DEVICE_BASE (0x1A000000)
+#define CORSTONE1000_DEVICE_SIZE (0x26000000)
+#define CORSTONE1000_MAP_DEVICE MAP_REGION_FLAT( \
+ CORSTONE1000_DEVICE_BASE, \
+ CORSTONE1000_DEVICE_SIZE, \
MT_DEVICE | MT_RW | MT_SECURE)
#define ARM_IRQ_SEC_PHY_TIMER 29
@@ -406,9 +406,9 @@
*/
#define PLAT_ARM_G1S_IRQ_PROPS(grp) \
ARM_G1S_IRQ_PROPS(grp), \
- INTR_PROP_DESC(DIPHDA_IRQ_TZ_WDOG, GIC_HIGHEST_SEC_PRIORITY, \
+ INTR_PROP_DESC(CORSTONE1000_IRQ_TZ_WDOG, GIC_HIGHEST_SEC_PRIORITY, \
(grp), GIC_INTR_CFG_LEVEL), \
- INTR_PROP_DESC(DIPHDA_IRQ_SEC_SYS_TIMER, \
+ INTR_PROP_DESC(CORSTONE1000_IRQ_SEC_SYS_TIMER, \
GIC_HIGHEST_SEC_PRIORITY, (grp), GIC_INTR_CFG_LEVEL)
#define PLAT_ARM_G0_IRQ_PROPS(grp) ARM_G0_IRQ_PROPS(grp)
diff --git a/plat/arm/board/diphda/include/plat_macros.S b/plat/arm/board/corstone1000/include/plat_macros.S
similarity index 100%
rename from plat/arm/board/diphda/include/plat_macros.S
rename to plat/arm/board/corstone1000/include/plat_macros.S
diff --git a/plat/arm/board/corstone1000/platform.mk b/plat/arm/board/corstone1000/platform.mk
new file mode 100644
index 0000000000..93e2ea0826
--- /dev/null
+++ b/plat/arm/board/corstone1000/platform.mk
@@ -0,0 +1,83 @@
+#
+# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+# Making sure the corstone1000 platform type is specified
+ifeq ($(filter ${TARGET_PLATFORM}, fpga fvp),)
+ $(error TARGET_PLATFORM must be fpga or fvp)
+endif
+
+CORSTONE1000_CPU_LIBS +=lib/cpus/aarch64/cortex_a35.S
+
+PLAT_INCLUDES := -Iplat/arm/board/corstone1000/common/include \
+ -Iplat/arm/board/corstone1000/include \
+ -Iinclude/plat/arm/common \
+ -Iinclude/plat/arm/css/common/aarch64
+
+
+CORSTONE1000_FW_NVCTR_VAL := 255
+TFW_NVCTR_VAL := ${CORSTONE1000_FW_NVCTR_VAL}
+NTFW_NVCTR_VAL := ${CORSTONE1000_FW_NVCTR_VAL}
+
+override NEED_BL1 := no
+
+override NEED_BL2 := yes
+FIP_BL2_ARGS := tb-fw
+
+override NEED_BL2U := no
+override NEED_BL31 := yes
+NEED_BL32 := yes
+override NEED_BL33 := yes
+
+# Include GICv2 driver files
+include drivers/arm/gic/v2/gicv2.mk
+
+CORSTONE1000_GIC_SOURCES := ${GICV2_SOURCES} \
+ plat/common/plat_gicv2.c \
+ plat/arm/common/arm_gicv2.c
+
+
+BL2_SOURCES += plat/arm/board/corstone1000/common/corstone1000_security.c \
+ plat/arm/board/corstone1000/common/corstone1000_err.c \
+ plat/arm/board/corstone1000/common/corstone1000_trusted_boot.c \
+ lib/utils/mem_region.c \
+ plat/arm/board/corstone1000/common/corstone1000_helpers.S \
+ plat/arm/board/corstone1000/common/corstone1000_plat.c \
+ plat/arm/board/corstone1000/common/corstone1000_bl2_mem_params_desc.c \
+ ${CORSTONE1000_CPU_LIBS} \
+
+
+BL31_SOURCES += drivers/cfi/v2m/v2m_flash.c \
+ lib/utils/mem_region.c \
+ plat/arm/board/corstone1000/common/corstone1000_helpers.S \
+ plat/arm/board/corstone1000/common/corstone1000_topology.c \
+ plat/arm/board/corstone1000/common/corstone1000_security.c \
+ plat/arm/board/corstone1000/common/corstone1000_plat.c \
+ plat/arm/board/corstone1000/common/corstone1000_pm.c \
+ ${CORSTONE1000_CPU_LIBS} \
+ ${CORSTONE1000_GIC_SOURCES}
+
+ifneq (${ENABLE_STACK_PROTECTOR},0)
+ ifneq (${ENABLE_STACK_PROTECTOR},none)
+ CORSTONE1000_SECURITY_SOURCES := plat/arm/board/corstone1000/common/corstone1000_stack_protector.c
+ BL2_SOURCES += ${CORSTONE1000_SECURITY_SOURCES}
+ BL31_SOURCES += ${CORSTONE1000_SECURITY_SOURCES}
+ endif
+endif
+
+FDT_SOURCES += plat/arm/board/corstone1000/common/fdts/corstone1000_spmc_manifest.dts
+CORSTONE1000_TOS_FW_CONFIG := ${BUILD_PLAT}/fdts/corstone1000_spmc_manifest.dtb
+
+# Add the SPMC manifest to FIP and specify the same to certtool
+$(eval $(call TOOL_ADD_PAYLOAD,${CORSTONE1000_TOS_FW_CONFIG},--tos-fw-config,${CORSTONE1000_TOS_FW_CONFIG}))
+
+# Adding TARGET_PLATFORM as a GCC define (-D option)
+$(eval $(call add_define,TARGET_PLATFORM_$(call uppercase,${TARGET_PLATFORM})))
+
+# Adding CORSTONE1000_FW_NVCTR_VAL as a GCC define (-D option)
+$(eval $(call add_define,CORSTONE1000_FW_NVCTR_VAL))
+
+include plat/arm/common/arm_common.mk
+include plat/arm/board/common/board_common.mk
diff --git a/plat/arm/board/diphda/platform.mk b/plat/arm/board/diphda/platform.mk
deleted file mode 100644
index 8b89cee7ed..0000000000
--- a/plat/arm/board/diphda/platform.mk
+++ /dev/null
@@ -1,83 +0,0 @@
-#
-# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-
-# Making sure the diphda platform type is specified
-ifeq ($(filter ${TARGET_PLATFORM}, fpga fvp),)
- $(error TARGET_PLATFORM must be fpga or fvp)
-endif
-
-DIPHDA_CPU_LIBS +=lib/cpus/aarch64/cortex_a35.S
-
-PLAT_INCLUDES := -Iplat/arm/board/diphda/common/include \
- -Iplat/arm/board/diphda/include \
- -Iinclude/plat/arm/common \
- -Iinclude/plat/arm/css/common/aarch64
-
-
-DIPHDA_FW_NVCTR_VAL := 255
-TFW_NVCTR_VAL := ${DIPHDA_FW_NVCTR_VAL}
-NTFW_NVCTR_VAL := ${DIPHDA_FW_NVCTR_VAL}
-
-override NEED_BL1 := no
-
-override NEED_BL2 := yes
-FIP_BL2_ARGS := tb-fw
-
-override NEED_BL2U := no
-override NEED_BL31 := yes
-NEED_BL32 := yes
-override NEED_BL33 := yes
-
-# Include GICv2 driver files
-include drivers/arm/gic/v2/gicv2.mk
-
-DIPHDA_GIC_SOURCES := ${GICV2_SOURCES} \
- plat/common/plat_gicv2.c \
- plat/arm/common/arm_gicv2.c
-
-
-BL2_SOURCES += plat/arm/board/diphda/common/diphda_security.c \
- plat/arm/board/diphda/common/diphda_err.c \
- plat/arm/board/diphda/common/diphda_trusted_boot.c \
- lib/utils/mem_region.c \
- plat/arm/board/diphda/common/diphda_helpers.S \
- plat/arm/board/diphda/common/diphda_plat.c \
- plat/arm/board/diphda/common/diphda_bl2_mem_params_desc.c \
- ${DIPHDA_CPU_LIBS} \
-
-
-BL31_SOURCES += drivers/cfi/v2m/v2m_flash.c \
- lib/utils/mem_region.c \
- plat/arm/board/diphda/common/diphda_helpers.S \
- plat/arm/board/diphda/common/diphda_topology.c \
- plat/arm/board/diphda/common/diphda_security.c \
- plat/arm/board/diphda/common/diphda_plat.c \
- plat/arm/board/diphda/common/diphda_pm.c \
- ${DIPHDA_CPU_LIBS} \
- ${DIPHDA_GIC_SOURCES}
-
-ifneq (${ENABLE_STACK_PROTECTOR},0)
- ifneq (${ENABLE_STACK_PROTECTOR},none)
- DIPHDA_SECURITY_SOURCES := plat/arm/board/diphda/common/diphda_stack_protector.c
- BL2_SOURCES += ${DIPHDA_SECURITY_SOURCES}
- BL31_SOURCES += ${DIPHDA_SECURITY_SOURCES}
- endif
-endif
-
-FDT_SOURCES += plat/arm/board/diphda/common/fdts/diphda_spmc_manifest.dts
-DIPHDA_TOS_FW_CONFIG := ${BUILD_PLAT}/fdts/diphda_spmc_manifest.dtb
-
-# Add the SPMC manifest to FIP and specify the same to certtool
-$(eval $(call TOOL_ADD_PAYLOAD,${DIPHDA_TOS_FW_CONFIG},--tos-fw-config,${DIPHDA_TOS_FW_CONFIG}))
-
-# Adding TARGET_PLATFORM as a GCC define (-D option)
-$(eval $(call add_define,TARGET_PLATFORM_$(call uppercase,${TARGET_PLATFORM})))
-
-# Adding DIPHDA_FW_NVCTR_VAL as a GCC define (-D option)
-$(eval $(call add_define,DIPHDA_FW_NVCTR_VAL))
-
-include plat/arm/common/arm_common.mk
-include plat/arm/board/common/board_common.mk
--
2.33.0
@@ -0,0 +1,201 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Arpita S.K <arpita.s.k@arm.com>
From bf95f27e300e962140a5dec45c2b1727c0829511 Mon Sep 17 00:00:00 2001
From: "Arpita S.K" <Arpita.S.K@arm.com>
Date: Wed, 13 Oct 2021 14:49:26 +0530
Subject: [PATCH] plat/arm: corstone1000: made changes to accommodate 3MB for
optee
* These changes are required to accommodate 3MB for OP-TEE and this
is required for SP's part of optee
* Added size macro's for better readability of the code
* Moved uboot execution memory from CVM to DDR
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
---
include/plat/common/common_def.h | 25 ++++++++
.../common/corstone1000_bl2_mem_params_desc.c | 7 +--
.../common/include/platform_def.h | 59 +++++++++++--------
3 files changed, 64 insertions(+), 27 deletions(-)
diff --git a/include/plat/common/common_def.h b/include/plat/common/common_def.h
index 14ae603b9b..5bb58692ef 100644
--- a/include/plat/common/common_def.h
+++ b/include/plat/common/common_def.h
@@ -12,6 +12,31 @@
#include <lib/utils_def.h>
#include <lib/xlat_tables/xlat_tables_defs.h>
+#define SZ_1K 0x00000400
+#define SZ_2K 0x00000800
+#define SZ_4K 0x00001000
+#define SZ_8K 0x00002000
+#define SZ_16K 0x00004000
+#define SZ_32K 0x00008000
+#define SZ_64K 0x00010000
+#define SZ_128K 0x00020000
+#define SZ_256K 0x00040000
+#define SZ_512K 0x00080000
+
+#define SZ_1M 0x00100000
+#define SZ_2M 0x00200000
+#define SZ_4M 0x00400000
+#define SZ_8M 0x00800000
+#define SZ_16M 0x01000000
+#define SZ_32M 0x02000000
+#define SZ_64M 0x04000000
+#define SZ_128M 0x08000000
+#define SZ_256M 0x10000000
+#define SZ_512M 0x20000000
+
+#define SZ_1G 0x40000000
+#define SZ_2G 0x80000000
+
/******************************************************************************
* Required platform porting definitions that are expected to be common to
* all platforms
diff --git a/plat/arm/board/corstone1000/common/corstone1000_bl2_mem_params_desc.c b/plat/arm/board/corstone1000/common/corstone1000_bl2_mem_params_desc.c
index 7baa82d31b..6e90936a14 100644
--- a/plat/arm/board/corstone1000/common/corstone1000_bl2_mem_params_desc.c
+++ b/plat/arm/board/corstone1000/common/corstone1000_bl2_mem_params_desc.c
@@ -71,13 +71,12 @@ static bl_mem_params_node_t bl2_mem_params_descs[] = {
.image_id = BL33_IMAGE_ID,
SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
VERSION_2, entry_point_info_t, NON_SECURE | EXECUTABLE),
- .ep_info.pc = PLAT_ARM_NS_IMAGE_BASE,
+ .ep_info.pc = BL33_BASE,
SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
VERSION_2, image_info_t, 0),
- .image_info.image_base = PLAT_ARM_NS_IMAGE_BASE,
- .image_info.image_max_size = ARM_DRAM1_BASE + ARM_DRAM1_SIZE
- - PLAT_ARM_NS_IMAGE_BASE,
+ .image_info.image_base = BL33_BASE,
+ .image_info.image_max_size = BL33_LIMIT - BL33_BASE,
.next_handoff_image_id = INVALID_IMAGE_ID,
},
diff --git a/plat/arm/board/corstone1000/common/include/platform_def.h b/plat/arm/board/corstone1000/common/include/platform_def.h
index e36bb626ee..a0ac0fe758 100644
--- a/plat/arm/board/corstone1000/common/include/platform_def.h
+++ b/plat/arm/board/corstone1000/common/include/platform_def.h
@@ -119,7 +119,7 @@
*
* <ARM_NS_SHARED_RAM_BASE> = <ARM_TRUSTED_SRAM_BASE> + 1 MB
*
- * partition size: 3 MB
+ * partition size: 512 KB
*
* content:
*
@@ -128,13 +128,13 @@
/* DDR memory */
#define ARM_DRAM1_BASE UL(0x80000000)
-#define ARM_DRAM1_SIZE UL(0x80000000)
+#define ARM_DRAM1_SIZE (SZ_2G) /* 2GB*/
#define ARM_DRAM1_END (ARM_DRAM1_BASE + \
ARM_DRAM1_SIZE - 1)
/* DRAM1 and DRAM2 are the same for corstone1000 */
-#define ARM_DRAM2_BASE ARM_DRAM1_BASE
-#define ARM_DRAM2_SIZE ARM_DRAM1_SIZE
+#define ARM_DRAM2_BASE ARM_DRAM1_BASE
+#define ARM_DRAM2_SIZE ARM_DRAM1_SIZE
#define ARM_DRAM2_END ARM_DRAM1_END
#define ARM_NS_DRAM1_BASE ARM_DRAM1_BASE
@@ -144,23 +144,31 @@
/* The first 8 KB of Trusted SRAM are used as shared memory */
#define ARM_TRUSTED_SRAM_BASE UL(0x02000000)
-#define ARM_SHARED_RAM_SIZE UL(0x00002000) /* 8 KB */
+#define ARM_SHARED_RAM_SIZE (SZ_8K) /* 8 KB */
#define ARM_SHARED_RAM_BASE ARM_TRUSTED_SRAM_BASE
/* The remaining Trusted SRAM is used to load the BL images */
+#define TOTAL_SRAM_SIZE (SZ_4M) /* 4 MB */
-#define PLAT_ARM_TRUSTED_SRAM_SIZE UL(0x00100000) /* 1 MB */
+/* Last 512KB of CVM is allocated for shared RAM
+ * as an example openAMP */
+#define ARM_NS_SHARED_RAM_SIZE (512 * SZ_1K)
-#define PLAT_ARM_MAX_BL2_SIZE UL(0x0002d000) /* 180 KB */
+#define PLAT_ARM_TRUSTED_SRAM_SIZE (TOTAL_SRAM_SIZE - \
+ ARM_NS_SHARED_RAM_SIZE - \
+ ARM_SHARED_RAM_SIZE)
-#define PLAT_ARM_MAX_BL31_SIZE UL(0x00023000) /* 140 KB */
+#define PLAT_ARM_MAX_BL2_SIZE (180 * SZ_1K) /* 180 KB */
-#define ARM_BL_RAM_BASE (ARM_SHARED_RAM_BASE + \
- ARM_SHARED_RAM_SIZE)
-#define ARM_BL_RAM_SIZE (PLAT_ARM_TRUSTED_SRAM_SIZE - \
- ARM_SHARED_RAM_SIZE)
+#define PLAT_ARM_MAX_BL31_SIZE (140 * SZ_1K) /* 140 KB */
+
+#define ARM_BL_RAM_BASE (ARM_SHARED_RAM_BASE + \
+ ARM_SHARED_RAM_SIZE)
+#define ARM_BL_RAM_SIZE (PLAT_ARM_TRUSTED_SRAM_SIZE - \
+ ARM_SHARED_RAM_SIZE)
+
+#define BL2_SIGNATURE_SIZE (SZ_4K) /* 4 KB */
-#define BL2_SIGNATURE_SIZE UL(0x00001000) /* 4 KB */
#define BL2_SIGNATURE_BASE (BL2_LIMIT - \
PLAT_ARM_MAX_BL2_SIZE)
#define BL2_BASE (BL2_LIMIT - \
@@ -175,14 +183,15 @@
#define CORSTONE1000_TOS_FW_CONFIG_BASE (BL31_BASE - \
CORSTONE1000_TOS_FW_CONFIG_SIZE)
-#define CORSTONE1000_TOS_FW_CONFIG_SIZE UL(0x00002000) /* 8 KB */
+#define CORSTONE1000_TOS_FW_CONFIG_SIZE (SZ_8K) /* 8 KB */
#define CORSTONE1000_TOS_FW_CONFIG_LIMIT BL31_BASE
#define BL32_BASE ARM_BL_RAM_BASE
-#define PLAT_ARM_MAX_BL32_SIZE (CORSTONE1000_TOS_FW_CONFIG_BASE - \
- BL32_BASE) /* 688 KB */
-#define BL32_LIMIT (BL32_BASE + \
- PLAT_ARM_MAX_BL32_SIZE)
+#define PLAT_ARM_MAX_BL32_SIZE (CORSTONE1000_TOS_FW_CONFIG_BASE - \
+ BL32_BASE)
+
+#define BL32_LIMIT (BL32_BASE + \
+ PLAT_ARM_MAX_BL32_SIZE)
/* SPD_spmd settings */
@@ -191,10 +200,14 @@
/* NS memory */
-/* The last 3 MB of the SRAM is allocated to the non secure area */
-#define ARM_NS_SHARED_RAM_BASE (ARM_TRUSTED_SRAM_BASE + \
- PLAT_ARM_TRUSTED_SRAM_SIZE)
-#define ARM_NS_SHARED_RAM_SIZE UL(0x00300000) /* 3 MB */
+/* The last 512KB of the SRAM is allocated as shared memory */
+#define ARM_NS_SHARED_RAM_BASE (ARM_TRUSTED_SRAM_BASE + TOTAL_SRAM_SIZE - \
+ (PLAT_ARM_MAX_BL31_SIZE + \
+ PLAT_ARM_MAX_BL32_SIZE))
+
+#define BL33_BASE ARM_DRAM1_BASE
+#define PLAT_ARM_MAX_BL33_SIZE (12 * SZ_1M) /* 12 MB*/
+#define BL33_LIMIT (ARM_DRAM1_BASE + PLAT_ARM_MAX_BL33_SIZE)
/* end of the definition of SRAM memory layout */
@@ -204,7 +217,7 @@
#define PLAT_ARM_FIP_MAX_SIZE UL(0x1ff000) /* 1.996 MB */
#define PLAT_ARM_NVM_BASE V2M_FLASH0_BASE
-#define PLAT_ARM_NVM_SIZE UL(0x02000000) /* 32 MB */
+#define PLAT_ARM_NVM_SIZE (SZ_32M) /* 32 MB */
#define PLAT_ARM_FLASH_IMAGE_BASE PLAT_ARM_FIP_BASE
#define PLAT_ARM_FLASH_IMAGE_MAX_SIZE PLAT_ARM_FIP_MAX_SIZE
--
2.33.0
@@ -0,0 +1,60 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Emekcan Aras <Emekcan.Aras@arm.com>
From 1b99c6dd614002a79e4dda96d630089775a1d233 Mon Sep 17 00:00:00 2001
From: Emekcan Aras <Emekcan.Aras@arm.com>
Date: Wed, 17 Nov 2021 18:45:32 +0000
Subject: [PATCH] corstone1000: implement platform specific psci reset
This implements platform specific psci reset for the corstone1000.
Signed-off-by: Emekcan Aras <Emekcan.Aras@arm.com>
---
.../corstone1000/common/corstone1000_pm.c | 23 +++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/plat/arm/board/corstone1000/common/corstone1000_pm.c b/plat/arm/board/corstone1000/common/corstone1000_pm.c
index 12b322e27..e95ab30b7 100644
--- a/plat/arm/board/corstone1000/common/corstone1000_pm.c
+++ b/plat/arm/board/corstone1000/common/corstone1000_pm.c
@@ -6,17 +6,36 @@
#include <lib/psci/psci.h>
#include <plat/arm/common/plat_arm.h>
-
/*******************************************************************************
* Export the platform handlers via plat_arm_psci_pm_ops. The ARM Standard
* platform layer will take care of registering the handlers with PSCI.
******************************************************************************/
+
+#define SECURE_WATCHDOG_ADDR_CTRL_REG 0x1A320000
+#define SECURE_WATCHDOG_ADDR_VAL_REG 0x1A320008
+#define SECURE_WATCHDOG_MASK_ENABLE 0x01
+#define SECURE_WATCHDOG_COUNTDOWN_VAL 0x1000
+
+static void __dead2 corstone1000_system_reset(void)
+{
+
+ uint32_t volatile * const watchdog_ctrl_reg = (int *) SECURE_WATCHDOG_ADDR_CTRL_REG;
+ uint32_t volatile * const watchdog_val_reg = (int *) SECURE_WATCHDOG_ADDR_VAL_REG;
+
+ *(watchdog_val_reg) = SECURE_WATCHDOG_COUNTDOWN_VAL;
+ *watchdog_ctrl_reg = SECURE_WATCHDOG_MASK_ENABLE;
+ while (1){
+ wfi();
+ }
+}
+
plat_psci_ops_t plat_arm_psci_pm_ops = {
- /* dummy struct */
+ .system_reset = corstone1000_system_reset,
.validate_ns_entrypoint = NULL
};
const plat_psci_ops_t *plat_arm_psci_override_pm_ops(plat_psci_ops_t *ops)
{
+ ops = &plat_arm_psci_pm_ops;
return ops;
}
--
2.25.1
@@ -0,0 +1,33 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
From 5541d466ebf46f0a14fae3effbcc46bcc2dd8efc Mon Sep 17 00:00:00 2001
From: Satish Kumar <satish.kumar01@arm.com>
Date: Mon, 20 Sep 2021 06:01:54 +0100
Subject: [PATCH 1/1] plat/arm: corstone1000: change base address of FIP in the flash
More space in the flash is reserved up front for metadata
parser and UEFI variables. That requires change in the flash
base address of where images are present.
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
---
plat/arm/board/corstone1000/common/include/platform_def.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plat/arm/board/corstone1000/common/include/platform_def.h b/plat/arm/board/corstone1000/common/include/platform_def.h
index 97d7b2974..079b1c9d4 100644
--- a/plat/arm/board/corstone1000/common/include/platform_def.h
+++ b/plat/arm/board/corstone1000/common/include/platform_def.h
@@ -208,7 +208,7 @@
/* NOR Flash */
-#define PLAT_ARM_FIP_BASE UL(0x08131000)
+#define PLAT_ARM_FIP_BASE UL(0x081EF000)
#define PLAT_ARM_FIP_MAX_SIZE UL(0x1ff000) /* 1.996 MB */
#define PLAT_ARM_NVM_BASE V2M_FLASH0_BASE
--
2.17.1
@@ -0,0 +1,102 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
From 03218b5bb3ef32298624a54d1b3b3cf3c8c5d800 Mon Sep 17 00:00:00 2001
From: Satish Kumar <satish.kumar01@arm.com>
Date: Wed, 27 Oct 2021 16:31:04 +0100
Subject: [PATCH 1/1] plat/arm: corstone1000: identify which bank to load fip
from
Secure enclave decide the boot bank based on the firmware update
state of the system and updated the boot bank information at a given
location in the flash. In this commit, bl2 reads the givev flash location
to indentify the bank from which it should load fip from.
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
---
.../corstone1000/common/corstone1000_plat.c | 39 +++++++++++++++++++
.../common/include/platform_def.h | 6 ++-
2 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/plat/arm/board/corstone1000/common/corstone1000_plat.c b/plat/arm/board/corstone1000/common/corstone1000_plat.c
index 7a38b0b2e..4351d5e9d 100644
--- a/plat/arm/board/corstone1000/common/corstone1000_plat.c
+++ b/plat/arm/board/corstone1000/common/corstone1000_plat.c
@@ -11,6 +11,10 @@
#include <plat/arm/common/plat_arm.h>
#include <plat/common/platform.h>
#include <platform_def.h>
+#include <drivers/generic_delay_timer.h>
+#include <plat/arm/common/arm_fconf_getter.h>
+#include <plat/arm/common/arm_fconf_io_storage.h>
+#include <drivers/io/io_storage.h>
/*
* Table of regions to map using the MMU.
@@ -26,6 +30,41 @@ const mmap_region_t plat_arm_mmap[] = {
{0}
};
+void identify_fip_start_address(void)
+{
+ const struct plat_io_policy *policy;
+ volatile uint32_t *boot_bank_flag = (uint32_t*)(PLAT_ARM_BOOT_BANK_FLAG);
+
+ VERBOSE("Boot bank flag = %u.\n\r", *boot_bank_flag);
+
+ policy = FCONF_GET_PROPERTY(arm, io_policies, FIP_IMAGE_ID);
+
+ assert(policy != NULL);
+ assert(policy->image_spec != 0UL);
+
+ io_block_spec_t *spec = (io_block_spec_t *)policy->image_spec;
+
+ if ((*boot_bank_flag) == 0) {
+ VERBOSE("Booting from bank 0: fip offset = 0x%lx\n\r",
+ PLAT_ARM_FIP_BASE_BANK0);
+ spec->offset = PLAT_ARM_FIP_BASE_BANK0;
+ } else {
+ VERBOSE("Booting from bank 1: fip offset = 0x%lx\n\r",
+ PLAT_ARM_FIP_BASE_BANK1);
+ spec->offset = PLAT_ARM_FIP_BASE_BANK1;
+ }
+}
+
+void bl2_platform_setup(void)
+{
+ arm_bl2_platform_setup();
+ /*
+ * Identify the start address of the FIP by reading the boot
+ * index flag from the flash.
+ */
+ identify_fip_start_address();
+}
+
/* corstone1000 only has one always-on power domain and there
* is no power control present
*/
diff --git a/plat/arm/board/corstone1000/common/include/platform_def.h b/plat/arm/board/corstone1000/common/include/platform_def.h
index edc90fa72..868e41388 100644
--- a/plat/arm/board/corstone1000/common/include/platform_def.h
+++ b/plat/arm/board/corstone1000/common/include/platform_def.h
@@ -213,13 +213,15 @@
/* NOR Flash */
-#define PLAT_ARM_FIP_BASE UL(0x081EF000)
+#define PLAT_ARM_BOOT_BANK_FLAG UL(0x08002000)
+#define PLAT_ARM_FIP_BASE_BANK0 UL(0x081EF000)
+#define PLAT_ARM_FIP_BASE_BANK1 UL(0x0916F000)
#define PLAT_ARM_FIP_MAX_SIZE UL(0x1ff000) /* 1.996 MB */
#define PLAT_ARM_NVM_BASE V2M_FLASH0_BASE
#define PLAT_ARM_NVM_SIZE (SZ_32M) /* 32 MB */
-#define PLAT_ARM_FLASH_IMAGE_BASE PLAT_ARM_FIP_BASE
+#define PLAT_ARM_FLASH_IMAGE_BASE PLAT_ARM_FIP_BASE_BANK0
#define PLAT_ARM_FLASH_IMAGE_MAX_SIZE PLAT_ARM_FIP_MAX_SIZE
/*
--
2.17.1
@@ -0,0 +1,53 @@
# Corstone1000 64-bit machines specific TFA support
COMPATIBLE_MACHINE = "(corstone1000)"
SRC_URI = "git://git.trustedfirmware.org/TF-A/trusted-firmware-a.git;protocol=https;name=tfa"
# TF-A master branch with all Corstone1000 patches merged
SRCREV_tfa = "459b24451a0829460783ce8dfa15561e36d901d8"
PV .= "+git${SRCREV_tfa}"
LIC_FILES_CHKSUM="file://docs/license.rst;md5=b2c740efedc159745b9b31f88ff03dde file://mbedtls/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"
FILESEXTRAPATHS:prepend := "${THISDIR}/files/corstone1000:"
SRC_URI:append = " \
file://0001-Rename-Diphda-to-corstone1000.patch \
file://0002-plat-arm-corstone1000-made-changes-to-accommodate-3M.patch \
file://0003-corstone1000-implement-platform-specific-psci-reset.patch \
file://0004-plat-arm-corstone1000-change-base-address-of-FIP-in-the-fl.patch \
file://0005-plat-arm-corstone1000-identify-which-bank-to-load-fip-from.patch \
"
TFA_DEBUG = "1"
TFA_UBOOT = "1"
TFA_MBEDTLS = "1"
TFA_BUILD_TARGET = "bl2 bl31 fip"
# Enabling Secure-EL1 Payload Dispatcher (SPD)
TFA_SPD = "spmd"
# Cortex-A35 supports Armv8.0-A (no S-EL2 execution state).
# So, the SPD SPMC component should run at the S-EL1 execution state
TFA_SPMD_SPM_AT_SEL2 = "0"
# BL2 loads BL32 (optee). So, optee needs to be built first:
DEPENDS += "optee-os"
EXTRA_OEMAKE:append = " \
ARCH=aarch64 \
TARGET_PLATFORM=${TFA_TARGET_PLATFORM} \
ENABLE_STACK_PROTECTOR=strong \
ENABLE_PIE=1 \
BL2_AT_EL3=1 \
CREATE_KEYS=1 \
GENERATE_COT=1 \
TRUSTED_BOARD_BOOT=1 \
COT=tbbr \
ARM_ROTPK_LOCATION=devel_rsa \
ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem \
BL32=${RECIPE_SYSROOT}/lib/firmware/tee-pager_v2.bin \
LOG_LEVEL=50 \
"
# trigger TF-M build so TF-A binaries get signed
do_deploy[depends]+= "virtual/trusted-firmware-m:do_prepare_recipe_sysroot"
@@ -3,6 +3,7 @@
MACHINE_TFA_REQUIRE ?= ""
MACHINE_TFA_REQUIRE:corstone500 = "trusted-firmware-a-corstone500.inc"
MACHINE_TFA_REQUIRE:corstone700 = "trusted-firmware-a-corstone700.inc"
MACHINE_TFA_REQUIRE:corstone1000 = "trusted-firmware-a-corstone1000.inc"
MACHINE_TFA_REQUIRE:fvp-base = "trusted-firmware-a-fvp.inc"
MACHINE_TFA_REQUIRE:fvp-base-arm32 = "trusted-firmware-a-fvp-arm32.inc"
MACHINE_TFA_REQUIRE:juno = "trusted-firmware-a-juno.inc"
@@ -0,0 +1,33 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
From beb8a8d92537b9574717f0a9a914642c15b439b1 Mon Sep 17 00:00:00 2001
From: Satish Kumar <satish.kumar01@arm.com>
Date: Wed, 29 Sep 2021 04:58:59 +0100
Subject: [PATCH 01/15] corstone1000: disable secure debug temporarily
Until ARM-DS is ready to use psa-adac secure debug protocol,
disable the secure debug in the platform. At present, the
secure debug integration is tested with the PyOCD based
scripts.
Change-Id: I3dd0f20e5714a2db69425607d9404172ce52129e
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
---
platform/ext/target/arm/corstone1000/config.cmake | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/platform/ext/target/arm/corstone1000/config.cmake b/platform/ext/target/arm/corstone1000/config.cmake
index dc12d27f9c..203e6b79a6 100644
--- a/platform/ext/target/arm/corstone1000/config.cmake
+++ b/platform/ext/target/arm/corstone1000/config.cmake
@@ -37,5 +37,5 @@ set(OPENAMP_VERSION "33037b04e0732e58fc0fa36afc244999ef632e1
if (${PLATFORM_IS_FVP})
set(PLATFORM_PSA_ADAC_SECURE_DEBUG FALSE CACHE BOOL "Whether to use psa-adac secure debug.")
else()
- set(PLATFORM_PSA_ADAC_SECURE_DEBUG TRUE CACHE BOOL "Whether to use psa-adac secure debug.")
+ set(PLATFORM_PSA_ADAC_SECURE_DEBUG FALSE CACHE BOOL "Whether to use psa-adac secure debug.")
endif()
--
2.17.1
@@ -0,0 +1,470 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
From 8e2b5cee153763dd35bba1bff3568e2e3c6f58d3 Mon Sep 17 00:00:00 2001
From: Satish Kumar <satish.kumar01@arm.com>
Date: Fri, 1 Oct 2021 14:20:55 +0100
Subject: [PATCH 02/15] corstone1000: provision firmware update metadata (fwu)
Firmware update metadata region in the flash is provisioned.
The metadata is provisioned assuming images are present in
bank-0.
Change-Id: I2a2274505d80528a3a0cc9211c1c6263415015d8
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
---
.../arm/corstone1000/bl1/CMakeLists.txt | 2 +
.../arm/corstone1000/bl1/bl1_boot_hal.c | 18 +
.../corstone1000/fw_update_agent/fwu_agent.c | 309 ++++++++++++++++++
.../corstone1000/fw_update_agent/fwu_agent.h | 31 ++
.../arm/corstone1000/partition/flash_layout.h | 11 +-
5 files changed, 369 insertions(+), 2 deletions(-)
create mode 100644 platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
create mode 100644 platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h
diff --git a/platform/ext/target/arm/corstone1000/bl1/CMakeLists.txt b/platform/ext/target/arm/corstone1000/bl1/CMakeLists.txt
index 0634fed4b8..92a78c1168 100644
--- a/platform/ext/target/arm/corstone1000/bl1/CMakeLists.txt
+++ b/platform/ext/target/arm/corstone1000/bl1/CMakeLists.txt
@@ -238,6 +238,7 @@ target_sources(bl1_main
../Device/Source/system_core_init.c
../Native_Driver/firewall.c
../Native_Driver/uart_pl011_drv.c
+ ../fw_update_agent/fwu_agent.c
bl1_boot_hal.c
bl1_flash_map.c
bl1_security_cnt.c
@@ -267,6 +268,7 @@ target_include_directories(bl1_main
../CMSIS_Driver/Config
../Device/Config
../Native_Driver
+ ../fw_update_agent
)
############################### SIGNING BL2 image ##################################
diff --git a/platform/ext/target/arm/corstone1000/bl1/bl1_boot_hal.c b/platform/ext/target/arm/corstone1000/bl1/bl1_boot_hal.c
index 3d1e3e72fc..5e5e5c9e68 100644
--- a/platform/ext/target/arm/corstone1000/bl1/bl1_boot_hal.c
+++ b/platform/ext/target/arm/corstone1000/bl1/bl1_boot_hal.c
@@ -12,8 +12,12 @@
#include "Driver_Flash.h"
#include "flash_layout.h"
#include "bootutil/fault_injection_hardening.h"
+#include "bootutil/bootutil_log.h"
#include "firewall.h"
#include "mpu_config.h"
+#include "tfm_plat_otp.h"
+#include "tfm_plat_provisioning.h"
+#include "fwu_agent.h"
#if defined(CRYPTO_HW_ACCELERATOR) || \
defined(CRYPTO_HW_ACCELERATOR_OTP_PROVISIONING)
@@ -595,6 +599,20 @@ int32_t boot_platform_init(void)
}
#endif /* CRYPTO_HW_ACCELERATOR */
+ result = tfm_plat_otp_init();
+ if (result != TFM_PLAT_ERR_SUCCESS) {
+ BOOT_LOG_ERR("OTP system initialization failed");
+ FIH_PANIC;
+ }
+
+ if (tfm_plat_provisioning_is_required()) {
+ result = fwu_metadata_provision();
+ if (result != FWU_AGENT_SUCCESS) {
+ BOOT_LOG_ERR("Provisioning FWU Metadata failed");
+ FIH_PANIC;
+ }
+ }
+
return 0;
}
diff --git a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
new file mode 100644
index 0000000000..b9c507e4ef
--- /dev/null
+++ b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
@@ -0,0 +1,309 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include <stdint.h>
+#include <string.h>
+#include "fwu_agent.h"
+#include "Driver_Flash.h"
+#include "flash_layout.h"
+#include "fip_parser/external/uuid.h"
+
+/* Properties of image in a bank */
+struct fwu_image_properties {
+
+ /* UUID of the image in this bank */
+ uuid_t img_uuid;
+
+ /* [0]: bit describing the image acceptance status
+ * 1 means the image is accepted
+ * [31:1]: MBZ
+ */
+ uint32_t accepted;
+
+ /* NOTE: using the reserved field */
+ /* image version */
+ uint32_t version;
+
+} __packed;
+
+/* Image entry information */
+struct fwu_image_entry {
+
+ /* UUID identifying the image type */
+ uuid_t img_type_uuid;
+
+ /* UUID of the storage volume where the image is located */
+ uuid_t location_uuid;
+
+ /* Properties of images with img_type_uuid in the different FW banks */
+ struct fwu_image_properties img_props[NR_OF_FW_BANKS];
+
+} __packed;
+
+struct fwu_metadata {
+
+ /* Metadata CRC value */
+ uint32_t crc_32;
+
+ /* Metadata version */
+ uint32_t version;
+
+ /* Bank index with which device boots */
+ uint32_t active_index;
+
+ /* Previous bank index with which device booted successfully */
+ uint32_t previous_active_index;
+
+ /* Image entry information */
+ struct fwu_image_entry img_entry[NR_OF_IMAGES_IN_FW_BANK];
+
+} __packed;
+
+/* This is Corstone1000 speific metadata for OTA.
+ * Private metadata is written at next sector following
+ * FWU METADATA location */
+struct fwu_private_metadata {
+
+ /* boot_index: the bank from which system is booted from */
+ uint32_t boot_index;
+
+} __packed;
+
+struct fwu_metadata _metadata;
+int is_initialized = 0;
+
+#define IMAGE_ACCEPTED (1)
+#define IMAGE_NOT_ACCEPTED (0)
+#define BANK_0 (0)
+#define BANK_1 (1)
+#define IMAGE_0 (0)
+#define IMAGE_1 (1)
+#define IMAGE_2 (2)
+#define IMAGE_3 (3)
+#define INVALID_VERSION (0xffffffff)
+
+#ifndef FWU_METADATA_FLASH_DEV
+ #ifndef FLASH_DEV_NAME
+ #error "FWU_METADATA_FLASH_DEV or FLASH_DEV_NAME must be defined in flash_layout.h"
+ #else
+ #define FWU_METADATA_FLASH_DEV FLASH_DEV_NAME
+ #endif
+#endif
+
+/* Import the CMSIS flash device driver */
+extern ARM_DRIVER_FLASH FWU_METADATA_FLASH_DEV;
+
+static enum fwu_agent_error_t private_metadata_read(
+ struct fwu_private_metadata* p_metadata)
+{
+ int ret;
+
+ FWU_LOG_MSG("%s: enter\n\r", __func__);
+
+ if (!p_metadata) {
+ return FWU_AGENT_ERROR;
+ }
+
+ ret = FWU_METADATA_FLASH_DEV.ReadData(FWU_PRIVATE_AREA_OFFSET, p_metadata,
+ sizeof(struct fwu_private_metadata));
+ if (ret != ARM_DRIVER_OK) {
+ return FWU_AGENT_ERROR;
+ }
+
+ FWU_LOG_MSG("%s: success: boot_index = %u\n\r", __func__,
+ p_metadata->boot_index);
+
+ return FWU_AGENT_SUCCESS;
+}
+
+static enum fwu_agent_error_t private_metadata_write(
+ struct fwu_private_metadata* p_metadata)
+{
+ int ret;
+
+ FWU_LOG_MSG("%s: enter: boot_index = %u\n\r", __func__,
+ p_metadata->boot_index);
+
+ if (!p_metadata) {
+ return FWU_AGENT_ERROR;
+ }
+
+ ret = FWU_METADATA_FLASH_DEV.EraseSector(FWU_PRIVATE_AREA_OFFSET);
+ if (ret != ARM_DRIVER_OK) {
+ return FWU_AGENT_ERROR;
+ }
+
+ ret = FWU_METADATA_FLASH_DEV.ProgramData(FWU_PRIVATE_AREA_OFFSET,
+ p_metadata, sizeof(struct fwu_private_metadata));
+ if (ret != ARM_DRIVER_OK) {
+ return FWU_AGENT_ERROR;
+ }
+
+ FWU_LOG_MSG("%s: success\n\r", __func__);
+ return FWU_AGENT_SUCCESS;
+}
+
+static enum fwu_agent_error_t metadata_read(struct fwu_metadata *p_metadata)
+{
+ int ret;
+
+ FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__,
+ FWU_METADATA_REPLICA_1_OFFSET, sizeof(struct fwu_metadata));
+
+ if (!p_metadata) {
+ return FWU_AGENT_ERROR;
+ }
+
+ ret = FWU_METADATA_FLASH_DEV.ReadData(FWU_METADATA_REPLICA_1_OFFSET,
+ p_metadata, sizeof(struct fwu_metadata));
+ if (ret != ARM_DRIVER_OK) {
+ return FWU_AGENT_ERROR;
+ }
+
+ FWU_LOG_MSG("%s: success: active = %u, previous = %d\n\r", __func__,
+ p_metadata->active_index, p_metadata->previous_active_index);
+
+ return FWU_AGENT_SUCCESS;
+}
+
+static enum fwu_agent_error_t metadata_write(
+ struct fwu_metadata *p_metadata)
+{
+ int ret;
+
+ FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__,
+ FWU_METADATA_REPLICA_1_OFFSET, sizeof(struct fwu_metadata));
+
+ if (!p_metadata) {
+ return FWU_AGENT_ERROR;
+ }
+
+ ret = FWU_METADATA_FLASH_DEV.EraseSector(FWU_METADATA_REPLICA_1_OFFSET);
+ if (ret != ARM_DRIVER_OK) {
+ return FWU_AGENT_ERROR;
+ }
+
+ ret = FWU_METADATA_FLASH_DEV.ProgramData(FWU_METADATA_REPLICA_1_OFFSET,
+ p_metadata, sizeof(struct fwu_metadata));
+ if (ret != ARM_DRIVER_OK) {
+ return FWU_AGENT_ERROR;
+ }
+
+ FWU_LOG_MSG("%s: success: active = %u, previous = %d\n\r", __func__,
+ p_metadata->active_index, p_metadata->previous_active_index);
+ return FWU_AGENT_SUCCESS;
+}
+
+enum fwu_agent_error_t fwu_metadata_init(void)
+{
+ enum fwu_agent_error_t ret;
+ ARM_FLASH_INFO* flash_info;
+
+ FWU_LOG_MSG("%s: enter\n\r", __func__);
+
+ if (is_initialized) {
+ return FWU_AGENT_SUCCESS;
+ }
+
+ /* Code assumes everything fits into a sector */
+ if (sizeof(struct fwu_metadata) > FWU_METADATA_FLASH_SECTOR_SIZE) {
+ return FWU_AGENT_ERROR;
+ }
+
+ if (sizeof(struct fwu_private_metadata) > FWU_METADATA_FLASH_SECTOR_SIZE) {
+ return FWU_AGENT_ERROR;
+ }
+
+ ret = FWU_METADATA_FLASH_DEV.Initialize(NULL);
+ if (ret != ARM_DRIVER_OK) {
+ return FWU_AGENT_ERROR;
+ }
+
+ flash_info = FWU_METADATA_FLASH_DEV.GetInfo();
+ if (flash_info->program_unit != 1) {
+ FWU_METADATA_FLASH_DEV.Uninitialize();
+ return FWU_AGENT_ERROR;
+ }
+
+ is_initialized = 1;
+
+ FWU_LOG_MSG("%s: is_initialized = %d\n\r", __func__, is_initialized);
+
+ return FWU_AGENT_SUCCESS;
+}
+
+enum fwu_agent_error_t fwu_metadata_provision(void)
+{
+ enum fwu_agent_error_t ret;
+ struct fwu_private_metadata priv_metadata;
+ uint32_t image_version = 0;
+
+ FWU_LOG_MSG("%s: enter\n\r", __func__);
+
+ ret = fwu_metadata_init();
+ if (ret) {
+ return ret;
+ }
+
+ /* Provision FWU Agent Metadata */
+
+ memset(&_metadata, 0, sizeof(struct fwu_metadata));
+
+ _metadata.version = 1;
+ _metadata.active_index = 0;
+ _metadata.previous_active_index = 1;
+
+ /* bank 0 is the place where images are located at the
+ * start of device lifecycle */
+
+ for (int i = 0; i < NR_OF_IMAGES_IN_FW_BANK; i++) {
+
+ _metadata.img_entry[i].img_props[BANK_0].accepted = IMAGE_ACCEPTED;
+ _metadata.img_entry[i].img_props[BANK_0].version = image_version;
+
+ _metadata.img_entry[i].img_props[BANK_1].accepted = IMAGE_NOT_ACCEPTED;
+ _metadata.img_entry[i].img_props[BANK_1].version = INVALID_VERSION;
+ }
+
+ ret = metadata_write(&_metadata);
+ if (ret) {
+ return ret;
+ }
+
+ memset(&_metadata, 0, sizeof(struct fwu_metadata));
+ ret = metadata_read(&_metadata);
+ if (ret) {
+ return ret;
+ }
+ FWU_LOG_MSG("%s: provisioned values: active = %u, previous = %d\n\r",
+ __func__, _metadata.active_index, _metadata.previous_active_index);
+
+
+ /* Provision Private metadata for update agent which is shared
+ beween BL1 and tf-m of secure enclave */
+
+ memset(&priv_metadata, 0, sizeof(struct fwu_private_metadata));
+
+ priv_metadata.boot_index = BANK_0;
+
+ ret = private_metadata_write(&priv_metadata);
+ if (ret) {
+ return ret;
+ }
+
+ memset(&priv_metadata, 0, sizeof(struct fwu_private_metadata));
+ ret = private_metadata_read(&priv_metadata);
+ if (ret) {
+ return ret;
+ }
+ FWU_LOG_MSG("%s: provisioned values: boot_index = %u\n\r", __func__,
+ priv_metadata.boot_index);
+
+ FWU_LOG_MSG("%s: FWU METADATA PROVISIONED.\n\r", __func__);
+ return FWU_AGENT_SUCCESS;
+}
+
diff --git a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h
new file mode 100644
index 0000000000..449d354100
--- /dev/null
+++ b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef FWU_AGENT_H
+#define FWU_AGENT_H
+
+/* Set 1 to enable debug messages */
+#define ENABLE_DEBUG_LOGS 1
+
+#if (ENABLE_DEBUG_LOGS == 1)
+ #include <stdio.h>
+ #define FWU_LOG_MSG(f_, ...) printf((f_), ##__VA_ARGS__)
+#else
+ #define FWU_LOG_MSG(f_, ...)
+#endif
+
+enum fwu_agent_error_t {
+ FWU_AGENT_SUCCESS = 0,
+ FWU_AGENT_ERROR = (-1)
+};
+
+enum fwu_agent_error_t fwu_metadata_provision(void);
+enum fwu_agent_error_t fwu_metadata_init(void);
+
+
+#endif /* FWU_AGENT_H */
+
diff --git a/platform/ext/target/arm/corstone1000/partition/flash_layout.h b/platform/ext/target/arm/corstone1000/partition/flash_layout.h
index f120a7b8ee..47445d9d29 100644
--- a/platform/ext/target/arm/corstone1000/partition/flash_layout.h
+++ b/platform/ext/target/arm/corstone1000/partition/flash_layout.h
@@ -117,11 +117,18 @@
/* 1MB: space in flash to store metadata and uefi variables */
+#define FWU_METADATA_FLASH_DEV (FLASH_DEV_NAME)
+#define FWU_METADATA_FLASH_SECTOR_SIZE (FLASH_SECTOR_SIZE)
+
#define FWU_METADATA_PARTITION_OFFSET (FLASH_BASE_OFFSET)
-#define FWU_METADATA_AREA_SIZE (FLASH_SECTOR_SIZE) /* 4KB */
+#define FWU_METADATA_AREA_SIZE (FWU_METADATA_FLASH_SECTOR_SIZE)
#define FWU_METADATA_REPLICA_1_OFFSET (FLASH_BASE_OFFSET)
#define FWU_METADATA_REPLICA_2_OFFSET (FWU_METADATA_REPLICA_1_OFFSET + \
FWU_METADATA_AREA_SIZE)
+#define FWU_PRIVATE_AREA_SIZE (FLASH_SECTOR_SIZE)
+#define FWU_PRIVATE_AREA_OFFSET (FWU_METADATA_REPLICA_2_OFFSET + \
+ FWU_METADATA_AREA_SIZE)
+
#define NR_OF_FW_BANKS (2)
#define NR_OF_IMAGES_IN_FW_BANK (4) /* Secure Enclave: BL2 and TF-M \
* Host: FIP and Kernel image
@@ -217,7 +224,7 @@
/*** ITS, PS and NV Counters ***/
/*******************************/
-#define FLASH_ITS_AREA_OFFSET (0)
+#define FLASH_ITS_AREA_OFFSET (0x10000) /* 64 KB */
#define FLASH_ITS_AREA_SIZE (4 * FLASH_SECTOR_SIZE) /* 4 KiB */
#define FLASH_PS_AREA_OFFSET (FLASH_ITS_AREA_OFFSET + \
--
2.17.1
@@ -0,0 +1,243 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
From 22aeb7708773c2cc9df2cc501d411b94c09fd0bd Mon Sep 17 00:00:00 2001
From: Satish Kumar <satish.kumar01@arm.com>
Date: Sat, 2 Oct 2021 12:31:07 +0100
Subject: [PATCH 03/15] corstone1000: parse the uefi firmware update capsule
The Host (OTA Client) sends a capsule containing fwu images
to secure enclave. The commit parses the capsule to retrieve
images.
Change-Id: Icf097cf88911a568bdc9eba8c98e2da93994f0bc
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
---
.../target/arm/corstone1000/CMakeLists.txt | 2 +
.../fw_update_agent/uefi_capsule_parser.c | 155 ++++++++++++++++++
.../fw_update_agent/uefi_capsule_parser.h | 31 ++++
3 files changed, 188 insertions(+)
create mode 100644 platform/ext/target/arm/corstone1000/fw_update_agent/uefi_capsule_parser.c
create mode 100644 platform/ext/target/arm/corstone1000/fw_update_agent/uefi_capsule_parser.h
diff --git a/platform/ext/target/arm/corstone1000/CMakeLists.txt b/platform/ext/target/arm/corstone1000/CMakeLists.txt
index 16d256bc34..f34035d361 100644
--- a/platform/ext/target/arm/corstone1000/CMakeLists.txt
+++ b/platform/ext/target/arm/corstone1000/CMakeLists.txt
@@ -51,6 +51,7 @@ target_include_directories(platform_s
services/include
INTERFACE
cc312
+ fw_update_agent
)
target_sources(platform_s
@@ -67,6 +68,7 @@ target_sources(platform_s
tfm_hal_platform.c
${CMAKE_SOURCE_DIR}/platform/ext/common/tfm_hal_nvic.c
$<$<BOOL:TFM_PARTITION_PLATFORM>:${CMAKE_CURRENT_SOURCE_DIR}/services/src/tfm_platform_system.c>
+ fw_update_agent/uefi_capsule_parser.c
)
if (PLATFORM_IS_FVP)
diff --git a/platform/ext/target/arm/corstone1000/fw_update_agent/uefi_capsule_parser.c b/platform/ext/target/arm/corstone1000/fw_update_agent/uefi_capsule_parser.c
new file mode 100644
index 0000000000..32133b2eb2
--- /dev/null
+++ b/platform/ext/target/arm/corstone1000/fw_update_agent/uefi_capsule_parser.c
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include "uefi_capsule_parser.h"
+#include "fwu_agent.h"
+#include <string.h>
+
+/*
+Update Capsule Structure (UEFI spec 2.9 1004)
+ EFI_CAPSULE_HEADER
+ ...
+ ...
+ ...
+ CAPSULE_BODY
+ efi_firmware_management_capsule_header
+ Optional Driver 1 (item_offset[0])
+ Optional Driver 2 (item_offset[1])
+ Payload 1 (item_offset[2])
+ efi_firmware_management_capsule_iamge_header
+ Binary Update image (Image_length == update_image_size)
+ Vendor Code bytes (Data lenght == update_vendorcode_size)
+ Payload 2 (item_offset[3])
+ ...
+ ...
+ Payload n (item_offset[embedded_driver_count + payload_item_count -1])
+*/
+
+typedef struct {
+ struct efi_guid capsule_guid;
+ uint32_t header_size;
+ uint32_t flags;
+ uint32_t capsule_image_size;
+} efi_capsule_header_t;
+
+typedef struct {
+ uint32_t version;
+ uint16_t embedded_driver_count;
+ uint16_t payload_item_count;
+ uint64_t item_offset_list[];
+} efi_firmware_management_capsule_header_t;
+
+typedef struct {
+ uint32_t version;
+ struct efi_guid update_image_type_id;
+ uint8_t update_image_index;
+ uint8_t reserved_bytes[3];
+ uint32_t update_image_size;
+ uint32_t update_vendorcode_size;
+ uint64_t update_hardware_instance; //introduced in v2
+ uint64_t image_capsule_support; //introduced in v3
+} efi_firmware_management_capsule_image_header_t;
+
+#define ANYSIZE_ARRAY 0
+
+typedef struct {
+ uint32_t dwLength;
+ uint16_t wRevision;
+ uint16_t wCertificateType;
+ uint8_t bCertificate[ANYSIZE_ARRAY];
+} WIN_CERTIFICATE;
+
+typedef struct {
+ WIN_CERTIFICATE hdr;
+ struct efi_guid cert_type;
+ uint8_t cert_data[ANYSIZE_ARRAY];
+} win_certificate_uefi_guid_t;
+
+typedef struct {
+ uint64_t monotonic_count;
+ win_certificate_uefi_guid_t auth_info;
+} efi_firmware_image_authentication_t;
+
+
+enum uefi_capsule_error_t uefi_capsule_retrieve_images(void* capsule_ptr,
+ capsule_image_info_t* images_info)
+{
+ char *ptr = (char*)capsule_ptr;
+ efi_capsule_header_t* capsule_header;
+ efi_firmware_management_capsule_header_t* payload_header;
+ efi_firmware_management_capsule_image_header_t* image_header;
+ efi_firmware_image_authentication_t* image_auth;
+ uint32_t total_size;
+ uint32_t image_count;
+ uint32_t auth_size;
+
+ FWU_LOG_MSG("%s: enter, capsule ptr = 0x%p\n\r", __func__, capsule_ptr);
+
+ if (!capsule_ptr) {
+ return UEFI_CAPSULE_PARSER_ERROR;
+ }
+
+ capsule_header = (efi_capsule_header_t*)ptr;
+ ptr += sizeof(efi_capsule_header_t) + sizeof(uint32_t);
+ payload_header = (efi_firmware_management_capsule_header_t*)ptr;
+
+ total_size = capsule_header->capsule_image_size;
+ image_count = payload_header->payload_item_count;
+ images_info->nr_image = image_count;
+
+ FWU_LOG_MSG("%s: capsule size = %u, image count = %u\n\r", __func__,
+ total_size, image_count);
+
+ if ((image_count == 0) || (image_count > NR_OF_IMAGES_IN_FW_BANK)) {
+ return UEFI_CAPSULE_PARSER_ERROR;
+ }
+
+ for (int i = 0; i < image_count; i++) {
+
+ image_header = (efi_firmware_management_capsule_image_header_t*)(ptr +
+ payload_header->item_offset_list[i]);
+
+ images_info->size[i] = image_header->update_image_size;
+ images_info->version[i] = image_header->version;
+ FWU_LOG_MSG("%s: image %i version = %u\n\r", __func__, i,
+ images_info->version[i]);
+
+ image_auth = (efi_firmware_image_authentication_t*)(
+ (char*)image_header +
+ sizeof (efi_firmware_management_capsule_image_header_t)
+ );
+ auth_size = sizeof(uint64_t) /* monotonic_count */ +
+ image_auth->auth_info.hdr.dwLength /* WIN_CERTIFICATE + cert_data */ +
+ sizeof(struct efi_guid) /* cert_type */;
+
+ FWU_LOG_MSG("%s: auth size = %u\n\r", __func__, auth_size);
+
+ images_info->size[i] -= auth_size;
+
+ images_info->image[i] = (
+ (char*)image_header +
+ sizeof(efi_firmware_management_capsule_image_header_t) +
+ auth_size);
+
+ memcpy(&images_info->guid[i], &(image_header->update_image_type_id),
+ sizeof(struct efi_guid));
+
+ FWU_LOG_MSG("%s: image %d at %p, size=%u\n\r", __func__, i,
+ images_info->image[i], images_info->size[i]);
+
+ if ((payload_header->item_offset_list[i] +
+ sizeof(efi_firmware_management_capsule_image_header_t) +
+ image_header->update_image_size) > total_size)
+ {
+ return UEFI_CAPSULE_PARSER_ERROR;
+ }
+
+ }
+
+ FWU_LOG_MSG("%s: exit\n\r", __func__);
+ return UEFI_CAPSULE_PARSER_SUCCESS;
+}
diff --git a/platform/ext/target/arm/corstone1000/fw_update_agent/uefi_capsule_parser.h b/platform/ext/target/arm/corstone1000/fw_update_agent/uefi_capsule_parser.h
new file mode 100644
index 0000000000..a890a709e9
--- /dev/null
+++ b/platform/ext/target/arm/corstone1000/fw_update_agent/uefi_capsule_parser.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef UEFI_CAPSULE_PARSER_H
+#define UEFI_CAPSULE_PARSER_H
+
+#include <stdint.h>
+#include "fip_parser/external/uuid.h"
+#include "flash_layout.h"
+
+enum uefi_capsule_error_t {
+ UEFI_CAPSULE_PARSER_SUCCESS = 0,
+ UEFI_CAPSULE_PARSER_ERROR = (-1)
+};
+
+typedef struct capsule_image_info {
+ uint32_t nr_image;
+ void *image[NR_OF_IMAGES_IN_FW_BANK];
+ struct efi_guid guid[NR_OF_IMAGES_IN_FW_BANK];
+ uint32_t size[NR_OF_IMAGES_IN_FW_BANK];
+ uint32_t version[NR_OF_IMAGES_IN_FW_BANK];
+} capsule_image_info_t;
+
+enum uefi_capsule_error_t uefi_capsule_retrieve_images(void* capsule_ptr,
+ capsule_image_info_t* images_info);
+
+#endif /* UEFI_CAPSULE_PARSER_H */
--
2.17.1
@@ -0,0 +1,106 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
From c1ae09844562f33ddf07b8f5ca6b7d98ccbaf24c Mon Sep 17 00:00:00 2001
From: Satish Kumar <satish.kumar01@arm.com>
Date: Sat, 2 Oct 2021 18:48:31 +0100
Subject: [PATCH 04/15] corstone1000: add firmware update (fwu) agent into TF-M
The commit links the firmware-update (fwu) agent into the
TF-M.
The commit also configures the secure enclave firewall to
access DRAM, where uefi capsule will be written by ota client
for fwu agent to parse.
Change-Id: I89617a9b515d6aa5cc4f383b5a75a4beef73cc33
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
---
.../ext/target/arm/corstone1000/CMakeLists.txt | 1 +
.../Device/Include/platform_base_address.h | 1 +
.../target/arm/corstone1000/bl1/bl1_boot_hal.c | 17 +++++++++++++++++
.../target/arm/corstone1000/tfm_hal_platform.c | 5 +++++
4 files changed, 24 insertions(+)
diff --git a/platform/ext/target/arm/corstone1000/CMakeLists.txt b/platform/ext/target/arm/corstone1000/CMakeLists.txt
index f34035d361..81623f16ff 100644
--- a/platform/ext/target/arm/corstone1000/CMakeLists.txt
+++ b/platform/ext/target/arm/corstone1000/CMakeLists.txt
@@ -69,6 +69,7 @@ target_sources(platform_s
${CMAKE_SOURCE_DIR}/platform/ext/common/tfm_hal_nvic.c
$<$<BOOL:TFM_PARTITION_PLATFORM>:${CMAKE_CURRENT_SOURCE_DIR}/services/src/tfm_platform_system.c>
fw_update_agent/uefi_capsule_parser.c
+ fw_update_agent/fwu_agent.c
)
if (PLATFORM_IS_FVP)
diff --git a/platform/ext/target/arm/corstone1000/Device/Include/platform_base_address.h b/platform/ext/target/arm/corstone1000/Device/Include/platform_base_address.h
index 5f37caa09c..e86ddcfbc9 100644
--- a/platform/ext/target/arm/corstone1000/Device/Include/platform_base_address.h
+++ b/platform/ext/target/arm/corstone1000/Device/Include/platform_base_address.h
@@ -75,5 +75,6 @@
#define CORSTONE1000_HOST_FPGA_SCC_REGISTERS (0x80000000U) /* FPGA SCC Registers */
#define CORSTONE1000_HOST_SE_SECURE_FLASH_BASE_FVP (0x80010000U) /* SE Flash */
#define CORSTONE1000_HOST_AXI_QSPI_CTRL_REG_BASE (0x80050000U) /* AXI QSPI Controller */
+#define CORSTONE1000_HOST_DRAM_UEFI_CAPSULE (0xA0000000U) /* 1.5 GB DDR */
#endif /* __PLATFORM_BASE_ADDRESS_H__ */
diff --git a/platform/ext/target/arm/corstone1000/bl1/bl1_boot_hal.c b/platform/ext/target/arm/corstone1000/bl1/bl1_boot_hal.c
index 5e5e5c9e68..54042495d7 100644
--- a/platform/ext/target/arm/corstone1000/bl1/bl1_boot_hal.c
+++ b/platform/ext/target/arm/corstone1000/bl1/bl1_boot_hal.c
@@ -47,6 +47,7 @@ REGION_DECLARE(Image$$, ARM_LIB_HEAP, $$ZI$$Limit)[];
#define HOST_AXI_QSPI_CTRL_REG_BASE_SE_SECURE_FLASH 0x60010000
#define HOST_DRAM_BASE 0x80000000
+#define HOST_DRAM_UEFI_CAPSULE 0x80000000
#define SE_MID 0
@@ -249,6 +250,22 @@ static void setup_se_firewall(void)
fc_enable_mpe(RGN_MPE0);
fc_enable_regions();
+ /* DDR/DRAM/UEFI_CAPSULE: 32MB */
+ fc_select_region(6);
+ fc_disable_regions();
+ fc_disable_mpe(RGN_MPE0);
+ fc_prog_rgn(RGN_SIZE_32MB, CORSTONE1000_HOST_DRAM_UEFI_CAPSULE);
+ fc_prog_rgn_upper_addr(HOST_DRAM_UEFI_CAPSULE);
+ fc_enable_addr_trans();
+ fc_init_mpl(RGN_MPE0);
+ mpl_rights = (RGN_MPL_SECURE_READ_MASK |
+ RGN_MPL_SECURE_WRITE_MASK);
+
+ fc_enable_mpl(RGN_MPE0, mpl_rights);
+ fc_prog_mid(RGN_MPE0, SE_MID);
+ fc_enable_mpe(RGN_MPE0);
+ fc_enable_regions();
+
fc_pe_enable();
}
diff --git a/platform/ext/target/arm/corstone1000/tfm_hal_platform.c b/platform/ext/target/arm/corstone1000/tfm_hal_platform.c
index 71472ea08c..0072b5b928 100644
--- a/platform/ext/target/arm/corstone1000/tfm_hal_platform.c
+++ b/platform/ext/target/arm/corstone1000/tfm_hal_platform.c
@@ -8,11 +8,16 @@
#include "cmsis.h"
#include "tfm_hal_platform.h"
#include "uart_stdout.h"
+#include "fwu_agent.h"
enum tfm_hal_status_t tfm_hal_platform_init(void)
{
__enable_irq();
stdio_init();
+ if (fwu_metadata_init()) {
+ return TFM_HAL_ERROR_GENERIC;
+ }
+
return TFM_HAL_SUCCESS;
}
--
2.17.1
@@ -0,0 +1,437 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
From 593087034655eca09ff8e80e67c3252399fa0ce7 Mon Sep 17 00:00:00 2001
From: Satish Kumar <satish.kumar01@arm.com>
Date: Sat, 2 Oct 2021 18:51:21 +0100
Subject: [PATCH 05/15] corstone1000: implement corstone1000_fwu_flash_images
The API, corstone1000_fwu_flash_images, is an non-secure host
inteface (firmware update client) to send new updatable images,
and to start the update process. The implementation of the API does
version verfification before coping the images to the update bank.
After copy, the platform is reset.
On successful call to the API, the firmware update state of the
system changes from regular state to trial state. On reset,
the system is expected but not guaranteed to boot from the
update/trial bank.
Change-Id: I6c278145ec95ec522f7e59d00e1640a039c9778e
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
---
.../corstone1000/CMSIS_Driver/Driver_Flash.c | 11 +
.../corstone1000/Native_Driver/flash_common.h | 1 +
.../corstone1000/fw_update_agent/fwu_agent.c | 225 ++++++++++++++++++
.../corstone1000/fw_update_agent/fwu_agent.h | 11 +
.../include/corstone1000_ioctl_requests.h | 32 +++
.../services/src/tfm_platform_system.c | 24 +-
6 files changed, 300 insertions(+), 4 deletions(-)
create mode 100644 platform/ext/target/arm/corstone1000/services/include/corstone1000_ioctl_requests.h
diff --git a/platform/ext/target/arm/corstone1000/CMSIS_Driver/Driver_Flash.c b/platform/ext/target/arm/corstone1000/CMSIS_Driver/Driver_Flash.c
index 10952d4cbe..01c535e094 100644
--- a/platform/ext/target/arm/corstone1000/CMSIS_Driver/Driver_Flash.c
+++ b/platform/ext/target/arm/corstone1000/CMSIS_Driver/Driver_Flash.c
@@ -175,6 +175,11 @@ int32_t Select_XIP_Mode_For_Shared_Flash(void)
return ARM_DRIVER_OK;
}
+int32_t Select_Write_Mode_For_Shared_Flash(void)
+{
+ return ARM_DRIVER_OK;
+}
+
static int32_t STRATAFLASHJ3_Initialize(ARM_Flash_SignalEvent_t cb_event)
{
ARG_UNUSED(cb_event);
@@ -392,6 +397,12 @@ int32_t Select_XIP_Mode_For_Shared_Flash(void)
return ARM_DRIVER_OK;
}
+int32_t Select_Write_Mode_For_Shared_Flash(void)
+{
+ select_qspi_mode(&AXI_QSPI_DEV_S);
+ return ARM_DRIVER_OK;
+}
+
static ARM_FLASH_CAPABILITIES N25Q256A_Driver_GetCapabilities(void)
{
return N25Q256ADriverCapabilities;
diff --git a/platform/ext/target/arm/corstone1000/Native_Driver/flash_common.h b/platform/ext/target/arm/corstone1000/Native_Driver/flash_common.h
index 76d5303f83..2e91fb2db4 100644
--- a/platform/ext/target/arm/corstone1000/Native_Driver/flash_common.h
+++ b/platform/ext/target/arm/corstone1000/Native_Driver/flash_common.h
@@ -18,6 +18,7 @@ extern "C"
#include "Driver_Common.h"
int32_t Select_XIP_Mode_For_Shared_Flash(void);
+int32_t Select_Write_Mode_For_Shared_Flash(void);
#ifdef __cplusplus
}
diff --git a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
index b9c507e4ef..7fa64db0f7 100644
--- a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
+++ b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
@@ -11,6 +11,10 @@
#include "Driver_Flash.h"
#include "flash_layout.h"
#include "fip_parser/external/uuid.h"
+#include "region_defs.h"
+#include "uefi_capsule_parser.h"
+#include "flash_common.h"
+#include "platform_base_address.h"
/* Properties of image in a bank */
struct fwu_image_properties {
@@ -73,9 +77,27 @@ struct fwu_private_metadata {
} __packed;
+
struct fwu_metadata _metadata;
+
int is_initialized = 0;
+capsule_image_info_t capsule_info;
+
+enum fwu_agent_state_t {
+ FWU_AGENT_STATE_UNKNOWN = -1,
+ FWU_AGENT_STATE_REGULAR = 0,
+ FWU_AGENT_STATE_TRIAL,
+};
+
+struct efi_guid full_capsule_image_guid = {
+ .time_low = 0x3a770ddc,
+ .time_mid = 0x409b,
+ .time_hi_and_version = 0x48b2,
+ .clock_seq_and_node = {0x81, 0x41, 0x93, 0xb7, 0xc6, 0x0b, 0x20, 0x9e}
+};
+
+
#define IMAGE_ACCEPTED (1)
#define IMAGE_NOT_ACCEPTED (0)
#define BANK_0 (0)
@@ -84,8 +106,12 @@ int is_initialized = 0;
#define IMAGE_1 (1)
#define IMAGE_2 (2)
#define IMAGE_3 (3)
+#define IMAGE_END (IMAGE_3)
+#define IMAGE_ALL (IMAGE_END + 1)
+#define IMAGE_NOT_RECOGNIZED (-1)
#define INVALID_VERSION (0xffffffff)
+
#ifndef FWU_METADATA_FLASH_DEV
#ifndef FLASH_DEV_NAME
#error "FWU_METADATA_FLASH_DEV or FLASH_DEV_NAME must be defined in flash_layout.h"
@@ -307,3 +333,202 @@ enum fwu_agent_error_t fwu_metadata_provision(void)
return FWU_AGENT_SUCCESS;
}
+static enum fwu_agent_state_t get_fwu_agent_state(
+ struct fwu_metadata *metadata_ptr,
+ struct fwu_private_metadata *priv_metadata_ptr)
+{
+ uint32_t boot_index;
+
+ FWU_LOG_MSG("%s: enter\n\r", __func__);
+
+ boot_index = priv_metadata_ptr->boot_index;
+
+ if (boot_index != metadata_ptr->active_index) {
+ return FWU_AGENT_STATE_TRIAL;
+ }
+
+ for (int i = 0; i < NR_OF_IMAGES_IN_FW_BANK; i++) {
+ if ((metadata_ptr->img_entry[i].img_props[boot_index].accepted)
+ == (IMAGE_NOT_ACCEPTED)) {
+ return FWU_AGENT_STATE_TRIAL;
+ }
+ }
+
+ FWU_LOG_MSG("%s: exit: FWU_AGENT_STATE_REGULAR\n\r", __func__);
+ return FWU_AGENT_STATE_REGULAR;
+}
+
+static int get_image_info_in_bank(struct efi_guid* guid, uint32_t* image_bank_offset)
+{
+ if ((memcmp(guid, &full_capsule_image_guid, sizeof(struct efi_guid))) == 0) {
+ *image_bank_offset = 0;
+ return IMAGE_ALL;
+ }
+
+ return IMAGE_NOT_RECOGNIZED;
+}
+
+static enum fwu_agent_error_t erase_bank(uint32_t bank_offset)
+{
+ int ret;
+ uint32_t sectors;
+
+ FWU_LOG_MSG("%s: enter\n\r", __func__);
+
+ if ((bank_offset % FWU_METADATA_FLASH_SECTOR_SIZE) != 0) {
+ return FWU_AGENT_ERROR;
+ }
+
+ if ((BANK_PARTITION_SIZE % FWU_METADATA_FLASH_SECTOR_SIZE) != 0) {
+ return FWU_AGENT_ERROR;
+ }
+
+ sectors = BANK_PARTITION_SIZE / FWU_METADATA_FLASH_SECTOR_SIZE;
+
+ FWU_LOG_MSG("%s: erasing sectors = %u, from offset = %u\n\r", __func__,
+ sectors, bank_offset);
+
+ for (int i = 0; i < sectors; i++) {
+ ret = FWU_METADATA_FLASH_DEV.EraseSector(
+ bank_offset + (i * FWU_METADATA_FLASH_SECTOR_SIZE));
+ if (ret != ARM_DRIVER_OK) {
+ return FWU_AGENT_ERROR;
+ }
+ }
+
+ FWU_LOG_MSG("%s: exit\n\r", __func__);
+ return FWU_AGENT_SUCCESS;
+}
+
+
+static enum fwu_agent_error_t flash_full_capsule(
+ struct fwu_metadata* metadata, void* images, uint32_t size,
+ uint32_t version)
+{
+ int ret;
+ uint32_t active_index = metadata->active_index;
+ uint32_t bank_offset;
+ uint32_t previous_active_index;
+
+ FWU_LOG_MSG("%s: enter: image = 0x%p, size = %u, version = %u\n\r"
+ , __func__, images, size, version);
+
+ if (!metadata || !images) {
+ return FWU_AGENT_ERROR;
+ }
+
+ if (size > BANK_PARTITION_SIZE) {
+ return FWU_AGENT_ERROR;
+ }
+
+ if (version <=
+ (metadata->img_entry[IMAGE_0].img_props[active_index].version)) {
+ return FWU_AGENT_ERROR;
+ }
+
+ if (active_index == BANK_0) {
+ previous_active_index = BANK_1;
+ bank_offset = BANK_1_PARTITION_OFFSET;
+ } else if (active_index == BANK_1) {
+ previous_active_index = BANK_0;
+ bank_offset = BANK_0_PARTITION_OFFSET;
+ } else {
+ return FWU_AGENT_ERROR;
+ }
+
+ if (erase_bank(bank_offset)) {
+ return FWU_AGENT_ERROR;
+ }
+
+ FWU_LOG_MSG("%s: writing capsule to the flash at offset = %u...\n\r",
+ __func__, bank_offset);
+ ret = FWU_METADATA_FLASH_DEV.ProgramData(bank_offset, images, size);
+ if (ret != ARM_DRIVER_OK) {
+ return FWU_AGENT_ERROR;
+ }
+ FWU_LOG_MSG("%s: images are written to bank offset = %u\n\r", __func__,
+ bank_offset);
+
+ /* Change system state to trial bank state */
+ for (int i = 0; i < NR_OF_IMAGES_IN_FW_BANK; i++) {
+ metadata->img_entry[i].img_props[previous_active_index].accepted =
+ IMAGE_NOT_ACCEPTED;
+ metadata->img_entry[i].img_props[previous_active_index].version = version;
+ }
+ metadata->active_index = previous_active_index;
+ metadata->previous_active_index = active_index;
+
+ ret = metadata_write(metadata);
+ if (ret) {
+ return ret;
+ }
+
+ FWU_LOG_MSG("%s: exit\n\r", __func__);
+ return FWU_AGENT_SUCCESS;
+}
+
+enum fwu_agent_error_t corstone1000_fwu_flash_image(void)
+{
+ enum fwu_agent_error_t ret;
+ struct fwu_private_metadata priv_metadata;
+ enum fwu_agent_state_t current_state;
+ void *capsule_ptr = (char*)CORSTONE1000_HOST_DRAM_UEFI_CAPSULE;
+ int image_index;
+ uint32_t image_bank_offset;
+ uint32_t nr_images;
+
+ FWU_LOG_MSG("%s: enter\n\r", __func__);
+
+ if (!is_initialized) {
+ return FWU_AGENT_ERROR;
+ }
+
+ Select_Write_Mode_For_Shared_Flash();
+
+ if (metadata_read(&_metadata)) {
+ ret = FWU_AGENT_ERROR;
+ goto out;
+ }
+
+ if (private_metadata_read(&priv_metadata)) {
+ ret = FWU_AGENT_ERROR;
+ goto out;
+ }
+
+ /* Firmware update process can only start in regular state. */
+ current_state = get_fwu_agent_state(&_metadata, &priv_metadata);
+ if (current_state != FWU_AGENT_STATE_REGULAR) {
+ ret = FWU_AGENT_ERROR;
+ goto out;
+ }
+
+ memset(&capsule_info, 0, sizeof(capsule_image_info_t));
+ if (uefi_capsule_retrieve_images(capsule_ptr, &capsule_info)) {
+ ret = FWU_AGENT_ERROR;
+ goto out;
+ }
+ nr_images = capsule_info.nr_image;
+
+ for (int i = 0; i < nr_images; i++) {
+ image_index = get_image_info_in_bank(&capsule_info.guid[i],
+ &image_bank_offset);
+ switch(image_index) {
+ case IMAGE_ALL:
+ ret = flash_full_capsule(&_metadata, capsule_info.image[i],
+ capsule_info.size[i],
+ capsule_info.version[i]);
+ break;
+ default:
+ FWU_LOG_MSG("%s: sent image not recognized\n\r", __func__);
+ ret = FWU_AGENT_ERROR;
+ break;
+ }
+ }
+
+out:
+ Select_XIP_Mode_For_Shared_Flash();
+
+ FWU_LOG_MSG("%s: exit: ret = %d\n\r", __func__, ret);
+ return ret;
+}
+
diff --git a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h
index 449d354100..f5ab877ef1 100644
--- a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h
+++ b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h
@@ -23,9 +23,20 @@ enum fwu_agent_error_t {
FWU_AGENT_ERROR = (-1)
};
+#define FWU_ASSERT(_c_) \
+ if (!(_c_)) { \
+ FWU_LOG_MSG("%s:%d assert hit\n\r", __func__, __LINE__); \
+ while(1) {}; \
+ } \
+
+
enum fwu_agent_error_t fwu_metadata_provision(void);
enum fwu_agent_error_t fwu_metadata_init(void);
+/* host to secure enclave:
+ * firwmare update image is sent accross
+ */
+enum fwu_agent_error_t corstone1000_fwu_flash_image(void);
#endif /* FWU_AGENT_H */
diff --git a/platform/ext/target/arm/corstone1000/services/include/corstone1000_ioctl_requests.h b/platform/ext/target/arm/corstone1000/services/include/corstone1000_ioctl_requests.h
new file mode 100644
index 0000000000..8ac67346b6
--- /dev/null
+++ b/platform/ext/target/arm/corstone1000/services/include/corstone1000_ioctl_requests.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef CORSTONE1000_IOCTL_REQUESTS_H
+#define CORSTONE1000_IOCTL_REQUESTS_H
+
+#include<stdint.h>
+
+
+enum corstone1000_ioctl_id_t {
+ IOCTL_CORSTONE1000_FWU_FLASH_IMAGES = 0,
+ IOCTL_CORSTONE1000_FWU_HOST_ACK,
+};
+
+
+typedef struct corstone1000_ioctl_in_params {
+
+ uint32_t ioctl_id;
+
+} corstone1000_ioctl_in_params_t;
+
+typedef struct corstone1000_ioctl_out_params {
+
+ int32_t result;
+
+} corstone1000_ioctl_out_params_t;
+
+#endif /* CORSTONE1000_IOCTL_REQUESTS_H */
diff --git a/platform/ext/target/arm/corstone1000/services/src/tfm_platform_system.c b/platform/ext/target/arm/corstone1000/services/src/tfm_platform_system.c
index ed31c8895a..f9629a1688 100644
--- a/platform/ext/target/arm/corstone1000/services/src/tfm_platform_system.c
+++ b/platform/ext/target/arm/corstone1000/services/src/tfm_platform_system.c
@@ -7,6 +7,8 @@
#include "tfm_platform_system.h"
#include "platform_description.h"
+#include "corstone1000_ioctl_requests.h"
+#include "fwu_agent.h"
void tfm_platform_hal_system_reset(void)
{
@@ -18,8 +20,22 @@ enum tfm_platform_err_t tfm_platform_hal_ioctl(tfm_platform_ioctl_req_t request,
psa_invec *in_vec,
psa_outvec *out_vec)
{
- (void)in_vec;
- (void)out_vec;
- /* No IOCTL is ipmlemented */
- return TFM_PLATFORM_ERR_NOT_SUPPORTED;
+ int32_t ret = TFM_PLATFORM_ERR_SUCCESS;
+ const corstone1000_ioctl_in_params_t *in_params =
+ (corstone1000_ioctl_in_params_t *)in_vec->base;
+ corstone1000_ioctl_out_params_t *out_params = (corstone1000_ioctl_out_params_t *)out_vec->base;
+
+ switch(in_params->ioctl_id) {
+ case IOCTL_CORSTONE1000_FWU_FLASH_IMAGES:
+ out_params->result = corstone1000_fwu_flash_image();
+ if (!out_params->result) {
+ NVIC_SystemReset();
+ }
+ break;
+ default:
+ ret = TFM_PLATFORM_ERR_NOT_SUPPORTED;
+ break;
+ }
+
+ return ret;
}
--
2.17.1
@@ -0,0 +1,266 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
From 7ec8812451a4e25ca0790f84c7a0ee1f260f864c Mon Sep 17 00:00:00 2001
From: Satish Kumar <satish.kumar01@arm.com>
Date: Mon, 11 Oct 2021 20:12:46 +0100
Subject: [PATCH 06/15] corstone1000: add logic to select boot bank
Bl1 selects the boot bank depending upon the firmware update state
of the system. When in the trial state, new images are being tried,
BL1 select trial/update image bank for a pre-determined number of
times. If in all attempts, the trial bank fails to boot, BL1 falls
back to the previous active bank. For any reason, if previous active
bank also fails to boot for that pre-determined number of times,
the BL1 simply goes into an assert halt state. Idealy a recovery
mechanism should boot but this is currently out-of-scope for the
project.
BL2 logic simply tries to boot from the bank selected by the BL1.
It is expected that the fail boots are detected by secure enclave,
and in those cases, reset of the system is triggered.
Change-Id: I773752f789bf8b402436c61134ac79bb405553b5
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
---
.../target/arm/corstone1000/CMakeLists.txt | 2 +
.../arm/corstone1000/bl1/bl1_boot_hal.c | 6 +-
.../target/arm/corstone1000/bl2_boot_hal.c | 8 +-
.../corstone1000/fw_update_agent/fwu_agent.c | 102 ++++++++++++++++++
.../corstone1000/fw_update_agent/fwu_agent.h | 5 +-
5 files changed, 117 insertions(+), 6 deletions(-)
diff --git a/platform/ext/target/arm/corstone1000/CMakeLists.txt b/platform/ext/target/arm/corstone1000/CMakeLists.txt
index 81623f16ff..a2191c835f 100644
--- a/platform/ext/target/arm/corstone1000/CMakeLists.txt
+++ b/platform/ext/target/arm/corstone1000/CMakeLists.txt
@@ -109,6 +109,7 @@ target_sources(platform_bl2
Native_Driver/uart_pl011_drv.c
fip_parser/fip_parser.c
bl2_boot_hal.c
+ fw_update_agent/fwu_agent.c
)
if (PLATFORM_IS_FVP)
@@ -155,6 +156,7 @@ target_include_directories(platform_bl2
${MCUBOOT_PATH}/boot/bootutil/include # for fault_injection_hardening.h only
${CMAKE_BINARY_DIR}/bl2/ext/mcuboot # for mcuboot_config.h only
$<BUILD_INTERFACE:${BL2_SOURCE}/ext/mcuboot/include>
+ fw_update_agent
)
#========================= BL1 component =======================================#
diff --git a/platform/ext/target/arm/corstone1000/bl1/bl1_boot_hal.c b/platform/ext/target/arm/corstone1000/bl1/bl1_boot_hal.c
index 54042495d7..2af5b8c846 100644
--- a/platform/ext/target/arm/corstone1000/bl1/bl1_boot_hal.c
+++ b/platform/ext/target/arm/corstone1000/bl1/bl1_boot_hal.c
@@ -587,7 +587,7 @@ extern void add_bank_offset_to_image_offset(uint32_t bank_offset);
int32_t boot_platform_init(void)
{
int32_t result;
- uint32_t bank_offset = BANK_0_PARTITION_OFFSET;
+ uint32_t bank_offset;
#if !(PLATFORM_IS_FVP)
setup_mpu();
@@ -596,7 +596,6 @@ int32_t boot_platform_init(void)
#if !(PLATFORM_IS_FVP)
setup_host_firewall();
#endif
- add_bank_offset_to_image_offset(bank_offset);
result = FLASH_DEV_NAME.Initialize(NULL);
if (result != ARM_DRIVER_OK) {
@@ -630,6 +629,9 @@ int32_t boot_platform_init(void)
}
}
+ bl1_get_boot_bank(&bank_offset);
+ add_bank_offset_to_image_offset(bank_offset);
+
return 0;
}
diff --git a/platform/ext/target/arm/corstone1000/bl2_boot_hal.c b/platform/ext/target/arm/corstone1000/bl2_boot_hal.c
index 75d2cb60d8..4f5b48a2e0 100644
--- a/platform/ext/target/arm/corstone1000/bl2_boot_hal.c
+++ b/platform/ext/target/arm/corstone1000/bl2_boot_hal.c
@@ -18,6 +18,7 @@
#include <string.h>
#include "tfm_plat_otp.h"
#include "tfm_plat_provisioning.h"
+#include "fwu_agent.h"
#ifdef PLATFORM_PSA_ADAC_SECURE_DEBUG
#include "psa_adac_platform.h"
@@ -112,15 +113,13 @@ int32_t boot_platform_init(void)
{
int32_t result;
enum tfm_plat_err_t plat_err;
- uint32_t bank_offset = BANK_0_PARTITION_OFFSET;
+ uint32_t bank_offset;
result = fill_bl2_flash_map_by_parsing_fips(BANK_0_PARTITION_OFFSET);
if (result) {
return 1;
}
- add_bank_offset_to_image_offset(bank_offset);
-
result = FLASH_DEV_NAME.Initialize(NULL);
if (result != ARM_DRIVER_OK) {
return 1;
@@ -154,6 +153,9 @@ int32_t boot_platform_init(void)
}
#endif
+ bl2_get_boot_bank(&bank_offset);
+ add_bank_offset_to_image_offset(bank_offset);
+
return 0;
}
diff --git a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
index 7fa64db0f7..23a15ee71b 100644
--- a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
+++ b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
@@ -75,8 +75,12 @@ struct fwu_private_metadata {
/* boot_index: the bank from which system is booted from */
uint32_t boot_index;
+ /* counter: tracking number of boot attempted so far */
+ uint32_t boot_attempted;
+
} __packed;
+#define MAX_BOOT_ATTEMPTS_PER_BANK 3
struct fwu_metadata _metadata;
@@ -315,6 +319,7 @@ enum fwu_agent_error_t fwu_metadata_provision(void)
memset(&priv_metadata, 0, sizeof(struct fwu_private_metadata));
priv_metadata.boot_index = BANK_0;
+ priv_metadata.boot_attempted = 0;
ret = private_metadata_write(&priv_metadata);
if (ret) {
@@ -532,3 +537,100 @@ out:
return ret;
}
+void bl1_get_boot_bank(uint32_t *bank_offset)
+{
+ struct fwu_private_metadata priv_metadata;
+ enum fwu_agent_state_t current_state;
+ uint32_t boot_attempted;
+ uint32_t boot_index;
+
+ FWU_LOG_MSG("%s: enter\n\r", __func__);
+
+ if (fwu_metadata_init()) {
+ FWU_ASSERT(0);
+ }
+
+ if (private_metadata_read(&priv_metadata)) {
+ FWU_ASSERT(0);
+ }
+
+ if (metadata_read(&_metadata)) {
+ FWU_ASSERT(0);
+ }
+
+ current_state = get_fwu_agent_state(&_metadata, &priv_metadata);
+
+ if (current_state == FWU_AGENT_STATE_REGULAR) {
+ boot_index = _metadata.active_index;
+ FWU_ASSERT(boot_index == priv_metadata.boot_index);
+ boot_attempted = 0;
+ } else if (current_state == FWU_AGENT_STATE_TRIAL) {
+ boot_attempted = (++priv_metadata.boot_attempted);
+ FWU_LOG_MSG("%s: attempting boot number = %u\n\r",
+ __func__, boot_attempted);
+ if (boot_attempted <= MAX_BOOT_ATTEMPTS_PER_BANK) {
+ boot_index = _metadata.active_index;
+ FWU_LOG_MSG("%s: booting from trial bank: %u\n\r",
+ __func__, boot_index);
+ } else if (boot_attempted <= (2 * MAX_BOOT_ATTEMPTS_PER_BANK)) {
+ boot_index = _metadata.previous_active_index;
+ FWU_LOG_MSG("%s: gave up booting from trial bank\n\r", __func__);
+ FWU_LOG_MSG("%s: booting from previous active bank: %u\n\r",
+ __func__, boot_index);
+ } else {
+ FWU_LOG_MSG("%s: cannot boot system from any bank, halting...\n\r", __func__);
+ FWU_ASSERT(0);
+ }
+ } else {
+ FWU_ASSERT(0);
+ }
+
+ priv_metadata.boot_index = boot_index;
+ if (private_metadata_write(&priv_metadata)) {
+ FWU_ASSERT(0);
+ }
+
+ if (boot_index == BANK_0) {
+ *bank_offset = BANK_0_PARTITION_OFFSET;
+ } else if (boot_index == BANK_1) {
+ *bank_offset = BANK_1_PARTITION_OFFSET;
+ } else {
+ FWU_ASSERT(0);
+ }
+
+ FWU_LOG_MSG("%s: exit: booting from bank = %u, offset = %x\n\r", __func__,
+ boot_index, *bank_offset);
+
+ return;
+}
+
+void bl2_get_boot_bank(uint32_t *bank_offset)
+{
+ uint32_t boot_index;
+ struct fwu_private_metadata priv_metadata;
+ FWU_LOG_MSG("%s: enter\n\r", __func__);
+
+ if (fwu_metadata_init()) {
+ FWU_ASSERT(0);
+ }
+
+ if (private_metadata_read(&priv_metadata)) {
+ FWU_ASSERT(0);
+ }
+
+ boot_index = priv_metadata.boot_index;
+
+ if (boot_index == BANK_0) {
+ *bank_offset = BANK_0_PARTITION_OFFSET;
+ } else if (boot_index == BANK_1) {
+ *bank_offset = BANK_1_PARTITION_OFFSET;
+ } else {
+ FWU_ASSERT(0);
+ }
+
+ FWU_LOG_MSG("%s: exit: booting from bank = %u, offset = %x\n\r", __func__,
+ boot_index, *bank_offset);
+
+ return;
+}
+
diff --git a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h
index f5ab877ef1..389381c326 100644
--- a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h
+++ b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h
@@ -38,5 +38,8 @@ enum fwu_agent_error_t fwu_metadata_init(void);
*/
enum fwu_agent_error_t corstone1000_fwu_flash_image(void);
-#endif /* FWU_AGENT_H */
+void bl1_get_boot_bank(uint32_t *bank_offset);
+void bl2_get_boot_bank(uint32_t *bank_offset);
+
+#endif /* FWU_AGENT_H */
--
2.17.1
@@ -0,0 +1,645 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
From d8c6e41ee040d19748915d2c598df1c4b90a93a8 Mon Sep 17 00:00:00 2001
From: Harry Moulton <harry.moulton@arm.com>
Date: Tue, 5 Oct 2021 12:40:57 +0100
Subject: [PATCH 07/15] corstone1000: integrate watchdog driver
This change integrates and enables the watchdog timer driver
inside the BL1, BL2 and TF-M. SoC and SE watchdogs are enabled,
meaning the system should get reset if software becomes
unresponsive.
Signed-off-by: Harry Moulton <harry.moulton@arm.com>
Change-Id: Iab957a58025aac98140bb71289a269443529e8ed
---
.../target/arm/corstone1000/CMakeLists.txt | 4 +
.../Native_Driver/arm_watchdog_drv.c | 190 ++++++++++++++++++
.../Native_Driver/arm_watchdog_drv.h | 179 +++++++++++++++++
.../arm/corstone1000/Native_Driver/watchdog.c | 81 ++++++++
.../arm/corstone1000/Native_Driver/watchdog.h | 32 +++
.../arm/corstone1000/bl1/CMakeLists.txt | 2 +
.../arm/corstone1000/bl1/bl1_boot_hal.c | 6 +
.../target/arm/corstone1000/bl2_boot_hal.c | 6 +
.../arm/corstone1000/tfm_hal_platform.c | 5 +
9 files changed, 505 insertions(+)
create mode 100644 platform/ext/target/arm/corstone1000/Native_Driver/arm_watchdog_drv.c
create mode 100644 platform/ext/target/arm/corstone1000/Native_Driver/arm_watchdog_drv.h
create mode 100644 platform/ext/target/arm/corstone1000/Native_Driver/watchdog.c
create mode 100644 platform/ext/target/arm/corstone1000/Native_Driver/watchdog.h
diff --git a/platform/ext/target/arm/corstone1000/CMakeLists.txt b/platform/ext/target/arm/corstone1000/CMakeLists.txt
index a2191c835f..cb66bd48d6 100644
--- a/platform/ext/target/arm/corstone1000/CMakeLists.txt
+++ b/platform/ext/target/arm/corstone1000/CMakeLists.txt
@@ -62,6 +62,8 @@ target_sources(platform_s
Device/Source/system_core_init.c
Native_Driver/uart_pl011_drv.c
Native_Driver/mhu_v2_x.c
+ Native_Driver/watchdog.c
+ Native_Driver/arm_watchdog_drv.c
spm_hal.c
tfm_hal_multi_core.c
tfm_hal_isolation.c
@@ -107,6 +109,8 @@ target_sources(platform_bl2
Device/Source/device_definition.c
Device/Source/system_core_init.c
Native_Driver/uart_pl011_drv.c
+ Native_Driver/watchdog.c
+ Native_Driver/arm_watchdog_drv.c
fip_parser/fip_parser.c
bl2_boot_hal.c
fw_update_agent/fwu_agent.c
diff --git a/platform/ext/target/arm/corstone1000/Native_Driver/arm_watchdog_drv.c b/platform/ext/target/arm/corstone1000/Native_Driver/arm_watchdog_drv.c
new file mode 100644
index 0000000000..b6323c99a5
--- /dev/null
+++ b/platform/ext/target/arm/corstone1000/Native_Driver/arm_watchdog_drv.c
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2016-2020 Arm Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "arm_watchdog_drv.h"
+
+/* Watchdog control definitions */
+#define ARM_WATCHDOG_CTRL_INTEN (0x1UL << 0)
+#define ARM_WATCHDOG_CTRL_RESEN (0x1UL << 1)
+#define ARM_WATCHDOG_INTCLR 1UL
+#define ARM_WATCHDOG_RAWINTSTAT 1UL
+#define ARM_WATCHDOG_MASKINTSTAT 1UL
+#define ARM_WATCHDOG_UNLOCK_VALUE 0x1ACCE551
+#define ARM_WATCHDOG_LOCK_VALUE 0x00000001
+#define ARM_WATCHDOG_INTEGTESTEN 1UL
+#define ARM_WATCHDOG_INTEGTESTOUTSET 1UL
+#define ARM_WATCHDOG_MAX_VALUE 0xFFFFFFFF
+
+/* Watchdog state definitions */
+#define ARM_WATCHDOG_INITIALIZED (1ul << 0)
+#define ARM_WATCHDOG_ENABLED (1ul << 1)
+
+/* ARM watchdog memory mapped register access structure */
+struct arm_watchdog_t {
+ volatile uint32_t load; /* Offset: 0x000 (R/W) Load register */
+ volatile uint32_t value; /* Offset: 0x004 (R/ ) Value register */
+ volatile uint32_t ctrl; /* Offset: 0x008 (R/W) Control register */
+ volatile uint32_t intclr; /* Offset: 0x00C ( /W) Clear interrupt
+ * register */
+ volatile uint32_t rawintstat; /* Offset: 0x010 (R/ ) Raw interrupt
+ * status register */
+ volatile uint32_t maskintstat; /* Offset: 0x014 (R/ ) Interrupt status
+ * register */
+ volatile uint32_t reserved0[762];
+ volatile uint32_t lock; /* Offset: 0xC00 (R/W) Lock register */
+ volatile uint32_t reserved1[191];
+ volatile uint32_t itcr; /* Offset: 0xF00 (R/W) Integration test
+ * control register */
+ volatile uint32_t itop; /* Offset: 0xF04 ( /W) Integration Test
+ * output set
+ * register */
+};
+
+void arm_watchdog_init(struct arm_watchdog_dev_t* dev, uint32_t timeout)
+{
+ /*
+ * The init function leaves the watchdog in a clean state:
+ * - initialized;
+ * - disabled;
+ * - locked.
+ */
+ if (arm_watchdog_is_enabled(dev)) {
+ arm_watchdog_unlock(dev);
+ (void)arm_watchdog_disable(dev);
+ }
+ arm_watchdog_lock(dev);
+
+ if (timeout == 0)
+ dev->data->timeout = ARM_WATCHDOG_MAX_VALUE;
+ else
+ dev->data->timeout = timeout;
+
+ dev->data->state = ARM_WATCHDOG_INITIALIZED;
+}
+
+enum arm_watchdog_error_t arm_watchdog_feed(struct arm_watchdog_dev_t* dev)
+{
+ struct arm_watchdog_t* p_wdog = (struct arm_watchdog_t*)dev->cfg->base;
+
+ if (!arm_watchdog_is_enabled(dev))
+ return ARM_WATCHDOG_ERR_NOT_ENAB;
+
+ if (arm_watchdog_is_locked(dev))
+ return ARM_WATCHDOG_ERR_LOCKED;
+
+ p_wdog->load = dev->data->timeout;
+
+ return ARM_WATCHDOG_ERR_NONE;
+}
+
+enum arm_watchdog_error_t
+arm_watchdog_clear_interrupt_and_refresh_counter(struct arm_watchdog_dev_t* dev)
+{
+ struct arm_watchdog_t* p_wdog = (struct arm_watchdog_t*)dev->cfg->base;
+
+ if (!arm_watchdog_is_enabled(dev))
+ return ARM_WATCHDOG_ERR_NOT_ENAB;
+
+ if (arm_watchdog_is_locked(dev))
+ return ARM_WATCHDOG_ERR_LOCKED;
+
+ p_wdog->intclr = ARM_WATCHDOG_INTCLR;
+
+ return ARM_WATCHDOG_ERR_NONE;
+}
+
+enum arm_watchdog_error_t arm_watchdog_enable(struct arm_watchdog_dev_t* dev)
+{
+ struct arm_watchdog_t* p_wdog = (struct arm_watchdog_t*)dev->cfg->base;
+
+ if (!arm_watchdog_is_initialized(dev))
+ return ARM_WATCHDOG_ERR_NOT_INIT;
+
+ if (arm_watchdog_is_locked(dev))
+ return ARM_WATCHDOG_ERR_LOCKED;
+
+ p_wdog->load = dev->data->timeout;
+
+ /* Starts the watchdog counter */
+ p_wdog->ctrl = (ARM_WATCHDOG_CTRL_RESEN | ARM_WATCHDOG_CTRL_INTEN);
+ dev->data->state |= ARM_WATCHDOG_ENABLED;
+
+ return ARM_WATCHDOG_ERR_NONE;
+}
+
+uint32_t arm_watchdog_is_enabled(struct arm_watchdog_dev_t* dev)
+{
+ return (dev->data->state & ARM_WATCHDOG_ENABLED);
+}
+
+enum arm_watchdog_error_t arm_watchdog_disable(struct arm_watchdog_dev_t* dev)
+{
+ struct arm_watchdog_t* p_wdog = (struct arm_watchdog_t*)dev->cfg->base;
+
+ if (!arm_watchdog_is_enabled(dev))
+ return ARM_WATCHDOG_ERR_NOT_ENAB;
+
+ if (arm_watchdog_is_locked(dev))
+ return ARM_WATCHDOG_ERR_LOCKED;
+
+ /* Stops the watchdog */
+ p_wdog->ctrl &= ~(ARM_WATCHDOG_CTRL_RESEN | ARM_WATCHDOG_CTRL_INTEN);
+ dev->data->state &= ~ARM_WATCHDOG_ENABLED;
+
+ return ARM_WATCHDOG_ERR_NONE;
+}
+
+void arm_watchdog_lock(struct arm_watchdog_dev_t* dev)
+{
+ struct arm_watchdog_t* p_wdog = (struct arm_watchdog_t*)dev->cfg->base;
+
+ /* Prevents writing to all of the registers */
+ p_wdog->lock = ARM_WATCHDOG_LOCK_VALUE;
+}
+
+uint32_t arm_watchdog_is_locked(struct arm_watchdog_dev_t* dev)
+{
+ struct arm_watchdog_t* p_wdog = (struct arm_watchdog_t*)dev->cfg->base;
+
+ /* The lock register can only return 0 or 1 when read */
+ return p_wdog->lock;
+}
+
+void arm_watchdog_unlock(struct arm_watchdog_dev_t* dev)
+{
+ struct arm_watchdog_t* p_wdog = (struct arm_watchdog_t*)dev->cfg->base;
+
+ p_wdog->lock = ARM_WATCHDOG_UNLOCK_VALUE;
+}
+
+inline uint32_t arm_watchdog_is_initialized(struct arm_watchdog_dev_t* dev)
+{
+ return (dev->data->state & ARM_WATCHDOG_INITIALIZED);
+}
+
+uint32_t arm_watchdog_get_remaining_time(struct arm_watchdog_dev_t* dev)
+{
+ struct arm_watchdog_t* p_wdog = (struct arm_watchdog_t*)dev->cfg->base;
+
+ if (!arm_watchdog_is_enabled(dev))
+ return 0;
+
+ if (arm_watchdog_is_locked(dev))
+ return 0;
+
+ return p_wdog->value;
+}
+
diff --git a/platform/ext/target/arm/corstone1000/Native_Driver/arm_watchdog_drv.h b/platform/ext/target/arm/corstone1000/Native_Driver/arm_watchdog_drv.h
new file mode 100644
index 0000000000..3b163625f5
--- /dev/null
+++ b/platform/ext/target/arm/corstone1000/Native_Driver/arm_watchdog_drv.h
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2016-2020 ARM Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * \file arm_watchdog_drv.h
+ * \brief Generic driver for ARM watchdogs.
+ */
+
+#ifndef __ARM_WATCHDOG_DRV_H__
+#define __ARM_WATCHDOG_DRV_H__
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum arm_watchdog_error_t {
+ ARM_WATCHDOG_ERR_NONE = 0, /*!< No error */
+ ARM_WATCHDOG_ERR_NOT_INIT, /*!< Watchdog is not initialized */
+ ARM_WATCHDOG_ERR_NOT_ENAB, /*!< Watchdog is not enabled */
+ ARM_WATCHDOG_ERR_LOCKED /*!< Watchdog is locked */
+};
+
+/* ARM watchdog device configuration structure */
+struct arm_watchdog_dev_cfg_t {
+ const uint32_t base; /*!< Watchdog base address */
+};
+
+/* ARM watchdog device data structure */
+struct arm_watchdog_dev_data_t {
+ uint32_t state; /*!< Indicates if the watchdog
+ is initialized and enabled */
+ uint32_t timeout; /*!< Timeout to reset in cycles */
+};
+
+/* ARM watchdog device structure */
+struct arm_watchdog_dev_t {
+ const struct arm_watchdog_dev_cfg_t* const cfg; /*!< Watchdog
+ configuration */
+ struct arm_watchdog_dev_data_t* const data; /*!< Watchdog data */
+};
+
+/**
+ * \brief Initializes a watchdog hardware.
+ *
+ * \param[in] dev Watchdog to be initialized \ref arm_watchdog_dev_t
+ * \param[in] timeout Timeout in cycles - 0 assings timeout to max value.
+ *
+ * \note This function doesn't check if dev is NULL.
+ * This function leaves the watchdog locked. Before any further
+ * operations, it needs to be unlocked and locked again.
+ */
+void arm_watchdog_init(struct arm_watchdog_dev_t* dev, uint32_t timeout);
+
+/**
+ * \brief Feeds the watchdog to not cause a reset.
+ *
+ * \param[in] dev Watchdog to be fed \ref arm_watchdog_dev_t
+ *
+ * \return Returns error code as specified in \ref arm_watchdog_error_t
+ *
+ * \note This function doesn't check if dev is NULL.
+ */
+enum arm_watchdog_error_t arm_watchdog_feed(struct arm_watchdog_dev_t* dev);
+
+/**
+ * \brief Clear the interrupt and load timeout value to the load register.
+ *
+ * \param[in] dev Watchdog to be fed \ref arm_watchdog_dev_t
+ *
+ * \return Returns error code as specified in \ref arm_watchdog_error_t
+ *
+ * \note This function doesn't check if dev is NULL.
+ */
+enum arm_watchdog_error_t
+arm_watchdog_clear_interrupt_and_refresh_counter(
+ struct arm_watchdog_dev_t* dev);
+
+/**
+ * \brief Enables the watchdog.
+ *
+ * \param[in] dev Watchdog to be enabled \ref arm_watchdog_dev_t
+ *
+ * \return Returns error code as specified in \ref arm_watchdog_error_t
+ *
+ * \note This function doesn't check if dev is NULL.
+ */
+enum arm_watchdog_error_t arm_watchdog_enable(struct arm_watchdog_dev_t* dev);
+
+/**
+ * \brief Checks if the watchdog is enabled
+ *
+ * \param[in] dev Watchdog to be checked \ref arm_watchdog_dev_t
+ *
+ * \return 1 if watchdog is enabled, 0 otherwise.
+ *
+ * \note This function doesn't check if dev is NULL.
+ */
+uint32_t arm_watchdog_is_enabled(struct arm_watchdog_dev_t* dev);
+
+/**
+ * \brief Disables the watchdog.
+ *
+ * \param[in] dev Watchdog to be disabled \ref arm_watchdog_dev_t
+ *
+ * \return 1 if watchdog is enabled, 0 otherwise.
+ *
+ * \note This function doesn't check if dev is NULL.
+ */
+enum arm_watchdog_error_t arm_watchdog_disable(struct arm_watchdog_dev_t* dev);
+
+/**
+ * \brief Locks the registers to not be written again.
+ *
+ * \param[in] dev Watchdog to be locked \ref arm_watchdog_dev_t
+ *
+ * \note This function doesn't check if dev is NULL.
+ */
+void arm_watchdog_lock(struct arm_watchdog_dev_t* dev);
+
+/**
+ * \brief Checks if the watchdog registers are locked
+ *
+ * \param[in] dev Watchdog to be checked \ref arm_watchdog_dev_t
+ *
+ * \return 1 if the registers are locked, 0 otherwise
+ *
+ * \note This function doesn't check if dev is NULL.
+ */
+uint32_t arm_watchdog_is_locked(struct arm_watchdog_dev_t* dev);
+
+/**
+ * \brief Unlocks the registers to configure the watchdog again.
+ *
+ * \param[in] dev Watchdog to be unlocked \ref arm_watchdog_dev_t
+ *
+ * \note This function doesn't check if dev is NULL.
+ */
+void arm_watchdog_unlock(struct arm_watchdog_dev_t* dev);
+
+/**
+ * \brief Gets if watchdog driver is initialized
+ *
+ * \param[in] dev Watchdog to be initialized \ref arm_watchdog_dev_t
+ *
+ * \returns 1 if watchdog driver is initialized. Otherwise 0.
+ */
+uint32_t arm_watchdog_is_initialized(struct arm_watchdog_dev_t* dev);
+
+/**
+ * \brief Provides watchdog remaining time before reset.
+ *
+ * \param[in] dev Watchdog to get the remaining time \ref arm_watchdog_dev_t
+ *
+ * \return 0 if watchdog is disabled.
+ *
+ * \note This function doesn't check if dev is NULL.
+ */
+uint32_t arm_watchdog_get_remaining_time(struct arm_watchdog_dev_t* dev);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __ARM_WATCHDOG_DRV_H__ */
+
diff --git a/platform/ext/target/arm/corstone1000/Native_Driver/watchdog.c b/platform/ext/target/arm/corstone1000/Native_Driver/watchdog.c
new file mode 100644
index 0000000000..d375af3afb
--- /dev/null
+++ b/platform/ext/target/arm/corstone1000/Native_Driver/watchdog.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2019-2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include "watchdog.h"
+
+#include "arm_watchdog_drv.h"
+#include "platform_base_address.h"
+#include "Driver_Common.h"
+#include "cmsis.h"
+#include <stdio.h>
+
+/* SoC watchdog config */
+struct arm_watchdog_dev_cfg_t SOC_WD_DEV_CFG = {CORSTONE1000_SOC_WATCHDOG_BASE};
+struct arm_watchdog_dev_data_t SOC_WD_DEV_DATA;
+struct arm_watchdog_dev_t SOC_WD_DEV = {&SOC_WD_DEV_CFG, &SOC_WD_DEV_DATA};
+#define SOC_WD_TIMEOUT 0x00030000
+
+/* SE watchdog config */
+struct arm_watchdog_dev_cfg_t SE_WD_DEV_CFG = {CORSTONE1000_WATCHDOG_TIMER_BASE};
+struct arm_watchdog_dev_data_t SE_WD_DEV_DATA;
+struct arm_watchdog_dev_t SE_WD_DEV = {&SE_WD_DEV_CFG, &SE_WD_DEV_DATA};
+#define SE_WD_TIMEOUT 0x0FFFFFFF
+#define SE_WD_IRQn SE_WATCHDOG_TIMER_IRQn
+
+
+/* SoC watchdog */
+void NMI_Handler(void)
+{
+ /* Unlock, clear and lock the watchdog timer */
+ arm_watchdog_unlock(&SOC_WD_DEV);
+ arm_watchdog_clear_interrupt_and_refresh_counter(&SOC_WD_DEV);
+ arm_watchdog_lock(&SOC_WD_DEV);
+}
+
+/* SE watchdog */
+void SE_WATCHDOG_TIMER_IRQHandler(void)
+{
+ /* Unlock, clear and lock the watchdog timer */
+ arm_watchdog_unlock(&SE_WD_DEV);
+ arm_watchdog_clear_interrupt_and_refresh_counter(&SE_WD_DEV);
+ arm_watchdog_lock(&SE_WD_DEV);
+}
+
+int corstone1000_watchdog_init()
+{
+ __disable_irq();
+
+ /* SoC Watchdog setup */
+ arm_watchdog_init(&SOC_WD_DEV, SOC_WD_TIMEOUT);
+ arm_watchdog_unlock(&SOC_WD_DEV);
+ arm_watchdog_enable(&SOC_WD_DEV);
+ arm_watchdog_lock(&SOC_WD_DEV);
+
+ if (!arm_watchdog_is_initialized(&SOC_WD_DEV))
+ return ARM_DRIVER_ERROR_UNSUPPORTED;
+
+ if (!arm_watchdog_is_enabled(&SOC_WD_DEV))
+ return ARM_DRIVER_ERROR_UNSUPPORTED;
+
+ /* SE Watchdog setup */
+ arm_watchdog_init(&SE_WD_DEV, SE_WD_TIMEOUT);
+ arm_watchdog_unlock(&SE_WD_DEV);
+ arm_watchdog_enable(&SE_WD_DEV);
+ arm_watchdog_lock(&SE_WD_DEV);
+
+ NVIC_EnableIRQ(SE_WD_IRQn);
+
+ if (!arm_watchdog_is_initialized(&SE_WD_DEV))
+ return ARM_DRIVER_ERROR_UNSUPPORTED;
+
+ if (!arm_watchdog_is_enabled(&SE_WD_DEV))
+ return ARM_DRIVER_ERROR_UNSUPPORTED;
+
+ __enable_irq();
+
+ return ARM_DRIVER_OK;
+}
diff --git a/platform/ext/target/arm/corstone1000/Native_Driver/watchdog.h b/platform/ext/target/arm/corstone1000/Native_Driver/watchdog.h
new file mode 100644
index 0000000000..fd1b7cf124
--- /dev/null
+++ b/platform/ext/target/arm/corstone1000/Native_Driver/watchdog.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2019-2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef WATCHDOG_H
+#define WATCHDOG_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "Driver_Common.h"
+#include "arm_watchdog_drv.h"
+#include "platform_base_address.h"
+
+/**
+ * \brief Initializes Secure Enclave & SoC Watchdog.
+ *
+ * \returns ARM Driver return code.
+ */
+int corstone1000_watchdog_init();
+
+/**
+ * \brief Reset the Secure Enclave & SoC Watchdog's.
+ *
+ * \returns ARM Driver return code.
+ */
+int corstone1000_watchdog_reset_timer();
+
+#endif /* watchdog_h */
diff --git a/platform/ext/target/arm/corstone1000/bl1/CMakeLists.txt b/platform/ext/target/arm/corstone1000/bl1/CMakeLists.txt
index 92a78c1168..1737fbee91 100644
--- a/platform/ext/target/arm/corstone1000/bl1/CMakeLists.txt
+++ b/platform/ext/target/arm/corstone1000/bl1/CMakeLists.txt
@@ -239,6 +239,8 @@ target_sources(bl1_main
../Native_Driver/firewall.c
../Native_Driver/uart_pl011_drv.c
../fw_update_agent/fwu_agent.c
+ ../Native_Driver/arm_watchdog_drv.c
+ ../Native_Driver/watchdog.c
bl1_boot_hal.c
bl1_flash_map.c
bl1_security_cnt.c
diff --git a/platform/ext/target/arm/corstone1000/bl1/bl1_boot_hal.c b/platform/ext/target/arm/corstone1000/bl1/bl1_boot_hal.c
index 2af5b8c846..edde6fb24e 100644
--- a/platform/ext/target/arm/corstone1000/bl1/bl1_boot_hal.c
+++ b/platform/ext/target/arm/corstone1000/bl1/bl1_boot_hal.c
@@ -14,6 +14,7 @@
#include "bootutil/fault_injection_hardening.h"
#include "bootutil/bootutil_log.h"
#include "firewall.h"
+#include "watchdog.h"
#include "mpu_config.h"
#include "tfm_plat_otp.h"
#include "tfm_plat_provisioning.h"
@@ -589,6 +590,11 @@ int32_t boot_platform_init(void)
int32_t result;
uint32_t bank_offset;
+ result = corstone1000_watchdog_init();
+ if (result != ARM_DRIVER_OK) {
+ return 1;
+ }
+
#if !(PLATFORM_IS_FVP)
setup_mpu();
#endif
diff --git a/platform/ext/target/arm/corstone1000/bl2_boot_hal.c b/platform/ext/target/arm/corstone1000/bl2_boot_hal.c
index 4f5b48a2e0..5c6b78ffb3 100644
--- a/platform/ext/target/arm/corstone1000/bl2_boot_hal.c
+++ b/platform/ext/target/arm/corstone1000/bl2_boot_hal.c
@@ -15,6 +15,7 @@
#include "bootutil/bootutil_log.h"
#include "fip_parser.h"
#include "flash_map/flash_map.h"
+#include "watchdog.h"
#include <string.h>
#include "tfm_plat_otp.h"
#include "tfm_plat_provisioning.h"
@@ -115,6 +116,11 @@ int32_t boot_platform_init(void)
enum tfm_plat_err_t plat_err;
uint32_t bank_offset;
+ result = corstone1000_watchdog_init();
+ if (result != ARM_DRIVER_OK) {
+ return 1;
+ }
+
result = fill_bl2_flash_map_by_parsing_fips(BANK_0_PARTITION_OFFSET);
if (result) {
return 1;
diff --git a/platform/ext/target/arm/corstone1000/tfm_hal_platform.c b/platform/ext/target/arm/corstone1000/tfm_hal_platform.c
index 0072b5b928..7faa71eb63 100644
--- a/platform/ext/target/arm/corstone1000/tfm_hal_platform.c
+++ b/platform/ext/target/arm/corstone1000/tfm_hal_platform.c
@@ -9,12 +9,17 @@
#include "tfm_hal_platform.h"
#include "uart_stdout.h"
#include "fwu_agent.h"
+#include "watchdog.h"
enum tfm_hal_status_t tfm_hal_platform_init(void)
{
__enable_irq();
stdio_init();
+ if (corstone1000_watchdog_init()) {
+ return TFM_HAL_ERROR_GENERIC;
+ }
+
if (fwu_metadata_init()) {
return TFM_HAL_ERROR_GENERIC;
}
--
2.17.1
@@ -0,0 +1,119 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
From 9b2b4e284d36d0433f5aa0af6f13e7eda5c783c0 Mon Sep 17 00:00:00 2001
From: Satish Kumar <satish.kumar01@arm.com>
Date: Thu, 14 Oct 2021 05:08:04 +0100
Subject: [PATCH 08/15] corstone1000: impelment accept image logic
Until all new images in the update/trial bank is accepted,
the firmware update state of the system remains in the trial
state. The state changes automatically to regular state when
all new images in the trial bank is accepted.
This commit adds the logic to accept one of the image type.
Change-Id: I1f18d77b185f2e5dd26d6e02bed792689019b7b8
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
---
.../corstone1000/fw_update_agent/fwu_agent.c | 70 +++++++++++++++++++
.../services/src/tfm_platform_system.c | 2 +-
2 files changed, 71 insertions(+), 1 deletion(-)
diff --git a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
index 23a15ee71b..a70638e993 100644
--- a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
+++ b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
@@ -537,6 +537,76 @@ out:
return ret;
}
+static enum fwu_agent_error_t accept_full_capsule(
+ struct fwu_metadata* metadata,
+ struct fwu_private_metadata* priv_metadata)
+{
+ uint32_t active_index = metadata->active_index;
+ enum fwu_agent_error_t ret;
+
+ FWU_LOG_MSG("%s: enter\n\r", __func__);
+
+ for (int i = 0; i < NR_OF_IMAGES_IN_FW_BANK; i++) {
+ metadata->img_entry[i].img_props[active_index].accepted =
+ IMAGE_ACCEPTED;
+ }
+
+ priv_metadata->boot_attempted = 0;
+
+ ret = private_metadata_write(priv_metadata);
+ if (ret) {
+ return ret;
+ }
+
+ ret = metadata_write(metadata);
+ if (ret) {
+ return ret;
+ }
+
+ FWU_LOG_MSG("%s: exit: fwu state is changed to regular\n\r", __func__);
+ return FWU_AGENT_SUCCESS;
+}
+
+static enum fwu_agent_error_t fwu_accept_image(struct efi_guid* guid,
+ struct fwu_metadata *metadata,
+ struct fwu_private_metadata *priv_metadata)
+{
+ enum fwu_agent_state_t current_state;
+ int image_index;
+ uint32_t image_bank_offset;
+ enum fwu_agent_error_t ret;
+
+ FWU_LOG_MSG("%s: enter\n\r", __func__);
+
+ /* it is expected to receive this call only when
+ in trial state */
+ current_state = get_fwu_agent_state(metadata, priv_metadata);
+ if (current_state != FWU_AGENT_STATE_TRIAL) {
+ return FWU_AGENT_ERROR;
+ }
+
+ /* booted from previous_active_bank, not expected
+ * to receive this call in this state, rather host should
+ * call corstone1000_fwu_select_previous */
+ if (metadata->active_index != priv_metadata->boot_index) {
+ return FWU_AGENT_ERROR;
+ }
+
+ image_index = get_image_info_in_bank(guid, &image_bank_offset);
+ switch(image_index) {
+ case IMAGE_ALL:
+ ret = accept_full_capsule(metadata, priv_metadata);
+ break;
+ default:
+ FWU_LOG_MSG("%s: sent image not recognized\n\r", __func__);
+ ret = FWU_AGENT_ERROR;
+ break;
+ }
+
+ FWU_LOG_MSG("%s: exit: ret = %d\n\r", __func__, ret);
+ return ret;
+}
+
void bl1_get_boot_bank(uint32_t *bank_offset)
{
struct fwu_private_metadata priv_metadata;
diff --git a/platform/ext/target/arm/corstone1000/services/src/tfm_platform_system.c b/platform/ext/target/arm/corstone1000/services/src/tfm_platform_system.c
index f9629a1688..16ad975c32 100644
--- a/platform/ext/target/arm/corstone1000/services/src/tfm_platform_system.c
+++ b/platform/ext/target/arm/corstone1000/services/src/tfm_platform_system.c
@@ -21,7 +21,7 @@ enum tfm_platform_err_t tfm_platform_hal_ioctl(tfm_platform_ioctl_req_t request,
psa_outvec *out_vec)
{
int32_t ret = TFM_PLATFORM_ERR_SUCCESS;
- const corstone1000_ioctl_in_params_t *in_params =
+ corstone1000_ioctl_in_params_t *in_params =
(corstone1000_ioctl_in_params_t *)in_vec->base;
corstone1000_ioctl_out_params_t *out_params = (corstone1000_ioctl_out_params_t *)out_vec->base;
--
2.17.1
@@ -0,0 +1,91 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
From a565999300cf5d40c772d3ff29e2020b786a2a10 Mon Sep 17 00:00:00 2001
From: Satish Kumar <satish.kumar01@arm.com>
Date: Sat, 16 Oct 2021 09:07:17 +0100
Subject: [PATCH 09/15] corstone1000: implement select previous bank logic
When firmware update process is not successful, the commit logic
reverts the system state to previous active bank. With this,
the state of the system also changes from the trial to regular
state. System gets reverted back to its previous known good state.
Change-Id: I265635ea984ae9542518a0e389c98e1242e78d10
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
---
.../corstone1000/fw_update_agent/fwu_agent.c | 58 +++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
index a70638e993..89f0a08eb5 100644
--- a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
+++ b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
@@ -607,6 +607,64 @@ static enum fwu_agent_error_t fwu_accept_image(struct efi_guid* guid,
return ret;
}
+static enum fwu_agent_error_t fwu_select_previous(
+ struct fwu_metadata *metadata,
+ struct fwu_private_metadata *priv_metadata)
+{
+ enum fwu_agent_error_t ret;
+ enum fwu_agent_state_t current_state;
+ uint32_t index;
+
+ FWU_LOG_MSG("%s: enter\n\r", __func__);
+
+ /* it is expected to receive this call only when
+ in trial state */
+ current_state = get_fwu_agent_state(metadata, priv_metadata);
+ if (current_state != FWU_AGENT_STATE_TRIAL) {
+ return FWU_AGENT_ERROR;
+ }
+
+ /* not expected to receive this call in this state, system
+ * did not boot from previous active index */
+ if (metadata->previous_active_index != priv_metadata->boot_index) {
+ return FWU_AGENT_ERROR;
+ }
+
+ FWU_LOG_MSG("%s: trial state: active index = %u, previous active = %u\n\r",
+ __func__, metadata->active_index, metadata->previous_active_index);
+
+ index = metadata->previous_active_index;
+ for (int i = 0; i < NR_OF_IMAGES_IN_FW_BANK; i++) {
+ if (metadata->img_entry[i].img_props[index].accepted != IMAGE_ACCEPTED)
+ {
+ FWU_ASSERT(0);
+ }
+ }
+
+ index = metadata->active_index;
+ metadata->active_index = metadata->previous_active_index;
+ metadata->previous_active_index = index;
+
+ priv_metadata->boot_attempted = 0;
+
+ ret = private_metadata_write(priv_metadata);
+ if (ret) {
+ return ret;
+ }
+
+ ret = metadata_write(metadata);
+ if (ret) {
+ return ret;
+ }
+
+ FWU_LOG_MSG("%s: in regular state by choosing previous active bank\n\r",
+ __func__);
+
+ FWU_LOG_MSG("%s: exit: ret = %d\n\r", __func__, ret);
+ return ret;
+
+}
+
void bl1_get_boot_bank(uint32_t *bank_offset)
{
struct fwu_private_metadata priv_metadata;
--
2.17.1
@@ -0,0 +1,136 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
From 0a4c27173e9ac31e6bfe424b6856c4dc612e247a Mon Sep 17 00:00:00 2001
From: Satish Kumar <satish.kumar01@arm.com>
Date: Tue, 16 Nov 2021 04:56:52 +0000
Subject: [PATCH 10/15] corstone1000: implement corstone1000_fwu_host_ack
The host uses the api 'corstone1000_fwu_host_ack' to acknowledge its
successful boot to the secure enclave. Based on the fwu state of
the system, the secure enalve decides where to move in the fwu state
machine. If in regular state, there is nothing to be done. If in
trial state and firmware update is a success, state moves to regular
by accepting images in the trial/update bank. Finaly if in trial
state and firmware update is a failure, state moves to regular by
reverting to previous known state.
Change-Id: I16657537909916bd19520eac3899501fdb14ecb4
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
---
.../corstone1000/fw_update_agent/fwu_agent.c | 47 +++++++++++++++++++
.../corstone1000/fw_update_agent/fwu_agent.h | 5 ++
.../services/src/tfm_platform_system.c | 14 +++++-
3 files changed, 64 insertions(+), 2 deletions(-)
diff --git a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
index 89f0a08eb5..5e87fd8d5e 100644
--- a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
+++ b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
@@ -762,3 +762,50 @@ void bl2_get_boot_bank(uint32_t *bank_offset)
return;
}
+enum fwu_agent_error_t corstone1000_fwu_host_ack(void)
+{
+ enum fwu_agent_error_t ret;
+ struct fwu_private_metadata priv_metadata;
+ enum fwu_agent_state_t current_state;
+
+ FWU_LOG_MSG("%s: enter\n\r", __func__);
+
+ if (!is_initialized) {
+ return FWU_AGENT_ERROR;
+ }
+
+ Select_Write_Mode_For_Shared_Flash();
+
+ if (metadata_read(&_metadata)) {
+ ret = FWU_AGENT_ERROR;
+ goto out;
+ }
+
+ if (private_metadata_read(&priv_metadata)) {
+ ret = FWU_AGENT_ERROR;
+ goto out;
+ }
+
+ current_state = get_fwu_agent_state(&_metadata, &priv_metadata);
+ if (current_state == FWU_AGENT_STATE_REGULAR) {
+ ret = FWU_AGENT_SUCCESS; /* nothing to be done */
+ goto out;
+ } else if (current_state != FWU_AGENT_STATE_TRIAL) {
+ FWU_ASSERT(0);
+ }
+
+ if (_metadata.active_index != priv_metadata.boot_index) {
+ /* firmware update failed, revert back to previous bank */
+ ret = fwu_select_previous(&_metadata, &priv_metadata);
+ } else {
+ /* firmware update successful */
+ ret = fwu_accept_image(&full_capsule_image_guid, &_metadata,
+ &priv_metadata);
+ }
+
+out:
+ Select_XIP_Mode_For_Shared_Flash();
+
+ FWU_LOG_MSG("%s: exit: ret = %d\n\r", __func__, ret);
+ return ret;
+}
diff --git a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h
index 389381c326..b8f7c676d7 100644
--- a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h
+++ b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h
@@ -38,6 +38,11 @@ enum fwu_agent_error_t fwu_metadata_init(void);
*/
enum fwu_agent_error_t corstone1000_fwu_flash_image(void);
+/* host to secure enclave:
+ * host responds with this api to acknowledge its successful
+ * boot.
+ */
+enum fwu_agent_error_t corstone1000_fwu_host_ack(void);
void bl1_get_boot_bank(uint32_t *bank_offset);
void bl2_get_boot_bank(uint32_t *bank_offset);
diff --git a/platform/ext/target/arm/corstone1000/services/src/tfm_platform_system.c b/platform/ext/target/arm/corstone1000/services/src/tfm_platform_system.c
index 16ad975c32..068234dcda 100644
--- a/platform/ext/target/arm/corstone1000/services/src/tfm_platform_system.c
+++ b/platform/ext/target/arm/corstone1000/services/src/tfm_platform_system.c
@@ -21,20 +21,30 @@ enum tfm_platform_err_t tfm_platform_hal_ioctl(tfm_platform_ioctl_req_t request,
psa_outvec *out_vec)
{
int32_t ret = TFM_PLATFORM_ERR_SUCCESS;
+
corstone1000_ioctl_in_params_t *in_params =
- (corstone1000_ioctl_in_params_t *)in_vec->base;
- corstone1000_ioctl_out_params_t *out_params = (corstone1000_ioctl_out_params_t *)out_vec->base;
+ (corstone1000_ioctl_in_params_t *)in_vec->base;
+
+ corstone1000_ioctl_out_params_t *out_params =
+ (corstone1000_ioctl_out_params_t *)out_vec->base;
switch(in_params->ioctl_id) {
+
case IOCTL_CORSTONE1000_FWU_FLASH_IMAGES:
out_params->result = corstone1000_fwu_flash_image();
if (!out_params->result) {
NVIC_SystemReset();
}
break;
+
+ case IOCTL_CORSTONE1000_FWU_HOST_ACK:
+ out_params->result = corstone1000_fwu_host_ack();
+ break;
+
default:
ret = TFM_PLATFORM_ERR_NOT_SUPPORTED;
break;
+
}
return ret;
--
2.17.1
@@ -0,0 +1,39 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
From 35ab33099d7b091630ec677cbad57abd60105f91 Mon Sep 17 00:00:00 2001
From: Satish Kumar <satish.kumar01@arm.com>
Date: Sun, 14 Nov 2021 11:49:11 +0000
Subject: [PATCH 11/15] SPM: multiple core: initailize multi-core communication
before the non-secure core is out of rest
Tf-m should be ready to receive the communication before non-secure
has been taken out of rest.
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
Change-Id: I0b609fffbed0fc2f09b521389fd50f4e992ad00d
---
secure_fw/spm/cmsis_psa/tfm_multi_core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/secure_fw/spm/cmsis_psa/tfm_multi_core.c b/secure_fw/spm/cmsis_psa/tfm_multi_core.c
index f830a6f5f7..946d1a60eb 100644
--- a/secure_fw/spm/cmsis_psa/tfm_multi_core.c
+++ b/secure_fw/spm/cmsis_psa/tfm_multi_core.c
@@ -25,11 +25,11 @@ void tfm_nspm_thread_entry(void)
SPMLOG_DBGMSG("Enabling non-secure core...");
#endif
+ tfm_inter_core_comm_init();
+
tfm_hal_boot_ns_cpu(tfm_spm_hal_get_ns_VTOR());
tfm_hal_wait_for_ns_cpu_ready();
- tfm_inter_core_comm_init();
-
/*
* TODO
* The infinite-loop can be replaced with platform-specific low-power sleep
--
2.17.1
@@ -0,0 +1,169 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
From 1a891fc818526bfb8b546c86a93b81353330a466 Mon Sep 17 00:00:00 2001
From: Satish Kumar <satish.kumar01@arm.com>
Date: Mon, 8 Nov 2021 18:10:44 +0000
Subject: [PATCH 12/15] corstone1000: implement timer to track host progress
When in fwu trial state, the secure enclave starts the timer to
keep track of host progress. Secure enclave expects that the host
acknowledges before the timer expires. If host fails to do so,
the secure enclave resets the system.
Change-Id: Ib63778b6c813f1b0d3517e0c05226d6f88927b04
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
---
.../corstone1000/fw_update_agent/fwu_agent.c | 78 +++++++++++++++++++
.../corstone1000/fw_update_agent/fwu_agent.h | 7 ++
.../arm/corstone1000/tfm_hal_multi_core.c | 5 +-
3 files changed, 89 insertions(+), 1 deletion(-)
diff --git a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
index 5e87fd8d5e..e8686704b8 100644
--- a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
+++ b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
@@ -15,6 +15,7 @@
#include "uefi_capsule_parser.h"
#include "flash_common.h"
#include "platform_base_address.h"
+#include "platform_description.h"
/* Properties of image in a bank */
struct fwu_image_properties {
@@ -127,6 +128,8 @@ struct efi_guid full_capsule_image_guid = {
/* Import the CMSIS flash device driver */
extern ARM_DRIVER_FLASH FWU_METADATA_FLASH_DEV;
+#define HOST_ACK_TIMEOUT_SEC (6 * 60) /* ~seconds, not exact */
+
static enum fwu_agent_error_t private_metadata_read(
struct fwu_private_metadata* p_metadata)
{
@@ -762,6 +765,13 @@ void bl2_get_boot_bank(uint32_t *bank_offset)
return;
}
+static void disable_host_ack_timer(void)
+{
+ FWU_LOG_MSG("%s: timer to reset is disabled\n\r", __func__);
+ SysTick->CTRL &= (~SysTick_CTRL_ENABLE_Msk);
+}
+
+
enum fwu_agent_error_t corstone1000_fwu_host_ack(void)
{
enum fwu_agent_error_t ret;
@@ -803,9 +813,77 @@ enum fwu_agent_error_t corstone1000_fwu_host_ack(void)
&priv_metadata);
}
+ if (ret == FWU_AGENT_SUCCESS) {
+ disable_host_ack_timer();
+ }
+
out:
Select_XIP_Mode_For_Shared_Flash();
FWU_LOG_MSG("%s: exit: ret = %d\n\r", __func__, ret);
return ret;
}
+
+static int systic_counter = 0;
+
+void SysTick_Handler(void)
+{
+ systic_counter++;
+ if ((systic_counter % 10) == 0) {
+ FWU_LOG_MSG("%s: counted = %d, expiring on = %u\n\r", __func__,
+ systic_counter, HOST_ACK_TIMEOUT_SEC);
+ }
+ if (systic_counter == HOST_ACK_TIMEOUT_SEC) {
+ FWU_LOG_MSG("%s, timer expired, reseting the system\n\r", __func__);
+ NVIC_SystemReset();
+ }
+}
+
+/* When in trial state, start the timer for host to respond.
+ * Diable timer when host responds back either by calling
+ * corstone1000_fwu_accept_image or corstone1000_fwu_select_previous.
+ * Otherwise, resets the system.
+ */
+void host_acknowledgement_timer_to_reset(void)
+{
+ struct fwu_private_metadata priv_metadata;
+ enum fwu_agent_state_t current_state;
+ uint32_t boot_attempted;
+ uint32_t boot_index;
+
+ FWU_LOG_MSG("%s: enter\n\r", __func__);
+
+ Select_Write_Mode_For_Shared_Flash();
+
+ if (!is_initialized) {
+ FWU_ASSERT(0);
+ }
+
+ if (private_metadata_read(&priv_metadata)) {
+ FWU_ASSERT(0);
+ }
+
+ if (metadata_read(&_metadata)) {
+ FWU_ASSERT(0);
+ }
+
+ Select_XIP_Mode_For_Shared_Flash();
+
+ current_state = get_fwu_agent_state(&_metadata, &priv_metadata);
+
+ if (current_state == FWU_AGENT_STATE_TRIAL) {
+ FWU_LOG_MSG("%s: in trial state, starting host ack timer\n\r",
+ __func__);
+ systic_counter = 0;
+ if (SysTick_Config(SysTick_LOAD_RELOAD_Msk)) {
+ FWU_LOG_MSG("%s: timer init failed\n\r", __func__);
+ FWU_ASSERT(0);
+ } else {
+ FWU_LOG_MSG("%s: timer started: seconds to expire : %u\n\r",
+ __func__, HOST_ACK_TIMEOUT_SEC);
+ }
+ }
+
+ FWU_LOG_MSG("%s: exit\n\r", __func__);
+ return;
+}
diff --git a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h
index b8f7c676d7..80f72e2bd6 100644
--- a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h
+++ b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h
@@ -47,4 +47,11 @@ enum fwu_agent_error_t corstone1000_fwu_host_ack(void);
void bl1_get_boot_bank(uint32_t *bank_offset);
void bl2_get_boot_bank(uint32_t *bank_offset);
+/* When in trial state, start the timer for host to respond.
+ * Diable timer when host responds back either by calling
+ * corstone1000_fwu_accept_image or corstone1000_fwu_select_previous.
+ * Otherwise, resets the system.
+ */
+void host_acknowledgement_timer_to_reset(void);
+
#endif /* FWU_AGENT_H */
diff --git a/platform/ext/target/arm/corstone1000/tfm_hal_multi_core.c b/platform/ext/target/arm/corstone1000/tfm_hal_multi_core.c
index 834ebc33e3..cc94055b94 100644
--- a/platform/ext/target/arm/corstone1000/tfm_hal_multi_core.c
+++ b/platform/ext/target/arm/corstone1000/tfm_hal_multi_core.c
@@ -56,7 +56,10 @@ void tfm_hal_boot_ns_cpu(uintptr_t start_addr)
void tfm_hal_wait_for_ns_cpu_ready(void)
{
- /* Synchronization between Host and SE is done by OpenAMP */
+ /* start the reset timer if firwmare update process is ongoing */
+#if !(PLATFORM_IS_FVP)
+ host_acknowledgement_timer_to_reset();
+#endif
}
void tfm_hal_get_mem_security_attr(const void *p, size_t s,
--
2.17.1
@@ -0,0 +1,369 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
From eb02f01cd9095f11bbd737db8b1723358e463d73 Mon Sep 17 00:00:00 2001
From: Satish Kumar <satish.kumar01@arm.com>
Date: Wed, 17 Nov 2021 07:30:26 +0000
Subject: [PATCH 13/15] corstone1000: fwu nv-counter anti-rollback support
The patch implements anti-rollback protection on the nv-counters.
The nv-counters are staged onto the flash, and only updated when
firmware update process is successful. Before update, one more
time verification is performed.
Change-Id: Ibe9df7f65c7aecdb9d712bd76c4dbff4e8fd1023
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
---
.../target/arm/corstone1000/CMakeLists.txt | 1 +
.../arm/corstone1000/bl1/bl1_security_cnt.c | 20 ++-
.../arm/corstone1000/bl2_security_cnt.c | 114 ++++++++++++++++++
.../ext/target/arm/corstone1000/config.cmake | 2 +
.../corstone1000/fw_update_agent/fwu_agent.c | 95 +++++++++++++++
.../corstone1000/fw_update_agent/fwu_agent.h | 16 +++
6 files changed, 245 insertions(+), 3 deletions(-)
create mode 100644 platform/ext/target/arm/corstone1000/bl2_security_cnt.c
diff --git a/platform/ext/target/arm/corstone1000/CMakeLists.txt b/platform/ext/target/arm/corstone1000/CMakeLists.txt
index cb66bd48d6..7b1ee53b15 100644
--- a/platform/ext/target/arm/corstone1000/CMakeLists.txt
+++ b/platform/ext/target/arm/corstone1000/CMakeLists.txt
@@ -114,6 +114,7 @@ target_sources(platform_bl2
fip_parser/fip_parser.c
bl2_boot_hal.c
fw_update_agent/fwu_agent.c
+ bl2_security_cnt.c
)
if (PLATFORM_IS_FVP)
diff --git a/platform/ext/target/arm/corstone1000/bl1/bl1_security_cnt.c b/platform/ext/target/arm/corstone1000/bl1/bl1_security_cnt.c
index f275cbfecb..e56defa09a 100644
--- a/platform/ext/target/arm/corstone1000/bl1/bl1_security_cnt.c
+++ b/platform/ext/target/arm/corstone1000/bl1/bl1_security_cnt.c
@@ -10,6 +10,8 @@
#include "tfm_plat_defs.h"
#include "bootutil/fault_injection_hardening.h"
#include <stdint.h>
+#include "tfm_plat_provisioning.h"
+#include "fwu_agent.h"
fih_int boot_nv_security_counter_init(void)
{
@@ -47,14 +49,26 @@ int32_t boot_nv_security_counter_update(uint32_t image_id,
uint32_t img_security_cnt)
{
enum tfm_plat_err_t err;
+ enum fwu_agent_error_t fwu_err;
if (image_id != 0) {
return -1;
}
- err = tfm_plat_set_nv_counter(PLAT_NV_COUNTER_BL1_0, img_security_cnt);
- if (err != TFM_PLAT_ERR_SUCCESS) {
- return -1;
+ if (tfm_plat_provisioning_is_required()) {
+
+ err = tfm_plat_set_nv_counter(PLAT_NV_COUNTER_BL1_0, img_security_cnt);
+ if (err != TFM_PLAT_ERR_SUCCESS) {
+ return -1;
+ }
+
+ } else {
+
+ fwu_err = fwu_stage_nv_counter(FWU_BL2_NV_COUNTER, img_security_cnt);
+ if (fwu_err != FWU_AGENT_SUCCESS) {
+ return -1;
+ }
+
}
return 0;
diff --git a/platform/ext/target/arm/corstone1000/bl2_security_cnt.c b/platform/ext/target/arm/corstone1000/bl2_security_cnt.c
new file mode 100644
index 0000000000..adb0c13039
--- /dev/null
+++ b/platform/ext/target/arm/corstone1000/bl2_security_cnt.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2019-2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include "bootutil/security_cnt.h"
+#include "tfm_plat_nv_counters.h"
+#include "tfm_plat_defs.h"
+#include "bootutil/fault_injection_hardening.h"
+#include <stdint.h>
+#include "tfm_plat_provisioning.h"
+#include "fwu_agent.h"
+
+#define TFM_BOOT_NV_COUNTER_0 PLAT_NV_COUNTER_BL2_0 /* NV counter of Image 0 */
+#define TFM_BOOT_NV_COUNTER_1 PLAT_NV_COUNTER_BL2_1 /* NV counter of Image 1 */
+#define TFM_BOOT_NV_COUNTER_2 PLAT_NV_COUNTER_BL2_2 /* NV counter of Image 2 */
+#define TFM_BOOT_NV_COUNTER_MAX PLAT_NV_COUNTER_BL2_2 + 1
+
+static enum tfm_nv_counter_t get_nv_counter_from_image_id(uint32_t image_id)
+{
+ uint32_t nv_counter;
+
+ /* Avoid integer overflow */
+ if ((UINT32_MAX - TFM_BOOT_NV_COUNTER_0) < image_id) {
+ return TFM_BOOT_NV_COUNTER_MAX;
+ }
+
+ nv_counter = TFM_BOOT_NV_COUNTER_0 + image_id;
+
+ /* Check the existence of the enumerated counter value */
+ if (nv_counter >= TFM_BOOT_NV_COUNTER_MAX) {
+ return TFM_BOOT_NV_COUNTER_MAX;
+ }
+
+ return (enum tfm_nv_counter_t)nv_counter;
+}
+
+fih_int boot_nv_security_counter_init(void)
+{
+ fih_int fih_rc = FIH_FAILURE;
+
+ fih_rc = fih_int_encode_zero_equality(tfm_plat_init_nv_counter());
+
+ FIH_RET(fih_rc);
+}
+
+fih_int boot_nv_security_counter_get(uint32_t image_id, fih_int *security_cnt)
+{
+ enum tfm_nv_counter_t nv_counter;
+ fih_int fih_rc = FIH_FAILURE;
+ uint32_t security_cnt_soft;
+
+ /* Check if it's a null-pointer. */
+ if (!security_cnt) {
+ FIH_RET(FIH_FAILURE);
+ }
+
+ nv_counter = get_nv_counter_from_image_id(image_id);
+ if (nv_counter >= TFM_BOOT_NV_COUNTER_MAX) {
+ FIH_RET(FIH_FAILURE);
+ }
+
+ fih_rc = fih_int_encode_zero_equality(
+ tfm_plat_read_nv_counter(nv_counter,
+ sizeof(security_cnt_soft),
+ (uint8_t *)&security_cnt_soft));
+ *security_cnt = fih_int_encode(security_cnt_soft);
+
+ printf("%s: security_cnt=%d\n\r", __func__, *security_cnt);
+
+ FIH_RET(fih_rc);
+}
+
+int32_t boot_nv_security_counter_update(uint32_t image_id,
+ uint32_t img_security_cnt)
+{
+ enum tfm_nv_counter_t nv_counter;
+ enum tfm_plat_err_t err;
+ enum fwu_agent_error_t fwu_err;
+
+ nv_counter = get_nv_counter_from_image_id(image_id);
+ if (nv_counter >= TFM_BOOT_NV_COUNTER_MAX) {
+ return -1;
+ }
+
+ printf("%s: security_cnt=%u:%u\n\r", __func__, nv_counter, img_security_cnt);
+
+ if (tfm_plat_provisioning_is_required()) {
+
+ err = tfm_plat_set_nv_counter(nv_counter, img_security_cnt);
+ if (err != TFM_PLAT_ERR_SUCCESS) {
+ return -1;
+ }
+
+ } else {
+
+ if (nv_counter == PLAT_NV_COUNTER_BL2_0) {
+ fwu_err = fwu_stage_nv_counter(FWU_TFM_NV_COUNTER, img_security_cnt);
+ } else if (nv_counter == PLAT_NV_COUNTER_BL2_1) {
+ fwu_err = fwu_stage_nv_counter(FWU_TFA_NV_COUNTER, img_security_cnt);
+ } else {
+ return -1;
+ }
+
+ if (fwu_err != FWU_AGENT_SUCCESS) {
+ return -1;
+ }
+
+ }
+
+ return 0;
+}
diff --git a/platform/ext/target/arm/corstone1000/config.cmake b/platform/ext/target/arm/corstone1000/config.cmake
index 203e6b79a6..d6f3ef7d21 100644
--- a/platform/ext/target/arm/corstone1000/config.cmake
+++ b/platform/ext/target/arm/corstone1000/config.cmake
@@ -39,3 +39,5 @@ if (${PLATFORM_IS_FVP})
else()
set(PLATFORM_PSA_ADAC_SECURE_DEBUG FALSE CACHE BOOL "Whether to use psa-adac secure debug.")
endif()
+
+set(DEFAULT_MCUBOOT_SECURITY_COUNTERS OFF CACHE BOOL "Whether to use the default security counter configuration defined by TF-M project")
diff --git a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
index e8686704b8..cd7f901287 100644
--- a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
+++ b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
@@ -16,6 +16,8 @@
#include "flash_common.h"
#include "platform_base_address.h"
#include "platform_description.h"
+#include "tfm_plat_nv_counters.h"
+#include "tfm_plat_defs.h"
/* Properties of image in a bank */
struct fwu_image_properties {
@@ -79,6 +81,9 @@ struct fwu_private_metadata {
/* counter: tracking number of boot attempted so far */
uint32_t boot_attempted;
+ /* staged nv_counter: temprary location before written to the otp */
+ uint32_t nv_counter[NR_OF_IMAGES_IN_FW_BANK];
+
} __packed;
#define MAX_BOOT_ATTEMPTS_PER_BANK 3
@@ -771,6 +776,56 @@ static void disable_host_ack_timer(void)
SysTick->CTRL &= (~SysTick_CTRL_ENABLE_Msk);
}
+static enum fwu_agent_error_t update_nv_counters(
+ struct fwu_private_metadata* priv_metadata)
+{
+ enum tfm_plat_err_t err;
+ uint32_t security_cnt;
+ enum tfm_nv_counter_t tfm_nv_counter_i;
+
+ FWU_LOG_MSG("%s: enter\n\r", __func__);
+
+ for (int i = 0; i <= FWU_MAX_NV_COUNTER_INDEX; i++) {
+
+ switch (i) {
+ case FWU_BL2_NV_COUNTER:
+ tfm_nv_counter_i = PLAT_NV_COUNTER_BL1_0;
+ break;
+ case FWU_TFM_NV_COUNTER:
+ tfm_nv_counter_i = PLAT_NV_COUNTER_BL2_0;
+ break;
+ case FWU_TFA_NV_COUNTER:
+ tfm_nv_counter_i = PLAT_NV_COUNTER_BL2_1;
+ break;
+ default:
+ FWU_ASSERT(0);
+ break;
+ }
+
+ err = tfm_plat_read_nv_counter(tfm_nv_counter_i,
+ sizeof(security_cnt), (uint8_t *)&security_cnt);
+ if (err != TFM_PLAT_ERR_SUCCESS) {
+ return FWU_AGENT_ERROR;
+ }
+
+ if (priv_metadata->nv_counter[i] < security_cnt) {
+ return FWU_AGENT_ERROR;
+ } else if (priv_metadata->nv_counter[i] > security_cnt) {
+ FWU_LOG_MSG("%s: updaing index = %u nv counter = %u->%u\n\r",
+ __func__, i, security_cnt,
+ priv_metadata->nv_counter[FWU_BL2_NV_COUNTER]);
+ err = tfm_plat_set_nv_counter(tfm_nv_counter_i,
+ priv_metadata->nv_counter[FWU_BL2_NV_COUNTER]);
+ if (err != TFM_PLAT_ERR_SUCCESS) {
+ return FWU_AGENT_ERROR;
+ }
+ }
+
+ }
+
+ FWU_LOG_MSG("%s: exit\n\r", __func__);
+ return FWU_AGENT_SUCCESS;
+}
enum fwu_agent_error_t corstone1000_fwu_host_ack(void)
{
@@ -811,6 +866,9 @@ enum fwu_agent_error_t corstone1000_fwu_host_ack(void)
/* firmware update successful */
ret = fwu_accept_image(&full_capsule_image_guid, &_metadata,
&priv_metadata);
+ if (!ret) {
+ ret = update_nv_counters(&priv_metadata);
+ }
}
if (ret == FWU_AGENT_SUCCESS) {
@@ -887,3 +945,40 @@ void host_acknowledgement_timer_to_reset(void)
FWU_LOG_MSG("%s: exit\n\r", __func__);
return;
}
+
+/* stage nv counter into private metadata section of the flash.
+ * staged nv counters are written to the otp when firmware update
+ * is successful
+ * the function assumes that the api is called in the boot loading
+ * stage
+ */
+enum fwu_agent_error_t fwu_stage_nv_counter(enum fwu_nv_counter_index_t index,
+ uint32_t img_security_cnt)
+{
+ struct fwu_private_metadata priv_metadata;
+
+ FWU_LOG_MSG("%s: enter: index = %u, val = %u\n\r", __func__,
+ index, img_security_cnt);
+
+ if (!is_initialized) {
+ FWU_ASSERT(0);
+ }
+
+ if (index > FWU_MAX_NV_COUNTER_INDEX) {
+ return FWU_AGENT_ERROR;
+ }
+
+ if (private_metadata_read(&priv_metadata)) {
+ FWU_ASSERT(0);
+ }
+
+ if (priv_metadata.nv_counter[index] != img_security_cnt) {
+ priv_metadata.nv_counter[index] = img_security_cnt;
+ if (private_metadata_write(&priv_metadata)) {
+ FWU_ASSERT(0);
+ }
+ }
+
+ FWU_LOG_MSG("%s: exit\n\r", __func__);
+ return FWU_AGENT_SUCCESS;
+}
diff --git a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h
index 80f72e2bd6..57b07e8d2c 100644
--- a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h
+++ b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.h
@@ -54,4 +54,20 @@ void bl2_get_boot_bank(uint32_t *bank_offset);
*/
void host_acknowledgement_timer_to_reset(void);
+enum fwu_nv_counter_index_t {
+ FWU_BL2_NV_COUNTER = 0,
+ FWU_TFM_NV_COUNTER,
+ FWU_TFA_NV_COUNTER,
+ FWU_MAX_NV_COUNTER_INDEX = FWU_TFA_NV_COUNTER
+};
+
+/* stage nv counter into private metadata section of the flash.
+ * staged nv counters are written to the otp when firmware update
+ * is successful
+ * the function assumes that the api is called in the boot loading
+ * stage
+ */
+enum fwu_agent_error_t fwu_stage_nv_counter(enum fwu_nv_counter_index_t index,
+ uint32_t img_security_cnt);
+
#endif /* FWU_AGENT_H */
--
2.17.1
@@ -0,0 +1,50 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
From 55d0c63bf6b097b6853e93355f5a1524df56f47b Mon Sep 17 00:00:00 2001
From: Satish Kumar <satish.kumar01@arm.com>
Date: Mon, 1 Nov 2021 08:03:42 +0000
Subject: [PATCH 14/15] corstone1000: bug fix in openamp version
Typing mistake in openamp version parameter, leads the cmake
to fetch the head of the master branch.
Also, the previous hash used for code version is deleted from the
openamp github. New hash from the master branch is in use.
Change-Id: Iee5980ba14f8bb9b964eb10c71ebb68664c1d441
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
---
platform/ext/target/arm/corstone1000/config.cmake | 2 +-
.../arm/corstone1000/openamp/ext/libopenamp/CMakeLists.txt | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/platform/ext/target/arm/corstone1000/config.cmake b/platform/ext/target/arm/corstone1000/config.cmake
index d6f3ef7d21..2dab210e0a 100644
--- a/platform/ext/target/arm/corstone1000/config.cmake
+++ b/platform/ext/target/arm/corstone1000/config.cmake
@@ -32,7 +32,7 @@ set(LIBMETAL_SRC_PATH "DOWNLOAD" CACHE PATH "Path to Lib
set(LIBMETAL_VERSION "f252f0e007fbfb8b3a52b1d5901250ddac96baad" CACHE STRING "The version of libmetal to use")
set(LIBOPENAMP_SRC_PATH "DOWNLOAD" CACHE PATH "Path to Libopenamp (or DOWNLOAD to fetch automatically")
-set(OPENAMP_VERSION "33037b04e0732e58fc0fa36afc244999ef632e10" CACHE STRING "The version of openamp to use")
+set(OPENAMP_VERSION "347397decaa43372fc4d00f965640ebde042966d" CACHE STRING "The version of openamp to use")
if (${PLATFORM_IS_FVP})
set(PLATFORM_PSA_ADAC_SECURE_DEBUG FALSE CACHE BOOL "Whether to use psa-adac secure debug.")
diff --git a/platform/ext/target/arm/corstone1000/openamp/ext/libopenamp/CMakeLists.txt b/platform/ext/target/arm/corstone1000/openamp/ext/libopenamp/CMakeLists.txt
index d91dc7d845..9b1602a04f 100644
--- a/platform/ext/target/arm/corstone1000/openamp/ext/libopenamp/CMakeLists.txt
+++ b/platform/ext/target/arm/corstone1000/openamp/ext/libopenamp/CMakeLists.txt
@@ -16,7 +16,7 @@ endif()
if ("${LIBOPENAMP_SRC_PATH}" STREQUAL "DOWNLOAD")
FetchContent_Declare(libopenamp
GIT_REPOSITORY https://github.com/OpenAMP/open-amp.git
- GIT_TAG ${OEPNAMP_VERSION}
+ GIT_TAG ${OPENAMP_VERSION}
)
FetchContent_GetProperties(libopenamp)
--
2.17.1
@@ -0,0 +1,80 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
From c33289422948ccb0bd6985512e5d0fc6936c0cd1 Mon Sep 17 00:00:00 2001
From: Satish Kumar <satish.kumar01@arm.com>
Date: Thu, 18 Nov 2021 12:49:10 +0000
Subject: [PATCH 15/15] corstone1000: secure host watchdog interrupt handler
With this commit, the host secure watchdog interrupt 1
(WS1) will be handled by the secure enclave. The commit
implements and enables the SECURE_WATCHDOG_WS1_IRQHandler
in NVIC controller. The host can now trigger a reboot
using the secure watchdog.
Change-Id: Ied82cc04496f5daf678ad1cdc7bcf6d3a7879186
Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
---
.../arm/corstone1000/Native_Driver/watchdog.c | 17 +++++++++++++++++
.../arm/corstone1000/Native_Driver/watchdog.h | 9 +++++++++
.../target/arm/corstone1000/tfm_hal_platform.c | 2 ++
3 files changed, 28 insertions(+)
diff --git a/platform/ext/target/arm/corstone1000/Native_Driver/watchdog.c b/platform/ext/target/arm/corstone1000/Native_Driver/watchdog.c
index d375af3afb..d7faa3067d 100644
--- a/platform/ext/target/arm/corstone1000/Native_Driver/watchdog.c
+++ b/platform/ext/target/arm/corstone1000/Native_Driver/watchdog.c
@@ -79,3 +79,20 @@ int corstone1000_watchdog_init()
return ARM_DRIVER_OK;
}
+
+/* Secure Host Watchdog WS1 Handler
+ * efi_reset_system from the host triggers "Secure
+ * watchdog WS1 interrupt" to reset the system. Host
+ * cannot access this interrupt by design, so SE
+ * resets the system using this handler
+ * */
+void SECURE_WATCHDOG_WS1_IRQHandler(void){
+ NVIC_SystemReset();
+}
+
+/*Enable Secure Watchdog WS1 Interrupt
+ * in NVIC controller (asserted by host)*/
+void corstone1000_host_watchdog_handler_init(){
+ NVIC_EnableIRQ(SECURE_WATCHDOG_WS1_IRQn);
+}
+
diff --git a/platform/ext/target/arm/corstone1000/Native_Driver/watchdog.h b/platform/ext/target/arm/corstone1000/Native_Driver/watchdog.h
index fd1b7cf124..cd9bed3f63 100644
--- a/platform/ext/target/arm/corstone1000/Native_Driver/watchdog.h
+++ b/platform/ext/target/arm/corstone1000/Native_Driver/watchdog.h
@@ -29,4 +29,13 @@ int corstone1000_watchdog_init();
*/
int corstone1000_watchdog_reset_timer();
+/**
+ * \brief Initializes Interrupt Handler for
+ * Secure Host Watchdog (WS1).
+ *
+ * \returns VOID
+ */
+void corstone1000_host_watchdog_handler_init();
+
+
#endif /* watchdog_h */
diff --git a/platform/ext/target/arm/corstone1000/tfm_hal_platform.c b/platform/ext/target/arm/corstone1000/tfm_hal_platform.c
index 7faa71eb63..e3c6b78950 100644
--- a/platform/ext/target/arm/corstone1000/tfm_hal_platform.c
+++ b/platform/ext/target/arm/corstone1000/tfm_hal_platform.c
@@ -24,5 +24,7 @@ enum tfm_hal_status_t tfm_hal_platform_init(void)
return TFM_HAL_ERROR_GENERIC;
}
+ corstone1000_host_watchdog_handler_init();
+
return TFM_HAL_SUCCESS;
}
--
2.17.1
@@ -0,0 +1,47 @@
# Corstone1000 machines specific TFM support
COMPATIBLE_MACHINE = "(corstone1000)"
TFM_DEBUG = "1"
## Default is the MPS3 board
TFM_PLATFORM_IS_FVP ?= "FALSE"
EXTRA_OECMAKE += "-DPLATFORM_IS_FVP=${TFM_PLATFORM_IS_FVP}"
SRCREV_tfm = "ca8c634a3dc15b42d41655a14e512b642320893a"
SRCREV_mcuboot = "29099e1d17f93ae1d09fe945ad191b703aacd3d8"
PV = "1.5+git${SRCREV_tfm}"
SRCREV_FORMAT = "tfm_mcuboot_tfm-tests_mbedtls"
# The install task signs the TF-A BL2 and FIP binaries.
# So they need to be copied to the sysroot. Hence the dependencies below:
do_prepare_recipe_sysroot[depends]+= "virtual/trusted-firmware-a:do_populate_sysroot"
# adding host images signing support
require trusted-firmware-m-sign-host-images.inc
do_install() {
if [ ! -d "${B}/install/outputs/ARM/CORSTONE1000" ]
then
bbfatal "'${B}/install/outputs/ARM/CORSTONE1000' output folder not found!"
fi
install -D -p -m 0644 ${B}/install/outputs/ARM/CORSTONE1000/tfm_s_signed.bin ${D}/firmware/tfm_s_signed.bin
install -D -p -m 0644 ${B}/install/outputs/ARM/CORSTONE1000/bl2_signed.bin ${D}/firmware/bl2_signed.bin
install -D -p -m 0644 ${B}/install/outputs/ARM/CORSTONE1000/bl1.bin ${D}/firmware/bl1.bin
#
# Signing TF-A BL2 and the FIP image
#
sign_host_image ${TFA_BL2_BINARY} ${RECIPE_SYSROOT}/firmware ${TFA_BL2_RE_IMAGE_LOAD_ADDRESS} ${TFA_BL2_RE_SIGN_BIN_SIZE}
fiptool update \
--tb-fw ${D}/firmware/signed_${TFA_BL2_BINARY} \
${RECIPE_SYSROOT}/firmware/${TFA_FIP_BINARY}
sign_host_image ${TFA_FIP_BINARY} ${RECIPE_SYSROOT}/firmware ${TFA_FIP_RE_IMAGE_LOAD_ADDRESS} ${TFA_FIP_RE_SIGN_BIN_SIZE}
}
@@ -0,0 +1,50 @@
# Signing host images using TF-M tools
DEPENDS += "python3-imgtool-native fiptool-native"
#
# sign_host_image
#
# Description:
#
# A generic function that signs a host image
# using MCUBOOT format
#
# Arguments:
#
# $1 ... host binary to sign
# $2 ... host binary path
# $3 ... load address of the given binary
# $4 ... signed binary size
#
# Note: The signed binary is copied to ${D}/firmware
#
sign_host_image() {
host_binary_filename="`basename -s .bin ${1}`"
host_binary_layout="${host_binary_filename}_ns"
cat << EOF > ${B}/${host_binary_layout}
enum image_attributes {
RE_IMAGE_LOAD_ADDRESS = ${3},
RE_SIGN_BIN_SIZE = ${4},
};
EOF
host_binary="${2}/`basename ${1}`"
host_binary_signed="${D}/firmware/signed_`basename ${1}`"
${PYTHON} ${S}/bl2/ext/mcuboot/scripts/wrapper/wrapper.py \
-v ${RE_LAYOUT_WRAPPER_VERSION} \
--layout ${B}/${host_binary_layout} \
-k ${TFM_SIGN_PRIVATE_KEY} \
--public-key-format full \
--align 1 \
--pad \
--pad-header \
-H ${RE_IMAGE_OFFSET} \
-s auto \
${host_binary} \
${host_binary_signed}
}
@@ -0,0 +1,6 @@
# Machine specific configurations
MACHINE_TFM_REQUIRE ?= ""
MACHINE_TFM_REQUIRE:corstone1000 = "trusted-firmware-m-corstone1000.inc"
require ${MACHINE_TFM_REQUIRE}
@@ -0,0 +1,330 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Arpita S.K <arpita.s.k@arm.com>
From 3feb071c77bb6297165c7b671b5c92d6ba306238 Mon Sep 17 00:00:00 2001
From: Rui Miguel Silva <rui.silva@linaro.org>
Date: Fri, 4 Jun 2021 10:58:24 +0100
Subject: [PATCH 01/16] arm: add corstone1000 platform
Add support for new corstone1000 platform.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Rui Miguel Silva <rui.silva@arm.com>
---
arch/arm/Kconfig | 9 ++++
board/armltd/corstone1000/Kconfig | 12 +++++
board/armltd/corstone1000/MAINTAINERS | 6 +++
board/armltd/corstone1000/Makefile | 7 +++
board/armltd/corstone1000/corstone1000.c | 92 +++++++++++++++++++++++++++++++++
configs/corstone1000_defconfig | 39 ++++++++++++++
include/configs/corstone1000.h | 80 ++++++++++++++++++++++++++++
7 files changed, 245 insertions(+)
create mode 100644 board/armltd/corstone1000/Kconfig
create mode 100644 board/armltd/corstone1000/MAINTAINERS
create mode 100644 board/armltd/corstone1000/Makefile
create mode 100644 board/armltd/corstone1000/corstone1000.c
create mode 100644 configs/corstone1000_defconfig
create mode 100644 include/configs/corstone1000.h
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 0448787b8b..25d2a707be 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1173,6 +1173,13 @@ config TARGET_VEXPRESS64_JUNO
select USB
select DM_USB
+config TARGET_CORSTONE1000
+ bool "Support Corstone1000 Platform"
+ select ARM64
+ select PL01X_SERIAL
+ select DM
+ select OF_BOARD
+
config TARGET_TOTAL_COMPUTE
bool "Support Total Compute Platform"
select ARM64
@@ -1985,6 +1992,8 @@ source "arch/arm/mach-nexell/Kconfig"
source "board/armltd/total_compute/Kconfig"
+source "board/armltd/corstone1000/Kconfig"
+
source "board/bosch/shc/Kconfig"
source "board/bosch/guardian/Kconfig"
source "board/CarMediaLab/flea3/Kconfig"
diff --git a/board/armltd/corstone1000/Kconfig b/board/armltd/corstone1000/Kconfig
new file mode 100644
index 000000000000..90e6b7af59cb
--- /dev/null
+++ b/board/armltd/corstone1000/Kconfig
@@ -0,0 +1,12 @@
+if TARGET_CORSTONE1000
+
+config SYS_BOARD
+ default "corstone1000"
+
+config SYS_VENDOR
+ default "armltd"
+
+config SYS_CONFIG_NAME
+ default "corstone1000"
+
+endif
diff --git a/board/armltd/corstone1000/MAINTAINERS b/board/armltd/corstone1000/MAINTAINERS
new file mode 100644
index 000000000000..601cff17b666
--- /dev/null
+++ b/board/armltd/corstone1000/MAINTAINERS
@@ -0,0 +1,6 @@
+CORSTONE1000 BOARD
+M: Rui Miguel Silva <rui.silva@linaro.org>
+S: Maintained
+F: board/armltd/corstone1000/
+F: include/configs/corstone1000.h
+F: configs/corstone1000_defconfig
diff --git a/board/armltd/corstone1000/Makefile b/board/armltd/corstone1000/Makefile
new file mode 100644
index 000000000000..7bad6f57f1ce
--- /dev/null
+++ b/board/armltd/corstone1000/Makefile
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2021 Arm Limited
+# (C) Copyright 2021 Linaro
+# Rui Miguel Silva <rui.silva@linaro.org>
+
+obj-y := corstone1000.o
diff --git a/board/armltd/corstone1000/corstone1000.c b/board/armltd/corstone1000/corstone1000.c
new file mode 100644
index 000000000000..fe986ceba1c5
--- /dev/null
+++ b/board/armltd/corstone1000/corstone1000.c
@@ -0,0 +1,92 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2021 ARM Limited
+ * (C) Copyright 2021 Linaro
+ * Rui Miguel Silva <rui.silva@linaro.org>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dm/platform_data/serial_pl01x.h>
+#include <asm/armv8/mmu.h>
+#include <asm/global_data.h>
+
+
+static const struct pl01x_serial_plat serial_plat = {
+ .base = V2M_UART0,
+ .type = TYPE_PL011,
+ .clock = CONFIG_PL011_CLOCK,
+};
+
+U_BOOT_DRVINFO(corstone1000_serials) = {
+ .name = "serial_pl01x",
+ .plat = &serial_plat,
+};
+
+static struct mm_region corstone1000_mem_map[] = {
+ {
+ /* CVM */
+ .virt = 0x02000000UL,
+ .phys = 0x02000000UL,
+ .size = 0x02000000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+ PTE_BLOCK_INNER_SHARE
+ }, {
+ /* QSPI */
+ .virt = 0x08000000UL,
+ .phys = 0x08000000UL,
+ .size = 0x08000000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+ PTE_BLOCK_INNER_SHARE
+ }, {
+ /* Host Peripherals */
+ .virt = 0x1A000000UL,
+ .phys = 0x1A000000UL,
+ .size = 0x26000000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+ PTE_BLOCK_NON_SHARE |
+ PTE_BLOCK_PXN | PTE_BLOCK_UXN
+ }, {
+ /* OCVM */
+ .virt = 0x80000000UL,
+ .phys = 0x80000000UL,
+ .size = 0x80000000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+ PTE_BLOCK_INNER_SHARE
+ }, {
+ /* List terminator */
+ 0,
+ }
+};
+
+struct mm_region *mem_map = corstone1000_mem_map;
+
+int board_init(void)
+{
+ return 0;
+}
+
+int dram_init(void)
+{
+ gd->ram_size = PHYS_SDRAM_1_SIZE;
+
+ return 0;
+}
+
+int dram_init_banksize(void)
+{
+ gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
+ gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
+
+#ifdef PHYS_SDRAM_2
+ gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
+ gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
+#endif
+
+
+ return 0;
+}
+
+void reset_cpu(ulong addr)
+{
+}
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
new file mode 100644
index 000000000000..47d4bf3771e0
--- /dev/null
+++ b/configs/corstone1000_defconfig
@@ -0,0 +1,39 @@
+CONFIG_ARM=y
+CONFIG_ARM64=y
+CONFIG_TARGET_CORSTONE1000=y
+CONFIG_SYS_TEXT_BASE=0x02100000
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_IDENT_STRING=" corstone1000 aarch64 "
+CONFIG_BOOTDELAY=3
+CONFIG_OF_BOARD=y
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="console=ttyAMA0 loglevel=9"
+# CONFIG_DISPLAY_CPUINFO is not set
+# CONFIG_DISPLAY_BOARDINFO is not set
+CONFIG_HUSH_PARSER=y
+CONFIG_SYS_PROMPT="corstone1000# "
+# CONFIG_CMD_CONSOLE is not set
+CONFIG_CMD_BOOTZ=y
+CONFIG_CMD_BOOTM=y
+# CONFIG_CMD_XIMG is not set
+# CONFIG_CMD_EDITENV is not set
+# CONFIG_CMD_ENV_EXISTS is not set
+# CONFIG_CMD_ARMFLASH=y
+# CONFIG_CMD_LOADS is not set
+# CONFIG_CMD_ITEST is not set
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_DHCP=y
+# CONFIG_CMD_NFS is not set
+CONFIG_CMD_MII=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_CACHE=y
+CONFIG_FIT=y
+# CONFIG_CMD_MISC is not set
+CONFIG_CMD_FAT=y
+CONFIG_DM=y
+# CONFIG_MMC is not set
+# CONFIG_MTD_NOR_FLASH=y
+CONFIG_DM_ETH=y
+CONFIG_DM_SERIAL=y
+CONFIG_OF_LIBFDT=y
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
new file mode 100644
index 000000000000..c8e630c5d857
--- /dev/null
+++ b/include/configs/corstone1000.h
@@ -0,0 +1,80 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2020 ARM Limited
+ * (C) Copyright 2020 Linaro
+ * Rui Miguel Silva <rui.silva@linaro.org>
+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+ *
+ * Configuration for Corstone1000. Parts were derived from other ARM
+ * configurations.
+ */
+
+#ifndef __CORSTONE1000_H
+#define __CORSTONE1000_H
+
+#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + 0x03f00000)
+#define CONFIG_SKIP_LOWLEVEL_INIT
+
+#define CONFIG_SYS_HZ 1000
+
+#define V2M_SRAM0 0x02000000
+#define V2M_QSPI 0x08000000
+
+#define V2M_DEBUG 0x10000000
+#define V2M_BASE_PERIPH 0x1A000000
+
+#define V2M_BASE 0x80000000
+
+#define V2M_PERIPH_OFFSET(x) (x << 16)
+
+#define V2M_SYSID (V2M_BASE_PERIPH)
+#define V2M_SYSCTL (V2M_BASE_PERIPH + V2M_PERIPH_OFFSET(1))
+
+#define V2M_COUNTER_CTL (V2M_BASE_PERIPH + V2M_PERIPH_OFFSET(32))
+#define V2M_COUNTER_READ (V2M_BASE_PERIPH + V2M_PERIPH_OFFSET(33))
+
+#define V2M_TIMER_CTL (V2M_BASE_PERIPH + V2M_PERIPH_OFFSET(34))
+#define V2M_TIMER_BASE0 (V2M_BASE_PERIPH + V2M_PERIPH_OFFSET(35))
+
+#define V2M_UART0 (V2M_BASE_PERIPH + V2M_PERIPH_OFFSET(81))
+#define V2M_UART1 (V2M_BASE_PERIPH + V2M_PERIPH_OFFSET(82))
+
+#define CONFIG_PL011_CLOCK 50000000
+
+/* Physical Memory Map */
+#define PHYS_SDRAM_1 (V2M_BASE)
+#define PHYS_SDRAM_2 (V2M_QSPI)
+
+/* Top 16MB reserved for secure world use (maybe not needed) */
+#define DRAM_SEC_SIZE 0x01000000
+#define PHYS_SDRAM_1_SIZE 0x80000000 - DRAM_SEC_SIZE
+
+#define PHYS_SDRAM_2_SIZE 0x02000000
+
+/* Size of malloc() pool */
+#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + (8 << 20))
+
+/* Miscellaneous configurable options */
+#define CONFIG_SYS_LOAD_ADDR (V2M_BASE + 0x10000000)
+
+#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
+
+/* Monitor Command Prompt */
+#define CONFIG_SYS_CBSIZE 512 /* Console I/O Buffer Size */
+#define CONFIG_SYS_MAXARGS 64 /* max command args */
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+ "fdt_addr=0x08330000\0" \
+ "fdt_addr_r=0x82000000\0" \
+ "kernel_addr=0x08430000\0" \
+ "kernel_addr_r=0x82100000\0" \
+ "fdt_high=0xffffffff\0"
+
+#define CONFIG_BOOTCOMMAND \
+ "echo Copying devicetree to memory ... ;" \
+ "cp.b $fdt_addr $fdt_addr_r 0x100000;" \
+ "echo Copying Kernel to memory ... ;" \
+ "cp.b $kernel_addr $kernel_addr_r 0xa00000;" \
+ "bootm $kernel_addr_r - $fdt_addr_r; "
+
+#endif
--
2.33.0
@@ -0,0 +1,59 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Arpita S.K <arpita.s.k@arm.com>
From 1a034bd9397f96939d58a86e9cf8cd9c206db647 Mon Sep 17 00:00:00 2001
From: Rui Miguel Silva <rui.silva@linaro.org>
Date: Tue, 22 Jun 2021 17:00:24 +0100
Subject: [PATCH 02/16] arm: corstone1000: enable devicetree in defconfig
Add support and setup the default device tree for corstone1000.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Rui Miguel Silva <rui.silva@arm.com>
---
configs/corstone1000_defconfig | 3 ++-
include/configs/corstone1000.h | 10 +++-------
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index bc983e6555..54c746d829 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -6,7 +6,8 @@ CONFIG_SYS_MALLOC_F_LEN=0x2000
CONFIG_NR_DRAM_BANKS=1
CONFIG_IDENT_STRING=" corstone1000 aarch64 "
CONFIG_BOOTDELAY=3
-CONFIG_OF_BOARD=y
+CONFIG_OF_CONTROL=y
+CONFIG_DEFAULT_DEVICE_TREE="corstone1000-mps3"
CONFIG_USE_BOOTARGS=y
CONFIG_BOOTARGS="console=ttyAMA0 loglevel=9"
# CONFIG_DISPLAY_CPUINFO is not set
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index 1fe909463f..389ac45a58 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -64,17 +64,13 @@
#define CONFIG_SYS_MAXARGS 64 /* max command args */
#define CONFIG_EXTRA_ENV_SETTINGS \
- "fdt_addr=0x08330000\0" \
"fdt_addr_r=0x82000000\0" \
- "kernel_addr=0x08430000\0" \
+ "kernel_addr=0x08330000\0" \
"kernel_addr_r=0x82100000\0" \
"fdt_high=0xffffffff\0"
#define CONFIG_BOOTCOMMAND \
- "echo Copying devicetree to memory ... ;" \
- "cp.b $fdt_addr $fdt_addr_r 0x100000;" \
"echo Copying Kernel to memory ... ;" \
- "cp.b $kernel_addr $kernel_addr_r 0xa00000;" \
- "bootm $kernel_addr_r - $fdt_addr_r; "
-
+ "cp.b $kernel_addr $kernel_addr_r 0xc00000;" \
+ "booti $kernel_addr_r - $fdtcontroladdr; "
#endif
--
2.33.0
@@ -0,0 +1,508 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Arpita S.K <arpita.s.k@arm.com>
From 84b3b8f2443d0b4f6ac8ef95c941b27d734afbde Mon Sep 17 00:00:00 2001
From: Rui Miguel Silva <rui.silva@linaro.org>
Date: Mon, 28 Jun 2021 23:20:55 +0100
Subject: [PATCH 03/16] usb: common: move urb code to common
Move urb code from musb only use to a more common scope, so other
drivers in the future can use the handling of urb in usb.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
---
drivers/usb/common/Makefile | 2 +
drivers/usb/common/usb_urb.c | 160 ++++++++++++++++++
drivers/usb/host/r8a66597-hcd.c | 30 +---
drivers/usb/musb-new/musb_core.c | 2 +-
drivers/usb/musb-new/musb_host.c | 2 +-
drivers/usb/musb-new/musb_host.h | 2 +-
drivers/usb/musb-new/musb_uboot.c | 38 +----
drivers/usb/musb-new/musb_uboot.h | 2 +-
.../linux/usb/usb_urb_compat.h | 52 ++++--
include/usb_defs.h | 32 ++++
10 files changed, 240 insertions(+), 82 deletions(-)
create mode 100644 drivers/usb/common/usb_urb.c
rename drivers/usb/musb-new/usb-compat.h => include/linux/usb/usb_urb_compat.h (57%)
diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile
index 3bedbf213f..dc05cb0a50 100644
--- a/drivers/usb/common/Makefile
+++ b/drivers/usb/common/Makefile
@@ -4,5 +4,7 @@
#
obj-$(CONFIG_$(SPL_)DM_USB) += common.o
+obj-$(CONFIG_USB_MUSB_HCD) += usb_urb.o
+obj-$(CONFIG_USB_MUSB_UDC) += usb_urb.o
obj-$(CONFIG_USB_EHCI_FSL) += fsl-dt-fixup.o fsl-errata.o
obj-$(CONFIG_USB_XHCI_FSL) += fsl-dt-fixup.o fsl-errata.o
diff --git a/drivers/usb/common/usb_urb.c b/drivers/usb/common/usb_urb.c
new file mode 100644
index 0000000000..be3b6b9f32
--- /dev/null
+++ b/drivers/usb/common/usb_urb.c
@@ -0,0 +1,160 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Common code for usb urb handling, based on the musb-new code
+ *
+ * Copyright 2021 Linaro, Rui Miguel Silva <rui.silva@linaro.org>
+ *
+ */
+
+#include <dm/device.h>
+#include <dm/device_compat.h>
+#include <linux/usb/usb_urb_compat.h>
+
+#include <time.h>
+#include <usb.h>
+
+#if CONFIG_IS_ENABLED(DM_USB)
+struct usb_device *usb_dev_get_parent(struct usb_device *udev)
+{
+ struct udevice *parent = udev->dev->parent;
+
+ /*
+ * When called from usb-uclass.c: usb_scan_device() udev->dev points
+ * to the parent udevice, not the actual udevice belonging to the
+ * udev as the device is not instantiated yet.
+ *
+ * If dev is an usb-bus, then we are called from usb_scan_device() for
+ * an usb-device plugged directly into the root port, return NULL.
+ */
+ if (device_get_uclass_id(udev->dev) == UCLASS_USB)
+ return NULL;
+
+ /*
+ * If these 2 are not the same we are being called from
+ * usb_scan_device() and udev itself is the parent.
+ */
+ if (dev_get_parent_priv(udev->dev) != udev)
+ return udev;
+
+ /* We are being called normally, use the parent pointer */
+ if (device_get_uclass_id(parent) == UCLASS_USB_HUB)
+ return dev_get_parent_priv(parent);
+
+ return NULL;
+}
+#else
+struct usb_device *usb_dev_get_parent(struct usb_device *udev)
+{
+ return udev->parent;
+}
+#endif
+
+static void usb_urb_complete(struct urb *urb)
+{
+ urb->dev->status &= ~USB_ST_NOT_PROC;
+ urb->dev->act_len = urb->actual_length;
+
+ if (urb->status == -EINPROGRESS)
+ urb->status = 0;
+}
+
+void usb_urb_fill(struct urb *urb, struct usb_host_endpoint *hep,
+ struct usb_device *dev, int endpoint_type,
+ unsigned long pipe, void *buffer, int len,
+ struct devrequest *setup, int interval)
+{
+ int epnum = usb_pipeendpoint(pipe);
+ int is_in = usb_pipein(pipe);
+ u16 maxpacketsize = is_in ? dev->epmaxpacketin[epnum] :
+ dev->epmaxpacketout[epnum];
+
+ memset(urb, 0, sizeof(struct urb));
+ memset(hep, 0, sizeof(struct usb_host_endpoint));
+ INIT_LIST_HEAD(&hep->urb_list);
+ INIT_LIST_HEAD(&urb->urb_list);
+ urb->ep = hep;
+ urb->complete = usb_urb_complete;
+ urb->status = -EINPROGRESS;
+ urb->dev = dev;
+ urb->pipe = pipe;
+ urb->transfer_buffer = buffer;
+ urb->transfer_dma = (unsigned long)buffer;
+ urb->transfer_buffer_length = len;
+ urb->setup_packet = (unsigned char *)setup;
+
+ urb->ep->desc.wMaxPacketSize = __cpu_to_le16(maxpacketsize);
+ urb->ep->desc.bmAttributes = endpoint_type;
+ urb->ep->desc.bEndpointAddress = ((is_in ? USB_DIR_IN : USB_DIR_OUT) |
+ epnum);
+ urb->ep->desc.bInterval = interval;
+}
+
+int usb_urb_submit(struct usb_hcd *hcd, struct urb *urb)
+{
+ const struct usb_urb_ops *ops = hcd->urb_ops;
+ unsigned long timeout;
+ int ret;
+
+ if (!ops)
+ return -EINVAL;
+
+ ret = ops->urb_enqueue(hcd, urb, 0);
+ if (ret < 0) {
+ printf("Failed to enqueue URB to controller\n");
+ return ret;
+ }
+
+ timeout = get_timer(0) + USB_TIMEOUT_MS(urb->pipe);
+ do {
+ if (ctrlc())
+ return -EIO;
+ ops->isr(0, hcd);
+ } while (urb->status == -EINPROGRESS && get_timer(0) < timeout);
+
+ if (urb->status == -EINPROGRESS)
+ ops->urb_dequeue(hcd, urb, -ETIME);
+
+ return urb->status;
+}
+
+int usb_urb_submit_control(struct usb_hcd *hcd, struct urb *urb,
+ struct usb_host_endpoint *hep,
+ struct usb_device *dev, unsigned long pipe,
+ void *buffer, int len, struct devrequest *setup,
+ int interval, enum usb_device_speed speed)
+{
+ const struct usb_urb_ops *ops = hcd->urb_ops;
+
+ usb_urb_fill(urb, hep, dev, USB_ENDPOINT_XFER_CONTROL, pipe, buffer,
+ len, setup, 0);
+
+ /* Fix speed for non hub-attached devices */
+ if (!usb_dev_get_parent(dev)) {
+ dev->speed = speed;
+ if (ops->hub_control)
+ return ops->hub_control(hcd, dev, pipe, buffer, len,
+ setup);
+ }
+
+ return usb_urb_submit(hcd, urb);
+}
+
+int usb_urb_submit_bulk(struct usb_hcd *hcd, struct urb *urb,
+ struct usb_host_endpoint *hep, struct usb_device *dev,
+ unsigned long pipe, void *buffer, int len)
+{
+ usb_urb_fill(urb, hep, dev, USB_ENDPOINT_XFER_BULK, pipe, buffer, len,
+ NULL, 0);
+
+ return usb_urb_submit(hcd, urb);
+}
+
+int usb_urb_submit_irq(struct usb_hcd *hcd, struct urb *urb,
+ struct usb_host_endpoint *hep, struct usb_device *dev,
+ unsigned long pipe, void *buffer, int len, int interval)
+{
+ usb_urb_fill(urb, hep, dev, USB_ENDPOINT_XFER_INT, pipe, buffer, len,
+ NULL, interval);
+
+ return usb_urb_submit(hcd, urb);
+}
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index f1fc93f3d4..3ccbc16da3 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -14,6 +14,7 @@
#include <dm/device_compat.h>
#include <linux/delay.h>
#include <linux/iopoll.h>
+#include <linux/usb/usb_urb_compat.h>
#include <power/regulator.h>
#include "r8a66597.h"
@@ -24,35 +25,6 @@
#define R8A66597_DPRINT(...)
#endif
-static inline struct usb_device *usb_dev_get_parent(struct usb_device *udev)
-{
- struct udevice *parent = udev->dev->parent;
-
- /*
- * When called from usb-uclass.c: usb_scan_device() udev->dev points
- * to the parent udevice, not the actual udevice belonging to the
- * udev as the device is not instantiated yet.
- *
- * If dev is an usb-bus, then we are called from usb_scan_device() for
- * an usb-device plugged directly into the root port, return NULL.
- */
- if (device_get_uclass_id(udev->dev) == UCLASS_USB)
- return NULL;
-
- /*
- * If these 2 are not the same we are being called from
- * usb_scan_device() and udev itself is the parent.
- */
- if (dev_get_parent_priv(udev->dev) != udev)
- return udev;
-
- /* We are being called normally, use the parent pointer */
- if (device_get_uclass_id(parent) == UCLASS_USB_HUB)
- return dev_get_parent_priv(parent);
-
- return NULL;
-}
-
static void get_hub_data(struct usb_device *dev, u16 *hub_devnum, u16 *hubport)
{
struct usb_device *parent = usb_dev_get_parent(dev);
diff --git a/drivers/usb/musb-new/musb_core.c b/drivers/usb/musb-new/musb_core.c
index 22811a5efb..d1d4ee2da3 100644
--- a/drivers/usb/musb-new/musb_core.c
+++ b/drivers/usb/musb-new/musb_core.c
@@ -89,9 +89,9 @@
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
#include <linux/usb/musb.h>
+#include <linux/usb/usb_urb_compat.h>
#include <asm/io.h>
#include "linux-compat.h"
-#include "usb-compat.h"
#endif
#include "musb_core.h"
diff --git a/drivers/usb/musb-new/musb_host.c b/drivers/usb/musb-new/musb_host.c
index acb2d40f3b..e5905d90d6 100644
--- a/drivers/usb/musb-new/musb_host.c
+++ b/drivers/usb/musb-new/musb_host.c
@@ -26,8 +26,8 @@
#include <dm/device_compat.h>
#include <usb.h>
#include <linux/bug.h>
+#include <linux/usb/usb_urb_compat.h>
#include "linux-compat.h"
-#include "usb-compat.h"
#endif
#include "musb_core.h"
diff --git a/drivers/usb/musb-new/musb_host.h b/drivers/usb/musb-new/musb_host.h
index afc8fa35a7..5a604bdb0c 100644
--- a/drivers/usb/musb-new/musb_host.h
+++ b/drivers/usb/musb-new/musb_host.h
@@ -10,7 +10,7 @@
#ifndef _MUSB_HOST_H
#define _MUSB_HOST_H
#ifdef __UBOOT__
-#include "usb-compat.h"
+#include <linux/usb/usb_urb_compat.h>
#endif
static inline struct usb_hcd *musb_to_hcd(struct musb *musb)
diff --git a/drivers/usb/musb-new/musb_uboot.c b/drivers/usb/musb-new/musb_uboot.c
index 8ac2f0a78a..85794356b0 100644
--- a/drivers/usb/musb-new/musb_uboot.c
+++ b/drivers/usb/musb-new/musb_uboot.c
@@ -8,10 +8,10 @@
#include <linux/errno.h>
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
+#include <linux/usb/usb_urb_compat.h>
#include <usb.h>
#include "linux-compat.h"
-#include "usb-compat.h"
#include "musb_core.h"
#include "musb_host.h"
#include "musb_gadget.h"
@@ -453,39 +453,3 @@ struct musb *musb_register(struct musb_hdrc_platform_data *plat, void *bdata,
return *musbp;
}
-
-#if CONFIG_IS_ENABLED(DM_USB)
-struct usb_device *usb_dev_get_parent(struct usb_device *udev)
-{
- struct udevice *parent = udev->dev->parent;
-
- /*
- * When called from usb-uclass.c: usb_scan_device() udev->dev points
- * to the parent udevice, not the actual udevice belonging to the
- * udev as the device is not instantiated yet.
- *
- * If dev is an usb-bus, then we are called from usb_scan_device() for
- * an usb-device plugged directly into the root port, return NULL.
- */
- if (device_get_uclass_id(udev->dev) == UCLASS_USB)
- return NULL;
-
- /*
- * If these 2 are not the same we are being called from
- * usb_scan_device() and udev itself is the parent.
- */
- if (dev_get_parent_priv(udev->dev) != udev)
- return udev;
-
- /* We are being called normally, use the parent pointer */
- if (device_get_uclass_id(parent) == UCLASS_USB_HUB)
- return dev_get_parent_priv(parent);
-
- return NULL;
-}
-#else
-struct usb_device *usb_dev_get_parent(struct usb_device *udev)
-{
- return udev->parent;
-}
-#endif
diff --git a/drivers/usb/musb-new/musb_uboot.h b/drivers/usb/musb-new/musb_uboot.h
index 18282efccc..6b162f03b1 100644
--- a/drivers/usb/musb-new/musb_uboot.h
+++ b/drivers/usb/musb-new/musb_uboot.h
@@ -8,8 +8,8 @@
#define __MUSB_UBOOT_H__
#include <usb.h>
+#include <linux/usb/usb_urb_compat.h>
#include "linux-compat.h"
-#include "usb-compat.h"
#include "musb_core.h"
struct musb_host_data {
diff --git a/drivers/usb/musb-new/usb-compat.h b/include/linux/usb/usb_urb_compat.h
similarity index 57%
rename from drivers/usb/musb-new/usb-compat.h
rename to include/linux/usb/usb_urb_compat.h
index 1c66c4fe36..438e70b56a 100644
--- a/drivers/usb/musb-new/usb-compat.h
+++ b/include/linux/usb/usb_urb_compat.h
@@ -1,16 +1,31 @@
-#ifndef __USB_COMPAT_H__
-#define __USB_COMPAT_H__
+#ifndef __USB_URB_COMPAT_H__
+#define __USB_URB_COMPAT_H__
-#include "usb.h"
+#include <linux/compat.h>
+#include <usb.h>
struct udevice;
+struct urb;
+struct usb_hcd;
+
+
+struct usb_urb_ops {
+ int (*urb_enqueue)(struct usb_hcd *hcd, struct urb *urb,
+ gfp_t mem_flags);
+ int (*urb_dequeue)(struct usb_hcd *hcd, struct urb *urb, int status);
+ int (*hub_control)(struct usb_hcd *hcd, struct usb_device *dev,
+ unsigned long pipe, void *buffer, int len,
+ struct devrequest *setup);
+ irqreturn_t (*isr)(int irq, void *priv);
+};
struct usb_hcd {
void *hcd_priv;
+ const struct usb_urb_ops *urb_ops;
};
struct usb_host_endpoint {
- struct usb_endpoint_descriptor desc;
+ struct usb_endpoint_descriptor desc;
struct list_head urb_list;
void *hcpriv;
};
@@ -23,8 +38,6 @@ struct usb_host_endpoint {
#define URB_SHORT_NOT_OK 0x0001 /* report short reads as errors */
#define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */
-struct urb;
-
typedef void (*usb_complete_t)(struct urb *);
struct urb {
@@ -68,12 +81,27 @@ static inline int usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd,
return 0;
}
-/**
- * usb_dev_get_parent() - Get the parent of a USB device
- *
- * @udev: USB struct containing information about the device
- * @return associated device for which udev == dev_get_parent_priv(dev)
- */
struct usb_device *usb_dev_get_parent(struct usb_device *udev);
+int usb_urb_submit_control(struct usb_hcd *hcd, struct urb *urb,
+ struct usb_host_endpoint *hep,
+ struct usb_device *dev, unsigned long pipe,
+ void *buffer, int len, struct devrequest *setup,
+ int interval, enum usb_device_speed speed);
+
+int usb_urb_submit_bulk(struct usb_hcd *hcd, struct urb *urb,
+ struct usb_host_endpoint *hep, struct usb_device *dev,
+ unsigned long pipe, void *buffer, int len);
+
+int usb_urb_submit_irq(struct usb_hcd *hcd, struct urb *urb,
+ struct usb_host_endpoint *hep, struct usb_device *dev,
+ unsigned long pipe, void *buffer, int len, int interval);
+
+void usb_urb_fill(struct urb *urb, struct usb_host_endpoint *hep,
+ struct usb_device *dev, int endpoint_type,
+ unsigned long pipe, void *buffer, int len,
+ struct devrequest *setup, int interval);
+
+int usb_urb_submit(struct usb_hcd *hcd, struct urb *urb);
+
#endif /* __USB_COMPAT_H__ */
diff --git a/include/usb_defs.h b/include/usb_defs.h
index 6dd2c997f9..ec00161710 100644
--- a/include/usb_defs.h
+++ b/include/usb_defs.h
@@ -81,6 +81,32 @@
#define EndpointOutRequest \
((USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8)
+/* class requests from the USB 2.0 hub spec, table 11-15 */
+#define HUB_CLASS_REQ(dir, type, request) ((((dir) | (type)) << 8) | (request))
+/* GetBusState and SetHubDescriptor are optional, omitted */
+#define ClearHubFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, \
+ USB_REQ_CLEAR_FEATURE)
+#define ClearPortFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, \
+ USB_REQ_CLEAR_FEATURE)
+#define GetHubDescriptor HUB_CLASS_REQ(USB_DIR_IN, USB_RT_HUB, \
+ USB_REQ_GET_DESCRIPTOR)
+#define GetHubStatus HUB_CLASS_REQ(USB_DIR_IN, USB_RT_HUB, \
+ USB_REQ_GET_STATUS)
+#define GetPortStatus HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, \
+ USB_REQ_GET_STATUS)
+#define SetHubFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, \
+ USB_REQ_SET_FEATURE)
+#define SetPortFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, \
+ USB_REQ_SET_FEATURE)
+#define ClearTTBuffer HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, \
+ HUB_CLEAR_TT_BUFFER)
+#define ResetTT HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, \
+ HUB_RESET_TT)
+#define GetTTState HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, \
+ HUB_GET_TT_STATE)
+#define StopTT HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, \
+ HUB_STOP_TT)
+
/* Descriptor types */
#define USB_DT_DEVICE 0x01
#define USB_DT_CONFIG 0x02
@@ -289,10 +315,16 @@
#define USB_SS_PORT_STAT_C_CONFIG_ERROR 0x0080
/* wHubCharacteristics (masks) */
+#define HUB_CHAR_COMMON_OCPM 0x0000 /* All ports Over-Current reporting */
+#define HUB_CHAR_INDV_PORT_LPSM 0x0001 /* per-port power control */
+#define HUB_CHAR_NO_LPSM 0x0002 /* no power switching */
#define HUB_CHAR_LPSM 0x0003
#define HUB_CHAR_COMPOUND 0x0004
+#define HUB_CHAR_INDV_PORT_OCPM 0x0008 /* per-port Over-current reporting */
+#define HUB_CHAR_NO_OCPM 0x0010 /* No Over-current Protection support */
#define HUB_CHAR_OCPM 0x0018
#define HUB_CHAR_TTTT 0x0060 /* TT Think Time mask */
+#define HUB_CHAR_PORTIND 0x0080 /* per-port indicators (LEDs) */
/*
* Hub Status & Hub Change bit masks
--
2.33.0
@@ -0,0 +1,92 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Arpita S.K <arpita.s.k@arm.com>
From 663bfde59a56d65c031526f75f0e08126f02d845 Mon Sep 17 00:00:00 2001
From: Rui Miguel Silva <rui.silva@linaro.org>
Date: Tue, 27 Jul 2021 23:34:57 +0100
Subject: [PATCH 05/16] corstone1000: enable isp1763 and usb stack
MPS3 board have a ISP1763 usb controller, add the correspondent mmio
area and enable it to be used for mass storage access for example.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
---
board/armltd/corstone1000/corstone1000.c | 8 ++++++++
configs/corstone1000_defconfig | 19 +++++++++----------
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/board/armltd/corstone1000/corstone1000.c b/board/armltd/corstone1000/corstone1000.c
index ab98fa87fb..a51f5ddfa0 100644
--- a/board/armltd/corstone1000/corstone1000.c
+++ b/board/armltd/corstone1000/corstone1000.c
@@ -46,6 +46,14 @@ static struct mm_region corstone1000_mem_map[] = {
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
PTE_BLOCK_NON_SHARE |
PTE_BLOCK_PXN | PTE_BLOCK_UXN
+ }, {
+ /* USB */
+ .virt = 0x40200000UL,
+ .phys = 0x40200000UL,
+ .size = 0x00100000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+ PTE_BLOCK_NON_SHARE |
+ PTE_BLOCK_PXN | PTE_BLOCK_UXN
}, {
/* OCVM */
.virt = 0x80000000UL,
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index 54c746d829..fed2b16c93 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -1,13 +1,12 @@
CONFIG_ARM=y
-CONFIG_ARM64=y
CONFIG_TARGET_CORSTONE1000=y
CONFIG_SYS_TEXT_BASE=0x02100000
CONFIG_SYS_MALLOC_F_LEN=0x2000
CONFIG_NR_DRAM_BANKS=1
CONFIG_IDENT_STRING=" corstone1000 aarch64 "
-CONFIG_BOOTDELAY=3
-CONFIG_OF_CONTROL=y
CONFIG_DEFAULT_DEVICE_TREE="corstone1000-mps3"
+CONFIG_FIT=y
+CONFIG_BOOTDELAY=3
CONFIG_USE_BOOTARGS=y
CONFIG_BOOTARGS="console=ttyAMA0 loglevel=9"
# CONFIG_DISPLAY_CPUINFO is not set
@@ -16,12 +15,11 @@ CONFIG_HUSH_PARSER=y
CONFIG_SYS_PROMPT="corstone1000# "
# CONFIG_CMD_CONSOLE is not set
CONFIG_CMD_BOOTZ=y
-CONFIG_CMD_BOOTM=y
# CONFIG_CMD_XIMG is not set
# CONFIG_CMD_EDITENV is not set
# CONFIG_CMD_ENV_EXISTS is not set
-# CONFIG_CMD_ARMFLASH=y
# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_USB=y
# CONFIG_CMD_ITEST is not set
# CONFIG_CMD_SETEXPR is not set
CONFIG_CMD_DHCP=y
@@ -29,12 +27,13 @@ CONFIG_CMD_DHCP=y
CONFIG_CMD_MII=y
CONFIG_CMD_PING=y
CONFIG_CMD_CACHE=y
-CONFIG_FIT=y
-# CONFIG_CMD_MISC is not set
CONFIG_CMD_FAT=y
-CONFIG_DM=y
+CONFIG_OF_CONTROL=y
+CONFIG_REGMAP=y
# CONFIG_MMC is not set
-# CONFIG_MTD_NOR_FLASH=y
CONFIG_DM_ETH=y
CONFIG_DM_SERIAL=y
-CONFIG_OF_LIBFDT=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_USB_ISP1760=y
+CONFIG_USB_STORAGE=y
--
2.33.0
@@ -0,0 +1,240 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Arpita S.K <arpita.s.k@arm.com>
From 8244c266643d7fe77e360d2927adcd123a691dd1 Mon Sep 17 00:00:00 2001
From: "Arpita S.K" <Arpita.S.K@arm.com>
Date: Mon, 11 Oct 2021 11:41:25 +0530
Subject: [PATCH 06/16] corstone1000: enable support for FVP
Introduces a new device tree for the FVP.
Signed-off-by: Arpita S.K <Arpita.S.K@arm.com>
---
arch/arm/dts/Makefile | 2 +
arch/arm/dts/corstone1000-fvp.dts | 28 ++++++
arch/arm/dts/corstone1000.dtsi | 152 ++++++++++++++++++++++++++++++
configs/corstone1000_defconfig | 1 -
4 files changed, 182 insertions(+), 1 deletion(-)
create mode 100644 arch/arm/dts/corstone1000-fvp.dts
create mode 100644 arch/arm/dts/corstone1000.dtsi
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 9fb38682e6..c70c20b9a5 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1112,6 +1112,8 @@ dtb-$(CONFIG_TARGET_PRESIDIO_ASIC) += ca-presidio-engboard.dtb
dtb-$(CONFIG_TARGET_IMX8MM_CL_IOT_GATE) += imx8mm-cl-iot-gate.dtb
+dtb-$(CONFIG_TARGET_CORSTONE1000) += $(DEVICE_TREE).dtb
+
targets += $(dtb-y)
# Add any required device tree compiler flags here
diff --git a/arch/arm/dts/corstone1000-fvp.dts b/arch/arm/dts/corstone1000-fvp.dts
new file mode 100644
index 0000000000..2188ca5e0e
--- /dev/null
+++ b/arch/arm/dts/corstone1000-fvp.dts
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/dts-v1/;
+
+#include "corstone1000.dtsi"
+
+/ {
+ model = "corstone1000-fvp";
+
+ ethernet: eth@4010000 {
+ compatible = "smsc,lan91c111";
+ reg = <0x40100000 0x10000>;
+ phy-mode = "mii";
+ interrupt-parent = <&gic>;
+ interrupts = <GIC_SPI 116 0xf04>;
+ reg-io-width = <2>;
+ smsc,irq-push-pull;
+ };
+
+};
+
+&refclk {
+ clock-frequency = <50000000>;
+};
diff --git a/arch/arm/dts/corstone1000.dtsi b/arch/arm/dts/corstone1000.dtsi
new file mode 100644
index 0000000000..b863193fb6
--- /dev/null
+++ b/arch/arm/dts/corstone1000.dtsi
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+/ {
+ compatible = "arm,corstone1000";
+ interrupt-parent = <&gic>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ chosen { };
+
+ cpus {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ cpu@0 {
+ device_type = "cpu";
+ compatible = "arm,armv8";
+ reg = <0>;
+ next-level-cache = <&L2_0>;
+ };
+ };
+
+ memory@80000000 {
+ device_type = "memory";
+ reg = <0x80000000 0x80000000>;
+ };
+
+ gic: interrupt-controller@1c000000 {
+ compatible = "arm,gic-400";
+ #interrupt-cells = <3>;
+ #address-cells = <0>;
+ interrupt-controller;
+ reg = <0x1c010000 0x1000>,
+ <0x1c02f000 0x2000>,
+ <0x1c04f000 0x1000>,
+ <0x1c06f000 0x2000>;
+ interrupts = <1 9 0xf08>;
+ };
+
+ L2_0: l2-cache0 {
+ compatible = "cache";
+ };
+
+ refclk100mhz: refclk100mhz {
+ compatible = "fixed-clock";
+ #clock-cells = <0>;
+ clock-frequency = <100000000>;
+ clock-output-names = "apb_pclk";
+ };
+
+ smbclk: refclk24mhzx2 {
+ /* Reference 24MHz clock x 2 */
+ compatible = "fixed-clock";
+ #clock-cells = <0>;
+ clock-frequency = <48000000>;
+ clock-output-names = "smclk";
+ };
+
+ uartclk: uartclk {
+ /* UART clock - 50MHz */
+ compatible = "fixed-clock";
+ #clock-cells = <0>;
+ clock-frequency = <50000000>;
+ clock-output-names = "uartclk";
+ };
+
+ serial0: uart@1a510000 {
+ compatible = "arm,pl011", "arm,primecell";
+ reg = <0x1a510000 0x1000>;
+ interrupt-parent = <&gic>;
+ interrupts = <0 19 4>;
+ clocks = <&uartclk>, <&refclk100mhz>;
+ clock-names = "uartclk", "apb_pclk";
+ };
+
+ timer {
+ compatible = "arm,armv8-timer";
+ interrupts = <1 13 0xf08>,
+ <1 14 0xf08>,
+ <1 11 0xf08>,
+ <1 10 0xf08>;
+ };
+
+ refclk: refclk@1a220000 {
+ compatible = "arm,armv7-timer-mem";
+ reg = <0x1a220000 0x1000>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+ ranges;
+
+ frame@1a230000 {
+ frame-number = <0>;
+ interrupts = <0 2 0xf04>;
+ reg = <0x1a230000 0x1000>;
+ };
+ };
+
+ mbox_es0mhu0: mhu@1b000000 {
+ compatible = "arm,mhuv2","arm,primecell";
+ reg = <0x1b000000 0x1000>,
+ <0x1b010000 0x1000>;
+ clocks = <&refclk100mhz>;
+ clock-names = "apb_pclk";
+ interrupts = <0 12 4>;
+ interrupt-names = "mhu_rx";
+ #mbox-cells = <1>;
+ mbox-name = "arm-es0-mhu0";
+ };
+
+ mbox_es0mhu1: mhu@1b020000 {
+ compatible = "arm,mhuv2","arm,primecell";
+ reg = <0x1b020000 0x1000>,
+ <0x1b030000 0x1000>;
+ clocks = <&refclk100mhz>;
+ clock-names = "apb_pclk";
+ interrupts = <0 47 4>;
+ interrupt-names = "mhu_rx";
+ #mbox-cells = <1>;
+ mbox-name = "arm-es0-mhu1";
+ };
+
+ mbox_semhu1: mhu@1b820000 {
+ compatible = "arm,mhuv2","arm,primecell";
+ reg = <0x1b820000 0x1000>,
+ <0x1b830000 0x1000>;
+ clocks = <&refclk100mhz>;
+ clock-names = "apb_pclk";
+ interrupts = <0 45 4>;
+ interrupt-names = "mhu_rx";
+ #mbox-cells = <1>;
+ mbox-name = "arm-se-mhu1";
+ };
+
+ client {
+ compatible = "arm,client";
+ mboxes = <&mbox_es0mhu0 0>, <&mbox_es0mhu1 0>, <&mbox_semhu1 0>;
+ mbox-names = "es0mhu0", "es0mhu1", "semhu1";
+ };
+
+ extsys0: extsys@1A010310 {
+ compatible = "arm,extsys_ctrl";
+ reg = <0x1A010310 0x4>,
+ <0x1A010314 0x4>;
+ reg-names = "rstreg", "streg";
+ };
+};
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index fed2b16c93..c7f291efb6 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -4,7 +4,6 @@ CONFIG_SYS_TEXT_BASE=0x02100000
CONFIG_SYS_MALLOC_F_LEN=0x2000
CONFIG_NR_DRAM_BANKS=1
CONFIG_IDENT_STRING=" corstone1000 aarch64 "
-CONFIG_DEFAULT_DEVICE_TREE="corstone1000-mps3"
CONFIG_FIT=y
CONFIG_BOOTDELAY=3
CONFIG_USE_BOOTARGS=y
--
2.33.0
@@ -0,0 +1,34 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Arpita S.K <arpita.s.k@arm.com>
From b50c1457fcd05cddf633bff074fc5edecff22e7e Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Wed, 25 Aug 2021 16:50:40 +0100
Subject: [PATCH 07/16] arm: corstone1000: sharing PSCI DTS node between FVP
and MPS3
At this level of development PSCI is needed to initialize the SMCCC.
SMCCC is needed by FF-A and it is relevant to the MPS3 and FVP.
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
---
arch/arm/dts/corstone1000.dtsi | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/arm/dts/corstone1000.dtsi b/arch/arm/dts/corstone1000.dtsi
index b863193fb6..da1725e01f 100644
--- a/arch/arm/dts/corstone1000.dtsi
+++ b/arch/arm/dts/corstone1000.dtsi
@@ -149,4 +149,8 @@
<0x1A010314 0x4>;
reg-names = "rstreg", "streg";
};
+ psci {
+ compatible = "arm,psci-1.0", "arm,psci-0.2";
+ method = "smc";
+ };
};
--
2.33.0
@@ -0,0 +1,32 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Arpita S.K <arpita.s.k@arm.com>
From 9a045bf04210bf9a00803fc47016e1af59d31e8f Mon Sep 17 00:00:00 2001
From: "Arpita S.K" <Arpita.S.K@arm.com>
Date: Mon, 11 Oct 2021 11:45:41 +0530
Subject: [PATCH 08/16] arm: corstone1000: Emulated RTC Support
This patch adds the options that should be
enabled to turn on emulated RTC support.
Signed-off-by: Arpita S.K <Arpita.S.K@arm.com>
---
configs/corstone1000_defconfig | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index c7f291efb6..dbe3c9e3f3 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -36,3 +36,8 @@ CONFIG_USB=y
CONFIG_DM_USB=y
CONFIG_USB_ISP1760=y
CONFIG_USB_STORAGE=y
+CONFIG_DM_RTC=y
+CONFIG_CMD_RTC=y
+CONFIG_EFI_GET_TIME=y
+CONFIG_EFI_SET_TIME=y
+CONFIG_RTC_EMULATION=y
--
2.33.0
@@ -0,0 +1,31 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Arpita S.K <arpita.s.k@arm.com>
From b720b166364407ceb05385f5e72cb238195622ad Mon Sep 17 00:00:00 2001
From: Vishnu Banavath <vishnu.banavath@arm.com>
Date: Wed, 1 Sep 2021 18:33:32 +0100
Subject: [PATCH 09/16] arm: corstone1000: execute uboot from DDR
Previously uboot was executing from CVM. With the addition of
secure partitions in optee, uboot has been moved to DDR.
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
---
configs/corstone1000_defconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index dbe3c9e3f3..af1c5ecd89 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -1,6 +1,6 @@
CONFIG_ARM=y
CONFIG_TARGET_CORSTONE1000=y
-CONFIG_SYS_TEXT_BASE=0x02100000
+CONFIG_SYS_TEXT_BASE=0x80000000
CONFIG_SYS_MALLOC_F_LEN=0x2000
CONFIG_NR_DRAM_BANKS=1
CONFIG_IDENT_STRING=" corstone1000 aarch64 "
--
2.33.0
@@ -0,0 +1,177 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Arpita S.K <arpita.s.k@arm.com>
From 5278fb64beabeddd6c80229e5165f91ed1e95376 Mon Sep 17 00:00:00 2001
From: Rui Miguel Silva <rui.silva@linaro.org>
Date: Thu, 24 Jun 2021 09:25:00 +0100
Subject: [PATCH 10/16] cmd: load: add load command for memory mapped
cp.b is used a lot as a way to load binaries to memory and execute
them, however we may need to integrate this with the efi subsystem to
set it up as a bootdev.
So, introduce a loadm command that will be consistent with the other
loadX commands and will call the efi API's.
ex: loadm $kernel_addr $kernel_addr_r $kernel_size
with this a kernel with CONFIG_EFI_STUB enabled will be loaded and
then subsequently booted with bootefi command.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
---
cmd/Kconfig | 6 ++++
cmd/bootefi.c | 12 ++++++++
cmd/load.c | 49 ++++++++++++++++++++++++++++++++
include/efi_loader.h | 2 ++
lib/efi_loader/efi_device_path.c | 10 +++++++
5 files changed, 79 insertions(+)
diff --git a/cmd/Kconfig b/cmd/Kconfig
index a9fb4eead2..56fa0ceade 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1048,6 +1048,12 @@ config CMD_LOADB
help
Load a binary file over serial line.
+config CMD_LOADM
+ bool "loadm"
+ default y
+ help
+ Load a binary over memory mapped.
+
config CMD_LOADS
bool "loads"
default y
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index cba81ffe75..9e1b91c89e 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -34,6 +34,18 @@ static struct efi_device_path *bootefi_device_path;
static void *image_addr;
static size_t image_size;
+/**
+ * efi_get_image_parameters() - return image parameters
+ *
+ * @img_addr: address of loaded image in memory
+ * @img_size: size of loaded image
+ */
+void efi_get_image_parameters(void **img_addr, size_t *img_size)
+{
+ *img_addr = image_addr;
+ *img_size = image_size;
+}
+
/**
* efi_clear_bootdev() - clear boot device
*/
diff --git a/cmd/load.c b/cmd/load.c
index b7894d7db0..4de197681c 100644
--- a/cmd/load.c
+++ b/cmd/load.c
@@ -1020,6 +1020,45 @@ static ulong load_serial_ymodem(ulong offset, int mode)
#endif
+#if defined(CONFIG_CMD_LOADM)
+static int do_load_memory_bin(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ ulong addr, dest, size;
+ void *src, *dst;
+
+ if (argc != 4)
+ return CMD_RET_USAGE;
+
+ addr = simple_strtoul(argv[1], NULL, 16);
+
+ dest = simple_strtoul(argv[2], NULL, 16);
+
+ size = simple_strtoul(argv[3], NULL, 16);
+
+
+ if (!size) {
+ puts ("can not load zero bytes\n");
+ return 1;
+ }
+
+ src = map_sysmem(addr, size);
+ dst = map_sysmem(dest, size);
+
+ memcpy(dst, src, size);
+
+ unmap_sysmem(src);
+ unmap_sysmem(dst);
+
+ if (IS_ENABLED(CONFIG_CMD_BOOTEFI))
+ efi_set_bootdev("Mem", "", "", map_sysmem(dest, 0), size);
+
+ printf("loaded bin to memory: size: %lu\n", size);
+
+ return 0;
+}
+#endif
+
/* -------------------------------------------------------------------- */
#if defined(CONFIG_CMD_LOADS)
@@ -1094,3 +1133,13 @@ U_BOOT_CMD(
);
#endif /* CONFIG_CMD_LOADB */
+
+#if defined(CONFIG_CMD_LOADM)
+U_BOOT_CMD(
+ loadm, 4, 0, do_load_memory_bin,
+ "load binary blob from two addresses",
+ "[src_addr] [dst_addr] [size]\n"
+ " - load a binary blob from one memory location to other"
+ " from src_addr to dst_addr by size bytes"
+);
+#endif /* CONFIG_CMD_LOADM */
diff --git a/include/efi_loader.h b/include/efi_loader.h
index b81180cfda..fc4f1ec67a 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -485,6 +485,8 @@ void efi_save_gd(void);
void efi_restore_gd(void);
/* Call this to relocate the runtime section to an address space */
void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map);
+/* Call this to get image parameters */
+void efi_get_image_parameters(void **img_addr, size_t *img_size);
/* Call this to set the current device name */
void efi_set_bootdev(const char *dev, const char *devnr, const char *path,
void *buffer, size_t buffer_size);
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index 76c2f82fe6..a610b6ff0e 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -1170,6 +1170,8 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr,
{
struct blk_desc *desc = NULL;
struct disk_partition fs_partition;
+ size_t image_size;
+ void *image_addr;
int part = 0;
char *filename;
char *s;
@@ -1185,6 +1187,14 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr,
} else if (!strcmp(dev, "Uart")) {
if (device)
*device = efi_dp_from_uart();
+ } else if (!strcmp(dev, "Mem")) {
+
+ efi_get_image_parameters(&image_addr, &image_size);
+
+ if (device)
+ *device = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
+ (uintptr_t)image_addr,
+ image_size);
} else {
part = blk_get_device_part_str(dev, devnr, &desc, &fs_partition,
1);
--
2.33.0
@@ -0,0 +1,61 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Arpita S.K <arpita.s.k@arm.com>
From 283cae5b37eced831080a50d76006359662fb6bf Mon Sep 17 00:00:00 2001
From: Rui Miguel Silva <rui.silva@linaro.org>
Date: Wed, 23 Jun 2021 00:45:38 +0100
Subject: [PATCH 11/16] arm: corstone1000: enable boot using uefi
In a way to prepare future use of uefi features, enable booting using
the bootefi binary loading.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Rui Miguel Silva <rui.silva@arm.com>
---
configs/corstone1000_defconfig | 7 +++++++
include/configs/corstone1000.h | 6 +++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index af1c5ecd89..aa664029fc 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -2,6 +2,7 @@ CONFIG_ARM=y
CONFIG_TARGET_CORSTONE1000=y
CONFIG_SYS_TEXT_BASE=0x80000000
CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_SYS_LOAD_ADDR=0x82100000
CONFIG_NR_DRAM_BANKS=1
CONFIG_IDENT_STRING=" corstone1000 aarch64 "
CONFIG_FIT=y
@@ -14,6 +15,12 @@ CONFIG_HUSH_PARSER=y
CONFIG_SYS_PROMPT="corstone1000# "
# CONFIG_CMD_CONSOLE is not set
CONFIG_CMD_BOOTZ=y
+CONFIG_CMD_BOOTM=y
+CONFIG_CMD_LOADM=y
+CONFIG_CMD_BOOTEFI=y
+CONFIG_EFI_LOADER=y
+CONFIG_CMD_BOOTEFI_HELLO_COMPILE=y
+CONFIG_CMD_BOOTEFI_HELLO=y
# CONFIG_CMD_XIMG is not set
# CONFIG_CMD_EDITENV is not set
# CONFIG_CMD_ENV_EXISTS is not set
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index 389ac45a58..5e22e075ad 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -70,7 +70,7 @@
"fdt_high=0xffffffff\0"
#define CONFIG_BOOTCOMMAND \
- "echo Copying Kernel to memory ... ;" \
- "cp.b $kernel_addr $kernel_addr_r 0xc00000;" \
- "booti $kernel_addr_r - $fdtcontroladdr; "
+ "echo Loading Kernel to memory ... ;" \
+ "loadm $kernel_addr $kernel_addr_r 0xc00000;" \
+ "bootefi $kernel_addr_r $fdtcontroladdr;"
#endif
--
2.33.0
@@ -0,0 +1,32 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Arpita S.K <arpita.s.k@arm.com>
From e49597b8d9058d8c5b925339b0041fd7096c622d Mon Sep 17 00:00:00 2001
From: Rui Miguel Silva <rui.silva@linaro.org>
Date: Tue, 14 Sep 2021 10:46:49 +0100
Subject: [PATCH 12/16] arm: corstone1000: enable uefi secure boot
To make it possible to have a secure way to execute UEFI images
enable UEFI secure boot support and by inherit the
cryptographic functionalities.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
---
configs/corstone1000_defconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index aa664029fc..a8651287ed 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -43,6 +43,7 @@ CONFIG_USB=y
CONFIG_DM_USB=y
CONFIG_USB_ISP1760=y
CONFIG_USB_STORAGE=y
+CONFIG_EFI_SECURE_BOOT=y
CONFIG_DM_RTC=y
CONFIG_CMD_RTC=y
CONFIG_EFI_GET_TIME=y
--
2.33.0
@@ -0,0 +1,47 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Arpita S.K <arpita.s.k@arm.com>
From de37d61d1414cb6408390412cf77d7a88f8964e1 Mon Sep 17 00:00:00 2001
From: Rui Miguel Silva <rui.silva@linaro.org>
Date: Tue, 14 Sep 2021 22:00:47 +0100
Subject: [PATCH 13/16] arm: corstone1000: enable handlers for uefi variables
Enable the setenv/printenv -e option to handle uefi
variables and the efidebug command.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
---
configs/corstone1000_defconfig | 3 +++
1 file changed, 3 insertions(+)
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index a8651287ed..b17e2df47b 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -24,6 +24,7 @@ CONFIG_CMD_BOOTEFI_HELLO=y
# CONFIG_CMD_XIMG is not set
# CONFIG_CMD_EDITENV is not set
# CONFIG_CMD_ENV_EXISTS is not set
+CONFIG_CMD_NVEDIT_EFI=y
# CONFIG_CMD_LOADS is not set
CONFIG_CMD_USB=y
# CONFIG_CMD_ITEST is not set
@@ -33,6 +34,7 @@ CONFIG_CMD_DHCP=y
CONFIG_CMD_MII=y
CONFIG_CMD_PING=y
CONFIG_CMD_CACHE=y
+CONFIG_CMD_EFIDEBUG=y
CONFIG_CMD_FAT=y
CONFIG_OF_CONTROL=y
CONFIG_REGMAP=y
@@ -43,6 +45,7 @@ CONFIG_USB=y
CONFIG_DM_USB=y
CONFIG_USB_ISP1760=y
CONFIG_USB_STORAGE=y
+# CONFIG_HEXDUMP is not set
CONFIG_EFI_SECURE_BOOT=y
CONFIG_DM_RTC=y
CONFIG_CMD_RTC=y
--
2.33.0
@@ -0,0 +1,36 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Arpita S.K <arpita.s.k@arm.com>
From fe0acf22a0c30f7d3eb1a8c66fb423b4146d35ab Mon Sep 17 00:00:00 2001
From: Rui Miguel Silva <rui.silva@linaro.org>
Date: Tue, 14 Sep 2021 22:07:15 +0100
Subject: [PATCH 14/16] arm: dipha: enable efi capsule options
Enable the set of efi capsule config options to enable the
variables.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
---
configs/corstone1000_defconfig | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index b17e2df47b..cfe80cf5f4 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -46,6 +46,12 @@ CONFIG_DM_USB=y
CONFIG_USB_ISP1760=y
CONFIG_USB_STORAGE=y
# CONFIG_HEXDUMP is not set
+CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y
+CONFIG_EFI_CAPSULE_ON_DISK=y
+CONFIG_EFI_CAPSULE_ON_DISK_EARLY=y
+CONFIG_EFI_CAPSULE_AUTHENTICATE=y
+CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y
+CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y
CONFIG_EFI_SECURE_BOOT=y
CONFIG_DM_RTC=y
CONFIG_CMD_RTC=y
--
2.33.0
@@ -0,0 +1,64 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Arpita S.K <arpita.s.k@arm.com>
From a3b3ff8fc2d4e52748989aa61f155fc92a63261a Mon Sep 17 00:00:00 2001
From: Rui Miguel Silva <rui.silva@linaro.org>
Date: Tue, 22 Jun 2021 11:35:10 +0100
Subject: [PATCH 15/16] arm: dts: add initial devicetree corstone1000 mps3
Corstone1000 is a platform enabled on MPS3 FPGA Arm board. It is a cortex-a35
with with 8MB of CVM and 32MB of QSPI, with the peripherals USB,
ethernet and others available on the MPS3 board.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
---
arch/arm/dts/corstone1000-mps3.dts | 37 ++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100644 arch/arm/dts/corstone1000-mps3.dts
diff --git a/arch/arm/dts/corstone1000-mps3.dts b/arch/arm/dts/corstone1000-mps3.dts
new file mode 100644
index 0000000000..d93915dbb7
--- /dev/null
+++ b/arch/arm/dts/corstone1000-mps3.dts
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/dts-v1/;
+
+#include "corstone1000.dtsi"
+
+/ {
+ model = "corstone1000-mps3";
+
+ ethernet: eth@4010000 {
+ compatible = "smsc,lan9220", "smsc,lan9115";
+ reg = <0x40100000 0x10000>;
+ phy-mode = "mii";
+ interrupt-parent = <&gic>;
+ interrupts = <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>;
+ reg-io-width = <2>;
+ smsc,irq-push-pull;
+ };
+
+ usb: usb@40200000 {
+ compatible = "nxp,usb-isp1763";
+ reg = <0x40200000 0x100000>;
+ interrupts-parent = <&gic>;
+ interrupts = <GIC_SPI 114 IRQ_TYPE_LEVEL_HIGH>;
+ bus-width = <16>;
+ dr_mode = "host";
+ };
+
+};
+
+&refclk {
+ clock-frequency = <50000000>;
+};
--
2.33.0
@@ -0,0 +1,34 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Arpita S.K <arpita.s.k@arm.com>
From b5ec956659c3e419fd2e95431d9359db497e4afb Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Thu, 22 Jul 2021 18:11:33 +0100
Subject: [PATCH 16/16] arm: corstone1000: adding PSCI device tree node
At this level of development PSCI is needed to initialize the SMCCC.
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
---
arch/arm/dts/corstone1000-mps3.dts | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm/dts/corstone1000-mps3.dts b/arch/arm/dts/corstone1000-mps3.dts
index d93915dbb7..a3726f1e1f 100644
--- a/arch/arm/dts/corstone1000-mps3.dts
+++ b/arch/arm/dts/corstone1000-mps3.dts
@@ -30,6 +30,11 @@
dr_mode = "host";
};
+ psci {
+ compatible = "arm,psci-1.0", "arm,psci-0.2";
+ method = "smc";
+ };
+
};
&refclk {
--
2.33.0
@@ -0,0 +1,32 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
From 3ee38ef07bd82c843497dc4e69a4d4c5f21dbbf7 Mon Sep 17 00:00:00 2001
From: Vishnu Banavath <vishnu.banavath@arm.com>
Date: Tue, 26 Oct 2021 18:29:05 +0100
Subject: [PATCH] arm: corstone1000: amend kernel bootargs with ip=dhcp
earlyprintk
This change is to
* pass ip=dhcp required for ethernet to get and ip
* enable earlyprintk to print kernel logs before the actual
kernel driver comes up
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index cfe80cf5f4..7574553e83 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -8,7 +8,7 @@ CONFIG_IDENT_STRING=" corstone1000 aarch64 "
CONFIG_FIT=y
CONFIG_BOOTDELAY=3
CONFIG_USE_BOOTARGS=y
-CONFIG_BOOTARGS="console=ttyAMA0 loglevel=9"
+CONFIG_BOOTARGS="console=ttyAMA0 loglevel=9 ip=dhcp earlyprintk"
# CONFIG_DISPLAY_CPUINFO is not set
# CONFIG_DISPLAY_BOARDINFO is not set
CONFIG_HUSH_PARSER=y
--
2.17.1
@@ -0,0 +1,344 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
From d65bce43228e85319f515e47f3490801fe02498b Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Tue, 16 Nov 2021 12:36:27 +0000
Subject: [PATCH 2/5] arm_ffa: introducing armffa command
A new armffa command is provided as an example of how to use
the FF-A helper functions to communicate with secure world.
The armffa command allows to query secure partitions data from
the secure world and exchanging messages with the partitions.
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
---
MAINTAINERS | 1 +
cmd/Kconfig | 10 ++
cmd/Makefile | 2 +
cmd/armffa.c | 266 +++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 279 insertions(+)
create mode 100644 cmd/armffa.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 77b40f4689..ca4dd584e2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -218,6 +218,7 @@ F: include/configs/turris_*.h
ARM FF-A
M: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
S: Maintained
+F: cmd/armffa.c
F: drivers/arm-ffa/
F: include/arm_ffa.h
F: include/arm_ffa_helper.h
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 56fa0ceade..b7beedd883 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -785,6 +785,16 @@ endmenu
menu "Device access commands"
+config CMD_ARMFFA
+ bool "Arm FF-A test command"
+ depends on ARM_FFA_TRANSPORT
+ help
+ Provides a test command for the Arm FF-A driver
+ supported options:
+ - Listing the partition(s) info
+ - Sending a data pattern to the specified partition
+ - Displaying the arm_ffa device info
+
config CMD_ARMFLASH
#depends on FLASH_CFI_DRIVER
bool "armflash"
diff --git a/cmd/Makefile b/cmd/Makefile
index 9d10e07f0e..dcd25168ab 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -12,6 +12,8 @@ obj-y += panic.o
obj-y += version.o
# command
+
+obj-$(CONFIG_CMD_ARMFFA) += armffa.o
obj-$(CONFIG_CMD_ACPI) += acpi.o
obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o
obj-$(CONFIG_CMD_AES) += aes.o
diff --git a/cmd/armffa.c b/cmd/armffa.c
new file mode 100644
index 0000000000..71a6ebb656
--- /dev/null
+++ b/cmd/armffa.c
@@ -0,0 +1,266 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2021 ARM Limited
+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+ */
+
+#include <arm_ffa_helper.h>
+#include <asm/io.h>
+#include <common.h>
+#include <command.h>
+#include <dm.h>
+#include <mapmem.h>
+#include <stdlib.h>
+
+/**
+ * do_ffa_get_singular_partition_info - implementation of the getpart subcommand
+ * @cmdtp: Command Table
+ * @flag: flags
+ * @argc: number of arguments
+ * @argv: arguments
+ *
+ * This function queries the secure partition information which the UUID is provided
+ * as an argument. The function uses the arm_ffa driver helper function
+ * to retrieve the data.
+ * The input UUID string is expected to be in big endian format.
+ *
+ * Return:
+ *
+ * CMD_RET_SUCCESS: on success, otherwise failure
+ */
+static int do_ffa_get_singular_partition_info(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ struct ffa_interface_data func_data = {0};
+ u32 count = 0;
+ int ret;
+ union ffa_partition_uuid service_uuid = {0};
+ struct ffa_partition_info *parts_info;
+ u32 info_idx;
+
+ if (argc != 1)
+ return -EINVAL;
+
+ if (ffa_uuid_str_to_bin(argv[0], (unsigned char *)&service_uuid)) {
+ ffa_err("Invalid UUID");
+ return -EINVAL;
+ }
+
+ /*
+ * get from the driver the count of the SPs matching the UUID
+ */
+ func_data.data0_size = sizeof(service_uuid);
+ func_data.data0 = &service_uuid;
+ func_data.data1_size = sizeof(count);
+ func_data.data1 = &count;
+
+ ret = ffa_helper_get_partitions_info(&func_data);
+ if (ret != FFA_ERR_STAT_SUCCESS) {
+ ffa_err("Failure in querying partitions count (error code: %d)", ret);
+ return ret;
+ }
+
+ if (!count) {
+ ffa_info("No secure partition found");
+ return ret;
+ }
+
+ /*
+ * pre-allocate a buffer to be filled by the driver
+ * with ffa_partition_info structs
+ */
+
+ parts_info = calloc(count, sizeof(struct ffa_partition_info));
+ if (!parts_info)
+ return -EINVAL;
+
+ ffa_info("Pre-allocating %d partition(s) info structures", count);
+
+ func_data.data1_size = count * sizeof(struct ffa_partition_info);
+ func_data.data1 = parts_info;
+
+ /*
+ * ask the driver to fill the buffer with the SPs info
+ */
+ ret = ffa_helper_get_partitions_info(&func_data);
+ if (ret != FFA_ERR_STAT_SUCCESS) {
+ ffa_err("Failure in querying partition(s) info (error code: %d)", ret);
+ free(parts_info);
+ return ret;
+ }
+
+ /*
+ * SPs found , show the partition information
+ */
+ for (info_idx = 0; info_idx < count ; info_idx++) {
+ ffa_info("Partition: id = 0x%x , exec_ctxt 0x%x , properties 0x%x",
+ parts_info[info_idx].id,
+ parts_info[info_idx].exec_ctxt,
+ parts_info[info_idx].properties);
+ }
+
+ free(parts_info);
+
+ return 0;
+}
+
+/**
+ * do_ffa_msg_send_direct_req - implementation of the ping subcommand
+ * @cmdtp: Command Table
+ * @flag: flags
+ * @argc: number of arguments
+ * @argv: arguments
+ *
+ * This function sends data to the secure partition which the ID is provided
+ * as an argument. The function uses the arm_ffa driver helper function
+ * to send data.
+ *
+ * Return:
+ *
+ * CMD_RET_SUCCESS: on success, otherwise failure
+ */
+int do_ffa_msg_send_direct_req(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ struct ffa_interface_data func_data = {0};
+ struct ffa_send_direct_data msg = {0};
+ u32 pattern = 0xaabbccd0;
+ u16 part_id;
+ int ret;
+
+ if (argc != 1)
+ return -EINVAL;
+
+ errno = 0;
+ part_id = strtoul(argv[0], NULL, 16);
+
+ if (errno) {
+ ffa_err("Invalid partition ID");
+ return -EINVAL;
+ }
+
+ /*
+ * telling the driver which partition to use
+ */
+ func_data.data0_size = sizeof(part_id);
+ func_data.data0 = &part_id;
+
+ /*
+ * filling the message data
+ */
+ msg.a3 = ++pattern;
+ msg.a4 = ++pattern;
+ msg.a5 = ++pattern;
+ msg.a6 = ++pattern;
+ msg.a7 = ++pattern;
+ func_data.data1_size = sizeof(msg);
+ func_data.data1 = &msg;
+
+ ret = ffa_helper_msg_send_direct_req(&func_data);
+ if (ret == FFA_ERR_STAT_SUCCESS) {
+ u8 cnt;
+
+ ffa_info("SP response:\n[LSB]");
+ for (cnt = 0;
+ cnt < sizeof(struct ffa_send_direct_data) / sizeof(u32);
+ cnt++)
+ ffa_info("0x%x", ((u32 *)&msg)[cnt]);
+ } else {
+ ffa_err("Sending direct request error (%d)", ret);
+ }
+
+ return ret;
+}
+
+/**
+ *do_ffa_dev_list - implementation of the devlist subcommand
+ * @cmdtp: [in] Command Table
+ * @flag: flags
+ * @argc: number of arguments
+ * @argv: arguments
+ *
+ * This function queries the devices belonging to the UCLASS_FFA
+ * class. Currently, one device is expected to show up: the arm_ffa device
+ *
+ * Return:
+ *
+ * CMD_RET_SUCCESS: on success, otherwise failure
+ */
+int do_ffa_dev_list(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+ struct udevice *dev = NULL;
+ int i, ret;
+
+ ffa_info("arm_ffa uclass entries:");
+
+ for (i = 0, ret = uclass_first_device(UCLASS_FFA, &dev);
+ dev;
+ ret = uclass_next_device(&dev), i++) {
+ if (ret)
+ break;
+
+ ffa_info("entry %d - instance %08x, ops %08x, plat %08x",
+ i,
+ (u32)map_to_sysmem(dev),
+ (u32)map_to_sysmem(dev->driver->ops),
+ (u32)map_to_sysmem(dev_get_plat(dev)));
+ }
+
+ return cmd_process_error(cmdtp, ret);
+}
+
+static struct cmd_tbl armffa_commands[] = {
+ U_BOOT_CMD_MKENT(getpart, 1, 1, do_ffa_get_singular_partition_info, "", ""),
+ U_BOOT_CMD_MKENT(ping, 1, 1, do_ffa_msg_send_direct_req, "", ""),
+ U_BOOT_CMD_MKENT(devlist, 0, 1, do_ffa_dev_list, "", ""),
+};
+
+/**
+ * do_armffa - the armffa command main function
+ * @cmdtp: Command Table
+ * @flag: flags
+ * @argc: number of arguments
+ * @argv: arguments
+ *
+ * This function identifies which armffa subcommand to run.
+ * Then, it makes sure the arm_ffa device is probed and
+ * ready for use.
+ * Then, it runs the subcommand.
+ *
+ * Return:
+ *
+ * CMD_RET_SUCCESS: on success, otherwise failure
+ */
+static int do_armffa(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+ struct cmd_tbl *armffa_cmd;
+ int ret;
+
+ if (argc < 2)
+ return CMD_RET_USAGE;
+
+ armffa_cmd = find_cmd_tbl(argv[1], armffa_commands, ARRAY_SIZE(armffa_commands));
+
+ argc -= 2;
+ argv += 2;
+
+ if (!armffa_cmd || argc > armffa_cmd->maxargs)
+ return CMD_RET_USAGE;
+
+ ret = ffa_helper_init_device();
+ if (ret != FFA_ERR_STAT_SUCCESS)
+ return cmd_process_error(cmdtp, ret);
+
+ ret = armffa_cmd->cmd(armffa_cmd, flag, argc, argv);
+
+ return cmd_process_error(armffa_cmd, ret);
+}
+
+U_BOOT_CMD(armffa, 4, 1, do_armffa,
+ "Arm FF-A operations test command",
+ "getpart <partition UUID>\n"
+ " - lists the partition(s) info\n"
+ "ping <partition ID>\n"
+ " - sends a data pattern to the specified partition\n"
+ "devlist\n"
+ " - displays the arm_ffa device info\n");
--
2.17.1
@@ -0,0 +1,134 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
From b77c6c2c8c0dff9a41e1dbb9a4e9c1ecac00c7f6 Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Tue, 16 Nov 2021 12:38:48 +0000
Subject: [PATCH 3/5] arm_ffa: introducing test module for UCLASS_FFA
This is the test module for the UCLASS_FFA class.
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
---
MAINTAINERS | 1 +
test/dm/Makefile | 1 +
test/dm/ffa.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++
test/dm/ffa.h | 19 ++++++++++++++++
4 files changed, 77 insertions(+)
create mode 100644 test/dm/ffa.c
create mode 100644 test/dm/ffa.h
diff --git a/MAINTAINERS b/MAINTAINERS
index ca4dd584e2..e73637e127 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -223,6 +223,7 @@ F: drivers/arm-ffa/
F: include/arm_ffa.h
F: include/arm_ffa_helper.h
F: lib/arm-ffa/
+F: test/dm/ffa.c
ARM FREESCALE IMX
M: Stefano Babic <sbabic@denx.de>
diff --git a/test/dm/Makefile b/test/dm/Makefile
index c9644617a1..c48f034584 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -74,6 +74,7 @@ obj-$(CONFIG_POWER_DOMAIN) += power-domain.o
obj-$(CONFIG_ACPI_PMC) += pmc.o
obj-$(CONFIG_DM_PMIC) += pmic.o
obj-$(CONFIG_DM_PWM) += pwm.o
+obj-$(CONFIG_ARM_FFA_TRANSPORT) += ffa.o
obj-$(CONFIG_QFW) += qfw.o
obj-$(CONFIG_RAM) += ram.o
obj-y += regmap.o
diff --git a/test/dm/ffa.c b/test/dm/ffa.c
new file mode 100644
index 0000000000..b937cea57b
--- /dev/null
+++ b/test/dm/ffa.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test for UCLASS_FFA class
+ *
+ * (C) Copyright 2021 ARM Limited
+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dm/test.h>
+#include <test/test.h>
+#include <test/ut.h>
+#include <arm_ffa_helper.h>
+#include "ffa.h"
+
+/* Basic test of 'armffa' command */
+static int dm_test_armffa_cmd(struct unit_test_state *uts)
+{
+ ut_assertok(ffa_helper_init_device());
+
+ ut_assertok(console_record_reset_enable());
+
+ /* armffa getpart <UUID> */
+ ut_assertok(run_command("armffa getpart " SE_PROXY_PARTITION_UUID, 0));
+ ut_assert_console_end();
+
+ /* armffa ping <ID> */
+ ut_assertok(run_command("armffa ping " SE_PROXY_PARTITION_ID, 0));
+ ut_assert_console_end();
+
+ /* armffa devlist */
+ ut_assertok(run_command("armffa devlist", 0));
+ ut_assert_console_end();
+
+ return 0;
+}
+
+DM_TEST(dm_test_armffa_cmd, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_CONSOLE_REC);
+
+static int test_ffa_msg_send_direct_req(void)
+{
+ char *const argv[1] = {SE_PROXY_PARTITION_ID}; /* Corstone1000 SE Proxy ID */
+
+ return do_ffa_msg_send_direct_req(NULL, 0, 1, argv);
+}
+
+/* Basic test of the FFA uclass */
+static int dm_test_ffa_uclass(struct unit_test_state *uts)
+{
+ ut_assertok(ffa_init_device());
+ ut_assertok(test_ffa_msg_send_direct_req());
+ return 0;
+}
+
+DM_TEST(dm_test_ffa_uclass, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/ffa.h b/test/dm/ffa.h
new file mode 100644
index 0000000000..a0802bd692
--- /dev/null
+++ b/test/dm/ffa.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2021 ARM Limited
+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+ */
+
+#ifndef __TEST_DM_FFA_H
+#define __TEST_DM_FFA_H
+
+#define SE_PROXY_PARTITION_ID "0x8002"
+#define SE_PROXY_PARTITION_UUID "46bb39d1-b4d9-45b5-88ff-040027dab249"
+
+/**
+ * do_ffa_msg_send_direct_req - implementation of the ping subcommand
+ */
+int do_ffa_msg_send_direct_req(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[]);
+
+#endif /*__TEST_DM_FFA_H */
--
2.17.1
@@ -0,0 +1,383 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
From f84b0592d5456aee690164d195f3bfe592086a06 Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Wed, 13 Oct 2021 17:51:44 +0100
Subject: [PATCH 4/5] arm_ffa: introducing MM communication with FF-A
This commit allows to perform MM communication using FF-A transport.
The MM SP (also called partition) can be StandAlonneMM or smm-gateway.
Both partitions run in OP-TEE.
When using the u-boot FF-A driver, StandAlonneMM and smm-gateway are
supported.
On EFI services such as GetVariable()/SetVariable(), the data
is copied from the communication buffer to the MM shared buffer.
Then, notifies the MM SP about data availability in the MM shared buffer.
Communication with the MM SP is performed using FF-A transport.
On such event, MM SP can read the data and updates the MM shared buffer
with response data.
The response data is copied back to the communication buffer.
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
---
lib/efi_loader/Kconfig | 14 +-
lib/efi_loader/efi_variable_tee.c | 255 +++++++++++++++++++++++++++++-
2 files changed, 263 insertions(+), 6 deletions(-)
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 156b391521..120b656504 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -53,13 +53,23 @@ config EFI_VARIABLE_FILE_STORE
stored as file /ubootefi.var on the EFI system partition.
config EFI_MM_COMM_TEE
- bool "UEFI variables storage service via OP-TEE"
- depends on OPTEE
+ bool "UEFI variables storage service via the trusted world"
+ depends on OPTEE || ARM_FFA_TRANSPORT
help
+ The MM SP (also called partition) can be StandAlonneMM or smm-gateway.
+ When using the u-boot OP-TEE driver, StandAlonneMM is supported.
+ When using the u-boot FF-A driver, StandAlonneMM and smm-gateway are supported.
+
If OP-TEE is present and running StandAloneMM, dispatch all UEFI
variable related operations to that. The application will verify,
authenticate and store the variables on an RPMB.
+ When ARM_FFA_TRANSPORT is used, dispatch all UEFI variable related
+ operations to the MM SP running under Optee in the trusted world.
+ A door bell mechanism is used to notify the SP when there is data in the shared
+ MM buffer. The data is copied by u-boot to thea shared buffer before issuing
+ the door bell event.
+
endchoice
config EFI_VARIABLES_PRESEED
diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c
index 51920bcb51..b363ec92bf 100644
--- a/lib/efi_loader/efi_variable_tee.c
+++ b/lib/efi_loader/efi_variable_tee.c
@@ -15,7 +15,28 @@
#include <malloc.h>
#include <mm_communication.h>
+#if (IS_ENABLED(CONFIG_OPTEE))
#define OPTEE_PAGE_SIZE BIT(12)
+#endif
+
+#if (IS_ENABLED(CONFIG_ARM_FFA_TRANSPORT))
+
+#include <arm_ffa_helper.h>
+#include <mapmem.h>
+
+/* MM return codes */
+#define MM_SUCCESS (0)
+
+#define ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64 (0xC4000061)
+#define ARM_SVC_ID_SP_EVENT_COMPLETE ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64
+
+/* MM_SP_UUID_DATA defined by the platform */
+union ffa_partition_uuid mm_sp_svc_uuid = {.bytes = {MM_SP_UUID_DATA}};
+
+static u16 __efi_runtime_data mm_sp_id;
+
+#endif
+
extern struct efi_var_file __efi_runtime_data *efi_var_buf;
static efi_uintn_t max_buffer_size; /* comm + var + func + data */
static efi_uintn_t max_payload_size; /* func + data */
@@ -25,6 +46,7 @@ struct mm_connection {
u32 session;
};
+#if (IS_ENABLED(CONFIG_OPTEE))
/**
* get_connection() - Retrieve OP-TEE session for a specific UUID.
*
@@ -140,16 +162,229 @@ static efi_status_t optee_mm_communicate(void *comm_buf, ulong dsize)
return ret;
}
+#endif
+
+#if (IS_ENABLED(CONFIG_ARM_FFA_TRANSPORT))
+
+/**
+ * ffa_notify_mm_sp() - Announce there is data in the shared buffer
+ *
+ * Notifies the MM partition in the trusted world that
+ * data is available in the shared buffer.
+ * This is a blocking call during which trusted world has exclusive access
+ * to the MM shared buffer.
+ *
+ * Return:
+ *
+ * 0 on success
+ */
+static int __efi_runtime ffa_notify_mm_sp(void)
+{
+ struct ffa_interface_data func_data = {0};
+ struct ffa_send_direct_data msg = {0};
+ int ret;
+ u32 sp_event_complete;
+ int sp_event_ret;
+
+ func_data.data0_size = sizeof(mm_sp_id);
+ func_data.data0 = &mm_sp_id;
+
+ msg.a3 = FFA_SHARED_MM_BUFFER_ADDR;
+ msg.a4 = FFA_SHARED_MM_BUFFER_SIZE;
+ func_data.data1_size = sizeof(msg);
+ func_data.data1 = &msg;
+
+ ret = ffa_helper_msg_send_direct_req(&func_data);
+ if (ret != FFA_ERR_STAT_SUCCESS) {
+ log_err("EFI: Failure to notify the MM SP , FF-A error (%d)\n", ret);
+ return ret;
+ }
+
+ sp_event_complete = msg.a3;
+ sp_event_ret = (int)msg.a4;
+
+ if (sp_event_complete == ARM_SVC_ID_SP_EVENT_COMPLETE && sp_event_ret == MM_SUCCESS)
+ return 0;
+
+ log_err("EFI: Failure to notify the MM SP (0x%x , %d)\n",
+ sp_event_complete,
+ sp_event_ret);
+
+ return -EACCES;
+}
+
+/**
+ * ffa_discover_mm_sp_id() - Query the MM partition ID
+ *
+ * Use the FF-A driver to get the MM partition ID.
+ * If multiple partitions are found, use the first one
+ *
+ * Return:
+ *
+ * 0 on success
+ */
+static int __efi_runtime ffa_discover_mm_sp_id(void)
+{
+ struct ffa_interface_data func_data = {0};
+ u32 count = 0;
+ int ret;
+ struct ffa_partition_info *parts_info;
+
+ /*
+ * get from the driver the count of the SPs matching the UUID
+ */
+ func_data.data0_size = sizeof(mm_sp_svc_uuid);
+ func_data.data0 = &mm_sp_svc_uuid;
+ func_data.data1_size = sizeof(count);
+ func_data.data1 = &count;
+
+ ret = ffa_helper_get_partitions_info(&func_data);
+ if (ret != FFA_ERR_STAT_SUCCESS) {
+ log_err("EFI: Failure in querying partitions count (error code: %d)\n", ret);
+ return ret;
+ }
+
+ if (!count) {
+ log_info("EFI: No MM partition found\n");
+ return ret;
+ }
+
+ /*
+ * pre-allocate a buffer to be filled by the driver
+ * with ffa_partition_info structs
+ */
+
+ parts_info = calloc(count, sizeof(struct ffa_partition_info));
+ if (!parts_info)
+ return -EINVAL;
+
+ log_info("EFI: Pre-allocating %d partition(s) info structures\n", count);
+
+ func_data.data1_size = count *
+ sizeof(struct ffa_partition_info);
+ func_data.data1 = parts_info;
+
+ /*
+ * ask the driver to fill the
+ * buffer with the SPs info
+ */
+ ret = ffa_helper_get_partitions_info(&func_data);
+ if (ret != FFA_ERR_STAT_SUCCESS) {
+ log_err("EFI: Failure in querying partition(s) info (error code: %d)\n", ret);
+ free(parts_info);
+ return ret;
+ }
+
+ /*
+ * MM SPs found , use the first one
+ */
+
+ mm_sp_id = parts_info[0].id;
+
+ log_info("EFI: MM partition ID 0x%x\n", mm_sp_id);
+
+ free(parts_info);
+
+ return 0;
+}
+
+/**
+ * ffa_mm_communicate() - Exchange EFI services data with the MM partition using FF-A
+ * @comm_buf: locally allocated communication buffer used for for rx/tx
+ * @dsize: communication buffer size
+ *
+ * Issues a door bell event to notify the MM partition (SP) running in OP-TEE
+ * that there is data to read from the shared buffer.
+ * Communication with the MM SP is performed using FF-A transport.
+ * On the event, MM SP can read the data from the buffer and
+ * update the MM shared buffer with response data.
+ * The response data is copied back to the communication buffer.
+ *
+ * Return:
+ *
+ * EFI status code
+ */
+static efi_status_t __efi_runtime ffa_mm_communicate(void *comm_buf, ulong comm_buf_size)
+{
+ ulong tx_data_size;
+ int ffa_ret;
+ struct efi_mm_communicate_header *mm_hdr;
+ void *virt_shared_buf;
+
+ if (!comm_buf)
+ return EFI_INVALID_PARAMETER;
+
+ /* Discover MM partition ID */
+ if (!mm_sp_id && ffa_discover_mm_sp_id() != FFA_ERR_STAT_SUCCESS) {
+ log_err("EFI: Failure to discover MM partition ID\n");
+ return EFI_UNSUPPORTED;
+ }
+
+ mm_hdr = (struct efi_mm_communicate_header *)comm_buf;
+ tx_data_size = mm_hdr->message_len + sizeof(efi_guid_t) + sizeof(size_t);
+
+ if (comm_buf_size != tx_data_size || tx_data_size > FFA_SHARED_MM_BUFFER_SIZE)
+ return EFI_INVALID_PARAMETER;
+
+ /* Copy the data to the shared buffer */
+
+ virt_shared_buf = (void *)map_sysmem((phys_addr_t)FFA_SHARED_MM_BUFFER_ADDR, 0);
+ efi_memcpy_runtime(virt_shared_buf, comm_buf, tx_data_size);
+
+ /* Announce there is data in the shared buffer */
+
+ ffa_ret = ffa_notify_mm_sp();
+ if (ffa_ret)
+ unmap_sysmem(virt_shared_buf);
+
+ switch (ffa_ret) {
+ case 0:
+ {
+ ulong rx_data_size;
+ /* Copy the MM SP response from the shared buffer to the communication buffer */
+ rx_data_size = ((struct efi_mm_communicate_header *)virt_shared_buf)->message_len +
+ sizeof(efi_guid_t) +
+ sizeof(size_t);
+
+ if (rx_data_size > comm_buf_size) {
+ unmap_sysmem(virt_shared_buf);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ efi_memcpy_runtime(comm_buf, virt_shared_buf, rx_data_size);
+ unmap_sysmem(virt_shared_buf);
+
+ return EFI_SUCCESS;
+ }
+ case -EINVAL:
+ return EFI_DEVICE_ERROR;
+ case -EPERM:
+ return EFI_INVALID_PARAMETER;
+ case -EACCES:
+ return EFI_ACCESS_DENIED;
+ case -EBUSY:
+ return EFI_OUT_OF_RESOURCES;
+ default:
+ return EFI_ACCESS_DENIED;
+ }
+}
+#endif
/**
- * mm_communicate() - Adjust the cmonnucation buffer to StandAlonneMM and send
+ * mm_communicate() - Adjust the communication buffer to the MM SP and send
* it to OP-TEE
*
- * @comm_buf: locally allocted communcation buffer
+ * @comm_buf: locally allocted communication buffer
* @dsize: buffer size
+ *
+ * The MM SP (also called partition) can be StandAlonneMM or smm-gateway.
+ * The comm_buf format is the same for both partitions.
+ * When using the u-boot OP-TEE driver, StandAlonneMM is supported.
+ * When using the u-boot FF-A driver, StandAlonneMM and smm-gateway are supported.
+ *
* Return: status code
*/
-static efi_status_t mm_communicate(u8 *comm_buf, efi_uintn_t dsize)
+static efi_status_t __efi_runtime mm_communicate(u8 *comm_buf, efi_uintn_t dsize)
{
efi_status_t ret;
struct efi_mm_communicate_header *mm_hdr;
@@ -159,7 +394,11 @@ static efi_status_t mm_communicate(u8 *comm_buf, efi_uintn_t dsize)
mm_hdr = (struct efi_mm_communicate_header *)comm_buf;
var_hdr = (struct smm_variable_communicate_header *)mm_hdr->data;
+ #if (IS_ENABLED(CONFIG_OPTEE))
ret = optee_mm_communicate(comm_buf, dsize);
+ #elif (IS_ENABLED(CONFIG_ARM_FFA_TRANSPORT))
+ ret = ffa_mm_communicate(comm_buf, dsize);
+ #endif
if (ret != EFI_SUCCESS) {
log_err("%s failed!\n", __func__);
return ret;
@@ -255,6 +494,8 @@ efi_status_t EFIAPI get_max_payload(efi_uintn_t *size)
goto out;
}
*size = var_payload->size;
+
+ #if (IS_ENABLED(CONFIG_OPTEE))
/*
* Although the max payload is configurable on StMM, we only share a
* single page from OP-TEE for the non-secure buffer used to communicate
@@ -264,6 +505,12 @@ efi_status_t EFIAPI get_max_payload(efi_uintn_t *size)
if (*size > OPTEE_PAGE_SIZE)
*size = OPTEE_PAGE_SIZE - MM_COMMUNICATE_HEADER_SIZE -
MM_VARIABLE_COMMUNICATE_SIZE;
+ #elif (IS_ENABLED(CONFIG_ARM_FFA_TRANSPORT))
+ if (*size > FFA_SHARED_MM_BUFFER_SIZE)
+ *size = FFA_SHARED_MM_BUFFER_SIZE - MM_COMMUNICATE_HEADER_SIZE -
+ MM_VARIABLE_COMMUNICATE_SIZE;
+ #endif
+
/*
* There seems to be a bug in EDK2 miscalculating the boundaries and
* size checks, so deduct 2 more bytes to fulfill this requirement. Fix
@@ -690,7 +937,7 @@ void efi_variables_boot_exit_notify(void)
ret = EFI_NOT_FOUND;
if (ret != EFI_SUCCESS)
- log_err("Unable to notify StMM for ExitBootServices\n");
+ log_err("Unable to notify the MM partition for ExitBootServices\n");
free(comm_buf);
/*
--
2.17.1
@@ -0,0 +1,112 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
From a0841a2072215b1912d95224de204c7a013650f0 Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Tue, 2 Nov 2021 16:44:39 +0000
Subject: [PATCH 5/5] arm_ffa: corstone1000: enable FF-A and MM support
This commit allows corstone1000 platform to perform
MM communication between u-boot and the secure world
using FF-A transport.
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
---
arch/arm/dts/corstone1000-fvp.dts | 4 ++++
arch/arm/dts/corstone1000-mps3.dts | 4 ++++
arch/arm/dts/corstone1000.dtsi | 7 +++++++
configs/corstone1000_defconfig | 5 +++++
include/configs/corstone1000.h | 14 ++++++++++++++
5 files changed, 34 insertions(+)
diff --git a/arch/arm/dts/corstone1000-fvp.dts b/arch/arm/dts/corstone1000-fvp.dts
index 2188ca5e0e..92da15df4e 100644
--- a/arch/arm/dts/corstone1000-fvp.dts
+++ b/arch/arm/dts/corstone1000-fvp.dts
@@ -26,3 +26,7 @@
&refclk {
clock-frequency = <50000000>;
};
+
+&arm_ffa {
+ status = "okay";
+};
diff --git a/arch/arm/dts/corstone1000-mps3.dts b/arch/arm/dts/corstone1000-mps3.dts
index a3726f1e1f..6842395405 100644
--- a/arch/arm/dts/corstone1000-mps3.dts
+++ b/arch/arm/dts/corstone1000-mps3.dts
@@ -40,3 +40,7 @@
&refclk {
clock-frequency = <50000000>;
};
+
+&arm_ffa {
+ status = "okay";
+};
diff --git a/arch/arm/dts/corstone1000.dtsi b/arch/arm/dts/corstone1000.dtsi
index da1725e01f..97dfac9ae7 100644
--- a/arch/arm/dts/corstone1000.dtsi
+++ b/arch/arm/dts/corstone1000.dtsi
@@ -153,4 +153,11 @@
compatible = "arm,psci-1.0", "arm,psci-0.2";
method = "smc";
};
+
+ arm_ffa: arm_ffa {
+ compatible = "arm,ffa";
+ method = "smc";
+ status = "disabled";
+ };
+
};
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index 7574553e83..abd52af8fc 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -9,6 +9,7 @@ CONFIG_FIT=y
CONFIG_BOOTDELAY=3
CONFIG_USE_BOOTARGS=y
CONFIG_BOOTARGS="console=ttyAMA0 loglevel=9 ip=dhcp earlyprintk"
+CONFIG_LOGLEVEL=7
# CONFIG_DISPLAY_CPUINFO is not set
# CONFIG_DISPLAY_BOARDINFO is not set
CONFIG_HUSH_PARSER=y
@@ -45,6 +46,10 @@ CONFIG_USB=y
CONFIG_DM_USB=y
CONFIG_USB_ISP1760=y
CONFIG_USB_STORAGE=y
+CONFIG_ARM_FFA_TRANSPORT=y
+CONFIG_EFI_MM_COMM_TEE=y
+# CONFIG_OPTEE is not set
+# CONFIG_GENERATE_SMBIOS_TABLE is not set
# CONFIG_HEXDUMP is not set
CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y
CONFIG_EFI_CAPSULE_ON_DISK=y
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index 5e22e075ad..7b644fb52b 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -12,6 +12,20 @@
#ifndef __CORSTONE1000_H
#define __CORSTONE1000_H
+#include <linux/sizes.h>
+
+/* MM SP UUID binary data (little-endian format) */
+#define MM_SP_UUID_DATA \
+ 0xed, 0x32, 0xd5, 0x33, \
+ 0x99, 0xe6, 0x42, 0x09, \
+ 0x9c, 0xc0, 0x2d, 0x72, \
+ 0xcd, 0xd9, 0x98, 0xa7
+
+#define FFA_SHARED_MM_BUFFER_SIZE SZ_4K /* 4 KB */
+
+/* shared buffer physical address used for communication between u-boot and the MM SP */
+#define FFA_SHARED_MM_BUFFER_ADDR (0x023F8000)
+
#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + 0x03f00000)
#define CONFIG_SKIP_LOWLEVEL_INIT
--
2.17.1
@@ -0,0 +1,419 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
From 666463acdd3dbf090952b8bc8b0f2508137804a4 Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Thu, 11 Nov 2021 16:27:59 +0000
Subject: [PATCH] efi: corstone1000: introduce EFI capsule update
This commit provides capsule update feature for Corstone1000.
This feature is available before and after ExitBootServices().
A platform specific capsule buffer is allocated. This buffer
is physically contiguous and allocated at the start of the DDR
memory after u-boot relocation to the end of DDR.
The capsule buffer is shared between u-boot and the secure world.
On UpdateCapsule() , capsule data is copied to the buffer
and a buffer ready event is generated using FF-A transport.
On ExitBootServices() a kernel started event is sent to the
SE Proxy FW update service. This event is generated on each boot.
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
---
arch/arm/dts/corstone1000.dtsi | 4 +-
configs/corstone1000_defconfig | 3 +-
include/configs/corstone1000.h | 30 +++++---
include/efi_loader.h | 4 +-
lib/efi_loader/efi_boottime.c | 47 +++++++++++
lib/efi_loader/efi_capsule.c | 137 ++++++++++++++++++++++++++++++++-
lib/efi_loader/efi_setup.c | 15 ++++
7 files changed, 224 insertions(+), 16 deletions(-)
diff --git a/arch/arm/dts/corstone1000.dtsi b/arch/arm/dts/corstone1000.dtsi
index 97dfac9ae7..0ea3a19698 100644
--- a/arch/arm/dts/corstone1000.dtsi
+++ b/arch/arm/dts/corstone1000.dtsi
@@ -26,9 +26,9 @@
};
};
- memory@80000000 {
+ memory@88200000 {
device_type = "memory";
- reg = <0x80000000 0x80000000>;
+ reg = <0x88200000 0x77e00000>;
};
gic: interrupt-controller@1c000000 {
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index 48ec37f641..c5eb9af101 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -53,7 +53,8 @@ CONFIG_EFI_MM_COMM_TEE=y
CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y
CONFIG_EFI_CAPSULE_ON_DISK=y
CONFIG_EFI_CAPSULE_ON_DISK_EARLY=y
-CONFIG_EFI_CAPSULE_AUTHENTICATE=y
+# CONFIG_EFI_CAPSULE_AUTHENTICATE is not set
+CONFIG_EFI_HAVE_CAPSULE_SUPPORT=y
CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y
CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y
CONFIG_EFI_SECURE_BOOT=y
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index 7b644fb52b..ce50bd5cc9 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -14,6 +14,24 @@
#include <linux/sizes.h>
+/* The SE Proxy partition ID*/
+#define CORSTONE1000_SEPROXY_PART_ID (0x8002)
+
+/* Update service ID provided by the SE Proxy secure partition*/
+#define CORSTONE1000_SEPROXY_UPDATE_SVC_ID (0x4)
+
+/* Notification events used with SE Proxy update service */
+#define CORSTONE1000_BUFFER_READY_EVT (0x1)
+#define CORSTONE1000_KERNEL_STARTED_EVT (0x2)
+
+/* Size in 4KB pages of the EFI capsule buffer */
+#define CORSTONE1000_CAPSULE_BUFFER_SIZE (8192) /* 32 MB */
+
+/* Capsule GUID */
+#define EFI_CORSTONE1000_CAPSULE_ID_GUID \
+ EFI_GUID(0x3a770ddc, 0x409b, 0x48b2, 0x81, 0x41, \
+ 0x93, 0xb7, 0xc6, 0x0b, 0x20, 0x9e)
+
/* MM SP UUID binary data (little-endian format) */
#define MM_SP_UUID_DATA \
0xed, 0x32, 0xd5, 0x33, \
@@ -57,20 +75,14 @@
/* Physical Memory Map */
#define PHYS_SDRAM_1 (V2M_BASE)
-#define PHYS_SDRAM_2 (V2M_QSPI)
-
-/* Top 16MB reserved for secure world use (maybe not needed) */
-#define DRAM_SEC_SIZE 0x01000000
-#define PHYS_SDRAM_1_SIZE 0x80000000 - DRAM_SEC_SIZE
+#define PHYS_SDRAM_1_SIZE 0x80000000
-#define PHYS_SDRAM_2_SIZE 0x02000000
+/* Default load address for the source command */
+#define CONFIG_SYS_LOAD_ADDR (V2M_BASE + 0x10000000)
/* Size of malloc() pool */
#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + (8 << 20))
-/* Miscellaneous configurable options */
-#define CONFIG_SYS_LOAD_ADDR (V2M_BASE + 0x10000000)
-
#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
/* Monitor Command Prompt */
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 611aae64a9..ebee330c68 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -950,11 +950,11 @@ extern const struct efi_firmware_management_protocol efi_fmp_fit;
extern const struct efi_firmware_management_protocol efi_fmp_raw;
/* Capsule update */
-efi_status_t EFIAPI efi_update_capsule(
+efi_status_t __efi_runtime EFIAPI efi_update_capsule(
struct efi_capsule_header **capsule_header_array,
efi_uintn_t capsule_count,
u64 scatter_gather_list);
-efi_status_t EFIAPI efi_query_capsule_caps(
+efi_status_t __efi_runtime EFIAPI efi_query_capsule_caps(
struct efi_capsule_header **capsule_header_array,
efi_uintn_t capsule_count,
u64 *maximum_capsule_size,
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 6f5f32b903..8175177a1c 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -2090,6 +2090,44 @@ static void efi_exit_caches(void)
#endif
}
+#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000)
+/**
+ * efi_corstone1000_kernel_started_event - notifies SE Proxy FW update service
+ *
+ * This function notifies the SE Proxy update service that the kernel has already started
+ *
+ * Return:
+ *
+ * 0: on success, otherwise failure
+ */
+static int efi_corstone1000_kernel_started_event(void)
+{
+ struct ffa_interface_data func_data = {0};
+ struct ffa_send_direct_data msg = {0};
+ u16 part_id = CORSTONE1000_SEPROXY_PART_ID;
+
+ log_debug("[%s]\n", __func__);
+
+ /*
+ * telling the driver which partition to use
+ */
+ func_data.data0_size = sizeof(part_id);
+ func_data.data0 = &part_id;
+
+ /*
+ * setting the kernel started event arguments
+ */
+ msg.a3 = CORSTONE1000_SEPROXY_UPDATE_SVC_ID;
+ msg.a5 = CORSTONE1000_KERNEL_STARTED_EVT;
+
+ func_data.data1_size = sizeof(msg);
+ func_data.data1 = &msg;
+
+ return ffa_helper_msg_send_direct_req(&func_data);
+}
+
+#endif
+
/**
* efi_exit_boot_services() - stop all boot services
* @image_handle: handle of the loaded image
@@ -2195,6 +2233,15 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
/* Recalculate CRC32 */
efi_update_table_header_crc32(&systab.hdr);
+#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000)
+ /* Notifying SE Proxy FW update service */
+ ffa_ret = efi_corstone1000_kernel_started_event();
+ if (ffa_ret)
+ debug("[efi_boottime][ERROR]: Failure to notify SE Proxy FW update service\n");
+ else
+ debug("[efi_boottime][INFO]: SE Proxy FW update service notified\n");
+#endif
+
/* Give the payload some time to boot */
efi_set_watchdog(0);
WATCHDOG_RESET();
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index b75e4bcba1..f180555faf 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -20,6 +20,14 @@
#include <crypto/pkcs7_parser.h>
#include <linux/err.h>
+#ifdef CONFIG_TARGET_CORSTONE1000
+#include <arm_ffa_helper.h>
+#include <cpu_func.h>
+
+void *__efi_runtime_data corstone1000_capsule_buf; /* capsule shared buffer virtual address */
+efi_guid_t corstone1000_capsule_guid = EFI_CORSTONE1000_CAPSULE_ID_GUID;
+#endif
+
const efi_guid_t efi_guid_capsule_report = EFI_CAPSULE_REPORT_GUID;
static const efi_guid_t efi_guid_firmware_management_capsule_id =
EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID;
@@ -472,6 +480,89 @@ static efi_status_t efi_capsule_update_firmware(
}
#endif /* CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT */
+#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000)
+
+/**
+ * efi_corstone1000_alloc_capsule_shared_buf - allocate capsule shared buffer
+ * @capsule_image_size: The capsule data (header + payload)
+ *
+ * This function allocates the physically contiguous buffer shared between u-boot
+ * and the secure world. On UpdateCapsule() capsule data is copied to the buffer
+ * and a door bell event is generated.
+ * The buffer is allocated at the start of the DDR memory after u-boot has been relocated
+ * to the end of DDR.
+ *
+ * Return:
+ *
+ * 0: on success, otherwise failure
+ */
+efi_status_t efi_corstone1000_alloc_capsule_shared_buf(void)
+{
+ efi_status_t efi_ret;
+ u64 ram_base = CONFIG_SYS_SDRAM_BASE;
+
+ log_debug("[%s]\n", __func__);
+
+ efi_ret = efi_allocate_pages(EFI_ALLOCATE_ADDRESS,
+ EFI_RUNTIME_SERVICES_DATA,
+ CORSTONE1000_CAPSULE_BUFFER_SIZE,
+ &ram_base);
+
+ if (efi_ret != EFI_SUCCESS) {
+ corstone1000_capsule_buf = NULL;
+ log_err("EFI: Corstone1000: Allocating capsule shared buffer error (%d)\n"
+ , (int)efi_ret);
+ return efi_ret;
+ }
+
+ log_info("EFI: Corstone1000: Capsule shared buffer at 0x%x , size %d pages\n"
+ , (unsigned int)ram_base,
+ CORSTONE1000_CAPSULE_BUFFER_SIZE);
+
+ corstone1000_capsule_buf = (void *)map_sysmem((phys_addr_t)ram_base, 0);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ * efi_corstone1000_buffer_ready_event - issue door bell event
+ * @capsule_image_size: The capsule data (header + payload)
+ *
+ * This function notifies the SE Proxy update service that capsule data is available
+ * in the capsule shared buffer.
+ *
+ * Return:
+ *
+ * 0: on success, otherwise failure
+ */
+static int __efi_runtime efi_corstone1000_buffer_ready_event(u32 capsule_image_size)
+{
+ struct ffa_interface_data func_data = {0};
+ struct ffa_send_direct_data msg = {0};
+ u16 part_id = CORSTONE1000_SEPROXY_PART_ID;
+
+ log_debug("[%s]\n", __func__);
+
+ /*
+ * telling the driver which partition to use
+ */
+ func_data.data0_size = sizeof(part_id);
+ func_data.data0 = &part_id;
+
+ /*
+ * setting the buffer ready event arguments
+ */
+ msg.a3 = CORSTONE1000_SEPROXY_UPDATE_SVC_ID;
+ msg.a4 = capsule_image_size;
+ msg.a5 = CORSTONE1000_BUFFER_READY_EVT;
+
+ func_data.data1_size = sizeof(msg);
+ func_data.data1 = &msg;
+
+ return ffa_helper_msg_send_direct_req(&func_data);
+}
+#endif
+
/**
* efi_update_capsule() - process information from operating system
* @capsule_header_array: Array of virtual address pointers
@@ -485,7 +576,7 @@ static efi_status_t efi_capsule_update_firmware(
*
* Return: status code
*/
-efi_status_t EFIAPI efi_update_capsule(
+efi_status_t __efi_runtime EFIAPI efi_update_capsule(
struct efi_capsule_header **capsule_header_array,
efi_uintn_t capsule_count,
u64 scatter_gather_list)
@@ -502,6 +593,13 @@ efi_status_t EFIAPI efi_update_capsule(
goto out;
}
+#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000)
+ if (capsule_count != 1 || !corstone1000_capsule_buf) {
+ ret = EFI_INVALID_PARAMETER;
+ goto out;
+ }
+#endif
+
ret = EFI_SUCCESS;
for (i = 0, capsule = *capsule_header_array; i < capsule_count;
i++, capsule = *(++capsule_header_array)) {
@@ -514,6 +612,41 @@ efi_status_t EFIAPI efi_update_capsule(
log_debug("Capsule[%d] (guid:%pUl)\n",
i, &capsule->capsule_guid);
+
+#if CONFIG_IS_ENABLED(TARGET_CORSTONE1000)
+
+ if (guidcmp(&corstone1000_capsule_guid, &capsule->capsule_guid)) {
+ ret = EFI_INVALID_PARAMETER;
+ log_err("Corstone1000: Invalid capsule GUID\n");
+ goto out;
+ }
+
+ if (efi_size_in_pages(capsule->capsule_image_size) >
+ CORSTONE1000_CAPSULE_BUFFER_SIZE) {
+ log_err("Corstone1000: Capsule data size exceeds the shared buffer size\n");
+ ret = EFI_BUFFER_TOO_SMALL;
+ goto out;
+ }
+
+ /* copy the data to the contiguous buffer */
+ efi_memcpy_runtime(corstone1000_capsule_buf, capsule, capsule->capsule_image_size);
+
+ /* invalidate the data cache */
+ invalidate_dcache_all();
+
+ /* issue buffer ready event */
+ ret = efi_corstone1000_buffer_ready_event(capsule->capsule_image_size);
+ if (ret) {
+ log_err("EFI: Corstone1000: Buffer ready event error (%d)\n", (int)ret);
+ ret = EFI_DEVICE_ERROR;
+ } else {
+ ret = EFI_SUCCESS;
+ }
+
+ goto out;
+
+#endif
+
if (!guidcmp(&capsule->capsule_guid,
&efi_guid_firmware_management_capsule_id)) {
ret = efi_capsule_update_firmware(capsule);
@@ -552,7 +685,7 @@ out:
*
* Return: status code
*/
-efi_status_t EFIAPI efi_query_capsule_caps(
+efi_status_t __efi_runtime EFIAPI efi_query_capsule_caps(
struct efi_capsule_header **capsule_header_array,
efi_uintn_t capsule_count,
u64 *maximum_capsule_size,
diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
index a2338d74af..9e3399a28c 100644
--- a/lib/efi_loader/efi_setup.c
+++ b/lib/efi_loader/efi_setup.c
@@ -16,6 +16,13 @@
efi_status_t efi_obj_list_initialized = OBJ_LIST_NOT_INITIALIZED;
+#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000)
+/**
+ * efi_corstone1000_alloc_capsule_shared_buf - allocate capsule shared buffer
+ */
+extern efi_status_t efi_corstone1000_alloc_capsule_shared_buf(void);
+#endif
+
/*
* Allow unaligned memory access.
*
@@ -128,6 +135,14 @@ static efi_status_t efi_init_capsule(void)
{
efi_status_t ret = EFI_SUCCESS;
+#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000)
+ ret = efi_corstone1000_alloc_capsule_shared_buf();
+ if (ret != EFI_SUCCESS) {
+ printf("EFI: Corstone-1000: cannot allocate caspsule shared buffer\n");
+ return ret;
+ }
+#endif
+
if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_UPDATE)) {
ret = efi_set_variable_int(L"CapsuleMax",
&efi_guid_capsule_report,
--
2.17.1
@@ -0,0 +1,34 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
From 1617ecbbf163c921468fee224c92a8f79b43e2fb Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Thu, 11 Nov 2021 16:34:54 +0000
Subject: [PATCH 7/7] corstone1000: adjust the environment and heap sizes
env size set to 64 KB
heap size 64 KB + 32 MB
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
---
include/configs/corstone1000.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index 7f8a8ee254..7d63dd4ad9 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -75,8 +75,9 @@
/* Default load address for the source command */
#define CONFIG_SYS_LOAD_ADDR (V2M_BASE + 0x10000000)
+#define CONFIG_ENV_SECT_SIZE SZ_64K
/* Size of malloc() pool */
-#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + (8 << 20))
+#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SECT_SIZE + SZ_32M)
#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
--
2.17.1
@@ -0,0 +1,38 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
From 313b89315d93ace166e2312a8e09aa85f1beb747 Mon Sep 17 00:00:00 2001
From: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Date: Wed, 17 Nov 2021 15:28:06 +0000
Subject: [PATCH 06/10] corstone1000: Update FFA shared buffer address
FFA shared buffer address changed to 0x02000000.
The existing address 0x023F8000 is currently being used by
Optee so the virtual address returned to the SMM gateway is 0x0000.
So the buffer is moved to 0x02000000.
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
%% original patch: 0025-Update-FFA-shared-buffer-address.patch
%% original patch: 0025-Update-FFA-shared-buffer-address.patch
---
include/configs/corstone1000.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index 7f8c61ba93..0451121b79 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -42,7 +42,7 @@
#define FFA_SHARED_MM_BUFFER_SIZE SZ_4K /* 4 KB */
/* shared buffer physical address used for communication between u-boot and the MM SP */
-#define FFA_SHARED_MM_BUFFER_ADDR (0x023F8000)
+#define FFA_SHARED_MM_BUFFER_ADDR (0x02000000)
#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + 0x03f00000)
#define CONFIG_SKIP_LOWLEVEL_INIT
--
2.17.1
@@ -0,0 +1,58 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
From 524c865ae37f9cb9278988120e508c5314c2cd73 Mon Sep 17 00:00:00 2001
From: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Date: Wed, 17 Nov 2021 15:28:53 +0000
Subject: [PATCH 07/10] corstone1000: Disable set/get of NV variables
This is a temporary change which uses only the volatile memory
for get and set variable calls.
The non volatile storage access is via openAmp in se proxy which is still not
integrated to the system. So when an efi_set_variable_int() call is made for
NV variables, mm_commmunicate results in failure. This change will direct
PlatformLang and OsIndications to volatile memory which would be a
temporary solution.
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
%% original patch: 0026-Disable-set-get-of-NV-variables.patch
%% original patch: 0026-Disable-set-get-of-NV-variables.patch
---
lib/efi_loader/efi_setup.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
index 9e3399a28c..fcf2eae9cd 100644
--- a/lib/efi_loader/efi_setup.c
+++ b/lib/efi_loader/efi_setup.c
@@ -83,7 +83,11 @@ static efi_status_t efi_init_platform_lang(void)
ret = efi_set_variable_int(L"PlatformLang",
&efi_global_variable_guid,
- EFI_VARIABLE_NON_VOLATILE |
+ /*
+ * This is a temporary change until NV memory is accessible
+ * through OpenAmp.
+ */
+ //EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS,
1 + strlen(lang), lang, false);
@@ -210,7 +214,11 @@ static efi_status_t efi_clear_os_indications(void)
os_indications &=
~EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED;
ret = efi_set_variable_int(L"OsIndications", &efi_global_variable_guid,
- EFI_VARIABLE_NON_VOLATILE |
+ /*
+ * This is a temporary change until NV memory is accessible
+ * through OpenAmp.
+ */
+ //EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(os_indications), &os_indications,
--
2.17.1
@@ -0,0 +1,45 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
From 5d53e40021d7fca594bb86307b0851a958047b6b Mon Sep 17 00:00:00 2001
From: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Date: Thu, 18 Nov 2021 16:42:59 +0000
Subject: [PATCH 08/10] corstone1000: Make sure shared buffer contents are not
cached
After updating the shared buffer, it is required to flush the cache
to ensure that the secure world sees expected the shared buffer
contents.
The MM communication shared buffer is configured in device region of optee
which has cache disabled. So we need to invalidate the cache every time we
update the buffer on uboot otherwise the secure world does not see the
accurate values.
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
%% original patch: 0027-Make-sure-shared-buffer-contents-are-not-cached.patch
%% original patch: 0027-Make-sure-shared-buffer-contents-are-not-cached.patch
---
lib/efi_loader/efi_variable_tee.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c
index b363ec92bf..9375aa6a63 100644
--- a/lib/efi_loader/efi_variable_tee.c
+++ b/lib/efi_loader/efi_variable_tee.c
@@ -331,6 +331,11 @@ static efi_status_t __efi_runtime ffa_mm_communicate(void *comm_buf, ulong comm_
virt_shared_buf = (void *)map_sysmem((phys_addr_t)FFA_SHARED_MM_BUFFER_ADDR, 0);
efi_memcpy_runtime(virt_shared_buf, comm_buf, tx_data_size);
+ /* The secure world has cache disabled for device region which we use for shared buffer
+ So, the secure world reads the data from DDR. Let's flush the cache so the DDR is
+ updated with the latest data */
+ invalidate_dcache_all();
+
/* Announce there is data in the shared buffer */
ffa_ret = ffa_notify_mm_sp();
--
2.17.1
@@ -0,0 +1,96 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Harry Moulton <harry.moulton@arm.com>
From 224d5d7ca9359a1c383ee417d934d2a6dfca53df Mon Sep 17 00:00:00 2001
From: Harry Moulton <harmou01@e123741.cambridge.arm.com>
Date: Mon, 29 Nov 2021 13:13:17 +0000
Subject: [PATCH] arm: corstone1000: fix unrecognized filesystem type
error.
Fix the 'unrecognized filesystem type' error when attempting to boot
from an EFI image on attached USB formated as GPT.
Signed-off-by: Harry Moulton <harry.moulton@arm.com>
---
common/usb_storage.c | 3 +++
configs/corstone1000_defconfig | 3 ++-
drivers/usb/isp1760/isp1760-uboot.c | 12 ++++++++++++
include/configs/corstone1000.h | 1 +
4 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/common/usb_storage.c b/common/usb_storage.c
index 946c6b2b32..77b8b55010 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -769,6 +769,9 @@ static int usb_stor_BBB_transport(struct scsi_cmd *srb, struct us_data *us)
st:
retry = 0;
again:
+ if (srb->cmd[0] == SCSI_TST_U_RDY)
+ mdelay(100);
+
debug("STATUS phase\n");
result = usb_bulk_msg(us->pusb_dev, pipein, csw, UMASS_BBB_CSW_SIZE,
&actlen, USB_CNTL_TIMEOUT*5);
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index c5eb9af101..fe77bdc63f 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -20,6 +20,7 @@ CONFIG_CMD_BOOTM=y
CONFIG_CMD_LOADM=y
CONFIG_CMD_BOOTEFI=y
CONFIG_EFI_LOADER=y
+CONFIG_EFI_PARTITION=y
CONFIG_CMD_BOOTEFI_HELLO_COMPILE=y
CONFIG_CMD_BOOTEFI_HELLO=y
# CONFIG_CMD_XIMG is not set
@@ -52,7 +53,7 @@ CONFIG_EFI_MM_COMM_TEE=y
# CONFIG_HEXDUMP is not set
CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y
CONFIG_EFI_CAPSULE_ON_DISK=y
-CONFIG_EFI_CAPSULE_ON_DISK_EARLY=y
+# CONFIG_EFI_CAPSULE_ON_DISK_EARLY is not set
# CONFIG_EFI_CAPSULE_AUTHENTICATE is not set
CONFIG_EFI_HAVE_CAPSULE_SUPPORT=y
CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y
diff --git a/drivers/usb/isp1760/isp1760-uboot.c b/drivers/usb/isp1760/isp1760-uboot.c
index 9f2eaa75f3..cb03bc5d8c 100644
--- a/drivers/usb/isp1760/isp1760-uboot.c
+++ b/drivers/usb/isp1760/isp1760-uboot.c
@@ -56,9 +56,21 @@ static int isp1760_msg_submit_irq(struct udevice *dev, struct usb_device *udev,
pipe, buffer, length, interval);
}
+static int isp1760_get_max_xfer_size(struct udevice *dev, size_t *size)
+{
+ struct isp1760_host_data *host = dev_get_priv(dev);
+ struct isp1760_hcd *priv = host->hcd.hcd_priv;
+ const struct isp1760_memory_layout *mem = priv->memory_layout;
+
+ *size = mem->blocks_size[ISP176x_BLOCK_NUM - 1];
+
+ return 0;
+}
+
struct dm_usb_ops isp1760_usb_ops = {
.control = isp1760_msg_submit_control,
.bulk = isp1760_msg_submit_bulk,
.interrupt = isp1760_msg_submit_irq,
+ .get_max_xfer_size = isp1760_get_max_xfer_size,
};
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index 87682406d6..4c7993649d 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -91,6 +91,7 @@
#define CONFIG_SYS_MAXARGS 64 /* max command args */
#define CONFIG_EXTRA_ENV_SETTINGS \
+ "usb_pgood_delay=250\0" \
"fdt_addr_r=0x82000000\0" \
"kernel_addr=0x08330000\0" \
"kernel_addr_r=0x82100000\0" \
--
2.17.1
@@ -0,0 +1,27 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Emekcan Aras <Emekcan.Aras@arm.com>
From 8b85cddde48f31266349277980a65d25dfae302e Mon Sep 17 00:00:00 2001
From: Emekcan Aras <Emekcan.Aras@arm.com>
Date: Wed, 17 Nov 2021 18:48:35 +0000
Subject: [PATCH] corstone1000: set CONFIG_PSCI_RESET
set CONFIG_PSCI_RESET to allow efi_reset_system API to use PSCI.
Signed-off-by: Emekcan Aras <Emekcan.Aras@arm.com>
---
configs/corstone1000_defconfig | 2 ++
1 file changed, 2 insertions(+)
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index b59b75df3e..55f93b0a2c 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -64,3 +64,5 @@ CONFIG_CMD_RTC=y
CONFIG_EFI_GET_TIME=y
CONFIG_EFI_SET_TIME=y
CONFIG_RTC_EMULATION=y
+CONFIG_PSCI_RESET=y
+
--
2.25.1
@@ -0,0 +1,64 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Emekcan Aras <Emekcan.Aras@arm.com>
From e51542907203c46bdbbd78aa1c76058204fd75f1 Mon Sep 17 00:00:00 2001
From: Emekcan Aras <Emekcan.Aras@arm.com>
Date: Thu, 25 Nov 2021 16:54:57 +0000
Subject: [PATCH] arm-bsp/u-boot: corstone1000: Implement autoboot
storage device selection
This commit implements distro_bootcmd in config_bootcommand in u-boot.
This command traverses all the USB devices connected to the board and
finds a usb device that has bootable image to boot from it. If it cannot
find a usb device with the bootable image, it will boot the system using
the existing flash.
Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
---
configs/corstone1000_defconfig | 2 +-
include/configs/corstone1000.h | 15 ++++++++++-----
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index 10b7c3ea18..0b9ead461b 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -66,4 +66,4 @@ CONFIG_EFI_GET_TIME=y
CONFIG_EFI_SET_TIME=y
CONFIG_RTC_EMULATION=y
CONFIG_PSCI_RESET=y
-
+CONFIG_DISTRO_DEFAULTS=y
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index b0932f9f33..d029059a81 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -85,15 +85,20 @@
#define CONFIG_SYS_CBSIZE 512 /* Console I/O Buffer Size */
#define CONFIG_SYS_MAXARGS 64 /* max command args */
-#define CONFIG_EXTRA_ENV_SETTINGS \
+#define BOOT_TARGET_DEVICES(func) \
+ func(USB, usb, 0)
+#include <config_distro_bootcmd.h>
+#define CONFIG_EXTRA_ENV_SETTINGS \
+ BOOTENV \
"usb_pgood_delay=250\0" \
"fdt_addr_r=0x82000000\0" \
"kernel_addr=0x08330000\0" \
- "kernel_addr_r=0x82100000\0" \
+ "kernel_addr_r=0x88200000\0" \
"fdt_high=0xffffffff\0"
-
-#define CONFIG_BOOTCOMMAND \
- "echo Loading Kernel to memory ... ;" \
+#define CONFIG_BOOTCOMMAND \
+ "echo Loading Kernel to memory ... ;" \
"loadm $kernel_addr $kernel_addr_r 0xc00000;" \
+ "usb start; usb reset;" \
+ "run distro_bootcmd;" \
"bootefi $kernel_addr_r $fdtcontroladdr;"
#endif
--
2.25.1
@@ -0,0 +1,47 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
From 1e76c4b70c8539c56b4b9ae6b8fd415d811a1812 Mon Sep 17 00:00:00 2001
From: Satish Kumar <satish.kumar01@arm.com>
Date: Wed, 1 Dec 2021 19:04:59 +0000
Subject: [PATCH] corstone1000: change base address of kernel in the flash
More space in the flash is reserved up front for metadata
parser and UEFI variables. That requires change in the flash
base address of where images are present.
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
---
include/configs/corstone1000.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index bb3b099806..baa0720fb5 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -94,16 +94,16 @@
func(USB, usb, 0)
#include <config_distro_bootcmd.h>
#define CONFIG_EXTRA_ENV_SETTINGS \
- BOOTENV \
- "usb_pgood_delay=250\0" \
+ BOOTENV \
+ "usb_pgood_delay=250\0" \
"fdt_addr_r=0x82000000\0" \
- "kernel_addr=0x08330000\0" \
+ "kernel_addr=0x083EE000\0" \
"kernel_addr_r=0x88200000\0" \
"fdt_high=0xffffffff\0"
-#define CONFIG_BOOTCOMMAND \
+#define CONFIG_BOOTCOMMAND \
"echo Loading Kernel to memory ... ;" \
"loadm $kernel_addr $kernel_addr_r 0xc00000;" \
- "usb start; usb reset;" \
- "run distro_bootcmd;" \
+ "usb start; usb reset;" \
+ "run distro_bootcmd;" \
"bootefi $kernel_addr_r $fdtcontroladdr;"
#endif
--
2.17.1
@@ -0,0 +1,66 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
From abc455d29aa9c983c6af2fa75870a7ee95da2496 Mon Sep 17 00:00:00 2001
From: Satish Kumar <satish.kumar01@arm.com>
Date: Wed, 1 Dec 2021 19:17:57 +0000
Subject: [PATCH] arm: corstone1000: identify which bank to load kernel from
Secure enclave, based on the firmware update state of the
system, decides the boot bank. In this commit, u-boot
identifies the selected boot bank and loads the kernel
from it.
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
---
configs/corstone1000_defconfig | 2 +-
include/configs/corstone1000.h | 18 ++++++++++++++----
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index 0b9ead461b..3c00e13ceb 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -29,7 +29,7 @@ CONFIG_CMD_BOOTEFI_HELLO=y
CONFIG_CMD_NVEDIT_EFI=y
# CONFIG_CMD_LOADS is not set
CONFIG_CMD_USB=y
-# CONFIG_CMD_ITEST is not set
+CONFIG_CMD_ITEST=y
# CONFIG_CMD_SETEXPR is not set
CONFIG_CMD_DHCP=y
# CONFIG_CMD_NFS is not set
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index baa0720fb5..7c6f66c891 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -97,12 +97,22 @@
BOOTENV \
"usb_pgood_delay=250\0" \
"fdt_addr_r=0x82000000\0" \
- "kernel_addr=0x083EE000\0" \
- "kernel_addr_r=0x88200000\0" \
+ "boot_bank_flag=0x08002000\0" \
+ "kernel_addr_bank_0=0x083EE000\0" \
+ "kernel_addr_bank_1=0x0936E000\0" \
+ "retrieve_kernel_load_addr=" \
+ "if itest.l *${boot_bank_flag} == 0; then " \
+ "setenv kernel_addr $kernel_addr_bank_0;" \
+ "else " \
+ "setenv kernel_addr $kernel_addr_bank_1;" \
+ "fi;" \
+ "\0" \
+ "kernel_addr_r=0x88200000\0" \
"fdt_high=0xffffffff\0"
#define CONFIG_BOOTCOMMAND \
- "echo Loading Kernel to memory ... ;" \
- "loadm $kernel_addr $kernel_addr_r 0xc00000;" \
+ "run retrieve_kernel_load_addr;" \
+ "echo Loading kernel from $kernel_addr to memory ... ;" \
+ "loadm $kernel_addr $kernel_addr_r 0xc00000;" \
"usb start; usb reset;" \
"run distro_bootcmd;" \
"bootefi $kernel_addr_r $fdtcontroladdr;"
--
2.17.1
@@ -0,0 +1,33 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
From d26f38e9b677ddbfa4e92e250058630ecd275908 Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Mon, 6 Dec 2021 14:46:06 +0000
Subject: [PATCH] corstone1000: dts: setting the boot console output
Setting stdout-path in the chosen node.
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
---
arch/arm/dts/corstone1000.dtsi | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/arm/dts/corstone1000.dtsi b/arch/arm/dts/corstone1000.dtsi
index 0ea3a19698..88fb1576b9 100644
--- a/arch/arm/dts/corstone1000.dtsi
+++ b/arch/arm/dts/corstone1000.dtsi
@@ -12,7 +12,9 @@
#address-cells = <1>;
#size-cells = <1>;
- chosen { };
+ chosen {
+ stdout-path = "/uart@1a510000:115200n8";
+ };
cpus {
#address-cells = <1>;
--
2.17.1
@@ -0,0 +1,34 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
From 871521cf90dabb1634af4e47cdf198f979f1907d Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Mon, 6 Dec 2021 15:53:56 +0000
Subject: [PATCH] corstone1000: dts: remove the use of fdt_addr_r
The device tree is embedded in the u-boot binary
and located at the end of the DDR. Its address
is specified in fdtcontroladdr environment variable.
No need to use fdt_addr_r anymore.
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
---
include/configs/corstone1000.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index 7c6f66c891..31fc0cb29e 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -96,7 +96,6 @@
#define CONFIG_EXTRA_ENV_SETTINGS \
BOOTENV \
"usb_pgood_delay=250\0" \
- "fdt_addr_r=0x82000000\0" \
"boot_bank_flag=0x08002000\0" \
"kernel_addr_bank_0=0x083EE000\0" \
"kernel_addr_bank_1=0x0936E000\0" \
--
2.17.1
@@ -0,0 +1,77 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
From 44e0b661c90d83b64b38023ebc27a836ae687b6a Mon Sep 17 00:00:00 2001
From: Vishnu Banavath <vishnu.banavath@arm.com>
Date: Fri, 10 Dec 2021 20:03:35 +0000
Subject: [PATCH 1/2] efi_capsule: corstone1000: pass interface id and buffer
event id using register w4
Initially the interface/event IDs are passed to the SP using register
w3 and w5.
Now the SE proxy SP requires this arguments to be in register w4.
This change is to pass interface ID(31:16) and event ID(15:0)
to SE proxy SP to trigger an event to secure enclave about
firmware update.
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
---
include/configs/corstone1000.h | 8 ++++++++
lib/efi_loader/efi_capsule.c | 11 +++++++----
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index 31fc0cb29e..4a78e1a3c5 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -24,6 +24,14 @@
#define CORSTONE1000_BUFFER_READY_EVT (0x1)
#define CORSTONE1000_KERNEL_STARTED_EVT (0x2)
+#define PREP_SEPROXY_SVC_ID_MASK GENMASK(31, 16)
+#define PREP_SEPROXY_SVC_ID(x) \
+ (FIELD_PREP(PREP_SEPROXY_SVC_ID_MASK, (x)))
+
+#define PREP_SEPROXY_EVT_MASK GENMASK(15, 0)
+#define PREP_SEPROXY_EVT(x) \
+ (FIELD_PREP(PREP_SEPROXY_EVT_MASK, (x)))
+
/* Size in 4KB pages of the EFI capsule buffer */
#define CORSTONE1000_CAPSULE_BUFFER_SIZE (8192) /* 32 MB */
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index 089eba0fd0..6917bb4925 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -21,6 +21,8 @@
#ifdef CONFIG_TARGET_CORSTONE1000
#include <arm_ffa_helper.h>
#include <cpu_func.h>
+#include <linux/bitfield.h>
+#include <linux/bitops.h>
void *__efi_runtime_data corstone1000_capsule_buf; /* capsule shared buffer virtual address */
efi_guid_t corstone1000_capsule_guid = EFI_CORSTONE1000_CAPSULE_ID_GUID;
@@ -495,11 +497,12 @@ static int __efi_runtime efi_corstone1000_buffer_ready_event(u32 capsule_image_s
func_data.data0 = &part_id;
/*
- * setting the buffer ready event arguments
+ * setting the buffer ready event arguments in register w4:
+ * - capsule update interface ID (31:16)
+ * - the buffer ready event ID (15:0)
*/
- msg.a3 = CORSTONE1000_SEPROXY_UPDATE_SVC_ID;
- msg.a4 = capsule_image_size;
- msg.a5 = CORSTONE1000_BUFFER_READY_EVT;
+ msg.a4 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) |
+ PREP_SEPROXY_EVT(CORSTONE1000_BUFFER_READY_EVT);
func_data.data1_size = sizeof(msg);
func_data.data1 = &msg;
--
2.17.1
@@ -0,0 +1,59 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
From 51600b4385ddd45ce480bdb58769205072ddadf2 Mon Sep 17 00:00:00 2001
From: Vishnu Banavath <vishnu.banavath@arm.com>
Date: Fri, 10 Dec 2021 20:10:41 +0000
Subject: [PATCH 2/2] efi_boottime: corstone1000: pass interface id and kernel
event id using register w4
Initially the interface/event IDs are passed to the SP using register
w3 and w5.
Now the SE proxy SP requires this arguments to be in register w4.
This change is to pass interface ID(31:16) and kernel started
event ID(15:0) to SE proxy SP to trigger an event to
secure enclave just before ExitbootService().
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
---
lib/efi_loader/efi_boottime.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index be49030717..17cc692064 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -26,6 +26,11 @@
#include <arm_ffa_helper.h>
#endif
+#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000)
+#include <linux/bitfield.h>
+#include <linux/bitops.h>
+#endif
+
DECLARE_GLOBAL_DATA_PTR;
/* Task priority level */
@@ -2114,10 +2119,12 @@ static int efi_corstone1000_kernel_started_event(void)
func_data.data0 = &part_id;
/*
- * setting the kernel started event arguments
+ * setting the kernel started event arguments:
+ * setting capsule update interface ID(31:16)
+ * the kernel started event ID(15:0)
*/
- msg.a3 = CORSTONE1000_SEPROXY_UPDATE_SVC_ID;
- msg.a5 = CORSTONE1000_KERNEL_STARTED_EVT;
+ msg.a4 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) |
+ PREP_SEPROXY_EVT(CORSTONE1000_KERNEL_STARTED_EVT);
func_data.data1_size = sizeof(msg);
func_data.data1 = &msg;
--
2.17.1
@@ -0,0 +1,62 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
From b126e250c2c6f2388fe3f30ee270dc9a891ad3a4 Mon Sep 17 00:00:00 2001
From: Vishnu Banavath <vishnu.banavath@arm.com>
Date: Sat, 11 Dec 2021 13:23:55 +0000
Subject: [PATCH] efi_loader: corstone1000: remove guid check from corstone1000 config option
Use generic fmp guid and no separte check is required for
CORSTONE1000 target.
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index f018c740ab..681470762a 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -554,18 +554,18 @@ efi_status_t __efi_runtime EFIAPI efi_update_capsule(
log_err("EFI: A capsule has not enough data\n");
continue;
}
+ if (guidcmp(&capsule->capsule_guid,
+ &efi_guid_firmware_management_capsule_id)) {
+ log_err("Unsupported capsule type: %pUl\n", &capsule->capsule_guid);
+ ret = EFI_UNSUPPORTED;
+ goto out;
+ }
log_debug("Capsule[%d] (guid:%pUl)\n",
i, &capsule->capsule_guid);
#if CONFIG_IS_ENABLED(TARGET_CORSTONE1000)
- if (guidcmp(&corstone1000_capsule_guid, &capsule->capsule_guid)) {
- ret = EFI_INVALID_PARAMETER;
- log_err("Corstone1000: Invalid capsule GUID\n");
- goto out;
- }
-
if (efi_size_in_pages(capsule->capsule_image_size) >
CORSTONE1000_CAPSULE_BUFFER_SIZE) {
log_err("Corstone1000: Capsule data size exceeds the shared buffer size\n");
@@ -591,15 +591,7 @@ efi_status_t __efi_runtime EFIAPI efi_update_capsule(
goto out;
#endif
-
- if (!guidcmp(&capsule->capsule_guid,
- &efi_guid_firmware_management_capsule_id)) {
- ret = efi_capsule_update_firmware(capsule);
- } else {
- log_err("EFI: not support capsule type: %pUl\n",
- &capsule->capsule_guid);
- ret = EFI_UNSUPPORTED;
- }
+ ret = efi_capsule_update_firmware(capsule);
if (ret != EFI_SUCCESS)
goto out;
--
2.17.1
@@ -0,0 +1,42 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
From 8907d857321de362ee545d3c86e39e9b49380c70 Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Sat, 11 Dec 2021 21:05:10 +0000
Subject: [PATCH] arm_ffa: removing the cast when using binary OR on FIELD_PREP
macros
When the GENMASK used is above 16-bits wide a u16 cast will cause
loss of data.
This commit fixes that.
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
---
drivers/arm-ffa/arm_ffa_prv.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/arm-ffa/arm_ffa_prv.h b/drivers/arm-ffa/arm_ffa_prv.h
index 38ea4ba83e..d0db3ef508 100644
--- a/drivers/arm-ffa/arm_ffa_prv.h
+++ b/drivers/arm-ffa/arm_ffa_prv.h
@@ -40,13 +40,13 @@
#define PREP_SELF_ENDPOINT_ID_MASK GENMASK(31, 16)
#define PREP_SELF_ENDPOINT_ID(x) \
- ((u16)(FIELD_PREP(PREP_SELF_ENDPOINT_ID_MASK, (x))))
+ (FIELD_PREP(PREP_SELF_ENDPOINT_ID_MASK, (x)))
/* Partition endpoint ID mask (partition with which u-boot communicates with) */
#define PREP_PART_ENDPOINT_ID_MASK GENMASK(15, 0)
#define PREP_PART_ENDPOINT_ID(x) \
- ((u16)(FIELD_PREP(PREP_PART_ENDPOINT_ID_MASK, (x))))
+ (FIELD_PREP(PREP_PART_ENDPOINT_ID_MASK, (x)))
/* The FF-A SMC function prototype definition */
--
2.17.1
@@ -0,0 +1,32 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
From 42676bed67b8f0b87e7b3bc1a7f43afc6f7ba505 Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Sat, 11 Dec 2021 21:18:59 +0000
Subject: [PATCH] efi_loader: add the header file for invalidate_dcache_all
function
The invalidate_dcache_all function has been implicitly declared.
This commit fixes that.
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
---
lib/efi_loader/efi_variable_tee.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c
index b7de80cd39..bebe2325b8 100644
--- a/lib/efi_loader/efi_variable_tee.c
+++ b/lib/efi_loader/efi_variable_tee.c
@@ -22,6 +22,7 @@
#if (IS_ENABLED(CONFIG_ARM_FFA_TRANSPORT))
#include <arm_ffa_helper.h>
+#include <cpu_func.h>
#include <mapmem.h>
/* MM return codes */
--
2.17.1
@@ -0,0 +1,33 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
From 048d07817e1508022dc9a623ae9410e8f142fd46 Mon Sep 17 00:00:00 2001
From: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Date: Sun, 12 Dec 2021 17:51:17 +0000
Subject: [PATCH 1/3] Return proper error code when rx buffer is larger
ffa_mm_communicate should return EFI_BUFFER_TOO_SMALL when
the buffer received from the secure world is larger than the
comm buffer as this value is forwarded by mm_communicate.
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
---
lib/efi_loader/efi_variable_tee.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c
index 3ffc35ea1e..ec68994e0f 100644
--- a/lib/efi_loader/efi_variable_tee.c
+++ b/lib/efi_loader/efi_variable_tee.c
@@ -354,7 +354,7 @@ static efi_status_t __efi_runtime ffa_mm_communicate(void *comm_buf, ulong comm_
if (rx_data_size > comm_buf_size) {
unmap_sysmem(virt_shared_buf);
- return EFI_OUT_OF_RESOURCES;
+ return EFI_BUFFER_TOO_SMALL;
}
efi_memcpy_runtime(comm_buf, virt_shared_buf, rx_data_size);
--
2.17.1
@@ -0,0 +1,42 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
From d2ae8c021185ac1d067c5b78f21467bda4b7591b Mon Sep 17 00:00:00 2001
From: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Date: Mon, 13 Dec 2021 15:25:23 +0000
Subject: [PATCH] Use correct buffer size
The comm buffer created has additional 4 bytes length which
needs to be trimmed. This change will reduce the size of the
comm buffer to what is expected.
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
---
include/mm_communication.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/mm_communication.h b/include/mm_communication.h
index e65fbde60d..bb99190956 100644
--- a/include/mm_communication.h
+++ b/include/mm_communication.h
@@ -123,7 +123,7 @@ struct __packed efi_mm_communicate_header {
*
* Defined in EDK2 as SMM_VARIABLE_COMMUNICATE_HEADER.
*/
-struct smm_variable_communicate_header {
+struct __packed smm_variable_communicate_header {
efi_uintn_t function;
efi_status_t ret_status;
u8 data[];
@@ -145,7 +145,7 @@ struct smm_variable_communicate_header {
* Defined in EDK2 as SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE.
*
*/
-struct smm_variable_access {
+struct __packed smm_variable_access {
efi_guid_t guid;
efi_uintn_t data_size;
efi_uintn_t name_size;
--
2.17.1
@@ -0,0 +1,32 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
From 7bd96f322f42ae577cd201465f618849605c1e85 Mon Sep 17 00:00:00 2001
From: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Date: Sun, 12 Dec 2021 17:58:08 +0000
Subject: [PATCH 3/3] Update comm_buf when EFI_BUFFER_TOO_SMALL
When the received buffer is larger than the comm buffer,
the contents of the shared buffer which can fit in the
comm buffer should be read before returning.
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
---
lib/efi_loader/efi_variable_tee.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c
index 1d7a033e98..c948eed491 100644
--- a/lib/efi_loader/efi_variable_tee.c
+++ b/lib/efi_loader/efi_variable_tee.c
@@ -355,6 +355,7 @@ static efi_status_t __efi_runtime ffa_mm_communicate(void *comm_buf, ulong comm_
sizeof(size_t);
if (rx_data_size > comm_buf_size) {
+ efi_memcpy_runtime(comm_buf, virt_shared_buf, comm_buf_size);
unmap_sysmem(virt_shared_buf);
return EFI_BUFFER_TOO_SMALL;
}
--
2.17.1
@@ -2,6 +2,60 @@
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
#
# Corstone1000 64-bit machines
#
CORSTONE1000_DEVICE_TREE:corstone1000-mps3 = "corstone1000-mps3"
CORSTONE1000_DEVICE_TREE:corstone1000-fvp = "corstone1000-fvp"
EXTRA_OEMAKE:append:corstone1000 = ' DEVICE_TREE=${CORSTONE1000_DEVICE_TREE}'
SYSROOT_DIRS:append:corstone1000 = " /boot"
SRC_URI:append:corstone1000 = " \
file://0001-arm-add-corstone1000-platform.patch \
file://0002-arm-corstone1000-enable-devicetree-in-defconfig.patch \
file://0003-usb-common-move-urb-code-to-common.patch \
file://0004-usb-add-isp1760-family-driver.patch \
file://0005-corstone1000-enable-isp1763-and-usb-stack.patch \
file://0006-corstone1000-enable-support-for-FVP.patch \
file://0007-arm-corstone1000-sharing-PSCI-DTS-node-between-FVP-a.patch \
file://0008-arm-corstone1000-Emulated-RTC-Support.patch \
file://0009-arm-corstone1000-execute-uboot-from-DDR.patch \
file://0010-cmd-load-add-load-command-for-memory-mapped.patch \
file://0011-arm-corstone1000-enable-boot-using-uefi.patch \
file://0012-arm-corstone1000-enable-uefi-secure-boot.patch \
file://0013-arm-corstone1000-enable-handlers-for-uefi-variables.patch \
file://0014-arm-corstone1000-enable-efi-capsule-options.patch \
file://0015-arm-dts-add-initial-devicetree-corstone1000-mps3.patch \
file://0016-arm-corstone1000-adding-PSCI-device-tree-node.patch \
file://0017-arm-corstone1000-amend-kernel-bootargs-with-ip-dhcp-.patch \
file://0018-arm_ffa-introducing-Arm-FF-A-low-level-driver.patch \
file://0019-arm_ffa-introducing-armffa-command.patch \
file://0020-arm_ffa-introducing-test-module-for-UCLASS_FFA.patch \
file://0021-arm_ffa-introducing-MM-communication-with-FF-A.patch \
file://0022-arm_ffa-corstone1000-enable-FF-A-and-MM-support.patch \
file://0023-efi-corstone1000-introduce-EFI-capsule-update.patch \
file://0024-corstone1000-adjust-the-environment-and-heap-sizes.patch \
file://0025-corstone1000-Update-FFA-shared-buffer-address.patch \
file://0026-corstone1000-Disable-set-get-of-NV-variables.patch \
file://0027-corstone1000-Make-sure-shared-buffer-contents-are-no.patch \
file://0028-arm-corstone1000-fix-unrecognized-filesystem-type-error.patch \
file://0029-corstone1000-set-CONFIG_PSCI_RESET.patch \
file://0030-arm-bsp-u-boot-corstone1000-Implement-autoboot-script.patch \
file://0031-corstone1000-change-base-address-of-kernel-in-the-fl.patch \
file://0032-arm-corstone1000-identify-which-bank-to-load-kernel.patch \
file://0033-corstone1000-dts-setting-the-boot-console-output.patch \
file://0034-corstone1000-dts-remove-the-use-of-fdt_addr_r.patch \
file://0035-efi_capsule-corstone1000-pass-interface-and-buffer-event-ids-in-w4.patch \
file://0036-efi_boottime-corstone1000-pass-interface-and-kernel-event-ids-in-w4.patch \
file://0037-efi_loader-remove-guid-check-from-corstone1000-confi.patch \
file://0038-arm_ffa-removing-the-cast-when-using-binary-OR-on-FIELD_PREP.patch \
file://0039-efi_loader-add-the-header-file-for-invalidate_dcache_all.patch \
file://0040-Return-proper-error-code-when-rx-buffer-is-larger.patch \
file://0041-Use-correct-buffer-size.patch \
file://0042-Update-comm_buf-when-EFI_BUFFER_TOO_SMALL.patch \
"
#
# FVP BASE
#
@@ -0,0 +1,14 @@
SUMMARY = "MCUboot's image signing and key management"
LICENSE = "Apache-2.0"
AUTHOR = "The MCUboot committers <mcuboot@groups.io>, \
Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>"
LIC_FILES_CHKSUM = "file://setup.py;md5=bd908c2a1211013db5df04f0ec181b9b"
SRC_URI[md5sum] = "a515e40ae31c1d7a70e653b997bb112b"
RDEPENDS_${PN} = "python3-cryptography-native python3-intelhex-native python3-click-native python3-cbor-native"
inherit pypi setuptools3
BBCLASSEXTEND = "native nativesdk"
@@ -0,0 +1,5 @@
define KMACHINE corstone1000
define KTYPE standard
define KARCH arm64
kconf hardware corstone1000/base.cfg
@@ -0,0 +1,29 @@
CONFIG_LOCALVERSION="-yocto-standard"
# CONFIG_LOCALVERSION_AUTO is not set
CONFIG_LOG_BUF_SHIFT=12
# CONFIG_UTS_NS is not set
# CONFIG_PID_NS is not set
# CONFIG_NET_NS is not set
# CONFIG_BLK_DEV_BSG is not set
CONFIG_ARM64=y
CONFIG_THUMB2_KERNEL=y
CONFIG_ZBOOT_ROM_TEXT=0x0
CONFIG_ZBOOT_ROM_BSS=0x0
CONFIG_VFP=y
# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
CONFIG_NET=y
CONFIG_PACKET=y
CONFIG_UNIX=y
CONFIG_INET=y
# CONFIG_IPV6 is not set
# CONFIG_WIRELESS is not set
CONFIG_DEVTMPFS=y
CONFIG_TMPFS=y
# CONFIG_WLAN is not set
# CONFIG_SERIO_SERPORT is not set
CONFIG_SERIAL_AMBA_PL011=y
CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
CONFIG_RTC_CLASS=y
CONFIG_RTC_DRV_PL031=y
CONFIG_MAILBOX=y
# CONFIG_CRYPTO_HW is not set
@@ -1,14 +1,13 @@
include features/input/input.scc
include cfg/timer/no_hz.scc
include cfg/virtio.scc
kconf hardware fvp-arm32/fvp-board.cfg
kconf hardware fvp-arm32/fvp-features.cfg
kconf hardware fvp/fvp-net.cfg
kconf hardware fvp/fvp-rtc.cfg
kconf hardware fvp/fvp-serial.cfg
kconf hardware fvp/fvp-virtio.cfg
kconf hardware fvp/fvp-cfi.cfg
kconf hardware fvp/fvp-drm.cfg
kconf hardware fvp/fvp-timer.cfg
kconf hardware fvp/fvp-virtio.cfg
kconf hardware fvp/fvp-watchdog.cfg
@@ -1,14 +1,13 @@
include features/input/input.scc
include features/net/net.scc
include cfg/timer/no_hz.scc
include cfg/virtio.scc
kconf hardware fvp/fvp-board.cfg
kconf hardware fvp/fvp-net.cfg
kconf hardware fvp/fvp-rtc.cfg
kconf hardware fvp/fvp-serial.cfg
kconf hardware fvp/fvp-virtio.cfg
kconf hardware fvp/fvp-cfi.cfg
kconf hardware fvp/fvp-drm.cfg
kconf hardware fvp/fvp-timer.cfg
kconf hardware fvp/fvp-virtio.cfg
kconf hardware fvp/fvp-watchdog.cfg
@@ -1,4 +0,0 @@
CONFIG_VIRTIO=y
CONFIG_VIRTIO_MMIO=y
CONFIG_BLOCK=y
CONFIG_VIRTIO_BLK=y
@@ -0,0 +1,191 @@
Upstream-Status: Accepted [merged with kernel 5.14.9]
Signed-off-by: Arpita S.K <arpita.s.k@arm.com>
From abfabc8ae3bd625f57fa35d25f2435bb6465a3b1 Mon Sep 17 00:00:00 2001
From: Rui Miguel Silva <rui.silva@linaro.org>
Date: Thu, 13 May 2021 09:47:09 +0100
Subject: [PATCH 01/23] usb: isp1760: fix strict typechecking
There are a lot of pre-existing typechecking warnings around the
access and assign of elements of ptd structure of __dw type.
sparse: warning: invalid assignment: |=
sparse: left side has type restricted __dw
sparse: right side has type unsigned int
or
warning: restricted __dw degrades to integer
or
sparse: warning: incorrect type in assignment (different base types)
sparse: expected restricted __dw [usertype] dw4
sparse: got unsigned int [assigned] [usertype] usof
To handle this, annotate conversions along the {TO,FROM}_DW* macros
and some assignments and function arguments.
This clean up completely all sparse warnings for this driver.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Link: https://lore.kernel.org/r/20210513084717.2487366-2-rui.silva@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/usb/isp1760/isp1760-hcd.c | 92 ++++++++++++++++---------------
1 file changed, 47 insertions(+), 45 deletions(-)
diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c
index 33ae656c4b68..0e0a4b01c710 100644
--- a/drivers/usb/isp1760/isp1760-hcd.c
+++ b/drivers/usb/isp1760/isp1760-hcd.c
@@ -66,44 +66,46 @@ struct ptd {
#define ATL_PTD_OFFSET 0x0c00
#define PAYLOAD_OFFSET 0x1000
-
-/* ATL */
-/* DW0 */
-#define DW0_VALID_BIT 1
-#define FROM_DW0_VALID(x) ((x) & 0x01)
-#define TO_DW0_LENGTH(x) (((u32) x) << 3)
-#define TO_DW0_MAXPACKET(x) (((u32) x) << 18)
-#define TO_DW0_MULTI(x) (((u32) x) << 29)
-#define TO_DW0_ENDPOINT(x) (((u32) x) << 31)
+#define TO_DW(x) ((__force __dw)x)
+#define TO_U32(x) ((__force u32)x)
+
+ /* ATL */
+ /* DW0 */
+#define DW0_VALID_BIT TO_DW(1)
+#define FROM_DW0_VALID(x) (TO_U32(x) & 0x01)
+#define TO_DW0_LENGTH(x) TO_DW((((u32)x) << 3))
+#define TO_DW0_MAXPACKET(x) TO_DW((((u32)x) << 18))
+#define TO_DW0_MULTI(x) TO_DW((((u32)x) << 29))
+#define TO_DW0_ENDPOINT(x) TO_DW((((u32)x) << 31))
/* DW1 */
-#define TO_DW1_DEVICE_ADDR(x) (((u32) x) << 3)
-#define TO_DW1_PID_TOKEN(x) (((u32) x) << 10)
-#define DW1_TRANS_BULK ((u32) 2 << 12)
-#define DW1_TRANS_INT ((u32) 3 << 12)
-#define DW1_TRANS_SPLIT ((u32) 1 << 14)
-#define DW1_SE_USB_LOSPEED ((u32) 2 << 16)
-#define TO_DW1_PORT_NUM(x) (((u32) x) << 18)
-#define TO_DW1_HUB_NUM(x) (((u32) x) << 25)
+#define TO_DW1_DEVICE_ADDR(x) TO_DW((((u32)x) << 3))
+#define TO_DW1_PID_TOKEN(x) TO_DW((((u32)x) << 10))
+#define DW1_TRANS_BULK TO_DW(((u32)2 << 12))
+#define DW1_TRANS_INT TO_DW(((u32)3 << 12))
+#define DW1_TRANS_SPLIT TO_DW(((u32)1 << 14))
+#define DW1_SE_USB_LOSPEED TO_DW(((u32)2 << 16))
+#define TO_DW1_PORT_NUM(x) TO_DW((((u32)x) << 18))
+#define TO_DW1_HUB_NUM(x) TO_DW((((u32)x) << 25))
/* DW2 */
-#define TO_DW2_DATA_START_ADDR(x) (((u32) x) << 8)
-#define TO_DW2_RL(x) ((x) << 25)
-#define FROM_DW2_RL(x) (((x) >> 25) & 0xf)
+#define TO_DW2_DATA_START_ADDR(x) TO_DW((((u32)x) << 8))
+#define TO_DW2_RL(x) TO_DW(((x) << 25))
+#define FROM_DW2_RL(x) ((TO_U32(x) >> 25) & 0xf)
/* DW3 */
-#define FROM_DW3_NRBYTESTRANSFERRED(x) ((x) & 0x7fff)
-#define FROM_DW3_SCS_NRBYTESTRANSFERRED(x) ((x) & 0x07ff)
-#define TO_DW3_NAKCOUNT(x) ((x) << 19)
-#define FROM_DW3_NAKCOUNT(x) (((x) >> 19) & 0xf)
-#define TO_DW3_CERR(x) ((x) << 23)
-#define FROM_DW3_CERR(x) (((x) >> 23) & 0x3)
-#define TO_DW3_DATA_TOGGLE(x) ((x) << 25)
-#define FROM_DW3_DATA_TOGGLE(x) (((x) >> 25) & 0x1)
-#define TO_DW3_PING(x) ((x) << 26)
-#define FROM_DW3_PING(x) (((x) >> 26) & 0x1)
-#define DW3_ERROR_BIT (1 << 28)
-#define DW3_BABBLE_BIT (1 << 29)
-#define DW3_HALT_BIT (1 << 30)
-#define DW3_ACTIVE_BIT (1 << 31)
-#define FROM_DW3_ACTIVE(x) (((x) >> 31) & 0x01)
+#define FROM_DW3_NRBYTESTRANSFERRED(x) TO_U32((x) & 0x7fff)
+#define FROM_DW3_SCS_NRBYTESTRANSFERRED(x) TO_U32((x) & 0x07ff)
+#define TO_DW3_NAKCOUNT(x) TO_DW(((x) << 19))
+#define FROM_DW3_NAKCOUNT(x) ((TO_U32(x) >> 19) & 0xf)
+#define TO_DW3_CERR(x) TO_DW(((x) << 23))
+#define FROM_DW3_CERR(x) ((TO_U32(x) >> 23) & 0x3)
+#define TO_DW3_DATA_TOGGLE(x) TO_DW(((x) << 25))
+#define FROM_DW3_DATA_TOGGLE(x) ((TO_U32(x) >> 25) & 0x1)
+#define TO_DW3_PING(x) TO_DW(((x) << 26))
+#define FROM_DW3_PING(x) ((TO_U32(x) >> 26) & 0x1)
+#define DW3_ERROR_BIT TO_DW((1 << 28))
+#define DW3_BABBLE_BIT TO_DW((1 << 29))
+#define DW3_HALT_BIT TO_DW((1 << 30))
+#define DW3_ACTIVE_BIT TO_DW((1 << 31))
+#define FROM_DW3_ACTIVE(x) ((TO_U32(x) >> 31) & 0x01)
#define INT_UNDERRUN (1 << 2)
#define INT_BABBLE (1 << 1)
@@ -292,12 +294,12 @@ static void ptd_write(void __iomem *base, u32 ptd_offset, u32 slot,
struct ptd *ptd)
{
mem_writes8(base, ptd_offset + slot*sizeof(*ptd) + sizeof(ptd->dw0),
- &ptd->dw1, 7*sizeof(ptd->dw1));
+ (__force u32 *)&ptd->dw1, 7 * sizeof(ptd->dw1));
/* Make sure dw0 gets written last (after other dw's and after payload)
since it contains the enable bit */
wmb();
- mem_writes8(base, ptd_offset + slot*sizeof(*ptd), &ptd->dw0,
- sizeof(ptd->dw0));
+ mem_writes8(base, ptd_offset + slot * sizeof(*ptd),
+ (__force u32 *)&ptd->dw0, sizeof(ptd->dw0));
}
@@ -553,7 +555,7 @@ static void create_ptd_atl(struct isp1760_qh *qh,
ptd->dw0 |= TO_DW0_ENDPOINT(usb_pipeendpoint(qtd->urb->pipe));
/* DW1 */
- ptd->dw1 = usb_pipeendpoint(qtd->urb->pipe) >> 1;
+ ptd->dw1 = TO_DW((usb_pipeendpoint(qtd->urb->pipe) >> 1));
ptd->dw1 |= TO_DW1_DEVICE_ADDR(usb_pipedevice(qtd->urb->pipe));
ptd->dw1 |= TO_DW1_PID_TOKEN(qtd->packet_type);
@@ -575,7 +577,7 @@ static void create_ptd_atl(struct isp1760_qh *qh,
/* SE bit for Split INT transfers */
if (usb_pipeint(qtd->urb->pipe) &&
(qtd->urb->dev->speed == USB_SPEED_LOW))
- ptd->dw1 |= 2 << 16;
+ ptd->dw1 |= DW1_SE_USB_LOSPEED;
rl = 0;
nak = 0;
@@ -647,14 +649,14 @@ static void transform_add_int(struct isp1760_qh *qh,
* that number come from? 0xff seems to work fine...
*/
/* ptd->dw5 = 0x1c; */
- ptd->dw5 = 0xff; /* Execute Complete Split on any uFrame */
+ ptd->dw5 = TO_DW(0xff); /* Execute Complete Split on any uFrame */
}
period = period >> 1;/* Ensure equal or shorter period than requested */
period &= 0xf8; /* Mask off too large values and lowest unused 3 bits */
- ptd->dw2 |= period;
- ptd->dw4 = usof;
+ ptd->dw2 |= TO_DW(period);
+ ptd->dw4 = TO_DW(usof);
}
static void create_ptd_int(struct isp1760_qh *qh,
@@ -977,10 +979,10 @@ static void schedule_ptds(struct usb_hcd *hcd)
static int check_int_transfer(struct usb_hcd *hcd, struct ptd *ptd,
struct urb *urb)
{
- __dw dw4;
+ u32 dw4;
int i;
- dw4 = ptd->dw4;
+ dw4 = TO_U32(ptd->dw4);
dw4 >>= 8;
/* FIXME: ISP1761 datasheet does not say what to do with these. Do we
--
2.33.0
@@ -0,0 +1,64 @@
Upstream-Status: Accepted [merged with kernel 5.14.9]
Signed-off-by: Arpita S.K <arpita.s.k@arm.com>
From 03e28d5233d50fb2a27fa02d032e77974d03eb2b Mon Sep 17 00:00:00 2001
From: Rui Miguel Silva <rui.silva@linaro.org>
Date: Thu, 13 May 2021 09:47:11 +0100
Subject: [PATCH 03/23] usb: isp1760: use relaxed primitives
Use io relaxed access memory primitives to satisfy strict type
checking (__force).
This will fix some existing sparse warnings:
sparse: warning: cast to restricted __le32
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Link: https://lore.kernel.org/r/20210513084717.2487366-4-rui.silva@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/usb/isp1760/isp1760-hcd.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c
index 20d142140574..2cc0555e029d 100644
--- a/drivers/usb/isp1760/isp1760-hcd.c
+++ b/drivers/usb/isp1760/isp1760-hcd.c
@@ -246,7 +246,7 @@ static void bank_reads8(void __iomem *src_base, u32 src_offset, u32 bank_addr,
if (src_offset < PAYLOAD_OFFSET) {
while (bytes >= 4) {
- *dst = le32_to_cpu(__raw_readl(src));
+ *dst = readl_relaxed(src);
bytes -= 4;
src++;
dst++;
@@ -267,7 +267,7 @@ static void bank_reads8(void __iomem *src_base, u32 src_offset, u32 bank_addr,
* allocated.
*/
if (src_offset < PAYLOAD_OFFSET)
- val = le32_to_cpu(__raw_readl(src));
+ val = readl_relaxed(src);
else
val = __raw_readl(src);
@@ -301,7 +301,7 @@ static void mem_writes8(void __iomem *dst_base, u32 dst_offset,
if (dst_offset < PAYLOAD_OFFSET) {
while (bytes >= 4) {
- __raw_writel(cpu_to_le32(*src), dst);
+ writel_relaxed(*src, dst);
bytes -= 4;
src++;
dst++;
@@ -322,7 +322,7 @@ static void mem_writes8(void __iomem *dst_base, u32 dst_offset,
*/
if (dst_offset < PAYLOAD_OFFSET)
- __raw_writel(cpu_to_le32(*src), dst);
+ writel_relaxed(*src, dst);
else
__raw_writel(*src, dst);
}
--
2.33.0

Some files were not shown because too many files have changed in this diff Show More