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

Compare commits

...

176 Commits

Author SHA1 Message Date
Vishnu Banavath 2b0650573b arm-bsp:ffa-debugfs: update git SHA for v2.1.0
git sha on
https://git.gitlab.arm.com/linux-arm/linux-trusted-services/-/tree/v2.1.0
has been changed recently for v2.1.0 tag. This change is to update
ffa-debugfs-mod_2.1.0.bb to fetch correct git SHA.

Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-09-07 09:34:13 -04:00
Jon Mason 9bf77afada gem5: add meta-arm-bsp dependency
meta-gem5 needs the 5.4 kernel, which is only present in the
meta-arm-bsp layer.  Add this as a dependency to resolve issues.

Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-08-08 14:55:23 -04:00
Ross Burton 5a2c82fe06 arm-toolchain/layer.conf: remove BB_DANGLINGAPPENDS_WARNONLY
This appears to be historical from when the toolchain was in meta-linaro.

It isn't needed anymore, there's one bbappend in meta-arm-toolchain for
grub which is part of oe-core, so will never be dangling.

This variable has a global effect, so leaving it in here has a negative
impact on users.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-08-04 14:08:10 -04:00
Ross Burton 6cc23cbee1 arm/linux-yocto: fix boot failure in qemuarm64-secureboot
The boot crash that appears to be triggered by the ZONE_DMA patches has
been root-caused, so work around the problem whilst upstream figure out
the best way to fix.

Also, upgrade qemuarm64-secureboot to 5.15 instead of pinning back to
5.10.

Signed-off-by: Ross Burton <ross.burton@arm.com>
2022-06-05 11:36:03 -04:00
Ross Burton 2623e69db3 runfvp: check for telnet
Check for telnet on startup to avoid mysterious failures later when
telnet isn't available.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-04-26 09:00:09 -04:00
Ross Burton 952e04cd58 runfvp: propagate the exit code correctly
runfvp could encounter an error but the exit code remained as 0.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-04-26 09:00:09 -04:00
Ross Burton 4b8aeb6edc runfvp: fix undefined variable in terminal selection login
Since 10e60cc the terminal_map doesn't exist, this piece of code wasn't
updated.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-04-26 09:00:09 -04:00
Ross Burton 0ffbe558a0 runfvp: refactor terminal selection
Rewrite the terminal code to have a priority list of terminals when
selecting a default, allow the user to pick a default with a
configuration file, and add gnome-terminal to the list.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-04-26 09:00:09 -04:00
Ross Burton 5920774ada runfvp: don't use f-string when there's no expressions
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-04-26 09:00:09 -04:00
Ross Burton 55453024ee runfvp: don't hide output when using terminals
Only pass a console_cb if we're hooking up a console, so that the output
from the FVP is visible on the terminal.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-04-26 09:00:09 -04:00
Ross Burton c72527d6a5 runfvp: handle the fvp quitting before we kill it
Don't raise an exception if the FVP has quit before we get around to
killing it.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-04-26 09:00:09 -04:00
Ross Burton cc1c99f537 runfvp: add an asyncio TODO
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-04-26 09:00:09 -04:00
Harry Moulton 0ea4b2220f arm-bsp/machine: Add runfvp config for corstone1000
Add the runfvp config for corstone1000-fvp.

Signed-off-by: Harry Moulton <harry.moulton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-04-26 09:00:09 -04:00
Emekcan Aras 2de4b3c893 arm-bsp/trusted-firmware-a: corstone1000: update Tfa SHA
This commit updates Tfa SHA to remove the patches from the
recipe since all of them are upstreamed now.

Signed-off-by: Emekcan Aras emekcan.aras@arm.com
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-04-25 16:00:25 -04:00
Satish Kumar 142ec9b8f9 kas/corstone1000.yml: refspec update for run-scripts
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-04-06 22:02:25 -04:00
Vishnu Banavath bca2dbf93f arm-bsp/u-boot: add SDCard support for corstone1000 FVP
This change is to add SDCard support for corstone1000 FVP

Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
2022-04-01 16:47:13 +01:00
Harry Moulton 33bbdc67f2 arm-bsp/corstone1000: Add RDEPENDS to remove unwanted images.
Remove unwanted build images that push the binaries size over the size
limit for corstone1000.

Signed-off-by: Harry Moulton <harry.moulton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-03-14 13:00:09 -04:00
Harry Moulton af33b41925 arm-bsp/linux-yocto: backport remove redundant kernel hacking
Backport of 7fc51c7c from master which removes some redundant code to
reduce the size of the resulting corstone1000 binary.

Signed-off-by: Harry Moulton <harry.moulton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-03-14 13:00:09 -04:00
Jon Mason 7bc7872930 arm-bsp: update linux-yocto 5.4 to the latest version
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-03-11 16:44:39 -05:00
Jon Mason daa9abf065 arm-bsp: fix yylloc kernel build error
Backport patch from upstream to address the following error:
scripts/dtc/dtc-parser.tab.o:(.bss+0x20): multiple definition of `yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here

Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-03-11 16:44:39 -05:00
Peter Hoyes 90facd19a6 arm-bsp/docs,kas: Add SSH server to fvp-baser-aemv8r64 image
To make it easier for users to test and evaluate the FVP, including
testing inbound network connections, enable the openssh SSH server by
default and map to port 8022 on the host.

Update fvp-baser-aemv8r64 documentation accordingly in new "Networking"
section.

Issue-Id: SCM-3881
Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
Change-Id: I88329731418e198e2ef5d3449bfb38fde5ae77bb
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-03-11 09:17:42 -05:00
Harry Moulton 6dabbf1542 arm/fvp-corstone1000: backport: update to latest version
Backport patch from master to update the URL and checksums for the
new Corstone1000 FVP version 11.17.23.

Signed-off-by: Harry Moulton <harry.moulton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-03-09 08:43:57 -05:00
Harry Moulton ed0e6cb0d3 corstone1000: backport: update meta-arm-image for kirkstone support
Backport patch from master to update the sha for meta-arm-image in
the corstone1000 kas file to add support for kirkstone.

Signed-off-by: Harry Moulton <harry.moulton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-03-08 14:54:05 -05:00
Peter Hoyes 85fb0ee28a arm-bsp/docs: Minor fvp-baser-aemv8r64 fixes
* Include `--upgrade` in pip3 command to ensure latest kas version is
   installed
 * Ensure all underscores are either quoted or escaped
 * Fix P9 example command

Issue-Id: SCM-3881
Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
Change-Id: Ie460dbd6b1f87f5f9ca2966329341d22da3606d3
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-03-08 10:16:05 -05:00
Peter Hoyes d64e3e2178 arm-bsp/docs: Add -b honister instruction for fvp-baser-aemv8r64
Issue-Id: SCM-3871
Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
Change-Id: I1874b0bd9dc5e3da9c40b46d9d002b83b41addcc
2022-03-04 09:21:22 +00:00
Peter Hoyes 2614c78f3b arm/fvp-base-r-aem: Update to version 11.17.21
Also update version and download link in meta-arm-bsp fvp-baser-aemv8r64
documentation

Issue-Id: SCM-3871
Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
Change-Id: I92ec616d25703ff74ed063918a1e4811bac9ff3f
2022-03-02 12:56:18 +00:00
Peter Hoyes b9f850fe0e arm-bsp/docs: Improve fvp-baser-aemv864 limitation
Add more details about the cache_state_modelled limitation, which can
worked around by setting cci400.force_on_from_start=1

Issue-Id: SCM-3871
Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
Change-Id: Idde23278a87316dae842c6c3793b9836482e8c3a
2022-03-02 12:56:03 +00:00
Peter Hoyes cc4fa4a11e arm-bsp/docs: Minor fvp-baser-aemv8r64 updates
* Add clarification on how to mount p9 device
 * Remove instruction to use ctrl + c to stop FVP
 * Add cache_state_modelled to Known Issues

Issue-Id: SCM-3871
Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
Change-Id: I122c5ae5b3ceee1d106205d93a006f75bdbfa2bf
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-02-25 09:09:09 -05:00
Peter Hoyes 621cc45395 arm-bsp/docs: Update fvp-baser-aemv8r64 docs
Document U-Boot addition, add new architecture section and update the
change log.

Issue-Id: SCM-3871
Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
Change-Id: Ie0e1ff35ade634f2b523c14bb058c9d775802632
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-02-25 09:09:09 -05:00
Peter Hoyes c0e651acc8 arm-bsp/conf: Use real-time clock for fvp-baser-aemv8r64
Enable the bp.refcounter.use_real_time option, so that the CNTPCT_EL0
increments in real-time instead of simulator time.

Issue-Id: SCM-3871
Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
Change-Id: I197d6de4a7316e5299aee34e64e149cbd3d515a9
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-02-25 09:09:09 -05:00
Peter Hoyes 2c3382d4d6 arm-bsp/kernel: Use 4 Gb of RAM in fvp-baser-aemv8r64
The FVP default configuration has bp.dram_size=4, which is sufficient
for development and testing purposes, so remove the FVP_CONFIG
override and set to 4 Gb in the device tree.

Issue-Id: SCM-3871
Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
Change-Id: I4a96062c9e94d36f5459f33c86aab4d4885bab43
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-02-25 09:09:09 -05:00
Peter Hoyes 8c7c60fb3b arm-bsp/u-boot: Add U-Boot for fvp-baser-aemv8r64
This patch introduces U-Boot into the fvp-baser-aemv8r64 boot flow,
providing EFI services.

The fvp-baser-aemv8r64 does not have an EL3, so the system starts at
S-EL2. For now, U-Boot is running at S-EL2, alongside boot-wrapper.
Enable the --enable-keep-el option in boot-wrapper-aarch64 so that it
boots the next stage (U-Boot) at S-EL2. Additionally, tell
boot-wrapper-aarch64 to bundle U-Boot instead of the kernel.

Linux only supports booting from S-EL1 on the fvp-baser-aemv8r64, so
U-Boot is configured with CONFIG_SWITCH_TO_EL1, so that booti or bootefi
switch to S-EL1 before booting the EFI payload (unless an enviornment
variable - armv8_switch_to_el1 - is set to 'n').

Add patches to U-Boot, which:
 * Backports 53b40e8d54fcdb834e10e6538084517524b8401b, to disable
   pointer authentication traps.
 * Add board support for the fvp-baser-aemv8r64 (with a memory map
   which is inverted from the fvp-base).
 * Enable the configuration of U-Boot using the device tree passed from
   boot-wrapper-aarch64.
 * Enable virtio-net.
 * Disable setting the exception vectors at S-EL2 so that the PSCI
   vectors pass through to Linux.
 * Set up system registers at S-EL2 for Linux.
 * Configure the S-EL2 MPU for the EFI services.
 * Allows bootefi to switch to EL1 before booting Linux.

Issue-Id: SCM-3871
Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
Change-Id: I229d14b0717df412c1fe33772230ca779f79b32d
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-02-25 09:09:09 -05:00
Peter Hoyes b63354017a arm-bsp/boot-wrapper-aarch64: Update patches for fvp-baser-aemv8r64
Update the SRCREV to a more recent revision for the fvp-baser-aemv8r64.

Update the machine-specific patches, which makes the following changes:
 * Add PSCI services to /memreserve/ in the device tree using libfdt.
 * Add --enable-keep-el option, which allows boot-wrapper-aarch64 to
   boot the next stage at the same exception level.
 * Update the counter frequency to 100 MHz.

Issue-Id: SCM-3871
Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
Change-Id: I41843e958cf629d69de644bb57b660fb542fc8b7
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-02-25 09:09:09 -05:00
Peter Hoyes 69d11b64cb arm/boot-wrapper-aarch64: Upgrade to newer revision
Upgrade boot-wrapper-aarch64 to 1044c77062573985f7c994c3b6cef5695f57e955

Hold back gem5 at 8d5a765251d9113c3c0f9fa14de42a9e7486fe8a in bbappend.

Issue-Id: SCM-3871
Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
Change-Id: Ia5ccca2234dd117d530970f9f90469dacbb778e3
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-02-25 09:09:09 -05:00
Peter Hoyes db6223090e arm-bsp/fvp-baser-aemv8r64: Fix PL011 and SP805 register sizes
The Linux kernel expects the peripheral ID register to be just below the
end of the address range, which for the PL011 and SP805 is at 0xFE0 not
0xFFE0, so set the size to 0x1000.

Issue-Id: SCM-3881
Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
Change-Id: Iada28e8192d72b1647822c33d13deffe507043b5
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-02-25 09:09:09 -05:00
Emekcan Aras 6dd18c2a80 arm-bsp/security: move TS patches to corstone1000 directory
This commit moves all the trusted-services patches to a new
corstone1000 directory.

Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-02-21 10:26:53 -05:00
Emekcan Aras 43e5b037e8 kas/corstone1000-base: update meta-arm-image SHA
This commit updates the meta-arm-image SHA to drop psa-arch-test
from the build.

Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-02-17 18:15:53 -05:00
Vishnu Banavath 400bd5d5f4 arm-bsp/security: trusted-services to fix psa-arch-tests
These changes are to fix failures in psa-arch-tests

Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-02-17 18:15:53 -05:00
Vishnu Banavath 2e388235cb arm-bsp/security: drop psa-arch-tests recipe
This change is to build and install psa-arch-tests using
trusted-services code and drop psa-arch-tests recipe.

Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-02-17 18:15:53 -05:00
Vishnu Banavath 8a6b6eb810 arm-bsp/tf-m: update git SHA
This change is to update TF-M git SHA to fix
psa-arch-tests test case failures.

Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-02-17 18:15:34 -05:00
Vishnu Banavath 68db42ec65 arm-bsp/security: replace mbedcrypto with mbedtls
This commit replaces mbedcrpyto with mbedtls on the trusted-service
recipe.

Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-02-17 18:15:34 -05:00
Ross Burton 51b728a52b CI: use the latest release of the Kas container
If we don't specify a tag name GitLab uses the 'latest' tag, which for
Kas is moved whenever an image build is made.

Instead explicitly use the latest-release tag, which is only updated
when a release is made.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-01-28 19:03:58 -05:00
Diego Sueiro 9653e905bd meta-arm: Make generic-arm64 kernel cfg based on linux-yocto standard kernel type
By having the generic-arm64 machine using the same kernel config as the
linux-yocto standard kernel type, application layers can rely on the same base
configuration, independently of the target machine.

Also, the kernel-yocto.bbclass searches for .scc files in the FILESEXTRAPATHS.
Hence, we don't need to list generic-arm64-standard.scc in the SRC_URI.

Issue-Id: SCM-3910
Signed-off-by: Diego Sueiro <diego.sueiro@arm.com>
Change-Id: I46889ce38b32521d8350534cc590b57b158ad573
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-01-28 19:03:31 -05:00
Vishnu Banavath ccf342afe1 arm-bsp/psa-arch-tests: change master to main for psa-arch-tests repo
master branch is renamed to main on psa-arch-tests github.

Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
2022-01-18 09:00:08 -05:00
Vishnu Banavath e15df2738e arm-bsp/uboot: fix null pointer exception for get_image_info
This change is to fix NULL pointer exception for get_image_info
API for corstone1000 platform

Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
2022-01-17 14:00:08 -05:00
Vishnu Banavath c30d90a77d arm-bsp/tf-m: fix capsule instability issue for corstone1000
This change is to upgrade TF-M to latest git hash which contains
fix for capsule instability issue for corstone1000 platform.

Latest TF-M would also require v3.1 mbedtls. Also updated git hash
for mbedtls repo.
2022-01-17 14:00:08 -05:00
Ross Burton 9542161475 CI: track honister branch for clang and zephyr
These layers now have honister branches, so track those instead of master.

Signed-off-by: Ross Burton <ross.burton@arm.com>
2022-01-17 13:36:30 +00:00
Vishnu Banavath eb48eea801 arm-bsp/uboot: send bootcomplete event to secure enclave
On corstone1000 platform, Secure Enclave will be expecting
an event from uboot when it performs capsule update. Previously,
an event is sent at exitbootservice level. This will create a problem
when user wants to interrupt at UEFI shell, hence, it is required
to send an uboot efi initialized event at efi sub-system initialization
stage.

Change-Id: I7d16e184675d537d790365e1b03a414ac802694a
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-01-06 08:58:41 -05:00
Vishnu Banavath 15815c7d49 arm-bsp/secure-partitions: add check for null attribute field
UEFI spec says that if 0 is passed in the attributes filed in
setVariable() API, it means that it's a delete variable call.
Currently smm gateway doesn't handle this case. This change
is to add above mentioned check.

Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Change-Id: Id3a54601d403102da5c5617d7b4da8ec51029200
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-01-04 14:43:27 -05:00
Gowtham Suresh Kumar 3d1183ab54 arm-bsp/u-boot: corstone1000: Disable mm_communicate failure log
When a getVariable() call is made with data size set to 0,
mm_communicate should return EFI_BUFFER_TOO_SMALL. This is
an expected behavior. There should not be any failure logs
in this case. So the error log is commented here.

Change-Id: Id5b36928b1450ef9f83d34a3ab7feb4839ff9734
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-01-04 14:43:13 -05:00
Vishnu Banavath 6124334645 arm-bsp/u-boot: fix EFI image load alignment
This patch is cherry-picked from upstream to fix misalignment
of efi load image

Change-Id: If64e635a80cd0b6ecb8f09c62aa2b248d0e36f4e
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
2021-12-23 19:03:16 +00:00
Vishnu Banavath 6e16e76bf3 arm-bsp/u-boot: add ethernet device and enable configs for SCT
These changes are to add
* ethernet device SMC911x device and this is required to support
  bootfromnetwork SCT
* also enabled other config options to fix SCT issues

Change-Id: Ic6112c019cb08f77e29508ad47980f851f79088c
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
2021-12-22 09:00:08 -05:00
Gowtham Suresh Kumar b7b634a788 arm-bsp/secure-partitions: Add error cases to setVariable() and getNextVariableName()
This patch fixes the SCT errors seen for setVariable() and
getNextVariableName() functions. The existing implementation of these
functions does not cover certain error conditions which are listed in
the uefi specification. This patch adds these changes.

Change-Id: Idcddc799588339de6729b73c0ceada5c2018dd4b
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2021-12-21 14:00:09 -05:00
Gowtham Suresh Kumar 2c084144c7 arm-bsp/secure-partitions: corstone1000: Change UID of variable index in SMM
This patch fixes the os_indications setVariable() failure. The variable
index UID in SMM gateway which was 1 is changed in this patch. TFM has a
special usage for variable with UID 1, which makes it write once only.
This is not required for SMM variable index.

Change-Id: I50d60b87d3ef44ffd50e71ec4f20d31fdacf7acd
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2021-12-21 14:00:09 -05:00
Vishnu Banavath 7afe7d50f1 arm-bsp/u-boot: populate ESRT table with image_info
These changes are to support populating corstone1000 image_info
to ESRT table

Change-Id: I6e5cdd8a3477fbf3c480bf7a725198841ed79796
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
2021-12-20 10:00:09 -05:00
Gowtham Suresh Kumar 5661a1d614 arm-bsp/security: Revert set append write TS patch
Change-Id: I6e8aea102ea24271097efe92f4eb820c68ff70d5
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2021-12-20 10:00:09 -05:00
Gowtham Suresh Kumar 9ac90c6b25 arm-bsp/u-boot: corstone1000: Fix SCT failures
This patch removes the CONFIG_CMD_DHCP and CONFIG_CMD_PING
config parameters from the defconfig. It also reverts the workaround
patch which disabled NV get and set on u-boot.

Change-Id: I80f41235dbca2e76003c28164b42f4403dadc499
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2021-12-20 10:00:09 -05:00
Gowtham Suresh Kumar 5f69e4a51b arm-bsp/secure-partitions: corstone1000: Configure storage in SMM gateway
This patch will add a macro to configure the volatile and
non volatile storage in SMM gateway. Few useful logs are
also added to the secure world.

Change-Id: Ifdb405a09a9a72718df8b335b9f42509dd8c850c
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2021-12-20 10:00:09 -05:00
Ross Burton 8613971bf0 arm/edk2-firmware: correctly set the target prefix in Clang builds
We set GCC5_AARCH64_PREFIX so the tools are prefixed correctly in GCC
builds, but didn't set CLANG38_AARCH64_PREFIX. This meant the clang build
used the host objcopy, which may not know about the target architecture.

Also these can just be the prefix and not a full path, as the binaries
are on $PATH.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-16 14:39:57 +00:00
Huifeng Zhang 33f5505b58 arm/fvpboot: change the execution order of do_write_fvpboot_conf
add the do_write_fvpboot_conf function into IMAGE_POSTPROCESS_COMMAND
so that this function can be called after the build system created the
final image output files.

It's possible that bitbake doesn't run start from the do_rootfs task but
run start from do_image_<type> at the stage of image generation.

For example, there are multiple partitions in the wic file and the
grub.cfg file is placed to the first partition and the rootfs is placed
to the second partition. At this time, if we change the content of
the grub.cfg file resided in the related recipe's directory and build,
the do_rootfs task won't be run by bitbake but a new wic file will be
generated. In this situation, the fvpconf file also won't be updated and
the 'bp.virtioblockdevice.image_path' is still pointing to a old image
file.

Issue-Id: SCM-3724
Signed-off-by: Huifeng Zhang <Huifeng.Zhang@arm.com>
Change-Id: I7a41afa1d7471d09b60d118c4a6c99c57a6b548c
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-16 13:21:47 +00:00
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
280 changed files with 50174 additions and 917 deletions
+1
View File
@@ -0,0 +1 @@
__pycache__
+61 -106
View File
@@ -1,9 +1,7 @@
image: ghcr.io/siemens/kas/kas
image: ghcr.io/siemens/kas/kas:latest-release
# 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
-1
View File
@@ -4,7 +4,6 @@ header:
repos:
meta-clang:
url: https://github.com/kraj/meta-clang
refspec: master
local_conf_header:
clang: |
+13
View File
@@ -0,0 +1,13 @@
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
-1
View File
@@ -6,4 +6,3 @@ header:
repos:
meta-zephyr:
url: https://git.yoctoproject.org/git/meta-zephyr
refspec: master
+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: 9f611833ef58394b707836d69356c4e27d0265fc
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
+23
View File
@@ -0,0 +1,23 @@
header:
version: 11
includes:
- kas/corstone1000-base.yml
repos:
run-scripts:
url: https://git.gitlab.arm.com/arm-reference-solutions/model-scripts.git
refspec: b40b4227fe6b6fc8e4b688db8928f4be76e94eb7
layers:
.: 'excluded'
machine: corstone1000-fvp
local_conf_header:
fvp-config: |
# Remove Dropbear SSH as it will not fit into the corstone1000 image.
IMAGE_FEATURES:remove = " ssh-server-dropbear"
INHERIT = " ${@bb.utils.contains('BUILD_ARCH', 'x86_64', 'fvpboot', '', d)}"
LICENSE_FLAGS_WHITELIST:append = " Arm-FVP-EULA"
target:
- corstone1000-image
+6
View File
@@ -0,0 +1,6 @@
header:
version: 11
includes:
- kas/corstone1000-base.yml
machine: corstone1000-mps3
+3 -2
View File
@@ -6,7 +6,7 @@ machine: fvp-baser-aemv8r64
defaults:
repos:
refspec: master
refspec: honister
repos:
meta-arm:
@@ -33,7 +33,8 @@ local_conf_header:
CONF_VERSION = "2"
PACKAGE_CLASSES = "package_ipk"
PACKAGECONFIG:remove:pn-qemu-system-native = "gtk+ sdl"
EXTRA_IMAGE_FEATURES:append = " debug-tweaks"
EXTRA_IMAGE_FEATURES:append = " debug-tweaks ssh-server-openssh"
FVP_CONFIG[bp.virtio_net.hostbridge.userNetPorts] ?= "8022=22"
IMAGE_CLASSES:append = " ${@oe.utils.ifelse(d.getVar('FVP_BASE_R_AEM_TARBALL_URI'), 'fvpboot', '')}"
LICENSE_FLAGS_WHITELIST:append = " ${@oe.utils.vartrue('FVP_BASE_R_ARM_EULA_ACCEPT', 'Arm-FVP-EULA', '', d)}"
+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,41 @@
#@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"
# testimage config
TEST_TARGET = "OEFVPTarget"
TEST_SUITES = "noop"
# FVP Config
FVP_PROVIDER ?= "fvp-corstone1000-native"
FVP_EXE ?= "FVP_Corstone-1000"
FVP_CONSOLE ?= "host_terminal_0"
# FVP Parameters
FVP_CONFIG[se.trustedBootROMloader.fname] ?= "${DEPLOY_DIR_IMAGE}/bl1.bin"
FVP_CONFIG[board.xnvm_size] ?= "64"
FVP_CONFIG[se.trustedSRAM_config] ?= "6"
FVP_CONFIG[se.BootROM_config] ?= "3"
FVP_CONFIG[board.hostbridge.interfaceName] ?= "tap0"
FVP_CONFIG[board.smsc_91c111.enabled] ?= "1"
FVP_CONFIG[board.hostbridge.userNetworking] ?= "true"
FVP_CONFIG[board.hostbridge.userNetPorts] ?= "5555=5555,8080=80,8022=22"
FVP_CONFIG[board.se_flash_size] ?= "8192"
FVP_CONFIG[diagnostics] ?= "4"
FVP_CONFIG[disable_visualisation] ?= "true"
FVP_CONFIG[se.nvm.update_raw_image] ?= "0"
# Boot image
FVP_DATA ?= "board.flash0=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.wic.nopt@0x68100000"
# FVP Terminals
FVP_TERMINALS[host.host_terminal_0] ?= "Normal World Console"
FVP_TERMINALS[host.host_terminal_1] ?= "Secure World Console"
FVP_TERMINALS[se.secenc_terminal] ?= "Secure Enclave Console"
FVP_TERMINALS[extsys0.extsys_terminal] ?= "Cortex M3"
@@ -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"
@@ -15,10 +15,14 @@ PREFERRED_VERSION_linux-yocto-rt ?= "5.14%"
KERNEL_IMAGETYPE = "Image"
KERNEL_DEVICETREE = "arm/fvp-baser-aemv8r64.dtb"
UBOOT_MACHINE ?= "vexpress_aemv8r_defconfig"
SERIAL_CONSOLES = "115200;ttyAMA0"
IMAGE_FSTYPES += "wic"
WKS_FILE ?= "fvp-base.wks"
WKS_FILE ?= "efi-disk.wks.in"
EFI_PROVIDER ?= "grub-efi"
MACHINE_FEATURES:append = " efi"
# As this is a virtual target that will not be used in the real world there is
# no need for real SSH keys. Disable rng-tools (which takes too long to
@@ -35,7 +39,6 @@ FVP_CONSOLE ?= "terminal_0"
FVP_CONFIG[bp.virtioblockdevice.image_path] ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.wic"
FVP_CONFIG[bp.dram_metadata.init_value] ?= "0"
FVP_CONFIG[bp.dram_metadata.is_enabled] ?= "true"
FVP_CONFIG[bp.dram_size] ?= "8"
FVP_CONFIG[bp.exclusive_monitor.monitor_access_level] ?= "1"
FVP_CONFIG[bp.pl011_uart0.unbuffered_output] ?= "1"
FVP_CONFIG[bp.pl011_uart0.untimed_fifos] ?= "true"
@@ -58,4 +61,5 @@ FVP_CONFIG[gic_distributor.has-two-security-states] ?= "0"
FVP_CONFIG[pctl.startup] ?= "0.0.0.*"
FVP_CONFIG[bp.virtio_net.enabled] ?= "1"
FVP_CONFIG[bp.virtio_net.hostbridge.userNetworking] ?= "1"
FVP_CONFIG[bp.vis.rate_limit-enable] ?= "0"
FVP_CONFIG[bp.vis.rate_limit-enable] ?= "0"
FVP_CONFIG[bp.refcounter.use_real_time] ?= "1"
+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,68 @@
require conf/machine/include/arm/armv8a/tune-cortexa35.inc
MACHINEOVERRIDES =. "corstone1000:"
# TF-A
TFA_PLATFORM = "corstone1000"
PREFERRED_VERSION_trusted-firmware-a ?= "2.6%"
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"
RDEPENDS:${KERNEL_PACKAGE_NAME}-base ?= ""
#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"
+102 -18
View File
@@ -28,12 +28,65 @@ where either a standard or Real-Time Linux kernel (PREEMPT\_RT) can be built
and run:
- boot-wrapper-aarch64: provides PSCI support
- U-Boot: v2021.07 - provides UEFI services
- Linux kernel: linux-yocto-5.14
- Linux kernel with PREEMPT\_RT support: linux-yocto-rt-5.14
Note that the Real-Time Linux kernel (PREEMPT\_RT) does not use the real-time
architectural extensions of the Armv8-R feature set.
High-Level Architecture
-----------------------
The diagram below shows the current boot flow:
+---------------------------------------------------------------+
| Linux kernel |
+---------------------------------------------------------------+
/|\ /|\
| |
| UEFI services |
| PSCI services |
\|/ |
+----------------+ | S-EL1
----| U-Boot |------------------------------|-----------
+----------------+ | S-EL2
/|\ |
| |
| |
| |
+--------------------------------------------------\|/----------+
| +----------------+ +----------------+ |
| boot-wrapper-aarch64 | Device tree | | PSCI handler | |
| +----------------+ +----------------+ |
+---------------------------------------------------------------+
The firmware binary (generated as `linux-system.axf`) includes
boot-wrapper-aarch64, the flattened device tree and U-Boot. U-Boot is configured
to automatically detect a virtio block device and boot the UEFI payload at the
path `/efi/boot/bootaa64.efi`. Using the standard build, the first partition
contains a Grub image at this path, which boots the Linux kernel at `/Image` on
the same partition. The second partition of the image contains the Linux root
file system.
There is no EL3 or non-secure world in the Armv8-R AArch64 architecture, so the
reset vector starts boot-wrapper-aarch64 at S-EL2. Boot-wrapper-aarch64 is
compiled with the `--enable-keep-el` flag, which causes it to boot U-Boot at
S-EL2 too. U-Boot is compiled with the `CONFIG_ARMV8_SWITCH_TO_EL1` flag, which
causes it to switch to S-EL1 before booting Linux.
The bundled device tree is passed to U-Boot via register x0. U-Boot passes the
same device tree to Linux via the UEFI system table.
Power state management is provided by PSCI services in boot-wrapper-aarch64.
Linux accesses the PSCI handler via HVC calls to S-EL2. U-Boot has been patched
to prevent it from overriding the exception vector at S-EL2. The PSCI handler
memory region is added to a `/memreserve/` node in the device tree.
Please note that the final firmware architecture for the fvp-baser-aemv8r64 is
not yet stabilized. The patches in this layer are provided for development and
evaluation purposes only, and should not be used in production firmware.
Quick start: Howto Build and Run
--------------------------------
@@ -44,26 +97,27 @@ 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
pip3 install --user --upgrade kas
For more details on kas, see https://kas.readthedocs.io/.
To build the images for fvp-base machine, you also need to:
- download the ``FVP_Base_AEMv8R_11.15_14.tgz`` image AEM V8-R FVP Installer
- download the ``FVP_Base_AEMv8R_11.17_21.tgz`` image AEM V8-R FVP Installer
(Linux) package from Arm's website:
https://silver.arm.com/download/download.tm?pv=4858045&p=4029857. You need
https://silver.arm.com/download/download.tm?pv=4865959&p=4029857. You need
to have an account and be logged in to be able to download it
- set absolute path to the ``FVP_Base_AEMv8R_11.15_14.tgz`` downloaded
- set absolute path to the ``FVP_Base_AEMv8R_11.17_21.tgz`` downloaded
package in ``FVP_BASE_R_AEM_TARBALL_URI``
- accept EULA in ``FVP_BASE_R_ARM_EULA_ACCEPT``
The variables should be set like so:
FVP_BASE_R_AEM_TARBALL_URI="file:///absolute/path/to/FVP_Base_AEMv8R_11.15_14.tgz"
FVP_BASE_R_AEM_TARBALL_URI="file:///absolute/path/to/FVP_Base_AEMv8R_11.17_21.tgz"
FVP_BASE_R_ARM_EULA_ACCEPT="True"
**Note:** The host machine should have at least 50 GBytes of free disk space
@@ -81,21 +135,21 @@ Fetch the meta-arm repository into a build directory:
mkdir -p ~/fvp-baser-aemv8r64-build
cd ~/fvp-baser-aemv8r64-build
git clone https://git.yoctoproject.org/git/meta-arm
git clone https://git.yoctoproject.org/git/meta-arm -b honister
### Build
Building with the standard Linux kernel:
cd ~/fvp-baser-aemv8r64-build
export FVP_BASE_R_AEM_TARBALL_URI="file:///absolute/path/to/FVP_Base_AEMv8R_11.15_14.tgz"
export FVP_BASE_R_AEM_TARBALL_URI="file:///absolute/path/to/FVP_Base_AEMv8R_11.17_21.tgz"
export FVP_BASE_R_ARM_EULA_ACCEPT="True"
kas build meta-arm/kas/fvp-baser-aemv8r64-bsp.yml
Building with the Real-Time Linux kernel (PREEMPT\_RT):
cd ~/fvp-baser-aemv8r64-build
export FVP_BASE_R_AEM_TARBALL_URI="file:///absolute/path/to/FVP_Base_AEMv8R_11.15_14.tgz"
export FVP_BASE_R_AEM_TARBALL_URI="file:///absolute/path/to/FVP_Base_AEMv8R_11.17_21.tgz"
export FVP_BASE_R_ARM_EULA_ACCEPT="True"
kas build meta-arm/kas/fvp-baser-aemv8r64-rt-bsp.yml
@@ -117,17 +171,28 @@ To run an image after the build is done with the Real-Time Linux kernel
**Note:** The terminal console login is `root` without password.
To finish the fvp emulation, you need to close the telnet session and stop the
runfvp script:
1. To close the telnet session:
To finish the fvp emulation, you need to close the telnet session:
- Escape to telnet console with ``ctrl+]``.
- Run ``quit`` to close the session.
2. To stop the runfvp:
### Networking
The FVP is configured by default to use "user-mode networking", which simulates
an IP router and DHCP server to avoid additional host dependencies and
networking configuration. Outbound connections work automatically, e.g. by
running:
- Type ``ctrl+c`` and wait for kas process to finish.
wget www.arm.com
Inbound connections require an explicit port mapping from the host. By default,
port 8022 on the host is mapped to port 22 on the FVP, so that the following
command will connect to an ssh server running on the FVP:
ssh root@localhost -p 8022
Note that user-mode networking does not support ICMP, so `ping` will not work.
For more information about user-mode networking, please see
https://developer.arm.com/documentation/100964/1117/Introduction-to-Fast-Models/User-mode-networking?lang=en
### File sharing between host and fvp
It is possible to share a directory between the host machine and the fvp using
@@ -141,6 +206,14 @@ launching the model:
--parameter 'bp.virtiop9device.root_path=/path/to/host-mount-dir'
e.g. for the standard Linux kernel:
kas shell --keep-config-unchanged \
meta-arm/kas/fvp-baser-aemv8r64-bsp.yml \
--command "../layers/meta-arm/scripts/runfvp \
--console -- --parameter \
'bp.virtiop9device.root_path=/path/to/host-mount-dir'"
Once you are logged into the fvp, the host directory can be mounted in a
directory on the model using the following command:
@@ -162,16 +235,27 @@ Known Issues and Limitations
- Only PSCI CPU\_ON and CPU\_OFF functions are supported
- Linux kernel does not support booting from secure EL2 on Armv8-R AArch64
- Linux KVM does not support Armv8-R AArch64
- Device DMA memory cache-coherence issue: the FVP `cache_state_modelled`
parameter will affect the cache coherence behavior of peripherals DMA. When
users set `cache_state_modelled=1`, they also have to set
`cci400.force_on_from_start=1` to force the FVP to enable snooping on upstream
ports.
Change Log
----------
- Added virtio_net User Networking mode by default and removed instructions
- Added U-Boot v2021.07 for UEFI support.
- Updated boot-wrapper-aarch64 revision and added support for booting U-Boot.
- Included boot-wrapper-aarch64 PSCI services in `/memreserve/` region.
- Fixed the counter frequency initialization in boot-wrapper-aarch64.
- Configured the FVP to use the default RAM size of 4 Gb
- Fixed PL011 and SP805 register sizes in the device tree.
- Added virtio\_net User Networking mode by default and removed instructions
about tap networking setup.
- Updated Linux kernel version from 5.10 to 5.14 for both standard and
Real-Time (PREEMPT\_RT) builds.
- Enabled SMP support via boot-wrapper-aarch64 providing the PSCI CPU_ON and
CPU_OFF functions.
- Enabled SMP support via boot-wrapper-aarch64 providing the PSCI CPU\_ON and
CPU\_OFF functions.
- Introduced Armv8-R64 compiler flags.
- Added Linux PREEMPT\_RT support via linux-yocto-rt-5.10.
- Added support for file sharing with the host machine using Virtio P9.
@@ -2,14 +2,30 @@ COMPATIBLE_MACHINE = "fvp-baser-aemv8r64"
FILESEXTRAPATHS:prepend := "${THISDIR}/files/${MACHINE}:"
SRC_URI:append = " \
file://0001-Decouple-V2M_SYS-config-by-auto-detect-dtb-node.patch \
file://0002-arch64-Introduce-EL2-boot-code-for-v8-r64.patch \
file://0003-Allow-enable-psci-to-choose-between-smc-and-hvc.patch \
file://0001-aarch64-Rename-labels-and-prepare-for-lower-EL-booti.patch \
file://0002-aarch64-Prepare-for-EL1-booting.patch \
file://0003-aarch64-Prepare-for-lower-EL-booting.patch \
file://0004-gic-v3-Prepare-for-gicv3-with-EL2.patch \
file://0005-aarch64-Prepare-for-booting-with-EL2.patch \
file://0006-aarch64-Introduce-EL2-boot-code-for-Armv8-R-AArch64.patch \
file://0007-Allow-enable-psci-to-choose-between-smc-and-hvc.patch \
file://0008-aarch64-Disable-CNTPCT_EL0-trap-for-v8-R64.patch \
file://0009-lds-Mark-the-mem-range.patch \
file://0010-common-Introduce-the-libfdt.patch \
file://0011-common-Add-essential-libc-functions.patch \
file://0012-Makefile-Add-the-libfdt-to-the-Makefile-system.patch \
file://0013-platform-Add-print_hex-func.patch \
file://0014-common-Add-mem-usage-to-memreserve.patch \
file://0015-boot-Add-the-enable-keep-el-compile-option.patch \
file://0016-Makefile-Change-COUNTER_FREQ-to-100-MHz.patch \
"
BOOT_WRAPPER_AARCH64_CMDLINE = "\
earlycon console=ttyAMA0 loglevel=8 rootfstype=ext4 root=/dev/vda1 rw"
EXTRA_OECONF += "--enable-psci=hvc"
EXTRA_OECONF += "--enable-psci=hvc --enable-keep-el"
TUNE_CCARGS = ""
BOOT_WRAPPER_AARCH64_KERNEL = "u-boot.bin"
do_deploy[depends] += "u-boot:do_deploy"
@@ -1,67 +0,0 @@
From 7b8c821c22929cd2d3532f937672fcf05dc7d5d0 Mon Sep 17 00:00:00 2001
Message-Id: <7b8c821c22929cd2d3532f937672fcf05dc7d5d0.1616744115.git.diego.sueiro@arm.com>
From: Jaxson Han <jaxson.han@arm.com>
Date: Thu, 25 Mar 2021 12:35:13 +0800
Subject: [PATCH 1/2] Decouple V2M_SYS config by auto-detect dtb node
An auto-detect switch is added to make it an option to enable/disable
'arm,vexpress-sysreg', because not all platforms support this feature.
Issue-ID: SCM-2221
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
Change-Id: Ib8738aa62ca3902f7bdae2ad9a5a63aa2d225abf
Upstream-Status: Pending
Signed-off-by: Diego Sueiro <diego.sueiro@arm.com>
---
Makefile.am | 2 +-
platform.c | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am
index af694b7..e131207 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,7 +19,7 @@ NR_CPUS := $(shell echo $(CPU_IDS) | tr ',' ' ' | wc -w)
DEFINES = -DCNTFRQ=$(CNTFRQ)
DEFINES += -DCPU_IDS=$(CPU_IDS)
DEFINES += -DNR_CPUS=$(NR_CPUS)
-DEFINES += -DSYSREGS_BASE=$(SYSREGS_BASE)
+DEFINES += $(if $(SYSREGS_BASE), -DSYSREGS_BASE=$(SYSREGS_BASE), )
DEFINES += -DUART_BASE=$(UART_BASE)
DEFINES += -DSTACK_SIZE=256
diff --git a/platform.c b/platform.c
index a528a55..d11f568 100644
--- a/platform.c
+++ b/platform.c
@@ -23,10 +23,12 @@
#define PL011(reg) ((void *)UART_BASE + PL011_##reg)
+#ifdef SYSREGS_BASE
#define V2M_SYS_CFGDATA 0xa0
#define V2M_SYS_CFGCTRL 0xa4
#define V2M_SYS(reg) ((void *)SYSREGS_BASE + V2M_SYS_##reg)
+#endif
static void print_string(const char *str)
{
@@ -59,6 +61,7 @@ void init_platform(void)
print_string("Boot-wrapper v0.2\r\n\r\n");
+#ifdef SYSREGS_BASE
/*
* CLCD output site MB
*/
@@ -66,4 +69,5 @@ void init_platform(void)
/* START | WRITE | MUXFPGA | SITE_MB */
raw_writel((1 << 31) | (1 << 30) | (7 << 20) | (0 << 16),
V2M_SYS(CFGCTRL));
+#endif
}
--
2.17.1
@@ -0,0 +1,135 @@
From 3e7cfbe39a2a053d2a6b0d928cc172ed9d1c6da8 Mon Sep 17 00:00:00 2001
From: Jaxson Han <jaxson.han@arm.com>
Date: Tue, 25 May 2021 07:25:00 +0100
Subject: [PATCH] aarch64: Rename labels and prepare for lower EL booting
Prepare for booting from lower EL. Rename *_el3 relavant labels with
*_el_max and *_no_el3 with *_keep_el. Since the original _no_el3 means
"We neither do init sequence at this highest EL nor drop to lower EL
when entering to kernel", we rename it with _keep_el to make it more
clear for lower EL initialisation.
Upstream-Status: Pending
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
---
arch/aarch64/boot.S | 28 ++++++++++++++++++++--------
arch/aarch64/psci.S | 9 +++++----
arch/aarch64/spin.S | 4 ++--
3 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/arch/aarch64/boot.S b/arch/aarch64/boot.S
index 27ba449..84e1646 100644
--- a/arch/aarch64/boot.S
+++ b/arch/aarch64/boot.S
@@ -21,18 +21,30 @@ ASM_FUNC(_start)
/*
* EL3 initialisation
+ * Boot sequence
+ * If CurrentEL == EL3, then goto EL3 initialisation and drop to
+ * lower EL before entering the kernel.
+ * Else, no initialisation and keep the current EL before
+ * entering the kernel.
*/
mrs x0, CurrentEL
cmp x0, #CURRENTEL_EL3
- b.eq 1f
+ b.eq el3_init
+ /*
+ * We stay in the current EL for entering the kernel
+ */
mov w0, #1
- ldr x1, =flag_no_el3
+ ldr x1, =flag_keep_el
str w0, [x1]
- b start_no_el3
+ b start_keep_el
-1: mov x0, #0x30 // RES1
+ /*
+ * EL3 initialisation
+ */
+el3_init:
+ mov x0, #0x30 // RES1
orr x0, x0, #(1 << 0) // Non-secure EL1
orr x0, x0, #(1 << 8) // HVC enable
@@ -124,7 +136,7 @@ ASM_FUNC(_start)
bl gic_secure_init
- b start_el3
+ b start_el_max
err_invalid_id:
b .
@@ -151,7 +163,7 @@ ASM_FUNC(jump_kernel)
bl find_logical_id
bl setup_stack // Reset stack pointer
- ldr w0, flag_no_el3
+ ldr w0, flag_keep_el
cmp w0, #0 // Prepare Z flag
mov x0, x20
@@ -160,7 +172,7 @@ ASM_FUNC(jump_kernel)
mov x3, x23
b.eq 1f
- br x19 // No EL3
+ br x19 // Keep current EL
1: mov x4, #SPSR_KERNEL
@@ -178,5 +190,5 @@ ASM_FUNC(jump_kernel)
.data
.align 3
-flag_no_el3:
+flag_keep_el:
.long 0
diff --git a/arch/aarch64/psci.S b/arch/aarch64/psci.S
index 8bd224b..7b8919a 100644
--- a/arch/aarch64/psci.S
+++ b/arch/aarch64/psci.S
@@ -79,7 +79,7 @@ smc_exit:
ldp x18, x19, [sp], #16
eret
-ASM_FUNC(start_el3)
+ASM_FUNC(start_el_max)
ldr x0, =vector
bl setup_vector
@@ -89,10 +89,11 @@ ASM_FUNC(start_el3)
b psci_first_spin
/*
- * This PSCI implementation requires EL3. Without EL3 we'll only boot the
- * primary cpu, all others will be trapped in an infinite loop.
+ * This PSCI implementation requires the highest EL(EL3 or Armv8-R EL2).
+ * Without the highest EL, we'll only boot the primary cpu, all othersr
+ * will be trapped in an infinite loop.
*/
-ASM_FUNC(start_no_el3)
+ASM_FUNC(start_keep_el)
cpuid x0, x1
bl find_logical_id
cbz x0, psci_first_spin
diff --git a/arch/aarch64/spin.S b/arch/aarch64/spin.S
index 1ea1c0b..bfb1d47 100644
--- a/arch/aarch64/spin.S
+++ b/arch/aarch64/spin.S
@@ -12,8 +12,8 @@
.text
-ASM_FUNC(start_el3)
-ASM_FUNC(start_no_el3)
+ASM_FUNC(start_el_max)
+ASM_FUNC(start_keep_el)
cpuid x0, x1
bl find_logical_id
@@ -0,0 +1,48 @@
From 26f9b5354c2de9cc052531096ff92b04c3a3846f Mon Sep 17 00:00:00 2001
From: Jaxson Han <jaxson.han@arm.com>
Date: Tue, 25 May 2021 07:25:00 +0100
Subject: [PATCH] aarch64: Prepare for EL1 booting
When booting from EL1, add a check and skip the init of
sctlr_el2 in jump_kernel
Upstream-Status: Pending
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
---
arch/aarch64/boot.S | 6 +++++-
arch/aarch64/include/asm/cpu.h | 1 +
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/aarch64/boot.S b/arch/aarch64/boot.S
index 84e1646..b589744 100644
--- a/arch/aarch64/boot.S
+++ b/arch/aarch64/boot.S
@@ -156,10 +156,14 @@ ASM_FUNC(jump_kernel)
ldr x0, =SCTLR_EL1_KERNEL
msr sctlr_el1, x0
+ mrs x0, CurrentEL
+ cmp x0, #CURRENTEL_EL2
+ b.lt 1f
+
ldr x0, =SCTLR_EL2_KERNEL
msr sctlr_el2, x0
- cpuid x0, x1
+1: cpuid x0, x1
bl find_logical_id
bl setup_stack // Reset stack pointer
diff --git a/arch/aarch64/include/asm/cpu.h b/arch/aarch64/include/asm/cpu.h
index 63eb1c3..b1003f4 100644
--- a/arch/aarch64/include/asm/cpu.h
+++ b/arch/aarch64/include/asm/cpu.h
@@ -11,6 +11,7 @@
#define MPIDR_ID_BITS 0xff00ffffff
+#define CURRENTEL_EL2 (2 << 2)
#define CURRENTEL_EL3 (3 << 2)
/*
@@ -1,314 +0,0 @@
From 81fcc5cc80c9c3c812d92000b9116f6a02ff7e6c Mon Sep 17 00:00:00 2001
Message-Id: <81fcc5cc80c9c3c812d92000b9116f6a02ff7e6c.1616744115.git.diego.sueiro@arm.com>
In-Reply-To: <7b8c821c22929cd2d3532f937672fcf05dc7d5d0.1616744115.git.diego.sueiro@arm.com>
References: <7b8c821c22929cd2d3532f937672fcf05dc7d5d0.1616744115.git.diego.sueiro@arm.com>
From: Jaxson Han <jaxson.han@arm.com>
Date: Thu, 25 Mar 2021 12:47:02 +0800
Subject: [PATCH 2/2] arch64: Introduce EL2 boot code for v8-r64
The v8-r64 boots from EL2 mode. In order to boot linux, EL2 boot mode
is needed. Because there is no MMU supported for v8-r64 under EL2 mode,
bootwrapper needs to switch to EL1 mode when jumpping to the kernel.
Some register in gic-v3.h need to be auto-detected.
Issue-ID: SCM-2221
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
Change-Id: I52ca3f045f1ab50f32945420144752f396d95193
Upstream-Status: Pending
Signed-off-by: Diego Sueiro <diego.sueiro@arm.com>
---
arch/aarch64/boot.S | 76 +++++++++++++++++++++++++++----
arch/aarch64/include/asm/cpu.h | 3 ++
arch/aarch64/include/asm/gic-v3.h | 23 ++++++++--
arch/aarch64/psci.S | 13 +++---
arch/aarch64/spin.S | 8 ++--
arch/aarch64/utils.S | 8 ++++
6 files changed, 110 insertions(+), 21 deletions(-)
diff --git a/arch/aarch64/boot.S b/arch/aarch64/boot.S
index e47cf59..5c3eb73 100644
--- a/arch/aarch64/boot.S
+++ b/arch/aarch64/boot.S
@@ -22,20 +22,30 @@ _start:
bl setup_stack
/*
- * EL3 initialisation
+ * Boot sequence
+ * If EL3, goto EL3 initialisation
+ * If EL2 && id_aa64mmfr0_el1.MSA == 0xf, do Armv8r initialisation
+ * Else no initialisation sequence
*/
mrs x0, CurrentEL
cmp x0, #CURRENTEL_EL3
- b.eq 1f
+ beq el3_init
+ cmp x0, #CURRENTEL_EL2
+ beq el2_init
+no_el_max:
mov w0, #1
ldr x1, =flag_no_el3
str w0, [x1]
bl setup_stack
- b start_no_el3
+ b start_no_el_max
-1: mov x0, #0x30 // RES1
+ /*
+ * EL3 initialisation
+ */
+el3_init:
+ mov x0, #0x30 // RES1
orr x0, x0, #(1 << 0) // Non-secure EL1
orr x0, x0, #(1 << 8) // HVC enable
@@ -93,14 +103,54 @@ _start:
mov x0, #ZCR_EL3_LEN_MASK // SVE: Enable full vector len
msr ZCR_EL3, x0 // for EL2.
-1:
+ mov w0, #SPSR_KERNEL
+ ldr x1, =spsr_to_elx
+ str w0, [x1]
+ b el_max_init
+
+ /*
+ * EL2 Armv8r initialisation
+ */
+el2_init:
+ /* Detect Armv8r */
+ mrs x1, id_aa64mmfr0_el1
+ ubfx x1, x1, #48, #4 // MSA
+ cmp x1, 0xf // 0xf means Armv8r
+ bne no_el_max
+
+ mrs x0, midr_el1
+ msr vpidr_el2, x0
+
+ mrs x0, mpidr_el1
+ msr vmpidr_el2, x0
+
+ mov x0, #(1 << 31) // VTCR_MSA: VMSAv8-64 support
+ msr vtcr_el2, x0
+
+ /* Enable pointer authentication if present */
+ mrs x1, id_aa64isar1_el1
+ ldr x2, =(((0xff) << 24) | (0xff << 4))
+ and x1, x1, x2
+ cbz x1, 1f
+
+ mrs x0, hcr_el2
+ orr x0, x0, #(1 << 40) // AP key enable
+ orr x0, x0, #(1 << 41) // AP insn enable
+ msr hcr_el2, x0
+
+1: isb
+ mov w0, #SPSR_KERNEL_EL1
+ ldr x1, =spsr_to_elx
+ str w0, [x1]
+ b el_max_init
+
+el_max_init:
ldr x0, =CNTFRQ
msr cntfrq_el0, x0
bl gic_secure_init
- b start_el3
-
+ b start_el_max
err_invalid_id:
b .
@@ -137,7 +187,7 @@ jump_kernel:
b.eq 1f
br x19 // No EL3
-1: mov x4, #SPSR_KERNEL
+1: ldr w4, spsr_to_elx
/*
* If bit 0 of the kernel address is set, we're entering in AArch32
@@ -145,13 +195,23 @@ jump_kernel:
*/
bfi x4, x19, #5, #1
+ mrs x18, CurrentEL
+ cmp x18, #CURRENTEL_EL2
+ b.eq 1f
+
msr elr_el3, x19
msr spsr_el3, x4
eret
+1: msr elr_el2, x19
+ msr spsr_el2, x4
+ eret
+
.ltorg
.data
.align 3
flag_no_el3:
.long 0
+spsr_to_elx:
+ .long 0
diff --git a/arch/aarch64/include/asm/cpu.h b/arch/aarch64/include/asm/cpu.h
index ccb5397..2b3a0a4 100644
--- a/arch/aarch64/include/asm/cpu.h
+++ b/arch/aarch64/include/asm/cpu.h
@@ -11,6 +11,7 @@
#define MPIDR_ID_BITS 0xff00ffffff
+#define CURRENTEL_EL2 (2 << 2)
#define CURRENTEL_EL3 (3 << 2)
/*
@@ -24,6 +25,7 @@
#define SPSR_I (1 << 7) /* IRQ masked */
#define SPSR_F (1 << 6) /* FIQ masked */
#define SPSR_T (1 << 5) /* Thumb */
+#define SPSR_EL1H (5 << 0) /* EL1 Handler mode */
#define SPSR_EL2H (9 << 0) /* EL2 Handler mode */
#define SPSR_HYP (0x1a << 0) /* M[3:0] = hyp, M[4] = AArch32 */
@@ -42,6 +44,7 @@
#else
#define SCTLR_EL1_RESET SCTLR_EL1_RES1
#define SPSR_KERNEL (SPSR_A | SPSR_D | SPSR_I | SPSR_F | SPSR_EL2H)
+#define SPSR_KERNEL_EL1 (SPSR_A | SPSR_D | SPSR_I | SPSR_F | SPSR_EL1H)
#endif
#ifndef __ASSEMBLY__
diff --git a/arch/aarch64/include/asm/gic-v3.h b/arch/aarch64/include/asm/gic-v3.h
index e743c02..f8ddb27 100644
--- a/arch/aarch64/include/asm/gic-v3.h
+++ b/arch/aarch64/include/asm/gic-v3.h
@@ -15,21 +15,38 @@
#define ICC_CTLR_EL3 "S3_6_C12_C12_4"
#define ICC_PMR_EL1 "S3_0_C4_C6_0"
+static inline uint32_t current_el(void)
+{
+ uint32_t val;
+
+ asm volatile ("mrs %0, CurrentEL" : "=r" (val));
+ return val;
+}
+
static inline uint32_t gic_read_icc_sre(void)
{
uint32_t val;
- asm volatile ("mrs %0, " ICC_SRE_EL3 : "=r" (val));
+
+ if(current_el() == CURRENTEL_EL3)
+ asm volatile ("mrs %0, " ICC_SRE_EL3 : "=r" (val));
+ else
+ asm volatile ("mrs %0, " ICC_SRE_EL2 : "=r" (val));
+
return val;
}
static inline void gic_write_icc_sre(uint32_t val)
{
- asm volatile ("msr " ICC_SRE_EL3 ", %0" : : "r" (val));
+ if(current_el() == CURRENTEL_EL3)
+ asm volatile ("msr " ICC_SRE_EL3 ", %0" : : "r" (val));
+ else
+ asm volatile ("msr " ICC_SRE_EL2 ", %0" : : "r" (val));
}
static inline void gic_write_icc_ctlr(uint32_t val)
{
- asm volatile ("msr " ICC_CTLR_EL3 ", %0" : : "r" (val));
+ if(current_el() == CURRENTEL_EL3)
+ asm volatile ("msr " ICC_CTLR_EL3 ", %0" : : "r" (val));
}
#endif
diff --git a/arch/aarch64/psci.S b/arch/aarch64/psci.S
index 01ebe7d..0681d5e 100644
--- a/arch/aarch64/psci.S
+++ b/arch/aarch64/psci.S
@@ -45,8 +45,8 @@ vector:
.text
- .globl start_no_el3
- .globl start_el3
+ .globl start_no_el_max
+ .globl start_el_max
err_exception:
b err_exception
@@ -101,7 +101,7 @@ smc_exit:
eret
-start_el3:
+start_el_max:
ldr x0, =vector
bl setup_vector
@@ -111,10 +111,11 @@ start_el3:
b psci_first_spin
/*
- * This PSCI implementation requires EL3. Without EL3 we'll only boot the
- * primary cpu, all others will be trapped in an infinite loop.
+ * This PSCI implementation requires EL3 or AArch64-R EL2. Without EL max
+ * we'll only boot the primary cpu, all others will be trapped in an infinite
+ * loop.
*/
-start_no_el3:
+start_no_el_max:
cpuid x0, x1
bl find_logical_id
cbz x0, psci_first_spin
diff --git a/arch/aarch64/spin.S b/arch/aarch64/spin.S
index 72603cf..fa1d657 100644
--- a/arch/aarch64/spin.S
+++ b/arch/aarch64/spin.S
@@ -11,11 +11,11 @@
.text
- .globl start_no_el3
- .globl start_el3
+ .globl start_no_el_max
+ .globl start_el_max
-start_el3:
-start_no_el3:
+start_el_max:
+start_no_el_max:
cpuid x0, x1
bl find_logical_id
diff --git a/arch/aarch64/utils.S b/arch/aarch64/utils.S
index ae22ea7..2a63fa7 100644
--- a/arch/aarch64/utils.S
+++ b/arch/aarch64/utils.S
@@ -41,6 +41,14 @@ find_logical_id:
* x0: vector address
*/
setup_vector:
+ mrs x1, CurrentEL
+ cmp x1, #CURRENTEL_EL2
+ b.eq 1f
+
msr VBAR_EL3, x0
isb
ret
+
+1: msr VBAR_EL2, x0
+ isb
+ ret
--
2.17.1
@@ -0,0 +1,55 @@
From ce628de7699dd6401ddf713efaa49872e2733619 Mon Sep 17 00:00:00 2001
From: Jaxson Han <jaxson.han@arm.com>
Date: Tue, 25 May 2021 07:25:00 +0100
Subject: [PATCH] aarch64: Prepare for lower EL booting
Save SPSR_KERNEL into spsr_to_elx during el3_init.
The jump_kernel will load spsr_to_elx into spsr_el3.
This change will make it easier to control whether drop to lower EL
before jumping to the kernel.
Upstream-Status: Pending
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
---
arch/aarch64/boot.S | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/arch/aarch64/boot.S b/arch/aarch64/boot.S
index b589744..6b45afc 100644
--- a/arch/aarch64/boot.S
+++ b/arch/aarch64/boot.S
@@ -130,7 +130,16 @@ el3_init:
mov x0, #ZCR_EL3_LEN_MASK // SVE: Enable full vector len
msr ZCR_EL3, x0 // for EL2.
-1:
+ /*
+ * Save SPSR_KERNEL into spsr_to_elx.
+ * The jump_kernel will load spsr_to_elx into spsr_el3
+ */
+1: mov w0, #SPSR_KERNEL
+ ldr x1, =spsr_to_elx
+ str w0, [x1]
+ b el_max_init
+
+el_max_init:
ldr x0, =COUNTER_FREQ
msr cntfrq_el0, x0
@@ -178,7 +187,7 @@ ASM_FUNC(jump_kernel)
b.eq 1f
br x19 // Keep current EL
-1: mov x4, #SPSR_KERNEL
+1: ldr w4, spsr_to_elx
/*
* If bit 0 of the kernel address is set, we're entering in AArch32
@@ -196,3 +205,5 @@ ASM_FUNC(jump_kernel)
.align 3
flag_keep_el:
.long 0
+spsr_to_elx:
+ .long 0
@@ -0,0 +1,105 @@
From 483d363bf825082b6db6de3c57d169e741861891 Mon Sep 17 00:00:00 2001
From: Jaxson Han <jaxson.han@arm.com>
Date: Tue, 25 May 2021 07:25:00 +0100
Subject: [PATCH] gic-v3: Prepare for gicv3 with EL2
This is a preparation for allowing boot-wrapper configuring the gicv3
with EL2.
When confiuring with EL2, since there is no ICC_CTLR_EL2, the
ICC_CTLR_EL3 cannot be replaced with ICC_CTLR_EL2 simply.
See [https://developer.arm.com/documentation/ihi0069/latest/].
As the caller, gic_secure_init expects the ICC_CTLR to be written,
we change the function into gic_init_icc_ctlr(). In the GIC spec,
the r/w bits in this register ([6:0]) either affect EL3 IRQ routing
(not applicable since no EL3), non-secure IRQ handling (not applicable
since only secure state in Armv8-R aarch64), or are aliased to
ICC_CTLR_EL1 bits.
So, based on this, the new gic_init_icc_ctlr() would be:
When currentEL is EL3, init ICC_CTLR_EL3 as before.
When currentEL is not EL3, init ICC_CTLR_EL1 with ICC_CTLR_EL1_RESET.
Upstream-Status: Pending
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
---
arch/aarch32/include/asm/gic-v3.h | 7 +++++++
arch/aarch64/include/asm/gic-v3.h | 23 ++++++++++++++++++++---
common/gic-v3.c | 2 +-
3 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/arch/aarch32/include/asm/gic-v3.h b/arch/aarch32/include/asm/gic-v3.h
index 65f38de..11e7bc7 100644
--- a/arch/aarch32/include/asm/gic-v3.h
+++ b/arch/aarch32/include/asm/gic-v3.h
@@ -9,6 +9,8 @@
#ifndef __ASM_AARCH32_GICV3_H
#define __ASM_AARCH32_GICV3_H
+#define ICC_CTLR_RESET (0UL)
+
static inline void gic_write_icc_sre(uint32_t val)
{
asm volatile ("mcr p15, 6, %0, c12, c12, 5" : : "r" (val));
@@ -19,4 +21,9 @@ static inline void gic_write_icc_ctlr(uint32_t val)
asm volatile ("mcr p15, 6, %0, c12, c12, 4" : : "r" (val));
}
+static inline void gic_init_icc_ctlr()
+{
+ gic_write_icc_ctlr(ICC_CTLR_RESET);
+}
+
#endif
diff --git a/arch/aarch64/include/asm/gic-v3.h b/arch/aarch64/include/asm/gic-v3.h
index 5b32380..090ab0b 100644
--- a/arch/aarch64/include/asm/gic-v3.h
+++ b/arch/aarch64/include/asm/gic-v3.h
@@ -15,14 +15,31 @@
#define ICC_CTLR_EL3 "S3_6_C12_C12_4"
#define ICC_PMR_EL1 "S3_0_C4_C6_0"
+#define ICC_CTLR_EL3_RESET (0UL)
+#define ICC_CTLR_EL1_RESET (0UL)
+
+static inline uint32_t current_el(void)
+{
+ uint32_t val;
+
+ asm volatile ("mrs %0, CurrentEL" : "=r" (val));
+ return val;
+}
+
static inline void gic_write_icc_sre(uint32_t val)
{
- asm volatile ("msr " ICC_SRE_EL3 ", %0" : : "r" (val));
+ if (current_el() == CURRENTEL_EL3)
+ asm volatile ("msr " ICC_SRE_EL3 ", %0" : : "r" (val));
+ else
+ asm volatile ("msr " ICC_SRE_EL2 ", %0" : : "r" (val));
}
-static inline void gic_write_icc_ctlr(uint32_t val)
+static inline void gic_init_icc_ctlr()
{
- asm volatile ("msr " ICC_CTLR_EL3 ", %0" : : "r" (val));
+ if (current_el() == CURRENTEL_EL3)
+ asm volatile ("msr " ICC_CTLR_EL3 ", %0" : : "r" (ICC_CTLR_EL3_RESET));
+ else
+ asm volatile ("msr " ICC_CTLR_EL1 ", %0" : : "r" (ICC_CTLR_EL1_RESET));
}
#endif
diff --git a/common/gic-v3.c b/common/gic-v3.c
index 6207007..a0fe564 100644
--- a/common/gic-v3.c
+++ b/common/gic-v3.c
@@ -117,6 +117,6 @@ void gic_secure_init(void)
gic_write_icc_sre(ICC_SRE_Enable | ICC_SRE_DIB | ICC_SRE_DFB | ICC_SRE_SRE);
isb();
- gic_write_icc_ctlr(0);
+ gic_init_icc_ctlr();
isb();
}
@@ -0,0 +1,63 @@
From be814863cdd5f61d9a16eec012d500550053c8c6 Mon Sep 17 00:00:00 2001
From: Jaxson Han <jaxson.han@arm.com>
Date: Tue, 25 May 2021 07:25:00 +0100
Subject: [PATCH] aarch64: Prepare for booting with EL2
Prepare for allowing boot-wrapper to be entered in EL2.
Detect current EL and set the corresponding EL registers.
Upstream-Status: Pending
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
---
arch/aarch64/boot.S | 8 ++++++++
arch/aarch64/utils.S | 10 +++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/arch/aarch64/boot.S b/arch/aarch64/boot.S
index 6b45afc..908764a 100644
--- a/arch/aarch64/boot.S
+++ b/arch/aarch64/boot.S
@@ -195,10 +195,18 @@ ASM_FUNC(jump_kernel)
*/
bfi x4, x19, #5, #1
+ mrs x5, CurrentEL
+ cmp x5, #CURRENTEL_EL2
+ b.eq 1f
+
msr elr_el3, x19
msr spsr_el3, x4
eret
+1: msr elr_el2, x19
+ msr spsr_el2, x4
+ eret
+
.ltorg
.data
diff --git a/arch/aarch64/utils.S b/arch/aarch64/utils.S
index 85c7f8a..f02a249 100644
--- a/arch/aarch64/utils.S
+++ b/arch/aarch64/utils.S
@@ -34,10 +34,18 @@ ASM_FUNC(find_logical_id)
ret
/*
- * Setup EL3 vectors
+ * Setup EL3/EL2 vectors
* x0: vector address
*/
ASM_FUNC(setup_vector)
+ mrs x1, CurrentEL
+ cmp x1, #CURRENTEL_EL2
+ b.eq 1f
+
msr VBAR_EL3, x0
isb
ret
+
+1: msr VBAR_EL2, x0
+ isb
+ ret
@@ -0,0 +1,182 @@
From 81df76f8d94cb6c31c01739b078a72bdb8497441 Mon Sep 17 00:00:00 2001
From: Jaxson Han <jaxson.han@arm.com>
Date: Tue, 25 May 2021 07:25:00 +0100
Subject: [PATCH] aarch64: Introduce EL2 boot code for Armv8-R AArch64
The Armv8-R AArch64 profile does not support the EL3 exception level.
The Armv8-R AArch64 profile allows for an (optional) VMSAv8-64 MMU
at EL1, which allows to run off-the-shelf Linux. However EL2 only
supports a PMSA, which is not supported by Linux, so we need to drop
into EL1 before entering the kernel.
We add a new err_invalid_arch symbol as a dead loop. If we detect the
current Armv8-R aarch64 only supports with PMSA, meaning we cannot boot
Linux anymore, then we jump to err_invalid_arch.
During Armv8-R aarch64 init, to make sure nothing unexpected traps into
EL2, we auto-detect and config FIEN and EnSCXT in HCR_EL2.
The boot sequence is:
If CurrentEL == EL3, then goto EL3 initialisation and drop to lower EL
before entering the kernel.
If CurrentEL == EL2 && id_aa64mmfr0_el1.MSA == 0xf (Armv8-R aarch64),
if id_aa64mmfr0_el1.MSA_frac == 0x2,
then goto Armv8-R AArch64 initialisation and drop to EL1 before
entering the kernel.
else, which means VMSA unsupported and cannot boot Linux,
goto err_invalid_arch (dead loop).
Else, no initialisation and keep the current EL before entering the
kernel.
Upstream-Status: Pending
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
---
arch/aarch64/boot.S | 92 +++++++++++++++++++++++++++++++++-
arch/aarch64/include/asm/cpu.h | 2 +
2 files changed, 92 insertions(+), 2 deletions(-)
diff --git a/arch/aarch64/boot.S b/arch/aarch64/boot.S
index 908764a..def9192 100644
--- a/arch/aarch64/boot.S
+++ b/arch/aarch64/boot.S
@@ -24,16 +24,24 @@ ASM_FUNC(_start)
* Boot sequence
* If CurrentEL == EL3, then goto EL3 initialisation and drop to
* lower EL before entering the kernel.
+ * If CurrentEL == EL2 && id_aa64mmfr0_el1.MSA == 0xf, then
+ * If id_aa64mmfr0_el1.MSA_frac == 0x2, then goto
+ * Armv8-R AArch64 initialisation and drop to EL1 before
+ * entering the kernel.
+ * Else, which means VMSA unsupported and cannot boot Linux,
+ * goto err_invalid_arch (dead loop).
* Else, no initialisation and keep the current EL before
* entering the kernel.
*/
mrs x0, CurrentEL
- cmp x0, #CURRENTEL_EL3
- b.eq el3_init
+ cmp x0, #CURRENTEL_EL2
+ bgt el3_init
+ beq el2_init
/*
* We stay in the current EL for entering the kernel
*/
+keep_el:
mov w0, #1
ldr x1, =flag_keep_el
str w0, [x1]
@@ -139,6 +147,85 @@ el3_init:
str w0, [x1]
b el_max_init
+ /*
+ * EL2 Armv8-R AArch64 initialisation
+ */
+el2_init:
+ /* Detect Armv8-R AArch64 */
+ mrs x1, id_aa64mmfr0_el1
+ /*
+ * Check MSA, bits [51:48]:
+ * 0xf means Armv8-R AArch64.
+ * If not 0xf, proceed in Armv8-A EL2.
+ */
+ ubfx x0, x1, #48, #4 // MSA
+ cmp x0, 0xf
+ bne keep_el
+ /*
+ * Check MSA_frac, bits [55:52]:
+ * 0x2 means EL1&0 translation regime also supports VMSAv8-64.
+ */
+ ubfx x0, x1, #52, #4 // MSA_frac
+ cmp x0, 0x2
+ /*
+ * If not 0x2, no VMSA, so cannot boot Linux and dead loop.
+ * Also, since the architecture guarantees that those CPUID
+ * fields never lose features when the value in a field
+ * increases, we use blt to cover it.
+ */
+ blt err_invalid_arch
+
+ mrs x0, midr_el1
+ msr vpidr_el2, x0
+
+ mrs x0, mpidr_el1
+ msr vmpidr_el2, x0
+
+ mov x0, #(1 << 31) // VTCR_MSA: VMSAv8-64 support
+ msr vtcr_el2, x0
+
+ /* Init HCR_EL2 */
+ mov x0, #(1 << 31) // RES1: Armv8-R aarch64 only
+
+ mrs x1, id_aa64pfr0_el1
+ ubfx x2, x1, #56, 4 // ID_AA64PFR0_EL1.CSV2
+ cmp x2, 0x2
+ b.lt 1f
+ /*
+ * Disable trap when accessing SCTXNUM_EL0 or SCTXNUM_EL1
+ * if FEAT_CSV2.
+ */
+ orr x0, x0, #(1 << 53) // HCR_EL2.EnSCXT
+
+1: ubfx x2, x1, #28, 4 // ID_AA64PFR0_EL1.RAS
+ cmp x2, 0x2
+ b.lt 1f
+ /* Disable trap when accessing ERXPFGCDN_EL1 if FEAT_RASv1p1. */
+ orr x0, x0, #(1 << 47) // HCR_EL2.FIEN
+
+ /* Enable pointer authentication if present */
+1: mrs x1, id_aa64isar1_el1
+ /*
+ * If ID_AA64ISAR1_EL1.{GPI, GPA, API, APA} == {0000, 0000, 0000, 0000}
+ * then HCR_EL2.APK and HCR_EL2.API are RES 0.
+ * Else
+ * set HCR_EL2.APK and HCR_EL2.API.
+ */
+ ldr x2, =(((0xff) << 24) | (0xff << 4))
+ and x1, x1, x2
+ cbz x1, 1f
+
+ orr x0, x0, #(1 << 40) // HCR_EL2.APK
+ orr x0, x0, #(1 << 41) // HCR_EL2.API
+
+1: msr hcr_el2, x0
+ isb
+
+ mov w0, #SPSR_KERNEL_EL1
+ ldr x1, =spsr_to_elx
+ str w0, [x1]
+ // fall through
+
el_max_init:
ldr x0, =COUNTER_FREQ
msr cntfrq_el0, x0
@@ -148,6 +235,7 @@ el_max_init:
b start_el_max
err_invalid_id:
+err_invalid_arch:
b .
/*
diff --git a/arch/aarch64/include/asm/cpu.h b/arch/aarch64/include/asm/cpu.h
index b1003f4..91f803c 100644
--- a/arch/aarch64/include/asm/cpu.h
+++ b/arch/aarch64/include/asm/cpu.h
@@ -25,6 +25,7 @@
#define SPSR_I (1 << 7) /* IRQ masked */
#define SPSR_F (1 << 6) /* FIQ masked */
#define SPSR_T (1 << 5) /* Thumb */
+#define SPSR_EL1H (5 << 0) /* EL1 Handler mode */
#define SPSR_EL2H (9 << 0) /* EL2 Handler mode */
#define SPSR_HYP (0x1a << 0) /* M[3:0] = hyp, M[4] = AArch32 */
@@ -43,6 +44,7 @@
#else
#define SCTLR_EL1_KERNEL SCTLR_EL1_RES1
#define SPSR_KERNEL (SPSR_A | SPSR_D | SPSR_I | SPSR_F | SPSR_EL2H)
+#define SPSR_KERNEL_EL1 (SPSR_A | SPSR_D | SPSR_I | SPSR_F | SPSR_EL1H)
#endif
#ifndef __ASSEMBLY__
@@ -1,4 +1,4 @@
From 5120127e5f767b44a087c741a3438cef1e22ed50 Mon Sep 17 00:00:00 2001
From f5a31b4f4ea8daaa0d337d5a2322ddb1912083fc Mon Sep 17 00:00:00 2001
From: Qi Feng <qi.feng@arm.com>
Date: Wed, 26 May 2021 17:52:01 +0800
Subject: [PATCH] Allow --enable-psci to choose between smc and hvc
@@ -28,38 +28,47 @@ To use hvc, use --enable-psci=hvc.
[1]: https://developer.arm.com/documentation/ddi0600/latest/
Issue-Id: SCM-2654
Upstream-Status: Pending
Signed-off-by: Qi Feng <qi.feng@arm.com>
Change-Id: Ib8afabdad2d98bc37371d165bbb6f1f9b88bfc87
Upstream-Status: Pending
Signed-off-by: Huifeng Zhang <Huifeng.Zhang@arm.com>
---
Makefile.am | 2 +-
Makefile.am | 10 +++++-----
configure.ac | 14 +++++++++-----
2 files changed, 10 insertions(+), 6 deletions(-)
2 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index ef6b793..a9ddd16 100644
index f941b07..88a27de 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -47,7 +47,7 @@ BOOTMETHOD := psci.o
OFILES += psci.o
PSCI_NODE := psci { \
compatible = \"arm,psci\"; \
@@ -50,11 +50,11 @@ endif
if PSCI
ARCH_OBJ += psci.o
COMMON_OBJ += psci.o
-PSCI_NODE := psci { \
- compatible = \"arm,psci\"; \
- method = \"smc\"; \
+ method = \"$(PSCI_METHOD)\"; \
cpu_on = <$(PSCI_CPU_ON)>; \
cpu_off = <$(PSCI_CPU_OFF)>; \
- cpu_on = <$(PSCI_CPU_ON)>; \
- cpu_off = <$(PSCI_CPU_OFF)>; \
+PSCI_NODE := psci { \
+ compatible = \"arm,psci\"; \
+ method = \"$(PSCI_METHOD)\"; \
+ cpu_on = <$(PSCI_CPU_ON)>; \
+ cpu_off = <$(PSCI_CPU_OFF)>; \
};
CPU_NODES := $(shell perl -I $(SCRIPT_DIR) $(SCRIPT_DIR)/addpsci.pl $(KERNEL_DTB))
else
diff --git a/configure.ac b/configure.ac
index 6914eb4..9aab4a1 100644
index 9e3b722..53e51be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -83,13 +83,17 @@ AS_IF([test "x$X_IMAGE" != "x"],
# Allow a user to pass --enable-psci
AC_ARG_ENABLE([psci],
AS_HELP_STRING([--enable-psci], [enable the psci boot method]),
- [USE_PSCI=$enableval])
AS_HELP_STRING([--disable-psci], [disable the psci boot method]),
- [USE_PSCI=$enableval], [USE_PSCI="yes"])
-AM_CONDITIONAL([PSCI], [test "x$USE_PSCI" = "xyes"])
-AS_IF([test "x$USE_PSCI" = "xyes"], [], [USE_PSCI=no])
-
@@ -68,7 +77,7 @@ index 6914eb4..9aab4a1 100644
+ yes|smc) USE_PSCI=smc ;;
+ hvc) USE_PSCI=hvc ;;
+ *) AC_MSG_ERROR([Bad value "${enableval}" for --enable-psci. Use "smc" or "hvc"]) ;;
+ esac])
+ esac], [USE_PSCI="yes"])
+AM_CONDITIONAL([PSCI], [test "x$USE_PSCI" = "xyes" -o "x$USE_PSCI" = "xsmc" -o "x$USE_PSCI" = "xhvc"])
+
+AS_IF([test "x$USE_PSCI" = "xno" -a "x$KERNEL_ES" = "x32"],
@@ -78,6 +87,3 @@ index 6914eb4..9aab4a1 100644
# Allow a user to pass --with-initrd
AC_ARG_WITH([initrd],
--
2.32.0
@@ -0,0 +1,48 @@
From 3f4614e02f0f8d2522510578da2752f8e3511bb3 Mon Sep 17 00:00:00 2001
From: Jaxson Han <jaxson.han@arm.com>
Date: Mon, 25 Oct 2021 17:09:13 +0800
Subject: [PATCH] aarch64: Disable CNTPCT_EL0 trap for v8-R64
To allow EL1 to access CNTPCT_EL0 without traping into EL2, we need to
set CNTHCTL_EL2.EL1PCTEN to 1.
For v8-R64, the CNTHCTL_EL2 register follows the v8-A architecture.
However, as described in the v8-A architecture profile, the
CNTHCTL_EL2's bit assignments are different according to whether the
FEAT_VHE is implemented.
Since v8-R64 does not support FEAT_VHE, we do not need to detect
FEAT_VHE. We can simply set CNTHCTL_EL2.EL1PCTEN to 1.
Issue-ID: SCM-3508
Upstream-Status: Inappropriate [other]
Temporary patch
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
Change-Id: I4147e66341c8153312021e6f2ab67d0037246da1
---
arch/aarch64/boot.S | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/arch/aarch64/boot.S b/arch/aarch64/boot.S
index def9192..6dbd5cc 100644
--- a/arch/aarch64/boot.S
+++ b/arch/aarch64/boot.S
@@ -219,6 +219,18 @@ el2_init:
orr x0, x0, #(1 << 41) // HCR_EL2.API
1: msr hcr_el2, x0
+
+ /*
+ * To disable trap when accessing CNTPCT_EL0, we need to set
+ * CNTHCTL_EL2.EL1PCTEN to 1. However, the CNTHCTL_EL2 bit assignments
+ * are different according to whether the FEAT_VHE is implemented.
+ *
+ * For Armv8-R AArch64, FEAT_VHE is not supported, so we do not need to
+ * detect FEAT_VHE(ID_AA64MMFR1_EL1.VH) and simply set
+ * CNTHCTL_EL2.EL1PCTEN to 1.
+ */
+ mov x0, #1 // CNTHCTL_EL2.EL1PCTEN
+ msr cnthctl_el2, x0
isb
mov w0, #SPSR_KERNEL_EL1
@@ -0,0 +1,38 @@
From 2851f0e6c1216894b9498d7b91256bb1ef49e544 Mon Sep 17 00:00:00 2001
From: Jaxson Han <jaxson.han@arm.com>
Date: Tue, 2 Nov 2021 15:10:28 +0800
Subject: [PATCH] lds: Mark the mem range
Add firmware_start and firmware_end, so that we can use them to
calculate the mem range of boot-wrapper and then set the range to
/memreserve/ of dtb.
Issue-ID: SCM-3815
Upstream-Status: Inappropriate [other]
Temporary patch
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
Change-Id: Idc5a2894e193c75381049a0f359b4b2a51c567ee
---
model.lds.S | 2 ++
1 file changed, 2 insertions(+)
diff --git a/model.lds.S b/model.lds.S
index d4e7e13..ab98ddf 100644
--- a/model.lds.S
+++ b/model.lds.S
@@ -64,6 +64,7 @@ SECTIONS
#endif
.boot PHYS_OFFSET: {
+ PROVIDE(firmware_start = .);
*(.init)
*(.text*)
*(.data* .rodata* .bss* COMMON)
@@ -76,6 +77,7 @@ SECTIONS
mbox = .;
QUAD(0x0)
}
+ PROVIDE(firmware_end = .);
ASSERT(etext <= (PHYS_OFFSET + TEXT_LIMIT), ".text overflow!")
}
@@ -0,0 +1,101 @@
From 0f2c7ca446063be6b193fbf870d38c0af19e15c5 Mon Sep 17 00:00:00 2001
From: Jaxson Han <jaxson.han@arm.com>
Date: Tue, 28 Dec 2021 17:28:25 +0800
Subject: [PATCH] common: Add essential libc functions
The libfdt uses some of the libc functions, e.g. memcmp, memmove,
strlen .etc. Add them in lib.c.
The code is copied from TF-A (v2.5) [1] project, which is under the
terms of BSD license. It is the same with boot-wrapper.
[1]: https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git
Issue-Id: SCM-3814
Upstream-Status: Inappropriate [other]
Temporary patch
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
Change-Id: If3b55b00afa8694c7522df989a41e0b38eda1d38
---
common/lib.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 70 insertions(+), 1 deletion(-)
diff --git a/common/lib.c b/common/lib.c
index fcf5f69..0be1c4a 100644
--- a/common/lib.c
+++ b/common/lib.c
@@ -32,4 +32,73 @@ void *memset(void *s, int c, size_t n)
return s;
}
-/* TODO: memmove and memcmp could also be called */
+int memcmp(const void *s1, const void *s2, size_t len)
+{
+ const unsigned char *s = s1;
+ const unsigned char *d = s2;
+ unsigned char sc;
+ unsigned char dc;
+
+ while (len--) {
+ sc = *s++;
+ dc = *d++;
+ if (sc - dc)
+ return (sc - dc);
+ }
+
+ return 0;
+}
+
+void *memmove(void *dst, const void *src, size_t len)
+{
+ if ((size_t)dst - (size_t)src >= len) {
+ /* destination not in source data, so can safely use memcpy */
+ return memcpy(dst, src, len);
+ } else {
+ /* copy backwards... */
+ const char *end = dst;
+ const char *s = (const char *)src + len;
+ char *d = (char *)dst + len;
+ while (d != end)
+ *--d = *--s;
+ }
+ return dst;
+}
+
+void *memchr(const void *src, int c, size_t len)
+{
+ const unsigned char *s = src;
+
+ while (len--) {
+ if (*s == (unsigned char)c)
+ return (void *) s;
+ s++;
+ }
+
+ return NULL;
+}
+
+char *strrchr(const char *p, int ch)
+{
+ char *save;
+ char c;
+
+ c = ch;
+ for (save = NULL;; ++p) {
+ if (*p == c)
+ save = (char *)p;
+ if (*p == '\0')
+ return (save);
+ }
+ /* NOTREACHED */
+}
+
+size_t strlen(const char *s)
+{
+ const char *cursor = s;
+
+ while (*cursor)
+ cursor++;
+
+ return cursor - s;
+}
@@ -0,0 +1,61 @@
From de5d2b6c200ae5dd8113751e58bf7cf5844eec5a Mon Sep 17 00:00:00 2001
From: Jaxson Han <jaxson.han@arm.com>
Date: Tue, 28 Dec 2021 17:42:48 +0800
Subject: [PATCH] Makefile: Add the libfdt to the Makefile system
Add the libfdt into Makefile system. The libfdt uses const value and
thus gcc will enable the stack guard. The stack guard will fail the
compile. Add -fno-stack-protector to fix it.
Issue-Id: SCM-3814
Upstream-Status: Inappropriate [other]
Temporary patch
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
Change-Id: I472bc28cdc5cde3b22461a4b7d7a3752ae382b4b
---
Makefile.am | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 88a27de..5e8668a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -36,6 +36,9 @@ PSCI_CPU_OFF := 0x84000002
COMMON_SRC := common/
COMMON_OBJ := boot.o bakery_lock.o platform.o lib.o
+LIBFDT_SRC := common/libfdt/
+LIBFDT_OBJS := fdt.o fdt_ro.o fdt_rw.o
+
ARCH_OBJ := boot.o stack.o utils.o
if BOOTWRAPPER_32
@@ -125,11 +128,12 @@ CHOSEN_NODE := chosen { \
CPPFLAGS += $(INITRD_FLAGS)
CFLAGS += -I$(top_srcdir)/include/ -I$(top_srcdir)/$(ARCH_SRC)/include/
CFLAGS += -Wall -fomit-frame-pointer
+CFLAGS += -fno-stack-protector
CFLAGS += -ffunction-sections -fdata-sections
CFLAGS += -fno-pic -fno-pie
LDFLAGS += --gc-sections
-OBJ := $(addprefix $(ARCH_SRC),$(ARCH_OBJ)) $(addprefix $(COMMON_SRC),$(COMMON_OBJ))
+OBJ := $(addprefix $(ARCH_SRC),$(ARCH_OBJ)) $(addprefix $(COMMON_SRC),$(COMMON_OBJ)) $(addprefix $(LIBFDT_SRC),$(LIBFDT_OBJS))
# Don't lookup all prerequisites in $(top_srcdir), only the source files. When
# building outside the source tree $(ARCH_SRC) needs to be created.
@@ -150,10 +154,13 @@ $(ARCH_SRC):
$(COMMON_SRC):
$(MKDIR_P) $@
+$(LIBFDT_SRC):
+ $(MKDIR_P) $@
+
%.o: %.S Makefile | $(ARCH_SRC)
$(CC) $(CPPFLAGS) -D__ASSEMBLY__ $(CFLAGS) $(DEFINES) -c -o $@ $<
-%.o: %.c Makefile | $(COMMON_SRC)
+%.o: %.c Makefile | $(COMMON_SRC) $(LIBFDT_SRC)
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c -o $@ $<
model.lds: $(LD_SCRIPT) Makefile
@@ -0,0 +1,67 @@
From 5b8cb5192dbd0332e027e8999c3afe4433983291 Mon Sep 17 00:00:00 2001
From: Jaxson Han <jaxson.han@arm.com>
Date: Wed, 29 Dec 2021 10:50:21 +0800
Subject: [PATCH] platform: Add print_hex func
Refine the print functions, and add a new print_hex func to print hex
numbers.
Issue-Id: SCM-3814
Upstream-Status: Inappropriate [other]
Temporary patch
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
Change-Id: Ic960345d9ef0b41d81d30c4a4dbd9c31139907c4
---
common/platform.c | 33 +++++++++++++++++++++++++--------
1 file changed, 25 insertions(+), 8 deletions(-)
diff --git a/common/platform.c b/common/platform.c
index d11f568..8269392 100644
--- a/common/platform.c
+++ b/common/platform.c
@@ -30,20 +30,37 @@
#define V2M_SYS(reg) ((void *)SYSREGS_BASE + V2M_SYS_##reg)
#endif
-static void print_string(const char *str)
+static void print_char(const char c)
{
uint32_t flags;
+ do {
+ flags = raw_readl(PL011(UARTFR));
+ } while (flags & PL011_UARTFR_FIFO_FULL);
+ raw_writel(c, PL011(UARTDR));
+
+ do {
+ flags = raw_readl(PL011(UARTFR));
+ } while (flags & PL011_UARTFR_BUSY);
+}
+
+void print_string(const char *str)
+{
while (*str) {
- do
- flags = raw_readl(PL011(UARTFR));
- while (flags & PL011_UARTFR_FIFO_FULL);
+ print_char(*str++);
+ }
+}
- raw_writel(*str++, PL011(UARTDR));
+#define HEX_CHARS_PER_INT (2 * sizeof(int))
+
+void print_hex(unsigned int val)
+{
- do
- flags = raw_readl(PL011(UARTFR));
- while (flags & PL011_UARTFR_BUSY);
+ const char hex_chars[16] = "0123456789abcdef";
+ int i;
+ for (i = HEX_CHARS_PER_INT - 1; i >= 0; i--) {
+ int v = (val >> (4 * i)) & 0xf;
+ print_char(hex_chars[v]);
}
}
@@ -0,0 +1,96 @@
From b447242cd2457bec20d47fe6a8a5758d97a3bde3 Mon Sep 17 00:00:00 2001
From: Jaxson Han <jaxson.han@arm.com>
Date: Wed, 19 Jan 2022 16:19:02 +0800
Subject: [PATCH] common: Add mem usage to /memreserve/
Set /memreserve/ to prevent next boot stages from overrding PSCI
services with libfdt.
Issue-Id: SCM-3815
Upstream-Status: Inappropriate [other]
Temporary patch
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
Change-Id: I2ea80cdf736a910fa2c3deb622e21d50f04be960
---
Makefile.am | 2 +-
common/boot.c | 1 +
common/device_tree.c | 34 ++++++++++++++++++++++++++++++++++
include/boot.h | 1 +
4 files changed, 37 insertions(+), 1 deletion(-)
create mode 100644 common/device_tree.c
diff --git a/Makefile.am b/Makefile.am
index 5e8668a..734de92 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -34,7 +34,7 @@ endif
PSCI_CPU_OFF := 0x84000002
COMMON_SRC := common/
-COMMON_OBJ := boot.o bakery_lock.o platform.o lib.o
+COMMON_OBJ := boot.o bakery_lock.o platform.o lib.o device_tree.o
LIBFDT_SRC := common/libfdt/
LIBFDT_OBJS := fdt.o fdt_ro.o fdt_rw.o
diff --git a/common/boot.c b/common/boot.c
index c74d34c..ee2bea0 100644
--- a/common/boot.c
+++ b/common/boot.c
@@ -63,6 +63,7 @@ void __noreturn first_spin(unsigned int cpu, unsigned long *mbox,
{
if (cpu == 0) {
init_platform();
+ dt_add_memreserve();
*mbox = (unsigned long)&entrypoint;
sevl();
diff --git a/common/device_tree.c b/common/device_tree.c
new file mode 100644
index 0000000..4d0876c
--- /dev/null
+++ b/common/device_tree.c
@@ -0,0 +1,34 @@
+/*
+ * device_tree.c - Basic device tree node handler
+ *
+ * Copyright (C) 2021 ARM Limited. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE.txt file.
+ */
+#include <libfdt.h>
+
+extern unsigned long dtb;
+extern char firmware_start[], firmware_end[];
+
+extern void print_string(const char *str);
+
+static void *blob;
+
+
+void dt_add_memreserve(void)
+{
+ int ret;
+
+ blob = (void*)&dtb;
+ print_string("Add /memreserve/\n\r");
+
+ fdt_open_into(blob, blob, fdt_totalsize(blob) +
+ sizeof(struct fdt_reserve_entry));
+ ret = fdt_add_mem_rsv(blob, (uint64_t)firmware_start,
+ (uint64_t)(firmware_end - firmware_start));
+
+ if(ret < 0) {
+ print_string("reserve mem add err\n\r");
+ }
+}
diff --git a/include/boot.h b/include/boot.h
index d75e013..c3e2ec1 100644
--- a/include/boot.h
+++ b/include/boot.h
@@ -16,4 +16,5 @@ void __noreturn spin(unsigned long *mbox, unsigned long invalid, int is_entry);
void __noreturn first_spin(unsigned int cpu, unsigned long *mbox,
unsigned long invalid_addr);
+void dt_add_memreserve(void);
#endif
@@ -0,0 +1,102 @@
From 8271c21bcff260295203214b7b8c87cdb8236453 Mon Sep 17 00:00:00 2001
From: Jaxson Han <jaxson.han@arm.com>
Date: Tue, 4 Jan 2022 17:01:55 +0800
Subject: [PATCH] boot: Add the --enable-keep-el compile option
Add --enable-keep-el compile option to enable boot-wrapper booting next
stage at EL2.
The Armv8R AArch64 boots at EL2. If the next stage requires EL2 booting,
the boot-wrapper should not drop to EL1.
Currently, this option only works for Armv8R AArch64. Also, to work with
Linux PSCI, this option will cause secondary cores booting at EL1.
Issue-Id: SCM-3813
Upstream-Status: Inappropriate [other]
Temporary patch
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
Change-Id: I3ba9c87cf0b59d163ca433f74c9e3a46e5ca2c63
---
Makefile.am | 4 ++++
arch/aarch64/boot.S | 6 +++++-
common/psci.c | 6 ++++++
configure.ac | 5 +++++
4 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am
index 734de92..054becd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -33,6 +33,10 @@ PSCI_CPU_ON := 0xc4000003
endif
PSCI_CPU_OFF := 0x84000002
+if KEEP_EL
+DEFINES += -DKEEP_EL
+endif
+
COMMON_SRC := common/
COMMON_OBJ := boot.o bakery_lock.o platform.o lib.o device_tree.o
diff --git a/arch/aarch64/boot.S b/arch/aarch64/boot.S
index 6dbd5cc..157c097 100644
--- a/arch/aarch64/boot.S
+++ b/arch/aarch64/boot.S
@@ -233,7 +233,11 @@ el2_init:
msr cnthctl_el2, x0
isb
+#ifdef KEEP_EL
+ mov w0, #SPSR_KERNEL
+#else
mov w0, #SPSR_KERNEL_EL1
+#endif
ldr x1, =spsr_to_elx
str w0, [x1]
// fall through
@@ -313,5 +317,5 @@ ASM_FUNC(jump_kernel)
.align 3
flag_keep_el:
.long 0
-spsr_to_elx:
+ASM_DATA(spsr_to_elx)
.long 0
diff --git a/common/psci.c b/common/psci.c
index a0e8700..945780b 100644
--- a/common/psci.c
+++ b/common/psci.c
@@ -18,6 +18,8 @@
#error "No MPIDRs provided"
#endif
+extern unsigned int spsr_to_elx;
+
static unsigned long branch_table[NR_CPUS];
bakery_ticket_t branch_table_lock[NR_CPUS];
@@ -44,6 +46,10 @@ static int psci_cpu_on(unsigned long target_mpidr, unsigned long address)
ret = psci_store_address(cpu, address);
bakery_unlock(branch_table_lock, this_cpu);
+#ifdef KEEP_EL
+ spsr_to_elx = SPSR_KERNEL_EL1;
+#endif
+
return ret;
}
diff --git a/configure.ac b/configure.ac
index 53e51be..0e07db3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,6 +25,11 @@ AS_IF([test "x$BOOTWRAPPER_ES" = x32 -a "x$KERNEL_ES" != x32],
[AC_MSG_ERROR([a 32-bit boot-wrapper cannot launch a 64-bit kernel])]
)
+AC_ARG_ENABLE([keep-el],
+ AC_HELP_STRING([--enable-keep-el], [keep exception level when start kernel]),
+ [KEEP_EL=yes], [KEEP_EL=no])
+AM_CONDITIONAL([KEEP_EL], [test "x$KEEP_EL" = xyes])
+
# Allow a user to pass --with-kernel-dir
AC_ARG_WITH([kernel-dir],
AS_HELP_STRING([--with-kernel-dir], [specify the root Linux kernel build directory (required)]),
@@ -0,0 +1,34 @@
From dd3e3f414d0e6ed1643c2e2ccac676b7fc1dc7a9 Mon Sep 17 00:00:00 2001
From: Peter Hoyes <Peter.Hoyes@arm.com>
Date: Tue, 1 Feb 2022 11:28:46 +0000
Subject: [PATCH] Makefile: Change COUNTER_FREQ to 100 MHz
Older Arm Fast Models (AEM < RevC) had a base frequency of 24 MHz. but
the RevC base models use 100 MHz. There is not a robust method of
determining the configured base frequency at runtime, so update
COUNTER_FREQ to be 100 MHz.
Issue-Id: SCM-3871
Upstream-Status: Pending
Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
Change-Id: Ia9ad0f8ee488d1a887791f1fa1d8f3bf9c5887fd
---
Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am
index 40bc5d6..b48173c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,7 +13,7 @@ SCRIPT_DIR := $(top_srcdir)/scripts
PHYS_OFFSET := $(shell perl -I $(SCRIPT_DIR) $(SCRIPT_DIR)/findmem.pl $(KERNEL_DTB))
UART_BASE := $(shell perl -I $(SCRIPT_DIR) $(SCRIPT_DIR)/findbase.pl $(KERNEL_DTB) 0 'arm,pl011')
SYSREGS_BASE := $(shell perl -I $(SCRIPT_DIR) $(SCRIPT_DIR)/findbase.pl $(KERNEL_DTB) 0 'arm,vexpress-sysreg' 2> /dev/null)
-COUNTER_FREQ := 24000000
+COUNTER_FREQ := 100000000
CPU_IDS := $(shell perl -I $(SCRIPT_DIR) $(SCRIPT_DIR)/findcpuids.pl $(KERNEL_DTB))
NR_CPUS := $(shell echo $(CPU_IDS) | tr ',' ' ' | wc -w)
--
2.25.1
@@ -0,0 +1,52 @@
# 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:"
SRCREV_tfa = "cf89fd57ed3286d7842eef41cd72a3977eb6d317"
PV = "2.6+git${SRCPV}"
SRC_URI:remove = " \
file://ssl.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,45 @@
# 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}"
EXTRA_OECMAKE += "-DCC312_LEGACY_DRIVER_API_ENABLED=OFF"
SRCBRANCH_tfm = "master"
SRCREV_tfm = "f8c7e5361b92b16108165601ea81c5d01feb3c22"
SRCREV_mbedtls = "d65aeb37349ad1a50e0f6c9b694d4b5290d60e49"
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() {
install -D -p -m 0644 ${B}/install/outputs/tfm_s_signed.bin ${D}/firmware/tfm_s_signed.bin
install -D -p -m 0644 ${B}/install/outputs/bl2_signed.bin ${D}/firmware/bl2_signed.bin
install -D -p -m 0644 ${B}/install/outputs/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

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