diff options
author | Patrick Williams <patrick@stwcx.xyz> | 2023-08-11 17:48:11 +0300 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2023-08-12 18:32:43 +0300 |
commit | 2a25492c13e2b768f94b864a51f84e82e4238aef (patch) | |
tree | 64102f707447c221fc7b27788cbed43052ed22a5 /meta-arm | |
parent | 6fddef299932b1270a799e78566e25daa911f742 (diff) | |
download | openbmc-2a25492c13e2b768f94b864a51f84e82e4238aef.tar.xz |
subtree updates
meta-openembedded: 0e3f5e5201..491b7592f4:
Alexander Kanavin (1):
libadwaita: move recipe to oe-core
Andrej Valek (1):
cve_check: convert CVE_CHECK_IGNORE to CVE_STATUS
Archana Polampalli (1):
yasm: fix CVE-2023-31975
Chase Qi (1):
meta-python: add python3-telnetlib3 package
Chen Qi (3):
iperf3: remove incorrect CVE_PRODUCT setting
open-vm-tools: add CVE_PRODUCT
grpc: fix CVE-2023-32732
Chi Xu (1):
lapack: Add ptest support
Chris Dimich (1):
image_types_sparse: Fix syntax error
Christian Hohnstaedt (1):
android-tools: fix QA warning about buildpaths
Christophe Vu-Brugier (2):
libnvme: add recipe
nvme-cli: upgrade 1.13 -> 2.5
Etienne Cordonnier (1):
uutils-coreutils: upgrade 0.0.19 -> 0.0.20
Gianfranco Costamagna (3):
vbxguestdrivers: upgrade 7.0.8 -> 7.0.10
dlt-daemon: Add patch to fix build with googletest 1.13
gpsd: make sure gps-utils-python runtime-depends on python3-pyserial
JD Schroeder (2):
radvd: Fix groupname gid change warning
cyrus-sasl: Fix groupname gid change warning
Jan Vermaete (1):
openh264: version bump 2.1.1 -> 2.3.1
Jasper Orschulko (1):
yaml-cpp: Fix cmake export
Khem Raj (9):
openwsman: Link with -lm to get floor() definition
portaudio-v19: Update to latest tip of trunk
python3-pyaudio: Fix cross builds
poco: Fix ptests
pcmciautils: Pass LD=CC via Make cmdline
ply: Pass LD via environment to configure
sip: upgrade 6.7.10 -> 6.7.11
nodejs: Upgrade to 18.17.0
python3-m2crypto: Remove __pycache__ files
Marek Vasut (1):
libiio: update to version 0.25
Markus Volk (9):
pipewire: update 0.3.73 -> 0.3.75
libcamera: update 0.0.5 -> 0.1.0
webkitgtk3: add recipe
geary: update 43.0 -> 44.0
webkitgtk3: upgrade 2.40.2 -> 2.40.5
fuse3: update 3.14.1 -> 3.15.1
pipewire: update 0.3.75 -> 0.3.77
pipewire: add support for liblc3
gnome-software: update 44.3 -> 44.4
Martin Jansa (4):
libtommath: add recipe for LibTomMath used by dropbear
libtomcrypt: backport a fix for CVE-2019-17362
libtomcrypt: add PACKAGECONFIG for ltm enabled by default
dlm: Do not use -fcf-protection=full on aarch64 platforms
Michael Opdenacker (7):
remove unused AUTHOR variable
remove unused AUTHOR variable
remove unused AUTHOR variable
remove unused AUTHOR variable
remove unused AUTHOR variable
remove unused AUTHOR variable
meta-python: Remove unused AUTHOR variable
Mingli Yu (2):
dracut: Remove busybox from RRECOMMENDS
mariadb: Upgrade to 10.11.4
Nicolas Marguet (2):
rsyslog: update from 8.2302.0 to 8.2306.0
rsyslog: Fix function inline errors in debug optimization
Peter Marko (1):
cve_check: fix conversion errors
Ramon Fried (1):
bitwise: Upgrade 0.43 -> 0.50
Ross Burton (1):
cherokee: add CVE_PRODUCT
Tim Orling (1):
libmodule-build-tiny-perl: upgrade 0.045 -> 0.046
Trevor Gamblin (31):
python3-django: upgrade 4.2.2 -> 4.2.3
python3-ipython: upgrade 8.12.0 -> 8.14.0
python3-awesomeversion: upgrade 22.9.0 -> 23.5.0
python3-binwalk: upgrade 2.3.3 -> 2.3.4
python3-bitstring: upgrade 3.1.9 -> 4.0.2
python3-bitstring: add python3-io to RDEPENDS, alphabetize
python3-blinker: upgrade 1.5 -> 1.6.2
python3-blinker: add python3-asyncio to RDEPENDS
python3-execnet: upgrade 1.9.0 -> 2.0.2
python3-flask: upgrade 2.2.3 -> 2.3.2
python3-flask: add python3-blinker to RDEPENDS, alphabetize
python3-greenstalk: upgrade 2.0.0 -> 2.0.2
python3-humanize: upgrade 4.4.0 -> 4.7.0
python3-versioneer: add recipe
python3-parse: upgrade 1.19.0 -> 1.19.1
python3-pandas: upgrade 1.5.3 -> 2.0.3
python3-pyperf: upgrade 2.5.0 -> 2.6.1
python3-rdflib: upgrade 6.2.0 -> 6.3.2
python3-semver: upgrade 2.13.0 -> 3.0.1
python3-send2trash: upgrade 1.8.0 -> 1.8.2
python3-sh: upgrade 1.14.3 -> 2.0.4
python3-snagboot: upgrade 1.0 -> 1.1
python3-werkzeug: upgrade 2.2.3 -> 2.3.6
python3-beautifulsoup4: upgrade 4.11.1 -> 4.12.2
python3-fastjsonschema: upgrade 2.16.3 -> 2.18.0
python3-jsonpatch: upgrade 1.32 -> 1.33
python3-m2crypto: upgrade 0.38.0 -> 0.39.0
python3-matplotlib: upgrade 3.6.3 -> 3.7.2
python3-pyaudio: upgrade 0.2.11 -> 0.2.13
python3-pybind11: upgrade 2.10.3 -> 2.11.1
python3-sqlparse: upgrade 0.4.3 -> 0.4.4
Vivien Didelot (1):
libcamera: bump to latest master
Wang Mingyu (83):
c-periphery: upgrade 2.4.1 -> 2.4.2
ctags: upgrade 6.0.20230611.0 -> 6.0.20230716.0
gensio: upgrade 2.6.6 -> 2.6.7
gnome-commander: upgrade 1.16.0 -> 1.16.1
hiredis: upgrade 1.1.0 -> 1.2.0
iperf3: upgrade 3.13 -> 3.14
iwd: upgrade 2.6 -> 2.7
libbytesize: upgrade 2.8 -> 2.9
libinih: upgrade 56 -> 57
libnftnl: upgrade 1.2.5 -> 1.2.6
lvgl: upgrade 8.3.7 -> 8.3.8
bats: upgrade 1.9.0 -> 1.10.0
function2: upgrade 4.2.2 -> 4.2.3
lmdb: upgrade 0.9.29 -> 0.9.31
redis: upgrade 6.2.12 -> 6.2.13
ser2net: upgrade 4.3.12 -> 4.3.13
python3-obd: upgrade 0.7.1 -> 0.7.2
python3-path: upgrade 16.6.0 -> 16.7.1
nginx: upgrade 1.24.0 -> 1.25.1
php: upgrade 8.2.7 -> 8.2.8
python3-charset-normalizer: upgrade 3.1.0 -> 3.2.0
python3-click: upgrade 8.1.3 -> 8.1.5
python3-dnspython: upgrade 2.3.0 -> 2.4.0
python3-engineio: upgrade 4.4.1 -> 4.5.1
python3-eth-utils: upgrade 2.1.1 -> 2.2.0
python3-frozenlist: upgrade 1.3.3 -> 1.4.0
python3-gevent: upgrade 22.10.2 -> 23.7.0
python3-google-api-python-client: upgrade 2.92.0 -> 2.93.0
python3-google-auth: upgrade 2.21.0 -> 2.22.0
python3-mock: upgrade 5.0.2 -> 5.1.0
python3-platformdirs: upgrade 3.8.0 -> 3.9.1
python3-protobuf: upgrade 4.23.3 -> 4.23.4
python3-pymisp: upgrade 2.4.172 -> 2.4.173
python3-pymongo: upgrade 4.4.0 -> 4.4.1
python3-tox: upgrade 4.6.3 -> 4.6.4
python3-virtualenv: upgrade 20.23.1 -> 20.24.0
python3-zeroconf: upgrade 0.70.0 -> 0.71.0
redis-plus-plus: upgrade 1.3.9 -> 1.3.10
redis: upgrade 7.0.11 -> 7.0.12
smemstat: upgrade 0.02.11 -> 0.02.12
tesseract: upgrade 5.3.1 -> 5.3.2
weechat: upgrade 4.0.1 -> 4.0.2
wireshark: upgrade 4.0.6 -> 4.0.7
xterm: upgrade 383 -> 384
lastlog2: add new recipe
wtmpdb: add new recipe
babeld: upgrade 1.12.2 -> 1.13.1
ctags: upgrade 6.0.20230716.0 -> 6.0.20230730.0
gspell: upgrade 1.12.1 -> 1.12.2
libcompress-raw-bzip2-perl: upgrade 2.204 -> 2.206
libcompress-raw-lzma-perl: upgrade 2.204 -> 2.206
libcompress-raw-zlib-perl: upgrade 2.204 -> 2.206
libio-compress-lzma-perl: upgrade 2.204 -> 2.206
libio-compress-perl: upgrade 2.204 -> 2.206
libqb: upgrade 2.0.7 -> 2.0.8
logcheck: upgrade 1.4.2 -> 1.4.3
mdio-tools,mdio-netlink: Upgrade recipes to 1.3.0
python3-dill: upgrade 0.3.6 -> 0.3.7
python3-gunicorn: upgrade 20.1.0 -> 21.2.0
python3-web3: upgrade 6.3.0 -> 6.7.0
python3-aiohttp: upgrade 3.8.4 -> 3.8.5
python3-bitarray: upgrade 2.7.6 -> 2.8.0
python3-click: upgrade 8.1.5 -> 8.1.6
python3-cmake: upgrade 3.26.4 -> 3.27.0
python3-configargparse: upgrade 1.5.5 -> 1.7
python3-cytoolz: upgrade 0.12.1 -> 0.12.2
python3-dnspython: upgrade 2.4.0 -> 2.4.1
python3-elementpath: upgrade 4.1.4 -> 4.1.5
python3-flask-socketio: upgrade 5.3.4 -> 5.3.5
python3-gnupg: upgrade 0.5.0 -> 0.5.1
python3-google-api-python-client: upgrade 2.93.0 -> 2.95.0
python3-grpcio: upgrade 1.56.0 -> 1.56.2
python3-jedi: upgrade 0.18.2 -> 0.19.0
python3-marshmallow: upgrade 3.19.0 -> 3.20.1
python3-portion: upgrade 2.4.0 -> 2.4.1
python3-pymodbus: upgrade 3.3.2 -> 3.4.1
python3-robotframework: upgrade 6.1 -> 6.1.1
python3-tomlkit: upgrade 0.11.8 -> 0.12.1
python3-typeguard: upgrade 4.0.0 -> 4.1.0
python3-virtualenv: upgrade 20.24.0 -> 20.24.2
python3-zeroconf: upgrade 0.71.0 -> 0.71.4
rdma-core: upgrade 46.0 -> 47.0
sip: upgrade 6.7.9 -> 6.7.10
Willy Tu (1):
mstpd: Add initial recipe for mstpd
Yi Zhao (4):
samba: upgrade 4.18.4 -> 4.18.5
libnfnetlink: enable native build
libnetfilter-queue: enable native build
daq: enable nfq module build
meta-raspberrypi: e3f733cadd..5e2f79a6fa:
Jan Vermaete (2):
kas-poky-rpi.yml: renamed ABORT to HALT
rpi-base.inc: add the disable-wifi overlay
Khem Raj (1):
rpi-base: Remove customizing SPLASH var
Martin Jansa (1):
libcamera: update PACKAGECONFIG for libcamera-0.1.0
Vincent Davis Jr (1):
rpidistro-vlc: fix error uint64_t does not name
Vivien Didelot (10):
rpi-libcamera-apps: fix Illegal Instruction
rpi-libcamera-apps: add opencv build dependency
rpi-libcamera-apps: add drm support
rpi-libcamera-apps: replace tensorflow config
rpi-libcamera-apps: don't force COMPATIBLE_MACHINE
rpi-libcamera-apps: rename to libcamera-apps
libcamera-apps: move recipe to dynamic-layers
libcamera-apps: bump to 3d9ac10
libcamera-apps: switch from CMake to meson
libcamera-apps: bump to latest main
meta-arm: b4d50a273d..992c07f7c0:
Abdellatif El Khlifi (2):
arm-bsp/trusted-firmware-a: corstone1000: psci: SMCCC_ARCH_FEATURES discovery through PSCI_FEATURES
arm-bsp/u-boot: corstone1000: upgrade to v2023.07
Adam Johnston (1):
arm-bsp/trusted-firmware-a: Reserve OP-TEE memory from NWd on N1SDP
Emekcan Aras (1):
arm-bsp/u-boot: corstone1000: increase the kernel size
Jon Mason (9):
CI: add defaults for get-binary-toolchains
CI: workaround 32bit timer warning in binary toolchain
arm-bsp/corstone1000: update u-boot preferred version
arm-toolchain/gcc-aarch64-none-elf: upgrade to 12.3.rel1
arm/edk2: move 202211 recipe to meta-arm-bsp
arm-bsp: clean-up patch noise
arm/optee-test: update musl workaround patch
arm-bsp/tc1: remove trusted-firmware-m target
arm/trusted-firmware-m: upgrade to v1.8.0
Robbie Cao (1):
arm/recipes-kernel: Add preempt-rt support for generic-arm64
Ross Burton (5):
arm-toolchain/androidclang: remove
arm-toolchain/arm-binary-toolchain: install to a versioned directory
arm-toolchain/gcc-arm-none-eabi-11.2: add new recipe
arm/trusted-firmware-m: explicitly use Arm GCC 11.2
arm-toolchain/gcc-arm-none-eabi: upgrade to 12.3.rel1
Ziad Elhanafy (1):
arm/recipes-devtools,doc: Update FVP version
poky: b398c7653e..71282bbc53:
Alex Kiernan (3):
base-passwd: Add the sgx group
udev: eudev: Revert add group to sgx
poky/poky-tiny: Explicitly exclude `shadow`
Alexander Kanavin (25):
meta: add missing summaries for image recipes
insane.bbclass: add do_recipe_qa task
devtool: do not run recipe_qa task when extracting source
insane.bbclass: add a SUMMARY/HOMEPAGE check (oe-core recipes only)
insane.bbclass: add a RECIPE_MAINTAINER check (oe-core recipes only)
librsvg: fix upstream version check
acpica: tarball and homepage relocated to intel.com
gnu-efi: upgrade 3.0.15 -> 3.0.17
gettext-minimal-native: obtain the needed files directly from gettext source tarball
kbd: upgrade 2.6.0 -> 2.6.1
systemd: upgrade 253.3 -> 253.7
jquery: upgrade 3.6.3 -> 3.7.0
strace: upgrade 6.3 -> 6.4
sudo: update 1.9.13p3 -> 1.9.14p2
libadwaita: add recipe from meta-gnome
epiphany: upgrade 43.1 -> 44.5
glibc-locale: use stricter matching for metapackages' runtime dependencies
uninative-tarball: install the full set of gconv modules
buildtools-extended-tarball: install the full set of gconv modules
procps: address failure with gettext 0.22
util-linux: upgrade 2.38.1 -> 2.39.1
ref-manual: document image-specific variant of INCOMPATIBLE_LICENSE
devtool/upgrade: raise an error if extracting source produces more than one directory
scripts/lib/scriptutils.py: add recipe_qa artifacts to exclusion list in filter_src_subdirs()
curl: ensure all ptest failures are caught
Alexandre Belloni (2):
base-files: bump PR because conf files are now sorted
wic: bootimg-efi: Stop hardcoding VMA offsets
Alexis Lothoré (3):
scripts/resulttool: add mention about new detected tests
scripts/resulttool: allow to replace test raw status with custom string
scripts/resulttool: define custom string for "not found" test results
Andrej Valek (2):
maintainers.inc: Modify email address
ref-manual: document CVE_STATUS and CVE_CHECK_STATUSMAP
Anuj Mittal (4):
glibc/check-test-wrapper: don't emit warnings from ssh
selftest/cases/glibc.py: increase the memory for testing
oeqa/utils/nfs: allow requesting non-udp ports
selftest/cases/glibc.py: switch to using NFS over TCP
BELOUARGA Mohamed (3):
linux-firmware : Add firmware of RTL8822 serie
bitbake: bitbake: fetch2/npmsw: Check if there are dependencies before trying to fetch them
bitbake: fetch2: Check if path is 'None' before calculating checksums
Bruce Ashfield (11):
kernel: make LOCALVERSION consistent between recipes
linux-yocto/6.4: fix CONFIG_LEDS_TRIGGER_GPIO kernel audit warning
linux-yocto/6.4: update to v6.4.6
linux-yocto/6.1: update to v6.1.41
linux-yocto/6.4: update to v6.4.7
linux-yocto-dev: bump to v6.5+
linux-yocto/6.4: update to v6.4.8
linux-yocto/6.1: update to v6.1.43
linux-yocto/6.4: update to v6.4.9
linux-yocto/6.4: fix qemuarm boot failure
linux-yocto-tiny/6.4: fix HID configuration warning
Chen Qi (4):
ncurses: fix CVE-2023-29491
multilib.conf: explicitly make MULTILIB_VARIANTS vardeps on MULTILIBS
gcc-crosssdk: ignore MULTILIB_VARIANTS in signature computation
openssh: sync with upstream's default
Christopher Larson (6):
bitbake: tests.data: add test for inline python calling a def'd function
bitbake: tests.codeparser: add test for exec of builtin from inline python
bitbake: data_smart: check for python builtins directly for context lookup
bitbake: tests.data: add test for builtin preferred over metadata value
bitbake: data_smart: directly check for methodpool functions in context lookup
bitbake: bb.tests.data: don't require the func flag for context functions
Denis OSTERLAND-HEIM (1):
kernel-fitImage: add machine compatible to config section
Dit Kozmaj (1):
bitbake: fetch2: Set maxsplit to match expected variables
Dmitry Baryshkov (5):
kmscube: bump SRCREV to get offscreen rendering to work
linux-firmware: package firmare for Dragonboard 410c
mesa: simplify overriding GALLIUMDRIVERS_LLVM
mesa: enable swrast Vulkan driver if LLVM drivers are enabled
linux-firmware: split platform-specific Adreno shaders to separate packages
Frederic Martinsons (4):
ptest-cargo.bbclass: Support of cargo workspaces
cargo.bbclass: Use --frozen flag for cargo operations
cargo_common.bbclass: Handle Cargo.lock modifications for git dependencies
rust-hello-world: Drop recipe
Jean-Marie Lemetayer (1):
package: always sort the conffiles
Joel Stanley (1):
kernel: don't fail if Modules.symvers doesn't exist
Jose Quaresma (1):
systemd: fix efi stubs
Joshua Watt (1):
bitbake: contrib: vim: Fix up a few errors when reloading
Julien Stephan (1):
libexif: add ptest support
Khem Raj (16):
nfs-utils: Fix host path contamination building locktest
ltp: Use bfd linker when lld is distro linker default
ffmpeg: Use bfd linker on i386 when lld is distro linker default
ltp: Use bfd linker for KVM_LD as well when ld-is-lld
autoconf: Backport upstreamed patches
Revert "site: merged common-glibc from OE"
x32-linux: Do not cache ac_cv_sys_file_offset_bits
gcc: Upgrade to 13.2 release
gnu-efi: Fix build break on riscv64
ffmpeg: Fix wrong code found with gas/2.41
systemd: Point to target binary paths for loadkeys and setfont
systemd: Make 254 work on musl
musl: Upgrade to tip of trunk
binutils: Upgrade to 2.41 release
systemd-boot: Ensure EFI_LD is also passed to compiler driver
pm-utils: Do not require GNU grep at runtime
Lee Chee Yang (2):
migration-guides: add release notes for 4.0.11
migration-guides: add release notes for 4.2.2
Luca Boccassi (2):
systemd: update to v254
systemd: add usrmerge to REQUIRED_DISTRO_FEATURES
Marek Vasut (1):
linux-firmware: Fix mediatek mt7601u firmware path
Mark Hatle (1):
tcf-agent: Update to 1.8.0 release
Markus Volk (4):
gcr3: remove recipe
systemd: add a packageconfig to support colored logs
webkitgtk: upgrade 2.40.2 -> 2.40.5
epiphany: upgrade 44.5 -> 44.6
Martin Jansa (3):
patchelf: add 3 fixes to optimize and fix uninative
alsa-utils: backport a fix to build with glibc-2.38
efivar: drop -fuse-ld=bfd
Michael Halstead (1):
yocto-uninative: Update hashes for uninative 4.1
Michael Opdenacker (4):
ref-manual: releases.svg: updates
ref-manual: LTS releases now supported for 4 years
poky.conf: update SANITY_TESTED_DISTROS to match autobuilder
recipes: remove unused AUTHOR variable
Oleksandr Hnatiuk (2):
file: return wrapper to fix builds when file is in buildtools-tarball
file: fix the way path is written to environment-setup.d
Ovidiu Panait (2):
mdadm: add util-linux-blockdev ptest dependency
mdadm: save ptest logs
Peter Marko (4):
cve-extra-exclusions: fix syntax error
libarchive: ignore CVE-2023-30571
cve-exclusion_6.1: correct typo in exclusion list name
bluez5: correct CVE status of ignored CVEs
Peter Suti (1):
externalsrc: fix dependency chain issues
Quentin Schulz (1):
docs: sdk-manual: appendix-obtain: fix literal block content
Richard Purdie (21):
createrepo-c: Fix 32 bit architecture segfaults with 64 bit time
build-appliance-image: Update to master head revision
oeqa/target/ssh: Ensure EAGAIN doesn't truncate output
createrepo-c: Update patch status
oeqa/runtime/ltp: Increase ltp test output timeout
oeqa/ltp: Show warning for non-zero exit codes
ltp: Add kernel loopback module dependency
target/ssh: Ensure exit code set for commands
autoconf: Upgrade to 2.72c
oeqa/ssh: Further improve process exit handling
oeqa/selftest/rust: Round test execution time to integer
qemuboot/runqemu: Fix 6.2 and later kernel network device naming
bitbake: siggen: Improve runtaskdeps data to fix sstate debugging
sstatesig: Update to match bitbake changes to runtaskdeps
Revert "kea: upgrade to v2.5.0"
selftest/reproducible: Update config to match ongoing changes
gnupg: Fix reproducibility failure
selftest: Ensure usrmerge is enabled with systemd
conf/init-mamager-systemd: Add usrmerge to DISTRO_FEATURES
bitbake.conf: Drop PE and PR from WORKDIR and STAMP
qemuboot: Update hardcoded path to match new layout
Robert Joslyn (2):
curl: Update from 8.1.2 to 8.2.0
curl: Refine ptest perl RDEPENDS
Ross Burton (8):
systemd: set correct paths for kdb binaries
systemd: depend on util-linux's swapon/off
linux-yocto: add script to generate kernel CVE_STATUS entries
ghostscript: backport fix for CVE-2023-38559
ghostscript: ignore CVE-2023-38560
openssh: upgrade to 9.3p2
librsvg: upgrade to 2.56.3
linux-yocto: extract generic kernel CVE_STATUS
Sakib Sajal (1):
go: upgrade 1.20.6 -> 1.20.7
Sudip Mukherjee (3):
libgit2: upgrade to v1.7.0
bind: upgrade to v9.18.17
kea: upgrade to v2.5.0
Tim Orling (10):
python3-urllib3: upgrade 2.0.3 -> 2.0.4
python3-hypothesis: upgrade 6.81.2 -> 6.82.0
python3-pyyaml: upgrade 6.0 -> 6.0.1
python_setuptools3_rust: inherit ...build_meta
python3-sphinx: upgrade 7.0.1 -> 7.1.1
python3-certifi: upgrade 2023.5.7 -> 2023.7.22
python3-more-itertools: upgrade 9.1.0 -> 10.0.0
python3-wheel: upgrade 0.40.0 -> 0.41.0
python3-chardet: upgrade 5.1.0 -> 5.2.0
python3-cryptography{-vectors}: upgrade -> 41.0.3
Trevor Gamblin (7):
python3-dtschema: upgrade 2023.4 -> 2023.6.1
python3-dtc: add from meta-virtualization
python3-dtschema: add python3-dtc to RDEPENDS
nfs-utils: upgrade 2.6.2 -> 2.6.3
iproute2: upgrade 6.3.0 -> 6.4.0
git: upgrade 2.39.3 -> 2.41.0
python3: add additional timing-related test skips
Ulrich Ölmann (3):
ref-manual: classes: kernel-fitimage: fix source of imagetype
ref-manual: classes: kernel-fitimage: fix typos
ref-manual: classes: kernel-fitimage: refine role of INITRAMFS_IMAGE_BUNDLE
Yang Xu (2):
oeqa/selftest/ssate: Add test for find_siginfo
bitbake: server/process: fix sig handle
Yash Shinde (5):
rust: Fix BOOTSTRAP_CARGO failure during Rust Oe-selftest
oeqa/selftest/rust: Add failed test cases to exclude list for Rust Oe-selftest
oeqa/selftest/binutils: Add elapsed time for binutils test report.
oeqa/selftest/gcc: Add elapsed time for gcc test report.
oeqa/selftest/glibc: Add elapsed time for glibc test report.
Yoann Congal (1):
bitbake: fetch2/gitsm: Document that we won't support propagating user parameter
meta-security: 405cca4028..b9bc938785:
Armin Kuster (21):
bastille: bastille/config should not be world writeable.
ossec-hids: Fix usermod
python3-flask-script: add package
python3-segno: add new package
python3-privacyidea: fixup REDPENDS
qemu: move qemu setting to image and out of layer.conf
packagegroup-core-security: only include firejail x86-64 and arch64
firejail: only allow x86-64 and arm64 to build
python3-tpm2-pytss: add python tss2 support
packagegroup: add python3-tpm2-pytss
clamav: update SRC_URI
scap-security-guide: refactor patches
packagegroup-security-tpm2: add more pkgs
scap-security-guide: enable ptest
python3-yamlpath: Add new pkg
python3-json2html: add new pkg
python3-json2html: add new pkg
meta-integrity: drop ima.cfg in favor of new k-cache
sshguard: Update to 2.4.3
meta-tpm linux-yocto-rt: Add the bbappend for rt kernel
layer: add QA_WARNINGS to all layers
Kai Kang (2):
openscap: fix buildpaths issue
sssd: 2.7.4 -> 2.9.1
Kevin Hao (1):
linux-yocto-rt: Add the bbappend for rt kernel
Luke Granger-Brown (1):
glome: update to tip
Wurm, Stephan (1):
dm-verity-image-initramfs: Allow compressed image types
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Icf1ba0c270d53f4c3c3838d4305116e5d6f794de
Diffstat (limited to 'meta-arm')
106 files changed, 5162 insertions, 8898 deletions
diff --git a/meta-arm/ci/external-gccarm.yml b/meta-arm/ci/external-gccarm.yml index fe8fa6ca8b..a3313d8921 100644 --- a/meta-arm/ci/external-gccarm.yml +++ b/meta-arm/ci/external-gccarm.yml @@ -6,3 +6,6 @@ local_conf_header: SKIP_RECIPE[gcc-cross-arm] = "Using external toolchain" TCMODE = "external-arm" EXTERNAL_TOOLCHAIN = "${TOPDIR}/toolchains/${TARGET_ARCH}" + # Temporary workaround for a number binaries in the toolchains that are using 32bit timer API + # This must be done here instead of the recipe because of all the libraries in the toolchain have the issue + INSANE_SKIP:append = " 32bit-time" diff --git a/meta-arm/ci/get-binary-toolchains b/meta-arm/ci/get-binary-toolchains index 23c3bbb16b..69a4d38ec0 100755 --- a/meta-arm/ci/get-binary-toolchains +++ b/meta-arm/ci/get-binary-toolchains @@ -5,9 +5,10 @@ BASENAME=arm-gnu-toolchain VER=${VER:-12.2.rel1} HOST_ARCH=${HOST_ARCH:-$(uname -m)} -DOWNLOAD_DIR=$1 -TOOLCHAIN_DIR=$2 -TOOLCHAIN_LINK_DIR=$3 +# Use the standard kas container locations if nothing is passed into the script +DOWNLOAD_DIR="${1:-/builds/persist/downloads/}" +TOOLCHAIN_DIR="${2:-/builds/persist//toolchains/}" +TOOLCHAIN_LINK_DIR="${3:-build/toolchains/}" # These should be already created by .gitlab-ci.yml, but do here if run outside of that env mkdir -p $DOWNLOAD_DIR $TOOLCHAIN_DIR $TOOLCHAIN_LINK_DIR diff --git a/meta-arm/ci/tc1.yml b/meta-arm/ci/tc1.yml index 66c5ab998e..77d67d2f08 100644 --- a/meta-arm/ci/tc1.yml +++ b/meta-arm/ci/tc1.yml @@ -9,4 +9,3 @@ machine: tc1 target: - core-image-minimal - - trusted-firmware-m diff --git a/meta-arm/ci/toolchains.yml b/meta-arm/ci/toolchains.yml index 72ce55823f..9b63bf2850 100644 --- a/meta-arm/ci/toolchains.yml +++ b/meta-arm/ci/toolchains.yml @@ -16,4 +16,5 @@ target: - nativesdk-gcc-aarch64-none-elf - gcc-arm-none-eabi - nativesdk-gcc-arm-none-eabi - - nativesdk-androidclang + - gcc-arm-none-eabi-11.2 + - nativesdk-gcc-arm-none-eabi-11.2 diff --git a/meta-arm/meta-arm-bsp/conf/machine/include/corstone1000.inc b/meta-arm/meta-arm-bsp/conf/machine/include/corstone1000.inc index 8a2e2a0204..aeb1411ab9 100644 --- a/meta-arm/meta-arm-bsp/conf/machine/include/corstone1000.inc +++ b/meta-arm/meta-arm-bsp/conf/machine/include/corstone1000.inc @@ -22,7 +22,7 @@ TFM_SIGN_PRIVATE_KEY = "${libdir}/tfm-scripts/root-RSA-3072_1.pem" RE_IMAGE_OFFSET = "0x1000" # u-boot -PREFERRED_VERSION_u-boot ?= "2023.01" +PREFERRED_VERSION_u-boot ?= "2023.07%" EXTRA_IMAGEDEPENDS += "u-boot" UBOOT_CONFIG ??= "EFI" diff --git a/meta-arm/meta-arm-bsp/documentation/fvp-baser-aemv8r64.md b/meta-arm/meta-arm-bsp/documentation/fvp-baser-aemv8r64.md index 00efed47d8..2635e75d79 100644 --- a/meta-arm/meta-arm-bsp/documentation/fvp-baser-aemv8r64.md +++ b/meta-arm/meta-arm-bsp/documentation/fvp-baser-aemv8r64.md @@ -27,7 +27,7 @@ The fvp-baser-aemv8r64 Yocto MACHINE supports the following BSP components, where either a standard or Real-Time Linux kernel (PREEMPT\_RT) can be built and run: - - FVP_Base_AEMv8R: v11.20.15 + - FVP_Base_AEMv8R: v11.22.14 - boot-wrapper-aarch64: provides PSCI support - U-Boot: v2022.07 - provides UEFI services - Linux kernel: linux-yocto-5.15 diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/corstone1000/0002-feat-corstone1000-bl2-loads-fip-based-on-metadata.patch b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/corstone1000/0002-feat-corstone1000-bl2-loads-fip-based-on-metadata.patch index 3afaa4b03b..d834e95bd7 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/corstone1000/0002-feat-corstone1000-bl2-loads-fip-based-on-metadata.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/corstone1000/0002-feat-corstone1000-bl2-loads-fip-based-on-metadata.patch @@ -16,7 +16,6 @@ image starts at fip partition + fip signature area size. Upstream-Status: Pending Signed-off-by: Mohamed Omar Asaker <mohamed.omarasaker@arm.com> -%% original patch: 0002-feat-corstone1000-bl2-loads-fip-based-on-metadata.patch --- bl2/bl2_main.c | 4 +++ .../corstone1000/common/corstone1000_plat.c | 32 ++++++------------- diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/corstone1000/0003-psci-SMCCC_ARCH_FEATURES-discovery-through-PSCI_FEATURES.patch b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/corstone1000/0003-psci-SMCCC_ARCH_FEATURES-discovery-through-PSCI_FEATURES.patch new file mode 100644 index 0000000000..2a7cd47e1b --- /dev/null +++ b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/corstone1000/0003-psci-SMCCC_ARCH_FEATURES-discovery-through-PSCI_FEATURES.patch @@ -0,0 +1,29 @@ +From 16937460429d6bcd502b21c20d16222541ed8d48 Mon Sep 17 00:00:00 2001 +From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> +Date: Mon, 6 Mar 2023 15:57:59 +0000 +Subject: [PATCH] psci: SMCCC_ARCH_FEATURES discovery through PSCI_FEATURES + +allow normal world use PSCI_FEATURES to discover SMCCC_ARCH_FEATURES + +Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> +Upstream-Status: Inappropriate [A U-Boot patch will be released to fix an issue in the PSCI driver] +--- + lib/psci/psci_main.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/psci/psci_main.c b/lib/psci/psci_main.c +index a631f3ffbf..cc8904b006 100644 +--- a/lib/psci/psci_main.c ++++ b/lib/psci/psci_main.c +@@ -337,7 +337,7 @@ int psci_features(unsigned int psci_fid) + { + unsigned int local_caps = psci_caps; + +- if (psci_fid == SMCCC_VERSION) ++ if (psci_fid == SMCCC_VERSION || psci_fid == SMCCC_ARCH_FEATURES) + return PSCI_E_SUCCESS; + + /* Check if it is a 64 bit function */ +-- +2.25.1 + diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/n1sdp/0001-Reserve-OP-TEE-memory-from-nwd.patch b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/n1sdp/0001-Reserve-OP-TEE-memory-from-nwd.patch new file mode 100644 index 0000000000..2c634e350f --- /dev/null +++ b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/n1sdp/0001-Reserve-OP-TEE-memory-from-nwd.patch @@ -0,0 +1,41 @@ +From 2d305094f8f500362079e9e7637d46129bf980e4 Mon Sep 17 00:00:00 2001 +From: Adam Johnston <adam.johnston@arm.com> +Date: Tue, 25 Jul 2023 16:05:51 +0000 +Subject: [PATCH] n1sdp: Reserve OP-TEE memory from NWd + +The physical memory which is used to run OP-TEE on the N1SDP is known +to the secure world via TOS_FW_CONFIG, but it may not be known to the +normal world. + +As a precaution, explicitly reserve this memory via NT_FW_CONFIG to +prevent the normal world from using it. This is not required on most +platforms as the Trusted OS is run from secure RAM. + +Upstream-Status: Pending (not yet submited to upstream) +Signed-off-by: Adam Johnston <adam.johnston@arm.com> +--- + plat/arm/board/n1sdp/fdts/n1sdp_nt_fw_config.dts | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/plat/arm/board/n1sdp/fdts/n1sdp_nt_fw_config.dts b/plat/arm/board/n1sdp/fdts/n1sdp_nt_fw_config.dts +index da5e04ddb6..b7e2d4e86f 100644 +--- a/plat/arm/board/n1sdp/fdts/n1sdp_nt_fw_config.dts ++++ b/plat/arm/board/n1sdp/fdts/n1sdp_nt_fw_config.dts +@@ -20,4 +20,16 @@ + local-ddr-size = <0x0>; + remote-ddr-size = <0x0>; + }; ++ ++ reserved-memory { ++ #address-cells = <2>; ++ #size-cells = <2>; ++ ranges; ++ ++ optee@0x08000000 { ++ compatible = "removed-dma-pool"; ++ reg = <0x0 0x08000000 0x0 0x02000000>; ++ no-map; ++ }; ++ }; + }; +\ No newline at end of file diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-corstone1000.inc b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-corstone1000.inc index 3a5be11fd3..06be28ee62 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-corstone1000.inc +++ b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-corstone1000.inc @@ -7,6 +7,7 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/files/corstone1000:" SRC_URI:append = " \ file://0001-Fix-FF-A-version-in-SPMC-manifest.patch \ file://0002-feat-corstone1000-bl2-loads-fip-based-on-metadata.patch \ + file://0003-psci-SMCCC_ARCH_FEATURES-discovery-through-PSCI_FEATURES.patch \ " #Sets TF-A version to 2.8.0 diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-n1sdp.inc b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-n1sdp.inc index f4ebcc1c5f..654e43270f 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-n1sdp.inc +++ b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-n1sdp.inc @@ -9,6 +9,12 @@ TFA_MBEDTLS = "1" TFA_UBOOT = "0" TFA_UEFI = "1" +FILESEXTRAPATHS:prepend := "${THISDIR}/files/n1sdp:" + +SRC_URI:append = " \ + file://0001-Reserve-OP-TEE-memory-from-nwd.patch \ + " + TFA_ROT_KEY= "plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem" # Enabling Secure-EL1 Payload Dispatcher (SPD) diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0013-Platform-corstone1000-Increase-BL2-size-in-flash-lay.patch b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0001-Platform-corstone1000-Increase-BL2-size-in-flash-lay.patch index 92d17cc0db..98dabbe96c 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0013-Platform-corstone1000-Increase-BL2-size-in-flash-lay.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0001-Platform-corstone1000-Increase-BL2-size-in-flash-lay.patch @@ -1,12 +1,13 @@ -From 77c5a3bd090955e48ffca92bf9535185d26e9017 Mon Sep 17 00:00:00 2001 +From 60598f3b44237bd5038e33400e749ec1e7e8fbda Mon Sep 17 00:00:00 2001 From: Emekcan Aras <emekcan.aras@arm.com> Date: Mon, 15 May 2023 10:42:23 +0100 -Subject: [PATCH 2/4] Platform: corstone1000: Increase BL2 size in flash layout +Subject: [PATCH] Platform: corstone1000: Increase BL2 size in flash layout Increases BL2 size to align with the flash page size in corstone1000. Signed-off-by: Emekcan Aras <emekcan.aras@arm.com> Upstream-Status: Pending [Not submitted to upstream yet] + --- platform/ext/target/arm/corstone1000/partition/flash_layout.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) @@ -24,6 +25,3 @@ index 41b4c6323f..bfe8c4fb3c 100644 #define SE_BL2_BANK_0_OFFSET (0x9000) /* 72nd LBA */ #define SE_BL2_BANK_1_OFFSET (0x1002000) /* 32784th LBA */ --- -2.17.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0001-Platform-corstone1000-make-sure-to-write-fwu-metadata-to-repl.patch b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0001-Platform-corstone1000-make-sure-to-write-fwu-metadata-to-repl.patch deleted file mode 100644 index eeaf6d197e..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0001-Platform-corstone1000-make-sure-to-write-fwu-metadata-to-repl.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 0ee6842d348e206d511ec89a7ff5b29a6f325456 Mon Sep 17 00:00:00 2001 -From: Rui Miguel Silva <rui.silva@linaro.org> -Date: Sun, 29 Jan 2023 19:01:08 +0000 -Subject: [PATCH] corstone1000: make sure to write fwu metadata to replica 2 - -u-boot and other, before using fwu metadata validate if -the copies in both replicas are good. so, make sure -we write fwu metadata in both replicas. - -Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20550] -Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> ---- - .../arm/corstone1000/fw_update_agent/fwu_agent.c | 14 ++++++++++++++ - 1 file changed, 14 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 e1fa297ac923..215902ce71b9 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 -@@ -238,6 +238,20 @@ static enum fwu_agent_error_t metadata_write( - return FWU_AGENT_ERROR; - } - -+ FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__, -+ FWU_METADATA_REPLICA_2_OFFSET, sizeof(struct fwu_metadata)); -+ -+ ret = FWU_METADATA_FLASH_DEV.EraseSector(FWU_METADATA_REPLICA_2_OFFSET); -+ if (ret != ARM_DRIVER_OK) { -+ return FWU_AGENT_ERROR; -+ } -+ -+ ret = FWU_METADATA_FLASH_DEV.ProgramData(FWU_METADATA_REPLICA_2_OFFSET, -+ p_metadata, sizeof(struct fwu_metadata)); -+ if (ret < 0 || ret != sizeof(struct fwu_metadata)) { -+ 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; --- -2.39.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0014-Platform-Corstone1000-Increase-BL2_DATA_SIZE.patch b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0002-Platform-Corstone1000-Increase-BL2_DATA_SIZE.patch index e2844bacc0..d348d02dbc 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0014-Platform-Corstone1000-Increase-BL2_DATA_SIZE.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0002-Platform-Corstone1000-Increase-BL2_DATA_SIZE.patch @@ -1,13 +1,14 @@ -From 17244ac692495c23008ff784611d0ee1d42c83dc Mon Sep 17 00:00:00 2001 +From b05fb661b3afc3ed8e3d4817df2798e9d4877b39 Mon Sep 17 00:00:00 2001 From: Emekcan Aras <emekcan.aras@arm.com> Date: Mon, 15 May 2023 10:46:18 +0100 -Subject: [PATCH 3/4] Platform: Corstone1000: Increase BL2_DATA_SIZE +Subject: [PATCH] Platform: Corstone1000: Increase BL2_DATA_SIZE Increases BL2_DATA_SIZE to accommodate the changes in metadata_write/read. Signed-off-by: Emekcan Aras <emekcan.aras@arm.com> Upstream-Status: Pending [Not submitted to upstream yet] + --- platform/ext/target/arm/corstone1000/partition/region_defs.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) @@ -28,6 +29,3 @@ index abfac39b62..e7f0bad2ba 100644 #define BL2_DATA_LIMIT (BL2_DATA_START + BL2_DATA_SIZE - 1) /* SE BL1 regions */ --- -2.17.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0002-Platform-corstone1000-get-fwu-and-private-metadata-f.patch b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0002-Platform-corstone1000-get-fwu-and-private-metadata-f.patch deleted file mode 100644 index 3d7fc4b3d1..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0002-Platform-corstone1000-get-fwu-and-private-metadata-f.patch +++ /dev/null @@ -1,307 +0,0 @@ -From 4a4d1b0a5a2455ad799a45f7f87c0c9fd0173034 Mon Sep 17 00:00:00 2001 -From: Rui Miguel Silva <rui.silva@linaro.org> -Date: Wed, 29 Mar 2023 10:58:32 +0100 -Subject: [PATCH] Platform: Corstone1000: get fwu and private metadata from gpt - -Read and Write the FWU metadata and private metadata using instead -static flash offsets get the partitions and start address from gpt -partition table. - -Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20551] -Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> ---- - .../target/arm/corstone1000/CMakeLists.txt | 7 ++ - .../corstone1000/fw_update_agent/fwu_agent.c | 90 +++++++++++++++---- - .../target/arm/corstone1000/partition/efi.h | 1 + - .../arm/corstone1000/partition/partition.c | 14 +++ - .../arm/corstone1000/partition/partition.h | 1 + - .../ext/target/arm/corstone1000/platform.h | 5 ++ - 6 files changed, 99 insertions(+), 19 deletions(-) - -diff --git a/platform/ext/target/arm/corstone1000/CMakeLists.txt b/platform/ext/target/arm/corstone1000/CMakeLists.txt -index 19863bcdb6d2..f232c7639bd5 100644 ---- a/platform/ext/target/arm/corstone1000/CMakeLists.txt -+++ b/platform/ext/target/arm/corstone1000/CMakeLists.txt -@@ -64,6 +64,8 @@ target_include_directories(platform_s - cc312 - fw_update_agent - soft_crc -+ io -+ partition - ) - - target_sources(platform_s -@@ -81,6 +83,11 @@ target_sources(platform_s - fw_update_agent/fwu_agent.c - fw_update_agent/uefi_fmp.c - soft_crc/soft_crc.c -+ io/io_block.c -+ io/io_flash.c -+ io/io_storage.c -+ partition/partition.c -+ partition/gpt.c - $<$<NOT:$<BOOL:${PLATFORM_DEFAULT_OTP}>>:${PLATFORM_DIR}/ext/accelerator/cc312/otp_cc312.c> - ) - -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 b6ed656de833..9c76b25a3a38 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 -@@ -14,6 +14,8 @@ - #include "region_defs.h" - #include "uefi_capsule_parser.h" - #include "flash_common.h" -+#include "partition.h" -+#include "platform.h" - #include "platform_base_address.h" - #include "platform_description.h" - #include "tfm_plat_nv_counters.h" -@@ -146,6 +148,8 @@ extern ARM_DRIVER_FLASH FWU_METADATA_FLASH_DEV; - static enum fwu_agent_error_t private_metadata_read( - struct fwu_private_metadata* p_metadata) - { -+ partition_entry_t *part; -+ uuid_t private_uuid = PRIVATE_METADATA_TYPE_UUID; - int ret; - - FWU_LOG_MSG("%s: enter\n\r", __func__); -@@ -154,7 +158,13 @@ static enum fwu_agent_error_t private_metadata_read( - return FWU_AGENT_ERROR; - } - -- ret = FWU_METADATA_FLASH_DEV.ReadData(FWU_PRIVATE_METADATA_REPLICA_1_OFFSET, p_metadata, -+ part = get_partition_entry_by_type(&private_uuid); -+ if (!part) { -+ FWU_LOG_MSG("Private metadata partition not found\n\r"); -+ return FWU_AGENT_ERROR; -+ } -+ -+ ret = FWU_METADATA_FLASH_DEV.ReadData(part->start, p_metadata, - sizeof(struct fwu_private_metadata)); - if (ret < 0 || ret != sizeof(struct fwu_private_metadata)) { - return FWU_AGENT_ERROR; -@@ -169,6 +179,8 @@ static enum fwu_agent_error_t private_metadata_read( - static enum fwu_agent_error_t private_metadata_write( - struct fwu_private_metadata* p_metadata) - { -+ uuid_t private_uuid = PRIVATE_METADATA_TYPE_UUID; -+ partition_entry_t *part; - int ret; - - FWU_LOG_MSG("%s: enter: boot_index = %u\n\r", __func__, -@@ -178,12 +190,18 @@ static enum fwu_agent_error_t private_metadata_write( - return FWU_AGENT_ERROR; - } - -- ret = FWU_METADATA_FLASH_DEV.EraseSector(FWU_PRIVATE_METADATA_REPLICA_1_OFFSET); -+ part = get_partition_entry_by_type(&private_uuid); -+ if (!part) { -+ FWU_LOG_MSG("Private metadata partition not found\n\r"); -+ return FWU_AGENT_ERROR; -+ } -+ -+ ret = FWU_METADATA_FLASH_DEV.EraseSector(part->start); - if (ret != ARM_DRIVER_OK) { - return FWU_AGENT_ERROR; - } - -- ret = FWU_METADATA_FLASH_DEV.ProgramData(FWU_PRIVATE_METADATA_REPLICA_1_OFFSET, -+ ret = FWU_METADATA_FLASH_DEV.ProgramData(part->start, - p_metadata, sizeof(struct fwu_private_metadata)); - if (ret < 0 || ret != sizeof(struct fwu_private_metadata)) { - return FWU_AGENT_ERROR; -@@ -219,16 +237,25 @@ static enum fwu_agent_error_t metadata_validate(struct fwu_metadata *p_metadata) - - static enum fwu_agent_error_t metadata_read_without_validation(struct fwu_metadata *p_metadata) - { -+ uuid_t metadata_uuid = FWU_METADATA_TYPE_UUID; -+ partition_entry_t *part; - 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, -+ part = get_partition_entry_by_type(&metadata_uuid); -+ if (!part) { -+ FWU_LOG_MSG("%s: FWU metadata partition not found\n\r", __func__); -+ return FWU_AGENT_ERROR; -+ } -+ -+ FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__, -+ part->start, sizeof(struct fwu_metadata)); -+ -+ -+ ret = FWU_METADATA_FLASH_DEV.ReadData(part->start, - p_metadata, sizeof(struct fwu_metadata)); - if (ret < 0 || ret != sizeof(struct fwu_metadata)) { - return FWU_AGENT_ERROR; -@@ -242,16 +269,24 @@ static enum fwu_agent_error_t metadata_read_without_validation(struct fwu_metada - - static enum fwu_agent_error_t metadata_read(struct fwu_metadata *p_metadata) - { -+ uuid_t metadata_uuid = FWU_METADATA_TYPE_UUID; -+ partition_entry_t *part; - 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, -+ part = get_partition_entry_by_type(&metadata_uuid); -+ if (!part) { -+ FWU_LOG_MSG("%s: FWU metadata partition not found\n\r", __func__); -+ return FWU_AGENT_ERROR; -+ } -+ -+ FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__, -+ part->start, sizeof(struct fwu_metadata)); -+ -+ ret = FWU_METADATA_FLASH_DEV.ReadData(part->start, - p_metadata, sizeof(struct fwu_metadata)); - if (ret < 0 || ret != sizeof(struct fwu_metadata)) { - return FWU_AGENT_ERROR; -@@ -270,35 +305,49 @@ static enum fwu_agent_error_t metadata_read(struct fwu_metadata *p_metadata) - static enum fwu_agent_error_t metadata_write( - struct fwu_metadata *p_metadata) - { -+ uuid_t metadata_uuid = FWU_METADATA_TYPE_UUID; -+ partition_entry_t *part; - 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); -+ part = get_partition_entry_by_type(&metadata_uuid); -+ if (!part) { -+ FWU_LOG_MSG("%s: FWU metadata partition not found\n\r", __func__); -+ return FWU_AGENT_ERROR; -+ } -+ -+ FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__, -+ part->start, sizeof(struct fwu_metadata)); -+ -+ ret = FWU_METADATA_FLASH_DEV.EraseSector(part->start); - if (ret != ARM_DRIVER_OK) { - return FWU_AGENT_ERROR; - } - -- ret = FWU_METADATA_FLASH_DEV.ProgramData(FWU_METADATA_REPLICA_1_OFFSET, -+ ret = FWU_METADATA_FLASH_DEV.ProgramData(part->start, - p_metadata, sizeof(struct fwu_metadata)); - if (ret < 0 || ret != sizeof(struct fwu_metadata)) { - return FWU_AGENT_ERROR; - } - -+ part = get_partition_replica_by_type(&metadata_uuid); -+ if (!part) { -+ FWU_LOG_MSG("%s: FWU metadata replica partition not found\n\r", __func__); -+ return FWU_AGENT_ERROR; -+ } -+ - FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__, -- FWU_METADATA_REPLICA_2_OFFSET, sizeof(struct fwu_metadata)); -+ part->start, sizeof(struct fwu_metadata)); - -- ret = FWU_METADATA_FLASH_DEV.EraseSector(FWU_METADATA_REPLICA_2_OFFSET); -+ ret = FWU_METADATA_FLASH_DEV.EraseSector(part->start); - if (ret != ARM_DRIVER_OK) { - return FWU_AGENT_ERROR; - } - -- ret = FWU_METADATA_FLASH_DEV.ProgramData(FWU_METADATA_REPLICA_2_OFFSET, -+ ret = FWU_METADATA_FLASH_DEV.ProgramData(part->start, - p_metadata, sizeof(struct fwu_metadata)); - if (ret < 0 || ret != sizeof(struct fwu_metadata)) { - return FWU_AGENT_ERROR; -@@ -355,6 +404,9 @@ enum fwu_agent_error_t fwu_metadata_provision(void) - - FWU_LOG_MSG("%s: enter\n\r", __func__); - -+ plat_io_storage_init(); -+ partition_init(PLATFORM_GPT_IMAGE); -+ - ret = fwu_metadata_init(); - if (ret) { - return ret; -diff --git a/platform/ext/target/arm/corstone1000/partition/efi.h b/platform/ext/target/arm/corstone1000/partition/efi.h -index f66daffb32d6..7e6a4bc883e6 100644 ---- a/platform/ext/target/arm/corstone1000/partition/efi.h -+++ b/platform/ext/target/arm/corstone1000/partition/efi.h -@@ -8,6 +8,7 @@ - #ifndef DRIVERS_PARTITION_EFI_H - #define DRIVERS_PARTITION_EFI_H - -+#include <stdint.h> - #include <string.h> - - #include "uuid.h" -diff --git a/platform/ext/target/arm/corstone1000/partition/partition.c b/platform/ext/target/arm/corstone1000/partition/partition.c -index afc6aa1c5cb8..d76e123d728f 100644 ---- a/platform/ext/target/arm/corstone1000/partition/partition.c -+++ b/platform/ext/target/arm/corstone1000/partition/partition.c -@@ -293,6 +293,20 @@ const partition_entry_t *get_partition_entry_by_type(const uuid_t *type_uuid) { - return NULL; - } - -+const partition_entry_t *get_partition_replica_by_type(const uuid_t *type_uuid) { -+ int count = 0; -+ int i; -+ -+ for (i = 0; i < list.entry_count; i++) { -+ if (guidcmp(type_uuid, &list.list[i].type_guid) == 0) { -+ if (++count == 2) -+ return &list.list[i]; -+ } -+ } -+ -+ return NULL; -+} -+ - const partition_entry_t *get_partition_entry_by_uuid(const uuid_t *part_uuid) { - int i; - -diff --git a/platform/ext/target/arm/corstone1000/partition/partition.h b/platform/ext/target/arm/corstone1000/partition/partition.h -index 54af47aca415..450cf20a073c 100644 ---- a/platform/ext/target/arm/corstone1000/partition/partition.h -+++ b/platform/ext/target/arm/corstone1000/partition/partition.h -@@ -40,6 +40,7 @@ typedef struct partition_entry_list { - int load_partition_table(unsigned int image_id); - const partition_entry_t *get_partition_entry(const char *name); - const partition_entry_t *get_partition_entry_by_type(const uuid_t *type_guid); -+const partition_entry_t *get_partition_replica_by_type(const uuid_t *type_uuid); - const partition_entry_t *get_partition_entry_by_uuid(const uuid_t *part_uuid); - const partition_entry_list_t *get_partition_entry_list(void); - void partition_init(unsigned int image_id); -diff --git a/platform/ext/target/arm/corstone1000/platform.h b/platform/ext/target/arm/corstone1000/platform.h -index 894f5e309029..a88093ed4f9d 100644 ---- a/platform/ext/target/arm/corstone1000/platform.h -+++ b/platform/ext/target/arm/corstone1000/platform.h -@@ -13,6 +13,11 @@ typedef enum { - PLATFORM_IMAGE_COUNT, - }platform_image_id_t; - -+#define FWU_METADATA_TYPE_UUID \ -+ ((uuid_t){{0xa0, 0x84, 0x7a, 0x8a}, {0x87, 0x83}, {0xf6, 0x40}, 0xab, 0x41, {0xa8, 0xb9, 0xa5, 0xa6, 0x0d, 0x23}}) -+#define PRIVATE_METADATA_TYPE_UUID \ -+ ((uuid_t){{0xc3, 0x5d, 0xb5, 0xec}, {0xb7, 0x8a}, {0x84, 0x4a}, 0xab, 0x56, {0xeb, 0x0a, 0x99, 0x74, 0xdb, 0x42}}) -+ - /* Initialize io storage of the platform */ - int32_t plat_io_storage_init(void); - --- -2.40.0 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0015-Platform-Corstone1000-Calculate-the-new-CRC32-value-.patch b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0003-Platform-Corstone1000-Calculate-the-new-CRC32-value-.patch index fd977ac2fd..bf7aba8de8 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0015-Platform-Corstone1000-Calculate-the-new-CRC32-value-.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0003-Platform-Corstone1000-Calculate-the-new-CRC32-value-.patch @@ -1,8 +1,8 @@ -From 83e423497afecc202a3a50c3e472161390056ebd Mon Sep 17 00:00:00 2001 +From 88cfce2e04913d48ec8636b6a3550d71ebdd49c4 Mon Sep 17 00:00:00 2001 From: Emekcan Aras <emekcan.aras@arm.com> Date: Mon, 15 May 2023 10:47:27 +0100 -Subject: [PATCH 4/4] Platform: Corstone1000: Calculate the new CRC32 value - after changing the metadata +Subject: [PATCH] Platform: Corstone1000: Calculate the new CRC32 value after + changing the metadata Calculates the new CRC32 value for the metadata struct after chaing a value during the capsule update. It also updates the CRC32 field in the metadata @@ -13,6 +13,7 @@ the boot anymore. Signed-off-by: Emekcan Aras <emekcan.aras@arm.com> Upstream-Status: Pending [Not submitted to upstream yet] + --- .../arm/corstone1000/fw_update_agent/fwu_agent.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) @@ -66,6 +67,3 @@ index afd8d66e42..f564f2902c 100644 if (priv_metadata->nv_counter[i] < security_cnt) { return FWU_AGENT_ERROR; } else if (priv_metadata->nv_counter[i] > security_cnt) { --- -2.17.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0003-Platform-corstone1000-Add-watchdog_reset_timer.patch b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0003-Platform-corstone1000-Add-watchdog_reset_timer.patch deleted file mode 100644 index 3ffd83e9a8..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0003-Platform-corstone1000-Add-watchdog_reset_timer.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 33d8f45c8f14e9e0d7add7d2804ed76c7d7fd0c2 Mon Sep 17 00:00:00 2001 -From: Emekcan Aras <emekcan.aras@arm.com> -Date: Sat, 25 Feb 2023 09:04:38 +0000 -Subject: [PATCH 1/7] Platform: corstone1000: Add watchdog_reset_timer - -From: Mohamed Omar Asaker <mohamed.omarasaker@arm.com> - -Implement watchdog_reset_timer - -Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20552] -Signed-off-by: Mohamed Omar Asaker <mohamed.omarasaker@arm.com> -Change-Id: I2684ca54f9a456b22efcbcd364abef3537d4c91f ---- - .../arm/corstone1000/Native_Driver/watchdog.c | 17 +++++++++++++++++ - 1 file changed, 17 insertions(+) - -diff --git a/platform/ext/target/arm/corstone1000/Native_Driver/watchdog.c b/platform/ext/target/arm/corstone1000/Native_Driver/watchdog.c -index 4e024a3b1..f6e182194 100644 ---- a/platform/ext/target/arm/corstone1000/Native_Driver/watchdog.c -+++ b/platform/ext/target/arm/corstone1000/Native_Driver/watchdog.c -@@ -80,6 +80,23 @@ int corstone1000_watchdog_init() - return ARM_DRIVER_OK; - } - -+/** -+ * \brief Reset the Secure Enclave & SoC Watchdog's. -+ * -+ * \returns ARM Driver return code. -+ */ -+int corstone1000_watchdog_reset_timer() { -+ /* 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); -+ /* 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); -+ return ARM_DRIVER_OK; -+} -+ - /* - * Secure Host Watchdog WS1 Handler - * efi_reset_system from the host triggers "Secure --- -2.17.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0004-Platform-corstone1000-Replace-MCUBOOT-BL1-by-TFM-s.patch b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0004-Platform-corstone1000-Replace-MCUBOOT-BL1-by-TFM-s.patch deleted file mode 100644 index 0ad44947f0..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0004-Platform-corstone1000-Replace-MCUBOOT-BL1-by-TFM-s.patch +++ /dev/null @@ -1,1034 +0,0 @@ -From e46fd33355b54c08d1764c2a8e7b553960d61157 Mon Sep 17 00:00:00 2001 -From: Emekcan Aras <emekcan.aras@arm.com> -Date: Sat, 25 Feb 2023 10:29:55 +0000 -Subject: [PATCH 1/6] Platform: corstone1000: Replace MCUBOOT BL1 by TFM's - -From: Mohamed Omar Asaker <mohamed.omarasaker@arm.com> - -Replace The current BL1 (MCUBOOT) with the TFM BL1 -by enabling -- PLATFORM_DEFAULT_BL1 -- Update linkerscripts -- Update CMakeFile -- Adapt boot_hal -- Adapt provisioning (to use the provision bundle) -- Adapt flash_layout and region_defs -- Update documentation of corstone1000 build and run sections - -Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20553] -Signed-off-by: Mohamed Omar Asaker <mohamed.omarasaker@arm.com> -Change-Id: I224b24d0f4423e62468e609c11a239a4575cdae4 ---- - .../target/arm/corstone1000/CMakeLists.txt | 70 +++++- - .../Device/Include/boot_measurement.h | 24 +++ - .../Device/Include/platform_base_address.h | 3 + - .../Device/Source/gcc/corstone1000_bl1_1.ld | 203 ++++++++++++++++++ - ...stone1000_bl1.ld => corstone1000_bl1_2.ld} | 8 +- - .../target/arm/corstone1000/bl1/bl1_rotpk.c | 48 ----- - .../bl1/{bl1_boot_hal.c => boot_hal_bl1.c} | 102 ++++----- - .../arm/corstone1000/bl1/flash_map_extended.c | 103 --------- - .../arm/corstone1000/bl1/provisioning.c | 109 +++++----- - .../ext/target/arm/corstone1000/config.cmake | 18 +- - .../arm/corstone1000/partition/flash_layout.h | 10 - - .../arm/corstone1000/partition/region_defs.h | 37 +++- - 12 files changed, 434 insertions(+), 301 deletions(-) - create mode 100644 platform/ext/target/arm/corstone1000/Device/Include/boot_measurement.h - create mode 100644 platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld - rename platform/ext/target/arm/corstone1000/Device/Source/gcc/{corstone1000_bl1.ld => corstone1000_bl1_2.ld} (95%) - delete mode 100644 platform/ext/target/arm/corstone1000/bl1/bl1_rotpk.c - rename platform/ext/target/arm/corstone1000/bl1/{bl1_boot_hal.c => boot_hal_bl1.c} (90%) - delete mode 100644 platform/ext/target/arm/corstone1000/bl1/flash_map_extended.c - -diff --git a/platform/ext/target/arm/corstone1000/CMakeLists.txt b/platform/ext/target/arm/corstone1000/CMakeLists.txt -index 19863bcdb..a4fe28c08 100644 ---- a/platform/ext/target/arm/corstone1000/CMakeLists.txt -+++ b/platform/ext/target/arm/corstone1000/CMakeLists.txt -@@ -41,6 +41,23 @@ target_add_scatter_file(bl2 - $<$<C_COMPILER_ID:GNU>:${PLATFORM_DIR}/ext/common/gcc/tfm_common_bl2.ld> - ) - -+target_sources(bl1_1 -+PRIVATE -+ $<$<C_COMPILER_ID:GNU>:${CMAKE_CURRENT_SOURCE_DIR}/Device/Source/startup_corstone1000.c> -+) -+ -+target_add_scatter_file(bl1_1 -+ $<$<C_COMPILER_ID:GNU>:${CMAKE_CURRENT_SOURCE_DIR}/Device/Source/gcc/corstone1000_bl1_1.ld> -+) -+ -+target_sources(bl1_2 -+PRIVATE -+ $<$<C_COMPILER_ID:GNU>:${CMAKE_CURRENT_SOURCE_DIR}/Device/Source/startup_corstone1000.c> -+) -+target_add_scatter_file(bl1_2 -+ $<$<C_COMPILER_ID:GNU>:${CMAKE_CURRENT_SOURCE_DIR}/Device/Source/gcc/corstone1000_bl1_2.ld> -+) -+ - #========================= Platform Secure ====================================# - - add_subdirectory(openamp) -@@ -115,6 +132,55 @@ if (TFM_PARTITION_CRYPTO) - ) - endif() - -+#========================= Platform BL1 =======================================# -+ -+target_sources(platform_bl1 -+ PRIVATE -+ ./Device/Source/system_core_init.c -+ ./Device/Source/device_definition.c -+ ./bl1/boot_hal_bl1.c -+ ./Native_Driver/firewall.c -+ ./CMSIS_Driver/Driver_Flash.c -+ ./CMSIS_Driver/Driver_USART.c -+ ./Native_Driver/uart_pl011_drv.c -+ $<$<BOOL:${PLATFORM_IS_FVP}>:${CMAKE_CURRENT_SOURCE_DIR}/Native_Driver/cfi_drv.c> -+ $<$<BOOL:${PLATFORM_IS_FVP}>:${PLATFORM_DIR}/ext/target/arm/drivers/flash/strata/spi_strataflashj3_flash_lib.c> -+ $<$<NOT:$<BOOL:${PLATFORM_IS_FVP}>>:${PLATFORM_DIR}/ext/target/arm/drivers/qspi/xilinx_pg153_axi/xilinx_pg153_axi_qspi_controller_drv.c> -+ $<$<NOT:$<BOOL:${PLATFORM_IS_FVP}>>:${PLATFORM_DIR}/ext/target/arm/drivers/flash/n25q256a/spi_n25q256a_flash_lib.c> -+ $<$<NOT:$<BOOL:${PLATFORM_IS_FVP}>>:${PLATFORM_DIR}/ext/target/arm/drivers/flash/sst26vf064b/spi_sst26vf064b_flash_lib.c> -+ ./fw_update_agent/uefi_capsule_parser.c -+ ./fw_update_agent/fwu_agent.c -+ ./fw_update_agent/uefi_fmp.c -+ ./soft_crc/soft_crc.c -+ ./Native_Driver/arm_watchdog_drv.c -+ ./Native_Driver/watchdog.c -+ ./bl1/provisioning.c -+ $<$<NOT:$<BOOL:${PLATFORM_DEFAULT_OTP}>>:${PLATFORM_DIR}/ext/accelerator/cc312/otp_cc312.c> -+) -+ -+target_compile_definitions(platform_bl1 -+ PUBLIC -+ $<$<BOOL:${PLATFORM_IS_FVP}>:PLATFORM_IS_FVP> -+ $<$<AND:$<BOOL:${CONFIG_TFM_BOOT_STORE_MEASUREMENTS}>,$<BOOL:${TFM_PARTITION_MEASURED_BOOT}>>:MEASURED_BOOT_API> -+ $<$<BOOL:${PLATFORM_DEFAULT_OTP_WRITEABLE}>:OTP_WRITEABLE> -+) -+ -+target_include_directories(platform_bl1_interface -+ INTERFACE -+ . -+ ./Device/Include -+ ./Device/Config -+ ./Native_Driver -+ ./CMSIS_Driver/Config -+ ./fw_update_agent -+ ./soft_crc -+ ${PLATFORM_DIR}/ext/target/arm/drivers/flash/common -+ ${PLATFORM_DIR}/ext/target/arm/drivers/flash/strata -+ ${PLATFORM_DIR}/ext/target/arm/drivers/qspi/xilinx_pg153_axi/ -+ ${PLATFORM_DIR}/ext/target/arm/drivers/flash/n25q256a/ -+ ${PLATFORM_DIR}/ext/target/arm/drivers/flash/sst26vf064b/ -+) -+ - #========================= Platform BL2 =======================================# - - set(BL2_SOURCE ${CMAKE_SOURCE_DIR}/bl2) -@@ -214,10 +280,6 @@ target_include_directories(platform_bl2 - $<BUILD_INTERFACE:${BL2_SOURCE}/ext/mcuboot/include> - ) - --#========================= BL1 component =======================================# -- --add_subdirectory(bl1) -- - #========================= ns_agent_mailbox ===================================# - - target_sources(tfm_psa_rot_partition_ns_agent_mailbox -diff --git a/platform/ext/target/arm/corstone1000/Device/Include/boot_measurement.h b/platform/ext/target/arm/corstone1000/Device/Include/boot_measurement.h -new file mode 100644 -index 000000000..a47bdb148 ---- /dev/null -+++ b/platform/ext/target/arm/corstone1000/Device/Include/boot_measurement.h -@@ -0,0 +1,24 @@ -+/* -+ * Copyright (c) 2023, Arm Limited. All rights reserved. -+ * -+ * SPDX-License-Identifier: BSD-3-Clause -+ * -+ */ -+ -+#ifndef __BOOT_MEASUREMENT_H__ -+#define __BOOT_MEASUREMENT_H__ -+ -+enum boot_measurement_slot_t { -+ BOOT_MEASUREMENT_SLOT_BL1_2 = 0, -+ BOOT_MEASUREMENT_SLOT_BL2, -+ BOOT_MEASUREMENT_SLOT_RT_0, -+ BOOT_MEASUREMENT_SLOT_RT_1, -+ BOOT_MEASUREMENT_SLOT_RT_2, -+ BOOT_MEASUREMENT_SLOT_MAX = 32, -+ BOOT_MEASUREMENT_SLOT_MAX_THEORETICAL = 63 /* Slot index is stored in -+ * 6 bits in the shared -+ * memory area. -+ */ -+}; -+ -+#endif /* __BOOT_MEASUREMENT_H__ */ -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 5cca4c4a1..416f0ebcd 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 -@@ -79,4 +79,7 @@ - #define CORSTONE1000_HOST_AXI_QSPI_CTRL_REG_BASE_SE_SECURE_FLASH (0x90010000U) /* AXI QSPI Controller for SE FLash */ - #define CORSTONE1000_HOST_DRAM_UEFI_CAPSULE (0xA0000000U) /* 1.5 GB DDR */ - -+/* Map Component definitions to Corstone definitions */ -+#define CC3XX_BASE_S CORSTONE1000_CRYPTO_ACCELERATOR_BASE -+ - #endif /* __PLATFORM_BASE_ADDRESS_H__ */ -diff --git a/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld b/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld -new file mode 100644 -index 000000000..d4eca2841 ---- /dev/null -+++ b/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld -@@ -0,0 +1,203 @@ -+;/* -+; * Copyright (c) 2009-2022, Arm Limited. All rights reserved. -+; * -+; * 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. -+; * -+; * -+; * This file is derivative of CMSIS V5.00 gcc_arm.ld -+; */ -+ -+/* Linker script to configure memory regions. */ -+/* This file will be run trough the pre-processor. */ -+ -+#include "region_defs.h" -+ -+MEMORY -+{ -+ FLASH (rx) : ORIGIN = BL1_1_CODE_START, LENGTH = BL1_1_CODE_SIZE -+ RAM (rwx) : ORIGIN = BL1_1_DATA_START, LENGTH = BL1_1_DATA_SIZE -+} -+ -+__heap_size__ = BL1_1_HEAP_SIZE; -+__msp_stack_size__ = BL1_1_MSP_STACK_SIZE; -+ -+/* Library configurations */ -+GROUP(libgcc.a libc.a libm.a libnosys.a) -+ -+ENTRY(Reset_Handler) -+ -+SECTIONS -+{ -+ .text : -+ { -+ KEEP(*(.vectors)) -+ __Vectors_End = .; -+ __Vectors_Size = __Vectors_End - __Vectors; -+ __end__ = .; -+ -+ *(.text*) -+ -+ KEEP(*shared_lib*:*(.text*)) -+ KEEP(*bl1_tests_shared*:*(.text*)) -+ KEEP(*bl1_crypto_hw*:*(.text*)) -+ KEEP(*boot_hal_bl1*(.text*)) -+ -+ KEEP(*(.init)) -+ KEEP(*(.fini)) -+ -+ -+ /* .ctors */ -+ *crtbegin.o(.ctors) -+ *crtbegin?.o(.ctors) -+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) -+ *(SORT(.ctors.*)) -+ *(.ctors) -+ -+ /* .dtors */ -+ *crtbegin.o(.dtors) -+ *crtbegin?.o(.dtors) -+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) -+ *(SORT(.dtors.*)) -+ *(.dtors) -+ -+ *(.rodata*) -+ -+ KEEP(*(.eh_frame*)) -+ } > FLASH -+ -+ .ARM.extab : -+ { -+ *(.ARM.extab* .gnu.linkonce.armextab.*) -+ } > FLASH -+ -+ __exidx_start = .; -+ .ARM.exidx : -+ { -+ *(.ARM.exidx* .gnu.linkonce.armexidx.*) -+ } > FLASH -+ __exidx_end = .; -+ -+ /* To copy multiple ROM to RAM sections, -+ * define etext2/data2_start/data2_end and -+ * define __STARTUP_COPY_MULTIPLE in startup_corstone700_bl2.S */ -+ .copy.table : -+ { -+ . = ALIGN(4); -+ __copy_table_start__ = .; -+ LONG (__etext) -+ LONG (__data_start__) -+ LONG ((__data_end__ - __data_start__) / 4) -+ LONG (DEFINED(__etext2) ? __etext2 : 0) -+ LONG (DEFINED(__data2_start__) ? __data2_start__ : 0) -+ LONG (DEFINED(__data2_start__) ? ((__data2_end__ - __data2_start__) / 4) : 0) -+ __copy_table_end__ = .; -+ } > FLASH -+ -+ /* To clear multiple BSS sections, -+ * uncomment .zero.table section and, -+ * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_cmsdk_musca_bl2.S */ -+ .zero.table : -+ { -+ . = ALIGN(4); -+ __zero_table_start__ = .; -+ LONG (__bss_start__) -+ LONG ((__bss_end__ - __bss_start__) / 4) -+ LONG (DEFINED(__bss2_start__) ? __bss2_start__ : 0) -+ LONG (DEFINED(__bss2_start__) ? ((__bss2_end__ - __bss2_start__) / 4) : 0) -+ __zero_table_end__ = .; -+ } > FLASH -+ -+ __etext = ALIGN (4); -+ -+ .tfm_bl2_shared_data : ALIGN(32) -+ { -+ . += BOOT_TFM_SHARED_DATA_SIZE; -+ } > RAM -+ Image$$SHARED_DATA$$RW$$Base = ADDR(.tfm_bl2_shared_data); -+ Image$$SHARED_DATA$$RW$$Limit = ADDR(.tfm_bl2_shared_data) + SIZEOF(.tfm_bl2_shared_data); -+ -+ . = BL1_1_DATA_START; -+ Image$$BL1_1_ER_DATA_START$$Base = .; -+ .data : AT (__etext) -+ { -+ __data_start__ = .; -+ *(vtable) -+ *(.data*) -+ -+ . = ALIGN(4); -+ /* preinit data */ -+ PROVIDE_HIDDEN (__preinit_array_start = .); -+ KEEP(*(.preinit_array)) -+ PROVIDE_HIDDEN (__preinit_array_end = .); -+ -+ . = ALIGN(4); -+ /* init data */ -+ PROVIDE_HIDDEN (__init_array_start = .); -+ KEEP(*(SORT(.init_array.*))) -+ KEEP(*(.init_array)) -+ PROVIDE_HIDDEN (__init_array_end = .); -+ -+ -+ . = ALIGN(4); -+ /* finit data */ -+ PROVIDE_HIDDEN (__fini_array_start = .); -+ KEEP(*(SORT(.fini_array.*))) -+ KEEP(*(.fini_array)) -+ PROVIDE_HIDDEN (__fini_array_end = .); -+ -+ KEEP(*(.jcr*)) -+ . = ALIGN(4); -+ /* All data end */ -+ __data_end__ = .; -+ -+ } > RAM -+ Image$$ER_DATA$$Base = ADDR(.data); -+ -+ .bss : -+ { -+ . = ALIGN(4); -+ __bss_start__ = .; -+ *(.bss*) -+ *(COMMON) -+ . = ALIGN(4); -+ __bss_end__ = .; -+ } > RAM -+ -+ bss_size = __bss_end__ - __bss_start__; -+ -+ .msp_stack (NOLOAD) : ALIGN(32) -+ { -+ . += __msp_stack_size__; -+ } > RAM -+ Image$$ARM_LIB_STACK$$ZI$$Base = ADDR(.msp_stack); -+ Image$$ARM_LIB_STACK$$ZI$$Limit = ADDR(.msp_stack) + SIZEOF(.msp_stack); -+ -+ .heap (NOLOAD): ALIGN(8) -+ { -+ . = ALIGN(8); -+ __end__ = .; -+ PROVIDE(end = .); -+ __HeapBase = .; -+ . += __heap_size__; -+ __HeapLimit = .; -+ __heap_limit = .; /* Add for _sbrk */ -+ } > RAM -+ Image$$ARM_LIB_HEAP$$ZI$$Limit = ADDR(.heap) + SIZEOF(.heap); -+ -+ PROVIDE(__stack = Image$$ARM_LIB_STACK$$ZI$$Limit); -+ -+ Image$$BL1_1_ER_DATA_LIMIT$$Base = .; -+ -+ Image$$BL1_2_ER_DATA_START$$Base = BL1_2_DATA_START; -+ Image$$BL1_2_ER_DATA_LIMIT$$Base = BL1_2_DATA_START + BL1_2_DATA_SIZE; -+} -diff --git a/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1.ld b/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld -similarity index 95% -rename from platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1.ld -rename to platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld -index 73be37d7c..6cd806378 100644 ---- a/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1.ld -+++ b/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld -@@ -24,12 +24,12 @@ - - MEMORY - { -- FLASH (rx) : ORIGIN = BL1_CODE_START, LENGTH = BL1_CODE_SIZE -- RAM (rwx) : ORIGIN = BL1_DATA_START, LENGTH = BL1_DATA_SIZE -+ FLASH (rx) : ORIGIN = BL1_2_CODE_START, LENGTH = BL1_2_CODE_SIZE -+ RAM (rwx) : ORIGIN = BL1_2_DATA_START, LENGTH = BL1_2_DATA_SIZE - } - --__heap_size__ = BL1_HEAP_SIZE; --__msp_stack_size__ = BL1_MSP_STACK_SIZE; -+__heap_size__ = BL1_2_HEAP_SIZE; -+__msp_stack_size__ = BL1_2_MSP_STACK_SIZE; - - /* Library configurations */ - GROUP(libgcc.a libc.a libm.a libnosys.a) -diff --git a/platform/ext/target/arm/corstone1000/bl1/bl1_rotpk.c b/platform/ext/target/arm/corstone1000/bl1/bl1_rotpk.c -deleted file mode 100644 -index d8cfe3759..000000000 ---- a/platform/ext/target/arm/corstone1000/bl1/bl1_rotpk.c -+++ /dev/null -@@ -1,48 +0,0 @@ --/* -- * Copyright (c) 2019-2021, Arm Limited. All rights reserved. -- * -- * SPDX-License-Identifier: BSD-3-Clause -- * -- */ -- --#include <stdint.h> --#include "tfm_plat_otp.h" -- --static enum tfm_plat_err_t get_rotpk_hash(enum tfm_otp_element_id_t id, -- uint8_t* rotpk_hash, -- uint32_t* rotpk_hash_size) --{ -- enum tfm_plat_err_t err; -- size_t otp_size; -- -- err = tfm_plat_otp_read(id, *rotpk_hash_size, rotpk_hash); -- if (err != TFM_PLAT_ERR_SUCCESS) { -- return err; -- } -- -- err = tfm_plat_otp_get_size(id, &otp_size); -- if (err != TFM_PLAT_ERR_SUCCESS) { -- return err; -- } -- -- *rotpk_hash_size = otp_size; -- -- return TFM_PLAT_ERR_SUCCESS; --} -- --enum tfm_plat_err_t --tfm_plat_get_rotpk_hash(uint8_t image_id, -- uint8_t *rotpk_hash, -- uint32_t *rotpk_hash_size) --{ -- switch(image_id) { -- case 0: -- return get_rotpk_hash(PLAT_OTP_ID_BL1_ROTPK_0, rotpk_hash, -- rotpk_hash_size); -- -- default: -- return TFM_PLAT_ERR_INVALID_INPUT; -- } -- -- return TFM_PLAT_ERR_SYSTEM_ERR; --} -diff --git a/platform/ext/target/arm/corstone1000/bl1/bl1_boot_hal.c b/platform/ext/target/arm/corstone1000/bl1/boot_hal_bl1.c -similarity index 90% -rename from platform/ext/target/arm/corstone1000/bl1/bl1_boot_hal.c -rename to platform/ext/target/arm/corstone1000/bl1/boot_hal_bl1.c -index a5fe0f7da..678342443 100644 ---- a/platform/ext/target/arm/corstone1000/bl1/bl1_boot_hal.c -+++ b/platform/ext/target/arm/corstone1000/bl1/boot_hal_bl1.c -@@ -12,13 +12,16 @@ - #include "Driver_Flash.h" - #include "flash_layout.h" - #include "fih.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" - #include "fwu_agent.h" -+#include "uart_stdout.h" -+#include "region_defs.h" -+#include "log.h" -+ - - #if defined(CRYPTO_HW_ACCELERATOR) || \ - defined(CRYPTO_HW_ACCELERATOR_OTP_PROVISIONING) -@@ -81,6 +84,9 @@ enum host_firewall_host_comp_id_t { - COMP_DEBUG, - }; - -+extern uint32_t platform_code_is_bl1_2; -+ -+ - static void setup_mpu(void) - { - uint32_t size; /* region size */ -@@ -581,56 +587,44 @@ static void setup_host_firewall(void) - fw_lockdown(FW_FULL_LOCKDOWN); - } - -- --__attribute__((naked)) void boot_clear_bl2_ram_area(void) -+uint32_t bl1_image_get_flash_offset(uint32_t image_id) - { -- __ASM volatile( -- ".syntax unified \n" -- "movs r0, #0 \n" -- "ldr r1, =Image$$ER_DATA$$Base \n" -- "ldr r2, =Image$$ARM_LIB_HEAP$$ZI$$Limit \n" -- "subs r2, r2, r1 \n" -- "Loop: \n" -- "subs r2, #4 \n" -- "blt Clear_done \n" -- "str r0, [r1, r2] \n" -- "b Loop \n" -- "Clear_done: \n" -- "bx lr \n" -- : : : "r0" , "r1" , "r2" , "memory" -- ); -+ /* SE BL2 Offset is equal to bank offset as it is the first think in the Bank */ -+ uint32_t se_bl2_offset = 0; -+ bl1_get_active_bl2_image(&se_bl2_offset); -+ switch (image_id) { -+ case 0: -+ return se_bl2_offset; -+ case 1: -+ return se_bl2_offset + SE_BL2_PARTITION_SIZE; -+ default: -+ FIH_PANIC; -+ } - } - --extern void set_flash_area_image_offset(uint32_t offset); -- - int32_t boot_platform_init(void) - { - int32_t result; - uint32_t image_offset; - -- result = corstone1000_watchdog_init(); -- if (result != ARM_DRIVER_OK) { -- return 1; -- } -- -+ if (!platform_code_is_bl1_2) { -+ result = corstone1000_watchdog_init(); -+ if (result != ARM_DRIVER_OK) { -+ return 1; -+ } - #if !(PLATFORM_IS_FVP) -- setup_mpu(); -+ setup_mpu(); - #endif -- setup_se_firewall(); -+ setup_se_firewall(); - #if !(PLATFORM_IS_FVP) -- setup_host_firewall(); -+ setup_host_firewall(); - #endif -- -- result = FLASH_DEV_NAME.Initialize(NULL); -- if (result != ARM_DRIVER_OK) { -- return 1; - } --#if PLATFORM_DEFAULT_OTP -- result = FLASH_DEV_NAME_SE_SECURE_FLASH.Initialize(NULL); -- if (result != ARM_DRIVER_OK) { -- return 1; -- } --#endif -+ -+#if defined(TFM_BL1_LOGGING) || defined(TEST_BL1_1) || defined(TEST_BL1_2) -+ stdio_init(); -+#endif /* defined(TFM_BL1_LOGGING) || defined(TEST_BL1_1) || defined(TEST_BL1_2) */ -+ - - #ifdef CRYPTO_HW_ACCELERATOR - result = crypto_hw_accelerator_init(); -@@ -639,23 +633,11 @@ 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; -- } -- } -- -- bl1_get_active_bl2_image(&image_offset); -- set_flash_area_image_offset(image_offset); -+ return 0; -+} - -+int32_t boot_platform_post_init(void) -+{ - return 0; - } - -@@ -678,17 +660,15 @@ void boot_platform_quit(struct boot_arm_vector_table *vt) - (void)fih_delay_init(); - #endif /* CRYPTO_HW_ACCELERATOR */ - -- result = FLASH_DEV_NAME.Uninitialize(); -- if (result != ARM_DRIVER_OK) { -- while (1); -- } - --#if PLATFORM_DEFAULT_OTP -- result = FLASH_DEV_NAME_SE_SECURE_FLASH.Uninitialize(); -+#if defined(TFM_BL1_LOGGING) || defined(TEST_BL1_1) || defined(TEST_BL1_2) -+ stdio_uninit(); -+#endif /* defined(TFM_BL1_LOGGING) || defined(TEST_BL1_1) || defined(TEST_BL1_2) */ -+ -+ result = corstone1000_watchdog_reset_timer(); - if (result != ARM_DRIVER_OK) { - while (1); - } --#endif - - vt_cpy = vt; - -diff --git a/platform/ext/target/arm/corstone1000/bl1/flash_map_extended.c b/platform/ext/target/arm/corstone1000/bl1/flash_map_extended.c -deleted file mode 100644 -index b6632b6c2..000000000 ---- a/platform/ext/target/arm/corstone1000/bl1/flash_map_extended.c -+++ /dev/null -@@ -1,103 +0,0 @@ --/* -- * Copyright (c) 2018 Nordic Semiconductor ASA -- * Copyright (c) 2015 Runtime Inc -- * Copyright (c) 2019-2021 Arm Limited. -- * -- * SPDX-License-Identifier: Apache-2.0 -- */ -- --/* -- * Original code taken from mcuboot project at: -- * https://github.com/mcu-tools/mcuboot -- * Git SHA of the original version: ac55554059147fff718015be9f4bd3108123f50a -- */ -- --#include <errno.h> --#include "target.h" --#include "cmsis.h" --#include "Driver_Flash.h" --#include "sysflash/sysflash.h" --#include "flash_map/flash_map.h" --#include "flash_map_backend/flash_map_backend.h" --#include "bootutil/bootutil_log.h" -- --__WEAK int flash_device_base(uint8_t fd_id, uintptr_t *ret) --{ -- if (fd_id != FLASH_DEVICE_ID) { -- BOOT_LOG_ERR("invalid flash ID %d; expected %d", -- fd_id, FLASH_DEVICE_ID); -- return -1; -- } -- *ret = FLASH_DEVICE_BASE; -- return 0; --} -- --/* -- * This depends on the mappings defined in flash_map.h. -- * MCUBoot uses continuous numbering for the primary slot, the secondary slot, -- * and the scratch while TF-M might number it differently. -- */ --int flash_area_id_from_multi_image_slot(int image_index, int slot) --{ -- switch (slot) { -- case 0: return BL1_FLASH_AREA_IMAGE_PRIMARY(image_index); -- case 1: return BL1_FLASH_AREA_IMAGE_SECONDARY(image_index); -- case 2: return BL1_FLASH_AREA_IMAGE_SCRATCH; -- } -- -- return -1; /* flash_area_open will fail on that */ --} -- --int flash_area_id_from_image_slot(int slot) --{ -- return flash_area_id_from_multi_image_slot(0, slot); --} -- --int flash_area_id_to_multi_image_slot(int image_index, int area_id) --{ -- if (area_id == BL1_FLASH_AREA_IMAGE_PRIMARY(image_index)) { -- return 0; -- } -- if (area_id == BL1_FLASH_AREA_IMAGE_SECONDARY(image_index)) { -- return 1; -- } -- -- BOOT_LOG_ERR("invalid flash area ID"); -- return -1; --} -- --int flash_area_id_to_image_slot(int area_id) --{ -- return flash_area_id_to_multi_image_slot(0, area_id); --} -- --uint8_t flash_area_erased_val(const struct flash_area *fap) --{ -- return DRV_FLASH_AREA(fap)->GetInfo()->erased_value; --} -- --int flash_area_read_is_empty(const struct flash_area *fa, uint32_t off, -- void *dst, uint32_t len) --{ -- uint32_t i; -- uint8_t *u8dst; -- int rc; -- -- BOOT_LOG_DBG("read_is_empty area=%d, off=%#x, len=%#x", -- fa->fa_id, off, len); -- -- rc = DRV_FLASH_AREA(fa)->ReadData(fa->fa_off + off, dst, len); -- if (rc) { -- return -1; -- } -- -- u8dst = (uint8_t*)dst; -- -- for (i = 0; i < len; i++) { -- if (u8dst[i] != flash_area_erased_val(fa)) { -- return 0; -- } -- } -- -- return 1; --} -diff --git a/platform/ext/target/arm/corstone1000/bl1/provisioning.c b/platform/ext/target/arm/corstone1000/bl1/provisioning.c -index 832fcea89..683bc45ea 100644 ---- a/platform/ext/target/arm/corstone1000/bl1/provisioning.c -+++ b/platform/ext/target/arm/corstone1000/bl1/provisioning.c -@@ -1,5 +1,5 @@ - /* -- * Copyright (c) 2021-2022, Arm Limited. All rights reserved. -+ * Copyright (c) 2021-2023, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - * -@@ -11,7 +11,9 @@ - #include "tfm_plat_otp.h" - #include "tfm_attest_hal.h" - #include "psa/crypto.h" --#include "bootutil/bootutil_log.h" -+#include "region_defs.h" -+#include "log.h" -+#include "fwu_agent.h" - - #include <string.h> - -@@ -19,51 +21,20 @@ - - __PACKED_STRUCT bl1_assembly_and_test_provisioning_data_t { - uint32_t magic; -- uint8_t bl1_rotpk_0[32]; -+ uint8_t bl2_encryption_key[32]; -+ uint8_t guk[32]; -+ uint8_t bl1_2_image_hash[32]; -+ uint8_t bl2_image_hash[32]; -+ uint8_t bl1_2_image[BL1_2_CODE_SIZE]; -+ uint8_t bl1_rotpk_0[56]; - }; - --#ifdef TFM_DUMMY_PROVISIONING --static const struct bl1_assembly_and_test_provisioning_data_t bl1_assembly_and_test_prov_data = { -- ASSEMBLY_AND_TEST_PROV_DATA_MAGIC, --#if (MCUBOOT_SIGN_RSA_LEN == 2048) -- /* bl1 rotpk 0 */ -- { -- 0xfc, 0x57, 0x01, 0xdc, 0x61, 0x35, 0xe1, 0x32, -- 0x38, 0x47, 0xbd, 0xc4, 0x0f, 0x04, 0xd2, 0xe5, -- 0xbe, 0xe5, 0x83, 0x3b, 0x23, 0xc2, 0x9f, 0x93, -- 0x59, 0x3d, 0x00, 0x01, 0x8c, 0xfa, 0x99, 0x94, -- }, --#elif (MCUBOOT_SIGN_RSA_LEN == 3072) -- /* bl1 rotpk 0 */ -- { -- 0xbf, 0xe6, 0xd8, 0x6f, 0x88, 0x26, 0xf4, 0xff, -- 0x97, 0xfb, 0x96, 0xc4, 0xe6, 0xfb, 0xc4, 0x99, -- 0x3e, 0x46, 0x19, 0xfc, 0x56, 0x5d, 0xa2, 0x6a, -- 0xdf, 0x34, 0xc3, 0x29, 0x48, 0x9a, 0xdc, 0x38, -- }, --#else --#error "No public key available for given signing algorithm." --#endif /* MCUBOOT_SIGN_RSA_LEN */ --}; --#else --static const struct bl1_assembly_and_test_provisioning_data_t bl1_assembly_and_test_prov_data; --#endif /* TFM_DUMMY_PROVISIONING */ -+static const struct bl1_assembly_and_test_provisioning_data_t *bl1_assembly_and_test_prov_data = -+ (struct bl1_assembly_and_test_provisioning_data_t *)PROVISIONING_DATA_START; -+ - - void tfm_plat_provisioning_check_for_dummy_keys(void) - { -- uint64_t iak_start; -- -- tfm_plat_otp_read(PLAT_OTP_ID_IAK, sizeof(iak_start), (uint8_t*)&iak_start); -- -- if(iak_start == 0xA4906F6DB254B4A9) { -- BOOT_LOG_WRN("%s%s%s%s", -- "\033[1;31m", -- "This device was provisioned with dummy keys. ", -- "This device is \033[1;1mNOT SECURE", -- "\033[0m"); -- } -- -- memset(&iak_start, 0, sizeof(iak_start)); - } - - int tfm_plat_provisioning_is_required(void) -@@ -85,12 +56,47 @@ enum tfm_plat_err_t provision_assembly_and_test(void) - enum tfm_plat_err_t err; - - err = tfm_plat_otp_write(PLAT_OTP_ID_BL1_ROTPK_0, -- sizeof(bl1_assembly_and_test_prov_data.bl1_rotpk_0), -- bl1_assembly_and_test_prov_data.bl1_rotpk_0); -+ sizeof(bl1_assembly_and_test_prov_data->bl1_rotpk_0), -+ bl1_assembly_and_test_prov_data->bl1_rotpk_0); -+ if (err != TFM_PLAT_ERR_SUCCESS && err != TFM_PLAT_ERR_UNSUPPORTED) { -+ return err; -+ } -+ -+ -+ err = tfm_plat_otp_write(PLAT_OTP_ID_BL1_2_IMAGE_HASH, -+ sizeof(bl1_assembly_and_test_prov_data->bl1_2_image_hash), -+ bl1_assembly_and_test_prov_data->bl1_2_image_hash); -+ if (err != TFM_PLAT_ERR_SUCCESS && err != TFM_PLAT_ERR_UNSUPPORTED) { -+ return err; -+ } -+ -+ -+ err = tfm_plat_otp_write(PLAT_OTP_ID_BL1_2_IMAGE, -+ sizeof(bl1_assembly_and_test_prov_data->bl1_2_image), -+ bl1_assembly_and_test_prov_data->bl1_2_image); -+ if (err != TFM_PLAT_ERR_SUCCESS && err != TFM_PLAT_ERR_UNSUPPORTED) { -+ return err; -+ } -+ -+ err = tfm_plat_otp_write(PLAT_OTP_ID_KEY_BL2_ENCRYPTION, -+ sizeof(bl1_assembly_and_test_prov_data->bl2_encryption_key), -+ bl1_assembly_and_test_prov_data->bl2_encryption_key); - if (err != TFM_PLAT_ERR_SUCCESS && err != TFM_PLAT_ERR_UNSUPPORTED) { - return err; - } - -+ err = tfm_plat_otp_write(PLAT_OTP_ID_BL2_IMAGE_HASH, -+ sizeof(bl1_assembly_and_test_prov_data->bl2_image_hash), -+ bl1_assembly_and_test_prov_data->bl2_image_hash); -+ if (err != TFM_PLAT_ERR_SUCCESS && err != TFM_PLAT_ERR_UNSUPPORTED) { -+ return err; -+ } -+ -+ err = fwu_metadata_provision(); -+ if (err != FWU_AGENT_SUCCESS) { -+ return 1; -+ } -+ - return err; - } - -@@ -104,19 +110,18 @@ enum tfm_plat_err_t tfm_plat_provisioning_perform(void) - return err; - } - -- BOOT_LOG_INF("Beginning BL1 provisioning"); -+ BL1_LOG("[INF] Beginning BL1 provisioning\r\n"); - - #ifdef TFM_DUMMY_PROVISIONING -- BOOT_LOG_WRN("%s%s%s%s", -- "\033[1;31m", -- "TFM_DUMMY_PROVISIONING is not suitable for production! ", -- "This device is \033[1;1mNOT SECURE", -- "\033[0m"); -+ BL1_LOG("\033[1;31m[WRN]"); -+ BL1_LOG("TFM_DUMMY_PROVISIONING is not suitable for production! "); -+ BL1_LOG("This device is \033[1;1mNOT SECURE"); -+ BL1_LOG("\033[0m\r\n"); - #endif /* TFM_DUMMY_PROVISIONING */ - - if (lcs == PLAT_OTP_LCS_ASSEMBLY_AND_TEST) { -- if (bl1_assembly_and_test_prov_data.magic != ASSEMBLY_AND_TEST_PROV_DATA_MAGIC) { -- BOOT_LOG_ERR("No valid ASSEMBLY_AND_TEST provisioning data found"); -+ if (bl1_assembly_and_test_prov_data->magic != ASSEMBLY_AND_TEST_PROV_DATA_MAGIC) { -+ BL1_LOG("[ERR] No valid ASSEMBLY_AND_TEST provisioning data found\r\n"); - return TFM_PLAT_ERR_INVALID_INPUT; - } - -diff --git a/platform/ext/target/arm/corstone1000/config.cmake b/platform/ext/target/arm/corstone1000/config.cmake -index aca75394d..1b0675404 100644 ---- a/platform/ext/target/arm/corstone1000/config.cmake -+++ b/platform/ext/target/arm/corstone1000/config.cmake -@@ -8,7 +8,14 @@ - #------------------------------------------------------------------------------- - - set(BL1 ON CACHE BOOL "Whether to build BL1") --set(PLATFORM_DEFAULT_BL1 OFF CACHE STRING "Whether to use default BL1 or platform-specific one") -+set(PLATFORM_DEFAULT_BL1 ON CACHE STRING "Whether to use default BL1 or platform-specific one") -+set(PLATFORM_DEFAULT_OTP OFF CACHE BOOL "Use trusted on-chip flash to implement OTP memory") -+ -+set(TFM_BL1_DEFAULT_PROVISIONING OFF CACHE BOOL "Whether BL1_1 will use default provisioning") -+set(TFM_BL1_SOFTWARE_CRYPTO OFF CACHE BOOL "Whether BL1_1 will use software crypto") -+set(TFM_BL1_MEMORY_MAPPED_FLASH OFF CACHE BOOL "Whether BL1 can directly access flash content") -+set(TFM_BL1_PQ_CRYPTO OFF CACHE BOOL "Enable LMS PQ crypto for BL2 verification. This is experimental and should not yet be used in production") -+ - set(BL2 ON CACHE BOOL "Whether to build BL2") - set(BL2_TRAILER_SIZE 0x800 CACHE STRING "Trailer size") - set(DEFAULT_MCUBOOT_FLASH_MAP OFF CACHE BOOL "Whether to use the default flash map defined by TF-M project") -@@ -26,13 +33,6 @@ set(TFM_CRYPTO_TEST_ALG_CFB OFF CACHE BOOL "Test CFB cryp - set(NS FALSE CACHE BOOL "Whether to build NS app") - set(EXTERNAL_SYSTEM_SUPPORT OFF CACHE BOOL "Whether to include external system support.") - --# FVP is not integrated/tested with CC312. --if (${PLATFORM_IS_FVP}) -- set(PLATFORM_DEFAULT_OTP TRUE CACHE BOOL "Use trusted on-chip flash to implement OTP memory") --else() -- set(PLATFORM_DEFAULT_OTP FALSE CACHE BOOL "Use trusted on-chip flash to implement OTP memory") --endif() -- - # External dependency on OpenAMP and Libmetal - set(LIBMETAL_SRC_PATH "DOWNLOAD" CACHE PATH "Path to Libmetal (or DOWNLOAD to fetch automatically") - set(LIBMETAL_VERSION "f252f0e007fbfb8b3a52b1d5901250ddac96baad" CACHE STRING "The version of libmetal to use") -@@ -59,6 +59,8 @@ set(TFM_PARTITION_PROTECTED_STORAGE ON CACHE BOOL "Enable Prot - set(TFM_PARTITION_CRYPTO ON CACHE BOOL "Enable Crypto partition") - set(TFM_PARTITION_INITIAL_ATTESTATION ON CACHE BOOL "Enable Initial Attestation partition") - set(TFM_PARTITION_INTERNAL_TRUSTED_STORAGE ON CACHE BOOL "Enable Internal Trusted Storage partition") -+set(TFM_PARTITION_MEASURED_BOOT ON CACHE BOOL "Enable Measured boot partition") -+ - - if (${CMAKE_BUILD_TYPE} STREQUAL Debug OR ${CMAKE_BUILD_TYPE} STREQUAL RelWithDebInfo) - set(ENABLE_FWU_AGENT_DEBUG_LOGS TRUE CACHE BOOL "Enable Firmware update agent debug logs.") -diff --git a/platform/ext/target/arm/corstone1000/partition/flash_layout.h b/platform/ext/target/arm/corstone1000/partition/flash_layout.h -index b01a3621b..a95ff63ef 100644 ---- a/platform/ext/target/arm/corstone1000/partition/flash_layout.h -+++ b/platform/ext/target/arm/corstone1000/partition/flash_layout.h -@@ -34,16 +34,6 @@ - - #define BL2_DATA_GAP_SIZE (0x09800) /* 38 KB */ - --#define BL1_DATA_START (SRAM_BASE) --#define BL1_DATA_SIZE (0x10000) /* 64 KiB*/ --#define BL1_DATA_LIMIT (BL1_DATA_START + BL1_DATA_SIZE - 1) -- --#ifdef BL1 -- --#define IMAGE_EXECUTABLE_RAM_START (SRAM_BASE + BL1_DATA_SIZE) --#define IMAGE_EXECUTABLE_RAM_SIZE (SRAM_SIZE - BL1_DATA_SIZE) -- --#endif /* BL1 */ - - /*****************/ - /***** Flash *****/ -diff --git a/platform/ext/target/arm/corstone1000/partition/region_defs.h b/platform/ext/target/arm/corstone1000/partition/region_defs.h -index 35055fe9c..8157c36bf 100644 ---- a/platform/ext/target/arm/corstone1000/partition/region_defs.h -+++ b/platform/ext/target/arm/corstone1000/partition/region_defs.h -@@ -20,12 +20,17 @@ - - #include "flash_layout.h" - -+/* BL1_1 */ -+#define BL1_1_HEAP_SIZE (0x0001000) /* 4KiB */ -+#define BL1_1_MSP_STACK_SIZE (0x0001800) /* 6KiB */ -+ -+/* BL1_2 */ -+#define BL1_2_HEAP_SIZE (0x0001000) /* 4KiB */ -+#define BL1_2_MSP_STACK_SIZE (0x0001800) /* 6KiB */ -+ - #define BL2_HEAP_SIZE (0x0001000) - #define BL2_MSP_STACK_SIZE (0x0001E00) - --#define BL1_HEAP_SIZE (0x0001000) --#define BL1_MSP_STACK_SIZE (0x0001800) -- - #ifdef ENABLE_HEAP - #define S_HEAP_SIZE (0x0000200) - #endif -@@ -80,8 +85,8 @@ - - - /* SE BL2 regions */ --#define BL2_CODE_START (SRAM_BASE + TFM_PARTITION_SIZE + \ -- BL2_DATA_GAP_SIZE + BL2_HEADER_SIZE) -+#define BL2_IMAGE_START (SRAM_BASE + SRAM_SIZE - SE_BL2_PARTITION_SIZE) -+#define BL2_CODE_START (BL2_IMAGE_START + BL2_HEADER_SIZE) - #define BL2_CODE_SIZE (IMAGE_BL2_CODE_SIZE) - #define BL2_CODE_LIMIT (BL2_CODE_START + BL2_CODE_SIZE - 1) - -@@ -91,9 +96,25 @@ - #define BL2_DATA_LIMIT (BL2_DATA_START + BL2_DATA_SIZE - 1) - - /* SE BL1 regions */ --#define BL1_CODE_START (0) --#define BL1_CODE_SIZE (0x00020000) /* Whole SE ROM, 128 KiB */ --#define BL1_CODE_LIMIT (BL2_CODE_START + BL2_CODE_SIZE - 1) -+#define BL1_1_CODE_START (0) -+#define BL1_1_CODE_SIZE (0x0000A000) /* 40 KiB */ -+#define BL1_1_CODE_LIMIT (BL1_1_CODE_START + BL1_1_CODE_SIZE - 1) -+ -+#define PROVISIONING_DATA_START (BL1_1_CODE_START + BL1_1_CODE_SIZE) -+#define PROVISIONING_DATA_SIZE (0x00002000) /* 8 KiB */ -+#define PROVISIONING_DATA_LIMIT (PROVISIONING_DATA_START + PROVISIONING_DATA_SIZE - 1) -+ -+#define BL1_1_DATA_START (SRAM_BASE) -+#define BL1_1_DATA_SIZE (0x8000) /* 32 KiB*/ -+#define BL1_1_DATA_LIMIT (BL1_1_DATA_START + BL1_1_DATA_SIZE - 1) -+ -+#define BL1_2_CODE_START (BL1_1_DATA_START + BL1_1_DATA_SIZE) -+#define BL1_2_CODE_SIZE (0x00001000) /* 4 KiB */ -+#define BL1_2_CODE_LIMIT (BL1_2_CODE_START + BL1_2_CODE_SIZE - 1) -+ -+#define BL1_2_DATA_START (BL1_2_CODE_START+BL1_2_CODE_SIZE) -+#define BL1_2_DATA_SIZE (0x8000) /* 32 KiB*/ -+#define BL1_2_DATA_LIMIT (BL1_2_DATA_START + BL1_2_DATA_SIZE - 1) - - #define BOOT_TFM_SHARED_DATA_BASE (S_DATA_PRIV_START) - --- -2.17.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/rwx.patch b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0004-arm-trusted-firmware-m-disable-fatal-warnings.patch index 1efd661827..07db4f6d59 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/rwx.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0004-arm-trusted-firmware-m-disable-fatal-warnings.patch @@ -1,4 +1,4 @@ -From 1d548c77d07fc9a83e3e9aa28a23aa19a0177e3b Mon Sep 17 00:00:00 2001 +From 04ce07d289e8cec75223349e9ebf7e69126fc04d Mon Sep 17 00:00:00 2001 From: Jon Mason <jon.mason@arm.com> Date: Wed, 18 Jan 2023 15:13:37 -0500 Subject: [PATCH] arm/trusted-firmware-m: disable fatal warnings @@ -11,7 +11,7 @@ Upstream-Status: Inappropriate 1 file changed, 1 deletion(-) diff --git a/toolchain_GNUARM.cmake b/toolchain_GNUARM.cmake -index 7978eaca68..88395f922a 100644 +index 7989718515..a5939323d6 100644 --- a/toolchain_GNUARM.cmake +++ b/toolchain_GNUARM.cmake @@ -71,7 +71,6 @@ macro(tfm_toolchain_reset_linker_flags) @@ -22,4 +22,3 @@ index 7978eaca68..88395f922a 100644 LINKER:--gc-sections LINKER:--no-wchar-size-warning ${MEMORY_USAGE_FLAG} - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0005-Platform-corstone1000-Replace-MCUBOOT-BL1-by-TFM-s-B.patch b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0005-Platform-corstone1000-Replace-MCUBOOT-BL1-by-TFM-s-B.patch deleted file mode 100644 index 697061e2d9..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0005-Platform-corstone1000-Replace-MCUBOOT-BL1-by-TFM-s-B.patch +++ /dev/null @@ -1,202 +0,0 @@ -From d5a7cde4648d2247f83a0f259aa088152199dfbd Mon Sep 17 00:00:00 2001 -From: Emekcan Aras <emekcan.aras@arm.com> -Date: Mon, 27 Feb 2023 20:58:30 +0000 -Subject: [PATCH 2/6] Platform: corstone1000: Replace MCUBOOT BL1 by TFM's - (BL2) - -From: Mohamed Omar Asaker <mohamed.omarasaker@arm.com> - -Set region_defs of BL2 correctly -Set FLASH Areas 0 and 1 to have BL2 -Set FLASH Areas 2 and 3 to have TFM -Set FLASH Areas 4 and 5 to have FIP -Initialize FLASH in BL1_2 boot platform code - -Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20554] -Signed-off-by: Mohamed Omar Asaker <mohamed.omarasaker@arm.com> -Change-Id: I987d29cb6318b8b30cafab67d24f446aaadfe500 ---- - .../arm/corstone1000/bl1/boot_hal_bl1.c | 14 +++++++ - .../target/arm/corstone1000/bl2_flash_map.c | 8 ++-- - .../ext/target/arm/corstone1000/config.cmake | 3 ++ - .../arm/corstone1000/partition/flash_layout.h | 41 +++++++++++++------ - .../arm/corstone1000/partition/region_defs.h | 4 +- - 5 files changed, 51 insertions(+), 19 deletions(-) - -diff --git a/platform/ext/target/arm/corstone1000/bl1/boot_hal_bl1.c b/platform/ext/target/arm/corstone1000/bl1/boot_hal_bl1.c -index 678342443..2124720b2 100644 ---- a/platform/ext/target/arm/corstone1000/bl1/boot_hal_bl1.c -+++ b/platform/ext/target/arm/corstone1000/bl1/boot_hal_bl1.c -@@ -638,6 +638,13 @@ int32_t boot_platform_init(void) - - int32_t boot_platform_post_init(void) - { -+ int32_t result; -+ if (platform_code_is_bl1_2) { -+ result = FLASH_DEV_NAME.Initialize(NULL); -+ if (result != ARM_DRIVER_OK) { -+ return 1; -+ } -+ } - return 0; - } - -@@ -665,6 +672,13 @@ void boot_platform_quit(struct boot_arm_vector_table *vt) - stdio_uninit(); - #endif /* defined(TFM_BL1_LOGGING) || defined(TEST_BL1_1) || defined(TEST_BL1_2) */ - -+ if (platform_code_is_bl1_2) { -+ result = FLASH_DEV_NAME.Uninitialize(); -+ if (result != ARM_DRIVER_OK) { -+ return 1; -+ } -+ } -+ - result = corstone1000_watchdog_reset_timer(); - if (result != ARM_DRIVER_OK) { - while (1); -diff --git a/platform/ext/target/arm/corstone1000/bl2_flash_map.c b/platform/ext/target/arm/corstone1000/bl2_flash_map.c -index 599f80b41..2b1cdfa19 100644 ---- a/platform/ext/target/arm/corstone1000/bl2_flash_map.c -+++ b/platform/ext/target/arm/corstone1000/bl2_flash_map.c -@@ -25,14 +25,14 @@ extern ARM_DRIVER_FLASH FLASH_DEV_NAME; - */ - struct flash_area flash_map[] = { - { -- .fa_id = FLASH_AREA_0_ID, -+ .fa_id = FLASH_AREA_2_ID, - .fa_device_id = FLASH_DEVICE_ID, - .fa_driver = &FLASH_DEV_NAME, - .fa_off = FLASH_INVALID_OFFSET, - .fa_size = FLASH_INVALID_SIZE, - }, - { -- .fa_id = FLASH_AREA_1_ID, -+ .fa_id = FLASH_AREA_3_ID, - .fa_device_id = FLASH_DEVICE_ID, - .fa_driver = &FLASH_DEV_NAME, - .fa_off = FLASH_INVALID_OFFSET, -@@ -40,14 +40,14 @@ struct flash_area flash_map[] = { - }, - #ifndef TFM_S_REG_TEST - { -- .fa_id = FLASH_AREA_2_ID, -+ .fa_id = FLASH_AREA_4_ID, - .fa_device_id = FLASH_DEVICE_ID, - .fa_driver = &FLASH_DEV_NAME, - .fa_off = FLASH_INVALID_OFFSET, - .fa_size = FLASH_INVALID_SIZE, - }, - { -- .fa_id = FLASH_AREA_3_ID, -+ .fa_id = FLASH_AREA_5_ID, - .fa_device_id = FLASH_DEVICE_ID, - .fa_driver = &FLASH_DEV_NAME, - .fa_off = FLASH_INVALID_OFFSET, -diff --git a/platform/ext/target/arm/corstone1000/config.cmake b/platform/ext/target/arm/corstone1000/config.cmake -index 1b0675404..bec6b84f0 100644 ---- a/platform/ext/target/arm/corstone1000/config.cmake -+++ b/platform/ext/target/arm/corstone1000/config.cmake -@@ -16,6 +16,9 @@ set(TFM_BL1_SOFTWARE_CRYPTO OFF CACHE BOOL "Whether BL1_1 - set(TFM_BL1_MEMORY_MAPPED_FLASH OFF CACHE BOOL "Whether BL1 can directly access flash content") - set(TFM_BL1_PQ_CRYPTO OFF CACHE BOOL "Enable LMS PQ crypto for BL2 verification. This is experimental and should not yet be used in production") - -+set(TFM_BL2_IMAGE_FLASH_AREA_NUM 0 CACHE STRING "Which flash area BL2 is stored in") -+set(MCUBOOT_S_IMAGE_FLASH_AREA_NUM 2 CACHE STRING "ID of the flash area containing the primary Secure image") -+ - set(BL2 ON CACHE BOOL "Whether to build BL2") - set(BL2_TRAILER_SIZE 0x800 CACHE STRING "Trailer size") - set(DEFAULT_MCUBOOT_FLASH_MAP OFF CACHE BOOL "Whether to use the default flash map defined by TF-M project") -diff --git a/platform/ext/target/arm/corstone1000/partition/flash_layout.h b/platform/ext/target/arm/corstone1000/partition/flash_layout.h -index a95ff63ef..41b4c6323 100644 ---- a/platform/ext/target/arm/corstone1000/partition/flash_layout.h -+++ b/platform/ext/target/arm/corstone1000/partition/flash_layout.h -@@ -136,23 +136,38 @@ - #define BANK_PARTITION_SIZE (0xFE0000) /* 15.875 MB */ - #define TFM_PARTITION_SIZE (0x5E000) /* 376 KB */ - --/* Macros needed to imgtool.py, used when creating BL2 signed image */ --#define BL2_IMAGE_LOAD_ADDRESS (SRAM_BASE + TFM_PARTITION_SIZE + BL2_DATA_GAP_SIZE) --#define BL2_IMAGE_OFFSET (0x0) --#define BL2_IMAGE_MAX_SIZE (SE_BL2_PARTITION_SIZE) -+/************************************************************/ -+/* Bank : Images flash offsets are with respect to the bank */ -+/************************************************************/ - --/* Image 1: TF-M primary and secondary images */ -+/* Image 0: BL2 primary and secondary images */ - #define FLASH_AREA_0_ID (1) --#define FLASH_AREA_0_SIZE (TFM_PARTITION_SIZE) -+#define FLASH_AREA_0_OFFSET (0) /* starting from 0th offset of the bank */ -+#define FLASH_AREA_0_SIZE (SE_BL2_PARTITION_SIZE) -+ - #define FLASH_AREA_1_ID (FLASH_AREA_0_ID + 1) --#define FLASH_AREA_1_SIZE (TFM_PARTITION_SIZE) -+#define FLASH_AREA_1_OFFSET (FLASH_AREA_0_OFFSET + FLASH_AREA_0_SIZE) -+#define FLASH_AREA_1_SIZE (SE_BL2_PARTITION_SIZE) -+ -+/* Image 1: TF-M primary and secondary images */ -+#define FLASH_AREA_2_ID (1) -+#define FLASH_AREA_2_SIZE (TFM_PARTITION_SIZE) -+#define FLASH_AREA_3_ID (FLASH_AREA_2_ID + 1) -+#define FLASH_AREA_3_SIZE (TFM_PARTITION_SIZE) - - /* Image 2: Host FIP */ - #define FIP_SIGNATURE_AREA_SIZE (0x1000) /* 4 KB */ - - /* Host BL2 (TF-A) primary and secondary image. */ --#define FLASH_AREA_2_ID (FLASH_AREA_1_ID + 1) --#define FLASH_AREA_3_ID (FLASH_AREA_2_ID + 1) -+#define FLASH_AREA_4_ID (FLASH_AREA_3_ID + 1) -+#define FLASH_AREA_5_ID (FLASH_AREA_4_ID + 1) -+ -+#define BL1_FLASH_AREA_IMAGE_PRIMARY(x) (((x) == 0) ? FLASH_AREA_0_ID : \ -+ 255 ) -+#define BL1_FLASH_AREA_IMAGE_SECONDARY(x) (((x) == 0) ? FLASH_AREA_1_ID : \ -+ 255 ) -+ -+#define BL1_FLASH_AREA_IMAGE_SCRATCH 255 - - /* Macros needed to imgtool.py, used when creating TF-M signed image */ - #define S_IMAGE_LOAD_ADDRESS (SRAM_BASE) -@@ -161,11 +176,11 @@ - #define NON_SECURE_IMAGE_OFFSET (TFM_PARTITION_SIZE) - #define NON_SECURE_IMAGE_MAX_SIZE (0x0) - --#define FLASH_AREA_IMAGE_PRIMARY(x) (((x) == 0) ? FLASH_AREA_0_ID : \ -- ((x) == 1) ? FLASH_AREA_2_ID : \ -+#define FLASH_AREA_IMAGE_PRIMARY(x) (((x) == 0) ? FLASH_AREA_2_ID : \ -+ ((x) == 1) ? FLASH_AREA_4_ID : \ - 255 ) --#define FLASH_AREA_IMAGE_SECONDARY(x) (((x) == 0) ? FLASH_AREA_1_ID : \ -- ((x) == 1) ? FLASH_AREA_3_ID : \ -+#define FLASH_AREA_IMAGE_SECONDARY(x) (((x) == 0) ? FLASH_AREA_3_ID : \ -+ ((x) == 1) ? FLASH_AREA_5_ID : \ - 255 ) - - #define FLASH_AREA_IMAGE_SCRATCH 255 -diff --git a/platform/ext/target/arm/corstone1000/partition/region_defs.h b/platform/ext/target/arm/corstone1000/partition/region_defs.h -index 8157c36bf..fc9f734f6 100644 ---- a/platform/ext/target/arm/corstone1000/partition/region_defs.h -+++ b/platform/ext/target/arm/corstone1000/partition/region_defs.h -@@ -48,7 +48,7 @@ - (TFM_PARTITION_SIZE - BL2_HEADER_SIZE - BL2_TRAILER_SIZE) - - #define IMAGE_BL2_CODE_SIZE \ -- (SE_BL2_PARTITION_SIZE - BL2_HEADER_SIZE - BL2_TRAILER_SIZE) -+ (SE_BL2_PARTITION_SIZE - BL1_HEADER_SIZE - BL1_TRAILER_SIZE) - - /* Secure regions */ - #define S_CODE_START (SRAM_BASE + BL2_HEADER_SIZE) -@@ -86,7 +86,7 @@ - - /* SE BL2 regions */ - #define BL2_IMAGE_START (SRAM_BASE + SRAM_SIZE - SE_BL2_PARTITION_SIZE) --#define BL2_CODE_START (BL2_IMAGE_START + BL2_HEADER_SIZE) -+#define BL2_CODE_START (BL2_IMAGE_START + BL1_HEADER_SIZE) - #define BL2_CODE_SIZE (IMAGE_BL2_CODE_SIZE) - #define BL2_CODE_LIMIT (BL2_CODE_START + BL2_CODE_SIZE - 1) - --- -2.17.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0006-Platform-corstone1000-Reorganize-bl2-files.patch b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0006-Platform-corstone1000-Reorganize-bl2-files.patch deleted file mode 100644 index 1e56e363d4..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0006-Platform-corstone1000-Reorganize-bl2-files.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 535d366137d2dd0804d3e67ada78151e0e318eeb Mon Sep 17 00:00:00 2001 -From: Emekcan Aras <emekcan.aras@arm.com> -Date: Fri, 3 Mar 2023 12:25:04 +0000 -Subject: [PATCH 3/6] Platform: corstone1000: Reorganize bl2 files - -From: Mohamed Omar Asaker <mohamed.omarasaker@arm.com> - -To be consistnant, organize bl2 files same as bl1 files - -Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20555] -Signed-off-by: Mohamed Omar Asaker <mohamed.omarasaker@arm.com> -Change-Id: I3332f4dbbde1c5f2cde5a187b038dc3430b9503f ---- - platform/ext/target/arm/corstone1000/CMakeLists.txt | 6 +++--- - .../ext/target/arm/corstone1000/{ => bl2}/boot_hal_bl2.c | 0 - .../corstone1000/{bl2_flash_map.c => bl2/flash_map_bl2.c} | 0 - .../{bl2_security_cnt.c => bl2/security_cnt_bl2.c} | 0 - 4 files changed, 3 insertions(+), 3 deletions(-) - rename platform/ext/target/arm/corstone1000/{ => bl2}/boot_hal_bl2.c (100%) - rename platform/ext/target/arm/corstone1000/{bl2_flash_map.c => bl2/flash_map_bl2.c} (100%) - rename platform/ext/target/arm/corstone1000/{bl2_security_cnt.c => bl2/security_cnt_bl2.c} (100%) - -diff --git a/platform/ext/target/arm/corstone1000/CMakeLists.txt b/platform/ext/target/arm/corstone1000/CMakeLists.txt -index a4fe28c08..3d4c787a6 100644 ---- a/platform/ext/target/arm/corstone1000/CMakeLists.txt -+++ b/platform/ext/target/arm/corstone1000/CMakeLists.txt -@@ -196,7 +196,7 @@ target_sources(platform_bl2 - Native_Driver/arm_watchdog_drv.c - fip_parser/fip_parser.c - fw_update_agent/fwu_agent.c -- bl2_security_cnt.c -+ bl2/security_cnt_bl2.c - $<$<NOT:$<BOOL:${PLATFORM_DEFAULT_OTP}>>:${PLATFORM_DIR}/ext/accelerator/cc312/otp_cc312.c> - io/io_block.c - io/io_flash.c -@@ -235,8 +235,8 @@ target_compile_definitions(platform_bl2 - # platform_init/quit* apis symbol collision in bl1. - target_sources(bl2 - PRIVATE -- bl2_flash_map.c -- boot_hal_bl2.c -+ bl2/flash_map_bl2.c -+ bl2/boot_hal_bl2.c - ) - - target_link_libraries(bl2 -diff --git a/platform/ext/target/arm/corstone1000/boot_hal_bl2.c b/platform/ext/target/arm/corstone1000/bl2/boot_hal_bl2.c -similarity index 100% -rename from platform/ext/target/arm/corstone1000/boot_hal_bl2.c -rename to platform/ext/target/arm/corstone1000/bl2/boot_hal_bl2.c -diff --git a/platform/ext/target/arm/corstone1000/bl2_flash_map.c b/platform/ext/target/arm/corstone1000/bl2/flash_map_bl2.c -similarity index 100% -rename from platform/ext/target/arm/corstone1000/bl2_flash_map.c -rename to platform/ext/target/arm/corstone1000/bl2/flash_map_bl2.c -diff --git a/platform/ext/target/arm/corstone1000/bl2_security_cnt.c b/platform/ext/target/arm/corstone1000/bl2/security_cnt_bl2.c -similarity index 100% -rename from platform/ext/target/arm/corstone1000/bl2_security_cnt.c -rename to platform/ext/target/arm/corstone1000/bl2/security_cnt_bl2.c --- -2.17.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0007-Platform-corstone1000-Fix-linker-script-comment.patch b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0007-Platform-corstone1000-Fix-linker-script-comment.patch deleted file mode 100644 index 62a9d85399..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0007-Platform-corstone1000-Fix-linker-script-comment.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 25b131f0d082b32b262c4e788f3bc95b7761bef7 Mon Sep 17 00:00:00 2001 -From: Emekcan Aras <emekcan.aras@arm.com> -Date: Mon, 13 Mar 2023 00:16:49 +0000 -Subject: [PATCH 4/6] Platform: corstone1000: Fix linker script comment - -From: Mohamed Omar Asaker <mohamed.omarasaker@arm.com> - -Comment explaining the necessary defines to copy multiple ROM to RAM -sections, was refering to the wrong file. - -Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20556] -Signed-off-by: Mohamed Omar Asaker <mohamed.omarasaker@arm.com> -Change-Id: I3e5f806330481daa24c5456d9c956e0cf589afee ---- - .../arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld | 2 +- - .../arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld b/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld -index d4eca2841..8ee334c6b 100644 ---- a/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld -+++ b/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld -@@ -89,7 +89,7 @@ SECTIONS - - /* To copy multiple ROM to RAM sections, - * define etext2/data2_start/data2_end and -- * define __STARTUP_COPY_MULTIPLE in startup_corstone700_bl2.S */ -+ * define __STARTUP_COPY_MULTIPLE in startup_corstone1000.c */ - .copy.table : - { - . = ALIGN(4); -diff --git a/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld b/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld -index 6cd806378..e1e4f2966 100644 ---- a/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld -+++ b/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld -@@ -84,7 +84,7 @@ SECTIONS - - /* To copy multiple ROM to RAM sections, - * define etext2/data2_start/data2_end and -- * define __STARTUP_COPY_MULTIPLE in startup_corstone700_bl2.S */ -+ * define __STARTUP_COPY_MULTIPLE in startup_corstone1000.c */ - .copy.table : - { - . = ALIGN(4); --- -2.17.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0008-Platform-corstone1000-Fix-linkerscripts-copyright-ye.patch b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0008-Platform-corstone1000-Fix-linkerscripts-copyright-ye.patch deleted file mode 100644 index 7f7f6ed083..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0008-Platform-corstone1000-Fix-linkerscripts-copyright-ye.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 7db7b197ec3f01163422450947540060d3cb0c17 Mon Sep 17 00:00:00 2001 -From: Mohamed Omar Asaker <mohamed.omarasaker@arm.com> -Date: Mon, 13 Mar 2023 00:21:44 +0000 -Subject: [PATCH 6/6] Platform: corstone1000: Fix linkerscripts copyright year - -set the copyright year to 2023 as these files are introduced in -2023. - -Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20557] -Signed-off-by: Mohamed Omar Asaker <mohamed.omarasaker@arm.com> -Change-Id: I293a4a380d5d1d59aba1e2ab17e0e5924664dbb4 ---- - .../arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld | 2 +- - .../arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld b/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld -index 8ee334c6b..cb6797f27 100644 ---- a/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld -+++ b/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld -@@ -1,5 +1,5 @@ - ;/* --; * Copyright (c) 2009-2022, Arm Limited. All rights reserved. -+; * Copyright (c) 2023, Arm Limited. All rights reserved. - ; * - ; * Licensed under the Apache License, Version 2.0 (the "License"); - ; * you may not use this file except in compliance with the License. -diff --git a/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld b/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld -index e1e4f2966..e66e54aa6 100644 ---- a/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld -+++ b/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld -@@ -1,5 +1,5 @@ - ;/* --; * Copyright (c) 2009-2022, Arm Limited. All rights reserved. -+; * Copyright (c) 2023, Arm Limited. All rights reserved. - ; * - ; * Licensed under the Apache License, Version 2.0 (the "License"); - ; * you may not use this file except in compliance with the License. --- diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0009-Platform-corstone1000-fix-flash-reading-issue-for-fi.patch b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0009-Platform-corstone1000-fix-flash-reading-issue-for-fi.patch deleted file mode 100644 index 5c0024b29e..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0009-Platform-corstone1000-fix-flash-reading-issue-for-fi.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 7914ec3f96dbb8228e791d9492cfc3651cf9deca Mon Sep 17 00:00:00 2001 -From: Emekcan Aras <emekcan.aras@arm.com> -Date: Wed, 5 Apr 2023 10:28:57 +0100 -Subject: [PATCH] Platform: corstone1000: Fix Flash reading issue for FIP data - -Fixes the flash reading issue since bl2 needs to read the data from -flash in XIP mode on FPGA (mps3). - -Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20558] -Signed-off-by: Emekcan Aras <emekcan.aras@arm.com> ---- - platform/ext/target/arm/corstone1000/bl2/boot_hal_bl2.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/platform/ext/target/arm/corstone1000/bl2/boot_hal_bl2.c b/platform/ext/target/arm/corstone1000/bl2/boot_hal_bl2.c -index cf6340c5a9..e4183c7a57 100644 ---- a/platform/ext/target/arm/corstone1000/bl2/boot_hal_bl2.c -+++ b/platform/ext/target/arm/corstone1000/bl2/boot_hal_bl2.c -@@ -89,6 +89,7 @@ static bool fill_flash_map_with_fip_data(uint8_t boot_index) { - - /* parse directly from flash using XIP mode */ - /* FIP is large so its not a good idea to load it in memory */ -+ Select_XIP_Mode_For_Shared_Flash(); - result = parse_fip_and_extract_tfa_info( - FLASH_BASE_ADDRESS + fip_offset + FIP_SIGNATURE_AREA_SIZE, fip_size, - &tfa_offset, &tfa_size); -@@ -96,7 +97,7 @@ static bool fill_flash_map_with_fip_data(uint8_t boot_index) { - BOOT_LOG_ERR("parse_fip_and_extract_tfa_info failed"); - return false; - } -- -+ Select_Write_Mode_For_Shared_Flash(); - flash_map[2].fa_off = fip_offset + FIP_SIGNATURE_AREA_SIZE + tfa_offset; - flash_map[2].fa_size = tfa_size; - flash_map[3].fa_off = flash_map[2].fa_off + flash_map[2].fa_size; --- -2.17.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0010-Platform-corstone1000-Adds-compiler-flags-to-FWU-age.patch b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0010-Platform-corstone1000-Adds-compiler-flags-to-FWU-age.patch deleted file mode 100644 index 29fce5eb65..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0010-Platform-corstone1000-Adds-compiler-flags-to-FWU-age.patch +++ /dev/null @@ -1,273 +0,0 @@ -From 11f6af40dc322630031511146763cc9059bdb805 Mon Sep 17 00:00:00 2001 -From: Emekcan Aras <emekcan.aras@arm.com> -Date: Fri, 14 Apr 2023 16:35:55 +0100 -Subject: [PATCH] Platform: corstone1000: Adds compiler flags to FWU agent for - BL1 - -Adds compiler flags for BL1 to fwu_agent.c functions to not use GPT parser and -IO libraries in BL1 rom code. - -Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20559] -Signed-off-by: Emekcan Aras <emekcan.aras@arm.com> ---- - .../corstone1000/fw_update_agent/fwu_agent.c | 176 +++++++++++++++++- - 1 file changed, 174 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 8ecb03d157..afd8d66e42 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 -@@ -14,8 +14,6 @@ - #include "region_defs.h" - #include "uefi_capsule_parser.h" - #include "flash_common.h" --#include "partition.h" --#include "platform.h" - #include "platform_base_address.h" - #include "platform_description.h" - #include "tfm_plat_nv_counters.h" -@@ -23,6 +21,10 @@ - #include "uefi_fmp.h" - #include "uart_stdout.h" - #include "soft_crc.h" -+#if !BL1 -+#include "partition.h" -+#include "platform.h" -+#endif - - /* Properties of image in a bank */ - struct fwu_image_properties { -@@ -145,6 +147,30 @@ extern ARM_DRIVER_FLASH FWU_METADATA_FLASH_DEV; - - #define HOST_ACK_TIMEOUT_SEC (6 * 60) /* ~seconds, not exact */ - -+#if BL1 -+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_METADATA_REPLICA_1_OFFSET, p_metadata, -+ sizeof(struct fwu_private_metadata)); -+ if (ret < 0 || ret != sizeof(struct fwu_private_metadata)) { -+ return FWU_AGENT_ERROR; -+ } -+ -+ FWU_LOG_MSG("%s: success: boot_index = %u\n\r", __func__, -+ p_metadata->boot_index); -+ -+ return FWU_AGENT_SUCCESS; -+} -+#elif - static enum fwu_agent_error_t private_metadata_read( - struct fwu_private_metadata* p_metadata) - { -@@ -175,7 +201,36 @@ static enum fwu_agent_error_t private_metadata_read( - - return FWU_AGENT_SUCCESS; - } -+#endif - -+#if BL1 -+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_METADATA_REPLICA_1_OFFSET); -+ if (ret != ARM_DRIVER_OK) { -+ return FWU_AGENT_ERROR; -+ } -+ -+ ret = FWU_METADATA_FLASH_DEV.ProgramData(FWU_PRIVATE_METADATA_REPLICA_1_OFFSET, -+ p_metadata, sizeof(struct fwu_private_metadata)); -+ if (ret < 0 || ret != sizeof(struct fwu_private_metadata)) { -+ return FWU_AGENT_ERROR; -+ } -+ -+ FWU_LOG_MSG("%s: success\n\r", __func__); -+ return FWU_AGENT_SUCCESS; -+} -+#elif - static enum fwu_agent_error_t private_metadata_write( - struct fwu_private_metadata* p_metadata) - { -@@ -210,6 +265,7 @@ static enum fwu_agent_error_t private_metadata_write( - FWU_LOG_MSG("%s: success\n\r", __func__); - return FWU_AGENT_SUCCESS; - } -+#endif - - static enum fwu_agent_error_t metadata_validate(struct fwu_metadata *p_metadata) - { -@@ -235,6 +291,30 @@ static enum fwu_agent_error_t metadata_validate(struct fwu_metadata *p_metadata) - return FWU_AGENT_SUCCESS; - } - -+#if BL1 -+static enum fwu_agent_error_t metadata_read_without_validation(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 < 0 || ret != sizeof(struct fwu_metadata)) { -+ 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; -+} -+#elif - static enum fwu_agent_error_t metadata_read_without_validation(struct fwu_metadata *p_metadata) - { - uuid_t metadata_uuid = FWU_METADATA_TYPE_UUID; -@@ -266,7 +346,36 @@ static enum fwu_agent_error_t metadata_read_without_validation(struct fwu_metada - - return FWU_AGENT_SUCCESS; - } -+#endif -+ -+#if BL1 -+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 < 0 || ret != sizeof(struct fwu_metadata)) { -+ return FWU_AGENT_ERROR; -+ } -+ -+ if (metadata_validate(p_metadata) != FWU_AGENT_SUCCESS) { -+ 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; -+} -+#elif - static enum fwu_agent_error_t metadata_read(struct fwu_metadata *p_metadata) - { - uuid_t metadata_uuid = FWU_METADATA_TYPE_UUID; -@@ -301,7 +410,66 @@ static enum fwu_agent_error_t metadata_read(struct fwu_metadata *p_metadata) - - return FWU_AGENT_SUCCESS; - } -+#endif -+ - -+#if BL1 -+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 < 0 || ret != sizeof(struct fwu_metadata)) { -+ return FWU_AGENT_ERROR; -+ } -+ -+ FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__, -+ FWU_METADATA_REPLICA_2_OFFSET, sizeof(struct fwu_metadata)); -+ -+ ret = FWU_METADATA_FLASH_DEV.EraseSector(FWU_METADATA_REPLICA_2_OFFSET); -+ if (ret != ARM_DRIVER_OK) { -+ return FWU_AGENT_ERROR; -+ } -+ -+ ret = FWU_METADATA_FLASH_DEV.ProgramData(FWU_METADATA_REPLICA_2_OFFSET, -+ p_metadata, sizeof(struct fwu_metadata)); -+ if (ret < 0 || ret != sizeof(struct fwu_metadata)) { -+ return FWU_AGENT_ERROR; -+ } -+ -+ FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__, -+ FWU_METADATA_REPLICA_2_OFFSET, sizeof(struct fwu_metadata)); -+ -+ ret = FWU_METADATA_FLASH_DEV.EraseSector(FWU_METADATA_REPLICA_2_OFFSET); -+ if (ret != ARM_DRIVER_OK) { -+ return FWU_AGENT_ERROR; -+ } -+ -+ ret = FWU_METADATA_FLASH_DEV.ProgramData(FWU_METADATA_REPLICA_2_OFFSET, -+ p_metadata, sizeof(struct fwu_metadata)); -+ if (ret < 0 || ret != sizeof(struct fwu_metadata)) { -+ 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; -+} -+#elif - static enum fwu_agent_error_t metadata_write( - struct fwu_metadata *p_metadata) - { -@@ -371,6 +539,8 @@ static enum fwu_agent_error_t metadata_write( - p_metadata->active_index, p_metadata->previous_active_index); - return FWU_AGENT_SUCCESS; - } -+#endif -+ - - enum fwu_agent_error_t fwu_metadata_init(void) - { -@@ -418,8 +588,10 @@ enum fwu_agent_error_t fwu_metadata_provision(void) - - FWU_LOG_MSG("%s: enter\n\r", __func__); - -+#if !BL1 - plat_io_storage_init(); - partition_init(PLATFORM_GPT_IMAGE); -+#endif - - ret = fwu_metadata_init(); - if (ret) { --- -2.17.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0011-Platform-corstone1000-adjust-PS-asset-configuration.patch b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0011-Platform-corstone1000-adjust-PS-asset-configuration.patch deleted file mode 100644 index 19a3773125..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0011-Platform-corstone1000-adjust-PS-asset-configuration.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 148d82d0984273b30d8b148f0c4e0ad0d3f23062 Mon Sep 17 00:00:00 2001 -From: Emekcan Aras <emekcan.aras@arm.com> -Date: Mon, 17 Apr 2023 12:07:55 +0100 -Subject: [PATCH 1/3] Platform: corstone1000: adjust PS asset configuration - -Adjust protected storage asset configuration to be more inline -with the one in trusted service side, that would make thinks -work when testing and using more than the default variables. - -Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20560] -Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> -Signed-off-by: Emekcan Aras <emekcan.aras@arm.com> -Change-Id: I181f9c72a816c727c2170c609100aec1d233fea7 ---- - platform/ext/target/arm/corstone1000/config.cmake | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/platform/ext/target/arm/corstone1000/config.cmake b/platform/ext/target/arm/corstone1000/config.cmake -index bec6b84f0..0c91fa59f 100644 ---- a/platform/ext/target/arm/corstone1000/config.cmake -+++ b/platform/ext/target/arm/corstone1000/config.cmake -@@ -76,3 +76,4 @@ endif() - # Platform-specific configurations - set(CONFIG_TFM_USE_TRUSTZONE OFF) - set(TFM_MULTI_CORE_TOPOLOGY ON) -+set(PS_NUM_ASSETS "40" CACHE STRING "The maximum number of assets to be stored in the Protected Storage area") --- -2.17.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0012-Platform-corstone1000-Increase-number-of-assets.patch b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0012-Platform-corstone1000-Increase-number-of-assets.patch deleted file mode 100644 index d2fc332d45..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/files/corstone1000/0012-Platform-corstone1000-Increase-number-of-assets.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 34263d1ea99da7b8a680a80601a73149bc9530e5 Mon Sep 17 00:00:00 2001 -From: Emekcan Aras <emekcan.aras@arm.com> -Date: Fri, 21 Apr 2023 15:17:21 +0100 -Subject: [PATCH] Platform: corstone1000: Increase number of assets - -As Corstone1000 stores at boot time few efi variables. -Therefore, number of assets is increased to compansate this early usage. - -Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20656] -Signed-off-by: Mohamed Omar Asaker <mohamed.omarasaker@arm.com> -Signed-off-by: Emekcan Aras <emekcan.aras@arm.com> -Change-Id: Id8555a09335ce13b80c07a33c4d913f5cb0f9084 ---- - platform/ext/target/arm/corstone1000/config_tfm_target.h | 8 ++++++++ - 1 file changed, 8 insertions(+) - -diff --git a/platform/ext/target/arm/corstone1000/config_tfm_target.h b/platform/ext/target/arm/corstone1000/config_tfm_target.h -index bf8d2f95f..e96836663 100644 ---- a/platform/ext/target/arm/corstone1000/config_tfm_target.h -+++ b/platform/ext/target/arm/corstone1000/config_tfm_target.h -@@ -16,4 +16,12 @@ - #undef PLATFORM_SERVICE_OUTPUT_BUFFER_SIZE - #define PLATFORM_SERVICE_OUTPUT_BUFFER_SIZE 256 - -+/* The maximum number of assets to be stored in the Internal Trusted Storage. */ -+#undef ITS_NUM_ASSETS -+#define ITS_NUM_ASSETS 20 -+ -+/* The maximum number of assets to be stored in the Protected Storage area. */ -+#undef PS_NUM_ASSETS -+#define PS_NUM_ASSETS 20 -+ - #endif /* __CONFIG_TFM_TARGET_H__ */ --- -2.17.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/trusted-firmware-m-1.7.0-corstone1000.inc b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/trusted-firmware-m-corstone1000.inc index 23c8c127bc..0831ed0e9b 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/trusted-firmware-m-1.7.0-corstone1000.inc +++ b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/trusted-firmware-m-corstone1000.inc @@ -11,10 +11,6 @@ TFM_PLATFORM_IS_FVP ?= "FALSE" EXTRA_OECMAKE += "-DPLATFORM_IS_FVP=${TFM_PLATFORM_IS_FVP}" EXTRA_OECMAKE += "-DCC312_LEGACY_DRIVER_API_ENABLED=ON" -SRCREV_tfm = "94c55967cbd1832681f07074a0945605b02ec8d0" -SRCREV_mcuboot = "9e8eddcecba931f99297765779f8b130d808a9a3" -SRCREV_mbedtls = "8c89224991adff88d53cd380f42a2baa36f91454" - # libmetal LICENSE += "& BSD-3-Clause" LIC_FILES_CHKSUM += "file://../libmetal/LICENSE.md;md5=fe0b8a4beea8f0813b606d15a3df3d3c" @@ -30,28 +26,12 @@ SRCREV_openamp = "347397decaa43372fc4d00f965640ebde042966d" EXTRA_OECMAKE += "-DLIBOPENAMP_SRC_PATH=${S}/../openamp -DLIBOPENAMP_BIN_PATH=${B}/libopenamp-build" -SRC_URI:remove:corstone1000 =" \ - file://rwx.patch \ -" - FILESEXTRAPATHS:prepend := "${THISDIR}/files:" SRC_URI:append:corstone1000 = " \ - file://0001-Platform-corstone1000-make-sure-to-write-fwu-metadata-to-repl.patch \ - file://0002-Platform-corstone1000-get-fwu-and-private-metadata-f.patch \ - file://0003-Platform-corstone1000-Add-watchdog_reset_timer.patch \ - file://0004-Platform-corstone1000-Replace-MCUBOOT-BL1-by-TFM-s.patch \ - file://0005-Platform-corstone1000-Replace-MCUBOOT-BL1-by-TFM-s-B.patch \ - file://0006-Platform-corstone1000-Reorganize-bl2-files.patch \ - file://0007-Platform-corstone1000-Fix-linker-script-comment.patch \ - file://0008-Platform-corstone1000-Fix-linkerscripts-copyright-ye.patch \ - file://0009-Platform-corstone1000-fix-flash-reading-issue-for-fi.patch \ - file://0010-Platform-corstone1000-Adds-compiler-flags-to-FWU-age.patch \ - file://0011-Platform-corstone1000-adjust-PS-asset-configuration.patch \ - file://0012-Platform-corstone1000-Increase-number-of-assets.patch \ - file://0013-Platform-corstone1000-Increase-BL2-size-in-flash-lay.patch \ - file://0014-Platform-Corstone1000-Increase-BL2_DATA_SIZE.patch \ - file://0015-Platform-Corstone1000-Calculate-the-new-CRC32-value-.patch \ - file://corstone1000/rwx.patch \ + file://0001-Platform-corstone1000-Increase-BL2-size-in-flash-lay.patch \ + file://0002-Platform-Corstone1000-Increase-BL2_DATA_SIZE.patch \ + file://0003-Platform-Corstone1000-Calculate-the-new-CRC32-value-.patch \ + file://0004-arm-trusted-firmware-m-disable-fatal-warnings.patch \ " # TF-M ships patches for external dependencies that needs to be applied diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/trusted-firmware-m_%.bbappend b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/trusted-firmware-m_%.bbappend new file mode 100644 index 0000000000..da70bc7806 --- /dev/null +++ b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/trusted-firmware-m_%.bbappend @@ -0,0 +1,6 @@ +# Machine specific configurations + +MACHINE_TFM_REQUIRE ?= "" +MACHINE_TFM_REQUIRE:corstone1000 = "trusted-firmware-m-corstone1000.inc" + +require ${MACHINE_TFM_REQUIRE} diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.7.%.bbappend b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.7.%.bbappend deleted file mode 100644 index a558cfee68..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.7.%.bbappend +++ /dev/null @@ -1,9 +0,0 @@ -# Machine specific configurations - -MACHINE_TFM_REQUIRE ?= "" -MACHINE_TFM_REQUIRE:corstone1000 = "trusted-firmware-m-1.7.0-corstone1000.inc" - -require ${MACHINE_TFM_REQUIRE} - -COMPATIBLE_MACHINE:tc = "(tc1)" -TFM_PLATFORM:tc = "arm/rss/tc" diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0001-arm64-smccc-add-support-for-SMCCCv1.2-x0-x17-registe.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0001-FF-A-v15-arm64-smccc-add-support-for-SMCCCv1.2-x0-x1.patch index 23f50198af..df633e2faf 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0001-arm64-smccc-add-support-for-SMCCCv1.2-x0-x17-registe.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0001-FF-A-v15-arm64-smccc-add-support-for-SMCCCv1.2-x0-x1.patch @@ -1,8 +1,8 @@ -From 5ce8bf4ad1aeb2657a7ab83c46eeb2cdaa56cfd4 Mon Sep 17 00:00:00 2001 +From b79722ade56bd49cf9e7d9b47b6256599c8cdb36 Mon Sep 17 00:00:00 2001 From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> Date: Fri, 29 Jul 2022 13:06:19 +0100 -Subject: [PATCH 01/42] arm64: smccc: add support for SMCCCv1.2 x0-x17 - registers +Subject: [PATCH 01/33] FF-A v15: arm64: smccc: add support for SMCCCv1.2 + x0-x17 registers add support for x0-x17 registers used by the SMC calls @@ -16,51 +16,35 @@ arm64: smccc: Add support for SMCCCv1.2 extended input/output registers [1]: https://documentation-service.arm.com/static/5f8edaeff86e16515cdbe4c6?token= Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> +Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> +Reviewed-by: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com> -Cc: Simon Glass <sjg@chromium.org> -Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> -Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/] - -Changelog: -=============== - -v7: - -* improve indentation of ARM_SMCCC_1_2_REGS_Xn_OFFS - -v4: - -* rename the commit title and improve description - new commit title: the current - -v3: - -* port x0-x17 registers support from linux kernel as defined by SMCCCv1.2 - commit title: - arm64: smccc: add Xn registers support used by SMC calls - -Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> +Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20230713132847.176000-1-abdellatif.elkhlifi@arm.com/] --- - arch/arm/cpu/armv8/smccc-call.S | 53 +++++++++++++++++++++++++++++++++ - arch/arm/lib/asm-offsets.c | 14 +++++++++ - include/linux/arm-smccc.h | 43 ++++++++++++++++++++++++++ - 3 files changed, 110 insertions(+) + arch/arm/cpu/armv8/smccc-call.S | 57 ++++++++++++++++++++++++++++++++- + arch/arm/lib/asm-offsets.c | 16 +++++++++ + include/linux/arm-smccc.h | 45 ++++++++++++++++++++++++++ + 3 files changed, 117 insertions(+), 1 deletion(-) diff --git a/arch/arm/cpu/armv8/smccc-call.S b/arch/arm/cpu/armv8/smccc-call.S -index dc92b28777..ec6f299bc9 100644 +index dc92b28777..93f66d3366 100644 --- a/arch/arm/cpu/armv8/smccc-call.S +++ b/arch/arm/cpu/armv8/smccc-call.S -@@ -1,6 +1,8 @@ +@@ -1,7 +1,11 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (c) 2015, Linaro Limited -+ * (C) Copyright 2022 ARM Limited -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> - */ +- */ ++ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++ * ++ * Authors: ++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++*/ #include <linux/linkage.h> #include <linux/arm-smccc.h> -@@ -45,3 +47,54 @@ ENDPROC(__arm_smccc_smc) + #include <generated/asm-offsets.h> +@@ -45,3 +49,54 @@ ENDPROC(__arm_smccc_smc) ENTRY(__arm_smccc_hvc) SMCCC hvc ENDPROC(__arm_smccc_hvc) @@ -116,20 +100,22 @@ index dc92b28777..ec6f299bc9 100644 + +#endif diff --git a/arch/arm/lib/asm-offsets.c b/arch/arm/lib/asm-offsets.c -index 22fd541f9a..db6d7ed234 100644 +index 6de0ce9152..181a8ac4c2 100644 --- a/arch/arm/lib/asm-offsets.c +++ b/arch/arm/lib/asm-offsets.c -@@ -9,6 +9,9 @@ +@@ -9,6 +9,11 @@ * generate asm statements containing #defines, * compile this file to assembler, and then extract the * #defines from the assembly-language output. + * -+ * (C) Copyright 2022 ARM Limited -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++ * ++ * Authors: ++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> */ #include <common.h> -@@ -117,6 +120,17 @@ int main(void) +@@ -90,6 +95,17 @@ int main(void) DEFINE(ARM_SMCCC_RES_X2_OFFS, offsetof(struct arm_smccc_res, a2)); DEFINE(ARM_SMCCC_QUIRK_ID_OFFS, offsetof(struct arm_smccc_quirk, id)); DEFINE(ARM_SMCCC_QUIRK_STATE_OFFS, offsetof(struct arm_smccc_quirk, state)); @@ -148,19 +134,21 @@ index 22fd541f9a..db6d7ed234 100644 return 0; diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h -index e1d09884a1..9105031d55 100644 +index e1d09884a1..f44e9e8f93 100644 --- a/include/linux/arm-smccc.h +++ b/include/linux/arm-smccc.h -@@ -1,6 +1,8 @@ +@@ -1,6 +1,10 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (c) 2015, Linaro Limited -+ * (C) Copyright 2022 ARM Limited -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++ * ++ * Authors: ++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> */ #ifndef __LINUX_ARM_SMCCC_H #define __LINUX_ARM_SMCCC_H -@@ -70,6 +72,47 @@ struct arm_smccc_res { +@@ -70,6 +74,47 @@ struct arm_smccc_res { unsigned long a3; }; diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0002-lib-uuid-introduce-uuid_str_to_le_bin-function.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0002-FF-A-v15-lib-uuid-introduce-uuid_str_to_le_bin-funct.patch index 5c0c61e585..550be6be1f 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0002-lib-uuid-introduce-uuid_str_to_le_bin-function.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0002-FF-A-v15-lib-uuid-introduce-uuid_str_to_le_bin-funct.patch @@ -1,84 +1,69 @@ -From 1dcebf6f57e3490f7b3e2464b4114b993dd70c7c Mon Sep 17 00:00:00 2001 +From 43137871fcc46513eea1480cd78ad091763578f0 Mon Sep 17 00:00:00 2001 From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> Date: Thu, 4 Aug 2022 16:46:47 +0100 -Subject: [PATCH 02/42] lib: uuid: introduce uuid_str_to_le_bin function +Subject: [PATCH 02/33] FF-A v15: lib: uuid: introduce uuid_str_to_le_bin + function convert UUID string to little endian binary data Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> +Reviewed-by: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com> -Cc: Simon Glass <sjg@chromium.org> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Cc: Jens Wiklander <jens.wiklander@linaro.org> -Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/] - -Changelog: -=============== - -v8: - -* use simple_strtoull() in uuid_str_to_le_bin() to support 32-bit platforms - -v7: - -* rename be_uuid_str_to_le_bin() to uuid_str_to_le_bin() -* make uuid_str_to_le_bin() implementation similar to uuid_str_to_bin() - by using same APIs - -v4: - -* rename ffa_uuid_str_to_bin to be_uuid_str_to_le_bin and put in - a standalone commit (the current) - -v3: - -* introduce ffa_uuid_str_to_bin (provided by - arm_ffa: introduce Arm FF-A low-level driver) - -Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> +Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20230713132847.176000-1-abdellatif.elkhlifi@arm.com/] --- - include/uuid.h | 8 ++++++++ - lib/uuid.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 54 insertions(+) + include/uuid.h | 15 +++++++++++++++ + lib/uuid.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 63 insertions(+) diff --git a/include/uuid.h b/include/uuid.h -index 4a4883d3b5..293a8eb0a5 100644 +index 4a4883d3b5..89b93e642b 100644 --- a/include/uuid.h +++ b/include/uuid.h -@@ -2,6 +2,8 @@ +@@ -2,6 +2,10 @@ /* * Copyright (C) 2014 Samsung Electronics * Przemyslaw Marczak <p.marczak@samsung.com> -+ * (C) Copyright 2022 ARM Limited -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++ * ++ * Authors: ++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> */ #ifndef __UUID_H__ #define __UUID_H__ -@@ -44,4 +46,10 @@ int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin); +@@ -44,4 +48,15 @@ int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin); const char *uuid_guid_get_str(const unsigned char *guid_bin); void gen_rand_uuid(unsigned char *uuid_bin); void gen_rand_uuid_str(char *uuid_str, int str_format); + +/** -+ * uuid_str_to_le_bin - Converts a UUID string to little endian binary data ++ * uuid_str_to_le_bin() - Convert string UUID to little endian binary data. ++ * @uuid_str: pointer to UUID string ++ * @uuid_bin: pointer to allocated array for little endian output [16B] ++ * Return: ++ * uuid_bin filled with little endian UUID data ++ * On success 0 is returned. Otherwise, failure code. + */ +int uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin); + #endif diff --git a/lib/uuid.c b/lib/uuid.c -index 465e1ac38f..d29f561a70 100644 +index 96e1af3c8b..45f325d964 100644 --- a/lib/uuid.c +++ b/lib/uuid.c -@@ -1,6 +1,8 @@ +@@ -1,6 +1,10 @@ // SPDX-License-Identifier: GPL-2.0+ /* * Copyright 2011 Calxeda, Inc. -+ * (C) Copyright 2022 ARM Limited -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++ * ++ * Authors: ++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> */ #include <common.h> -@@ -346,6 +348,50 @@ int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin, +@@ -354,6 +358,50 @@ int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin, return 0; } diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0003-FF-A-v15-lib-uuid-introduce-testcase-for-uuid_str_to.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0003-FF-A-v15-lib-uuid-introduce-testcase-for-uuid_str_to.patch new file mode 100644 index 0000000000..bbd4e04824 --- /dev/null +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0003-FF-A-v15-lib-uuid-introduce-testcase-for-uuid_str_to.patch @@ -0,0 +1,94 @@ +From 80fd758cb55f8b44078b4535284ea132b0d5a944 Mon Sep 17 00:00:00 2001 +From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> +Date: Mon, 27 Mar 2023 16:24:29 +0100 +Subject: [PATCH 03/33] FF-A v15: lib: uuid: introduce testcase for + uuid_str_to_le_bin + +provide a test case + +Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> +Reviewed-by: Simon Glass <sjg@chromium.org> +Cc: Tom Rini <trini@konsulko.com> +Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20230713132847.176000-1-abdellatif.elkhlifi@arm.com/] +--- + MAINTAINERS | 5 +++++ + test/lib/Makefile | 1 + + test/lib/uuid.c | 41 +++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 47 insertions(+) + create mode 100644 test/lib/uuid.c + +diff --git a/MAINTAINERS b/MAINTAINERS +index 3bf60c4643..a1122afb01 100644 +--- a/MAINTAINERS ++++ b/MAINTAINERS +@@ -1632,3 +1632,8 @@ S: Maintained + F: arch/arm/dts/ls1021a-twr-u-boot.dtsi + F: drivers/crypto/fsl/ + F: include/fsl_sec.h ++ ++UUID testing ++M: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++S: Maintained ++F: test/lib/uuid.c +diff --git a/test/lib/Makefile b/test/lib/Makefile +index e0bd9e04e8..e75a263e6a 100644 +--- a/test/lib/Makefile ++++ b/test/lib/Makefile +@@ -22,6 +22,7 @@ obj-$(CONFIG_AES) += test_aes.o + obj-$(CONFIG_GETOPT) += getopt.o + obj-$(CONFIG_CRC8) += test_crc8.o + obj-$(CONFIG_UT_LIB_CRYPT) += test_crypt.o ++obj-$(CONFIG_LIB_UUID) += uuid.o + else + obj-$(CONFIG_SANDBOX) += kconfig_spl.o + endif +diff --git a/test/lib/uuid.c b/test/lib/uuid.c +new file mode 100644 +index 0000000000..e24331a136 +--- /dev/null ++++ b/test/lib/uuid.c +@@ -0,0 +1,41 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++/* ++ * Functional tests for UCLASS_FFA class ++ * ++ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++ * ++ * Authors: ++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++ */ ++ ++#include <common.h> ++#include <uuid.h> ++#include <test/lib.h> ++#include <test/test.h> ++#include <test/ut.h> ++ ++/* test UUID */ ++#define TEST_SVC_UUID "ed32d533-4209-99e6-2d72-cdd998a79cc0" ++ ++#define UUID_SIZE 16 ++ ++/* The UUID binary data (little-endian format) */ ++static const u8 ref_uuid_bin[UUID_SIZE] = { ++ 0x33, 0xd5, 0x32, 0xed, ++ 0x09, 0x42, 0xe6, 0x99, ++ 0x72, 0x2d, 0xc0, 0x9c, ++ 0xa7, 0x98, 0xd9, 0xcd ++}; ++ ++static int lib_test_uuid_to_le(struct unit_test_state *uts) ++{ ++ const char *uuid_str = TEST_SVC_UUID; ++ u8 ret_uuid_bin[UUID_SIZE] = {0}; ++ ++ ut_assertok(uuid_str_to_le_bin(uuid_str, ret_uuid_bin)); ++ ut_asserteq_mem(ref_uuid_bin, ret_uuid_bin, UUID_SIZE); ++ ++ return 0; ++} ++ ++LIB_TEST(lib_test_uuid_to_le, 0); +-- +2.25.1 + diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0003-arm_ffa-introduce-Arm-FF-A-low-level-driver.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0003-arm_ffa-introduce-Arm-FF-A-low-level-driver.patch deleted file mode 100644 index f76c74b699..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0003-arm_ffa-introduce-Arm-FF-A-low-level-driver.patch +++ /dev/null @@ -1,2139 +0,0 @@ -From 77cf1f517f6d92d5e3efb40d8335adb03b289525 Mon Sep 17 00:00:00 2001 -From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Date: Tue, 29 Nov 2022 14:40:05 +0000 -Subject: [PATCH 03/42] arm_ffa: introduce Arm FF-A low-level driver - -Add the core driver implementing Arm Firmware Framework for Armv8-A v1.0 - -The Firmware Framework for Arm A-profile processors (FF-A v1.0) [1] -describes interfaces (ABIs) that standardize communication -between the Secure World and Normal World leveraging TrustZone -technology. - -This driver uses 64-bit registers as per SMCCCv1.2 spec and comes -on top of the SMCCC layer. The driver provides the FF-A ABIs needed for -querying the FF-A framework from the secure world. - -The driver uses SMC32 calling convention which means using the first -32-bit data of the Xn registers. - -All supported ABIs come with their 32-bit version except FFA_RXTX_MAP -which has 64-bit version supported. - -Both 32-bit and 64-bit direct messaging are supported which allows both -32-bit and 64-bit clients to use the FF-A bus. - -In U-Boot FF-A design, FF-A is considered as a discoverable bus. -The Secure World is considered as one entity to communicate with -using the FF-A bus. FF-A communication is handled by one device and -one instance (the bus). This FF-A driver takes care of all the -interactions between Normal world and Secure World. - -The driver exports its operations to be used by upper layers. - -Exported operations: - -- partition_info_get -- sync_send_receive -- rxtx_unmap - -For more details please refer to the driver documentation [2]. - -[1]: https://developer.arm.com/documentation/den0077/latest/ -[2]: doc/arch/arm64.ffa.rst - -Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Cc: Tom Rini <trini@konsulko.com> -Cc: Simon Glass <sjg@chromium.org> -Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> -Cc: Jens Wiklander <jens.wiklander@linaro.org> -Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/] - -Changelog: -=============== - -v8: - -* make ffa_get_partitions_info() second argument to be an SP count in both - modes -* update ffa_bus_prvdata_get() to return a pointer rather than a pointer - address -* remove packing from ffa_partition_info and ffa_send_direct_data structures -* pass the FF-A bus device to the bus operations - -v7: - -* add support for 32-bit direct messaging -* rename be_uuid_str_to_le_bin() to uuid_str_to_le_bin() -* improve the declaration of error handling mapping -* stating in doc/arch/arm64.ffa.rst that EFI runtime is not supported - -v6: - -* drop use of EFI runtime support (We decided with Linaro to add this later) -* drop discovery from initcalls (discovery will be on demand by FF-A users) -* set the alignment of the RX/TX buffers to the larger translation granule size -* move FF-A RX/TX buffers unmapping at ExitBootServices() to a separate commit -* update the documentation and move it to doc/arch/arm64.ffa.rst - -v4: - -* add doc/README.ffa.drv -* moving the FF-A driver work to drivers/firmware/arm-ffa -* use less #ifdefs in lib/efi_loader/efi_boottime.c and replace - #if defined by #if CONFIG_IS_ENABLED -* improving error handling by mapping the FF-A errors to standard errors - and logs -* replacing panics with an error log and returning an error code -* improving features discovery in FFA_FEATURES by introducing - rxtx_min_pages private data field -* add ffa_remove and ffa_unbind functions -* improve how the driver behaves when bus discovery is done more than - once - -v3: - -* align the interfaces of the U-Boot FF-A driver with those in the linux - FF-A driver -* remove the FF-A helper layer -* make the U-Boot FF-A driver independent from EFI -* provide an optional config that enables copying the driver data to EFI - runtime section at ExitBootServices service -* use 64-bit version of FFA_RXTX_MAP, FFA_MSG_SEND_DIRECT_{REQ, RESP} - -v2: - -* make FF-A bus discoverable using device_{bind, probe} APIs -* remove device tree support - -v1: - -* introduce FF-A bus driver with device tree support - -Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> ---- - MAINTAINERS | 7 + - doc/arch/arm64.ffa.rst | 218 ++++ - doc/arch/index.rst | 1 + - drivers/Kconfig | 2 + - drivers/Makefile | 1 + - drivers/firmware/arm-ffa/Kconfig | 30 + - drivers/firmware/arm-ffa/Makefile | 6 + - drivers/firmware/arm-ffa/arm-ffa-uclass.c | 16 + - drivers/firmware/arm-ffa/arm_ffa_prv.h | 200 ++++ - drivers/firmware/arm-ffa/core.c | 1315 +++++++++++++++++++++ - include/arm_ffa.h | 97 ++ - include/dm/uclass-id.h | 4 + - 12 files changed, 1897 insertions(+) - create mode 100644 doc/arch/arm64.ffa.rst - create mode 100644 drivers/firmware/arm-ffa/Kconfig - create mode 100644 drivers/firmware/arm-ffa/Makefile - create mode 100644 drivers/firmware/arm-ffa/arm-ffa-uclass.c - create mode 100644 drivers/firmware/arm-ffa/arm_ffa_prv.h - create mode 100644 drivers/firmware/arm-ffa/core.c - create mode 100644 include/arm_ffa.h - -diff --git a/MAINTAINERS b/MAINTAINERS -index 3fc4cd0f12..509619d31c 100644 ---- a/MAINTAINERS -+++ b/MAINTAINERS -@@ -264,6 +264,13 @@ F: drivers/net/cortina_ni.h - F: drivers/net/phy/ca_phy.c - F: configs/cortina_presidio-asic-pnand_defconfig - -+ARM FF-A -+M: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -+S: Maintained -+F: doc/arch/arm64.ffa.rst -+F: drivers/firmware/arm-ffa/ -+F: include/arm_ffa.h -+ - ARM FREESCALE IMX - M: Stefano Babic <sbabic@denx.de> - M: Fabio Estevam <festevam@gmail.com> -diff --git a/doc/arch/arm64.ffa.rst b/doc/arch/arm64.ffa.rst -new file mode 100644 -index 0000000000..dfcec82e45 ---- /dev/null -+++ b/doc/arch/arm64.ffa.rst -@@ -0,0 +1,218 @@ -+.. SPDX-License-Identifier: GPL-2.0+ -+ -+Arm FF-A Driver -+=============== -+ -+Summary -+------- -+ -+FF-A stands for Firmware Framework for Arm A-profile processors. -+ -+FF-A specifies interfaces that enable a pair of software sandboxes to -+communicate with each other. A sandbox aka partition could -+be a VM in the Normal or Secure world, an application in S-EL0, or a -+Trusted OS in S-EL1. -+ -+This FF-A driver implements the interfaces to communicate with partitions in -+the Secure world aka Secure partitions (SPs). -+ -+The driver specifically focuses on communicating with SPs that isolate portions -+of EFI runtime services that must run in a protected environment which is -+inaccessible by the Host OS or Hypervisor. Examples of such services are -+set/get variables. -+ -+FF-A driver uses the SMC ABIs defined by the FF-A specification to: -+ -+- Discover the presence of SPs of interest -+- Access an SP's service through communication protocols -+ e.g. EFI MM communication protocol -+ -+At this stage of development the FF-A driver supports EFI boot time only. -+ -+Runtime support will be added in future developments. -+ -+FF-A and SMC specifications -+------------------------------------------- -+ -+The current implementation of the driver relies on FF-A specification v1.0 -+and uses SMC32 calling convention which means using the first 32-bit data of the -+Xn registers. -+ -+At this stage we only need the FF-A v1.0 features. -+ -+The driver has been tested with OP-TEE which supports SMC32 calling convention. -+ -+For more details please refer to the FF-A v1.0 spec: -+https://documentation-service.arm.com/static/5fb7e8a6ca04df4095c1d65e?token= -+ -+Hypervisors are supported if they are configured to trap SMC calls. -+ -+The FF-A driver uses 64-bit registers as per SMCCCv1.2 specification. -+ -+For more details please refer to the SMC Calling Convention v1.2 spec: -+https://documentation-service.arm.com/static/5f8edaeff86e16515cdbe4c6?token= -+ -+Supported hardware -+-------------------------------- -+ -+Aarch64 plaforms -+ -+Configuration -+---------------------- -+ -+CONFIG_ARM_FFA_TRANSPORT -+ Enables the FF-A bus driver. Turn this on if you want to use FF-A -+ communication. -+ -+CONFIG_SANDBOX_FFA -+ Enables FF-A Sandbox driver. This emulates the FF-A ABIs handling under -+ Sandbox and provides functional tests for FF-A. -+ -+FF-A ABIs under the hood -+--------------------------------------- -+ -+Invoking an FF-A ABI involves providing to the secure world/hypervisor the -+expected arguments from the ABI. -+ -+The ABI arguments are stored in x0 to x7 registers. Then, an SMC instruction -+is executed. -+ -+At the secure side level or hypervisor the ABI is handled at a higher exception -+level and the arguments are read and processed. -+ -+The response is put back through x0 to x7 registers and control is given back -+to the U-Boot FF-A driver (non-secure world). -+ -+The driver reads the response and processes it accordingly. -+ -+This methodology applies to all the FF-A ABIs in the driver. -+ -+FF-A bus discovery in U-Boot -+------------------------------------------- -+ -+When CONFIG_ARM_FFA_TRANSPORT is enabled, the FF-A bus is discovered on -+demand by the clients (users). -+ -+Clients can discover the FF-A bus using ffa_bus_discover() API which triggers the -+discovery process. -+ -+ffa_bus_discover() creates, binds and probes the arm_ffa device using -+device_{bind, probe} APIs. -+ -+The discovery process consists in communicating with secure world (or hypervisor) -+and querying specific data. -+ -+The discovery process takes place during the arm_ffa device probing which is -+handled by ffa_probe(). -+ -+The FF-A bus discovery is successful and the bus is ready for use when these -+operations succeed: -+ -+- querying the FF-A framework version -+- querying from secure world the U-Boot endpoint ID -+- querying from secure world the RX/TX mapping features -+- mapping the RX/TX buffers -+- querying from secure world all the partitions information -+ -+Discovery failure results in a probing failure and the arm_ffa device is -+destroyed. -+ -+Requirements for clients -+------------------------------------- -+ -+When using the FF-A bus with EFI, clients must: -+ -+- Query SPs in EFI boot time mode using the service UUID. -+- Unmap RX/TX buffers before EFI runtime mode starts. -+ -+The RX/TX buffers are only available at EFI boot time. Querying partitions is -+done at boot time and data is cached for future use. -+ -+RX/TX buffers should be unmapped by the user before EFI runtime mode -+starts. The driver provides a bus operation for that: rxtx_unmap() -+ -+If RX/TX buffers created by U-Boot are not unmapped and by -+consequence becoming available at EFI runtime, secure world will get confused -+about RX/TX buffers ownership (U-Boot vs kernel). -+ -+When invoking FF-A direct messaging, clients should specify which ABI protocol -+they want to use (32-bit vs 64-bit). Selecting the protocol means using -+the 32-bit or 64-bit version of FFA_MSG_SEND_DIRECT_{REQ, RESP}. -+The calling convention stays the same: SMC32. -+ -+The bus driver layer -+------------------------------ -+ -+The driver comes on top of the SMCCC layer and is implemented in -+drivers/firmware/arm-ffa/core.c -+ -+The driver provides the following features: -+ -+- Support for the 32-bit version of the following ABIs: -+ -+FFA_VERSION -+FFA_ID_GET -+FFA_FEATURES -+FFA_PARTITION_INFO_GET -+FFA_RXTX_UNMAP -+FFA_RX_RELEASE -+FFA_RUN -+FFA_ERROR -+FFA_SUCCESS -+FFA_INTERRUPT -+FFA_MSG_SEND_DIRECT_REQ -+FFA_MSG_SEND_DIRECT_RESP -+ -+- Support for the 64-bit version of the following ABIs: -+ -+FFA_RXTX_MAP -+FFA_MSG_SEND_DIRECT_REQ -+FFA_MSG_SEND_DIRECT_RESP -+ -+- Processing the received data from the secure world/hypervisor and caching it -+ -+- Hiding from upper layers the FF-A protocol and registers details. Upper -+ layers focus on exchanged data, the driver takes care of how to transport -+ that to the secure world/hypervisor using FF-A -+ -+- The driver provides callbacks to be used by clients to access the FF-A bus: -+ -+partition_info_get -+sync_send_receive -+rxtx_unmap -+ -+- FF-A bus discovery makes sure FF-A framework is responsive and compatible -+ with the driver -+ -+- FF-A bus can be compiled and used without EFI -+ -+Using armffa command -+----------------------------------- -+ -+armffa is an implementation defined command showcasing how to use the FF-A driver and how to invoke -+its operations. -+ -+This provides a guidance to the client developers on how to call the FF-A bus -+interfaces. -+ -+Usage: -+ -+armffa <sub-command> <arguments> -+ -+sub-commands: -+ -+ getpart <partition UUID> -+ -+ lists the partition(s) info -+ -+ ping <partition ID> -+ -+ sends a data pattern to the specified partition -+ -+ devlist -+ -+ displays the arm_ffa device info -+ -+Contributors -+------------ -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -diff --git a/doc/arch/index.rst b/doc/arch/index.rst -index b3e85f9bf3..cf1cfc9287 100644 ---- a/doc/arch/index.rst -+++ b/doc/arch/index.rst -@@ -8,6 +8,7 @@ Architecture-specific doc - - arc - arm64 -+ arm64.ffa - m68k - mips - nios2 -diff --git a/drivers/Kconfig b/drivers/Kconfig -index 75ac149d31..ff75b7c3f8 100644 ---- a/drivers/Kconfig -+++ b/drivers/Kconfig -@@ -6,6 +6,8 @@ source "drivers/core/Kconfig" - - source "drivers/adc/Kconfig" - -+source "drivers/firmware/arm-ffa/Kconfig" -+ - source "drivers/ata/Kconfig" - - source "drivers/axi/Kconfig" -diff --git a/drivers/Makefile b/drivers/Makefile -index 6f1de58e00..28c8f538c8 100644 ---- a/drivers/Makefile -+++ b/drivers/Makefile -@@ -112,6 +112,7 @@ obj-y += iommu/ - obj-y += smem/ - obj-y += thermal/ - obj-$(CONFIG_TEE) += tee/ -+obj-$(CONFIG_ARM_FFA_TRANSPORT) += firmware/arm-ffa/ - obj-y += axi/ - obj-y += ufs/ - obj-$(CONFIG_W1) += w1/ -diff --git a/drivers/firmware/arm-ffa/Kconfig b/drivers/firmware/arm-ffa/Kconfig -new file mode 100644 -index 0000000000..e4914b9bc7 ---- /dev/null -+++ b/drivers/firmware/arm-ffa/Kconfig -@@ -0,0 +1,30 @@ -+# SPDX-License-Identifier: GPL-2.0 -+ -+config ARM_FFA_TRANSPORT -+ bool "Enable Arm Firmware Framework for Armv8-A driver" -+ depends on DM && ARM64 -+ select ARM_SMCCC -+ select LIB_UUID -+ select DEVRES -+ help -+ The Firmware Framework for Arm A-profile processors (FF-A) -+ describes interfaces (ABIs) that standardize communication -+ between the Secure World and Normal World leveraging TrustZone -+ technology. -+ -+ This driver is based on FF-A specification v1.0 and uses SMC32 -+ calling convention. -+ -+ FF-A specification: -+ -+ https://developer.arm.com/documentation/den0077/a/?lang=en -+ -+ In U-Boot FF-A design, FF-A is considered as a discoverable bus. -+ The Secure World is considered as one entity to communicate with -+ using the FF-A bus. -+ FF-A communication is handled by one device and one instance (the bus). -+ This FF-A driver takes care of all the interactions between Normal world -+ and Secure World. -+ -+ For more details about the FF-A driver, please refer to doc/arch/arm64.ffa.rst -+ -diff --git a/drivers/firmware/arm-ffa/Makefile b/drivers/firmware/arm-ffa/Makefile -new file mode 100644 -index 0000000000..043a8915be ---- /dev/null -+++ b/drivers/firmware/arm-ffa/Makefile -@@ -0,0 +1,6 @@ -+# SPDX-License-Identifier: GPL-2.0+ -+# -+# (C) Copyright 2022 -+# Abdellatif El Khlifi, Arm Limited, abdellatif.elkhlifi@arm.com. -+ -+obj-y += arm-ffa-uclass.o core.o -diff --git a/drivers/firmware/arm-ffa/arm-ffa-uclass.c b/drivers/firmware/arm-ffa/arm-ffa-uclass.c -new file mode 100644 -index 0000000000..7d9695d289 ---- /dev/null -+++ b/drivers/firmware/arm-ffa/arm-ffa-uclass.c -@@ -0,0 +1,16 @@ -+// SPDX-License-Identifier: GPL-2.0+ -+/* -+ * (C) Copyright 2022 ARM Limited -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -+ */ -+ -+#include <common.h> -+#include <dm.h> -+#include <asm/global_data.h> -+ -+DECLARE_GLOBAL_DATA_PTR; -+ -+UCLASS_DRIVER(ffa) = { -+ .name = "ffa", -+ .id = UCLASS_FFA, -+}; -diff --git a/drivers/firmware/arm-ffa/arm_ffa_prv.h b/drivers/firmware/arm-ffa/arm_ffa_prv.h -new file mode 100644 -index 0000000000..4eea7dc036 ---- /dev/null -+++ b/drivers/firmware/arm-ffa/arm_ffa_prv.h -@@ -0,0 +1,200 @@ -+/* SPDX-License-Identifier: GPL-2.0+ */ -+/* -+ * (C) Copyright 2022 ARM Limited -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -+ */ -+ -+#ifndef __ARM_FFA_PRV_H -+#define __ARM_FFA_PRV_H -+ -+#include <arm_ffa.h> -+#include <linux/bitfield.h> -+#include <linux/bitops.h> -+#include <linux/arm-smccc.h> -+ -+/* -+ * This header is private. It is exclusively used by the FF-A driver -+ */ -+ -+/* FF-A core driver name */ -+#define FFA_DRV_NAME "arm_ffa" -+ -+/* FF-A driver version definitions */ -+ -+#define MAJOR_VERSION_MASK GENMASK(30, 16) -+#define MINOR_VERSION_MASK GENMASK(15, 0) -+#define GET_FFA_MAJOR_VERSION(x) \ -+ ((u16)(FIELD_GET(MAJOR_VERSION_MASK, (x)))) -+#define GET_FFA_MINOR_VERSION(x) \ -+ ((u16)(FIELD_GET(MINOR_VERSION_MASK, (x)))) -+#define PACK_VERSION_INFO(major, minor) \ -+ (FIELD_PREP(MAJOR_VERSION_MASK, (major)) | \ -+ FIELD_PREP(MINOR_VERSION_MASK, (minor))) -+ -+#define FFA_MAJOR_VERSION (1) -+#define FFA_MINOR_VERSION (0) -+#define FFA_VERSION_1_0 \ -+ PACK_VERSION_INFO(FFA_MAJOR_VERSION, FFA_MINOR_VERSION) -+ -+/* Endpoint ID mask (u-boot endpoint ID) */ -+ -+#define GET_SELF_ENDPOINT_ID_MASK GENMASK(15, 0) -+#define GET_SELF_ENDPOINT_ID(x) \ -+ ((u16)(FIELD_GET(GET_SELF_ENDPOINT_ID_MASK, (x)))) -+ -+#define PREP_SELF_ENDPOINT_ID_MASK GENMASK(31, 16) -+#define PREP_SELF_ENDPOINT_ID(x) \ -+ (FIELD_PREP(PREP_SELF_ENDPOINT_ID_MASK, (x))) -+ -+/* Partition endpoint ID mask (partition with which u-boot communicates with) */ -+ -+#define PREP_PART_ENDPOINT_ID_MASK GENMASK(15, 0) -+#define PREP_PART_ENDPOINT_ID(x) \ -+ (FIELD_PREP(PREP_PART_ENDPOINT_ID_MASK, (x))) -+ -+/* -+ * Definitions of the Arm FF-A interfaces supported by the Arm FF-A driver -+ */ -+ -+#define FFA_SMC(calling_convention, func_num) \ -+ ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, (calling_convention), \ -+ ARM_SMCCC_OWNER_STANDARD, (func_num)) -+ -+#define FFA_SMC_32(func_num) FFA_SMC(ARM_SMCCC_SMC_32, (func_num)) -+#define FFA_SMC_64(func_num) FFA_SMC(ARM_SMCCC_SMC_64, (func_num)) -+ -+enum ffa_abis { -+ FFA_ERROR = 0x60, -+ FFA_SUCCESS = 0x61, -+ FFA_INTERRUPT = 0x62, -+ FFA_VERSION = 0x63, -+ FFA_FEATURES = 0x64, -+ FFA_RX_RELEASE = 0x65, -+ FFA_RXTX_MAP = 0x66, -+ FFA_RXTX_UNMAP = 0x67, -+ FFA_PARTITION_INFO_GET = 0x68, -+ FFA_ID_GET = 0x69, -+ FFA_RUN = 0x6D, -+ FFA_MSG_SEND_DIRECT_REQ = 0x6F, -+ FFA_MSG_SEND_DIRECT_RESP = 0x70, -+ -+ /* to be updated when adding new FFA IDs */ -+ FFA_FIRST_ID = FFA_ERROR, /* lowest number ID*/ -+ FFA_LAST_ID = FFA_MSG_SEND_DIRECT_RESP, /* highest number ID*/ -+}; -+ -+enum ffa_abi_errcode { -+ NOT_SUPPORTED = 1, -+ INVALID_PARAMETERS, -+ NO_MEMORY, -+ BUSY, -+ INTERRUPTED, -+ DENIED, -+ RETRY, -+ ABORTED, -+ MAX_NUMBER_FFA_ERR -+}; -+ -+/* container structure and helper macros to map between an FF-A error and relevant error log */ -+struct ffa_abi_errmap { -+ char *err_str[MAX_NUMBER_FFA_ERR]; -+}; -+ -+#define FFA_ERRMAP_COUNT (FFA_LAST_ID - FFA_FIRST_ID + 1) -+#define FFA_ID_TO_ERRMAP_ID(ffa_id) ((ffa_id) - FFA_FIRST_ID) -+ -+/* The FF-A SMC function definitions */ -+ -+typedef struct arm_smccc_1_2_regs ffa_value_t; -+typedef void (*invoke_ffa_fn_t)(ffa_value_t args, ffa_value_t *res); -+ -+/* -+ * struct ffa_partition_uuid - 16 bytes UUID transmitted by FFA_PARTITION_INFO_GET -+ * @a1-4: 32-bit words access to the UUID data -+ * -+ */ -+struct ffa_partition_uuid { -+ u32 a1; /* w1 */ -+ u32 a2; /* w2 */ -+ u32 a3; /* w3 */ -+ u32 a4; /* w4 */ -+}; -+ -+/** -+ * enum ffa_rxtx_buf_sizes - minimum sizes supported -+ * for the RX/TX buffers -+ */ -+enum ffa_rxtx_buf_sizes { -+ RXTX_4K, -+ RXTX_64K, -+ RXTX_16K -+}; -+ -+/** -+ * struct ffa_rxtxpair - structure hosting the RX/TX buffers virtual addresses -+ * @rxbuf: virtual address of the RX buffer -+ * @txbuf: virtual address of the TX buffer -+ * @rxtx_min_pages: RX/TX buffers minimum size in pages -+ * -+ * Data structure hosting the virtual addresses of the mapped RX/TX buffers -+ * These addresses are used by the FF-A functions that use the RX/TX buffers -+ */ -+struct ffa_rxtxpair { -+ u64 rxbuf; /* virtual address */ -+ u64 txbuf; /* virtual address */ -+ size_t rxtx_min_pages; /* minimum number of pages in each of the RX/TX buffers */ -+}; -+ -+/** -+ * struct ffa_partition_desc - the secure partition descriptor -+ * @info: partition information -+ * @sp_uuid: the secure partition UUID -+ * -+ * Each partition has its descriptor containing the partitions information and the UUID -+ */ -+struct ffa_partition_desc { -+ struct ffa_partition_info info; -+ struct ffa_partition_uuid sp_uuid; -+}; -+ -+/** -+ * struct ffa_partitions - descriptors for all secure partitions -+ * @count: The number of partitions descriptors -+ * @descs The partitions descriptors table -+ * -+ * This data structure contains the partitions descriptors table -+ */ -+struct ffa_partitions { -+ u32 count; -+ struct ffa_partition_desc *descs; /* virtual address */ -+}; -+ -+/** -+ * struct ffa_prvdata - the driver private data structure -+ * -+ * @dev: The arm_ffa device under u-boot driver model -+ * @ffa_ops: The driver operations structure -+ * @fwk_version: FF-A framework version -+ * @id: u-boot endpoint ID -+ * @partitions: The partitions descriptors structure -+ * @pair: The RX/TX buffers pair -+ * @invoke_ffa_fn: The function executing the FF-A function -+ * -+ * The driver data structure hosting all resident data. -+ */ -+struct ffa_prvdata { -+ struct udevice *dev; -+ struct ffa_bus_ops ffa_ops; -+ u32 fwk_version; -+ u16 id; -+ struct ffa_partitions partitions; -+ struct ffa_rxtxpair pair; -+ invoke_ffa_fn_t invoke_ffa_fn; -+}; -+ -+/** -+ * ffa_bus_prvdata_get - bus driver private data getter -+ */ -+struct ffa_prvdata *ffa_bus_prvdata_get(void); -+ -+#endif -diff --git a/drivers/firmware/arm-ffa/core.c b/drivers/firmware/arm-ffa/core.c -new file mode 100644 -index 0000000000..0b1f8e6a07 ---- /dev/null -+++ b/drivers/firmware/arm-ffa/core.c -@@ -0,0 +1,1315 @@ -+// SPDX-License-Identifier: GPL-2.0+ -+/* -+ * (C) Copyright 2022 ARM Limited -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -+ */ -+ -+#include "arm_ffa_prv.h" -+#include <asm/global_data.h> -+#include <common.h> -+#include <dm.h> -+#include <dm/device-internal.h> -+#include <dm/devres.h> -+#include <dm/root.h> -+#include <linux/errno.h> -+#include <linux/sizes.h> -+#include <log.h> -+#include <malloc.h> -+#include <string.h> -+#include <uuid.h> -+ -+DECLARE_GLOBAL_DATA_PTR; -+ -+/** -+ * The device private data structure containing all the -+ * data read from secure world -+ */ -+struct ffa_prvdata *ffa_priv_data; -+ -+/* Error mapping declarations */ -+ -+int ffa_to_std_errmap[MAX_NUMBER_FFA_ERR] = { -+ [NOT_SUPPORTED] = -EOPNOTSUPP, -+ [INVALID_PARAMETERS] = -EINVAL, -+ [NO_MEMORY] = -ENOMEM, -+ [BUSY] = -EBUSY, -+ [INTERRUPTED] = -EINTR, -+ [DENIED] = -EACCES, -+ [RETRY] = -EAGAIN, -+ [ABORTED] = -ECANCELED, -+}; -+ -+struct ffa_abi_errmap err_msg_map[FFA_ERRMAP_COUNT] = { -+ [FFA_ID_TO_ERRMAP_ID(FFA_VERSION)] = { -+ { -+ [NOT_SUPPORTED] = -+ "NOT_SUPPORTED: A Firmware Framework implementation does not exist", -+ }, -+ }, -+ [FFA_ID_TO_ERRMAP_ID(FFA_ID_GET)] = { -+ { -+ [NOT_SUPPORTED] = -+ "NOT_SUPPORTED: This function is not implemented at this FF-A instance", -+ }, -+ }, -+ [FFA_ID_TO_ERRMAP_ID(FFA_FEATURES)] = { -+ { -+ [NOT_SUPPORTED] = -+ "NOT_SUPPORTED: FFA_RXTX_MAP is not implemented at this FF-A instance", -+ }, -+ }, -+ [FFA_ID_TO_ERRMAP_ID(FFA_PARTITION_INFO_GET)] = { -+ { -+ [NOT_SUPPORTED] = -+ "NOT_SUPPORTED: This function is not implemented at this FF-A instance", -+ [INVALID_PARAMETERS] = -+ "INVALID_PARAMETERS: Unrecognized UUID", -+ [NO_MEMORY] = -+ "NO_MEMORY: Results cannot fit in RX buffer of the caller", -+ [BUSY] = -+ "BUSY: RX buffer of the caller is not free", -+ [DENIED] = -+ "DENIED: Callee is not in a state to handle this request", -+ }, -+ }, -+ [FFA_ID_TO_ERRMAP_ID(FFA_RXTX_UNMAP)] = { -+ { -+ [NOT_SUPPORTED] = -+ "NOT_SUPPORTED: FFA_RXTX_UNMAP is not implemented at this FF-A instance", -+ [INVALID_PARAMETERS] = -+ "INVALID_PARAMETERS: No buffer pair registered on behalf of the caller", -+ }, -+ }, -+ [FFA_ID_TO_ERRMAP_ID(FFA_RX_RELEASE)] = { -+ { -+ [NOT_SUPPORTED] = -+ "NOT_SUPPORTED: FFA_RX_RELEASE is not implemented at this FF-A instance", -+ [DENIED] = -+ "DENIED: Caller did not have ownership of the RX buffer", -+ }, -+ }, -+ [FFA_ID_TO_ERRMAP_ID(FFA_RXTX_MAP)] = { -+ { -+ [NOT_SUPPORTED] = -+ "NOT_SUPPORTED: This function is not implemented at this FF-A instance", -+ [INVALID_PARAMETERS] = -+ "INVALID_PARAMETERS: Field(s) in input parameters incorrectly encoded", -+ [NO_MEMORY] = -+ "NO_MEMORY: Not enough memory", -+ [DENIED] = -+ "DENIED: Buffer pair already registered", -+ }, -+ }, -+}; -+ -+/** -+ * ffa_to_std_errno - convert FF-A error code to standard error code -+ * @ffa_errno: Error code returned by the FF-A ABI -+ * -+ * This function maps the given FF-A error code as specified -+ * by the spec to a u-boot standard error code. -+ * -+ * Return: -+ * -+ * The standard error code on success. . Otherwise, failure -+ */ -+int ffa_to_std_errno(int ffa_errno) -+{ -+ int err_idx = -ffa_errno; -+ -+ /* map the FF-A error code to the standard u-boot error code */ -+ if (err_idx > 0 && err_idx < MAX_NUMBER_FFA_ERR) -+ return ffa_to_std_errmap[err_idx]; -+ return -EINVAL; -+} -+ -+/** -+ * ffa_print_error_log - print the error log corresponding to the selected FF-A ABI -+ * @ffa_id: FF-A ABI ID -+ * @ffa_errno: Error code returned by the FF-A ABI -+ * -+ * This function maps the FF-A error code to the error log relevant to the -+ * selected FF-A ABI. Then the error log is printed. -+ * -+ * Return: -+ * -+ * 0 on success. . Otherwise, failure -+ */ -+int ffa_print_error_log(u32 ffa_id, int ffa_errno) -+{ -+ int err_idx = -ffa_errno, abi_idx = 0; -+ -+ /* map the FF-A error code to the corresponding error log */ -+ -+ if (err_idx <= 0 || err_idx >= MAX_NUMBER_FFA_ERR) -+ return -EINVAL; -+ -+ if (ffa_id < FFA_FIRST_ID || ffa_id > FFA_LAST_ID) -+ return -EINVAL; -+ -+ abi_idx = FFA_ID_TO_ERRMAP_ID(ffa_id); -+ if (abi_idx < 0 || abi_idx >= FFA_ERRMAP_COUNT) -+ return -EINVAL; -+ -+ if (!err_msg_map[abi_idx].err_str[err_idx]) -+ return -EINVAL; -+ -+ ffa_err("%s", err_msg_map[abi_idx].err_str[err_idx]); -+ -+ return 0; -+} -+ -+/* -+ * Driver core functions -+ */ -+ -+/** -+ * ffa_remove_device - removes the arm_ffa device -+ * @dev: the device to be removed -+ * -+ * This function makes sure the arm_ffa device is removed -+ * No need to free the kmalloced data when the device is destroyed. -+ * It's automatically done by devm management by -+ * device_remove() -> device_free() -> devres_release_probe(). -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+int ffa_remove_device(struct udevice *dev) -+{ -+ int ret; -+ -+ if (!dev) { -+ ffa_err("no udevice found"); -+ return -ENODEV; -+ } -+ -+ ret = device_remove(dev, DM_REMOVE_NORMAL); -+ if (ret) { -+ ffa_err("unable to remove. err:%d\n", ret); -+ return ret; -+ } -+ -+ ffa_info("device removed and freed"); -+ -+ ret = device_unbind(dev); -+ if (ret) { -+ ffa_err("unable to unbind. err:%d\n", ret); -+ return ret; -+ } -+ -+ ffa_info("device unbound"); -+ -+ return 0; -+} -+ -+/** -+ * ffa_device_get - create, bind and probe the arm_ffa device -+ * @pdev: the address of a device pointer (to be filled when the arm_ffa bus device is created -+ * successfully) -+ * -+ * This function makes sure the arm_ffa device is -+ * created, bound to this driver, probed and ready to use. -+ * Arm FF-A transport is implemented through a single U-Boot -+ * device managing the FF-A bus (arm_ffa). -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+int ffa_device_get(struct udevice **pdev) -+{ -+ int ret; -+ struct udevice *dev = NULL; -+ -+ ret = device_bind(dm_root(), DM_DRIVER_GET(arm_ffa), FFA_DRV_NAME, NULL, ofnode_null(), -+ &dev); -+ if (ret) -+ return ret; -+ -+ /* The FF-A bus discovery succeeds when probing is successful */ -+ ret = device_probe(dev); -+ if (ret) { -+ ffa_err("arm_ffa device probing failed"); -+ ffa_remove_device(dev); -+ return ret; -+ } -+ -+ if (pdev) -+ *pdev = dev; -+ -+ return 0; -+} -+ -+/** -+ * ffa_get_version - FFA_VERSION handler function -+ * -+ * This function implements FFA_VERSION FF-A function -+ * to get from the secure world the FF-A framework version -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+static int ffa_get_version(void) -+{ -+ u16 major, minor; -+ ffa_value_t res = {0}; -+ int ffa_errno; -+ -+ ffa_priv_data->invoke_ffa_fn((ffa_value_t){ -+ .a0 = FFA_SMC_32(FFA_VERSION), .a1 = FFA_VERSION_1_0, -+ }, &res); -+ -+ ffa_errno = res.a0; -+ if (ffa_errno < 0) { -+ ffa_print_error_log(FFA_VERSION, ffa_errno); -+ return ffa_to_std_errno(ffa_errno); -+ } -+ -+ major = GET_FFA_MAJOR_VERSION(res.a0); -+ minor = GET_FFA_MINOR_VERSION(res.a0); -+ -+ ffa_info("FF-A driver %d.%d\nFF-A framework %d.%d", -+ FFA_MAJOR_VERSION, FFA_MINOR_VERSION, major, minor); -+ -+ if ((major == FFA_MAJOR_VERSION && minor >= FFA_MINOR_VERSION)) { -+ ffa_info("Versions are compatible "); -+ -+ ffa_priv_data->fwk_version = res.a0; -+ -+ return 0; -+ } -+ -+ ffa_err("versions are incompatible\nExpected: %d.%d , Found: %d.%d\n", -+ FFA_MAJOR_VERSION, FFA_MINOR_VERSION, major, minor); -+ -+ return -EPROTONOSUPPORT; -+} -+ -+/** -+ * ffa_get_endpoint_id - FFA_ID_GET handler function -+ * -+ * This function implements FFA_ID_GET FF-A function -+ * to get from the secure world u-boot endpoint ID -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+static int ffa_get_endpoint_id(void) -+{ -+ ffa_value_t res = {0}; -+ int ffa_errno; -+ -+ ffa_priv_data->invoke_ffa_fn((ffa_value_t){ -+ .a0 = FFA_SMC_32(FFA_ID_GET), -+ }, &res); -+ -+ if (res.a0 == FFA_SMC_32(FFA_SUCCESS)) { -+ ffa_priv_data->id = GET_SELF_ENDPOINT_ID((u32)res.a2); -+ ffa_info("endpoint ID is %u", ffa_priv_data->id); -+ -+ return 0; -+ } -+ -+ ffa_errno = res.a2; -+ -+ ffa_print_error_log(FFA_ID_GET, ffa_errno); -+ -+ return ffa_to_std_errno(ffa_errno); -+} -+ -+/** -+ * ffa_set_rxtx_buffers_pages_cnt - sets the minimum number of pages in each of the RX/TX buffers -+ * @prop_field: properties field obtained from FFA_FEATURES ABI -+ * -+ * This function sets the minimum number of pages -+ * in each of the RX/TX buffers in the private data structure -+ * -+ * Return: -+ * -+ * buf_4k_pages points to the returned number of pages -+ * 0 on success. Otherwise, failure -+ */ -+static int ffa_set_rxtx_buffers_pages_cnt(u32 prop_field) -+{ -+ if (!ffa_priv_data) -+ return -EINVAL; -+ -+ switch (prop_field) { -+ case RXTX_4K: -+ ffa_priv_data->pair.rxtx_min_pages = 1; -+ break; -+ case RXTX_16K: -+ ffa_priv_data->pair.rxtx_min_pages = 4; -+ break; -+ case RXTX_64K: -+ ffa_priv_data->pair.rxtx_min_pages = 16; -+ break; -+ default: -+ ffa_err("RX/TX buffer size not supported"); -+ return -EINVAL; -+ } -+ -+ return 0; -+} -+ -+/** -+ * ffa_get_rxtx_map_features - FFA_FEATURES handler function with FFA_RXTX_MAP argument -+ * -+ * This function implements FFA_FEATURES FF-A function -+ * to retrieve the FFA_RXTX_MAP features -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+static int ffa_get_rxtx_map_features(void) -+{ -+ ffa_value_t res = {0}; -+ int ffa_errno; -+ -+ ffa_priv_data->invoke_ffa_fn((ffa_value_t){ -+ .a0 = FFA_SMC_32(FFA_FEATURES), -+ .a1 = FFA_SMC_64(FFA_RXTX_MAP), -+ }, &res); -+ -+ if (res.a0 == FFA_SMC_32(FFA_SUCCESS)) -+ return ffa_set_rxtx_buffers_pages_cnt(res.a2); -+ -+ ffa_errno = res.a2; -+ ffa_print_error_log(FFA_FEATURES, ffa_errno); -+ -+ return ffa_to_std_errno(ffa_errno); -+} -+ -+/** -+ * ffa_free_rxtx_buffers - frees the RX/TX buffers -+ * -+ * This function frees the RX/TX buffers -+ * -+ */ -+static void ffa_free_rxtx_buffers(void) -+{ -+ ffa_info("Freeing RX/TX buffers"); -+ -+ if (ffa_priv_data->pair.rxbuf) { -+ free((void *)ffa_priv_data->pair.rxbuf); -+ ffa_priv_data->pair.rxbuf = 0; -+ } -+ -+ if (ffa_priv_data->pair.txbuf) { -+ free((void *)ffa_priv_data->pair.txbuf); -+ ffa_priv_data->pair.txbuf = 0; -+ } -+} -+ -+/** -+ * ffa_alloc_rxtx_buffers - allocates the RX/TX buffers -+ * -+ * This function is used by ffa_map_rxtx_buffers to allocate -+ * the RX/TX buffers before mapping them. The allocated memory is physically -+ * contiguous since memalign ends up calling malloc which allocates -+ * contiguous memory in u-boot. -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+static int ffa_alloc_rxtx_buffers(void) -+{ -+ u64 bytes; -+ -+ ffa_info("Using %lu 4KB page(s) for RX/TX buffers size", -+ ffa_priv_data->pair.rxtx_min_pages); -+ -+ bytes = ffa_priv_data->pair.rxtx_min_pages * SZ_4K; -+ -+ /* -+ * The alignment of the RX and TX buffers must be equal -+ * to the larger translation granule size -+ */ -+ -+ ffa_priv_data->pair.rxbuf = (u64)memalign(bytes, bytes); -+ if (!ffa_priv_data->pair.rxbuf) { -+ ffa_err("failure to allocate RX buffer"); -+ return -ENOBUFS; -+ } -+ -+ ffa_info("RX buffer at virtual address 0x%llx", ffa_priv_data->pair.rxbuf); -+ -+ ffa_priv_data->pair.txbuf = (u64)memalign(bytes, bytes); -+ if (!ffa_priv_data->pair.txbuf) { -+ free((void *)ffa_priv_data->pair.rxbuf); -+ ffa_priv_data->pair.rxbuf = 0; -+ ffa_err("failure to allocate the TX buffer"); -+ return -ENOBUFS; -+ } -+ -+ ffa_info("TX buffer at virtual address 0x%llx", ffa_priv_data->pair.txbuf); -+ -+ /* -+ * make sure the buffers are cleared before use -+ */ -+ memset((void *)ffa_priv_data->pair.rxbuf, 0, bytes); -+ memset((void *)ffa_priv_data->pair.txbuf, 0, bytes); -+ -+ return 0; -+} -+ -+/** -+ * ffa_map_rxtx_buffers - FFA_RXTX_MAP handler function -+ * -+ * This function implements FFA_RXTX_MAP FF-A function -+ * to map the RX/TX buffers -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+static int ffa_map_rxtx_buffers(void) -+{ -+ int ret; -+ ffa_value_t res = {0}; -+ int ffa_errno; -+ -+ ret = ffa_alloc_rxtx_buffers(); -+ if (ret) -+ return ret; -+ -+ /* -+ * we need to pass the physical addresses of the RX/TX buffers -+ * in u-boot physical/virtual mapping is 1:1 -+ * no need to convert from virtual to physical -+ */ -+ -+ ffa_priv_data->invoke_ffa_fn((ffa_value_t){ -+ .a0 = FFA_SMC_64(FFA_RXTX_MAP), -+ .a1 = ffa_priv_data->pair.txbuf, -+ .a2 = ffa_priv_data->pair.rxbuf, -+ .a3 = ffa_priv_data->pair.rxtx_min_pages, -+ }, &res); -+ -+ if (res.a0 == FFA_SMC_32(FFA_SUCCESS)) { -+ ffa_info("RX/TX buffers mapped"); -+ return 0; -+ } -+ -+ ffa_errno = res.a2; -+ ffa_print_error_log(FFA_RXTX_MAP, ffa_errno); -+ -+ ffa_free_rxtx_buffers(); -+ -+ return ffa_to_std_errno(ffa_errno); -+} -+ -+/** -+ * ffa_unmap_rxtx_buffers - FFA_RXTX_UNMAP handler function -+ * @dev: The arm_ffa bus device -+ * -+ * This function implements FFA_RXTX_UNMAP FF-A function -+ * to unmap the RX/TX buffers -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+static int ffa_unmap_rxtx_buffers(struct udevice *dev) -+{ -+ ffa_value_t res = {0}; -+ int ffa_errno; -+ -+ ffa_priv_data->invoke_ffa_fn((ffa_value_t){ -+ .a0 = FFA_SMC_32(FFA_RXTX_UNMAP), -+ .a1 = PREP_SELF_ENDPOINT_ID(ffa_priv_data->id), -+ }, &res); -+ -+ if (res.a0 == FFA_SMC_32(FFA_SUCCESS)) { -+ ffa_free_rxtx_buffers(); -+ return 0; -+ } -+ -+ ffa_errno = res.a2; -+ ffa_print_error_log(FFA_RXTX_UNMAP, ffa_errno); -+ -+ return ffa_to_std_errno(ffa_errno); -+} -+ -+/** -+ * ffa_release_rx_buffer - FFA_RX_RELEASE handler function -+ * -+ * This function invokes FFA_RX_RELEASE FF-A function -+ * to release the ownership of the RX buffer -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+static int ffa_release_rx_buffer(void) -+{ -+ ffa_value_t res = {0}; -+ int ffa_errno; -+ -+ ffa_priv_data->invoke_ffa_fn((ffa_value_t){ -+ .a0 = FFA_SMC_32(FFA_RX_RELEASE), -+ }, &res); -+ -+ if (res.a0 == FFA_SMC_32(FFA_SUCCESS)) -+ return 0; -+ -+ ffa_errno = res.a2; -+ ffa_print_error_log(FFA_RX_RELEASE, ffa_errno); -+ -+ return ffa_to_std_errno(ffa_errno); -+} -+ -+/** -+ * ffa_uuid_are_identical - checks whether two given UUIDs are identical -+ * @uuid1: first UUID -+ * @uuid2: second UUID -+ * -+ * This function is used by ffa_read_partitions_info to search -+ * for a UUID in the partitions descriptors table -+ * -+ * Return: -+ * -+ * 1 when UUIDs match. Otherwise, 0 -+ */ -+bool ffa_uuid_are_identical(const struct ffa_partition_uuid *uuid1, -+ const struct ffa_partition_uuid *uuid2) -+{ -+ if (!uuid1 || !uuid2) -+ return 0; -+ -+ return !memcmp(uuid1, uuid2, sizeof(struct ffa_partition_uuid)); -+} -+ -+/** -+ * ffa_read_partitions_info - reads the data queried by FFA_PARTITION_INFO_GET -+ * and saves it in the private structure -+ * @count: The number of partitions queried -+ * @part_uuid: Pointer to the partition(s) UUID -+ * -+ * This function reads the partitions information -+ * returned by the FFA_PARTITION_INFO_GET and saves it in the private -+ * data structure. -+ * -+ * Return: -+ * -+ * The private data structure is updated with the partition(s) information -+ * 0 is returned on success. Otherwise, failure -+ */ -+static int ffa_read_partitions_info(u32 count, struct ffa_partition_uuid *part_uuid) -+{ -+ if (!count) { -+ ffa_err("no partition detected"); -+ return -ENODATA; -+ } -+ -+ ffa_info("Reading partitions data from the RX buffer"); -+ -+ if (!part_uuid) { -+ /* -+ * querying information of all partitions -+ */ -+ u64 buf_bytes; -+ u64 data_bytes; -+ u32 desc_idx; -+ struct ffa_partition_info *parts_info; -+ -+ data_bytes = count * sizeof(struct ffa_partition_desc); -+ -+ buf_bytes = ffa_priv_data->pair.rxtx_min_pages * SZ_4K; -+ -+ if (data_bytes > buf_bytes) { -+ ffa_err("partitions data size exceeds the RX buffer size:"); -+ ffa_err(" sizes in bytes: data %llu , RX buffer %llu ", -+ data_bytes, -+ buf_bytes); -+ -+ return -ENOMEM; -+ } -+ -+ ffa_priv_data->partitions.descs = devm_kmalloc(ffa_priv_data->dev, data_bytes, -+ __GFP_ZERO); -+ if (!ffa_priv_data->partitions.descs) { -+ ffa_err("cannot allocate partitions data buffer"); -+ return -ENOMEM; -+ } -+ -+ parts_info = (struct ffa_partition_info *)ffa_priv_data->pair.rxbuf; -+ -+ for (desc_idx = 0 ; desc_idx < count ; desc_idx++) { -+ ffa_priv_data->partitions.descs[desc_idx].info = -+ parts_info[desc_idx]; -+ -+ ffa_info("Partition ID %x : info cached", -+ ffa_priv_data->partitions.descs[desc_idx].info.id); -+ } -+ -+ ffa_priv_data->partitions.count = count; -+ -+ ffa_info("%d partition(s) found and cached", count); -+ -+ } else { -+ u32 rx_desc_idx, cached_desc_idx; -+ struct ffa_partition_info *parts_info; -+ u8 desc_found; -+ -+ parts_info = (struct ffa_partition_info *)ffa_priv_data->pair.rxbuf; -+ -+ /* -+ * search for the SP IDs read from the RX buffer -+ * in the already cached SPs. -+ * Update the UUID when ID found. -+ */ -+ for (rx_desc_idx = 0; rx_desc_idx < count ; rx_desc_idx++) { -+ desc_found = 0; -+ -+ /* -+ * search the current ID in the cached partitions -+ */ -+ for (cached_desc_idx = 0; -+ cached_desc_idx < ffa_priv_data->partitions.count; -+ cached_desc_idx++) { -+ /* -+ * save the UUID -+ */ -+ if (ffa_priv_data->partitions.descs[cached_desc_idx].info.id == -+ parts_info[rx_desc_idx].id) { -+ ffa_priv_data->partitions.descs[cached_desc_idx].sp_uuid = -+ *part_uuid; -+ -+ desc_found = 1; -+ break; -+ } -+ } -+ -+ if (!desc_found) -+ return -ENODATA; -+ } -+ } -+ -+ return 0; -+} -+ -+/** -+ * ffa_query_partitions_info - invokes FFA_PARTITION_INFO_GET and saves partitions data -+ * -+ * @part_uuid: Pointer to the partition(s) UUID -+ * @pcount: Pointer to the number of partitions variable filled when querying -+ * -+ * This function executes the FFA_PARTITION_INFO_GET -+ * to query the partitions data. Then, it calls ffa_read_partitions_info -+ * to save the data in the private data structure. -+ * -+ * After reading the data the RX buffer is released using ffa_release_rx_buffer -+ * -+ * Return: -+ * -+ * When part_uuid is NULL, all partitions data are retrieved from secure world -+ * When part_uuid is non NULL, data for partitions matching the given UUID are -+ * retrieved and the number of partitions is returned -+ * 0 is returned on success. Otherwise, failure -+ */ -+static int ffa_query_partitions_info(struct ffa_partition_uuid *part_uuid, -+ u32 *pcount) -+{ -+ struct ffa_partition_uuid query_uuid = {0}; -+ ffa_value_t res = {0}; -+ int ffa_errno; -+ -+ /* -+ * If a UUID is specified. Information for one or more -+ * partitions in the system is queried. Otherwise, information -+ * for all installed partitions is queried -+ */ -+ -+ if (part_uuid) { -+ if (!pcount) -+ return -EINVAL; -+ -+ query_uuid = *part_uuid; -+ } else if (pcount) { -+ return -EINVAL; -+ } -+ -+ ffa_priv_data->invoke_ffa_fn((ffa_value_t){ -+ .a0 = FFA_SMC_32(FFA_PARTITION_INFO_GET), -+ .a1 = query_uuid.a1, -+ .a2 = query_uuid.a2, -+ .a3 = query_uuid.a3, -+ .a4 = query_uuid.a4, -+ }, &res); -+ -+ if (res.a0 == FFA_SMC_32(FFA_SUCCESS)) { -+ int ret; -+ -+ /* -+ * res.a2 contains the count of partition information descriptors -+ * populated in the RX buffer -+ */ -+ if (res.a2) { -+ ret = ffa_read_partitions_info((u32)res.a2, part_uuid); -+ if (ret) { -+ ffa_err("failed to read partition(s) data , error (%d)", ret); -+ ffa_release_rx_buffer(); -+ return -EINVAL; -+ } -+ } -+ -+ /* -+ * return the SP count (when querying using a UUID) -+ */ -+ if (pcount) -+ *pcount = (u32)res.a2; -+ -+ /* -+ * After calling FFA_PARTITION_INFO_GET the buffer ownership -+ * is assigned to the consumer (u-boot). So, we need to give -+ * the ownership back to the SPM or hypervisor -+ */ -+ ret = ffa_release_rx_buffer(); -+ -+ return ret; -+ } -+ -+ ffa_errno = res.a2; -+ ffa_print_error_log(FFA_PARTITION_INFO_GET, ffa_errno); -+ -+ return ffa_to_std_errno(ffa_errno); -+} -+ -+/** -+ * ffa_get_partitions_info - FFA_PARTITION_INFO_GET handler function -+ * -+ * The passed arguments: -+ * Mode 1: When getting from the driver the number of -+ * secure partitions: -+ * @uuid_str: pointer to the UUID string -+ * @sp_count: pointer to the variable that contains the number of partitions -+ * The variable will be set by the driver -+ * @buffer: NULL -+ * -+ * Mode 2: When requesting the driver to return the -+ * partitions information: -+ * @dev: The arm_ffa bus device -+ * @uuid_str: pointer to the UUID string -+ * @sp_count: pointer to the variable that contains the number of empty partition descriptors -+ * The variable will be read by the driver -+ * @buffer: pointer to SPs information buffer -+ * (allocated by the client and contains empty @sp_count descriptors). -+ * The buffer will be filled by the driver -+ * -+ * This function queries the secure partition data from -+ * the private data structure. If not found, it invokes FFA_PARTITION_INFO_GET -+ * FF-A function to query the partition information from secure world. -+ * -+ * A client of the FF-A driver should know the UUID of the service it wants to -+ * access. It should use the UUID to request the FF-A driver to provide the -+ * partition(s) information of the service. The FF-A driver uses -+ * PARTITION_INFO_GET to obtain this information. This is implemented through -+ * ffa_get_partitions_info function. -+ * A new FFA_PARTITION_INFO_GET call is issued (first one performed through -+ * ffa_cache_partitions_info) allowing to retrieve the partition(s) information. -+ * They are not saved (already done). We only update the UUID in the cached area. -+ * This assumes that partitions data does not change in the secure world. -+ * Otherwise u-boot will have an outdated partition data. The benefit of caching -+ * the information in the FF-A driver is to accommodate discovery after -+ * ExitBootServices(). -+ * -+ * When invoked through a client request, ffa_get_partitions_info should be -+ * called twice. First call is to get from the driver the number of secure -+ * partitions (SPs) associated to a particular UUID. -+ * Then, the caller (client) allocates the buffer to host the SPs data and -+ * issues a 2nd call. Then, the driver fills the SPs data in the pre-allocated -+ * buffer. -+ * -+ * To achieve the mechanism described above, ffa_get_partitions_info uses the -+ * following functions: -+ * ffa_read_partitions_info -+ * ffa_query_partitions_info -+ * -+ * Return: -+ * -+ * @sp_count: When pointing to the number of partitions variable, the number is -+ * set by the driver. -+ * When pointing to the partitions information buffer size, the buffer will be -+ * filled by the driver. -+ * -+ * On success 0 is returned. Otherwise, failure -+ */ -+static int ffa_get_partitions_info(struct udevice *dev, const char *uuid_str, -+ u32 *sp_count, struct ffa_partition_info *buffer) -+{ -+ /* -+ * fill_data: -+ * 0: return the SP count -+ * 1: fill SP data and return it to the caller -+ */ -+ bool fill_data = 0; -+ u32 desc_idx, client_desc_idx; -+ struct ffa_partition_uuid part_uuid = {0}; -+ u32 sp_found = 0; -+ -+ if (!ffa_priv_data->partitions.count || !ffa_priv_data->partitions.descs) { -+ ffa_err("no partition installed"); -+ return -EINVAL; -+ } -+ -+ if (!uuid_str) { -+ ffa_err("no UUID provided"); -+ return -EINVAL; -+ } -+ -+ if (!sp_count) { -+ ffa_err("no size/count provided"); -+ return -EINVAL; -+ } -+ -+ if (uuid_str_to_le_bin(uuid_str, (unsigned char *)&part_uuid)) { -+ ffa_err("invalid UUID"); -+ return -EINVAL; -+ } -+ -+ if (!buffer) { -+ /* Mode 1: getting the number of secure partitions */ -+ -+ fill_data = 0; -+ -+ ffa_info("Preparing for checking partitions count"); -+ -+ } else if (*sp_count) { -+ /* Mode 2: retrieving the partitions information */ -+ -+ fill_data = 1; -+ -+ client_desc_idx = 0; -+ -+ ffa_info("Preparing for filling partitions info"); -+ -+ } else { -+ ffa_err("invalid function arguments provided"); -+ return -EINVAL; -+ } -+ -+ ffa_info("Searching partitions using the provided UUID"); -+ -+ /* -+ * search in the cached partitions -+ */ -+ for (desc_idx = 0; -+ desc_idx < ffa_priv_data->partitions.count; -+ desc_idx++) { -+ if (ffa_uuid_are_identical(&ffa_priv_data->partitions.descs[desc_idx].sp_uuid, -+ &part_uuid)) { -+ ffa_info("Partition ID %x matches the provided UUID", -+ ffa_priv_data->partitions.descs[desc_idx].info.id); -+ -+ sp_found++; -+ -+ if (fill_data) { -+ /* -+ * trying to fill the partition info in the input buffer -+ */ -+ -+ if (client_desc_idx < *sp_count) { -+ buffer[client_desc_idx++] = -+ ffa_priv_data->partitions.descs[desc_idx].info; -+ continue; -+ } -+ -+ ffa_err("failed to fill the current descriptor client buffer full"); -+ return -ENOBUFS; -+ } -+ } -+ } -+ -+ if (!sp_found) { -+ int ret; -+ -+ ffa_info("No partition found. Querying framework ..."); -+ -+ ret = ffa_query_partitions_info(&part_uuid, &sp_found); -+ -+ if (ret == 0) { -+ if (!fill_data) { -+ *sp_count = sp_found; -+ -+ ffa_info("Number of partition(s) found matching the UUID: %d", -+ sp_found); -+ } else { -+ /* -+ * If SPs data detected, they are already in the private data -+ * structure, retry searching SP data again to return them -+ * to the caller -+ */ -+ if (sp_found) -+ ret = ffa_get_partitions_info(dev, uuid_str, sp_count, -+ buffer); -+ else -+ ret = -ENODATA; -+ } -+ } -+ -+ return ret; -+ } -+ -+ /* partition(s) found */ -+ if (!fill_data) -+ *sp_count = sp_found; -+ -+ return 0; -+} -+ -+/** -+ * ffa_cache_partitions_info - Queries and saves all secure partitions data -+ * -+ * This function invokes FFA_PARTITION_INFO_GET FF-A -+ * function to query from secure world all partitions information. -+ * -+ * The FFA_PARTITION_INFO_GET call is issued with nil UUID as an argument. -+ * All installed partitions information are returned. We cache them in the -+ * resident private data structure and we keep the UUID field empty -+ * (in FF-A 1.0 UUID is not provided by the partition descriptor) -+ * -+ * This function is called at the device probing level. -+ * ffa_cache_partitions_info uses ffa_query_partitions_info to get the data -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+static int ffa_cache_partitions_info(void) -+{ -+ return ffa_query_partitions_info(NULL, NULL); -+} -+ -+/** -+ * ffa_msg_send_direct_req - FFA_MSG_SEND_DIRECT_{REQ,RESP} handler function -+ * @dev: The arm_ffa bus device -+ * @dst_part_id: destination partition ID -+ * @msg: pointer to the message data preallocated by the client (in/out) -+ * @is_smc64: select 64-bit or 32-bit FF-A ABI -+ * -+ * This function implements FFA_MSG_SEND_DIRECT_{REQ,RESP} -+ * FF-A functions. -+ * -+ * FFA_MSG_SEND_DIRECT_REQ is used to send the data to the secure partition. -+ * The response from the secure partition is handled by reading the -+ * FFA_MSG_SEND_DIRECT_RESP arguments. -+ * -+ * The maximum size of the data that can be exchanged is 40 bytes which is -+ * sizeof(struct ffa_send_direct_data) as defined by the FF-A specification 1.0 -+ * in the section relevant to FFA_MSG_SEND_DIRECT_{REQ,RESP} -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+static int ffa_msg_send_direct_req(struct udevice *dev, u16 dst_part_id, -+ struct ffa_send_direct_data *msg, bool is_smc64) -+{ -+ ffa_value_t res = {0}; -+ int ffa_errno; -+ u64 req_mode, resp_mode; -+ -+ if (!ffa_priv_data || !ffa_priv_data->invoke_ffa_fn) -+ return -EINVAL; -+ -+ /* No partition installed */ -+ if (!ffa_priv_data->partitions.count || !ffa_priv_data->partitions.descs) -+ return -ENODEV; -+ -+ if (is_smc64) { -+ req_mode = FFA_SMC_64(FFA_MSG_SEND_DIRECT_REQ); -+ resp_mode = FFA_SMC_64(FFA_MSG_SEND_DIRECT_RESP); -+ } else { -+ req_mode = FFA_SMC_32(FFA_MSG_SEND_DIRECT_REQ); -+ resp_mode = FFA_SMC_32(FFA_MSG_SEND_DIRECT_RESP); -+ } -+ -+ ffa_priv_data->invoke_ffa_fn((ffa_value_t){ -+ .a0 = req_mode, -+ .a1 = PREP_SELF_ENDPOINT_ID(ffa_priv_data->id) | -+ PREP_PART_ENDPOINT_ID(dst_part_id), -+ .a2 = 0, -+ .a3 = msg->data0, -+ .a4 = msg->data1, -+ .a5 = msg->data2, -+ .a6 = msg->data3, -+ .a7 = msg->data4, -+ }, &res); -+ -+ while (res.a0 == FFA_SMC_32(FFA_INTERRUPT)) -+ ffa_priv_data->invoke_ffa_fn((ffa_value_t){ -+ .a0 = FFA_SMC_32(FFA_RUN), -+ .a1 = res.a1, -+ }, &res); -+ -+ if (res.a0 == FFA_SMC_32(FFA_SUCCESS)) { -+ /* Message sent with no response */ -+ return 0; -+ } -+ -+ if (res.a0 == resp_mode) { -+ /* -+ * Message sent with response -+ * extract the return data -+ */ -+ msg->data0 = res.a3; -+ msg->data1 = res.a4; -+ msg->data2 = res.a5; -+ msg->data3 = res.a6; -+ msg->data4 = res.a7; -+ -+ return 0; -+ } -+ -+ ffa_errno = res.a2; -+ return ffa_to_std_errno(ffa_errno); -+} -+ -+/** -+ * __arm_ffa_fn_smc - SMC wrapper -+ * @args: FF-A ABI arguments to be copied to Xn registers -+ * @res: FF-A ABI return data to be copied from Xn registers -+ * -+ * Calls low level SMC assembly function -+ * -+ * Return: void -+ */ -+void __arm_ffa_fn_smc(ffa_value_t args, ffa_value_t *res) -+{ -+ arm_smccc_1_2_smc(&args, res); -+} -+ -+/** -+ * ffa_set_smc_conduit - Set the SMC conduit -+ * -+ * This function selects the SMC conduit by setting the driver invoke function -+ * to SMC assembly function -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+static int ffa_set_smc_conduit(void) -+{ -+ ffa_priv_data->invoke_ffa_fn = __arm_ffa_fn_smc; -+ -+ if (!ffa_priv_data->invoke_ffa_fn) { -+ ffa_err("failure to set the invoke function"); -+ return -EINVAL; -+ } -+ -+ ffa_info("Conduit is SMC"); -+ -+ return 0; -+} -+ -+/** -+ * ffa_set_bus_ops - Set the bus driver operations -+ * -+ * Setting the driver callbacks. -+ * -+ */ -+static void ffa_set_bus_ops(void) -+{ -+ ffa_priv_data->ffa_ops.partition_info_get = ffa_get_partitions_info; -+ ffa_priv_data->ffa_ops.sync_send_receive = ffa_msg_send_direct_req; -+ ffa_priv_data->ffa_ops.rxtx_unmap = ffa_unmap_rxtx_buffers; -+} -+ -+/** -+ * ffa_alloc_prvdata - allocate the driver main data structure and sets the device -+ * @dev: the arm_ffa device -+ * -+ * This function creates the main data structure embedding all the driver data. -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+static int ffa_alloc_prvdata(struct udevice *dev) -+{ -+ if (!dev) { -+ ffa_err("no udevice found"); -+ return -ENODEV; -+ } -+ -+ /* The device is registered with the DM. Let's create the driver main data structure*/ -+ -+ ffa_priv_data = devm_kmalloc(dev, sizeof(struct ffa_prvdata), __GFP_ZERO); -+ if (!ffa_priv_data) { -+ ffa_err("can not allocate the driver main data structure"); -+ return -ENOMEM; -+ } -+ -+ ffa_priv_data->dev = dev; -+ -+ return 0; -+} -+ -+/** -+ * ffa_probe - The driver probe function -+ * @dev: the arm_ffa device -+ * -+ * Probing is done at boot time and triggered by the uclass device discovery. -+ * At probe level the following actions are done: -+ * - setting the conduit -+ * - querying the FF-A framework version -+ * - querying from secure world the u-boot endpoint ID -+ * - querying from secure world the supported features of FFA_RXTX_MAP -+ * - mapping the RX/TX buffers -+ * - querying from secure world all the partitions information -+ * -+ * All data queried from secure world is saved in the resident private data structure. -+ * -+ * The probe will fail if either FF-A framework is not detected or the -+ * FF-A requests are not behaving correctly. This ensures that the -+ * driver is not installed and its operations are not exported to the clients. -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+static int ffa_probe(struct udevice *dev) -+{ -+ int ret; -+ -+ ret = ffa_alloc_prvdata(dev); -+ if (ret != 0) -+ return ret; -+ -+ ffa_set_bus_ops(); -+ -+ ret = ffa_set_smc_conduit(); -+ if (ret != 0) -+ return ret; -+ -+ ret = ffa_get_version(); -+ if (ret != 0) -+ return ret; -+ -+ ret = ffa_get_endpoint_id(); -+ if (ret != 0) -+ return ret; -+ -+ ret = ffa_get_rxtx_map_features(); -+ if (ret != 0) -+ return ret; -+ -+ ret = ffa_map_rxtx_buffers(); -+ if (ret != 0) -+ return ret; -+ -+ ret = ffa_cache_partitions_info(); -+ if (ret != 0) { -+ ffa_free_rxtx_buffers(); -+ return ret; -+ } -+ -+ return 0; -+} -+ -+/** -+ * ffa_remove - The driver remove function -+ * @dev: the arm_ffa device -+ * When the device is about to be removed , unmap the RX/TX buffers and free the memory -+ * Return: -+ * -+ * 0 on success. -+ */ -+static int ffa_remove(struct udevice *dev) -+{ -+ ffa_info("removing the device"); -+ -+ ffa_unmap_rxtx_buffers(dev); -+ -+ if (ffa_priv_data->pair.rxbuf || ffa_priv_data->pair.txbuf) -+ ffa_free_rxtx_buffers(); -+ -+ return 0; -+} -+ -+/** -+ * ffa_unbind - The driver unbind function -+ * @dev: the arm_ffa device -+ * After the device is removed and memory freed the device is unbound -+ * Return: -+ * -+ * 0 on success. -+ */ -+static int ffa_unbind(struct udevice *dev) -+{ -+ ffa_info("unbinding the device , private data already released"); -+ -+ ffa_priv_data = NULL; -+ -+ return 0; -+} -+ -+/** -+ * ffa_bus_ops_get - bus driver operations getter -+ * -+ * Return: -+ * This function returns a pointer to the driver operations structure -+ */ -+const struct ffa_bus_ops *ffa_bus_ops_get(void) -+{ -+ return &ffa_priv_data->ffa_ops; -+} -+ -+/** -+ * ffa_bus_prvdata_get - bus driver private data getter -+ * -+ * Return: -+ * This function returns a pointer to the main private data structure -+ */ -+struct ffa_prvdata *ffa_bus_prvdata_get(void) -+{ -+ return ffa_priv_data; -+} -+ -+/** -+ * ffa_bus_discover - discover FF-A bus and probe arm_ffa device -+ * @pdev: the address of a device pointer (to be filled when the arm_ffa bus device is created -+ * successfully) -+ * -+ * This function makes sure the FF-A bus is discoverable. -+ * When probing succeeds FF-A discovery is done. The arm_ffa device is ready to use. -+ * -+ * When the bus was already discovered successfully the discovery will not run again. -+ * -+ * Arm FF-A transport is implemented through arm_ffa u-boot device managing the FF-A -+ * communication. -+ * All FF-A clients should use the arm_ffa device to use the FF-A transport. -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+int ffa_bus_discover(struct udevice **pdev) -+{ -+ int ret = 0; -+ -+ if (!ffa_priv_data) { -+ ret = ffa_device_get(pdev); -+ -+ return ret; -+} -+ -+/** -+ * Declaring the arm_ffa driver under UCLASS_FFA -+ */ -+ -+U_BOOT_DRIVER(arm_ffa) = { -+ .name = FFA_DRV_NAME, -+ .id = UCLASS_FFA, -+ .probe = ffa_probe, -+ .remove = ffa_remove, -+ .unbind = ffa_unbind, -+}; -diff --git a/include/arm_ffa.h b/include/arm_ffa.h -new file mode 100644 -index 0000000000..74b16174c2 ---- /dev/null -+++ b/include/arm_ffa.h -@@ -0,0 +1,97 @@ -+/* SPDX-License-Identifier: GPL-2.0+ */ -+/* -+ * (C) Copyright 2022 ARM Limited -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -+ */ -+ -+#ifndef __ARM_FFA_H -+#define __ARM_FFA_H -+ -+#include <linux/printk.h> -+ -+/* -+ * This header is public. It can be used by clients to access -+ * data structures and definitions they need -+ */ -+ -+/* -+ * Macros for displaying logs -+ */ -+ -+#define ffa_info(fmt, ...) pr_info("[FFA] " fmt "\n", ##__VA_ARGS__) -+#define ffa_err(fmt, ...) pr_err("[FFA] " fmt "\n", ##__VA_ARGS__) -+ -+/* -+ * struct ffa_partition_info - Partition information descriptor -+ * @id: Partition ID -+ * @exec_ctxt: Execution context count -+ * @properties: Partition properties -+ * -+ * Data structure containing information about partitions instantiated in the system -+ * This structure is filled with the data queried by FFA_PARTITION_INFO_GET -+ */ -+struct ffa_partition_info { -+ u16 id; -+ u16 exec_ctxt; -+/* partition supports receipt of direct requests */ -+#define FFA_PARTITION_DIRECT_RECV BIT(0) -+/* partition can send direct requests. */ -+#define FFA_PARTITION_DIRECT_SEND BIT(1) -+/* partition can send and receive indirect messages. */ -+#define FFA_PARTITION_INDIRECT_MSG BIT(2) -+ u32 properties; -+}; -+ -+/* -+ * struct ffa_send_direct_data - Data structure hosting the data -+ * used by FFA_MSG_SEND_DIRECT_{REQ,RESP} -+ * @data0-4: Data read/written from/to x3-x7 registers -+ * -+ * Data structure containing the data to be sent by FFA_MSG_SEND_DIRECT_REQ -+ * or read from FFA_MSG_SEND_DIRECT_RESP -+ */ -+ -+/* For use with FFA_MSG_SEND_DIRECT_{REQ,RESP} which pass data via registers */ -+struct ffa_send_direct_data { -+ unsigned long data0; /* w3/x3 */ -+ unsigned long data1; /* w4/x4 */ -+ unsigned long data2; /* w5/x5 */ -+ unsigned long data3; /* w6/x6 */ -+ unsigned long data4; /* w7/x7 */ -+}; -+ -+struct udevice; -+ -+/** -+ * struct ffa_bus_ops - The driver operations structure -+ * @partition_info_get: callback for the FFA_PARTITION_INFO_GET -+ * @sync_send_receive: callback for the FFA_MSG_SEND_DIRECT_REQ -+ * @rxtx_unmap: callback for the FFA_RXTX_UNMAP -+ * -+ * The data structure providing all the operations supported by the driver. -+ * This structure is EFI runtime resident. -+ */ -+struct ffa_bus_ops { -+ int (*partition_info_get)(struct udevice *dev, const char *uuid_str, -+ u32 *sp_count, struct ffa_partition_info *buffer); -+ int (*sync_send_receive)(struct udevice *dev, u16 dst_part_id, -+ struct ffa_send_direct_data *msg, -+ bool is_smc64); -+ int (*rxtx_unmap)(struct udevice *dev); -+}; -+ -+/** -+ * The device driver and the Uclass driver public functions -+ */ -+ -+/** -+ * ffa_bus_ops_get - driver operations getter -+ */ -+const struct ffa_bus_ops *ffa_bus_ops_get(void); -+ -+/** -+ * ffa_bus_discover - discover FF-A bus and probes the arm_ffa device -+ */ -+int ffa_bus_discover(struct udevice **pdev); -+ -+#endif -diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h -index 376f741cc2..fa08a66ac8 100644 ---- a/include/dm/uclass-id.h -+++ b/include/dm/uclass-id.h -@@ -4,6 +4,9 @@ - * - * (C) Copyright 2012 - * Pavel Herrmann <morpheus.ibis@gmail.com> -+ * -+ * (C) Copyright 2022 ARM Limited -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> - */ - - #ifndef _DM_UCLASS_ID_H -@@ -55,6 +58,7 @@ enum uclass_id { - UCLASS_EFI_MEDIA, /* Devices provided by UEFI firmware */ - UCLASS_ETH, /* Ethernet device */ - UCLASS_ETH_PHY, /* Ethernet PHY device */ -+ UCLASS_FFA, /* Arm Firmware Framework for Armv8-A */ - UCLASS_FIRMWARE, /* Firmware */ - UCLASS_FPGA, /* FPGA device */ - UCLASS_FUZZING_ENGINE, /* Fuzzing engine */ --- -2.25.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0004-FF-A-v15-arm_ffa-introduce-Arm-FF-A-support.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0004-FF-A-v15-arm_ffa-introduce-Arm-FF-A-support.patch new file mode 100644 index 0000000000..f0d67639fc --- /dev/null +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0004-FF-A-v15-arm_ffa-introduce-Arm-FF-A-support.patch @@ -0,0 +1,2132 @@ +From e8b71ec24884a0c973ac663e6802ff529a8be349 Mon Sep 17 00:00:00 2001 +From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> +Date: Mon, 17 Jul 2023 15:11:43 +0100 +Subject: [PATCH 04/33] FF-A v15: arm_ffa: introduce Arm FF-A support + +Add Arm FF-A support implementing Arm Firmware Framework for Armv8-A v1.0 + +The Firmware Framework for Arm A-profile processors (FF-A v1.0) [1] +describes interfaces (ABIs) that standardize communication +between the Secure World and Normal World leveraging TrustZone +technology. + +This driver uses 64-bit registers as per SMCCCv1.2 spec and comes +on top of the SMCCC layer. The driver provides the FF-A ABIs needed for +querying the FF-A framework from the secure world. + +The driver uses SMC32 calling convention which means using the first +32-bit data of the Xn registers. + +All supported ABIs come with their 32-bit version except FFA_RXTX_MAP +which has 64-bit version supported. + +Both 32-bit and 64-bit direct messaging are supported which allows both +32-bit and 64-bit clients to use the FF-A bus. + +FF-A is a discoverable bus and similar to architecture features. +FF-A bus is discovered using ARM_SMCCC_FEATURES mechanism performed +by the PSCI driver. + +Clients are able to probe then use the FF-A bus by calling the DM class +searching APIs (e.g: uclass_first_device). + +The Secure World is considered as one entity to communicate with +using the FF-A bus. FF-A communication is handled by one device and +one instance (the bus). This FF-A driver takes care of all the +interactions between Normal world and Secure World. + +The driver exports its operations to be used by upper layers. + +Exported operations: + +- ffa_partition_info_get +- ffa_sync_send_receive +- ffa_rxtx_unmap + +Generic FF-A methods are implemented in the Uclass (arm-ffa-uclass.c). +Arm specific methods are implemented in the Arm driver (arm-ffa.c). + +For more details please refer to the driver documentation [2]. + +[1]: https://developer.arm.com/documentation/den0077/latest/ +[2]: doc/arch/arm64.ffa.rst + +Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> +Reviewed-by: Simon Glass <sjg@chromium.org> +Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20230713132847.176000-1-abdellatif.elkhlifi@arm.com/] +--- + MAINTAINERS | 8 + + doc/arch/arm64.ffa.rst | 238 ++++ + doc/arch/index.rst | 1 + + drivers/Makefile | 1 + + drivers/firmware/Kconfig | 1 + + drivers/firmware/arm-ffa/Kconfig | 36 + + drivers/firmware/arm-ffa/Makefile | 8 + + drivers/firmware/arm-ffa/arm-ffa-uclass.c | 1065 +++++++++++++++++ + drivers/firmware/arm-ffa/arm-ffa.c | 104 ++ + .../firmware/arm-ffa/sandbox_arm_ffa_priv.h | 14 + + include/arm_ffa.h | 213 ++++ + include/arm_ffa_priv.h | 246 ++++ + include/dm/uclass-id.h | 6 + + 13 files changed, 1941 insertions(+) + create mode 100644 doc/arch/arm64.ffa.rst + create mode 100644 drivers/firmware/arm-ffa/Kconfig + create mode 100644 drivers/firmware/arm-ffa/Makefile + create mode 100644 drivers/firmware/arm-ffa/arm-ffa-uclass.c + create mode 100644 drivers/firmware/arm-ffa/arm-ffa.c + create mode 100644 drivers/firmware/arm-ffa/sandbox_arm_ffa_priv.h + create mode 100644 include/arm_ffa.h + create mode 100644 include/arm_ffa_priv.h + +diff --git a/MAINTAINERS b/MAINTAINERS +index a1122afb01..9c5ebf312c 100644 +--- a/MAINTAINERS ++++ b/MAINTAINERS +@@ -266,6 +266,14 @@ F: drivers/net/cortina_ni.h + F: drivers/net/phy/ca_phy.c + F: configs/cortina_presidio-asic-pnand_defconfig + ++ARM FF-A ++M: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++S: Maintained ++F: doc/arch/arm64.ffa.rst ++F: drivers/firmware/arm-ffa/ ++F: include/arm_ffa.h ++F: include/sandbox_arm_ffa.h ++ + ARM FREESCALE IMX + M: Stefano Babic <sbabic@denx.de> + M: Fabio Estevam <festevam@gmail.com> +diff --git a/doc/arch/arm64.ffa.rst b/doc/arch/arm64.ffa.rst +new file mode 100644 +index 0000000000..4f817f053c +--- /dev/null ++++ b/doc/arch/arm64.ffa.rst +@@ -0,0 +1,238 @@ ++.. SPDX-License-Identifier: GPL-2.0+ ++ ++Arm FF-A Support ++================ ++ ++Summary ++------- ++ ++FF-A stands for Firmware Framework for Arm A-profile processors. ++ ++FF-A specifies interfaces that enable a pair of software execution environments aka partitions to ++communicate with each other. A partition could be a VM in the Normal or Secure world, an ++application in S-EL0, or a Trusted OS in S-EL1. ++ ++The U-Boot FF-A support (the bus) implements the interfaces to communicate ++with partitions in the Secure world aka Secure partitions (SPs). ++ ++The FF-A support specifically focuses on communicating with SPs that ++isolate portions of EFI runtime services that must run in a protected ++environment which is inaccessible by the Host OS or Hypervisor. ++Examples of such services are set/get variables. ++ ++The FF-A support uses the SMC ABIs defined by the FF-A specification to: ++ ++- Discover the presence of SPs of interest ++- Access an SP's service through communication protocols ++ e.g. EFI MM communication protocol ++ ++At this stage of development only EFI boot-time services are supported. ++Runtime support will be added in future developments. ++ ++The U-Boot FF-A support provides the following parts: ++ ++- A Uclass driver providing generic FF-A methods. ++- An Arm FF-A device driver providing Arm-specific methods and reusing the Uclass methods. ++ ++FF-A and SMC specifications ++------------------------------------------- ++ ++The current implementation of the U-Boot FF-A support relies on ++`FF-A v1.0 specification`_ and uses SMC32 calling convention which ++means using the first 32-bit data of the Xn registers. ++ ++At this stage we only need the FF-A v1.0 features. ++ ++The FF-A support has been tested with OP-TEE which supports SMC32 calling ++convention. ++ ++Hypervisors are supported if they are configured to trap SMC calls. ++ ++The FF-A support uses 64-bit registers as per `SMC Calling Convention v1.2 specification`_. ++ ++Supported hardware ++-------------------------------- ++ ++Aarch64 plaforms ++ ++Configuration ++---------------------- ++ ++CONFIG_ARM_FFA_TRANSPORT ++ Enables the FF-A support. Turn this on if you want to use FF-A ++ communication. ++ When using an Arm 64-bit platform, the Arm FF-A driver will be used. ++ ++FF-A ABIs under the hood ++--------------------------------------- ++ ++Invoking an FF-A ABI involves providing to the secure world/hypervisor the ++expected arguments from the ABI. ++ ++On an Arm 64-bit platform, the ABI arguments are stored in x0 to x7 registers. ++Then, an SMC instruction is executed. ++ ++At the secure side level or hypervisor the ABI is handled at a higher exception ++level and the arguments are read and processed. ++ ++The response is put back through x0 to x7 registers and control is given back ++to the U-Boot Arm FF-A driver (non-secure world). ++ ++The driver reads the response and processes it accordingly. ++ ++This methodology applies to all the FF-A ABIs. ++ ++FF-A bus discovery on Arm 64-bit platforms ++--------------------------------------------- ++ ++When CONFIG_ARM_FFA_TRANSPORT is enabled, the FF-A bus is considered as ++an architecture feature and discovered using ARM_SMCCC_FEATURES mechanism. ++This discovery mechanism is performed by the PSCI driver. ++ ++The PSCI driver comes with a PSCI device tree node which is the root node for all ++architecture features including FF-A bus. ++ ++:: ++ ++ => dm tree ++ ++ Class Index Probed Driver Name ++ ----------------------------------------------------------- ++ ... ++ firmware 0 [ + ] psci |-- psci ++ ffa 0 [ ] arm_ffa | `-- arm_ffa ++ ... ++ ++The PSCI driver is bound to the PSCI device and when probed it tries to discover ++the architecture features by calling a callback the features drivers provide. ++ ++In case of FF-A, the callback is arm_ffa_is_supported() which tries to discover the ++FF-A framework by querying the FF-A framework version from secure world using ++FFA_VERSION ABI. When discovery is successful, the ARM_SMCCC_FEATURES ++mechanism creates a U-Boot device for the FF-A bus and binds the Arm FF-A driver ++with the device using device_bind_driver(). ++ ++At this stage the FF-A bus is registered with the DM and can be interacted with using ++the DM APIs. ++ ++Clients are able to probe then use the FF-A bus by calling uclass_first_device(). ++Please refer to the armffa command implementation as an example of how to probe ++and interact with the FF-A bus. ++ ++When calling uclass_first_device(), the FF-A driver is probed and ends up calling ++ffa_do_probe() provided by the Uclass which does the following: ++ ++ - saving the FF-A framework version in uc_priv ++ - querying from secure world the u-boot endpoint ID ++ - querying from secure world the supported features of FFA_RXTX_MAP ++ - mapping the RX/TX buffers ++ - querying from secure world all the partitions information ++ ++When one of the above actions fails, probing fails and the driver stays not active ++and can be probed again if needed. ++ ++Requirements for clients ++------------------------------------- ++ ++When using the FF-A bus with EFI, clients must query the SPs they are looking for ++during EFI boot-time mode using the service UUID. ++ ++The RX/TX buffers are only available at EFI boot-time. Querying partitions is ++done at boot time and data is cached for future use. ++ ++RX/TX buffers should be unmapped before EFI runtime mode starts. ++The driver provides a bus operation for that called ffa_rxtx_unmap(). ++ ++The user should call ffa_rxtx_unmap() to unmap the RX/TX buffers when required ++(e.g: at efi_exit_boot_services()). ++ ++The Linux kernel allocates its own RX/TX buffers. To be able to register these kernel buffers ++with secure world, the U-Boot's RX/TX buffers should be unmapped before EFI runtime starts. ++ ++When invoking FF-A direct messaging, clients should specify which ABI protocol ++they want to use (32-bit vs 64-bit). Selecting the protocol means using ++the 32-bit or 64-bit version of FFA_MSG_SEND_DIRECT_{REQ, RESP}. ++The calling convention between U-Boot and the secure world stays the same: SMC32. ++ ++Requirements for user drivers ++------------------------------------- ++ ++Users who want to implement their custom FF-A device driver while reusing the FF-A Uclass can do so ++by implementing their own invoke_ffa_fn() in the user driver. ++ ++The bus driver layer ++------------------------------ ++ ++FF-A support comes on top of the SMCCC layer and is implemented by the FF-A Uclass drivers/firmware/arm-ffa/arm-ffa-uclass.c ++ ++The following features are provided: ++ ++- Support for the 32-bit version of the following ABIs: ++ ++ - FFA_VERSION ++ - FFA_ID_GET ++ - FFA_FEATURES ++ - FFA_PARTITION_INFO_GET ++ - FFA_RXTX_UNMAP ++ - FFA_RX_RELEASE ++ - FFA_RUN ++ - FFA_ERROR ++ - FFA_SUCCESS ++ - FFA_INTERRUPT ++ - FFA_MSG_SEND_DIRECT_REQ ++ - FFA_MSG_SEND_DIRECT_RESP ++ ++- Support for the 64-bit version of the following ABIs: ++ ++ - FFA_RXTX_MAP ++ - FFA_MSG_SEND_DIRECT_REQ ++ - FFA_MSG_SEND_DIRECT_RESP ++ ++- Processing the received data from the secure world/hypervisor and caching it ++ ++- Hiding from upper layers the FF-A protocol and registers details. Upper ++ layers focus on exchanged data, FF-A support takes care of how to transport ++ that to the secure world/hypervisor using FF-A ++ ++- FF-A support provides driver operations to be used by upper layers: ++ ++ - ffa_partition_info_get ++ - ffa_sync_send_receive ++ - ffa_rxtx_unmap ++ ++- FF-A bus discovery makes sure FF-A framework is responsive and compatible ++ with the driver ++ ++- FF-A bus can be compiled and used without EFI ++ ++Example of boot logs with FF-A enabled ++-------------------------------------- ++ ++For example, when using FF-A with Corstone-1000 the logs are as follows: ++ ++:: ++ ++ U-Boot 2023.01 (May 10 2023 - 11:08:07 +0000) corstone1000 aarch64 ++ ++ DRAM: 2 GiB ++ Arm FF-A framework discovery ++ FF-A driver 1.0 ++ FF-A framework 1.0 ++ FF-A versions are compatible ++ ... ++ FF-A driver 1.0 ++ FF-A framework 1.0 ++ FF-A versions are compatible ++ EFI: MM partition ID 0x8003 ++ ... ++ EFI stub: Booting Linux Kernel... ++ ... ++ Linux version 6.1.9-yocto-standard (oe-user@oe-host) (aarch64-poky-linux-musl-gcc (GCC) 12.2.0, GNU ld (GNU Binutils) 2.40.202301193 ++ Machine model: ARM Corstone1000 FPGA MPS3 board ++ ++Contributors ++------------ ++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++ ++.. _`FF-A v1.0 specification`: https://documentation-service.arm.com/static/5fb7e8a6ca04df4095c1d65e ++.. _`SMC Calling Convention v1.2 specification`: https://documentation-service.arm.com/static/5f8edaeff86e16515cdbe4c6 +diff --git a/doc/arch/index.rst b/doc/arch/index.rst +index b8da4b8c8e..2f916f4026 100644 +--- a/doc/arch/index.rst ++++ b/doc/arch/index.rst +@@ -8,6 +8,7 @@ Architecture-specific doc + + arc + arm64 ++ arm64.ffa + m68k + mips + nios2 +diff --git a/drivers/Makefile b/drivers/Makefile +index 29be78a3f2..6094fac50d 100644 +--- a/drivers/Makefile ++++ b/drivers/Makefile +@@ -114,6 +114,7 @@ obj-y += iommu/ + obj-y += smem/ + obj-y += thermal/ + obj-$(CONFIG_TEE) += tee/ ++obj-$(CONFIG_ARM_FFA_TRANSPORT) += firmware/arm-ffa/ + obj-y += axi/ + obj-y += ufs/ + obj-$(CONFIG_W1) += w1/ +diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig +index eae1c8ddc9..8789b1ea14 100644 +--- a/drivers/firmware/Kconfig ++++ b/drivers/firmware/Kconfig +@@ -45,4 +45,5 @@ config ARM_SMCCC_FEATURES + the PSCI driver is always probed and binds dirvers registered to the Arm SMCCC + services if any and reported as supported by the SMCCC firmware. + ++source "drivers/firmware/arm-ffa/Kconfig" + source "drivers/firmware/scmi/Kconfig" +diff --git a/drivers/firmware/arm-ffa/Kconfig b/drivers/firmware/arm-ffa/Kconfig +new file mode 100644 +index 0000000000..9200c8028b +--- /dev/null ++++ b/drivers/firmware/arm-ffa/Kconfig +@@ -0,0 +1,36 @@ ++# SPDX-License-Identifier: GPL-2.0 ++ ++config ARM_FFA_TRANSPORT ++ bool "Enable Arm Firmware Framework for Armv8-A driver" ++ depends on DM && ARM64 ++ select ARM_SMCCC ++ select ARM_SMCCC_FEATURES ++ select LIB_UUID ++ select DEVRES ++ help ++ The Firmware Framework for Arm A-profile processors (FF-A) ++ describes interfaces (ABIs) that standardize communication ++ between the Secure World and Normal World leveraging TrustZone ++ technology. ++ ++ The FF-A support in U-Boot is based on FF-A specification v1.0 and uses SMC32 ++ calling convention. ++ ++ FF-A specification: ++ ++ https://developer.arm.com/documentation/den0077/a/?lang=en ++ ++ In U-Boot FF-A design, FF-A is considered as a discoverable bus. ++ FF-A bus is discovered using ARM_SMCCC_FEATURES mechanism performed ++ by the PSCI driver. ++ The Secure World is considered as one entity to communicate with ++ using the FF-A bus. ++ FF-A communication is handled by one device and one instance (the bus). ++ The FF-A support on U-Boot takes care of all the interactions between Normal ++ world and Secure World. ++ ++ Generic FF-A methods are implemented in the Uclass (arm-ffa-uclass.c). ++ Arm specific methods are implemented in the Arm driver (arm-ffa.c). ++ ++ For more details about the FF-A support, please refer to doc/arch/arm64.ffa.rst ++ +diff --git a/drivers/firmware/arm-ffa/Makefile b/drivers/firmware/arm-ffa/Makefile +new file mode 100644 +index 0000000000..11b1766285 +--- /dev/null ++++ b/drivers/firmware/arm-ffa/Makefile +@@ -0,0 +1,8 @@ ++# SPDX-License-Identifier: GPL-2.0+ ++# ++# Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++# ++# Authors: ++# Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++ ++obj-y += arm-ffa-uclass.o arm-ffa.o +diff --git a/drivers/firmware/arm-ffa/arm-ffa-uclass.c b/drivers/firmware/arm-ffa/arm-ffa-uclass.c +new file mode 100644 +index 0000000000..ffa9d81fa7 +--- /dev/null ++++ b/drivers/firmware/arm-ffa/arm-ffa-uclass.c +@@ -0,0 +1,1065 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++/* ++ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++ * ++ * Authors: ++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++ */ ++#include <common.h> ++#include <arm_ffa.h> ++#include <arm_ffa_priv.h> ++#include <dm.h> ++#include <log.h> ++#include <malloc.h> ++#include <string.h> ++#include <uuid.h> ++#include <asm/global_data.h> ++#include <dm/device-internal.h> ++#include <dm/devres.h> ++#include <dm/root.h> ++#include <linux/errno.h> ++#include <linux/sizes.h> ++ ++DECLARE_GLOBAL_DATA_PTR; ++ ++/* Error mapping declarations */ ++ ++int ffa_to_std_errmap[MAX_NUMBER_FFA_ERR] = { ++ [NOT_SUPPORTED] = -EOPNOTSUPP, ++ [INVALID_PARAMETERS] = -EINVAL, ++ [NO_MEMORY] = -ENOMEM, ++ [BUSY] = -EBUSY, ++ [INTERRUPTED] = -EINTR, ++ [DENIED] = -EACCES, ++ [RETRY] = -EAGAIN, ++ [ABORTED] = -ECANCELED, ++}; ++ ++static struct ffa_abi_errmap err_msg_map[FFA_ERRMAP_COUNT] = { ++ [FFA_ID_TO_ERRMAP_ID(FFA_VERSION)] = { ++ { ++ [NOT_SUPPORTED] = ++ "NOT_SUPPORTED: A Firmware Framework implementation does not exist", ++ }, ++ }, ++ [FFA_ID_TO_ERRMAP_ID(FFA_ID_GET)] = { ++ { ++ [NOT_SUPPORTED] = ++ "NOT_SUPPORTED: This function is not implemented at this FF-A instance", ++ }, ++ }, ++ [FFA_ID_TO_ERRMAP_ID(FFA_FEATURES)] = { ++ { ++ [NOT_SUPPORTED] = ++ "NOT_SUPPORTED: FFA_RXTX_MAP is not implemented at this FF-A instance", ++ }, ++ }, ++ [FFA_ID_TO_ERRMAP_ID(FFA_PARTITION_INFO_GET)] = { ++ { ++ [NOT_SUPPORTED] = ++ "NOT_SUPPORTED: This function is not implemented at this FF-A instance", ++ [INVALID_PARAMETERS] = ++ "INVALID_PARAMETERS: Unrecognized UUID", ++ [NO_MEMORY] = ++ "NO_MEMORY: Results cannot fit in RX buffer of the caller", ++ [BUSY] = ++ "BUSY: RX buffer of the caller is not free", ++ [DENIED] = ++ "DENIED: Callee is not in a state to handle this request", ++ }, ++ }, ++ [FFA_ID_TO_ERRMAP_ID(FFA_RXTX_UNMAP)] = { ++ { ++ [NOT_SUPPORTED] = ++ "NOT_SUPPORTED: FFA_RXTX_UNMAP is not implemented at this FF-A instance", ++ [INVALID_PARAMETERS] = ++ "INVALID_PARAMETERS: No buffer pair registered on behalf of the caller", ++ }, ++ }, ++ [FFA_ID_TO_ERRMAP_ID(FFA_RX_RELEASE)] = { ++ { ++ [NOT_SUPPORTED] = ++ "NOT_SUPPORTED: FFA_RX_RELEASE is not implemented at this FF-A instance", ++ [DENIED] = ++ "DENIED: Caller did not have ownership of the RX buffer", ++ }, ++ }, ++ [FFA_ID_TO_ERRMAP_ID(FFA_RXTX_MAP)] = { ++ { ++ [NOT_SUPPORTED] = ++ "NOT_SUPPORTED: This function is not implemented at this FF-A instance", ++ [INVALID_PARAMETERS] = ++ "INVALID_PARAMETERS: Field(s) in input parameters incorrectly encoded", ++ [NO_MEMORY] = ++ "NO_MEMORY: Not enough memory", ++ [DENIED] = ++ "DENIED: Buffer pair already registered", ++ }, ++ }, ++}; ++ ++/** ++ * ffa_to_std_errno() - convert FF-A error code to standard error code ++ * @ffa_errno: Error code returned by the FF-A ABI ++ * ++ * Map the given FF-A error code as specified ++ * by the spec to a u-boot standard error code. ++ * ++ * Return: ++ * ++ * The standard error code on success. . Otherwise, failure ++ */ ++static int ffa_to_std_errno(int ffa_errno) ++{ ++ int err_idx = -ffa_errno; ++ ++ /* Map the FF-A error code to the standard u-boot error code */ ++ if (err_idx > 0 && err_idx < MAX_NUMBER_FFA_ERR) ++ return ffa_to_std_errmap[err_idx]; ++ return -EINVAL; ++} ++ ++/** ++ * ffa_print_error_log() - print the error log corresponding to the selected FF-A ABI ++ * @ffa_id: FF-A ABI ID ++ * @ffa_errno: Error code returned by the FF-A ABI ++ * ++ * Map the FF-A error code to the error log relevant to the ++ * selected FF-A ABI. Then the error log is printed. ++ * ++ * Return: ++ * ++ * 0 on success. . Otherwise, failure ++ */ ++static int ffa_print_error_log(u32 ffa_id, int ffa_errno) ++{ ++ int err_idx = -ffa_errno, abi_idx = 0; ++ ++ /* Map the FF-A error code to the corresponding error log */ ++ ++ if (err_idx <= 0 || err_idx >= MAX_NUMBER_FFA_ERR) ++ return -EINVAL; ++ ++ if (ffa_id < FFA_FIRST_ID || ffa_id > FFA_LAST_ID) ++ return -EINVAL; ++ ++ abi_idx = FFA_ID_TO_ERRMAP_ID(ffa_id); ++ if (abi_idx < 0 || abi_idx >= FFA_ERRMAP_COUNT) ++ return -EINVAL; ++ ++ if (!err_msg_map[abi_idx].err_str[err_idx]) ++ return -EINVAL; ++ ++ log_err("%s\n", err_msg_map[abi_idx].err_str[err_idx]); ++ ++ return 0; ++} ++ ++/* FF-A ABIs implementation (U-Boot side) */ ++ ++/** ++ * invoke_ffa_fn() - SMC wrapper ++ * @args: FF-A ABI arguments to be copied to Xn registers ++ * @res: FF-A ABI return data to be copied from Xn registers ++ * ++ * Calls low level SMC implementation. ++ * This function should be implemented by the user driver. ++ */ ++void __weak invoke_ffa_fn(ffa_value_t args, ffa_value_t *res) ++{ ++} ++ ++/** ++ * ffa_get_version_hdlr() - FFA_VERSION handler function ++ * @dev: The FF-A bus device ++ * ++ * Implement FFA_VERSION FF-A function ++ * to get from the secure world the FF-A framework version ++ * FFA_VERSION is used to discover the FF-A framework. ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++int ffa_get_version_hdlr(struct udevice *dev) ++{ ++ u16 major, minor; ++ ffa_value_t res = {0}; ++ int ffa_errno; ++ struct ffa_priv *uc_priv; ++ ++ invoke_ffa_fn((ffa_value_t){ ++ .a0 = FFA_SMC_32(FFA_VERSION), .a1 = FFA_VERSION_1_0, ++ }, &res); ++ ++ ffa_errno = res.a0; ++ if (ffa_errno < 0) { ++ ffa_print_error_log(FFA_VERSION, ffa_errno); ++ return ffa_to_std_errno(ffa_errno); ++ } ++ ++ major = GET_FFA_MAJOR_VERSION(res.a0); ++ minor = GET_FFA_MINOR_VERSION(res.a0); ++ ++ log_info("FF-A driver %d.%d\nFF-A framework %d.%d\n", ++ FFA_MAJOR_VERSION, FFA_MINOR_VERSION, major, minor); ++ ++ if (major == FFA_MAJOR_VERSION && minor >= FFA_MINOR_VERSION) { ++ log_info("FF-A versions are compatible\n"); ++ ++ if (dev) { ++ uc_priv = dev_get_uclass_priv(dev); ++ if (uc_priv) ++ uc_priv->fwk_version = res.a0; ++ } ++ ++ return 0; ++ } ++ ++ log_err("versions are incompatible\nExpected: %d.%d , Found: %d.%d\n", ++ FFA_MAJOR_VERSION, FFA_MINOR_VERSION, major, minor); ++ ++ return -EPROTONOSUPPORT; ++} ++ ++/** ++ * ffa_get_endpoint_id() - FFA_ID_GET handler function ++ * @dev: The FF-A bus device ++ * ++ * Implement FFA_ID_GET FF-A function ++ * to get from the secure world u-boot endpoint ID ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++static int ffa_get_endpoint_id(struct udevice *dev) ++{ ++ ffa_value_t res = {0}; ++ int ffa_errno; ++ struct ffa_priv *uc_priv = dev_get_uclass_priv(dev); ++ ++ invoke_ffa_fn((ffa_value_t){ ++ .a0 = FFA_SMC_32(FFA_ID_GET), ++ }, &res); ++ ++ if (res.a0 == FFA_SMC_32(FFA_SUCCESS)) { ++ uc_priv->id = GET_SELF_ENDPOINT_ID((u32)res.a2); ++ log_debug("FF-A endpoint ID is %u\n", uc_priv->id); ++ ++ return 0; ++ } ++ ++ ffa_errno = res.a2; ++ ++ ffa_print_error_log(FFA_ID_GET, ffa_errno); ++ ++ return ffa_to_std_errno(ffa_errno); ++} ++ ++/** ++ * ffa_set_rxtx_buffers_pages_cnt() - set the minimum number of pages in each of the RX/TX buffers ++ * @dev: The FF-A bus device ++ * @prop_field: properties field obtained from FFA_FEATURES ABI ++ * ++ * Set the minimum number of pages in each of the RX/TX buffers in uc_priv ++ * ++ * Return: ++ * ++ * rxtx_min_pages field contains the returned number of pages ++ * 0 on success. Otherwise, failure ++ */ ++static int ffa_set_rxtx_buffers_pages_cnt(struct udevice *dev, u32 prop_field) ++{ ++ struct ffa_priv *uc_priv = dev_get_uclass_priv(dev); ++ ++ switch (prop_field) { ++ case RXTX_4K: ++ uc_priv->pair.rxtx_min_pages = 1; ++ break; ++ case RXTX_16K: ++ uc_priv->pair.rxtx_min_pages = 4; ++ break; ++ case RXTX_64K: ++ uc_priv->pair.rxtx_min_pages = 16; ++ break; ++ default: ++ log_err("RX/TX buffer size not supported\n"); ++ return -EINVAL; ++ } ++ ++ return 0; ++} ++ ++/** ++ * ffa_get_rxtx_map_features_hdlr() - FFA_FEATURES handler function with FFA_RXTX_MAP argument ++ * @dev: The FF-A bus device ++ * ++ * Implement FFA_FEATURES FF-A function to retrieve the FFA_RXTX_MAP features ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++static int ffa_get_rxtx_map_features_hdlr(struct udevice *dev) ++{ ++ ffa_value_t res = {0}; ++ int ffa_errno; ++ ++ invoke_ffa_fn((ffa_value_t){ ++ .a0 = FFA_SMC_32(FFA_FEATURES), ++ .a1 = FFA_SMC_64(FFA_RXTX_MAP), ++ }, &res); ++ ++ if (res.a0 == FFA_SMC_32(FFA_SUCCESS)) ++ return ffa_set_rxtx_buffers_pages_cnt(dev, res.a2); ++ ++ ffa_errno = res.a2; ++ ffa_print_error_log(FFA_FEATURES, ffa_errno); ++ ++ return ffa_to_std_errno(ffa_errno); ++} ++ ++/** ++ * ffa_free_rxtx_buffers() - free the RX/TX buffers ++ * @dev: The FF-A bus device ++ * ++ * Free the RX/TX buffers ++ */ ++static void ffa_free_rxtx_buffers(struct udevice *dev) ++{ ++ struct ffa_priv *uc_priv = dev_get_uclass_priv(dev); ++ ++ log_debug("Freeing FF-A RX/TX buffers\n"); ++ ++ if (uc_priv->pair.rxbuf) { ++ free(uc_priv->pair.rxbuf); ++ uc_priv->pair.rxbuf = NULL; ++ } ++ ++ if (uc_priv->pair.txbuf) { ++ free(uc_priv->pair.txbuf); ++ uc_priv->pair.txbuf = NULL; ++ } ++} ++ ++/** ++ * ffa_alloc_rxtx_buffers() - allocate the RX/TX buffers ++ * @dev: The FF-A bus device ++ * ++ * Used by ffa_map_rxtx_buffers to allocate ++ * the RX/TX buffers before mapping them. The allocated memory is physically ++ * contiguous since memalign ends up calling malloc which allocates ++ * contiguous memory in u-boot. ++ * The size of the memory allocated is the minimum allowed. ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++static int ffa_alloc_rxtx_buffers(struct udevice *dev) ++{ ++ u64 bytes; ++ struct ffa_priv *uc_priv = dev_get_uclass_priv(dev); ++ ++ log_debug("Using %lu 4KB page(s) for FF-A RX/TX buffers size\n", ++ uc_priv->pair.rxtx_min_pages); ++ ++ bytes = uc_priv->pair.rxtx_min_pages * SZ_4K; ++ ++ /* ++ * The alignment of the RX and TX buffers must be equal ++ * to the larger translation granule size ++ * Assumption: Memory allocated with memalign is always physically contiguous ++ */ ++ ++ uc_priv->pair.rxbuf = memalign(bytes, bytes); ++ if (!uc_priv->pair.rxbuf) { ++ log_err("failure to allocate RX buffer\n"); ++ return -ENOBUFS; ++ } ++ ++ log_debug("FF-A RX buffer at virtual address %p\n", uc_priv->pair.rxbuf); ++ ++ uc_priv->pair.txbuf = memalign(bytes, bytes); ++ if (!uc_priv->pair.txbuf) { ++ free(uc_priv->pair.rxbuf); ++ uc_priv->pair.rxbuf = NULL; ++ log_err("failure to allocate the TX buffer\n"); ++ return -ENOBUFS; ++ } ++ ++ log_debug("FF-A TX buffer at virtual address %p\n", uc_priv->pair.txbuf); ++ ++ /* Make sure the buffers are cleared before use */ ++ memset(uc_priv->pair.rxbuf, 0, bytes); ++ memset(uc_priv->pair.txbuf, 0, bytes); ++ ++ return 0; ++} ++ ++/** ++ * ffa_map_rxtx_buffers_hdlr() - FFA_RXTX_MAP handler function ++ * @dev: The FF-A bus device ++ * ++ * Implement FFA_RXTX_MAP FF-A function to map the RX/TX buffers ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++static int ffa_map_rxtx_buffers_hdlr(struct udevice *dev) ++{ ++ int ret; ++ ffa_value_t res = {0}; ++ int ffa_errno; ++ struct ffa_priv *uc_priv = dev_get_uclass_priv(dev); ++ ++ ret = ffa_alloc_rxtx_buffers(dev); ++ if (ret) ++ return ret; ++ ++ /* ++ * we need to pass the physical addresses of the RX/TX buffers ++ * in u-boot physical/virtual mapping is 1:1 ++ * no need to convert from virtual to physical ++ */ ++ ++ invoke_ffa_fn((ffa_value_t){ ++ .a0 = FFA_SMC_64(FFA_RXTX_MAP), ++ .a1 = map_to_sysmem(uc_priv->pair.txbuf), ++ .a2 = map_to_sysmem(uc_priv->pair.rxbuf), ++ .a3 = uc_priv->pair.rxtx_min_pages, ++ }, &res); ++ ++ if (res.a0 == FFA_SMC_32(FFA_SUCCESS)) { ++ log_debug("FF-A RX/TX buffers mapped\n"); ++ return 0; ++ } ++ ++ ffa_errno = res.a2; ++ ffa_print_error_log(FFA_RXTX_MAP, ffa_errno); ++ ++ ffa_free_rxtx_buffers(dev); ++ ++ return ffa_to_std_errno(ffa_errno); ++} ++ ++/** ++ * ffa_unmap_rxtx_buffers_hdlr() - FFA_RXTX_UNMAP handler function ++ * @dev: The FF-A bus device ++ * ++ * Implement FFA_RXTX_UNMAP FF-A function to unmap the RX/TX buffers ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++int ffa_unmap_rxtx_buffers_hdlr(struct udevice *dev) ++{ ++ ffa_value_t res = {0}; ++ int ffa_errno; ++ struct ffa_priv *uc_priv; ++ ++ log_debug("unmapping FF-A RX/TX buffers\n"); ++ ++ uc_priv = dev_get_uclass_priv(dev); ++ ++ invoke_ffa_fn((ffa_value_t){ ++ .a0 = FFA_SMC_32(FFA_RXTX_UNMAP), ++ .a1 = PREP_SELF_ENDPOINT_ID(uc_priv->id), ++ }, &res); ++ ++ if (res.a0 == FFA_SMC_32(FFA_SUCCESS)) { ++ ffa_free_rxtx_buffers(dev); ++ return 0; ++ } ++ ++ ffa_errno = res.a2; ++ ffa_print_error_log(FFA_RXTX_UNMAP, ffa_errno); ++ ++ return ffa_to_std_errno(ffa_errno); ++} ++ ++/** ++ * ffa_release_rx_buffer_hdlr() - FFA_RX_RELEASE handler function ++ * @dev: The FF-A bus device ++ * ++ * Invoke FFA_RX_RELEASE FF-A function to release the ownership of the RX buffer ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++static int ffa_release_rx_buffer_hdlr(struct udevice *dev) ++{ ++ ffa_value_t res = {0}; ++ int ffa_errno; ++ ++ invoke_ffa_fn((ffa_value_t){ ++ .a0 = FFA_SMC_32(FFA_RX_RELEASE), ++ }, &res); ++ ++ if (res.a0 == FFA_SMC_32(FFA_SUCCESS)) ++ return 0; ++ ++ ffa_errno = res.a2; ++ ffa_print_error_log(FFA_RX_RELEASE, ffa_errno); ++ ++ return ffa_to_std_errno(ffa_errno); ++} ++ ++/** ++ * ffa_uuid_are_identical() - check whether two given UUIDs are identical ++ * @uuid1: first UUID ++ * @uuid2: second UUID ++ * ++ * Used by ffa_read_partitions_info to search for a UUID in the partitions descriptors table ++ * ++ * Return: ++ * ++ * 1 when UUIDs match. Otherwise, 0 ++ */ ++static bool ffa_uuid_are_identical(const struct ffa_partition_uuid *uuid1, ++ const struct ffa_partition_uuid *uuid2) ++{ ++ if (!uuid1 || !uuid2) ++ return 0; ++ ++ return !memcmp(uuid1, uuid2, sizeof(struct ffa_partition_uuid)); ++} ++ ++/** ++ * ffa_read_partitions_info() - read queried partition data ++ * @dev: The FF-A bus device ++ * @count: The number of partitions queried ++ * @part_uuid: Pointer to the partition(s) UUID ++ * ++ * Read the partitions information returned by the FFA_PARTITION_INFO_GET and saves it in uc_priv ++ * ++ * Return: ++ * ++ * uc_priv is updated with the partition(s) information ++ * 0 is returned on success. Otherwise, failure ++ */ ++static int ffa_read_partitions_info(struct udevice *dev, u32 count, ++ struct ffa_partition_uuid *part_uuid) ++{ ++ struct ffa_priv *uc_priv = dev_get_uclass_priv(dev); ++ ++ if (!count) { ++ log_err("no partition detected\n"); ++ return -ENODATA; ++ } ++ ++ log_debug("Reading FF-A partitions data from the RX buffer\n"); ++ ++ if (!part_uuid) { ++ /* Querying information of all partitions */ ++ u64 buf_bytes; ++ u64 data_bytes; ++ u32 desc_idx; ++ struct ffa_partition_info *parts_info; ++ ++ data_bytes = count * sizeof(struct ffa_partition_desc); ++ ++ buf_bytes = uc_priv->pair.rxtx_min_pages * SZ_4K; ++ ++ if (data_bytes > buf_bytes) { ++ log_err("partitions data size exceeds the RX buffer size:\n"); ++ log_err(" sizes in bytes: data %llu , RX buffer %llu\n", ++ data_bytes, ++ buf_bytes); ++ ++ return -ENOMEM; ++ } ++ ++ uc_priv->partitions.descs = devm_kmalloc(dev, data_bytes, __GFP_ZERO); ++ if (!uc_priv->partitions.descs) { ++ log_err("cannot allocate partitions data buffer\n"); ++ return -ENOMEM; ++ } ++ ++ parts_info = uc_priv->pair.rxbuf; ++ ++ for (desc_idx = 0 ; desc_idx < count ; desc_idx++) { ++ uc_priv->partitions.descs[desc_idx].info = ++ parts_info[desc_idx]; ++ ++ log_debug("FF-A partition ID %x : info cached\n", ++ uc_priv->partitions.descs[desc_idx].info.id); ++ } ++ ++ uc_priv->partitions.count = count; ++ ++ log_debug("%d FF-A partition(s) found and cached\n", count); ++ ++ } else { ++ u32 rx_desc_idx, cached_desc_idx; ++ struct ffa_partition_info *parts_info; ++ u8 desc_found; ++ ++ parts_info = uc_priv->pair.rxbuf; ++ ++ /* ++ * Search for the SP IDs read from the RX buffer ++ * in the already cached SPs. ++ * Update the UUID when ID found. ++ */ ++ for (rx_desc_idx = 0; rx_desc_idx < count ; rx_desc_idx++) { ++ desc_found = 0; ++ ++ /* Search the current ID in the cached partitions */ ++ for (cached_desc_idx = 0; ++ cached_desc_idx < uc_priv->partitions.count; ++ cached_desc_idx++) { ++ /* Save the UUID */ ++ if (uc_priv->partitions.descs[cached_desc_idx].info.id == ++ parts_info[rx_desc_idx].id) { ++ uc_priv->partitions.descs[cached_desc_idx].sp_uuid = ++ *part_uuid; ++ ++ desc_found = 1; ++ break; ++ } ++ } ++ ++ if (!desc_found) ++ return -ENODATA; ++ } ++ } ++ ++ return 0; ++} ++ ++/** ++ * ffa_query_partitions_info() - invoke FFA_PARTITION_INFO_GET and save partitions data ++ * @dev: The FF-A bus device ++ * @part_uuid: Pointer to the partition(s) UUID ++ * @pcount: Pointer to the number of partitions variable filled when querying ++ * ++ * Execute the FFA_PARTITION_INFO_GET to query the partitions data. ++ * Then, call ffa_read_partitions_info to save the data in uc_priv. ++ * ++ * After reading the data the RX buffer is released using ffa_release_rx_buffer ++ * ++ * Return: ++ * ++ * When part_uuid is NULL, all partitions data are retrieved from secure world ++ * When part_uuid is non NULL, data for partitions matching the given UUID are ++ * retrieved and the number of partitions is returned ++ * 0 is returned on success. Otherwise, failure ++ */ ++static int ffa_query_partitions_info(struct udevice *dev, struct ffa_partition_uuid *part_uuid, ++ u32 *pcount) ++{ ++ struct ffa_partition_uuid query_uuid = {0}; ++ ffa_value_t res = {0}; ++ int ffa_errno; ++ ++ /* ++ * If a UUID is specified. Information for one or more ++ * partitions in the system is queried. Otherwise, information ++ * for all installed partitions is queried ++ */ ++ ++ if (part_uuid) { ++ if (!pcount) ++ return -EINVAL; ++ ++ query_uuid = *part_uuid; ++ } else if (pcount) { ++ return -EINVAL; ++ } ++ ++ invoke_ffa_fn((ffa_value_t){ ++ .a0 = FFA_SMC_32(FFA_PARTITION_INFO_GET), ++ .a1 = query_uuid.a1, ++ .a2 = query_uuid.a2, ++ .a3 = query_uuid.a3, ++ .a4 = query_uuid.a4, ++ }, &res); ++ ++ if (res.a0 == FFA_SMC_32(FFA_SUCCESS)) { ++ int ret; ++ ++ /* ++ * res.a2 contains the count of partition information descriptors ++ * populated in the RX buffer ++ */ ++ if (res.a2) { ++ ret = ffa_read_partitions_info(dev, (u32)res.a2, part_uuid); ++ if (ret) { ++ log_err("failed reading SP(s) data , err (%d)\n", ret); ++ ffa_release_rx_buffer_hdlr(dev); ++ return -EINVAL; ++ } ++ } ++ ++ /* Return the SP count (when querying using a UUID) */ ++ if (pcount) ++ *pcount = (u32)res.a2; ++ ++ /* ++ * After calling FFA_PARTITION_INFO_GET the buffer ownership ++ * is assigned to the consumer (u-boot). So, we need to give ++ * the ownership back to the SPM or hypervisor ++ */ ++ ret = ffa_release_rx_buffer_hdlr(dev); ++ ++ return ret; ++ } ++ ++ ffa_errno = res.a2; ++ ffa_print_error_log(FFA_PARTITION_INFO_GET, ffa_errno); ++ ++ return ffa_to_std_errno(ffa_errno); ++} ++ ++/** ++ * ffa_get_partitions_info_hdlr() - FFA_PARTITION_INFO_GET handler function ++ * @uuid_str: pointer to the UUID string ++ * @sp_count: address of the variable containing the number of partitions matching the UUID ++ * The variable is set by the driver ++ * @sp_descs: address of the descriptors of the partitions matching the UUID ++ * The address is set by the driver ++ * ++ * Return the number of partitions and their descriptors matching the UUID ++ * ++ * Query the secure partition data from uc_priv. ++ * If not found, invoke FFA_PARTITION_INFO_GET FF-A function to query the partition information ++ * from secure world. ++ * ++ * A client of the FF-A driver should know the UUID of the service it wants to ++ * access. It should use the UUID to request the FF-A driver to provide the ++ * partition(s) information of the service. The FF-A driver uses ++ * PARTITION_INFO_GET to obtain this information. This is implemented through ++ * ffa_get_partitions_info_hdlr() function. ++ * If the partition(s) matching the UUID found, the partition(s) information and the ++ * number are returned. ++ * If no partition matching the UUID is found in the cached area, a new FFA_PARTITION_INFO_GET ++ * call is issued. ++ * If not done yet, the UUID is updated in the cached area. ++ * This assumes that partitions data does not change in the secure world. ++ * Otherwise u-boot will have an outdated partition data. The benefit of caching ++ * the information in the FF-A driver is to accommodate discovery after ++ * ExitBootServices(). ++ * ++ * Return: ++ * ++ * @sp_count: the number of partitions ++ * @sp_descs: address of the partitions descriptors ++ * ++ * On success 0 is returned. Otherwise, failure ++ */ ++int ffa_get_partitions_info_hdlr(struct udevice *dev, const char *uuid_str, ++ u32 *sp_count, struct ffa_partition_desc **sp_descs) ++{ ++ u32 i; ++ struct ffa_partition_uuid part_uuid = {0}; ++ struct ffa_priv *uc_priv; ++ struct ffa_partition_desc *rx_descs; ++ ++ uc_priv = dev_get_uclass_priv(dev); ++ ++ if (!uc_priv->partitions.count || !uc_priv->partitions.descs) { ++ log_err("no partition installed\n"); ++ return -EINVAL; ++ } ++ ++ if (!uuid_str) { ++ log_err("no UUID provided\n"); ++ return -EINVAL; ++ } ++ ++ if (!sp_count) { ++ log_err("no count argument provided\n"); ++ return -EINVAL; ++ } ++ ++ if (!sp_descs) { ++ log_err("no info argument provided\n"); ++ return -EINVAL; ++ } ++ ++ if (uuid_str_to_le_bin(uuid_str, (unsigned char *)&part_uuid)) { ++ log_err("invalid UUID\n"); ++ return -EINVAL; ++ } ++ ++ log_debug("Searching FF-A partitions using the provided UUID\n"); ++ ++ *sp_count = 0; ++ *sp_descs = uc_priv->pair.rxbuf; ++ rx_descs = *sp_descs; ++ ++ /* Search in the cached partitions */ ++ for (i = 0; i < uc_priv->partitions.count; i++) ++ if (ffa_uuid_are_identical(&uc_priv->partitions.descs[i].sp_uuid, ++ &part_uuid)) { ++ log_debug("FF-A partition ID %x matches the provided UUID\n", ++ uc_priv->partitions.descs[i].info.id); ++ ++ (*sp_count)++; ++ *rx_descs++ = uc_priv->partitions.descs[i]; ++ } ++ ++ if (!(*sp_count)) { ++ int ret; ++ ++ log_debug("No FF-A partition found. Querying framework ...\n"); ++ ++ ret = ffa_query_partitions_info(dev, &part_uuid, sp_count); ++ ++ if (!ret) { ++ log_debug("Number of FF-A partition(s) matching the UUID: %d\n", *sp_count); ++ ++ if (*sp_count) ++ ret = ffa_get_partitions_info_hdlr(dev, uuid_str, sp_count, ++ sp_descs); ++ else ++ ret = -ENODATA; ++ } ++ ++ return ret; ++ } ++ ++ return 0; ++} ++ ++/** ++ * ffa_cache_partitions_info() - Query and saves all secure partitions data ++ * @dev: The FF-A bus device ++ * ++ * Invoke FFA_PARTITION_INFO_GET FF-A function to query from secure world ++ * all partitions information. ++ * ++ * The FFA_PARTITION_INFO_GET call is issued with nil UUID as an argument. ++ * All installed partitions information are returned. We cache them in uc_priv ++ * and we keep the UUID field empty (in FF-A 1.0 UUID is not provided by the partition descriptor) ++ * ++ * Called at the device probing level. ++ * ffa_cache_partitions_info uses ffa_query_partitions_info to get the data ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++static int ffa_cache_partitions_info(struct udevice *dev) ++{ ++ return ffa_query_partitions_info(dev, NULL, NULL); ++} ++ ++/** ++ * ffa_msg_send_direct_req_hdlr() - FFA_MSG_SEND_DIRECT_{REQ,RESP} handler function ++ * @dev: The FF-A bus device ++ * @dst_part_id: destination partition ID ++ * @msg: pointer to the message data preallocated by the client (in/out) ++ * @is_smc64: select 64-bit or 32-bit FF-A ABI ++ * ++ * Implement FFA_MSG_SEND_DIRECT_{REQ,RESP} ++ * FF-A functions. ++ * ++ * FFA_MSG_SEND_DIRECT_REQ is used to send the data to the secure partition. ++ * The response from the secure partition is handled by reading the ++ * FFA_MSG_SEND_DIRECT_RESP arguments. ++ * ++ * The maximum size of the data that can be exchanged is 40 bytes which is ++ * sizeof(struct ffa_send_direct_data) as defined by the FF-A specification 1.0 ++ * in the section relevant to FFA_MSG_SEND_DIRECT_{REQ,RESP} ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++int ffa_msg_send_direct_req_hdlr(struct udevice *dev, u16 dst_part_id, ++ struct ffa_send_direct_data *msg, bool is_smc64) ++{ ++ ffa_value_t res = {0}; ++ int ffa_errno; ++ u64 req_mode, resp_mode; ++ struct ffa_priv *uc_priv; ++ ++ uc_priv = dev_get_uclass_priv(dev); ++ ++ /* No partition installed */ ++ if (!uc_priv->partitions.count || !uc_priv->partitions.descs) ++ return -ENODEV; ++ ++ if (is_smc64) { ++ req_mode = FFA_SMC_64(FFA_MSG_SEND_DIRECT_REQ); ++ resp_mode = FFA_SMC_64(FFA_MSG_SEND_DIRECT_RESP); ++ } else { ++ req_mode = FFA_SMC_32(FFA_MSG_SEND_DIRECT_REQ); ++ resp_mode = FFA_SMC_32(FFA_MSG_SEND_DIRECT_RESP); ++ } ++ ++ invoke_ffa_fn((ffa_value_t){ ++ .a0 = req_mode, ++ .a1 = PREP_SELF_ENDPOINT_ID(uc_priv->id) | ++ PREP_PART_ENDPOINT_ID(dst_part_id), ++ .a2 = 0, ++ .a3 = msg->data0, ++ .a4 = msg->data1, ++ .a5 = msg->data2, ++ .a6 = msg->data3, ++ .a7 = msg->data4, ++ }, &res); ++ ++ while (res.a0 == FFA_SMC_32(FFA_INTERRUPT)) ++ invoke_ffa_fn((ffa_value_t){ ++ .a0 = FFA_SMC_32(FFA_RUN), ++ .a1 = res.a1, ++ }, &res); ++ ++ if (res.a0 == FFA_SMC_32(FFA_SUCCESS)) { ++ /* Message sent with no response */ ++ return 0; ++ } ++ ++ if (res.a0 == resp_mode) { ++ /* Message sent with response extract the return data */ ++ msg->data0 = res.a3; ++ msg->data1 = res.a4; ++ msg->data2 = res.a5; ++ msg->data3 = res.a6; ++ msg->data4 = res.a7; ++ ++ return 0; ++ } ++ ++ ffa_errno = res.a2; ++ return ffa_to_std_errno(ffa_errno); ++} ++ ++/* FF-A driver operations (used by clients for communicating with FF-A)*/ ++ ++/** ++ * ffa_partition_info_get() - FFA_PARTITION_INFO_GET driver operation ++ * @uuid_str: pointer to the UUID string ++ * @sp_count: address of the variable containing the number of partitions matching the UUID ++ * The variable is set by the driver ++ * @sp_descs: address of the descriptors of the partitions matching the UUID ++ * The address is set by the driver ++ * ++ * Driver operation for FFA_PARTITION_INFO_GET. ++ * Please see ffa_get_partitions_info_hdlr() description for more details. ++ * ++ * Return: ++ * ++ * @sp_count: the number of partitions ++ * @sp_descs: address of the partitions descriptors ++ * ++ * On success 0 is returned. Otherwise, failure ++ */ ++int ffa_partition_info_get(struct udevice *dev, const char *uuid_str, ++ u32 *sp_count, struct ffa_partition_desc **sp_descs) ++{ ++ struct ffa_bus_ops *ops = ffa_get_ops(dev); ++ ++ if (!ops->partition_info_get) ++ return -ENOSYS; ++ ++ return ops->partition_info_get(dev, uuid_str, sp_count, sp_descs); ++} ++ ++/** ++ * ffa_sync_send_receive() - FFA_MSG_SEND_DIRECT_{REQ,RESP} driver operation ++ * @dev: The FF-A bus device ++ * @dst_part_id: destination partition ID ++ * @msg: pointer to the message data preallocated by the client (in/out) ++ * @is_smc64: select 64-bit or 32-bit FF-A ABI ++ * ++ * Driver operation for FFA_MSG_SEND_DIRECT_{REQ,RESP}. ++ * Please see ffa_msg_send_direct_req_hdlr() description for more details. ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++int ffa_sync_send_receive(struct udevice *dev, u16 dst_part_id, ++ struct ffa_send_direct_data *msg, bool is_smc64) ++{ ++ struct ffa_bus_ops *ops = ffa_get_ops(dev); ++ ++ if (!ops->sync_send_receive) ++ return -ENOSYS; ++ ++ return ops->sync_send_receive(dev, dst_part_id, msg, is_smc64); ++} ++ ++/** ++ * ffa_rxtx_unmap() - FFA_RXTX_UNMAP driver operation ++ * @dev: The FF-A bus device ++ * ++ * Driver operation for FFA_RXTX_UNMAP. ++ * Please see ffa_unmap_rxtx_buffers_hdlr() description for more details. ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++int ffa_rxtx_unmap(struct udevice *dev) ++{ ++ struct ffa_bus_ops *ops = ffa_get_ops(dev); ++ ++ if (!ops->rxtx_unmap) ++ return -ENOSYS; ++ ++ return ops->rxtx_unmap(dev); ++} ++ ++/** ++ * ffa_do_probe() - probing FF-A framework ++ * @dev: the FF-A bus device (arm_ffa) ++ * ++ * Probing is triggered on demand by clients searching for the uclass. ++ * At probe level the following actions are done: ++ * - saving the FF-A framework version in uc_priv ++ * - querying from secure world the u-boot endpoint ID ++ * - querying from secure world the supported features of FFA_RXTX_MAP ++ * - mapping the RX/TX buffers ++ * - querying from secure world all the partitions information ++ * ++ * All data queried from secure world is saved in uc_priv. ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++static int ffa_do_probe(struct udevice *dev) ++{ ++ int ret; ++ ++ ret = ffa_get_version_hdlr(dev); ++ if (ret) ++ return ret; ++ ++ ret = ffa_get_endpoint_id(dev); ++ if (ret) ++ return ret; ++ ++ ret = ffa_get_rxtx_map_features_hdlr(dev); ++ if (ret) ++ return ret; ++ ++ ret = ffa_map_rxtx_buffers_hdlr(dev); ++ if (ret) ++ return ret; ++ ++ ret = ffa_cache_partitions_info(dev); ++ if (ret) { ++ ffa_unmap_rxtx_buffers_hdlr(dev); ++ return ret; ++ } ++ ++ return 0; ++} ++ ++UCLASS_DRIVER(ffa) = { ++ .name = "ffa", ++ .id = UCLASS_FFA, ++ .pre_probe = ffa_do_probe, ++ .pre_remove = ffa_unmap_rxtx_buffers_hdlr, ++ .per_device_auto = sizeof(struct ffa_priv) ++}; +diff --git a/drivers/firmware/arm-ffa/arm-ffa.c b/drivers/firmware/arm-ffa/arm-ffa.c +new file mode 100644 +index 0000000000..68df75bd9e +--- /dev/null ++++ b/drivers/firmware/arm-ffa/arm-ffa.c +@@ -0,0 +1,104 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++/* ++ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++ * ++ * Authors: ++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++ */ ++ ++#include <common.h> ++#include <arm_ffa.h> ++#include <arm_ffa_priv.h> ++#include <dm.h> ++#include <log.h> ++#include <asm/global_data.h> ++#include <dm/device-internal.h> ++#include <linux/errno.h> ++ ++DECLARE_GLOBAL_DATA_PTR; ++ ++/** ++ * invoke_ffa_fn() - SMC wrapper ++ * @args: FF-A ABI arguments to be copied to Xn registers ++ * @res: FF-A ABI return data to be copied from Xn registers ++ * ++ * Calls low level SMC assembly function ++ */ ++void invoke_ffa_fn(ffa_value_t args, ffa_value_t *res) ++{ ++ arm_smccc_1_2_smc(&args, res); ++} ++ ++/** ++ * arm_ffa_discover() - perform FF-A discovery ++ * @dev: The Arm FF-A bus device (arm_ffa) ++ * Try to discover the FF-A framework. Discovery is performed by ++ * querying the FF-A framework version from secure world using the FFA_VERSION ABI. ++ * Return: ++ * ++ * true on success. Otherwise, false. ++ */ ++static bool arm_ffa_discover(struct udevice *dev) ++{ ++ int ret; ++ ++ log_info("Arm FF-A framework discovery\n"); ++ ++ ret = ffa_get_version_hdlr(dev); ++ if (ret) ++ return false; ++ ++ return true; ++} ++ ++/** ++ * arm_ffa_is_supported() - FF-A bus discovery callback ++ * @invoke_fn: legacy SMC invoke function (not used) ++ * ++ * Perform FF-A discovery by calling arm_ffa_discover(). ++ * Discovery is performed by querying the FF-A framework version from ++ * secure world using the FFA_VERSION ABI. ++ * ++ * The FF-A driver is registered as an SMCCC feature driver. So, features discovery ++ * callbacks are called by the PSCI driver (PSCI device is the SMCCC features ++ * root device). ++ * ++ * The FF-A driver supports the SMCCCv1.2 extended input/output registers. ++ * So, the legacy SMC invocation is not used. ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++static bool arm_ffa_is_supported(void (*invoke_fn)(ulong a0, ulong a1, ++ ulong a2, ulong a3, ++ ulong a4, ulong a5, ++ ulong a6, ulong a7, ++ struct arm_smccc_res *res)) ++{ ++ return arm_ffa_discover(NULL); ++} ++ ++/* Arm FF-A driver operations */ ++ ++static const struct ffa_bus_ops ffa_ops = { ++ .partition_info_get = ffa_get_partitions_info_hdlr, ++ .sync_send_receive = ffa_msg_send_direct_req_hdlr, ++ .rxtx_unmap = ffa_unmap_rxtx_buffers_hdlr, ++}; ++ ++/* Registering the FF-A driver as an SMCCC feature driver */ ++ ++ARM_SMCCC_FEATURE_DRIVER(arm_ffa) = { ++ .driver_name = FFA_DRV_NAME, ++ .is_supported = arm_ffa_is_supported, ++}; ++ ++/* Declaring the FF-A driver under UCLASS_FFA */ ++ ++U_BOOT_DRIVER(arm_ffa) = { ++ .name = FFA_DRV_NAME, ++ .id = UCLASS_FFA, ++ .flags = DM_REMOVE_OS_PREPARE, ++ .ops = &ffa_ops, ++}; +diff --git a/drivers/firmware/arm-ffa/sandbox_arm_ffa_priv.h b/drivers/firmware/arm-ffa/sandbox_arm_ffa_priv.h +new file mode 100644 +index 0000000000..4338f9c9b1 +--- /dev/null ++++ b/drivers/firmware/arm-ffa/sandbox_arm_ffa_priv.h +@@ -0,0 +1,14 @@ ++/* SPDX-License-Identifier: GPL-2.0+ */ ++/* ++ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++ * ++ * Authors: ++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++ */ ++ ++#ifndef __SANDBOX_ARM_FFA_PRV_H ++#define __SANDBOX_ARM_FFA_PRV_H ++ ++/* Future sandbox support private declarations */ ++ ++#endif +diff --git a/include/arm_ffa.h b/include/arm_ffa.h +new file mode 100644 +index 0000000000..db9b1be995 +--- /dev/null ++++ b/include/arm_ffa.h +@@ -0,0 +1,213 @@ ++/* SPDX-License-Identifier: GPL-2.0+ */ ++/* ++ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++ * ++ * Authors: ++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++ */ ++ ++#ifndef __ARM_FFA_H ++#define __ARM_FFA_H ++ ++#include <linux/printk.h> ++ ++/* ++ * This header is public. It can be used by clients to access ++ * data structures and definitions they need ++ */ ++ ++/* ++ * struct ffa_partition_info - Partition information descriptor ++ * @id: Partition ID ++ * @exec_ctxt: Execution context count ++ * @properties: Partition properties ++ * ++ * Data structure containing information about partitions instantiated in the system ++ * This structure is filled with the data queried by FFA_PARTITION_INFO_GET ++ */ ++struct ffa_partition_info { ++ u16 id; ++ u16 exec_ctxt; ++/* partition supports receipt of direct requests */ ++#define FFA_PARTITION_DIRECT_RECV BIT(0) ++/* partition can send direct requests. */ ++#define FFA_PARTITION_DIRECT_SEND BIT(1) ++/* partition can send and receive indirect messages. */ ++#define FFA_PARTITION_INDIRECT_MSG BIT(2) ++ u32 properties; ++}; ++ ++/* ++ * struct ffa_partition_uuid - 16 bytes UUID transmitted by FFA_PARTITION_INFO_GET ++ * @a1-4: 32-bit words access to the UUID data ++ * ++ */ ++struct ffa_partition_uuid { ++ u32 a1; /* w1 */ ++ u32 a2; /* w2 */ ++ u32 a3; /* w3 */ ++ u32 a4; /* w4 */ ++}; ++ ++/** ++ * struct ffa_partition_desc - the secure partition descriptor ++ * @info: partition information ++ * @sp_uuid: the secure partition UUID ++ * ++ * Each partition has its descriptor containing the partitions information and the UUID ++ */ ++struct ffa_partition_desc { ++ struct ffa_partition_info info; ++ struct ffa_partition_uuid sp_uuid; ++}; ++ ++/* ++ * struct ffa_send_direct_data - Data structure hosting the data ++ * used by FFA_MSG_SEND_DIRECT_{REQ,RESP} ++ * @data0-4: Data read/written from/to x3-x7 registers ++ * ++ * Data structure containing the data to be sent by FFA_MSG_SEND_DIRECT_REQ ++ * or read from FFA_MSG_SEND_DIRECT_RESP ++ */ ++ ++/* For use with FFA_MSG_SEND_DIRECT_{REQ,RESP} which pass data via registers */ ++struct ffa_send_direct_data { ++ ulong data0; /* w3/x3 */ ++ ulong data1; /* w4/x4 */ ++ ulong data2; /* w5/x5 */ ++ ulong data3; /* w6/x6 */ ++ ulong data4; /* w7/x7 */ ++}; ++ ++struct udevice; ++ ++/** ++ * struct ffa_bus_ops - Operations for FF-A ++ * @partition_info_get: callback for the FFA_PARTITION_INFO_GET ++ * @sync_send_receive: callback for the FFA_MSG_SEND_DIRECT_REQ ++ * @rxtx_unmap: callback for the FFA_RXTX_UNMAP ++ * ++ * The data structure providing all the operations supported by the driver. ++ * This structure is EFI runtime resident. ++ */ ++struct ffa_bus_ops { ++ int (*partition_info_get)(struct udevice *dev, const char *uuid_str, ++ u32 *sp_count, struct ffa_partition_desc **sp_descs); ++ int (*sync_send_receive)(struct udevice *dev, u16 dst_part_id, ++ struct ffa_send_direct_data *msg, ++ bool is_smc64); ++ int (*rxtx_unmap)(struct udevice *dev); ++}; ++ ++#define ffa_get_ops(dev) ((struct ffa_bus_ops *)(dev)->driver->ops) ++ ++/** ++ * ffa_rxtx_unmap() - FFA_RXTX_UNMAP driver operation ++ * Please see ffa_unmap_rxtx_buffers_hdlr() description for more details. ++ */ ++int ffa_rxtx_unmap(struct udevice *dev); ++ ++/** ++ * ffa_unmap_rxtx_buffers_hdlr() - FFA_RXTX_UNMAP handler function ++ * @dev: The arm_ffa bus device ++ * ++ * This function implements FFA_RXTX_UNMAP FF-A function ++ * to unmap the RX/TX buffers ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++int ffa_unmap_rxtx_buffers_hdlr(struct udevice *dev); ++ ++/** ++ * ffa_sync_send_receive() - FFA_MSG_SEND_DIRECT_{REQ,RESP} driver operation ++ * Please see ffa_msg_send_direct_req_hdlr() description for more details. ++ */ ++int ffa_sync_send_receive(struct udevice *dev, u16 dst_part_id, ++ struct ffa_send_direct_data *msg, bool is_smc64); ++ ++/** ++ * ffa_msg_send_direct_req_hdlr() - FFA_MSG_SEND_DIRECT_{REQ,RESP} handler function ++ * @dev: The arm_ffa bus device ++ * @dst_part_id: destination partition ID ++ * @msg: pointer to the message data preallocated by the client (in/out) ++ * @is_smc64: select 64-bit or 32-bit FF-A ABI ++ * ++ * This function implements FFA_MSG_SEND_DIRECT_{REQ,RESP} ++ * FF-A functions. ++ * ++ * FFA_MSG_SEND_DIRECT_REQ is used to send the data to the secure partition. ++ * The response from the secure partition is handled by reading the ++ * FFA_MSG_SEND_DIRECT_RESP arguments. ++ * ++ * The maximum size of the data that can be exchanged is 40 bytes which is ++ * sizeof(struct ffa_send_direct_data) as defined by the FF-A specification 1.0 ++ * in the section relevant to FFA_MSG_SEND_DIRECT_{REQ,RESP} ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++int ffa_msg_send_direct_req_hdlr(struct udevice *dev, u16 dst_part_id, ++ struct ffa_send_direct_data *msg, bool is_smc64); ++ ++/** ++ * ffa_partition_info_get() - FFA_PARTITION_INFO_GET driver operation ++ * Please see ffa_get_partitions_info_hdlr() description for more details. ++ */ ++int ffa_partition_info_get(struct udevice *dev, const char *uuid_str, ++ u32 *sp_count, struct ffa_partition_desc **sp_descs); ++ ++/** ++ * ffa_get_partitions_info_hdlr() - FFA_PARTITION_INFO_GET handler function ++ * @uuid_str: pointer to the UUID string ++ * @sp_count: address of the variable containing the number of partitions matching the UUID ++ * The variable is set by the driver ++ * @sp_descs: address of the descriptors of the partitions matching the UUID ++ * The address is set by the driver ++ * ++ * Return the number of partitions and their descriptors matching the UUID ++ * ++ * Query the secure partition data from uc_priv. ++ * If not found, invoke FFA_PARTITION_INFO_GET ++ * FF-A function to query the partition information from secure world. ++ * ++ * A client of the FF-A driver should know the UUID of the service it wants to ++ * access. It should use the UUID to request the FF-A driver to provide the ++ * partition(s) information of the service. The FF-A driver uses ++ * PARTITION_INFO_GET to obtain this information. This is implemented through ++ * ffa_get_partitions_info_hdlr() function. ++ * A new FFA_PARTITION_INFO_GET call is issued (first one performed through ++ * ffa_cache_partitions_info) allowing to retrieve the partition(s) information. ++ * They are not saved (already done). We only update the UUID in the cached area. ++ * This assumes that partitions data does not change in the secure world. ++ * Otherwise u-boot will have an outdated partition data. The benefit of caching ++ * the information in the FF-A driver is to accommodate discovery after ++ * ExitBootServices(). ++ * ++ * Return: ++ * ++ * @sp_count: the number of partitions ++ * @sp_descs: address of the partitions descriptors ++ * ++ * On success 0 is returned. Otherwise, failure ++ */ ++int ffa_get_partitions_info_hdlr(struct udevice *dev, const char *uuid_str, ++ u32 *sp_count, struct ffa_partition_desc **sp_descs); ++ ++struct ffa_priv; ++ ++/** ++ * ffa_set_smc_conduit() - Set the SMC conduit ++ * @dev: The FF-A bus device ++ * ++ * Selects the SMC conduit by setting the FF-A ABI invoke function. ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++int ffa_set_smc_conduit(struct udevice *dev); ++ ++#endif +diff --git a/include/arm_ffa_priv.h b/include/arm_ffa_priv.h +new file mode 100644 +index 0000000000..d564c33c64 +--- /dev/null ++++ b/include/arm_ffa_priv.h +@@ -0,0 +1,246 @@ ++/* SPDX-License-Identifier: GPL-2.0+ */ ++/* ++ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++ * ++ * Authors: ++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++ */ ++ ++#ifndef __ARM_FFA_PRV_H ++#define __ARM_FFA_PRV_H ++ ++#include <mapmem.h> ++#include <linux/bitfield.h> ++#include <linux/bitops.h> ++ ++/* This header is exclusively used by the FF-A Uclass and FF-A driver(s) */ ++ ++/* Arm FF-A driver name */ ++#define FFA_DRV_NAME "arm_ffa" ++ ++/* The FF-A SMC function definitions */ ++ ++#if CONFIG_IS_ENABLED(SANDBOX) ++ ++/* Providing Arm SMCCC declarations to sandbox */ ++ ++/** ++ * struct sandbox_smccc_1_2_regs - emulated SMC call arguments or results ++ * @a0-a17 argument values from registers 0 to 17 ++ */ ++struct sandbox_smccc_1_2_regs { ++ ulong a0; ++ ulong a1; ++ ulong a2; ++ ulong a3; ++ ulong a4; ++ ulong a5; ++ ulong a6; ++ ulong a7; ++ ulong a8; ++ ulong a9; ++ ulong a10; ++ ulong a11; ++ ulong a12; ++ ulong a13; ++ ulong a14; ++ ulong a15; ++ ulong a16; ++ ulong a17; ++}; ++ ++typedef struct sandbox_smccc_1_2_regs ffa_value_t; ++ ++#define ARM_SMCCC_FAST_CALL 1UL ++#define ARM_SMCCC_OWNER_STANDARD 4 ++#define ARM_SMCCC_SMC_32 0 ++#define ARM_SMCCC_SMC_64 1 ++#define ARM_SMCCC_TYPE_SHIFT 31 ++#define ARM_SMCCC_CALL_CONV_SHIFT 30 ++#define ARM_SMCCC_OWNER_MASK 0x3f ++#define ARM_SMCCC_OWNER_SHIFT 24 ++#define ARM_SMCCC_FUNC_MASK 0xffff ++ ++#define ARM_SMCCC_CALL_VAL(type, calling_convention, owner, func_num) \ ++ (((type) << ARM_SMCCC_TYPE_SHIFT) | \ ++ ((calling_convention) << ARM_SMCCC_CALL_CONV_SHIFT) | \ ++ (((owner) & ARM_SMCCC_OWNER_MASK) << ARM_SMCCC_OWNER_SHIFT) | \ ++ ((func_num) & ARM_SMCCC_FUNC_MASK)) ++ ++#else ++/* CONFIG_ARM64 */ ++#include <linux/arm-smccc.h> ++typedef struct arm_smccc_1_2_regs ffa_value_t; ++#endif ++ ++/* Defining the function pointer type for the function executing the FF-A ABIs */ ++typedef void (*invoke_ffa_fn_t)(ffa_value_t args, ffa_value_t *res); ++ ++/* FF-A driver version definitions */ ++ ++#define MAJOR_VERSION_MASK GENMASK(30, 16) ++#define MINOR_VERSION_MASK GENMASK(15, 0) ++#define GET_FFA_MAJOR_VERSION(x) \ ++ ((u16)(FIELD_GET(MAJOR_VERSION_MASK, (x)))) ++#define GET_FFA_MINOR_VERSION(x) \ ++ ((u16)(FIELD_GET(MINOR_VERSION_MASK, (x)))) ++#define PACK_VERSION_INFO(major, minor) \ ++ (FIELD_PREP(MAJOR_VERSION_MASK, (major)) | \ ++ FIELD_PREP(MINOR_VERSION_MASK, (minor))) ++ ++#define FFA_MAJOR_VERSION (1) ++#define FFA_MINOR_VERSION (0) ++#define FFA_VERSION_1_0 \ ++ PACK_VERSION_INFO(FFA_MAJOR_VERSION, FFA_MINOR_VERSION) ++ ++/* Endpoint ID mask (u-boot endpoint ID) */ ++ ++#define GET_SELF_ENDPOINT_ID_MASK GENMASK(15, 0) ++#define GET_SELF_ENDPOINT_ID(x) \ ++ ((u16)(FIELD_GET(GET_SELF_ENDPOINT_ID_MASK, (x)))) ++ ++#define PREP_SELF_ENDPOINT_ID_MASK GENMASK(31, 16) ++#define PREP_SELF_ENDPOINT_ID(x) \ ++ (FIELD_PREP(PREP_SELF_ENDPOINT_ID_MASK, (x))) ++ ++/* Partition endpoint ID mask (partition with which u-boot communicates with) */ ++ ++#define PREP_PART_ENDPOINT_ID_MASK GENMASK(15, 0) ++#define PREP_PART_ENDPOINT_ID(x) \ ++ (FIELD_PREP(PREP_PART_ENDPOINT_ID_MASK, (x))) ++ ++/* Definitions of the Arm FF-A interfaces supported by the Arm FF-A driver */ ++ ++#define FFA_SMC(calling_convention, func_num) \ ++ ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, (calling_convention), \ ++ ARM_SMCCC_OWNER_STANDARD, (func_num)) ++ ++#define FFA_SMC_32(func_num) FFA_SMC(ARM_SMCCC_SMC_32, (func_num)) ++#define FFA_SMC_64(func_num) FFA_SMC(ARM_SMCCC_SMC_64, (func_num)) ++ ++enum ffa_abis { ++ FFA_ERROR = 0x60, ++ FFA_SUCCESS = 0x61, ++ FFA_INTERRUPT = 0x62, ++ FFA_VERSION = 0x63, ++ FFA_FEATURES = 0x64, ++ FFA_RX_RELEASE = 0x65, ++ FFA_RXTX_MAP = 0x66, ++ FFA_RXTX_UNMAP = 0x67, ++ FFA_PARTITION_INFO_GET = 0x68, ++ FFA_ID_GET = 0x69, ++ FFA_RUN = 0x6d, ++ FFA_MSG_SEND_DIRECT_REQ = 0x6f, ++ FFA_MSG_SEND_DIRECT_RESP = 0x70, ++ ++ /* To be updated when adding new FFA IDs */ ++ FFA_FIRST_ID = FFA_ERROR, /* Lowest number ID */ ++ FFA_LAST_ID = FFA_MSG_SEND_DIRECT_RESP, /* Highest number ID */ ++}; ++ ++enum ffa_abi_errcode { ++ NOT_SUPPORTED = 1, ++ INVALID_PARAMETERS, ++ NO_MEMORY, ++ BUSY, ++ INTERRUPTED, ++ DENIED, ++ RETRY, ++ ABORTED, ++ MAX_NUMBER_FFA_ERR ++}; ++ ++extern int ffa_to_std_errmap[MAX_NUMBER_FFA_ERR]; ++ ++/* Container structure and helper macros to map between an FF-A error and relevant error log */ ++struct ffa_abi_errmap { ++ char *err_str[MAX_NUMBER_FFA_ERR]; ++}; ++ ++#define FFA_ERRMAP_COUNT (FFA_LAST_ID - FFA_FIRST_ID + 1) ++#define FFA_ID_TO_ERRMAP_ID(ffa_id) ((ffa_id) - FFA_FIRST_ID) ++ ++/** ++ * enum ffa_rxtx_buf_sizes - minimum sizes supported ++ * for the RX/TX buffers ++ */ ++enum ffa_rxtx_buf_sizes { ++ RXTX_4K, ++ RXTX_64K, ++ RXTX_16K ++}; ++ ++/** ++ * struct ffa_rxtxpair - Hosts the RX/TX buffers virtual addresses ++ * @rxbuf: virtual address of the RX buffer ++ * @txbuf: virtual address of the TX buffer ++ * @rxtx_min_pages: RX/TX buffers minimum size in pages ++ * ++ * Hosts the virtual addresses of the mapped RX/TX buffers ++ * These addresses are used by the FF-A functions that use the RX/TX buffers ++ */ ++struct ffa_rxtxpair { ++ void *rxbuf; /* Virtual address returned by memalign */ ++ void *txbuf; /* Virtual address returned by memalign */ ++ size_t rxtx_min_pages; /* Minimum number of pages in each of the RX/TX buffers */ ++}; ++ ++struct ffa_partition_desc; ++ ++/** ++ * struct ffa_partitions - descriptors for all secure partitions ++ * @count: The number of partitions descriptors ++ * @descs The partitions descriptors table ++ * ++ * Contains the partitions descriptors table ++ */ ++struct ffa_partitions { ++ u32 count; ++ struct ffa_partition_desc *descs; /* Virtual address */ ++}; ++ ++/** ++ * struct ffa_priv - the driver private data structure ++ * ++ * @fwk_version: FF-A framework version ++ * @emul: FF-A sandbox emulator ++ * @id: u-boot endpoint ID ++ * @partitions: The partitions descriptors structure ++ * @pair: The RX/TX buffers pair ++ * ++ * The device private data structure containing all the ++ * data read from secure world. ++ */ ++struct ffa_priv { ++ u32 fwk_version; ++ struct udevice *emul; ++ u16 id; ++ struct ffa_partitions partitions; ++ struct ffa_rxtxpair pair; ++}; ++ ++/** ++ * ffa_get_version_hdlr() - FFA_VERSION handler function ++ * @dev: The FF-A bus device ++ * ++ * Implement FFA_VERSION FF-A function ++ * to get from the secure world the FF-A framework version ++ * FFA_VERSION is used to discover the FF-A framework. ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++int ffa_get_version_hdlr(struct udevice *dev); ++ ++/** ++ * invoke_ffa_fn() - SMC wrapper ++ * @args: FF-A ABI arguments to be copied to Xn registers ++ * @res: FF-A ABI return data to be copied from Xn registers ++ * ++ * Calls low level SMC implementation. ++ * This function should be implemented by the user driver. ++ */ ++void invoke_ffa_fn(ffa_value_t args, ffa_value_t *res); ++ ++#endif +diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h +index 307ad6931c..3c6af2e3d2 100644 +--- a/include/dm/uclass-id.h ++++ b/include/dm/uclass-id.h +@@ -4,6 +4,11 @@ + * + * (C) Copyright 2012 + * Pavel Herrmann <morpheus.ibis@gmail.com> ++ * ++ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++ * ++ * Authors: ++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> + */ + + #ifndef _DM_UCLASS_ID_H +@@ -57,6 +62,7 @@ enum uclass_id { + UCLASS_ETH, /* Ethernet device */ + UCLASS_ETH_PHY, /* Ethernet PHY device */ + UCLASS_EXTCON, /* External Connector Class */ ++ UCLASS_FFA, /* Arm Firmware Framework for Armv8-A */ + UCLASS_FIRMWARE, /* Firmware */ + UCLASS_FPGA, /* FPGA device */ + UCLASS_FUZZING_ENGINE, /* Fuzzing engine */ +-- +2.25.1 + diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0004-arm_ffa-efi-unmap-RX-TX-buffers.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0004-arm_ffa-efi-unmap-RX-TX-buffers.patch deleted file mode 100644 index 3a3dae834d..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0004-arm_ffa-efi-unmap-RX-TX-buffers.patch +++ /dev/null @@ -1,74 +0,0 @@ -From b09b391e33e024a18842dfdc99282d0050cc5fcb Mon Sep 17 00:00:00 2001 -From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Date: Thu, 6 Oct 2022 15:04:25 +0100 -Subject: [PATCH 04/42] arm_ffa: efi: unmap RX/TX buffers - -unmap RX/TX buffers at ExitBootServices() - -Unmapping the RX/TX buffers created by u-boot is needed before EFI -runtime. - -At EFI runtime the linux kernel takes care of allocating its own RX/TX -buffers and registering them with the secure world. - -Secure world should be using the RX/TX buffers created by the kernel. -So, RX/TX buffers created by u-boot must be unmapped. - -Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Cc: Tom Rini <trini@konsulko.com> -Cc: Simon Glass <sjg@chromium.org> -Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> -Cc: Jens Wiklander <jens.wiklander@linaro.org> -Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/] - -Changelog: -=============== - -v8: pass NULL device pointer to the FF-A bus operation -v7: replace debug() by log_err() -Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> ---- - lib/efi_loader/efi_boottime.c | 13 +++++++++++++ - 1 file changed, 13 insertions(+) - -diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c -index e65ca6a4cb..3481f2afe7 100644 ---- a/lib/efi_loader/efi_boottime.c -+++ b/lib/efi_loader/efi_boottime.c -@@ -3,6 +3,9 @@ - * EFI application boot time services - * - * Copyright (c) 2016 Alexander Graf -+ * -+ * (C) Copyright 2022 ARM Limited -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> - */ - - #include <common.h> -@@ -23,6 +26,10 @@ - #include <asm/setjmp.h> - #include <linux/libfdt_env.h> - -+#if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT) -+#include <arm_ffa.h> -+#endif -+ - DECLARE_GLOBAL_DATA_PTR; - - /* Task priority level */ -@@ -2178,6 +2185,12 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle, - dm_remove_devices_flags(DM_REMOVE_ACTIVE_ALL); - } - -+#if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT) -+ /* unmap FF-A RX/TX buffers */ -+ if (ffa_bus_ops_get()->rxtx_unmap(NULL)) -+ log_err("Can't unmap FF-A RX/TX buffers\n"); -+#endif -+ - /* Patch out unsupported runtime function */ - efi_runtime_detach(); - --- -2.25.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0005-FF-A-v15-arm_ffa-introduce-armffa-command.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0005-FF-A-v15-arm_ffa-introduce-armffa-command.patch new file mode 100644 index 0000000000..aeb4bb908a --- /dev/null +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0005-FF-A-v15-arm_ffa-introduce-armffa-command.patch @@ -0,0 +1,436 @@ +From 3eb4fb19777383f5f05b7ce74da141f53ffc4374 Mon Sep 17 00:00:00 2001 +From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> +Date: Wed, 10 May 2023 17:27:01 +0100 +Subject: [PATCH 05/33] FF-A v15: arm_ffa: introduce armffa command + +Provide armffa command showcasing the use of the U-Boot FF-A support + +armffa is a command showcasing how to invoke FF-A operations. +This provides a guidance to the client developers on how to +call the FF-A bus interfaces. The command also allows to gather secure +partitions information and ping these partitions. The command is also +helpful in testing the communication with secure partitions. + +For more details please refer to the command documentation [1]. + +[1]: doc/usage/cmd/armffa.rst + +Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> +Reviewed-by: Simon Glass <sjg@chromium.org> +Cc: Tom Rini <trini@konsulko.com> +Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> +Cc: Jens Wiklander <jens.wiklander@linaro.org> +Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> +Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20230713132847.176000-1-abdellatif.elkhlifi@arm.com/] +--- + MAINTAINERS | 2 + + cmd/Kconfig | 10 ++ + cmd/Makefile | 1 + + cmd/armffa.c | 202 +++++++++++++++++++++++++++++++ + doc/arch/arm64.ffa.rst | 7 ++ + doc/usage/cmd/armffa.rst | 93 ++++++++++++++ + doc/usage/index.rst | 1 + + drivers/firmware/arm-ffa/Kconfig | 1 + + 8 files changed, 317 insertions(+) + create mode 100644 cmd/armffa.c + create mode 100644 doc/usage/cmd/armffa.rst + +diff --git a/MAINTAINERS b/MAINTAINERS +index 9c5ebf312c..4ae82229fc 100644 +--- a/MAINTAINERS ++++ b/MAINTAINERS +@@ -269,7 +269,9 @@ F: configs/cortina_presidio-asic-pnand_defconfig + ARM FF-A + M: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> + S: Maintained ++F: cmd/armffa.c + F: doc/arch/arm64.ffa.rst ++F: doc/usage/cmd/armffa.rst + F: drivers/firmware/arm-ffa/ + F: include/arm_ffa.h + F: include/sandbox_arm_ffa.h +diff --git a/cmd/Kconfig b/cmd/Kconfig +index 02e54f1e50..79b4f8367a 100644 +--- a/cmd/Kconfig ++++ b/cmd/Kconfig +@@ -935,6 +935,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 FF-A support ++ 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 6c37521b4e..7d20a85a46 100644 +--- a/cmd/Makefile ++++ b/cmd/Makefile +@@ -12,6 +12,7 @@ obj-y += panic.o + obj-y += version.o + + # command ++obj-$(CONFIG_CMD_ARMFFA) += armffa.o + obj-$(CONFIG_CMD_2048) += 2048.o + obj-$(CONFIG_CMD_ACPI) += acpi.o + obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o +diff --git a/cmd/armffa.c b/cmd/armffa.c +new file mode 100644 +index 0000000000..7e6eafc03a +--- /dev/null ++++ b/cmd/armffa.c +@@ -0,0 +1,202 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++/* ++ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++ * ++ * Authors: ++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++ */ ++#include <common.h> ++#include <arm_ffa.h> ++#include <command.h> ++#include <dm.h> ++#include <mapmem.h> ++#include <stdlib.h> ++#include <asm/io.h> ++ ++/* Select the right physical address formatting according to the platform */ ++#ifdef CONFIG_PHYS_64BIT ++#define PhysAddrLength "ll" ++#else ++#define PhysAddrLength "" ++#endif ++#define PHYS_ADDR_LN "%" PhysAddrLength "x" ++ ++/** ++ * ffa_get_dev() - Return the FF-A device ++ * @devp: pointer to the FF-A device ++ * ++ * Search for the FF-A device. ++ * ++ * Return: ++ * 0 on success. Otherwise, failure ++ */ ++static int ffa_get_dev(struct udevice **devp) ++{ ++ int ret; ++ ++ ret = uclass_first_device_err(UCLASS_FFA, devp); ++ if (ret) { ++ log_err("Cannot find FF-A bus device\n"); ++ return ret; ++ } ++ ++ return 0; ++} ++ ++/** ++ * do_ffa_getpart() - implementation of the getpart subcommand ++ * @cmdtp: Command Table ++ * @flag: flags ++ * @argc: number of arguments ++ * @argv: arguments ++ * ++ * Query a secure partition information. The secure partition UUID is provided ++ * as an argument. The function uses the arm_ffa driver ++ * partition_info_get operation which implements FFA_PARTITION_INFO_GET ++ * ABI 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_getpart(struct cmd_tbl *cmdtp, int flag, int argc, ++ char *const argv[]) ++{ ++ u32 count = 0; ++ int ret; ++ struct ffa_partition_desc *descs; ++ u32 i; ++ struct udevice *dev; ++ ++ if (argc != 2) { ++ log_err("Missing argument\n"); ++ return CMD_RET_USAGE; ++ } ++ ++ ret = ffa_get_dev(&dev); ++ if (ret) ++ return CMD_RET_FAILURE; ++ ++ /* Ask the driver to fill the buffer with the SPs info */ ++ ++ ret = ffa_partition_info_get(dev, argv[1], &count, &descs); ++ if (ret) { ++ log_err("Failure in querying partition(s) info (error code: %d)\n", ret); ++ return CMD_RET_FAILURE; ++ } ++ ++ /* SPs found , show the partition information */ ++ for (i = 0; i < count ; i++) { ++ log_info("Partition: id = %x , exec_ctxt %x , properties %x\n", ++ descs[i].info.id, ++ descs[i].info.exec_ctxt, ++ descs[i].info.properties); ++ } ++ ++ return CMD_RET_SUCCESS; ++} ++ ++/** ++ * do_ffa_ping() - implementation of the ping subcommand ++ * @cmdtp: Command Table ++ * @flag: flags ++ * @argc: number of arguments ++ * @argv: arguments ++ * ++ * Send data to a secure partition. The secure partition UUID is provided ++ * as an argument. Use the arm_ffa driver sync_send_receive operation ++ * which implements FFA_MSG_SEND_DIRECT_{REQ,RESP} ABIs to send/receive data. ++ * ++ * Return: ++ * ++ * CMD_RET_SUCCESS: on success, otherwise failure ++ */ ++static int do_ffa_ping(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) ++{ ++ struct ffa_send_direct_data msg = { ++ .data0 = 0xaaaaaaaa, ++ .data1 = 0xbbbbbbbb, ++ .data2 = 0xcccccccc, ++ .data3 = 0xdddddddd, ++ .data4 = 0xeeeeeeee, ++ }; ++ u16 part_id; ++ int ret; ++ struct udevice *dev; ++ ++ if (argc != 2) { ++ log_err("Missing argument\n"); ++ return CMD_RET_USAGE; ++ } ++ ++ part_id = strtoul(argv[1], NULL, 16); ++ if (!part_id) { ++ log_err("Partition ID can not be 0\n"); ++ return CMD_RET_USAGE; ++ } ++ ++ ret = ffa_get_dev(&dev); ++ if (ret) ++ return CMD_RET_FAILURE; ++ ++ ret = ffa_sync_send_receive(dev, part_id, &msg, 1); ++ if (!ret) { ++ u8 cnt; ++ ++ log_info("SP response:\n[LSB]\n"); ++ for (cnt = 0; ++ cnt < sizeof(struct ffa_send_direct_data) / sizeof(u64); ++ cnt++) ++ log_info("%llx\n", ((u64 *)&msg)[cnt]); ++ return CMD_RET_SUCCESS; ++ } ++ ++ log_err("Sending direct request error (%d)\n", ret); ++ return CMD_RET_FAILURE; ++} ++ ++/** ++ *do_ffa_devlist() - implementation of the devlist subcommand ++ * @cmdtp: [in] Command Table ++ * @flag: flags ++ * @argc: number of arguments ++ * @argv: arguments ++ * ++ * Query the device belonging to the UCLASS_FFA ++ * class. ++ * ++ * Return: ++ * ++ * CMD_RET_SUCCESS: on success, otherwise failure ++ */ ++static int do_ffa_devlist(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) ++{ ++ struct udevice *dev; ++ int ret; ++ ++ ret = ffa_get_dev(&dev); ++ if (ret) ++ return CMD_RET_FAILURE; ++ ++ log_info("device %s, addr " PHYS_ADDR_LN ", driver %s, ops " PHYS_ADDR_LN "\n", ++ dev->name, ++ map_to_sysmem(dev), ++ dev->driver->name, ++ map_to_sysmem(dev->driver->ops)); ++ ++ return CMD_RET_SUCCESS; ++} ++ ++static char armffa_help_text[] = ++ "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 information about the FF-A device/driver\n"; ++ ++U_BOOT_CMD_WITH_SUBCMDS(armffa, "Arm FF-A test command", armffa_help_text, ++ U_BOOT_SUBCMD_MKENT(getpart, 2, 1, do_ffa_getpart), ++ U_BOOT_SUBCMD_MKENT(ping, 2, 1, do_ffa_ping), ++ U_BOOT_SUBCMD_MKENT(devlist, 1, 1, do_ffa_devlist)); +diff --git a/doc/arch/arm64.ffa.rst b/doc/arch/arm64.ffa.rst +index 4f817f053c..aefd527447 100644 +--- a/doc/arch/arm64.ffa.rst ++++ b/doc/arch/arm64.ffa.rst +@@ -205,6 +205,13 @@ The following features are provided: + + - FF-A bus can be compiled and used without EFI + ++The armffa command ++----------------------------------- ++ ++armffa is a command showcasing how to use the FF-A bus and how to invoke the driver operations. ++ ++Please refer the command documentation at :doc:`../usage/cmd/armffa` ++ + Example of boot logs with FF-A enabled + -------------------------------------- + +diff --git a/doc/usage/cmd/armffa.rst b/doc/usage/cmd/armffa.rst +new file mode 100644 +index 0000000000..3d422686c1 +--- /dev/null ++++ b/doc/usage/cmd/armffa.rst +@@ -0,0 +1,93 @@ ++.. SPDX-License-Identifier: GPL-2.0+: ++ ++armffa command ++============== ++ ++Synopsis ++-------- ++ ++:: ++ ++ armffa [sub-command] [arguments] ++ ++ sub-commands: ++ ++ getpart [partition UUID] ++ ++ lists the partition(s) info ++ ++ ping [partition ID] ++ ++ sends a data pattern to the specified partition ++ ++ devlist ++ ++ displays information about the FF-A device/driver ++ ++Description ++----------- ++ ++armffa is a command showcasing how to use the FF-A bus and how to invoke its operations. ++ ++This provides a guidance to the client developers on how to call the FF-A bus interfaces. ++ ++The command also allows to gather secure partitions information and ping these partitions. ++ ++The command is also helpful in testing the communication with secure partitions. ++ ++Example ++------- ++ ++The following examples are run on Corstone-1000 platform. ++ ++* ping ++ ++:: ++ ++ corstone1000# armffa ping 0x8003 ++ SP response: ++ [LSB] ++ fffffffe ++ 0 ++ 0 ++ 0 ++ 0 ++ ++* ping (failure case) ++ ++:: ++ ++ corstone1000# armffa ping 0 ++ Sending direct request error (-22) ++ ++* getpart ++ ++:: ++ ++ corstone1000# armffa getpart 33d532ed-e699-0942-c09c-a798d9cd722d ++ Partition: id = 8003 , exec_ctxt 1 , properties 3 ++ ++* getpart (failure case) ++ ++:: ++ ++ corstone1000# armffa getpart 33d532ed-e699-0942-c09c-a798d9cd7221 ++ INVALID_PARAMETERS: Unrecognized UUID ++ Failure in querying partitions count (error code: -22) ++ ++* devlist ++ ++:: ++ ++ corstone1000# armffa devlist ++ device name arm_ffa, dev 00000000fdf41c30, driver name arm_ffa, ops 00000000fffc0e98 ++ ++Configuration ++------------- ++ ++The command is available if CONFIG_CMD_ARMFFA=y and CONFIG_ARM_FFA_TRANSPORT=y. ++ ++Return value ++------------ ++ ++The return value $? is 0 (true) on success, 1 (false) on failure. +diff --git a/doc/usage/index.rst b/doc/usage/index.rst +index 388e59f173..e462de2806 100644 +--- a/doc/usage/index.rst ++++ b/doc/usage/index.rst +@@ -22,6 +22,7 @@ Shell commands + + cmd/acpi + cmd/addrmap ++ cmd/armffa + cmd/askenv + cmd/base + cmd/bdinfo +diff --git a/drivers/firmware/arm-ffa/Kconfig b/drivers/firmware/arm-ffa/Kconfig +index 9200c8028b..a7d5392859 100644 +--- a/drivers/firmware/arm-ffa/Kconfig ++++ b/drivers/firmware/arm-ffa/Kconfig +@@ -5,6 +5,7 @@ config ARM_FFA_TRANSPORT + depends on DM && ARM64 + select ARM_SMCCC + select ARM_SMCCC_FEATURES ++ imply CMD_ARMFFA + select LIB_UUID + select DEVRES + help +-- +2.25.1 + diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0005-arm_ffa-introduce-armffa-command.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0005-arm_ffa-introduce-armffa-command.patch deleted file mode 100644 index b00e3d9f77..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0005-arm_ffa-introduce-armffa-command.patch +++ /dev/null @@ -1,364 +0,0 @@ -From f3bc86a7ec63c0454577cb6712395c577b2cfd66 Mon Sep 17 00:00:00 2001 -From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Date: Mon, 6 Jun 2022 12:46:38 +0100 -Subject: [PATCH 05/42] arm_ffa: introduce armffa command - -Provide armffa command showcasing the use of the FF-A driver - -The armffa command allows to query secure partitions data from -the secure world and exchanging messages with the partitions -using 64-bit FF-A direct messaging. - -Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Cc: Tom Rini <trini@konsulko.com> -Cc: Simon Glass <sjg@chromium.org> -Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> -Cc: Jens Wiklander <jens.wiklander@linaro.org> -Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/] - -Changelog: -=============== - -v8: - -* update partition_info_get() second argument to be an SP count -* pass NULL device pointer to the FF-A bus discovery and operations - -v7: - -* adapt do_ffa_dev_list() following the recent update on - uclass_first_device/uclass_next_device functions (they return void now) -* set armffa command to use 64-bit direct messaging - -v4: - -* remove pattern data in do_ffa_msg_send_direct_req - -v3: - -* use the new driver interfaces (partition_info_get, sync_send_receive) - in armffa command - -v2: - -* replace use of ffa_helper_init_device function by - ffa_helper_bus_discover - -v1: - -* introduce armffa command - -Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> ---- - MAINTAINERS | 1 + - cmd/Kconfig | 10 ++ - cmd/Makefile | 2 + - cmd/armffa.c | 237 +++++++++++++++++++++++++++++++ - drivers/firmware/arm-ffa/Kconfig | 1 + - 5 files changed, 251 insertions(+) - create mode 100644 cmd/armffa.c - -diff --git a/MAINTAINERS b/MAINTAINERS -index 509619d31c..61ce6c436f 100644 ---- a/MAINTAINERS -+++ b/MAINTAINERS -@@ -267,6 +267,7 @@ F: configs/cortina_presidio-asic-pnand_defconfig - ARM FF-A - M: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> - S: Maintained -+F: cmd/armffa.c - F: doc/arch/arm64.ffa.rst - F: drivers/firmware/arm-ffa/ - F: include/arm_ffa.h -diff --git a/cmd/Kconfig b/cmd/Kconfig -index b2d7598717..7d0a40e8ac 100644 ---- a/cmd/Kconfig -+++ b/cmd/Kconfig -@@ -924,6 +924,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 0b6a96c1d9..c757f1647d 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..d2e8687bfb ---- /dev/null -+++ b/cmd/armffa.c -@@ -0,0 +1,237 @@ -+// SPDX-License-Identifier: GPL-2.0+ -+/* -+ * (C) Copyright 2022 ARM Limited -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -+ */ -+ -+#include <arm_ffa.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 partition_info_get operation -+ * 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[]) -+{ -+ u32 count = 0; -+ int ret; -+ struct ffa_partition_info *parts_info; -+ u32 info_idx; -+ -+ if (argc != 1) -+ return -EINVAL; -+ -+ /* Mode 1: getting the number of secure partitions */ -+ ret = ffa_bus_ops_get()->partition_info_get(NULL, argv[0], &count, NULL); -+ if (ret != 0) { -+ 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 -+ */ -+ -+ ffa_info("Pre-allocating %d partition(s) info structures", count); -+ -+ parts_info = calloc(count, sizeof(struct ffa_partition_info)); -+ if (!parts_info) -+ return -EINVAL; -+ -+ /* -+ * ask the driver to fill the buffer with the SPs info -+ */ -+ -+ ret = ffa_bus_ops_get()->partition_info_get(NULL, argv[0], &count, parts_info); -+ if (ret != 0) { -+ 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 sync_send_receive operation -+ * 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_send_direct_data msg = { -+ .data0 = 0xaaaaaaaa, -+ .data1 = 0xbbbbbbbb, -+ .data2 = 0xcccccccc, -+ .data3 = 0xdddddddd, -+ .data4 = 0xeeeeeeee, -+ }; -+ 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; -+ } -+ -+ ret = ffa_bus_ops_get()->sync_send_receive(NULL, part_id, &msg, 1); -+ if (ret == 0) { -+ u8 cnt; -+ -+ ffa_info("SP response:\n[LSB]"); -+ for (cnt = 0; -+ cnt < sizeof(struct ffa_send_direct_data) / sizeof(u64); -+ cnt++) -+ ffa_info("0x%llx", ((u64 *)&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; -+ -+ ffa_info("arm_ffa uclass entries:"); -+ -+ for (i = 0, uclass_first_device(UCLASS_FFA, &dev); -+ dev; -+ uclass_next_device(&dev), i++) { -+ 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 0; -+} -+ -+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_bus_discover(NULL); -+ if (ret != 0) -+ return cmd_process_error(cmdtp, ret); -+ -+ if (!ffa_bus_ops_get()) -+ return -EINVAL; -+ -+ 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"); -diff --git a/drivers/firmware/arm-ffa/Kconfig b/drivers/firmware/arm-ffa/Kconfig -index e4914b9bc7..be4df89d23 100644 ---- a/drivers/firmware/arm-ffa/Kconfig -+++ b/drivers/firmware/arm-ffa/Kconfig -@@ -4,6 +4,7 @@ config ARM_FFA_TRANSPORT - bool "Enable Arm Firmware Framework for Armv8-A driver" - depends on DM && ARM64 - select ARM_SMCCC -+ select CMD_ARMFFA - select LIB_UUID - select DEVRES - help --- -2.25.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0006-FF-A-v15-arm_ffa-introduce-sandbox-FF-A-support.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0006-FF-A-v15-arm_ffa-introduce-sandbox-FF-A-support.patch new file mode 100644 index 0000000000..4f94b72228 --- /dev/null +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0006-FF-A-v15-arm_ffa-introduce-sandbox-FF-A-support.patch @@ -0,0 +1,1314 @@ +From 4f104ef6804ffd6483d166840d113630be85edb0 Mon Sep 17 00:00:00 2001 +From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> +Date: Mon, 17 Jul 2023 15:18:58 +0100 +Subject: [PATCH 06/33] FF-A v15: arm_ffa: introduce sandbox FF-A support + +Emulate Secure World's FF-A ABIs and allow testing U-Boot FF-A support + +Features of the sandbox FF-A support: + +- Introduce an FF-A emulator +- Introduce an FF-A device driver for FF-A comms with emulated Secure World +- Provides test methods allowing to read the status of the inspected ABIs + +The sandbox FF-A emulator supports only 64-bit direct messaging. + +Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> +Reviewed-by: Simon Glass <sjg@chromium.org> +Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20230713132847.176000-1-abdellatif.elkhlifi@arm.com/] +--- + MAINTAINERS | 3 +- + arch/sandbox/dts/sandbox.dtsi | 9 + + arch/sandbox/dts/test.dts | 9 + + arch/sandbox/include/asm/sandbox_arm_ffa.h | 72 ++ + .../include/asm/sandbox_arm_ffa_priv.h | 121 +++ + configs/sandbox64_defconfig | 2 + + configs/sandbox_defconfig | 2 + + doc/arch/arm64.ffa.rst | 19 +- + doc/arch/sandbox/sandbox.rst | 1 + + drivers/firmware/arm-ffa/Kconfig | 13 +- + drivers/firmware/arm-ffa/Makefile | 10 +- + drivers/firmware/arm-ffa/ffa-emul-uclass.c | 720 ++++++++++++++++++ + .../firmware/arm-ffa/sandbox_arm_ffa_priv.h | 14 - + drivers/firmware/arm-ffa/sandbox_ffa.c | 110 +++ + include/dm/uclass-id.h | 1 + + 15 files changed, 1084 insertions(+), 22 deletions(-) + create mode 100644 arch/sandbox/include/asm/sandbox_arm_ffa.h + create mode 100644 arch/sandbox/include/asm/sandbox_arm_ffa_priv.h + create mode 100644 drivers/firmware/arm-ffa/ffa-emul-uclass.c + delete mode 100644 drivers/firmware/arm-ffa/sandbox_arm_ffa_priv.h + create mode 100644 drivers/firmware/arm-ffa/sandbox_ffa.c + +diff --git a/MAINTAINERS b/MAINTAINERS +index 4ae82229fc..679a3acdd8 100644 +--- a/MAINTAINERS ++++ b/MAINTAINERS +@@ -269,12 +269,13 @@ F: configs/cortina_presidio-asic-pnand_defconfig + ARM FF-A + M: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> + S: Maintained ++F: arch/sandbox/include/asm/sandbox_arm_ffa.h ++F: arch/sandbox/include/asm/sandbox_arm_ffa_priv.h + F: cmd/armffa.c + F: doc/arch/arm64.ffa.rst + F: doc/usage/cmd/armffa.rst + F: drivers/firmware/arm-ffa/ + F: include/arm_ffa.h +-F: include/sandbox_arm_ffa.h + + ARM FREESCALE IMX + M: Stefano Babic <sbabic@denx.de> +diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi +index 30a305c4d2..94a08814b8 100644 +--- a/arch/sandbox/dts/sandbox.dtsi ++++ b/arch/sandbox/dts/sandbox.dtsi +@@ -445,6 +445,15 @@ + thermal { + compatible = "sandbox,thermal"; + }; ++ ++ arm-ffa-emul { ++ compatible = "sandbox,arm-ffa-emul"; ++ ++ sandbox-arm-ffa { ++ compatible = "sandbox,arm-ffa"; ++ }; ++ }; ++ + }; + + &cros_ec { +diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts +index ff9f9222e6..c6807ee031 100644 +--- a/arch/sandbox/dts/test.dts ++++ b/arch/sandbox/dts/test.dts +@@ -1820,6 +1820,15 @@ + extcon { + compatible = "sandbox,extcon"; + }; ++ ++ arm-ffa-emul { ++ compatible = "sandbox,arm-ffa-emul"; ++ ++ sandbox-arm-ffa { ++ compatible = "sandbox,arm-ffa"; ++ }; ++ }; ++ + }; + + #include "sandbox_pmic.dtsi" +diff --git a/arch/sandbox/include/asm/sandbox_arm_ffa.h b/arch/sandbox/include/asm/sandbox_arm_ffa.h +new file mode 100644 +index 0000000000..be2790f496 +--- /dev/null ++++ b/arch/sandbox/include/asm/sandbox_arm_ffa.h +@@ -0,0 +1,72 @@ ++/* SPDX-License-Identifier: GPL-2.0+ */ ++/* ++ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++ * ++ * Authors: ++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++ */ ++ ++#ifndef __SANDBOX_ARM_FFA_H ++#define __SANDBOX_ARM_FFA_H ++ ++#include <arm_ffa.h> ++ ++/* ++ * This header provides public sandbox FF-A emulator declarations ++ * and declarations needed by FF-A sandbox clients ++ */ ++ ++/* UUIDs strings of the emulated services */ ++#define SANDBOX_SERVICE1_UUID "ed32d533-4209-99e6-2d72-cdd998a79cc0" ++#define SANDBOX_SERVICE2_UUID "ed32d544-4209-99e6-2d72-cdd998a79cc0" ++ ++/* IDs of the emulated secure partitions (SPs) */ ++#define SANDBOX_SP1_ID 0x1245 ++#define SANDBOX_SP2_ID 0x9836 ++#define SANDBOX_SP3_ID 0x6452 ++#define SANDBOX_SP4_ID 0x7814 ++ ++/* Invalid service UUID (no matching SP) */ ++#define SANDBOX_SERVICE3_UUID "55d532ed-0942-e699-722d-c09ca798d9cd" ++ ++/* Invalid service UUID (invalid UUID string format) */ ++#define SANDBOX_SERVICE4_UUID "32ed-0942-e699-722d-c09ca798d9cd" ++ ++/* Number of valid services */ ++#define SANDBOX_SP_COUNT_PER_VALID_SERVICE 2 ++ ++/** ++ * struct ffa_sandbox_data - query ABI state data structure ++ * @data0_size: size of the first argument ++ * @data0: pointer to the first argument ++ * @data1_size>: size of the second argument ++ * @data1: pointer to the second argument ++ * ++ * Used to pass various types of data with different sizes between ++ * the test cases and the sandbox emulator. ++ * The data is for querying FF-A ABIs state. ++ */ ++struct ffa_sandbox_data { ++ u32 data0_size; /* size of the first argument */ ++ void *data0; /* pointer to the first argument */ ++ u32 data1_size; /* size of the second argument */ ++ void *data1; /* pointer to the second argument */ ++}; ++ ++/* The sandbox FF-A emulator public functions */ ++ ++/** ++ * sandbox_query_ffa_emul_state() - Inspect the FF-A ABIs ++ * @queried_func_id: The FF-A function to be queried ++ * @func_data: Pointer to the FF-A function arguments container structure ++ * ++ * Query the status of FF-A ABI specified in the input argument. ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++int sandbox_query_ffa_emul_state(u32 queried_func_id, ++ struct ffa_sandbox_data *func_data); ++ ++#endif +diff --git a/arch/sandbox/include/asm/sandbox_arm_ffa_priv.h b/arch/sandbox/include/asm/sandbox_arm_ffa_priv.h +new file mode 100644 +index 0000000000..b0881822d7 +--- /dev/null ++++ b/arch/sandbox/include/asm/sandbox_arm_ffa_priv.h +@@ -0,0 +1,121 @@ ++/* SPDX-License-Identifier: GPL-2.0+ */ ++/* ++ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++ * ++ * Authors: ++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++ */ ++ ++#ifndef __SANDBOX_ARM_FFA_PRV_H ++#define __SANDBOX_ARM_FFA_PRV_H ++ ++#include <arm_ffa_priv.h> ++ ++/* This header is exclusively used by the Sandbox FF-A driver and emulator */ ++ ++/* Non-secure physical FF-A instance */ ++#define NS_PHYS_ENDPOINT_ID (0) ++ ++#define GET_NS_PHYS_ENDPOINT_ID_MASK GENMASK(31, 16) ++#define GET_NS_PHYS_ENDPOINT_ID(x) \ ++ ((u16)(FIELD_GET(GET_NS_PHYS_ENDPOINT_ID_MASK, (x)))) ++ ++/* Helper macro for reading the destination partition ID */ ++#define GET_DST_SP_ID_MASK GENMASK(15, 0) ++#define GET_DST_SP_ID(x) \ ++ ((u16)(FIELD_GET(GET_DST_SP_ID_MASK, (x)))) ++ ++/* Helper macro for setting the source partition ID */ ++#define PREP_SRC_SP_ID_MASK GENMASK(31, 16) ++#define PREP_SRC_SP_ID(x) \ ++ (FIELD_PREP(PREP_SRC_SP_ID_MASK, (x))) ++ ++/* Helper macro for setting the destination endpoint ID */ ++#define PREP_NS_PHYS_ENDPOINT_ID_MASK GENMASK(15, 0) ++#define PREP_NS_PHYS_ENDPOINT_ID(x) \ ++ (FIELD_PREP(PREP_NS_PHYS_ENDPOINT_ID_MASK, (x))) ++ ++/* RX/TX buffers minimum size */ ++#define RXTX_BUFFERS_MIN_SIZE (RXTX_4K) ++#define RXTX_BUFFERS_MIN_PAGES (1) ++ ++/* MBZ registers info */ ++ ++/* x1-x7 MBZ */ ++#define FFA_X1X7_MBZ_CNT (7) ++#define FFA_X1X7_MBZ_REG_START (&res->a1) ++ ++/* x4-x7 MBZ */ ++#define FFA_X4X7_MBZ_CNT (4) ++#define FFA_X4X7_MBZ_REG_START (&res->a4) ++ ++/* x3-x7 MBZ */ ++#define FFA_X3X7_MBZ_CNT (5) ++#define FFA_X3_MBZ_REG_START (&res->a3) ++ ++/* number of emulated FF-A secure partitions (SPs) */ ++#define SANDBOX_PARTITIONS_CNT (4) ++ ++/* Binary data of the emulated services UUIDs */ ++ ++/* service 1 UUID binary data (little-endian format) */ ++#define SANDBOX_SERVICE1_UUID_A1 0xed32d533 ++#define SANDBOX_SERVICE1_UUID_A2 0x99e64209 ++#define SANDBOX_SERVICE1_UUID_A3 0x9cc02d72 ++#define SANDBOX_SERVICE1_UUID_A4 0xcdd998a7 ++ ++/* service 2 UUID binary data (little-endian format) */ ++#define SANDBOX_SERVICE2_UUID_A1 0xed32d544 ++#define SANDBOX_SERVICE2_UUID_A2 0x99e64209 ++#define SANDBOX_SERVICE2_UUID_A3 0x9cc02d72 ++#define SANDBOX_SERVICE2_UUID_A4 0xcdd998a7 ++ ++/** ++ * struct ffa_rxtxpair_info - structure hosting the RX/TX buffers flags ++ * @rxbuf_owned: RX buffer ownership flag (the owner is non secure world) ++ * @rxbuf_mapped: RX buffer mapping flag ++ * @txbuf_owned TX buffer ownership flag ++ * @txbuf_mapped: TX buffer mapping flag ++ * @rxtx_buf_size: RX/TX buffers size ++ * ++ * Hosts the ownership/mapping flags of the RX/TX buffers ++ * When a buffer is owned/mapped its corresponding flag is set to 1 otherwise 0. ++ */ ++struct ffa_rxtxpair_info { ++ u8 rxbuf_owned; ++ u8 rxbuf_mapped; ++ u8 txbuf_owned; ++ u8 txbuf_mapped; ++ u32 rxtx_buf_size; ++}; ++ ++/** ++ * struct sandbox_ffa_emul - emulator data ++ * ++ * @fwk_version: FF-A framework version ++ * @id: u-boot endpoint ID ++ * @partitions: The partitions descriptors structure ++ * @pair: The RX/TX buffers pair ++ * @pair_info: The RX/TX buffers pair flags and size ++ * @test_ffa_data: The data of the FF-A bus under test ++ * ++ * Hosts all the emulated secure world data. ++ */ ++struct sandbox_ffa_emul { ++ u32 fwk_version; ++ u16 id; ++ struct ffa_partitions partitions; ++ struct ffa_rxtxpair pair; ++ struct ffa_rxtxpair_info pair_info; ++}; ++ ++/** ++ * ffa_emul_find() - Finds the FF-A emulator ++ * @dev: the sandbox FF-A device (sandbox-arm-ffa) ++ * @emulp: the FF-A emulator device (sandbox-ffa-emul) ++ * Return: ++ * 0 on success. Otherwise, failure ++ */ ++int ffa_emul_find(struct udevice *dev, struct udevice **emulp); ++ ++#endif +diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig +index 98b3e0cda4..2db69b8e52 100644 +--- a/configs/sandbox64_defconfig ++++ b/configs/sandbox64_defconfig +@@ -260,3 +260,5 @@ CONFIG_FWU_MULTI_BANK_UPDATE=y + CONFIG_UNIT_TEST=y + CONFIG_UT_TIME=y + CONFIG_UT_DM=y ++CONFIG_NVMXIP_QSPI=y ++CONFIG_ARM_FFA_TRANSPORT=y +diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig +index 1ec44d5b33..f77733377d 100644 +--- a/configs/sandbox_defconfig ++++ b/configs/sandbox_defconfig +@@ -344,3 +344,5 @@ CONFIG_TEST_FDTDEC=y + CONFIG_UNIT_TEST=y + CONFIG_UT_TIME=y + CONFIG_UT_DM=y ++CONFIG_CMD_2048=y ++CONFIG_ARM_FFA_TRANSPORT=y +diff --git a/doc/arch/arm64.ffa.rst b/doc/arch/arm64.ffa.rst +index aefd527447..b7c754fa3d 100644 +--- a/doc/arch/arm64.ffa.rst ++++ b/doc/arch/arm64.ffa.rst +@@ -33,6 +33,10 @@ The U-Boot FF-A support provides the following parts: + + - A Uclass driver providing generic FF-A methods. + - An Arm FF-A device driver providing Arm-specific methods and reusing the Uclass methods. ++- A sandbox emulator for Arm FF-A, emulates the FF-A side of the Secure World and provides ++ FF-A ABIs inspection methods. ++- An FF-A sandbox device driver for FF-A communication with the emulated Secure World. ++ The driver leverages the FF-A Uclass to establish FF-A communication. + + FF-A and SMC specifications + ------------------------------------------- +@@ -62,6 +66,7 @@ CONFIG_ARM_FFA_TRANSPORT + Enables the FF-A support. Turn this on if you want to use FF-A + communication. + When using an Arm 64-bit platform, the Arm FF-A driver will be used. ++ When using sandbox, the sandbox FF-A emulator and FF-A sandbox driver will be used. + + FF-A ABIs under the hood + --------------------------------------- +@@ -98,10 +103,8 @@ architecture features including FF-A bus. + + Class Index Probed Driver Name + ----------------------------------------------------------- +- ... + firmware 0 [ + ] psci |-- psci + ffa 0 [ ] arm_ffa | `-- arm_ffa +- ... + + The PSCI driver is bound to the PSCI device and when probed it tries to discover + the architecture features by calling a callback the features drivers provide. +@@ -205,6 +208,18 @@ The following features are provided: + + - FF-A bus can be compiled and used without EFI + ++Relationship between the sandbox emulator and the FF-A device ++--------------------------------------------------------------- ++ ++:: ++ ++ => dm tree ++ ++ Class Index Probed Driver Name ++ ----------------------------------------------------------- ++ ffa_emul 0 [ + ] sandbox_ffa_emul `-- arm-ffa-emul ++ ffa 0 [ ] sandbox_arm_ffa `-- sandbox-arm-ffa ++ + The armffa command + ----------------------------------- + +diff --git a/doc/arch/sandbox/sandbox.rst b/doc/arch/sandbox/sandbox.rst +index 77ca6bc4cc..a3631de749 100644 +--- a/doc/arch/sandbox/sandbox.rst ++++ b/doc/arch/sandbox/sandbox.rst +@@ -200,6 +200,7 @@ Supported Drivers + + U-Boot sandbox supports these emulations: + ++- Arm FF-A + - Block devices + - Chrome OS EC + - GPIO +diff --git a/drivers/firmware/arm-ffa/Kconfig b/drivers/firmware/arm-ffa/Kconfig +index a7d5392859..d75f8b53fd 100644 +--- a/drivers/firmware/arm-ffa/Kconfig ++++ b/drivers/firmware/arm-ffa/Kconfig +@@ -2,9 +2,9 @@ + + config ARM_FFA_TRANSPORT + bool "Enable Arm Firmware Framework for Armv8-A driver" +- depends on DM && ARM64 +- select ARM_SMCCC +- select ARM_SMCCC_FEATURES ++ depends on DM && (ARM64 || SANDBOX) ++ select ARM_SMCCC if !SANDBOX ++ select ARM_SMCCC_FEATURES if !SANDBOX + imply CMD_ARMFFA + select LIB_UUID + select DEVRES +@@ -33,5 +33,10 @@ config ARM_FFA_TRANSPORT + Generic FF-A methods are implemented in the Uclass (arm-ffa-uclass.c). + Arm specific methods are implemented in the Arm driver (arm-ffa.c). + +- For more details about the FF-A support, please refer to doc/arch/arm64.ffa.rst ++ FF-A sandbox is provided to run FF-A under sandbox and allows to test the FF-A Uclass. ++ Sandbox support includes an emulator for Arm FF-A which emulates the FF-A side of ++ the Secure World and provides FF-A ABIs inspection methods (ffa-emul-uclass.c). ++ An FF-A sandbox driver is also provided for FF-A communication with the emulated ++ Secure World (sandbox_ffa.c). + ++ For more details about the FF-A support, please refer to doc/arch/arm64.ffa.rst +diff --git a/drivers/firmware/arm-ffa/Makefile b/drivers/firmware/arm-ffa/Makefile +index 11b1766285..318123a7f4 100644 +--- a/drivers/firmware/arm-ffa/Makefile ++++ b/drivers/firmware/arm-ffa/Makefile +@@ -5,4 +5,12 @@ + # Authors: + # Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> + +-obj-y += arm-ffa-uclass.o arm-ffa.o ++# build the generic FF-A methods ++obj-y += arm-ffa-uclass.o ++ifeq ($(CONFIG_SANDBOX),y) ++# build the FF-A sandbox emulator and driver ++obj-y += ffa-emul-uclass.o sandbox_ffa.o ++else ++# build the Arm64 FF-A driver ++obj-y += arm-ffa.o ++endif +diff --git a/drivers/firmware/arm-ffa/ffa-emul-uclass.c b/drivers/firmware/arm-ffa/ffa-emul-uclass.c +new file mode 100644 +index 0000000000..5562bbaac3 +--- /dev/null ++++ b/drivers/firmware/arm-ffa/ffa-emul-uclass.c +@@ -0,0 +1,720 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++/* ++ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++ * ++ * Authors: ++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++ */ ++#include <common.h> ++#include <dm.h> ++#include <mapmem.h> ++#include <string.h> ++#include <asm/global_data.h> ++#include <asm/sandbox_arm_ffa.h> ++#include <asm/sandbox_arm_ffa_priv.h> ++#include <dm/device-internal.h> ++#include <dm/lists.h> ++#include <dm/root.h> ++#include <linux/errno.h> ++#include <linux/sizes.h> ++ ++DECLARE_GLOBAL_DATA_PTR; ++ ++/* The partitions (SPs) table */ ++static struct ffa_partition_desc sandbox_partitions[SANDBOX_PARTITIONS_CNT] = { ++ { ++ .info = { .id = SANDBOX_SP1_ID, .exec_ctxt = 0x5687, .properties = 0x89325621 }, ++ .sp_uuid = { ++ .a1 = SANDBOX_SERVICE1_UUID_A1, ++ .a2 = SANDBOX_SERVICE1_UUID_A2, ++ .a3 = SANDBOX_SERVICE1_UUID_A3, ++ .a4 = SANDBOX_SERVICE1_UUID_A4, ++ } ++ }, ++ { ++ .info = { .id = SANDBOX_SP3_ID, .exec_ctxt = 0x7687, .properties = 0x23325621 }, ++ .sp_uuid = { ++ .a1 = SANDBOX_SERVICE2_UUID_A1, ++ .a2 = SANDBOX_SERVICE2_UUID_A2, ++ .a3 = SANDBOX_SERVICE2_UUID_A3, ++ .a4 = SANDBOX_SERVICE2_UUID_A4, ++ } ++ }, ++ { ++ .info = { .id = SANDBOX_SP2_ID, .exec_ctxt = 0x9587, .properties = 0x45325621 }, ++ .sp_uuid = { ++ .a1 = SANDBOX_SERVICE1_UUID_A1, ++ .a2 = SANDBOX_SERVICE1_UUID_A2, ++ .a3 = SANDBOX_SERVICE1_UUID_A3, ++ .a4 = SANDBOX_SERVICE1_UUID_A4, ++ } ++ }, ++ { ++ .info = { .id = SANDBOX_SP4_ID, .exec_ctxt = 0x1487, .properties = 0x70325621 }, ++ .sp_uuid = { ++ .a1 = SANDBOX_SERVICE2_UUID_A1, ++ .a2 = SANDBOX_SERVICE2_UUID_A2, ++ .a3 = SANDBOX_SERVICE2_UUID_A3, ++ .a4 = SANDBOX_SERVICE2_UUID_A4, ++ } ++ } ++ ++}; ++ ++/* The emulator functions */ ++ ++/** ++ * sandbox_ffa_version() - Emulated FFA_VERSION handler function ++ * @emul: The sandbox FF-A emulator device ++ * @pargs: The SMC call input arguments a0-a7 ++ * @res: The SMC return data ++ * ++ * Emulate FFA_VERSION FF-A function. ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++ ++static int sandbox_ffa_version(struct udevice *emul, ffa_value_t *pargs, ffa_value_t *res) ++{ ++ struct sandbox_ffa_emul *priv = dev_get_priv(emul); ++ ++ priv->fwk_version = FFA_VERSION_1_0; ++ res->a0 = priv->fwk_version; ++ ++ /* x1-x7 MBZ */ ++ memset(FFA_X1X7_MBZ_REG_START, 0, FFA_X1X7_MBZ_CNT * sizeof(ulong)); ++ ++ return 0; ++} ++ ++/** ++ * sandbox_ffa_id_get() - Emulated FFA_ID_GET handler function ++ * @emul: The sandbox FF-A emulator device ++ * @pargs: The SMC call input arguments a0-a7 ++ * @res: The SMC return data ++ * ++ * Emulate FFA_ID_GET FF-A function. ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++static int sandbox_ffa_id_get(struct udevice *emul, ffa_value_t *pargs, ffa_value_t *res) ++{ ++ struct sandbox_ffa_emul *priv = dev_get_priv(emul); ++ ++ res->a0 = FFA_SMC_32(FFA_SUCCESS); ++ res->a1 = 0; ++ ++ priv->id = NS_PHYS_ENDPOINT_ID; ++ res->a2 = priv->id; ++ ++ /* x3-x7 MBZ */ ++ memset(FFA_X3_MBZ_REG_START, 0, FFA_X3X7_MBZ_CNT * sizeof(ulong)); ++ ++ return 0; ++} ++ ++/** ++ * sandbox_ffa_features() - Emulated FFA_FEATURES handler function ++ * @pargs: The SMC call input arguments a0-a7 ++ * @res: The SMC return data ++ * ++ * Emulate FFA_FEATURES FF-A function. ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++static int sandbox_ffa_features(ffa_value_t *pargs, ffa_value_t *res) ++{ ++ res->a1 = 0; ++ ++ if (pargs->a1 == FFA_SMC_64(FFA_RXTX_MAP)) { ++ res->a0 = FFA_SMC_32(FFA_SUCCESS); ++ res->a2 = RXTX_BUFFERS_MIN_SIZE; ++ res->a3 = 0; ++ /* x4-x7 MBZ */ ++ memset(FFA_X4X7_MBZ_REG_START, 0, FFA_X4X7_MBZ_CNT * sizeof(ulong)); ++ return 0; ++ } ++ ++ res->a0 = FFA_SMC_32(FFA_ERROR); ++ res->a2 = -NOT_SUPPORTED; ++ /* x3-x7 MBZ */ ++ memset(FFA_X3_MBZ_REG_START, 0, FFA_X3X7_MBZ_CNT * sizeof(ulong)); ++ log_err("FF-A interface %lx not implemented\n", pargs->a1); ++ ++ return ffa_to_std_errmap[NOT_SUPPORTED]; ++} ++ ++/** ++ * sandbox_ffa_partition_info_get() - Emulated FFA_PARTITION_INFO_GET handler ++ * @emul: The sandbox FF-A emulator device ++ * @pargs: The SMC call input arguments a0-a7 ++ * @res: The SMC return data ++ * ++ * Emulate FFA_PARTITION_INFO_GET FF-A function. ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++static int sandbox_ffa_partition_info_get(struct udevice *emul, ffa_value_t *pargs, ++ ffa_value_t *res) ++{ ++ struct ffa_partition_info *rxbuf_desc_info = NULL; ++ u32 descs_cnt; ++ u32 descs_size_bytes; ++ int ret; ++ struct sandbox_ffa_emul *priv = dev_get_priv(emul); ++ ++ res->a0 = FFA_SMC_32(FFA_ERROR); ++ ++ if (!priv->pair.rxbuf) { ++ res->a2 = -DENIED; ++ ret = ffa_to_std_errmap[DENIED]; ++ goto cleanup; ++ } ++ ++ if (priv->pair_info.rxbuf_owned) { ++ res->a2 = -BUSY; ++ ret = ffa_to_std_errmap[BUSY]; ++ goto cleanup; ++ } ++ ++ if (!priv->partitions.descs) { ++ priv->partitions.descs = sandbox_partitions; ++ priv->partitions.count = SANDBOX_PARTITIONS_CNT; ++ } ++ ++ descs_size_bytes = SANDBOX_PARTITIONS_CNT * ++ sizeof(struct ffa_partition_desc); ++ ++ /* Abort if the RX buffer size is smaller than the descs buffer size */ ++ if ((priv->pair_info.rxtx_buf_size * SZ_4K) < descs_size_bytes) { ++ res->a2 = -NO_MEMORY; ++ ret = ffa_to_std_errmap[NO_MEMORY]; ++ goto cleanup; ++ } ++ ++ rxbuf_desc_info = priv->pair.rxbuf; ++ ++ /* No UUID specified. Return the information of all partitions */ ++ if (!pargs->a1 && !pargs->a2 && !pargs->a3 && !pargs->a4) { ++ for (descs_cnt = 0; descs_cnt < SANDBOX_PARTITIONS_CNT; descs_cnt++) ++ *(rxbuf_desc_info++) = priv->partitions.descs[descs_cnt].info; ++ ++ res->a0 = FFA_SMC_32(FFA_SUCCESS); ++ res->a2 = SANDBOX_PARTITIONS_CNT; ++ /* Transfer ownership to the consumer: the non secure world */ ++ priv->pair_info.rxbuf_owned = 1; ++ ret = 0; ++ ++ goto cleanup; ++ } ++ ++ /* A UUID specified. Return the info of all SPs matching the UUID */ ++ ++ for (descs_cnt = 0 ; descs_cnt < SANDBOX_PARTITIONS_CNT ; descs_cnt++) ++ if (pargs->a1 == priv->partitions.descs[descs_cnt].sp_uuid.a1 && ++ pargs->a2 == priv->partitions.descs[descs_cnt].sp_uuid.a2 && ++ pargs->a3 == priv->partitions.descs[descs_cnt].sp_uuid.a3 && ++ pargs->a4 == priv->partitions.descs[descs_cnt].sp_uuid.a4) { ++ *(rxbuf_desc_info++) = priv->partitions.descs[descs_cnt].info; ++ } ++ ++ if (rxbuf_desc_info != priv->pair.rxbuf) { ++ res->a0 = FFA_SMC_32(FFA_SUCCESS); ++ /* Store the partitions count */ ++ res->a2 = (ulong) ++ (rxbuf_desc_info - (struct ffa_partition_info *) ++ priv->pair.rxbuf); ++ ret = 0; ++ ++ /* Transfer ownership to the consumer: the non secure world */ ++ priv->pair_info.rxbuf_owned = 1; ++ } else { ++ /* Unrecognized UUID */ ++ res->a2 = -INVALID_PARAMETERS; ++ ret = ffa_to_std_errmap[INVALID_PARAMETERS]; ++ } ++ ++cleanup: ++ ++ log_err("FFA_PARTITION_INFO_GET (%ld)\n", res->a2); ++ ++ res->a1 = 0; ++ ++ /* x3-x7 MBZ */ ++ memset(FFA_X3_MBZ_REG_START, 0, FFA_X3X7_MBZ_CNT * sizeof(ulong)); ++ ++ return ret; ++} ++ ++/** ++ * sandbox_ffa_rxtx_map() - Emulated FFA_RXTX_MAP handler ++ * @emul: The sandbox FF-A emulator device ++ * @pargs: The SMC call input arguments a0-a7 ++ * @res: The SMC return data ++ * ++ * Emulate FFA_RXTX_MAP FF-A function. ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++static int sandbox_ffa_rxtx_map(struct udevice *emul, ffa_value_t *pargs, ffa_value_t *res) ++{ ++ int ret; ++ struct sandbox_ffa_emul *priv = dev_get_priv(emul); ++ ++ res->a0 = FFA_SMC_32(FFA_ERROR); ++ ++ if (priv->pair.txbuf && priv->pair.rxbuf) { ++ res->a2 = -DENIED; ++ ret = ffa_to_std_errmap[DENIED]; ++ goto feedback; ++ } ++ ++ if (pargs->a3 >= RXTX_BUFFERS_MIN_PAGES && pargs->a1 && pargs->a2) { ++ priv->pair.txbuf = map_sysmem(pargs->a1, 0); ++ priv->pair.rxbuf = map_sysmem(pargs->a2, 0); ++ priv->pair_info.rxtx_buf_size = pargs->a3; ++ priv->pair_info.rxbuf_mapped = 1; ++ res->a0 = FFA_SMC_32(FFA_SUCCESS); ++ res->a2 = 0; ++ ret = 0; ++ goto feedback; ++ } ++ ++ if (!pargs->a1 || !pargs->a2) { ++ res->a2 = -INVALID_PARAMETERS; ++ ret = ffa_to_std_errmap[INVALID_PARAMETERS]; ++ } else { ++ res->a2 = -NO_MEMORY; ++ ret = ffa_to_std_errmap[NO_MEMORY]; ++ } ++ ++ log_err("Error in FFA_RXTX_MAP arguments (%d)\n", ++ (int)res->a2); ++ ++feedback: ++ ++ res->a1 = 0; ++ ++ /* x3-x7 MBZ */ ++ memset(FFA_X3_MBZ_REG_START, 0, FFA_X3X7_MBZ_CNT * sizeof(ulong)); ++ ++ return ret; ++} ++ ++/** ++ * sandbox_ffa_rxtx_unmap() - Emulated FFA_RXTX_UNMAP handler ++ * @emul: The sandbox FF-A emulator device ++ * @pargs: The SMC call input arguments a0-a7 ++ * @res: The SMC return data ++ * ++ * Emulate FFA_RXTX_UNMAP FF-A function. ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++static int sandbox_ffa_rxtx_unmap(struct udevice *emul, ffa_value_t *pargs, ffa_value_t *res) ++{ ++ int ret; ++ struct sandbox_ffa_emul *priv = dev_get_priv(emul); ++ ++ res->a0 = FFA_SMC_32(FFA_ERROR); ++ res->a2 = -INVALID_PARAMETERS; ++ ret = ffa_to_std_errmap[INVALID_PARAMETERS]; ++ ++ if (GET_NS_PHYS_ENDPOINT_ID(pargs->a1) != priv->id) ++ goto feedback; ++ ++ if (priv->pair.txbuf && priv->pair.rxbuf) { ++ priv->pair.txbuf = 0; ++ priv->pair.rxbuf = 0; ++ priv->pair_info.rxtx_buf_size = 0; ++ priv->pair_info.rxbuf_mapped = 0; ++ res->a0 = FFA_SMC_32(FFA_SUCCESS); ++ res->a2 = 0; ++ ret = 0; ++ goto feedback; ++ } ++ ++ log_err("No buffer pair registered on behalf of the caller\n"); ++ ++feedback: ++ ++ res->a1 = 0; ++ ++ /* x3-x7 MBZ */ ++ memset(FFA_X3_MBZ_REG_START, 0, FFA_X3X7_MBZ_CNT * sizeof(ulong)); ++ ++ return ret; ++} ++ ++/** ++ * sandbox_ffa_rx_release() - Emulated FFA_RX_RELEASE handler ++ * @emul: The sandbox FF-A emulator device ++ * @pargs: The SMC call input arguments a0-a7 ++ * @res: The SMC return data ++ * ++ * Emulate FFA_RX_RELEASE FF-A function. ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++static int sandbox_ffa_rx_release(struct udevice *emul, ffa_value_t *pargs, ffa_value_t *res) ++{ ++ int ret; ++ struct sandbox_ffa_emul *priv = dev_get_priv(emul); ++ ++ if (!priv->pair_info.rxbuf_owned) { ++ res->a0 = FFA_SMC_32(FFA_ERROR); ++ res->a2 = -DENIED; ++ ret = ffa_to_std_errmap[DENIED]; ++ } else { ++ priv->pair_info.rxbuf_owned = 0; ++ res->a0 = FFA_SMC_32(FFA_SUCCESS); ++ res->a2 = 0; ++ ret = 0; ++ } ++ ++ res->a1 = 0; ++ ++ /* x3-x7 MBZ */ ++ memset(FFA_X3_MBZ_REG_START, 0, FFA_X3X7_MBZ_CNT * sizeof(ulong)); ++ ++ return ret; ++} ++ ++/** ++ * sandbox_ffa_sp_valid() - Check SP validity ++ * @emul: The sandbox FF-A emulator device ++ * @part_id: partition ID to check ++ * ++ * Search the input ID in the descriptors table. ++ * ++ * Return: ++ * ++ * 1 on success (Partition found). Otherwise, failure ++ */ ++static int sandbox_ffa_sp_valid(struct udevice *emul, u16 part_id) ++{ ++ u32 descs_cnt; ++ struct sandbox_ffa_emul *priv = dev_get_priv(emul); ++ ++ for (descs_cnt = 0 ; descs_cnt < SANDBOX_PARTITIONS_CNT ; descs_cnt++) ++ if (priv->partitions.descs[descs_cnt].info.id == part_id) ++ return 1; ++ ++ return 0; ++} ++ ++/** ++ * sandbox_ffa_msg_send_direct_req() - Emulated FFA_MSG_SEND_DIRECT_{REQ,RESP} handler ++ * @emul: The sandbox FF-A emulator device ++ * @pargs: The SMC call input arguments a0-a7 ++ * @res: The SMC return data ++ * ++ * Emulate FFA_MSG_SEND_DIRECT_{REQ,RESP} FF-A ABIs. ++ * Only SMC 64-bit is supported in Sandbox. ++ * ++ * Emulating interrupts is not supported. So, FFA_RUN and FFA_INTERRUPT are not ++ * supported. In case of success FFA_MSG_SEND_DIRECT_RESP is returned with ++ * default pattern data (0xff). ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++static int sandbox_ffa_msg_send_direct_req(struct udevice *emul, ++ ffa_value_t *pargs, ffa_value_t *res) ++{ ++ u16 part_id; ++ struct sandbox_ffa_emul *priv = dev_get_priv(emul); ++ ++ part_id = GET_DST_SP_ID(pargs->a1); ++ ++ if (GET_NS_PHYS_ENDPOINT_ID(pargs->a1) != priv->id || ++ !sandbox_ffa_sp_valid(emul, part_id) || pargs->a2) { ++ res->a0 = FFA_SMC_32(FFA_ERROR); ++ res->a1 = 0; ++ res->a2 = -INVALID_PARAMETERS; ++ ++ /* x3-x7 MBZ */ ++ memset(FFA_X3_MBZ_REG_START, 0, FFA_X3X7_MBZ_CNT * sizeof(ulong)); ++ ++ return ffa_to_std_errmap[INVALID_PARAMETERS]; ++ } ++ ++ res->a0 = FFA_SMC_64(FFA_MSG_SEND_DIRECT_RESP); ++ ++ res->a1 = PREP_SRC_SP_ID(part_id) | ++ PREP_NS_PHYS_ENDPOINT_ID(priv->id); ++ ++ res->a2 = 0; ++ ++ /* Return 0xff bytes as a response */ ++ res->a3 = -1UL; ++ res->a4 = -1UL; ++ res->a5 = -1UL; ++ res->a6 = -1UL; ++ res->a7 = -1UL; ++ ++ return 0; ++} ++ ++/** ++ * sandbox_ffa_get_rxbuf_flags() - Read the mapping/ownership flags ++ * @emul: The sandbox FF-A emulator device ++ * @queried_func_id: The FF-A function to be queried ++ * @func_data: Pointer to the FF-A function arguments container structure ++ * ++ * Query the status flags of the following emulated ++ * ABIs: FFA_RXTX_MAP, FFA_RXTX_UNMAP, FFA_RX_RELEASE. ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++static int sandbox_ffa_get_rxbuf_flags(struct udevice *emul, u32 queried_func_id, ++ struct ffa_sandbox_data *func_data) ++{ ++ struct sandbox_ffa_emul *priv = dev_get_priv(emul); ++ ++ if (!func_data) ++ return -EINVAL; ++ ++ if (!func_data->data0 || func_data->data0_size != sizeof(u8)) ++ return -EINVAL; ++ ++ switch (queried_func_id) { ++ case FFA_RXTX_MAP: ++ case FFA_RXTX_UNMAP: ++ *((u8 *)func_data->data0) = priv->pair_info.rxbuf_mapped; ++ return 0; ++ case FFA_RX_RELEASE: ++ *((u8 *)func_data->data0) = priv->pair_info.rxbuf_owned; ++ return 0; ++ default: ++ log_err("The querried FF-A interface flag (%d) undefined\n", ++ queried_func_id); ++ return -EINVAL; ++ } ++} ++ ++/** ++ * sandbox_ffa_get_fwk_version() - Return the FFA framework version ++ * @emul: The sandbox FF-A emulator device ++ * @func_data: Pointer to the FF-A function arguments container structure ++ * ++ * Return the FFA framework version read from the FF-A emulator data. ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++static int sandbox_ffa_get_fwk_version(struct udevice *emul, struct ffa_sandbox_data *func_data) ++{ ++ struct sandbox_ffa_emul *priv = dev_get_priv(emul); ++ ++ if (!func_data) ++ return -EINVAL; ++ ++ if (!func_data->data0 || ++ func_data->data0_size != sizeof(priv->fwk_version)) ++ return -EINVAL; ++ ++ *((u32 *)func_data->data0) = priv->fwk_version; ++ ++ return 0; ++} ++ ++/** ++ * sandbox_ffa_get_parts() - Return the address of partitions data ++ * @emul: The sandbox FF-A emulator device ++ * @func_data: Pointer to the FF-A function arguments container structure ++ * ++ * Return the address of partitions data read from the FF-A emulator data. ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++static int sandbox_ffa_get_parts(struct udevice *emul, struct ffa_sandbox_data *func_data) ++{ ++ struct sandbox_ffa_emul *priv = dev_get_priv(emul); ++ ++ if (!func_data) ++ return -EINVAL; ++ ++ if (!func_data->data0 || ++ func_data->data0_size != sizeof(struct ffa_partitions *)) ++ return -EINVAL; ++ ++ *((struct ffa_partitions **)func_data->data0) = &priv->partitions; ++ ++ return 0; ++} ++ ++/** ++ * sandbox_query_ffa_emul_state() - Inspect the FF-A ABIs ++ * @queried_func_id: The FF-A function to be queried ++ * @func_data: Pointer to the FF-A function arguments container structure ++ * ++ * Query the status of FF-A ABI specified in the input argument. ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++int sandbox_query_ffa_emul_state(u32 queried_func_id, ++ struct ffa_sandbox_data *func_data) ++{ ++ struct udevice *emul; ++ int ret; ++ ++ ret = uclass_first_device_err(UCLASS_FFA_EMUL, &emul); ++ if (ret) { ++ log_err("Cannot find FF-A emulator during querying state\n"); ++ return ret; ++ } ++ ++ switch (queried_func_id) { ++ case FFA_RXTX_MAP: ++ case FFA_RXTX_UNMAP: ++ case FFA_RX_RELEASE: ++ return sandbox_ffa_get_rxbuf_flags(emul, queried_func_id, func_data); ++ case FFA_VERSION: ++ return sandbox_ffa_get_fwk_version(emul, func_data); ++ case FFA_PARTITION_INFO_GET: ++ return sandbox_ffa_get_parts(emul, func_data); ++ default: ++ log_err("Undefined FF-A interface (%d)\n", ++ queried_func_id); ++ return -EINVAL; ++ } ++} ++ ++/** ++ * sandbox_arm_ffa_smccc_smc() - FF-A SMC call emulation ++ * @args: the SMC call arguments ++ * @res: the SMC call returned data ++ * ++ * Emulate the FF-A ABIs SMC call. ++ * The emulated FF-A ABI is identified and invoked. ++ * FF-A emulation is based on the FF-A specification 1.0 ++ * ++ * Return: ++ * ++ * 0 on success. Otherwise, failure. ++ * FF-A protocol error codes are returned using the registers arguments as ++ * described by the specification ++ */ ++void sandbox_arm_ffa_smccc_smc(ffa_value_t *args, ffa_value_t *res) ++{ ++ int ret = 0; ++ struct udevice *emul; ++ ++ ret = uclass_first_device_err(UCLASS_FFA_EMUL, &emul); ++ if (ret) { ++ log_err("Cannot find FF-A emulator during SMC emulation\n"); ++ return; ++ } ++ ++ switch (args->a0) { ++ case FFA_SMC_32(FFA_VERSION): ++ ret = sandbox_ffa_version(emul, args, res); ++ break; ++ case FFA_SMC_32(FFA_PARTITION_INFO_GET): ++ ret = sandbox_ffa_partition_info_get(emul, args, res); ++ break; ++ case FFA_SMC_32(FFA_RXTX_UNMAP): ++ ret = sandbox_ffa_rxtx_unmap(emul, args, res); ++ break; ++ case FFA_SMC_64(FFA_MSG_SEND_DIRECT_REQ): ++ ret = sandbox_ffa_msg_send_direct_req(emul, args, res); ++ break; ++ case FFA_SMC_32(FFA_ID_GET): ++ ret = sandbox_ffa_id_get(emul, args, res); ++ break; ++ case FFA_SMC_32(FFA_FEATURES): ++ ret = sandbox_ffa_features(args, res); ++ break; ++ case FFA_SMC_64(FFA_RXTX_MAP): ++ ret = sandbox_ffa_rxtx_map(emul, args, res); ++ break; ++ case FFA_SMC_32(FFA_RX_RELEASE): ++ ret = sandbox_ffa_rx_release(emul, args, res); ++ break; ++ default: ++ log_err("Undefined FF-A interface (%lx)\n", ++ args->a0); ++ } ++ ++ if (ret != 0) ++ log_err("FF-A ABI internal failure (%d)\n", ret); ++} ++ ++/** ++ * invoke_ffa_fn() - SMC wrapper ++ * @args: FF-A ABI arguments to be copied to Xn registers ++ * @res: FF-A ABI return data to be copied from Xn registers ++ * ++ * Calls the emulated SMC call. ++ */ ++void invoke_ffa_fn(ffa_value_t args, ffa_value_t *res) ++{ ++ sandbox_arm_ffa_smccc_smc(&args, res); ++} ++ ++/** ++ * ffa_emul_find() - Find the FF-A emulator ++ * @dev: the sandbox FF-A device (sandbox-arm-ffa) ++ * @emulp: the FF-A emulator device (sandbox-ffa-emul) ++ * ++ * Search for the FF-A emulator and returns its device pointer. ++ * ++ * Return: ++ * 0 on success. Otherwise, failure ++ */ ++int ffa_emul_find(struct udevice *dev, struct udevice **emulp) ++{ ++ int ret; ++ ++ ret = uclass_first_device_err(UCLASS_FFA_EMUL, emulp); ++ if (ret) { ++ log_err("Cannot find FF-A emulator\n"); ++ return ret; ++ } ++ ++ log_info("FF-A emulator ready to use\n"); ++ ++ return 0; ++} ++ ++UCLASS_DRIVER(ffa_emul) = { ++ .name = "ffa_emul", ++ .id = UCLASS_FFA_EMUL, ++ .post_bind = dm_scan_fdt_dev, ++}; ++ ++static const struct udevice_id sandbox_ffa_emul_ids[] = { ++ { .compatible = "sandbox,arm-ffa-emul" }, ++ { } ++}; ++ ++/* Declaring the sandbox FF-A emulator under UCLASS_FFA_EMUL */ ++U_BOOT_DRIVER(sandbox_ffa_emul) = { ++ .name = "sandbox_ffa_emul", ++ .id = UCLASS_FFA_EMUL, ++ .of_match = sandbox_ffa_emul_ids, ++ .priv_auto = sizeof(struct sandbox_ffa_emul), ++}; +diff --git a/drivers/firmware/arm-ffa/sandbox_arm_ffa_priv.h b/drivers/firmware/arm-ffa/sandbox_arm_ffa_priv.h +deleted file mode 100644 +index 4338f9c9b1..0000000000 +--- a/drivers/firmware/arm-ffa/sandbox_arm_ffa_priv.h ++++ /dev/null +@@ -1,14 +0,0 @@ +-/* SPDX-License-Identifier: GPL-2.0+ */ +-/* +- * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> +- * +- * Authors: +- * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> +- */ +- +-#ifndef __SANDBOX_ARM_FFA_PRV_H +-#define __SANDBOX_ARM_FFA_PRV_H +- +-/* Future sandbox support private declarations */ +- +-#endif +diff --git a/drivers/firmware/arm-ffa/sandbox_ffa.c b/drivers/firmware/arm-ffa/sandbox_ffa.c +new file mode 100644 +index 0000000000..ef9491ccea +--- /dev/null ++++ b/drivers/firmware/arm-ffa/sandbox_ffa.c +@@ -0,0 +1,110 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++/* ++ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++ * ++ * Authors: ++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++ */ ++#include <common.h> ++#include <arm_ffa.h> ++#include <dm.h> ++#include <log.h> ++#include <asm/global_data.h> ++#include <asm/sandbox_arm_ffa_priv.h> ++#include <dm/device-internal.h> ++#include <linux/errno.h> ++ ++DECLARE_GLOBAL_DATA_PTR; ++ ++/** ++ * sandbox_ffa_discover() - perform sandbox FF-A discovery ++ * @dev: The sandbox FF-A bus device ++ * Try to discover the FF-A framework. Discovery is performed by ++ * querying the FF-A framework version from secure world using the FFA_VERSION ABI. ++ * Return: ++ * ++ * 0 on success. Otherwise, failure ++ */ ++static int sandbox_ffa_discover(struct udevice *dev) ++{ ++ int ret; ++ struct udevice *emul; ++ ++ log_info("Emulated FF-A framework discovery\n"); ++ ++ ret = ffa_emul_find(dev, &emul); ++ if (ret) { ++ log_err("Cannot find FF-A emulator\n"); ++ return ret; ++ } ++ ++ ret = ffa_get_version_hdlr(dev); ++ if (ret) ++ return ret; ++ ++ return 0; ++} ++ ++/** ++ * sandbox_ffa_probe() - The sandbox FF-A driver probe function ++ * @dev: the sandbox-arm-ffa device ++ * Save the emulator device in uc_priv. ++ * Return: ++ * ++ * 0 on success. ++ */ ++static int sandbox_ffa_probe(struct udevice *dev) ++{ ++ int ret; ++ struct ffa_priv *uc_priv = dev_get_uclass_priv(dev); ++ ++ ret = uclass_first_device_err(UCLASS_FFA_EMUL, &uc_priv->emul); ++ if (ret) { ++ log_err("Cannot find FF-A emulator\n"); ++ return ret; ++ } ++ ++ return 0; ++} ++ ++/** ++ * sandbox_ffa_bind() - The sandbox FF-A driver bind function ++ * @dev: the sandbox-arm-ffa device ++ * Try to discover the emulated FF-A bus. ++ * Return: ++ * ++ * 0 on success. ++ */ ++static int sandbox_ffa_bind(struct udevice *dev) ++{ ++ int ret; ++ ++ ret = sandbox_ffa_discover(dev); ++ if (ret) ++ return ret; ++ ++ return 0; ++} ++ ++/* Sandbox Arm FF-A emulator operations */ ++ ++static const struct ffa_bus_ops sandbox_ffa_ops = { ++ .partition_info_get = ffa_get_partitions_info_hdlr, ++ .sync_send_receive = ffa_msg_send_direct_req_hdlr, ++ .rxtx_unmap = ffa_unmap_rxtx_buffers_hdlr, ++}; ++ ++static const struct udevice_id sandbox_ffa_id[] = { ++ { "sandbox,arm-ffa", 0 }, ++ { }, ++}; ++ ++/* Declaring the sandbox FF-A driver under UCLASS_FFA */ ++U_BOOT_DRIVER(sandbox_arm_ffa) = { ++ .name = "sandbox_arm_ffa", ++ .of_match = sandbox_ffa_id, ++ .id = UCLASS_FFA, ++ .bind = sandbox_ffa_bind, ++ .probe = sandbox_ffa_probe, ++ .ops = &sandbox_ffa_ops, ++}; +diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h +index 3c6af2e3d2..0432c95c9e 100644 +--- a/include/dm/uclass-id.h ++++ b/include/dm/uclass-id.h +@@ -63,6 +63,7 @@ enum uclass_id { + UCLASS_ETH_PHY, /* Ethernet PHY device */ + UCLASS_EXTCON, /* External Connector Class */ + UCLASS_FFA, /* Arm Firmware Framework for Armv8-A */ ++ UCLASS_FFA_EMUL, /* sandbox FF-A device emulator */ + UCLASS_FIRMWARE, /* Firmware */ + UCLASS_FPGA, /* FPGA device */ + UCLASS_FUZZING_ENGINE, /* Fuzzing engine */ +-- +2.25.1 + diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0006-arm_ffa-introduce-the-FF-A-Sandbox-driver.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0006-arm_ffa-introduce-the-FF-A-Sandbox-driver.patch deleted file mode 100644 index 8c3892f043..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0006-arm_ffa-introduce-the-FF-A-Sandbox-driver.patch +++ /dev/null @@ -1,1164 +0,0 @@ -From 301430b7c8dceebe349b82c598097628da733090 Mon Sep 17 00:00:00 2001 -From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Date: Tue, 29 Nov 2022 14:44:36 +0000 -Subject: [PATCH 06/42] arm_ffa: introduce the FF-A Sandbox driver - -Provide a Sandbox driver to emulate the FF-A ABIs - -The emulated ABIs are those supported by the FF-A core driver -and according to FF-A specification v1.0. - -The Sandbox driver provides operations allowing the test -application to read the status of all the inspected ABIs -and perform functional tests based on that. - -sandbox driver supports only 64-bit direct messaging. - -Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Cc: Tom Rini <trini@konsulko.com> -Cc: Simon Glass <sjg@chromium.org> -Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> -Cc: Jens Wiklander <jens.wiklander@linaro.org> -Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/] - -Changelog: -=============== - -v8: update ffa_bus_prvdata_get() to return a pointer rather than - a pointer address - -v7: state that sandbox driver supports only 64-bit direct messaging - -v4: align sandbox driver with the new FF-A driver interfaces - and new way of error handling - -v1: introduce the sandbox driver -Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> ---- - MAINTAINERS | 1 + - configs/sandbox64_defconfig | 2 + - configs/sandbox_defconfig | 2 + - drivers/firmware/arm-ffa/Kconfig | 9 +- - drivers/firmware/arm-ffa/Makefile | 1 + - drivers/firmware/arm-ffa/arm_ffa_prv.h | 15 +- - drivers/firmware/arm-ffa/core.c | 22 +- - drivers/firmware/arm-ffa/sandbox.c | 659 ++++++++++++++++++ - .../firmware/arm-ffa/sandbox_arm_ffa_prv.h | 144 ++++ - include/arm_ffa.h | 2 +- - include/sandbox_arm_ffa.h | 91 +++ - lib/efi_loader/efi_boottime.c | 2 +- - 12 files changed, 937 insertions(+), 13 deletions(-) - create mode 100644 drivers/firmware/arm-ffa/sandbox.c - create mode 100644 drivers/firmware/arm-ffa/sandbox_arm_ffa_prv.h - create mode 100644 include/sandbox_arm_ffa.h - -diff --git a/MAINTAINERS b/MAINTAINERS -index 61ce6c436f..297d165f84 100644 ---- a/MAINTAINERS -+++ b/MAINTAINERS -@@ -271,6 +271,7 @@ F: cmd/armffa.c - F: doc/arch/arm64.ffa.rst - F: drivers/firmware/arm-ffa/ - F: include/arm_ffa.h -+F: include/sandbox_arm_ffa.h - - ARM FREESCALE IMX - M: Stefano Babic <sbabic@denx.de> -diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig -index ba45ac0b71..4b8a1ec42b 100644 ---- a/configs/sandbox64_defconfig -+++ b/configs/sandbox64_defconfig -@@ -259,3 +259,5 @@ CONFIG_FWU_MULTI_BANK_UPDATE=y - CONFIG_UNIT_TEST=y - CONFIG_UT_TIME=y - CONFIG_UT_DM=y -+CONFIG_ARM_FFA_TRANSPORT=y -+CONFIG_SANDBOX_FFA=y -\ No newline at end of file -diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig -index be46cae7aa..650f06ae61 100644 ---- a/configs/sandbox_defconfig -+++ b/configs/sandbox_defconfig -@@ -334,3 +334,5 @@ CONFIG_TEST_FDTDEC=y - CONFIG_UNIT_TEST=y - CONFIG_UT_TIME=y - CONFIG_UT_DM=y -+CONFIG_ARM_FFA_TRANSPORT=y -+CONFIG_SANDBOX_FFA=y -\ No newline at end of file -diff --git a/drivers/firmware/arm-ffa/Kconfig b/drivers/firmware/arm-ffa/Kconfig -index be4df89d23..b86f16d778 100644 ---- a/drivers/firmware/arm-ffa/Kconfig -+++ b/drivers/firmware/arm-ffa/Kconfig -@@ -2,8 +2,8 @@ - - config ARM_FFA_TRANSPORT - bool "Enable Arm Firmware Framework for Armv8-A driver" -- depends on DM && ARM64 -- select ARM_SMCCC -+ depends on DM && (ARM64 || SANDBOX) -+ select ARM_SMCCC if !SANDBOX - select CMD_ARMFFA - select LIB_UUID - select DEVRES -@@ -29,3 +29,8 @@ config ARM_FFA_TRANSPORT - - For more details about the FF-A driver, please refer to doc/arch/arm64.ffa.rst - -+config SANDBOX_FFA -+ bool "FF-A Sandbox driver" -+ depends on ARM_FFA_TRANSPORT && SANDBOX -+ help -+ This emulates the FF-A handling under Sandbox and allows to test the FF-A driver -diff --git a/drivers/firmware/arm-ffa/Makefile b/drivers/firmware/arm-ffa/Makefile -index 043a8915be..0d21d6b47a 100644 ---- a/drivers/firmware/arm-ffa/Makefile -+++ b/drivers/firmware/arm-ffa/Makefile -@@ -4,3 +4,4 @@ - # Abdellatif El Khlifi, Arm Limited, abdellatif.elkhlifi@arm.com. - - obj-y += arm-ffa-uclass.o core.o -+obj-$(CONFIG_SANDBOX_FFA) += sandbox.o -diff --git a/drivers/firmware/arm-ffa/arm_ffa_prv.h b/drivers/firmware/arm-ffa/arm_ffa_prv.h -index 4eea7dc036..bbc8b87069 100644 ---- a/drivers/firmware/arm-ffa/arm_ffa_prv.h -+++ b/drivers/firmware/arm-ffa/arm_ffa_prv.h -@@ -19,6 +19,16 @@ - /* FF-A core driver name */ - #define FFA_DRV_NAME "arm_ffa" - -+/* The FF-A SMC function definitions */ -+ -+#if CONFIG_IS_ENABLED(SANDBOX_FFA) -+#include "sandbox_arm_ffa.h" -+#else -+typedef struct arm_smccc_1_2_regs ffa_value_t; -+#endif -+ -+typedef void (*invoke_ffa_fn_t)(ffa_value_t args, ffa_value_t *res); -+ - /* FF-A driver version definitions */ - - #define MAJOR_VERSION_MASK GENMASK(30, 16) -@@ -103,11 +113,6 @@ struct ffa_abi_errmap { - #define FFA_ERRMAP_COUNT (FFA_LAST_ID - FFA_FIRST_ID + 1) - #define FFA_ID_TO_ERRMAP_ID(ffa_id) ((ffa_id) - FFA_FIRST_ID) - --/* The FF-A SMC function definitions */ -- --typedef struct arm_smccc_1_2_regs ffa_value_t; --typedef void (*invoke_ffa_fn_t)(ffa_value_t args, ffa_value_t *res); -- - /* - * struct ffa_partition_uuid - 16 bytes UUID transmitted by FFA_PARTITION_INFO_GET - * @a1-4: 32-bit words access to the UUID data -diff --git a/drivers/firmware/arm-ffa/core.c b/drivers/firmware/arm-ffa/core.c -index 0b1f8e6a07..560603b28b 100644 ---- a/drivers/firmware/arm-ffa/core.c -+++ b/drivers/firmware/arm-ffa/core.c -@@ -1072,6 +1072,7 @@ static int ffa_msg_send_direct_req(struct udevice *dev, u16 dst_part_id, - return ffa_to_std_errno(ffa_errno); - } - -+#if !CONFIG_IS_ENABLED(SANDBOX_FFA) - /** - * __arm_ffa_fn_smc - SMC wrapper - * @args: FF-A ABI arguments to be copied to Xn registers -@@ -1085,6 +1086,7 @@ void __arm_ffa_fn_smc(ffa_value_t args, ffa_value_t *res) - { - arm_smccc_1_2_smc(&args, res); - } -+#endif - - /** - * ffa_set_smc_conduit - Set the SMC conduit -@@ -1098,7 +1100,12 @@ void __arm_ffa_fn_smc(ffa_value_t args, ffa_value_t *res) - */ - static int ffa_set_smc_conduit(void) - { -- ffa_priv_data->invoke_ffa_fn = __arm_ffa_fn_smc; -+#if CONFIG_IS_ENABLED(SANDBOX_FFA) -+ ffa_priv_data->invoke_ffa_fn = sandbox_arm_ffa_smccc_smc; -+ ffa_info("Using SMC emulation"); -+#else -+ ffa_priv_data->invoke_ffa_fn = __arm_ffa_fn_smc; -+#endif - - if (!ffa_priv_data->invoke_ffa_fn) { - ffa_err("failure to set the invoke function"); -@@ -1275,17 +1282,18 @@ struct ffa_prvdata *ffa_bus_prvdata_get(void) - } - - /** -- * ffa_bus_discover - discover FF-A bus and probe arm_ffa device -+ * ffa_bus_discover - discover FF-A bus and probe arm_ffa and sandbox_arm_ffa devices - * @pdev: the address of a device pointer (to be filled when the arm_ffa bus device is created - * successfully) - * - * This function makes sure the FF-A bus is discoverable. -- * When probing succeeds FF-A discovery is done. The arm_ffa device is ready to use. -+ * When probing succeeds FF-A discovery is done. The arm_ffa and sandbox_arm_ffa devices -+ * are ready to use. - * - * When the bus was already discovered successfully the discovery will not run again. - * - * Arm FF-A transport is implemented through arm_ffa u-boot device managing the FF-A -- * communication. -+ * communication. In Sandbox mode sandbox_arm_ffa is used to test arm_ffa driver. - * All FF-A clients should use the arm_ffa device to use the FF-A transport. - * - * Return: -@@ -1299,6 +1307,12 @@ int ffa_bus_discover(struct udevice **pdev) - if (!ffa_priv_data) { - ret = ffa_device_get(pdev); - -+#if CONFIG_IS_ENABLED(SANDBOX_FFA) -+ if (ret == 0) -+ ret = sandbox_ffa_device_get(); -+#endif -+ } -+ - return ret; - } - -diff --git a/drivers/firmware/arm-ffa/sandbox.c b/drivers/firmware/arm-ffa/sandbox.c -new file mode 100644 -index 0000000000..16f1ca926e ---- /dev/null -+++ b/drivers/firmware/arm-ffa/sandbox.c -@@ -0,0 +1,659 @@ -+// SPDX-License-Identifier: GPL-2.0+ -+/* -+ * (C) Copyright 2022 ARM Limited -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -+ */ -+ -+#include "sandbox_arm_ffa_prv.h" -+#include <asm/global_data.h> -+#include <common.h> -+#include <dm.h> -+#include <dm/device-internal.h> -+#include <dm/root.h> -+#include <linux/errno.h> -+#include <linux/sizes.h> -+#include <mapmem.h> -+#include <string.h> -+ -+DECLARE_GLOBAL_DATA_PTR; -+ -+/** -+ * The device private data structure containing all the emulated secure world data -+ */ -+static struct sandbox_ffa_prvdata sandbox_ffa_priv_data = {0}; -+ -+/* The partitions (SPs) table */ -+static struct ffa_partition_desc sandbox_partitions[SANDBOX_PARTITIONS_CNT] = { -+ { -+ .info = { .id = SANDBOX_SP1_ID, .exec_ctxt = 0x5687, .properties = 0x89325621 }, -+ .sp_uuid = { -+ .a1 = SANDBOX_SERVICE1_UUID_A1, -+ .a2 = SANDBOX_SERVICE1_UUID_A2, -+ .a3 = SANDBOX_SERVICE1_UUID_A3, -+ .a4 = SANDBOX_SERVICE1_UUID_A4, -+ } -+ }, -+ { -+ .info = { .id = SANDBOX_SP2_ID, .exec_ctxt = 0x9587, .properties = 0x45325621 }, -+ .sp_uuid = { -+ .a1 = SANDBOX_SERVICE2_UUID_A1, -+ .a2 = SANDBOX_SERVICE2_UUID_A2, -+ .a3 = SANDBOX_SERVICE2_UUID_A3, -+ .a4 = SANDBOX_SERVICE2_UUID_A4, -+ } -+ }, -+ { -+ .info = { .id = SANDBOX_SP3_ID, .exec_ctxt = 0x7687, .properties = 0x23325621 }, -+ .sp_uuid = { -+ .a1 = SANDBOX_SERVICE1_UUID_A1, -+ .a2 = SANDBOX_SERVICE1_UUID_A2, -+ .a3 = SANDBOX_SERVICE1_UUID_A3, -+ .a4 = SANDBOX_SERVICE1_UUID_A4, -+ } -+ }, -+ { -+ .info = { .id = SANDBOX_SP4_ID, .exec_ctxt = 0x1487, .properties = 0x70325621 }, -+ .sp_uuid = { -+ .a1 = SANDBOX_SERVICE2_UUID_A1, -+ .a2 = SANDBOX_SERVICE2_UUID_A2, -+ .a3 = SANDBOX_SERVICE2_UUID_A3, -+ .a4 = SANDBOX_SERVICE2_UUID_A4, -+ } -+ } -+ -+}; -+ -+/* -+ * Driver functions -+ */ -+ -+/** -+ * sandbox_ffa_get_device - probes the sandbox_arm_ffa device -+ * -+ * This function makes sure the sandbox_arm_ffa device is probed -+ * This function makes sure the sandbox_arm_ffa device is -+ * created, bound to this driver, probed and ready to use. -+ * -+ * sandbox_arm_ffa depends on arm_ffa device. This dependency is -+ * handled by ffa_bus_discover function. arm_ffa is probed first then -+ * sandbox_arm_ffa. -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+int sandbox_ffa_device_get(void) -+{ -+ int ret; -+ -+ if (sandbox_ffa_priv_data.dev) -+ return 0; -+ -+ ret = device_bind(dm_root(), -+ DM_DRIVER_GET(sandbox_arm_ffa), -+ FFA_SANDBOX_DRV_NAME, -+ NULL, -+ ofnode_null(), -+ &sandbox_ffa_priv_data.dev); -+ if (ret) { -+ sandbox_ffa_priv_data.dev = NULL; -+ return ret; -+ } -+ -+ ret = device_probe(sandbox_ffa_priv_data.dev); -+ if (ret) { -+ ffa_err("[Sandbox] can not probe the device"); -+ device_unbind(sandbox_ffa_priv_data.dev); -+ sandbox_ffa_priv_data.dev = NULL; -+ return ret; -+ } -+ -+ return 0; -+} -+ -+/** -+ * sandbox_ffa_version - Emulated FFA_VERSION handler function -+ * @{a0-a7} , res: The SMC call arguments and return structure. -+ * -+ * This is the function that emulates FFA_VERSION FF-A function. -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+SANDBOX_SMC_FFA_ABI(ffa_version) -+{ -+ sandbox_ffa_priv_data.fwk_version = FFA_VERSION_1_0; -+ res->a0 = sandbox_ffa_priv_data.fwk_version; -+ -+ /* x1-x7 MBZ */ -+ memset(FFA_X1X7_MBZ_REG_START, 0, FFA_X1X7_MBZ_CNT * sizeof(unsigned long)); -+ -+ return 0; -+} -+ -+/** -+ * sandbox_ffa_id_get - Emulated FFA_ID_GET handler function -+ * @{a0-a7} , res: The SMC call arguments and return structure. -+ * -+ * This is the function that emulates FFA_ID_GET FF-A function. -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+SANDBOX_SMC_FFA_ABI(ffa_id_get) -+{ -+ res->a0 = FFA_SMC_32(FFA_SUCCESS); -+ res->a1 = 0; -+ -+ sandbox_ffa_priv_data.id = NS_PHYS_ENDPOINT_ID; -+ res->a2 = sandbox_ffa_priv_data.id; -+ -+ /* x3-x7 MBZ */ -+ memset(FFA_X3_MBZ_REG_START, 0, FFA_X3X7_MBZ_CNT * sizeof(unsigned long)); -+ -+ return 0; -+} -+ -+/** -+ * sandbox_ffa_features - Emulated FFA_FEATURES handler function -+ * @{a0-a7} , res: The SMC call arguments and return structure. -+ * -+ * This is the function that emulates FFA_FEATURES FF-A function. -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+SANDBOX_SMC_FFA_ABI(ffa_features) -+{ -+ if (pargs->a1 == FFA_SMC_64(FFA_RXTX_MAP)) { -+ res->a0 = FFA_SMC_32(FFA_SUCCESS); -+ res->a2 = RXTX_BUFFERS_MIN_SIZE; -+ res->a3 = 0; -+ /* x4-x7 MBZ */ -+ memset(FFA_X4X7_MBZ_REG_START, -+ 0, FFA_X4X7_MBZ_CNT * sizeof(unsigned long)); -+ } else { -+ res->a0 = FFA_SMC_32(FFA_ERROR); -+ res->a2 = FFA_ERR_STAT_NOT_SUPPORTED; -+ /* x3-x7 MBZ */ -+ memset(FFA_X3_MBZ_REG_START, -+ 0, FFA_X3X7_MBZ_CNT * sizeof(unsigned long)); -+ ffa_err("[Sandbox] FF-A interface 0x%lx not implemented", pargs->a1); -+ } -+ -+ res->a1 = 0; -+ -+ return 0; -+} -+ -+/** -+ * sandbox_ffa_partition_info_get - Emulated FFA_PARTITION_INFO_GET handler function -+ * @{a0-a7} , res: The SMC call arguments and return structure. -+ * -+ * This is the function that emulates FFA_PARTITION_INFO_GET FF-A function. -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+SANDBOX_SMC_FFA_ABI(ffa_partition_info_get) -+{ -+ struct ffa_partition_info *rxbuf_desc_info = NULL; -+ u32 descs_cnt; -+ u32 descs_size_bytes; -+ -+ res->a0 = FFA_SMC_32(FFA_ERROR); -+ -+ if (!sandbox_ffa_priv_data.pair.rxbuf) { -+ res->a2 = FFA_ERR_STAT_DENIED; -+ goto cleanup; -+ } -+ -+ if (sandbox_ffa_priv_data.pair_info.rxbuf_owned) { -+ res->a2 = FFA_ERR_STAT_BUSY; -+ goto cleanup; -+ } -+ -+ if (!sandbox_ffa_priv_data.partitions.descs) { -+ sandbox_ffa_priv_data.partitions.descs = sandbox_partitions; -+ sandbox_ffa_priv_data.partitions.count = SANDBOX_PARTITIONS_CNT; -+ } -+ -+ descs_size_bytes = SANDBOX_PARTITIONS_CNT * sizeof(struct ffa_partition_desc); -+ -+ /* Abort if the RX buffer size is smaller than the descriptors buffer size */ -+ if ((sandbox_ffa_priv_data.pair_info.rxtx_buf_size * SZ_4K) < descs_size_bytes) { -+ res->a2 = FFA_ERR_STAT_NO_MEMORY; -+ goto cleanup; -+ } -+ -+ rxbuf_desc_info = (struct ffa_partition_info *)sandbox_ffa_priv_data.pair.rxbuf; -+ -+ /* No UUID specified. Return the information of all partitions */ -+ if (!pargs->a1 && !pargs->a2 && !pargs->a3 && !pargs->a4) { -+ for (descs_cnt = 0 ; descs_cnt < SANDBOX_PARTITIONS_CNT ; descs_cnt++) -+ *(rxbuf_desc_info++) = -+ sandbox_ffa_priv_data.partitions.descs[descs_cnt].info; -+ -+ res->a0 = FFA_SMC_32(FFA_SUCCESS); -+ res->a2 = SANDBOX_PARTITIONS_CNT; -+ /* transfer ownership to the consumer: the non secure world */ -+ sandbox_ffa_priv_data.pair_info.rxbuf_owned = 1; -+ -+ goto cleanup; -+ } -+ -+ /* -+ * A UUID is specified. Return the information of all partitions matching -+ * the UUID -+ */ -+ -+ for (descs_cnt = 0 ; descs_cnt < SANDBOX_PARTITIONS_CNT ; descs_cnt++) -+ if (pargs->a1 == sandbox_ffa_priv_data.partitions.descs[descs_cnt].sp_uuid.a1 && -+ pargs->a2 == sandbox_ffa_priv_data.partitions.descs[descs_cnt].sp_uuid.a2 && -+ pargs->a3 == sandbox_ffa_priv_data.partitions.descs[descs_cnt].sp_uuid.a3 && -+ pargs->a4 == sandbox_ffa_priv_data.partitions.descs[descs_cnt].sp_uuid.a4) { -+ *(rxbuf_desc_info++) = -+ sandbox_ffa_priv_data.partitions.descs[descs_cnt].info; -+ } -+ -+ if (rxbuf_desc_info != ((struct ffa_partition_info *)sandbox_ffa_priv_data.pair.rxbuf)) { -+ res->a0 = FFA_SMC_32(FFA_SUCCESS); -+ /* store the partitions count */ -+ res->a2 = (unsigned long) -+ (rxbuf_desc_info - (struct ffa_partition_info *) -+ sandbox_ffa_priv_data.pair.rxbuf); -+ -+ /* transfer ownership to the consumer: the non secure world */ -+ sandbox_ffa_priv_data.pair_info.rxbuf_owned = 1; -+ } else { -+ /* Unrecognized UUID */ -+ res->a2 = FFA_ERR_STAT_INVALID_PARAMETERS; -+ } -+ -+cleanup: -+ -+ ffa_err("[Sandbox] FFA_PARTITION_INFO_GET (%ld)", res->a2); -+ -+ res->a1 = 0; -+ -+ /* x3-x7 MBZ */ -+ memset(FFA_X3_MBZ_REG_START, 0, FFA_X3X7_MBZ_CNT * sizeof(unsigned long)); -+ -+ return 0; -+} -+ -+/** -+ * sandbox_ffa_rxtx_map - Emulated FFA_RXTX_MAP handler function -+ * @{a0-a7} , res: The SMC call arguments and return structure. -+ * -+ * This is the function that emulates FFA_RXTX_MAP FF-A function. -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+SANDBOX_SMC_FFA_ABI(ffa_rxtx_map) -+{ -+ res->a0 = FFA_SMC_32(FFA_ERROR); -+ -+ if (sandbox_ffa_priv_data.pair.txbuf && sandbox_ffa_priv_data.pair.rxbuf) { -+ res->a2 = FFA_ERR_STAT_DENIED; -+ goto feedback; -+ } -+ -+ if (pargs->a3 >= RXTX_BUFFERS_MIN_PAGES && pargs->a1 && pargs->a2) { -+ sandbox_ffa_priv_data.pair.txbuf = pargs->a1; -+ sandbox_ffa_priv_data.pair.rxbuf = pargs->a2; -+ sandbox_ffa_priv_data.pair_info.rxtx_buf_size = pargs->a3; -+ sandbox_ffa_priv_data.pair_info.rxbuf_mapped = 1; -+ res->a0 = FFA_SMC_32(FFA_SUCCESS); -+ res->a2 = 0; -+ goto feedback; -+ } -+ -+ if (!pargs->a1 || !pargs->a2) -+ res->a2 = FFA_ERR_STAT_INVALID_PARAMETERS; -+ else -+ res->a2 = FFA_ERR_STAT_NO_MEMORY; -+ -+ ffa_err("[Sandbox] error in FFA_RXTX_MAP arguments (%d)", (int)res->a2); -+ -+feedback: -+ -+ res->a1 = 0; -+ -+ /* x3-x7 MBZ */ -+ memset(FFA_X3_MBZ_REG_START, -+ 0, FFA_X3X7_MBZ_CNT * sizeof(unsigned long)); -+ -+ return 0; -+} -+ -+/** -+ * sandbox_ffa_rxtx_unmap - Emulated FFA_RXTX_UNMAP handler function -+ * @{a0-a7} , res: The SMC call arguments and return structure. -+ * -+ * This is the function that emulates FFA_RXTX_UNMAP FF-A function. -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+SANDBOX_SMC_FFA_ABI(ffa_rxtx_unmap) -+{ -+ res->a0 = FFA_SMC_32(FFA_ERROR); -+ res->a2 = FFA_ERR_STAT_INVALID_PARAMETERS; -+ -+ if (GET_NS_PHYS_ENDPOINT_ID(pargs->a1) != sandbox_ffa_priv_data.id) -+ goto feedback; -+ -+ if (sandbox_ffa_priv_data.pair.txbuf && sandbox_ffa_priv_data.pair.rxbuf) { -+ sandbox_ffa_priv_data.pair.txbuf = 0; -+ sandbox_ffa_priv_data.pair.rxbuf = 0; -+ sandbox_ffa_priv_data.pair_info.rxtx_buf_size = 0; -+ sandbox_ffa_priv_data.pair_info.rxbuf_mapped = 0; -+ res->a0 = FFA_SMC_32(FFA_SUCCESS); -+ res->a2 = 0; -+ goto feedback; -+ } -+ -+ ffa_err("[Sandbox] No buffer pair registered on behalf of the caller"); -+ -+feedback: -+ -+ res->a1 = 0; -+ -+ /* x3-x7 MBZ */ -+ memset(FFA_X3_MBZ_REG_START, -+ 0, FFA_X3X7_MBZ_CNT * sizeof(unsigned long)); -+ -+ return 0; -+} -+ -+/** -+ * sandbox_ffa_rx_release - Emulated FFA_RX_RELEASE handler function -+ * @{a0-a7} , res: The SMC call arguments and return structure. -+ * -+ * This is the function that emulates FFA_RX_RELEASE FF-A function. -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+SANDBOX_SMC_FFA_ABI(ffa_rx_release) -+{ -+ if (!sandbox_ffa_priv_data.pair_info.rxbuf_owned) { -+ res->a0 = FFA_SMC_32(FFA_ERROR); -+ res->a2 = FFA_ERR_STAT_DENIED; -+ } else { -+ sandbox_ffa_priv_data.pair_info.rxbuf_owned = 0; -+ res->a0 = FFA_SMC_32(FFA_SUCCESS); -+ res->a2 = 0; -+ } -+ -+ res->a1 = 0; -+ -+ /* x3-x7 MBZ */ -+ memset(FFA_X3_MBZ_REG_START, -+ 0, FFA_X3X7_MBZ_CNT * sizeof(unsigned long)); -+ -+ return 0; -+} -+ -+/** -+ * sandbox_ffa_sp_valid - Checks SP validity -+ * @part_id: partition ID to check -+ * -+ * This is the function searches the input ID in the descriptors table. -+ * -+ * Return: -+ * -+ * 1 on success (Partition found). Otherwise, failure -+ */ -+static int sandbox_ffa_sp_valid(u16 part_id) -+{ -+ u32 descs_cnt; -+ -+ for (descs_cnt = 0 ; descs_cnt < SANDBOX_PARTITIONS_CNT ; descs_cnt++) -+ if (sandbox_ffa_priv_data.partitions.descs[descs_cnt].info.id == part_id) -+ return 1; -+ -+ return 0; -+} -+ -+/** -+ * sandbox_ffa_msg_send_direct_req - Emulated FFA_MSG_SEND_DIRECT_{REQ,RESP} handler function -+ * @{a0-a7} , res: The SMC call arguments and return structure. -+ * -+ * This is the function that emulates FFA_MSG_SEND_DIRECT_{REQ,RESP} -+ * FF-A functions. Only SMC 64-bit is supported in Sandbox. -+ * -+ * Emulating interrupts is not supported. So, FFA_RUN and FFA_INTERRUPT are not supported. -+ * In case of success FFA_MSG_SEND_DIRECT_RESP is returned with default pattern data (0xff). -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+SANDBOX_SMC_FFA_ABI(ffa_msg_send_direct_req) -+{ -+ u16 part_id; -+ -+ part_id = GET_DST_SP_ID(pargs->a1); -+ -+ if ((GET_NS_PHYS_ENDPOINT_ID(pargs->a1) != sandbox_ffa_priv_data.id) || -+ !sandbox_ffa_sp_valid(part_id) || -+ pargs->a2) { -+ res->a0 = FFA_SMC_32(FFA_ERROR); -+ res->a1 = 0; -+ res->a2 = FFA_ERR_STAT_INVALID_PARAMETERS; -+ -+ /* x3-x7 MBZ */ -+ memset(FFA_X3_MBZ_REG_START, -+ 0, FFA_X3X7_MBZ_CNT * sizeof(unsigned long)); -+ -+ return 0; -+ } -+ -+ res->a0 = FFA_SMC_64(FFA_MSG_SEND_DIRECT_RESP); -+ -+ res->a1 = PREP_SRC_SP_ID(part_id) | -+ PREP_NS_PHYS_ENDPOINT_ID(sandbox_ffa_priv_data.id); -+ -+ res->a2 = 0; -+ -+ /* -+ * return 0xff bytes as a response -+ */ -+ res->a3 = 0xffffffffffffffff; -+ res->a4 = 0xffffffffffffffff; -+ res->a5 = 0xffffffffffffffff; -+ res->a6 = 0xffffffffffffffff; -+ res->a7 = 0xffffffffffffffff; -+ -+ return 0; -+} -+ -+/** -+ * sandbox_ffa_get_prv_data - Returns the pointer to FF-A core pivate data -+ * @func_data: Pointer to the FF-A function arguments container structure -+ * -+ * This is the handler that returns the address of the FF-A core pivate data. -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+static int sandbox_ffa_get_prv_data(struct ffa_sandbox_data *func_data) -+{ -+ if (!func_data) -+ return -EINVAL; -+ -+ if (!func_data->data0 || func_data->data0_size != sizeof(struct ffa_prvdata *)) -+ return -EINVAL; -+ -+ if (!func_data->data1 || func_data->data1_size != sizeof(struct sandbox_ffa_prvdata *)) -+ return -EINVAL; -+ -+ *((struct ffa_prvdata **)func_data->data0) = ffa_bus_prvdata_get(); -+ *((struct sandbox_ffa_prvdata **)func_data->data1) = &sandbox_ffa_priv_data; -+ -+ return 0; -+} -+ -+/** -+ * sandbox_ffa_get_rxbuf_flags - Reading the mapping/ownership flags -+ * @queried_func_id: The FF-A function to be queried -+ * @func_data: Pointer to the FF-A function arguments container structure -+ * -+ * This is the handler that queries the status flags of the following emulated ABIs: -+ * FFA_RXTX_MAP, FFA_RXTX_UNMAP, FFA_RX_RELEASE -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+static int sandbox_ffa_get_rxbuf_flags(u32 queried_func_id, struct ffa_sandbox_data *func_data) -+{ -+ if (!func_data) -+ return -EINVAL; -+ -+ if (!func_data->data0 || func_data->data0_size != sizeof(u8)) -+ return -EINVAL; -+ -+ switch (queried_func_id) { -+ case FFA_RXTX_MAP: -+ case FFA_RXTX_UNMAP: -+ *((u8 *)func_data->data0) = sandbox_ffa_priv_data.pair_info.rxbuf_mapped; -+ return 0; -+ case FFA_RX_RELEASE: -+ *((u8 *)func_data->data0) = sandbox_ffa_priv_data.pair_info.rxbuf_owned; -+ return 0; -+ default: -+ ffa_err("[Sandbox] The querried FF-A interface flag (%d) undefined", -+ queried_func_id); -+ return -EINVAL; -+ } -+} -+ -+/** -+ * sandbox_ffa_query_core_state - The driver dispatcher function -+ * @queried_func_id: The FF-A function to be queried -+ * @func_data: Pointer to the FF-A function arguments container structure -+ * -+ * Queries the status of FF-A ABI specified in the input argument. -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+int sandbox_ffa_query_core_state(u32 queried_func_id, struct ffa_sandbox_data *func_data) -+{ -+ switch (queried_func_id) { -+ case FFA_VERSION: -+ case FFA_ID_GET: -+ case FFA_FEATURES: -+ return sandbox_ffa_get_prv_data(func_data); -+ case FFA_RXTX_MAP: -+ case FFA_RXTX_UNMAP: -+ case FFA_RX_RELEASE: -+ return sandbox_ffa_get_rxbuf_flags(queried_func_id, func_data); -+ default: -+ ffa_err("[Sandbox] The querried FF-A interface (%d) undefined", queried_func_id); -+ return -EINVAL; -+ } -+} -+ -+/** -+ * sandbox_arm_ffa_smccc_smc - FF-A SMC call emulation -+ * @args: the SMC call arguments -+ * @res: the SMC call returned data -+ * -+ * Sandbox driver emulates the FF-A ABIs SMC call using this function. -+ * The emulated FF-A ABI is identified and invoked. -+ * FF-A emulation is based on the FF-A specification 1.0 -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure. -+ * FF-A protocol error codes are returned using the registers arguments as described -+ * by the specification -+ */ -+void sandbox_arm_ffa_smccc_smc(ffa_value_t args, ffa_value_t *res) -+{ -+ int ret = 0; -+ -+ switch (args.a0) { -+ case FFA_SMC_32(FFA_VERSION): -+ ret = sandbox_ffa_version(&args, res); -+ break; -+ case FFA_SMC_32(FFA_PARTITION_INFO_GET): -+ ret = sandbox_ffa_partition_info_get(&args, res); -+ break; -+ case FFA_SMC_32(FFA_RXTX_UNMAP): -+ ret = sandbox_ffa_rxtx_unmap(&args, res); -+ break; -+ case FFA_SMC_64(FFA_MSG_SEND_DIRECT_REQ): -+ ret = sandbox_ffa_msg_send_direct_req(&args, res); -+ break; -+ case FFA_SMC_32(FFA_ID_GET): -+ ret = sandbox_ffa_id_get(&args, res); -+ break; -+ case FFA_SMC_32(FFA_FEATURES): -+ ret = sandbox_ffa_features(&args, res); -+ break; -+ case FFA_SMC_64(FFA_RXTX_MAP): -+ ret = sandbox_ffa_rxtx_map(&args, res); -+ break; -+ case FFA_SMC_32(FFA_RX_RELEASE): -+ ret = sandbox_ffa_rx_release(&args, res); -+ break; -+ default: -+ ffa_err("[Sandbox] Undefined FF-A interface (0x%lx)", args.a0); -+ } -+ -+ if (ret != 0) -+ ffa_err("[Sandbox] FF-A ABI internal failure (%d)", ret); -+} -+ -+/** -+ * sandbox_ffa_probe - The driver probe function -+ * @dev: the sandbox_arm_ffa device -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+static int sandbox_ffa_probe(struct udevice *dev) -+{ -+ return 0; -+} -+ -+/** -+ * sandbox_ffa_remove - The driver remove function -+ * @dev: the sandbox_arm_ffa device -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+static int sandbox_ffa_remove(struct udevice *dev) -+{ -+ ffa_info("[Sandbox] removing the device"); -+ memset(&sandbox_ffa_priv_data, 0, sizeof(sandbox_ffa_priv_data)); -+ return 0; -+} -+ -+/** -+ * Declaring the sandbox_arm_ffa driver under UCLASS_FFA -+ */ -+U_BOOT_DRIVER(sandbox_arm_ffa) = { -+ .name = FFA_SANDBOX_DRV_NAME, -+ .id = UCLASS_FFA, -+ .probe = sandbox_ffa_probe, -+ .remove = sandbox_ffa_remove, -+}; -diff --git a/drivers/firmware/arm-ffa/sandbox_arm_ffa_prv.h b/drivers/firmware/arm-ffa/sandbox_arm_ffa_prv.h -new file mode 100644 -index 0000000000..4db57f5092 ---- /dev/null -+++ b/drivers/firmware/arm-ffa/sandbox_arm_ffa_prv.h -@@ -0,0 +1,144 @@ -+/* SPDX-License-Identifier: GPL-2.0+ */ -+/* -+ * (C) Copyright 2022 ARM Limited -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -+ */ -+ -+#ifndef __SANDBOX_ARM_FFA_PRV_H -+#define __SANDBOX_ARM_FFA_PRV_H -+ -+#include "arm_ffa_prv.h" -+#include <sandbox_arm_ffa.h> -+ -+/* -+ * This header is private. It is exclusively used by the Sandbox FF-A driver -+ */ -+ -+/* FF-A core driver name */ -+#define FFA_SANDBOX_DRV_NAME "sandbox_arm_ffa" -+ -+/* FF-A ABIs internal error codes (as defined by the spec) */ -+ -+#define FFA_ERR_STAT_NOT_SUPPORTED -1 -+#define FFA_ERR_STAT_INVALID_PARAMETERS -2 -+#define FFA_ERR_STAT_NO_MEMORY -3 -+#define FFA_ERR_STAT_BUSY -4 -+#define FFA_ERR_STAT_DENIED -6 -+ -+/* Providing Arm SMCCC declarations to sandbox */ -+ -+#define ARM_SMCCC_FAST_CALL 1UL -+#define ARM_SMCCC_OWNER_STANDARD 4 -+#define ARM_SMCCC_SMC_32 0 -+#define ARM_SMCCC_SMC_64 1 -+#define ARM_SMCCC_TYPE_SHIFT 31 -+#define ARM_SMCCC_CALL_CONV_SHIFT 30 -+#define ARM_SMCCC_OWNER_MASK 0x3F -+#define ARM_SMCCC_OWNER_SHIFT 24 -+#define ARM_SMCCC_FUNC_MASK 0xFFFF -+ -+#define ARM_SMCCC_CALL_VAL(type, calling_convention, owner, func_num) \ -+ (((type) << ARM_SMCCC_TYPE_SHIFT) | \ -+ ((calling_convention) << ARM_SMCCC_CALL_CONV_SHIFT) | \ -+ (((owner) & ARM_SMCCC_OWNER_MASK) << ARM_SMCCC_OWNER_SHIFT) | \ -+ ((func_num) & ARM_SMCCC_FUNC_MASK)) -+ -+/* Non-secure physical FF-A instance */ -+#define NS_PHYS_ENDPOINT_ID (0) -+ -+#define GET_NS_PHYS_ENDPOINT_ID_MASK GENMASK(31, 16) -+#define GET_NS_PHYS_ENDPOINT_ID(x) \ -+ ((u16)(FIELD_GET(GET_NS_PHYS_ENDPOINT_ID_MASK, (x)))) -+ -+/* Helper macro for reading the destination partition ID */ -+#define GET_DST_SP_ID_MASK GENMASK(15, 0) -+#define GET_DST_SP_ID(x) \ -+ ((u16)(FIELD_GET(GET_DST_SP_ID_MASK, (x)))) -+ -+/* Helper macro for setting the source partition ID */ -+#define PREP_SRC_SP_ID_MASK GENMASK(31, 16) -+#define PREP_SRC_SP_ID(x) \ -+ (FIELD_PREP(PREP_SRC_SP_ID_MASK, (x))) -+ -+/* Helper macro for setting the destination endpoint ID */ -+#define PREP_NS_PHYS_ENDPOINT_ID_MASK GENMASK(15, 0) -+#define PREP_NS_PHYS_ENDPOINT_ID(x) \ -+ (FIELD_PREP(PREP_NS_PHYS_ENDPOINT_ID_MASK, (x))) -+ -+/* RX/TX buffers minimum size */ -+#define RXTX_BUFFERS_MIN_SIZE (RXTX_4K) -+#define RXTX_BUFFERS_MIN_PAGES (1) -+ -+/* MBZ registers info */ -+ -+/* x1-x7 MBZ */ -+#define FFA_X1X7_MBZ_CNT (7) -+#define FFA_X1X7_MBZ_REG_START (&res->a1) -+ -+/* x4-x7 MBZ */ -+#define FFA_X4X7_MBZ_CNT (4) -+#define FFA_X4X7_MBZ_REG_START (&res->a4) -+ -+/* x3-x7 MBZ */ -+#define FFA_X3X7_MBZ_CNT (5) -+#define FFA_X3_MBZ_REG_START (&res->a3) -+ -+/* secure partitions count */ -+#define SANDBOX_PARTITIONS_CNT (4) -+ -+/* service 1 UUID binary data (little-endian format) */ -+#define SANDBOX_SERVICE1_UUID_A1 0xed32d533 -+#define SANDBOX_SERVICE1_UUID_A2 0x99e64209 -+#define SANDBOX_SERVICE1_UUID_A3 0x9cc02d72 -+#define SANDBOX_SERVICE1_UUID_A4 0xcdd998a7 -+ -+/* service 2 UUID binary data (little-endian format) */ -+#define SANDBOX_SERVICE2_UUID_A1 0xed32d544 -+#define SANDBOX_SERVICE2_UUID_A2 0x99e64209 -+#define SANDBOX_SERVICE2_UUID_A3 0x9cc02d72 -+#define SANDBOX_SERVICE2_UUID_A4 0xcdd998a7 -+ -+/** -+ * struct ffa_rxtxpair_info - structure hosting the RX/TX buffers flags -+ * @rxbuf_owned: RX buffer ownership flag (the owner is non secure world: the consumer) -+ * @rxbuf_mapped: RX buffer mapping flag -+ * @txbuf_owned TX buffer ownership flag -+ * @txbuf_mapped: TX buffer mapping flag -+ * @rxtx_buf_size: RX/TX buffers size as set by the FF-A core driver -+ * -+ * Data structure hosting the ownership/mapping flags of the RX/TX buffers -+ * When a buffer is owned/mapped its corresponding flag is set to 1 otherwise 0. -+ */ -+struct ffa_rxtxpair_info { -+ u8 rxbuf_owned; -+ u8 rxbuf_mapped; -+ u8 txbuf_owned; -+ u8 txbuf_mapped; -+ u32 rxtx_buf_size; -+}; -+ -+/** -+ * struct sandbox_ffa_prvdata - the driver private data structure -+ * -+ * @dev: The arm_ffa device under u-boot driver model -+ * @fwk_version: FF-A framework version -+ * @id: u-boot endpoint ID -+ * @partitions: The partitions descriptors structure -+ * @pair: The RX/TX buffers pair -+ * @pair_info: The RX/TX buffers pair flags and size -+ * @conduit: The selected conduit -+ * -+ * The driver data structure hosting all the emulated secure world data. -+ */ -+struct sandbox_ffa_prvdata { -+ struct udevice *dev; -+ u32 fwk_version; -+ u16 id; -+ struct ffa_partitions partitions; -+ struct ffa_rxtxpair pair; -+ struct ffa_rxtxpair_info pair_info; -+}; -+ -+#define SANDBOX_SMC_FFA_ABI(ffabi) static int sandbox_##ffabi(ffa_value_t *pargs, ffa_value_t *res) -+ -+#endif -diff --git a/include/arm_ffa.h b/include/arm_ffa.h -index 74b16174c2..b88904fe50 100644 ---- a/include/arm_ffa.h -+++ b/include/arm_ffa.h -@@ -90,7 +90,7 @@ struct ffa_bus_ops { - const struct ffa_bus_ops *ffa_bus_ops_get(void); - - /** -- * ffa_bus_discover - discover FF-A bus and probes the arm_ffa device -+ * ffa_bus_discover - discover FF-A bus and probes the arm_ffa and sandbox_arm_ffa devices - */ - int ffa_bus_discover(struct udevice **pdev); - -diff --git a/include/sandbox_arm_ffa.h b/include/sandbox_arm_ffa.h -new file mode 100644 -index 0000000000..d5df16f282 ---- /dev/null -+++ b/include/sandbox_arm_ffa.h -@@ -0,0 +1,91 @@ -+/* SPDX-License-Identifier: GPL-2.0+ */ -+/* -+ * (C) Copyright 2022 ARM Limited -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -+ */ -+ -+#ifndef __SANDBOX_ARM_FFA_H -+#define __SANDBOX_ARM_FFA_H -+ -+#include <arm_ffa.h> -+ -+/** -+ * struct sandbox_smccc_1_2_regs - Arguments for or Results from emulated SMC call -+ * @a0-a17 argument values from registers 0 to 17 -+ */ -+struct sandbox_smccc_1_2_regs { -+ unsigned long a0; -+ unsigned long a1; -+ unsigned long a2; -+ unsigned long a3; -+ unsigned long a4; -+ unsigned long a5; -+ unsigned long a6; -+ unsigned long a7; -+ unsigned long a8; -+ unsigned long a9; -+ unsigned long a10; -+ unsigned long a11; -+ unsigned long a12; -+ unsigned long a13; -+ unsigned long a14; -+ unsigned long a15; -+ unsigned long a16; -+ unsigned long a17; -+}; -+ -+typedef struct sandbox_smccc_1_2_regs ffa_value_t; -+ -+/* UUIDs of services supported by the sandbox driver */ -+#define SANDBOX_SERVICE1_UUID "ed32d533-4209-99e6-2d72-cdd998a79cc0" -+#define SANDBOX_SERVICE2_UUID "ed32d544-4209-99e6-2d72-cdd998a79cc0" -+#define SANDBOX_SP1_ID 0x1245 -+#define SANDBOX_SP2_ID 0x9836 -+#define SANDBOX_SP3_ID 0x6452 -+#define SANDBOX_SP4_ID 0x7814 -+ -+/* invalid service UUID (no matching SP) */ -+#define SANDBOX_SERVICE3_UUID "55d532ed-0942-e699-722d-c09ca798d9cd" -+ -+/* invalid service UUID (invalid UUID string format) */ -+#define SANDBOX_SERVICE4_UUID "32ed-0942-e699-722d-c09ca798d9cd" -+ -+#define SANDBOX_SP_COUNT_PER_VALID_SERVICE 2 -+ -+/** -+ * struct ffa_sandbox_data - generic data structure used to exchange -+ * data between test cases and the sandbox driver -+ * @data0_size: size of the first argument -+ * @data0: pointer to the first argument -+ * @data1_size>: size of the second argument -+ * @data1: pointer to the second argument -+ * -+ * Using this structure sandbox test cases can pass various types of data with different sizes. -+ */ -+struct ffa_sandbox_data { -+ u32 data0_size; /* size of the first argument */ -+ void *data0; /* pointer to the first argument */ -+ u32 data1_size; /* size of the second argument */ -+ void *data1; /* pointer to the second argument */ -+}; -+ -+/** -+ * The sandbox driver public functions -+ */ -+ -+/** -+ * sandbox_ffa_query_core_state - Queries the status of FF-A ABIs -+ */ -+int sandbox_ffa_query_core_state(u32 queried_func_id, struct ffa_sandbox_data *func_data); -+ -+/** -+ * sandbox_ffa_get_device - create, bind and probe the sandbox_arm_ffa device -+ */ -+int sandbox_ffa_device_get(void); -+ -+/** -+ * sandbox_arm_ffa_smccc_smc - FF-A SMC call emulation -+ */ -+void sandbox_arm_ffa_smccc_smc(ffa_value_t args, ffa_value_t *res); -+ -+#endif -diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c -index 3481f2afe7..fea4eb7a34 100644 ---- a/lib/efi_loader/efi_boottime.c -+++ b/lib/efi_loader/efi_boottime.c -@@ -2185,7 +2185,7 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle, - dm_remove_devices_flags(DM_REMOVE_ACTIVE_ALL); - } - --#if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT) -+#if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT) && !CONFIG_IS_ENABLED(SANDBOX_FFA) - /* unmap FF-A RX/TX buffers */ - if (ffa_bus_ops_get()->rxtx_unmap(NULL)) - log_err("Can't unmap FF-A RX/TX buffers\n"); --- -2.25.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0007-FF-A-v15-arm_ffa-introduce-sandbox-test-cases-for-UC.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0007-FF-A-v15-arm_ffa-introduce-sandbox-test-cases-for-UC.patch new file mode 100644 index 0000000000..966c32bdec --- /dev/null +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0007-FF-A-v15-arm_ffa-introduce-sandbox-test-cases-for-UC.patch @@ -0,0 +1,341 @@ +From 00d0d8edf47430e3069e7c1dfa7a5bb7bb36bd49 Mon Sep 17 00:00:00 2001 +From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> +Date: Wed, 10 May 2023 17:34:55 +0100 +Subject: [PATCH 07/33] FF-A v15: arm_ffa: introduce sandbox test cases for + UCLASS_FFA + +Add functional test cases for the FF-A support + +These tests rely on the FF-A sandbox emulator and FF-A +sandbox driver which help in inspecting the FF-A communication. + +Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> +Reviewed-by: Simon Glass <sjg@chromium.org> +Cc: Tom Rini <trini@konsulko.com> +Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> +Cc: Jens Wiklander <jens.wiklander@linaro.org> +Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> +Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20230713132847.176000-1-abdellatif.elkhlifi@arm.com/] +--- + MAINTAINERS | 1 + + doc/arch/arm64.ffa.rst | 1 + + test/dm/Makefile | 3 +- + test/dm/ffa.c | 261 +++++++++++++++++++++++++++++++++++++++++ + 4 files changed, 265 insertions(+), 1 deletion(-) + create mode 100644 test/dm/ffa.c + +diff --git a/MAINTAINERS b/MAINTAINERS +index 679a3acdd8..ccd7859c88 100644 +--- a/MAINTAINERS ++++ b/MAINTAINERS +@@ -276,6 +276,7 @@ F: doc/arch/arm64.ffa.rst + F: doc/usage/cmd/armffa.rst + F: drivers/firmware/arm-ffa/ + F: include/arm_ffa.h ++F: test/dm/ffa.c + + ARM FREESCALE IMX + M: Stefano Babic <sbabic@denx.de> +diff --git a/doc/arch/arm64.ffa.rst b/doc/arch/arm64.ffa.rst +index b7c754fa3d..325fb80346 100644 +--- a/doc/arch/arm64.ffa.rst ++++ b/doc/arch/arm64.ffa.rst +@@ -37,6 +37,7 @@ The U-Boot FF-A support provides the following parts: + FF-A ABIs inspection methods. + - An FF-A sandbox device driver for FF-A communication with the emulated Secure World. + The driver leverages the FF-A Uclass to establish FF-A communication. ++- Sandbox FF-A test cases. + + FF-A and SMC specifications + ------------------------------------------- +diff --git a/test/dm/Makefile b/test/dm/Makefile +index 3799b1ae8f..7ed00733c1 100644 +--- a/test/dm/Makefile ++++ b/test/dm/Makefile +@@ -1,7 +1,7 @@ + # SPDX-License-Identifier: GPL-2.0+ + # + # Copyright (c) 2013 Google, Inc +-# Copyright 2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++# Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> + + obj-$(CONFIG_UT_DM) += test-dm.o + +@@ -92,6 +92,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..6912666bb4 +--- /dev/null ++++ b/test/dm/ffa.c +@@ -0,0 +1,261 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++/* ++ * Functional tests for UCLASS_FFA class ++ * ++ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++ * ++ * Authors: ++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++ */ ++ ++#include <common.h> ++#include <console.h> ++#include <dm.h> ++#include <asm/sandbox_arm_ffa.h> ++#include <asm/sandbox_arm_ffa_priv.h> ++#include <dm/test.h> ++#include <test/test.h> ++#include <test/ut.h> ++ ++/* Functional tests for the UCLASS_FFA */ ++ ++static int check_fwk_version(struct ffa_priv *uc_priv, struct unit_test_state *uts) ++{ ++ struct ffa_sandbox_data func_data; ++ u32 fwk_version = 0; ++ ++ func_data.data0 = &fwk_version; ++ func_data.data0_size = sizeof(fwk_version); ++ ut_assertok(sandbox_query_ffa_emul_state(FFA_VERSION, &func_data)); ++ ut_asserteq(uc_priv->fwk_version, fwk_version); ++ ++ return 0; ++} ++ ++static int check_endpoint_id(struct ffa_priv *uc_priv, struct unit_test_state *uts) ++{ ++ ut_asserteq(0, uc_priv->id); ++ ++ return 0; ++} ++ ++static int check_rxtxbuf(struct ffa_priv *uc_priv, struct unit_test_state *uts) ++{ ++ ut_assertnonnull(uc_priv->pair.rxbuf); ++ ut_assertnonnull(uc_priv->pair.txbuf); ++ ++ return 0; ++} ++ ++static int check_features(struct ffa_priv *uc_priv, struct unit_test_state *uts) ++{ ++ ut_assert(uc_priv->pair.rxtx_min_pages == RXTX_4K || ++ uc_priv->pair.rxtx_min_pages == RXTX_16K || ++ uc_priv->pair.rxtx_min_pages == RXTX_64K); ++ ++ return 0; ++} ++ ++static int check_rxbuf_mapped_flag(u32 queried_func_id, ++ u8 rxbuf_mapped, ++ struct unit_test_state *uts) ++{ ++ switch (queried_func_id) { ++ case FFA_RXTX_MAP: ++ ut_asserteq(1, rxbuf_mapped); ++ break; ++ case FFA_RXTX_UNMAP: ++ ut_asserteq(0, rxbuf_mapped); ++ break; ++ default: ++ ut_assert(false); ++ } ++ ++ return 0; ++} ++ ++static int check_rxbuf_release_flag(u8 rxbuf_owned, struct unit_test_state *uts) ++{ ++ ut_asserteq(0, rxbuf_owned); ++ ++ return 0; ++} ++ ++static int test_ffa_msg_send_direct_req(u16 part_id, struct unit_test_state *uts) ++{ ++ struct ffa_send_direct_data msg; ++ u8 cnt; ++ struct udevice *dev; ++ ++ ut_assertok(uclass_first_device_err(UCLASS_FFA, &dev)); ++ ++ ut_assertok(ffa_sync_send_receive(dev, part_id, &msg, 1)); ++ ++ for (cnt = 0; cnt < sizeof(struct ffa_send_direct_data) / sizeof(u64); cnt++) ++ ut_asserteq_64(-1UL, ((u64 *)&msg)[cnt]); ++ ++ return 0; ++} ++ ++static int test_partitions_and_comms(const char *service_uuid, ++ struct unit_test_state *uts) ++{ ++ struct ffa_partition_desc *descs; ++ u32 count, i, j, valid_sps = 0; ++ struct udevice *dev; ++ struct ffa_sandbox_data func_data; ++ struct ffa_partitions *partitions; ++ ++ ut_assertok(uclass_first_device_err(UCLASS_FFA, &dev)); ++ ++ /* Get from the driver the count and information of the SPs matching the UUID */ ++ ut_assertok(ffa_partition_info_get(dev, service_uuid, &count, &descs)); ++ ++ /* Make sure the count is correct */ ++ ut_asserteq(SANDBOX_SP_COUNT_PER_VALID_SERVICE, count); ++ ++ /* SPs found , verify the partitions information */ ++ ++ func_data.data0 = &partitions; ++ func_data.data0_size = sizeof(struct ffa_partitions *); ++ ut_assertok(sandbox_query_ffa_emul_state(FFA_PARTITION_INFO_GET, &func_data)); ++ ++ for (i = 0; i < count ; i++) { ++ for (j = 0; ++ j < partitions->count; ++ j++) { ++ if (descs[i].info.id == ++ partitions->descs[j].info.id) { ++ valid_sps++; ++ ut_asserteq_mem(&descs[i], ++ &partitions->descs[j], ++ sizeof(struct ffa_partition_desc)); ++ /* Send and receive data from the current partition */ ++ test_ffa_msg_send_direct_req(descs[i].info.id, uts); ++ } ++ } ++ } ++ ++ /* Verify expected partitions found in the emulated secure world */ ++ ut_asserteq(SANDBOX_SP_COUNT_PER_VALID_SERVICE, valid_sps); ++ ++ return 0; ++} ++ ++static int dm_test_ffa_ack(struct unit_test_state *uts) ++{ ++ struct ffa_priv *uc_priv; ++ struct ffa_sandbox_data func_data; ++ u8 rxbuf_flag = 0; ++ const char *svc1_uuid = SANDBOX_SERVICE1_UUID; ++ const char *svc2_uuid = SANDBOX_SERVICE2_UUID; ++ struct udevice *dev; ++ ++ /* Test probing the sandbox FF-A bus */ ++ ut_assertok(uclass_first_device_err(UCLASS_FFA, &dev)); ++ ++ /* Get a pointer to the sandbox FF-A bus private data */ ++ uc_priv = dev_get_uclass_priv(dev); ++ ++ /* Make sure the private data pointer is retrieved */ ++ ut_assertnonnull(uc_priv); ++ ++ /* Test FFA_VERSION */ ++ check_fwk_version(uc_priv, uts); ++ ++ /* Test FFA_ID_GET */ ++ check_endpoint_id(uc_priv, uts); ++ ++ /* Test FFA_FEATURES */ ++ check_features(uc_priv, uts); ++ ++ /* Test RX/TX buffers */ ++ check_rxtxbuf(uc_priv, uts); ++ ++ /* Test FFA_RXTX_MAP */ ++ func_data.data0 = &rxbuf_flag; ++ func_data.data0_size = sizeof(rxbuf_flag); ++ ++ rxbuf_flag = 0; ++ sandbox_query_ffa_emul_state(FFA_RXTX_MAP, &func_data); ++ check_rxbuf_mapped_flag(FFA_RXTX_MAP, rxbuf_flag, uts); ++ ++ /* FFA_PARTITION_INFO_GET / FFA_MSG_SEND_DIRECT_REQ */ ++ test_partitions_and_comms(svc1_uuid, uts); ++ ++ /* Test FFA_RX_RELEASE */ ++ rxbuf_flag = 1; ++ sandbox_query_ffa_emul_state(FFA_RX_RELEASE, &func_data); ++ check_rxbuf_release_flag(rxbuf_flag, uts); ++ ++ /* FFA_PARTITION_INFO_GET / FFA_MSG_SEND_DIRECT_REQ */ ++ test_partitions_and_comms(svc2_uuid, uts); ++ ++ /* Test FFA_RX_RELEASE */ ++ rxbuf_flag = 1; ++ ut_assertok(sandbox_query_ffa_emul_state(FFA_RX_RELEASE, &func_data)); ++ check_rxbuf_release_flag(rxbuf_flag, uts); ++ ++ return 0; ++} ++ ++DM_TEST(dm_test_ffa_ack, UT_TESTF_SCAN_FDT | UT_TESTF_CONSOLE_REC); ++ ++static int dm_test_ffa_nack(struct unit_test_state *uts) ++{ ++ struct ffa_priv *uc_priv; ++ const char *valid_svc_uuid = SANDBOX_SERVICE1_UUID; ++ const char *unvalid_svc_uuid = SANDBOX_SERVICE3_UUID; ++ const char *unvalid_svc_uuid_str = SANDBOX_SERVICE4_UUID; ++ struct ffa_send_direct_data msg; ++ int ret; ++ u32 count; ++ u16 part_id = 0; ++ struct udevice *dev; ++ struct ffa_partition_desc *descs = NULL; ++ ++ /* Test probing the sandbox FF-A bus */ ++ ut_assertok(uclass_first_device_err(UCLASS_FFA, &dev)); ++ ++ /* Get a pointer to the sandbox FF-A bus private data */ ++ uc_priv = dev_get_uclass_priv(dev); ++ ++ /* Make sure the private data pointer is retrieved */ ++ ut_assertnonnull(uc_priv); ++ ++ /* Query partitions count using invalid arguments */ ++ ret = ffa_partition_info_get(dev, NULL, NULL, NULL); ++ ut_asserteq(-EINVAL, ret); ++ ret = ffa_partition_info_get(dev, unvalid_svc_uuid, NULL, NULL); ++ ut_asserteq(-EINVAL, ret); ++ ret = ffa_partition_info_get(dev, unvalid_svc_uuid, &count, NULL); ++ ut_asserteq(-EINVAL, ret); ++ ++ /* Query partitions count using an invalid UUID string */ ++ ret = ffa_partition_info_get(dev, unvalid_svc_uuid_str, &count, &descs); ++ ut_asserteq(-EINVAL, ret); ++ ++ /* Query partitions count using an invalid UUID (no matching SP) */ ++ count = 0; ++ ret = ffa_partition_info_get(dev, unvalid_svc_uuid, &count, &descs); ++ ut_asserteq(0, count); ++ ++ /* Query partitions data using a valid UUID */ ++ count = 0; ++ ut_assertok(ffa_partition_info_get(dev, valid_svc_uuid, &count, &descs)); ++ /* Make sure partitions are detected */ ++ ut_asserteq(SANDBOX_SP_COUNT_PER_VALID_SERVICE, count); ++ ut_assertnonnull(descs); ++ ++ /* Send data to an invalid partition */ ++ ret = ffa_sync_send_receive(dev, part_id, &msg, 1); ++ ut_asserteq(-EINVAL, ret); ++ ++ /* Send data to a valid partition */ ++ part_id = uc_priv->partitions.descs[0].info.id; ++ ut_assertok(ffa_sync_send_receive(dev, part_id, &msg, 1)); ++ ++ return 0; ++} ++ ++DM_TEST(dm_test_ffa_nack, UT_TESTF_SCAN_FDT | UT_TESTF_CONSOLE_REC); +-- +2.25.1 + diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0007-arm_ffa-introduce-Sandbox-test-cases-for-UCLASS_FFA.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0007-arm_ffa-introduce-Sandbox-test-cases-for-UCLASS_FFA.patch deleted file mode 100644 index d248e8b0d9..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0007-arm_ffa-introduce-Sandbox-test-cases-for-UCLASS_FFA.patch +++ /dev/null @@ -1,472 +0,0 @@ -From 3664fe7503cbc4348bbd7bcb8fbf7e1db332ac5d Mon Sep 17 00:00:00 2001 -From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Date: Mon, 6 Jun 2022 17:26:06 +0100 -Subject: [PATCH 07/42] arm_ffa: introduce Sandbox test cases for UCLASS_FFA - -Add functional test cases for the FF-A core driver - -These tests rely on the FF-A Sandbox driver which helps in - inspecting the FF-A core driver. - -Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Cc: Tom Rini <trini@konsulko.com> -Cc: Simon Glass <sjg@chromium.org> -Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> -Cc: Jens Wiklander <jens.wiklander@linaro.org> -Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/] - -Changelog: -=============== - -v8: - - * update partition_info_get() second argument to be an SP count - * pass NULL device pointer to the FF-A bus discovery and operations - -v7: set the tests to use 64-bit direct messaging - -v4: align sandbox tests with the new FF-A driver interfaces - and new way of error handling - -v1: introduce sandbox tests -Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> ---- - MAINTAINERS | 1 + - test/dm/Makefile | 2 + - test/dm/ffa.c | 392 +++++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 395 insertions(+) - create mode 100644 test/dm/ffa.c - -diff --git a/MAINTAINERS b/MAINTAINERS -index 297d165f84..c1d3d4ae1c 100644 ---- a/MAINTAINERS -+++ b/MAINTAINERS -@@ -272,6 +272,7 @@ F: doc/arch/arm64.ffa.rst - F: drivers/firmware/arm-ffa/ - F: include/arm_ffa.h - F: include/sandbox_arm_ffa.h -+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 7a79b6e1a2..85e99e1c12 100644 ---- a/test/dm/Makefile -+++ b/test/dm/Makefile -@@ -1,6 +1,7 @@ - # SPDX-License-Identifier: GPL-2.0+ - # - # Copyright (c) 2013 Google, Inc -+# (C) Copyright 2022 ARM Limited - - obj-$(CONFIG_UT_DM) += test-dm.o - -@@ -85,6 +86,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_SANDBOX_FFA) += 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..128d8626a7 ---- /dev/null -+++ b/test/dm/ffa.c -@@ -0,0 +1,392 @@ -+// SPDX-License-Identifier: GPL-2.0+ -+/* -+ * Functional tests for UCLASS_FFA class -+ * -+ * (C) Copyright 2022 ARM Limited -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -+ */ -+ -+#include <common.h> -+#include <console.h> -+#include <dm.h> -+#include <dm/test.h> -+#include "../../drivers/firmware/arm-ffa/sandbox_arm_ffa_prv.h" -+#include <sandbox_arm_ffa.h> -+#include <test/test.h> -+#include <test/ut.h> -+ -+/* Macros */ -+ -+#define LOG_MSG_SZ (100) -+#define LOG_CMD_SZ (LOG_MSG_SZ * 2) -+ -+/* Functional tests for the UCLASS_FFA */ -+ -+static int dm_test_ffa_log(struct unit_test_state *uts, char *msg) -+{ -+ char cmd[LOG_CMD_SZ] = {0}; -+ -+ console_record_reset(); -+ -+ snprintf(cmd, LOG_CMD_SZ, "echo \"%s\"", msg); -+ run_command(cmd, 0); -+ -+ ut_assert_console_end(); -+ -+ return CMD_RET_SUCCESS; -+} -+ -+static int check_fwk_version(struct ffa_prvdata *prvdata, struct sandbox_ffa_prvdata *sdx_prvdata, -+ struct unit_test_state *uts) -+{ -+ if (prvdata->fwk_version != sdx_prvdata->fwk_version) { -+ char msg[LOG_MSG_SZ] = {0}; -+ -+ snprintf(msg, LOG_MSG_SZ, -+ "[%s]: Error: framework version: core = 0x%x , sandbox = 0x%x", __func__, -+ prvdata->fwk_version, -+ sdx_prvdata->fwk_version); -+ -+ dm_test_ffa_log(uts, msg); -+ return CMD_RET_FAILURE; -+ } -+ return CMD_RET_SUCCESS; -+} -+ -+static int check_endpoint_id(struct ffa_prvdata *prvdata, struct unit_test_state *uts) -+{ -+ if (prvdata->id) { -+ char msg[LOG_MSG_SZ] = {0}; -+ -+ snprintf(msg, LOG_MSG_SZ, -+ "[%s]: Error: endpoint id: core = 0x%x", __func__, prvdata->id); -+ dm_test_ffa_log(uts, msg); -+ return CMD_RET_FAILURE; -+ } -+ return CMD_RET_SUCCESS; -+} -+ -+static int check_core_dev(struct ffa_prvdata *prvdata, struct unit_test_state *uts) -+{ -+ if (!prvdata->dev) { -+ char msg[LOG_MSG_SZ] = {0}; -+ -+ snprintf(msg, LOG_MSG_SZ, "[%s]: Error: core device NULL", __func__); -+ dm_test_ffa_log(uts, msg); -+ return CMD_RET_FAILURE; -+ } -+ return CMD_RET_SUCCESS; -+} -+ -+static int check_sandbox_dev(struct sandbox_ffa_prvdata *sdx_prvdata, struct unit_test_state *uts) -+{ -+ if (!sdx_prvdata->dev) { -+ char msg[LOG_MSG_SZ] = {0}; -+ -+ snprintf(msg, LOG_MSG_SZ, "[%s]: Error: sandbox device NULL", __func__); -+ dm_test_ffa_log(uts, msg); -+ return CMD_RET_FAILURE; -+ } -+ return CMD_RET_SUCCESS; -+} -+ -+static int check_rxtxbuf(struct ffa_prvdata *prvdata, struct unit_test_state *uts) -+{ -+ if (!prvdata->pair.rxbuf && prvdata->pair.txbuf) { -+ char msg[LOG_MSG_SZ] = {0}; -+ -+ snprintf(msg, LOG_MSG_SZ, "[%s]: Error: rxbuf = 0x%llx txbuf = 0x%llx", __func__, -+ prvdata->pair.rxbuf, -+ prvdata->pair.txbuf); -+ dm_test_ffa_log(uts, msg); -+ return CMD_RET_FAILURE; -+ } -+ return CMD_RET_SUCCESS; -+} -+ -+static int check_features(struct ffa_prvdata *prvdata, struct unit_test_state *uts) -+{ -+ char msg[LOG_MSG_SZ] = {0}; -+ -+ if (prvdata->pair.rxtx_min_pages != RXTX_4K && -+ prvdata->pair.rxtx_min_pages != RXTX_16K && -+ prvdata->pair.rxtx_min_pages != RXTX_64K) { -+ snprintf(msg, -+ LOG_MSG_SZ, -+ "[%s]: Error: FFA_RXTX_MAP features = 0x%lx", -+ __func__, -+ prvdata->pair.rxtx_min_pages); -+ dm_test_ffa_log(uts, msg); -+ return CMD_RET_FAILURE; -+ } -+ -+ return CMD_RET_SUCCESS; -+} -+ -+static int check_rxbuf_mapped_flag(u32 queried_func_id, -+ u8 rxbuf_mapped, -+ struct unit_test_state *uts) -+{ -+ char msg[LOG_MSG_SZ] = {0}; -+ -+ switch (queried_func_id) { -+ case FFA_RXTX_MAP: -+ { -+ if (rxbuf_mapped) -+ return CMD_RET_SUCCESS; -+ break; -+ } -+ case FFA_RXTX_UNMAP: -+ { -+ if (!rxbuf_mapped) -+ return CMD_RET_SUCCESS; -+ break; -+ } -+ default: -+ return CMD_RET_FAILURE; -+ } -+ -+ snprintf(msg, LOG_MSG_SZ, "[%s]: Error: %s mapping issue", __func__, -+ (queried_func_id == FFA_RXTX_MAP ? "FFA_RXTX_MAP" : "FFA_RXTX_UNMAP")); -+ dm_test_ffa_log(uts, msg); -+ -+ return CMD_RET_FAILURE; -+} -+ -+static int check_rxbuf_release_flag(u8 rxbuf_owned, struct unit_test_state *uts) -+{ -+ if (rxbuf_owned) { -+ char msg[LOG_MSG_SZ] = {0}; -+ -+ snprintf(msg, LOG_MSG_SZ, "[%s]: Error: RX buffer not released", __func__); -+ dm_test_ffa_log(uts, msg); -+ return CMD_RET_FAILURE; -+ } -+ return CMD_RET_SUCCESS; -+} -+ -+static int test_ffa_msg_send_direct_req(u16 part_id, struct unit_test_state *uts) -+{ -+ struct ffa_send_direct_data msg = {0}; -+ u8 cnt; -+ -+ ut_assertok(ffa_bus_ops_get()->sync_send_receive(NULL, part_id, &msg, 1)); -+ -+ for (cnt = 0; cnt < sizeof(struct ffa_send_direct_data) / sizeof(u64); cnt++) -+ ut_assertok(((u64 *)&msg)[cnt] != 0xffffffffffffffff); -+ -+ return CMD_RET_SUCCESS; -+} -+ -+static int test_partitions_and_comms(const char *service_uuid, -+ struct sandbox_ffa_prvdata *sdx_prvdata, -+ struct unit_test_state *uts) -+{ -+ u32 count = 0; -+ struct ffa_partition_info *parts_info; -+ u32 info_idx, exp_info_idx; -+ int ret; -+ -+ /* -+ * get from the driver the count of the SPs matching the UUID -+ */ -+ ret = ffa_bus_ops_get()->partition_info_get(NULL, service_uuid, &count, NULL); -+ /* make sure partitions are detected */ -+ ut_assertok(ret != 0); -+ ut_assertok(count != SANDBOX_SP_COUNT_PER_VALID_SERVICE); -+ -+ /* -+ * pre-allocate a buffer to be filled by the driver -+ * with ffa_partition_info structs -+ */ -+ -+ parts_info = calloc(count, sizeof(struct ffa_partition_info)); -+ ut_assertok(!parts_info); -+ -+ /* -+ * ask the driver to fill the buffer with the SPs info -+ */ -+ ret = ffa_bus_ops_get()->partition_info_get(NULL, service_uuid, &count, parts_info); -+ if (ret != 0) { -+ free(parts_info); -+ ut_assertok(ret != 0); -+ } -+ -+ /* -+ * SPs found , verify the partitions information -+ */ -+ -+ ret = CMD_RET_FAILURE; -+ -+ for (info_idx = 0; info_idx < count ; info_idx++) { -+ for (exp_info_idx = 0; -+ exp_info_idx < sdx_prvdata->partitions.count; -+ exp_info_idx++) { -+ if (parts_info[info_idx].id == -+ sdx_prvdata->partitions.descs[exp_info_idx].info.id) { -+ ret = memcmp(&parts_info[info_idx], -+ &sdx_prvdata->partitions.descs[exp_info_idx] -+ .info, -+ sizeof(struct ffa_partition_info)); -+ if (ret) -+ free(parts_info); -+ ut_assertok(ret != 0); -+ /* send and receive data from the current partition */ -+ test_ffa_msg_send_direct_req(parts_info[info_idx].id, uts); -+ } -+ ret = CMD_RET_SUCCESS; -+ } -+ } -+ -+ free(parts_info); -+ -+ /* Verify expected partitions found in the emulated secure world*/ -+ ut_assertok(ret != CMD_RET_SUCCESS); -+ -+ return CMD_RET_SUCCESS; -+} -+ -+static int dm_test_ffa_ack(struct unit_test_state *uts) -+{ -+ struct ffa_prvdata *prvdata = NULL; -+ struct sandbox_ffa_prvdata *sdx_prvdata = NULL; -+ struct ffa_sandbox_data func_data = {0}; -+ u8 rxbuf_flag = 0; -+ const char *svc1_uuid = SANDBOX_SERVICE1_UUID; -+ const char *svc2_uuid = SANDBOX_SERVICE2_UUID; -+ int ret; -+ -+ /* test probing FF-A devices */ -+ ut_assertok(ffa_bus_discover(NULL)); -+ -+ /* get a pointer to the FF-A core and sandbox drivers private data */ -+ func_data.data0 = &prvdata; -+ func_data.data0_size = sizeof(prvdata); -+ func_data.data1 = &sdx_prvdata; -+ func_data.data1_size = sizeof(sdx_prvdata); -+ -+ ut_assertok(sandbox_ffa_query_core_state(FFA_VERSION, &func_data)); -+ -+ /* make sure private data pointers are retrieved */ -+ ut_assertok(prvdata == 0); -+ ut_assertok(sdx_prvdata == 0); -+ -+ /* make sure dev devices created */ -+ ut_assertok(check_core_dev(prvdata, uts)); -+ ut_assertok(check_sandbox_dev(sdx_prvdata, uts)); -+ -+ /* test FFA_VERSION */ -+ ut_assertok(check_fwk_version(prvdata, sdx_prvdata, uts)); -+ -+ /* test FFA_ID_GET */ -+ ut_assertok(check_endpoint_id(prvdata, uts)); -+ -+ /* test FFA_FEATURES */ -+ ut_assertok(check_features(prvdata, uts)); -+ -+ /* test core RX/TX buffers */ -+ ut_assertok(check_rxtxbuf(prvdata, uts)); -+ -+ /* test FFA_RXTX_MAP */ -+ func_data.data0 = &rxbuf_flag; -+ func_data.data0_size = sizeof(rxbuf_flag); -+ -+ rxbuf_flag = 0; -+ ut_assertok(sandbox_ffa_query_core_state(FFA_RXTX_MAP, &func_data)); -+ ut_assertok(check_rxbuf_mapped_flag(FFA_RXTX_MAP, rxbuf_flag, uts)); -+ -+ /* FFA_PARTITION_INFO_GET / FFA_MSG_SEND_DIRECT_REQ */ -+ ret = test_partitions_and_comms(svc1_uuid, sdx_prvdata, uts); -+ ut_assertok(ret != CMD_RET_SUCCESS); -+ -+ /* test FFA_RX_RELEASE */ -+ rxbuf_flag = 1; -+ ut_assertok(sandbox_ffa_query_core_state(FFA_RX_RELEASE, &func_data)); -+ ut_assertok(check_rxbuf_release_flag(rxbuf_flag, uts)); -+ -+ /* FFA_PARTITION_INFO_GET / FFA_MSG_SEND_DIRECT_REQ */ -+ ret = test_partitions_and_comms(svc2_uuid, sdx_prvdata, uts); -+ ut_assertok(ret != CMD_RET_SUCCESS); -+ -+ /* test FFA_RX_RELEASE */ -+ rxbuf_flag = 1; -+ ut_assertok(sandbox_ffa_query_core_state(FFA_RX_RELEASE, &func_data)); -+ ut_assertok(check_rxbuf_release_flag(rxbuf_flag, uts)); -+ -+ /* test FFA_RXTX_UNMAP */ -+ ut_assertok(ffa_bus_ops_get()->rxtx_unmap(NULL)); -+ -+ rxbuf_flag = 1; -+ ut_assertok(sandbox_ffa_query_core_state(FFA_RXTX_UNMAP, &func_data)); -+ ut_assertok(check_rxbuf_mapped_flag(FFA_RXTX_UNMAP, rxbuf_flag, uts)); -+ -+ return CMD_RET_SUCCESS; -+} -+ -+DM_TEST(dm_test_ffa_ack, UT_TESTF_SCAN_FDT | UT_TESTF_CONSOLE_REC); -+ -+static int dm_test_ffa_nack(struct unit_test_state *uts) -+{ -+ struct ffa_prvdata *prvdata = NULL; -+ struct sandbox_ffa_prvdata *sdx_prvdata = NULL; -+ struct ffa_sandbox_data func_data = {0}; -+ const char *valid_svc_uuid = SANDBOX_SERVICE1_UUID; -+ const char *unvalid_svc_uuid = SANDBOX_SERVICE3_UUID; -+ const char *unvalid_svc_uuid_str = SANDBOX_SERVICE4_UUID; -+ struct ffa_send_direct_data msg = {0}; -+ int ret; -+ u32 count = 0; -+ u16 part_id = 0; -+ -+ /* test probing FF-A devices */ -+ ut_assertok(ffa_bus_discover(NULL)); -+ -+ /* get a pointer to the FF-A core and sandbox drivers private data */ -+ func_data.data0 = &prvdata; -+ func_data.data0_size = sizeof(prvdata); -+ func_data.data1 = &sdx_prvdata; -+ func_data.data1_size = sizeof(sdx_prvdata); -+ -+ ut_assertok(sandbox_ffa_query_core_state(FFA_VERSION, &func_data)); -+ -+ /* make sure private data pointers are retrieved */ -+ ut_assertok(prvdata == 0); -+ ut_assertok(sdx_prvdata == 0); -+ -+ /* make sure dev devices created */ -+ ut_assertok(check_core_dev(prvdata, uts)); -+ ut_assertok(check_sandbox_dev(sdx_prvdata, uts)); -+ -+ /* query partitions count using invalid arguments */ -+ ret = ffa_bus_ops_get()->partition_info_get(NULL, unvalid_svc_uuid, NULL, NULL); -+ ut_assertok(ret != -EINVAL); -+ -+ /* query partitions count using an invalid UUID string */ -+ ret = ffa_bus_ops_get()->partition_info_get(NULL, unvalid_svc_uuid_str, &count, NULL); -+ ut_assertok(ret != -EINVAL); -+ -+ /* query partitions count using an invalid UUID (no matching SP) */ -+ count = 0; -+ ret = ffa_bus_ops_get()->partition_info_get(NULL, unvalid_svc_uuid, &count, NULL); -+ ut_assertok(count != 0); -+ -+ /* query partitions count using a valid UUID */ -+ count = 0; -+ ret = ffa_bus_ops_get()->partition_info_get(NULL, valid_svc_uuid, &count, NULL); -+ /* make sure partitions are detected */ -+ ut_assertok(ret != 0); -+ ut_assertok(count != SANDBOX_SP_COUNT_PER_VALID_SERVICE); -+ -+ /* send data to an invalid partition */ -+ ret = ffa_bus_ops_get()->sync_send_receive(NULL, part_id, &msg, 1); -+ ut_assertok(ret != -EINVAL); -+ -+ /* send data to a valid partition */ -+ part_id = prvdata->partitions.descs[0].info.id; -+ ret = ffa_bus_ops_get()->sync_send_receive(NULL, part_id, &msg, 1); -+ ut_assertok(ret != 0); -+ -+ return CMD_RET_SUCCESS; -+} -+ -+DM_TEST(dm_test_ffa_nack, UT_TESTF_SCAN_FDT | UT_TESTF_CONSOLE_REC); --- -2.25.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0008-arm_ffa-introduce-armffa-command-Sandbox-test.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0008-FF-A-v15-arm_ffa-introduce-armffa-command-Sandbox-te.patch index d5842827a4..05b5e4d1ab 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0008-arm_ffa-introduce-armffa-command-Sandbox-test.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0008-FF-A-v15-arm_ffa-introduce-armffa-command-Sandbox-te.patch @@ -1,105 +1,92 @@ -From 5af272d2bb2a7a8c8a4732c8d598dd1713856949 Mon Sep 17 00:00:00 2001 +From 78547a9f322b981a93bbeeb48b3eda1d2ab35cd0 Mon Sep 17 00:00:00 2001 From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Date: Tue, 29 Nov 2022 14:48:34 +0000 -Subject: [PATCH 08/42] arm_ffa: introduce armffa command Sandbox test +Date: Fri, 23 Jun 2023 13:44:10 +0100 +Subject: [PATCH 08/33] FF-A v15: arm_ffa: introduce armffa command Sandbox + test Add Sandbox test for the armffa command Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> +Reviewed-by: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com> -Cc: Simon Glass <sjg@chromium.org> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Cc: Jens Wiklander <jens.wiklander@linaro.org> -Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/] - -Changelog: -=============== - -v4: drop use of helper APIs - -v1: introduce armffa command sandbox test -Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> +Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20230713132847.176000-1-abdellatif.elkhlifi@arm.com/] --- MAINTAINERS | 1 + test/cmd/Makefile | 2 ++ - test/cmd/armffa.c | 39 +++++++++++++++++++++++++++++++++++++++ - 3 files changed, 42 insertions(+) + test/cmd/armffa.c | 33 +++++++++++++++++++++++++++++++++ + 3 files changed, 36 insertions(+) create mode 100644 test/cmd/armffa.c diff --git a/MAINTAINERS b/MAINTAINERS -index c1d3d4ae1c..a2f60a3b93 100644 +index ccd7859c88..885d91fe5c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS -@@ -272,6 +272,7 @@ F: doc/arch/arm64.ffa.rst +@@ -276,6 +276,7 @@ F: doc/arch/arm64.ffa.rst + F: doc/usage/cmd/armffa.rst F: drivers/firmware/arm-ffa/ F: include/arm_ffa.h - F: include/sandbox_arm_ffa.h +F: test/cmd/armffa.c F: test/dm/ffa.c ARM FREESCALE IMX diff --git a/test/cmd/Makefile b/test/cmd/Makefile -index bc961df3dc..21aa6d740e 100644 +index 055adc65a2..1d1dbb4fbc 100644 --- a/test/cmd/Makefile +++ b/test/cmd/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0+ # # Copyright (c) 2013 Google, Inc -+# (C) Copyright 2022 ARM Limited ++# Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ifdef CONFIG_HUSH_PARSER obj-$(CONFIG_CONSOLE_RECORD) += test_echo.o -@@ -18,6 +19,7 @@ obj-$(CONFIG_CMD_PINMUX) += pinmux.o - obj-$(CONFIG_CMD_PWM) += pwm.o +@@ -23,6 +24,7 @@ obj-$(CONFIG_CMD_SEAMA) += seama.o ifdef CONFIG_SANDBOX + obj-$(CONFIG_CMD_READ) += rw.o obj-$(CONFIG_CMD_SETEXPR) += setexpr.o -+obj-$(CONFIG_SANDBOX_FFA) += armffa.o ++obj-$(CONFIG_ARM_FFA_TRANSPORT) += armffa.o endif obj-$(CONFIG_CMD_TEMPERATURE) += temperature.o obj-$(CONFIG_CMD_WGET) += wget.o diff --git a/test/cmd/armffa.c b/test/cmd/armffa.c new file mode 100644 -index 0000000000..e04363ba63 +index 0000000000..9a44a397e8 --- /dev/null +++ b/test/cmd/armffa.c -@@ -0,0 +1,39 @@ +@@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Test for armffa command + * -+ * (C) Copyright 2022 ARM Limited -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++ * ++ * Authors: ++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> + */ + +#include <common.h> -+#include <dm/test.h> -+#include <sandbox_arm_ffa.h> +#include <string.h> ++#include <asm/sandbox_arm_ffa.h> ++#include <dm/test.h> +#include <test/test.h> +#include <test/ut.h> + -+#define PING_CMD_SIZE 19 -+ +/* Basic test of 'armffa' command */ +static int dm_test_armffa_cmd(struct unit_test_state *uts) +{ -+ char ping_cmd[PING_CMD_SIZE] = {0}; -+ -+ ut_assertok(ffa_bus_discover(NULL)); -+ + /* armffa getpart <UUID> */ + ut_assertok(run_command("armffa getpart " SANDBOX_SERVICE1_UUID, 0)); + -+ snprintf(ping_cmd, PING_CMD_SIZE, "armffa ping 0x%x", SANDBOX_SP1_ID); -+ + /* armffa ping <ID> */ -+ ut_assertok(run_command(ping_cmd, 0)); ++ ut_assertok(run_commandf("armffa ping 0x%x", SANDBOX_SP1_ID)); + + /* armffa devlist */ + ut_assertok(run_command("armffa devlist", 0)); + -+ return CMD_RET_SUCCESS; ++ return 0; +} + +DM_TEST(dm_test_armffa_cmd, UT_TESTF_SCAN_FDT | UT_TESTF_CONSOLE_REC); diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0009-arm_ffa-efi-introduce-FF-A-MM-communication.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0009-FF-A-v15-arm_ffa-efi-introduce-FF-A-MM-communication.patch index 574b7df958..bd75bc1d37 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0009-arm_ffa-efi-introduce-FF-A-MM-communication.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0009-FF-A-v15-arm_ffa-efi-introduce-FF-A-MM-communication.patch @@ -1,7 +1,7 @@ -From ca1ae0e78ee3476090919459ec5d08187d5eefbc Mon Sep 17 00:00:00 2001 +From 342844c2a5ad6beb127e1e8e52b311df77cff472 Mon Sep 17 00:00:00 2001 From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> Date: Mon, 15 Aug 2022 15:12:49 +0100 -Subject: [PATCH 09/42] arm_ffa: efi: introduce FF-A MM communication +Subject: [PATCH 09/33] FF-A v15: arm_ffa: efi: introduce FF-A MM communication Add MM communication support using FF-A transport @@ -27,80 +27,33 @@ consumed by the EFI subsystem. MM communication protocol supports FF-A 64-bit direct messaging. Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com> +Tested-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com> +Reviewed-by: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com> -Cc: Simon Glass <sjg@chromium.org> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Cc: Jens Wiklander <jens.wiklander@linaro.org> -Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/] - -Changelog: -=============== - -v8: - -* isolate the compilation choices between FF-A and OP-TEE -* update partition_info_get() second argument to be an SP count -* pass NULL device pointer to the FF-A bus discovery and operations - -v7: - -* set the MM door bell event to use 64-bit direct messaging -* issue a compile time error when one of these macros are not found : - FFA_SHARED_MM_BUFFER_SIZE, FFA_SHARED_MM_BUFFER_OFFSET, FFA_SHARED_MM_BUFFER_ADDR -* make mm_sp_svc_uuid static -* replace EINVAL with ENOMEM in ffa_discover_mm_sp_id() when calloc() fails -* improve use of unmap_sysmem() in ffa_mm_communicate() - -v6: - -* add FF-A runtime discovery at MM communication level -* drop EFI runtime support for FF-A MM communication -* revert the changes in include/mm_communication.h for - efi_mm_communicate_header and smm_variable_access structures - -v4: - -* use the new FF-A driver interfaces -* discover MM partitions at runtime -* copy FF-A driver private data to EFI runtime section at - ExitBootServices() -* drop use of FFA_ERR_STAT_SUCCESS error code -* replace EFI_BUFFER_TOO_SMALL with EFI_OUT_OF_RESOURCES - in ffa_mm_communicate(). No need for efi_memcpy_runtime() anymore -* revert the error log in mm_communicate() in case of failure -* remove packed attribute from efi_mm_communicate_header and - smm_variable_communicate_header - -v2: - -* set default values to 0 for FFA_SHARED_MM_BUFFER_SIZE, FFA_SHARED_MM_BUFFER_ADDR and MM_SP_UUID_DATA and add warnings - -v1: - -* introduce FF-A MM communication - -Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> +Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20230713132847.176000-1-abdellatif.elkhlifi@arm.com/] --- - include/mm_communication.h | 5 + - lib/efi_loader/Kconfig | 14 +- - lib/efi_loader/efi_variable_tee.c | 294 +++++++++++++++++++++++++++++- - 3 files changed, 307 insertions(+), 6 deletions(-) + include/mm_communication.h | 13 ++ + lib/efi_loader/Kconfig | 46 +++++- + lib/efi_loader/efi_variable_tee.c | 257 +++++++++++++++++++++++++++++- + 3 files changed, 309 insertions(+), 7 deletions(-) diff --git a/include/mm_communication.h b/include/mm_communication.h -index e65fbde60d..d409bed777 100644 +index e65fbde60d..f17847583b 100644 --- a/include/mm_communication.h +++ b/include/mm_communication.h -@@ -6,6 +6,8 @@ +@@ -6,6 +6,9 @@ * Copyright (c) 2017, Intel Corporation. All rights reserved. * Copyright (C) 2020 Linaro Ltd. <sughosh.ganu@linaro.org> * Copyright (C) 2020 Linaro Ltd. <ilias.apalodimas@linaro.org> -+ * (C) Copyright 2022 ARM Limited -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++ * Authors: ++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> */ #ifndef _MM_COMMUNICATION_H_ -@@ -13,6 +15,9 @@ +@@ -13,6 +16,9 @@ #include <part_efi.h> @@ -110,18 +63,32 @@ index e65fbde60d..d409bed777 100644 /* * Interface to the pseudo Trusted Application (TA), which provides a * communication channel with the Standalone MM (Management Mode) +@@ -248,4 +254,11 @@ struct smm_variable_var_check_property { + u16 name[]; + }; + ++/* supported MM transports */ ++enum mm_comms_select { ++ MM_COMMS_UNDEFINED, ++ MM_COMMS_FFA, ++ MM_COMMS_OPTEE ++}; ++ + #endif /* _MM_COMMUNICATION_H_ */ diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig -index b498c72206..ca73908481 100644 +index c5835e6ef6..553e6a30a2 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig -@@ -55,13 +55,23 @@ config EFI_VARIABLE_FILE_STORE +@@ -55,13 +55,55 @@ 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 ++ select ARM_FFA_TRANSPORT ++ select TEE ++ select OPTEE help + Allowing access to the MM SP services (SPs such as StandAlonneMM, smm-gateway). + When using the u-boot OP-TEE driver, StandAlonneMM is supported. @@ -137,84 +104,87 @@ index b498c72206..ca73908481 100644 + MM buffer. The data is copied by u-boot to the shared buffer before issuing + the door bell event. + ++config FFA_SHARED_MM_BUF_SIZE ++ int "Memory size of the shared MM communication buffer" ++ default 0 ++ depends on EFI_MM_COMM_TEE ++ help ++ This defines the size in bytes of the memory area reserved for the shared ++ buffer used for communication between the MM feature in U-Boot and ++ the MM SP in secure world. ++ The size of the memory region must be a multiple of the size of the maximum ++ translation granule size that is specified in the ID_AA64MMFR0_EL1 System register. ++ It is assumed that the MM SP knows the size of the shared MM communication buffer. ++ ++config FFA_SHARED_MM_BUF_OFFSET ++ int "Data offset in the shared MM communication buffer" ++ default 0 ++ depends on EFI_MM_COMM_TEE ++ help ++ This defines the offset in bytes of the data read or written to in the shared ++ buffer by the MM SP. ++ ++config FFA_SHARED_MM_BUF_ADDR ++ hex "Define the address of the shared MM communication buffer" ++ default 0x0 ++ depends on EFI_MM_COMM_TEE ++ help ++ This defines the address of the shared MM communication buffer ++ used for communication between the MM feature in U-Boot and ++ the MM SP in secure world. ++ It is assumed that the MM SP knows the address of the shared MM communication buffer. ++ config EFI_VARIABLE_NO_STORE bool "Don't persist non-volatile UEFI variables" help diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c -index dfef18435d..3933a24e8c 100644 +index dfef18435d..5137b871ea 100644 --- a/lib/efi_loader/efi_variable_tee.c +++ b/lib/efi_loader/efi_variable_tee.c -@@ -4,9 +4,12 @@ +@@ -4,17 +4,34 @@ * * Copyright (C) 2019 Linaro Ltd. <sughosh.ganu@linaro.org> * Copyright (C) 2019 Linaro Ltd. <ilias.apalodimas@linaro.org> -+ * Copyright (C) 2022 ARM Limited -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ++ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> ++ * ++ * Authors: ++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> */ #include <common.h> ++#include <arm_ffa.h> ++#include <cpu_func.h> +#include <dm.h> #include <efi.h> #include <efi_api.h> #include <efi_loader.h> -@@ -15,6 +18,36 @@ + #include <efi_variable.h> +-#include <tee.h> #include <malloc.h> - #include <mm_communication.h> - -+#if (IS_ENABLED(CONFIG_ARM_FFA_TRANSPORT)) -+ -+#include <arm_ffa.h> -+#include <cpu_func.h> +#include <mapmem.h> -+ -+#ifndef FFA_SHARED_MM_BUFFER_SIZE -+#error "FFA_SHARED_MM_BUFFER_SIZE must be defined in include/configs/<board>.h" -+#define FFA_SHARED_MM_BUFFER_SIZE 0 -+#endif -+ -+#ifndef FFA_SHARED_MM_BUFFER_OFFSET -+#error "FFA_SHARED_MM_BUFFER_OFFSET must be defined in include/configs/<board>.h" -+#define FFA_SHARED_MM_BUFFER_OFFSET 0 -+#endif -+ -+#ifndef FFA_SHARED_MM_BUFFER_ADDR -+#error "FFA_SHARED_MM_BUFFER_ADDR must be defined in include/configs/<board>.h" -+#define FFA_SHARED_MM_BUFFER_ADDR 0 -+#endif + #include <mm_communication.h> ++#include <tee.h> + +/* MM return codes */ +#define MM_SUCCESS (0) -+ ++#define MM_NOT_SUPPORTED (-1) ++#define MM_INVALID_PARAMETER (-2) ++#define MM_DENIED (-3) ++#define MM_NO_MEMORY (-5) + +static const char *mm_sp_svc_uuid = MM_SP_UUID; -+ +static u16 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 */ -@@ -24,6 +57,7 @@ struct mm_connection { - u32 session; - }; - -+#if (IS_ENABLED(CONFIG_OPTEE)) - /** - * get_connection() - Retrieve OP-TEE session for a specific UUID. - * -@@ -143,13 +177,248 @@ static efi_status_t optee_mm_communicate(void *comm_buf, ulong dsize) - - return ret; +@@ -145,16 +162,241 @@ static efi_status_t optee_mm_communicate(void *comm_buf, ulong dsize) } -+#endif -+ -+#if (IS_ENABLED(CONFIG_ARM_FFA_TRANSPORT)) /** - * mm_communicate() - Adjust the cmonnucation buffer to StandAlonneMM and send + * ffa_notify_mm_sp() - Announce there is data in the shared buffer + * -+ * Notifies the MM partition in the trusted world that ++ * Notify 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. @@ -227,27 +197,44 @@ index dfef18435d..3933a24e8c 100644 +{ + struct ffa_send_direct_data msg = {0}; + int ret; -+ int sp_event_ret = -1; ++ int sp_event_ret; ++ struct udevice *dev; + -+ if (!ffa_bus_ops_get()) -+ return -EINVAL; ++ ret = uclass_first_device_err(UCLASS_FFA, &dev); ++ if (ret) { ++ log_err("EFI: Cannot find FF-A bus device, notify MM SP failure\n"); ++ return ret; ++ } + -+ msg.data0 = FFA_SHARED_MM_BUFFER_OFFSET; /* x3 */ ++ msg.data0 = CONFIG_FFA_SHARED_MM_BUF_OFFSET; /* x3 */ + -+ ret = ffa_bus_ops_get()->sync_send_receive(NULL, mm_sp_id, &msg, 1); -+ if (ret != 0) ++ ret = ffa_sync_send_receive(dev, mm_sp_id, &msg, 1); ++ if (ret) + return ret; + + sp_event_ret = msg.data0; /* x3 */ + -+ if (sp_event_ret == MM_SUCCESS) -+ return 0; -+ -+ /* -+ * Failure to notify the MM SP -+ */ ++ switch (sp_event_ret) { ++ case MM_SUCCESS: ++ ret = 0; ++ break; ++ case MM_NOT_SUPPORTED: ++ ret = -EINVAL; ++ break; ++ case MM_INVALID_PARAMETER: ++ ret = -EPERM; ++ break; ++ case MM_DENIED: ++ ret = -EACCES; ++ break; ++ case MM_NO_MEMORY: ++ ret = -EBUSY; ++ break; ++ default: ++ ret = -EACCES; ++ } + -+ return -EACCES; ++ return ret; +} + +/** @@ -265,57 +252,28 @@ index dfef18435d..3933a24e8c 100644 +{ + u32 count = 0; + int ret; -+ struct ffa_partition_info *parts_info; -+ -+ if (!ffa_bus_ops_get()) -+ return -EINVAL; ++ struct ffa_partition_desc *descs; ++ struct udevice *dev; + -+ /* -+ * get from the driver the count of the SPs matching the UUID -+ */ -+ ret = ffa_bus_ops_get()->partition_info_get(NULL, mm_sp_svc_uuid, &count, NULL); -+ if (ret != 0) { -+ 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"); ++ ret = uclass_first_device_err(UCLASS_FFA, &dev); ++ if (ret) { ++ log_err("EFI: Cannot find FF-A bus device, MM SP discovery failure\n"); + return ret; + } + -+ /* -+ * pre-allocate a buffer to be filled by the driver -+ * with ffa_partition_info structs -+ */ -+ -+ log_info("EFI: Pre-allocating %d partition(s) info structures\n", count); -+ -+ parts_info = calloc(count, sizeof(*parts_info)); -+ if (!parts_info) -+ return -ENOMEM; -+ -+ /* -+ * ask the driver to fill the -+ * buffer with the SPs info -+ */ -+ ret = ffa_bus_ops_get()->partition_info_get(NULL, mm_sp_svc_uuid, &count, parts_info); ++ /* Ask the driver to fill the buffer with the SPs info */ ++ ret = ffa_partition_info_get(dev, mm_sp_svc_uuid, &count, &descs); + if (ret) { -+ log_err("EFI: Failure in querying partition(s) info (error code: %d)\n", ret); -+ free(parts_info); ++ log_err("EFI: Failure in querying SPs info (%d), MM SP discovery failure\n", ret); + return ret; + } + -+ /* -+ * MM SPs found , use the first one -+ */ ++ /* MM SPs found , use the first one */ + -+ mm_sp_id = parts_info[0].id; ++ mm_sp_id = descs[0].info.id; + + log_info("EFI: MM partition ID 0x%x\n", mm_sp_id); + -+ free(parts_info); -+ + return 0; +} + @@ -324,7 +282,7 @@ index dfef18435d..3933a24e8c 100644 + * @comm_buf: locally allocated communication buffer used for rx/tx + * @dsize: communication buffer size + * -+ * Issues a door bell event to notify the MM partition (SP) running in OP-TEE ++ * Issue 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 @@ -347,20 +305,20 @@ index dfef18435d..3933a24e8c 100644 + return EFI_INVALID_PARAMETER; + + /* Discover MM partition ID at boot time */ -+ if (!mm_sp_id && ffa_discover_mm_sp_id() != 0) { -+ log_err("EFI: Failure to discover MM partition ID at boot time\n"); ++ if (!mm_sp_id && ffa_discover_mm_sp_id()) { ++ log_err("EFI: Failure to discover MM SP ID at boot time, FF-A MM comms failure\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) ++ if (comm_buf_size != tx_data_size || tx_data_size > CONFIG_FFA_SHARED_MM_BUF_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); ++ virt_shared_buf = map_sysmem((phys_addr_t)CONFIG_FFA_SHARED_MM_BUF_ADDR, 0); + memcpy(virt_shared_buf, comm_buf, tx_data_size); + + /* @@ -369,17 +327,16 @@ index dfef18435d..3933a24e8c 100644 + * In this case, the secure world reads the data from DRAM. + * Let's flush the cache so the DRAM is updated with the latest data. + */ -+ #ifdef CONFIG_ARM64 ++#ifdef CONFIG_ARM64 + invalidate_dcache_all(); -+ #endif ++#endif + + /* Announce there is data in the shared buffer */ + + ffa_ret = ffa_notify_mm_sp(); + + switch (ffa_ret) { -+ case 0: -+ { ++ 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 + @@ -414,27 +371,32 @@ index dfef18435d..3933a24e8c 100644 + unmap_sysmem(virt_shared_buf); + return efi_ret; +} -+#endif + +/** -+ * select_ffa_mm_comms() - checks FF-A support availability ++ * get_mm_comms() - detect the available MM transport + * -+ * Making sure FF-A is compiled in. If that's the case try to discover -+ * the FF-A bus. ++ * Make sure the FF-A bus is probed successfully ++ * which means FF-A communication with secure world works and ready ++ * for use. ++ * ++ * If FF-A bus is not ready, use OPTEE comms. + * + * Return: + * -+ * 0: FF-A ready for use. Otherwise, failure ++ * MM_COMMS_FFA or MM_COMMS_OPTEE + */ -+static efi_status_t select_ffa_mm_comms(void) ++static enum mm_comms_select get_mm_comms(void) +{ -+ efi_status_t ret = EFI_UNSUPPORTED; -+#if (IS_ENABLED(CONFIG_ARM_FFA_TRANSPORT)) -+ ret = ffa_bus_discover(NULL); -+ if (ret) -+ ret = EFI_NOT_READY; -+#endif -+ return ret; ++ struct udevice *dev; ++ int ret; ++ ++ ret = uclass_first_device_err(UCLASS_FFA, &dev); ++ if (ret) { ++ log_err("EFI: Cannot find FF-A bus device, trying Optee comms\n"); ++ return MM_COMMS_OPTEE; ++ } ++ ++ return MM_COMMS_FFA; +} + +/** @@ -453,40 +415,27 @@ index dfef18435d..3933a24e8c 100644 * Return: status code */ static efi_status_t mm_communicate(u8 *comm_buf, efi_uintn_t dsize) -@@ -162,7 +431,17 @@ static efi_status_t mm_communicate(u8 *comm_buf, efi_uintn_t dsize) + { + efi_status_t ret; ++ enum mm_comms_select mm_comms; + struct efi_mm_communicate_header *mm_hdr; + struct smm_variable_communicate_header *var_hdr; + +@@ -162,7 +404,12 @@ 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; - ret = optee_mm_communicate(comm_buf, dsize); -+ ret = select_ffa_mm_comms(); -+ if (ret != EFI_SUCCESS) { -+#if (IS_ENABLED(CONFIG_OPTEE)) -+ ret = optee_mm_communicate(comm_buf, dsize); -+#endif -+ } else { -+#if (IS_ENABLED(CONFIG_ARM_FFA_TRANSPORT)) ++ mm_comms = get_mm_comms(); ++ if (mm_comms == MM_COMMS_FFA) + ret = ffa_mm_communicate(comm_buf, dsize); -+#endif -+ } ++ else ++ ret = optee_mm_communicate(comm_buf, dsize); + if (ret != EFI_SUCCESS) { log_err("%s failed!\n", __func__); return ret; -@@ -258,6 +537,13 @@ efi_status_t EFIAPI get_max_payload(efi_uintn_t *size) - goto out; - } - *size = var_payload->size; -+ -+ #if (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 -@@ -697,7 +983,7 @@ void efi_variables_boot_exit_notify(void) +@@ -697,7 +944,7 @@ void efi_variables_boot_exit_notify(void) ret = EFI_NOT_FOUND; if (ret != EFI_SUCCESS) diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0010-FF-A-v15-arm_ffa-efi-corstone1000-enable-MM-communic.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0010-FF-A-v15-arm_ffa-efi-corstone1000-enable-MM-communic.patch new file mode 100644 index 0000000000..4dcec1dc39 --- /dev/null +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0010-FF-A-v15-arm_ffa-efi-corstone1000-enable-MM-communic.patch @@ -0,0 +1,33 @@ +From 79e941be83a7394d03b09c618c8e2924ef962d64 Mon Sep 17 00:00:00 2001 +From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> +Date: Mon, 17 Jul 2023 15:23:33 +0100 +Subject: [PATCH 10/33] FF-A v15: arm_ffa: efi: corstone1000: enable MM + communication + +turn on EFI MM communication + +On corstone1000 platform MM communication between u-boot +and the secure world (Optee) is done using the FF-A bus. + +Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> +Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20230713132847.176000-1-abdellatif.elkhlifi@arm.com/] +--- + configs/corstone1000_defconfig | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig +index 2d391048cd..ee5481b63c 100644 +--- a/configs/corstone1000_defconfig ++++ b/configs/corstone1000_defconfig +@@ -53,3 +53,8 @@ CONFIG_DM_SERIAL=y + CONFIG_USB=y + CONFIG_USB_ISP1760=y + CONFIG_ERRNO_STR=y ++CONFIG_NVMXIP_QSPI=y ++CONFIG_EFI_MM_COMM_TEE=y ++CONFIG_FFA_SHARED_MM_BUF_SIZE=4096 ++CONFIG_FFA_SHARED_MM_BUF_OFFSET=0 ++CONFIG_FFA_SHARED_MM_BUF_ADDR=0x02000000 +-- +2.25.1 + diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0010-arm_ffa-efi-corstone1000-enable-MM-communication.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0010-arm_ffa-efi-corstone1000-enable-MM-communication.patch deleted file mode 100644 index 4fe1405cbb..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0010-arm_ffa-efi-corstone1000-enable-MM-communication.patch +++ /dev/null @@ -1,86 +0,0 @@ -From a595dfd91d3e226eaa39e324673871c73ae0aa29 Mon Sep 17 00:00:00 2001 -From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Date: Fri, 23 Sep 2022 15:17:21 +0100 -Subject: [PATCH 10/42] arm_ffa: efi: corstone1000: enable MM communication - -turn on EFI MM communication - -On corstone1000 platform MM communication between u-boot -and the secure world (Optee) is done using the FF-A bus. - -Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Cc: Tom Rini <trini@konsulko.com> -Cc: Simon Glass <sjg@chromium.org> -Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> -Cc: Jens Wiklander <jens.wiklander@linaro.org> -Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/] - -Changelog: -=============== - -v8: - -* drop OP-TEE configs from Corstone-1000 defconfig - -v7: - -* improve the definition of FFA_SHARED_MM_BUFFER_ADDR and - FFA_SHARED_MM_BUFFER_OFFSET -* update FFA_SHARED_MM_BUFFER_ADDR value - -v6: - -* corstone-1000: enable optee driver -* corstone-1000: remove CONFIG_ARM_FFA_EFI_RUNTIME_MODE from the defconfig - -v4: - -* corstone-1000: turn on EFI MM communication - -Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> ---- - configs/corstone1000_defconfig | 2 ++ - include/configs/corstone1000.h | 10 ++++++++++ - 2 files changed, 12 insertions(+) - -diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig -index dddfa27507..d1dc06c86c 100644 ---- a/configs/corstone1000_defconfig -+++ b/configs/corstone1000_defconfig -@@ -52,3 +52,5 @@ CONFIG_DM_SERIAL=y - CONFIG_USB=y - CONFIG_USB_ISP1760=y - CONFIG_ERRNO_STR=y -+CONFIG_EFI_MM_COMM_TEE=y -+CONFIG_ARM_FFA_TRANSPORT=y -diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h -index 8e0230c135..b6226fa12a 100644 ---- a/include/configs/corstone1000.h -+++ b/include/configs/corstone1000.h -@@ -14,6 +14,15 @@ - - #include <linux/sizes.h> - -+#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 0x02000000UL -+#define FFA_SHARED_MM_BUFFER_OFFSET 0 -+ - #define V2M_BASE 0x80000000 - - #define CONFIG_PL011_CLOCK 50000000 -@@ -22,6 +31,7 @@ - #define PHYS_SDRAM_1 (V2M_BASE) - #define PHYS_SDRAM_1_SIZE 0x80000000 - -+#define CFG_SYS_SDRAM_BASE PHYS_SDRAM_1 - #define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1 - - #define BOOT_TARGET_DEVICES(func) \ --- -2.25.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0011-efi-corstone1000-introduce-EFI-capsule-update.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0011-efi-corstone1000-fwu-introduce-EFI-capsule-update.patch index c526626dc7..d2c440c828 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0011-efi-corstone1000-introduce-EFI-capsule-update.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0011-efi-corstone1000-fwu-introduce-EFI-capsule-update.patch @@ -1,7 +1,7 @@ -From b9c44c396f9ad9588184272cdc5ed98e19e82c0a Mon Sep 17 00:00:00 2001 +From 90b2741149a538c93aed61522c0d3363351bd578 Mon Sep 17 00:00:00 2001 From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Date: Tue, 29 Nov 2022 15:11:27 +0000 -Subject: [PATCH 11/42] efi: corstone1000: introduce EFI capsule update +Date: Mon, 17 Jul 2023 15:56:18 +0100 +Subject: [PATCH 11/33] efi: corstone1000: fwu: introduce EFI capsule update This commit provides capsule update feature for Corstone1000. @@ -12,30 +12,35 @@ 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. +On UpdateCapsule() , capsule data is copied to the buffer and a buffer ready event is generated using FF-A transport. + +On efi_init_capsule() in U-Boot, an EFI started event is sent to SE Proxy FW update service. This event is generated on each boot. + +Note: The SE proxy SP requires that the interface/event IDs are passed using register w4 for the buffer ready event and the EFI started event. + + interface ID (31:16) + event ID (15:0) Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> +Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com> Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> Upstream-Status: Pending [Not submitted to upstream yet] --- board/armltd/corstone1000/corstone1000.c | 4 + configs/corstone1000_defconfig | 3 + - include/configs/corstone1000.h | 18 ++++ + include/configs/corstone1000.h | 24 ++++ include/efi_loader.h | 4 +- - lib/efi_loader/efi_boottime.c | 36 +++++++ - lib/efi_loader/efi_capsule.c | 124 ++++++++++++++++++++++- - lib/efi_loader/efi_setup.c | 15 +++ - 7 files changed, 200 insertions(+), 4 deletions(-) + lib/efi_loader/efi_boottime.c | 7 ++ + lib/efi_loader/efi_capsule.c | 136 ++++++++++++++++++++++- + lib/efi_loader/efi_setup.c | 64 +++++++++++ + 7 files changed, 238 insertions(+), 4 deletions(-) diff --git a/board/armltd/corstone1000/corstone1000.c b/board/armltd/corstone1000/corstone1000.c -index 4f4b96a095..76816f8f4e 100644 +index 6ec8e6144f..c840290885 100644 --- a/board/armltd/corstone1000/corstone1000.c +++ b/board/armltd/corstone1000/corstone1000.c -@@ -66,6 +66,10 @@ static struct mm_region corstone1000_mem_map[] = { +@@ -67,6 +67,10 @@ static struct mm_region corstone1000_mem_map[] = { struct mm_region *mem_map = corstone1000_mem_map; @@ -47,21 +52,21 @@ index 4f4b96a095..76816f8f4e 100644 { return 0; diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig -index d1dc06c86c..06eac3e041 100644 +index ee5481b63c..40ba415ecb 100644 --- a/configs/corstone1000_defconfig +++ b/configs/corstone1000_defconfig -@@ -54,3 +54,6 @@ CONFIG_USB_ISP1760=y - CONFIG_ERRNO_STR=y - CONFIG_EFI_MM_COMM_TEE=y - CONFIG_ARM_FFA_TRANSPORT=y +@@ -58,3 +58,6 @@ CONFIG_EFI_MM_COMM_TEE=y + CONFIG_FFA_SHARED_MM_BUF_SIZE=4096 + CONFIG_FFA_SHARED_MM_BUF_OFFSET=0 + CONFIG_FFA_SHARED_MM_BUF_ADDR=0x02000000 +CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y +CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y +CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h -index b6226fa12a..cd30499e3c 100644 +index 3347c11792..8927b09499 100644 --- a/include/configs/corstone1000.h +++ b/include/configs/corstone1000.h -@@ -14,6 +14,24 @@ +@@ -14,6 +14,30 @@ #include <linux/sizes.h> @@ -73,7 +78,13 @@ index b6226fa12a..cd30499e3c 100644 + +/* Notification events used with SE Proxy update service */ +#define CORSTONE1000_BUFFER_READY_EVT (0x1) -+#define CORSTONE1000_KERNEL_STARTED_EVT (0x2) ++#define CORSTONE1000_UBOOT_EFI_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 */ @@ -83,14 +94,14 @@ index b6226fa12a..cd30499e3c 100644 + EFI_GUID(0x3a770ddc, 0x409b, 0x48b2, 0x81, 0x41, \ + 0x93, 0xb7, 0xc6, 0x0b, 0x20, 0x9e) + - #define FFA_SHARED_MM_BUFFER_SIZE SZ_4K /* 4 KB */ + #define V2M_BASE 0x80000000 - /* + #define CFG_PL011_CLOCK 50000000 diff --git a/include/efi_loader.h b/include/efi_loader.h -index f9e427f090..26981141c2 100644 +index 38d7f66bab..0a613ed51e 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h -@@ -1032,11 +1032,11 @@ extern const struct efi_firmware_management_protocol efi_fmp_fit; +@@ -1036,11 +1036,11 @@ extern const struct efi_firmware_management_protocol efi_fmp_fit; extern const struct efi_firmware_management_protocol efi_fmp_raw; /* Capsule update */ @@ -105,70 +116,37 @@ index f9e427f090..26981141c2 100644 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 fea4eb7a34..faab74474d 100644 +index d5065f296a..a5da77c36c 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c -@@ -2103,6 +2103,33 @@ static void efi_exit_caches(void) - #endif - } +@@ -23,6 +23,13 @@ + #include <asm/setjmp.h> + #include <linux/libfdt_env.h> +#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_send_direct_data msg = {0}; -+ -+ log_debug("[%s]\n", __func__); -+ -+ /* -+ * setting the kernel started event arguments -+ */ -+ msg.data0 = CORSTONE1000_SEPROXY_UPDATE_SVC_ID; /* x3 */ -+ msg.data2 = CORSTONE1000_KERNEL_STARTED_EVT; /* x5 */ -+ -+ return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg, 0); -+} -+ ++#include <arm_ffa.h> ++#include <dm.h> ++#include <linux/bitfield.h> ++#include <linux/bitops.h> +#endif + - /** - * efi_exit_boot_services() - stop all boot services - * @image_handle: handle of the loaded image -@@ -2209,6 +2236,15 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle, - /* Recalculate CRC32 */ - efi_update_table_header_crc32(&systab.hdr); + DECLARE_GLOBAL_DATA_PTR; -+#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); - schedule(); + /* Task priority level */ diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c -index 0997cd248f..9e8ddaac7f 100644 +index 7a6f195cbc..ea084e4ed2 100644 --- a/lib/efi_loader/efi_capsule.c +++ b/lib/efi_loader/efi_capsule.c -@@ -26,6 +26,14 @@ +@@ -26,6 +26,17 @@ #include <crypto/pkcs7_parser.h> #include <linux/err.h> +#ifdef CONFIG_TARGET_CORSTONE1000 +#include <arm_ffa.h> +#include <cpu_func.h> ++#include <dm.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; @@ -177,7 +155,7 @@ index 0997cd248f..9e8ddaac7f 100644 DECLARE_GLOBAL_DATA_PTR; const efi_guid_t efi_guid_capsule_report = EFI_CAPSULE_REPORT_GUID; -@@ -696,6 +704,78 @@ static efi_status_t efi_capsule_update_firmware( +@@ -709,6 +720,87 @@ static efi_status_t efi_capsule_update_firmware( } #endif /* CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT */ @@ -239,24 +217,33 @@ index 0997cd248f..9e8ddaac7f 100644 +static int __efi_runtime efi_corstone1000_buffer_ready_event(u32 capsule_image_size) +{ + struct ffa_send_direct_data msg = {0}; ++ int ret; ++ struct udevice *dev; + + log_debug("[%s]\n", __func__); + ++ ret = uclass_first_device_err(UCLASS_FFA, &dev); ++ if (ret) { ++ log_err("Cannot find FF-A bus device\n"); ++ return ret; ++ } ++ + /* -+ * 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.data0 = CORSTONE1000_SEPROXY_UPDATE_SVC_ID; /* x3 */ -+ msg.data1 = capsule_image_size; /* x4 */ -+ msg.data2 = CORSTONE1000_BUFFER_READY_EVT; /* x5 */ ++ msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) | ++ PREP_SEPROXY_EVT(CORSTONE1000_BUFFER_READY_EVT); /* w4 */ + -+ return ffa_bus_ops_get()->sync_send_receive(NULL, CORSTONE1000_SEPROXY_PART_ID, &msg, 0); ++ return ffa_sync_send_receive(dev, CORSTONE1000_SEPROXY_PART_ID, &msg, 0); +} +#endif + /** * efi_update_capsule() - process information from operating system * @capsule_header_array: Array of virtual address pointers -@@ -709,7 +789,7 @@ static efi_status_t efi_capsule_update_firmware( +@@ -722,7 +814,7 @@ static efi_status_t efi_capsule_update_firmware( * * Return: status code */ @@ -265,7 +252,7 @@ index 0997cd248f..9e8ddaac7f 100644 struct efi_capsule_header **capsule_header_array, efi_uintn_t capsule_count, u64 scatter_gather_list) -@@ -726,6 +806,13 @@ efi_status_t EFIAPI efi_update_capsule( +@@ -739,6 +831,13 @@ efi_status_t EFIAPI efi_update_capsule( goto out; } @@ -279,7 +266,7 @@ index 0997cd248f..9e8ddaac7f 100644 ret = EFI_SUCCESS; for (i = 0, capsule = *capsule_header_array; i < capsule_count; i++, capsule = *(++capsule_header_array)) { -@@ -738,6 +825,39 @@ efi_status_t EFIAPI efi_update_capsule( +@@ -751,6 +850,39 @@ efi_status_t EFIAPI efi_update_capsule( log_debug("Capsule[%d] (guid:%pUs)\n", i, &capsule->capsule_guid); @@ -319,7 +306,7 @@ index 0997cd248f..9e8ddaac7f 100644 if (!guidcmp(&capsule->capsule_guid, &efi_guid_firmware_management_capsule_id)) { ret = efi_capsule_update_firmware(capsule); -@@ -776,7 +896,7 @@ out: +@@ -789,7 +921,7 @@ out: * * Return: status code */ @@ -329,14 +316,19 @@ index 0997cd248f..9e8ddaac7f 100644 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 5437641135..1ad2fa52d7 100644 +index 58d4e13402..bf90a98b5a 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c -@@ -16,6 +16,13 @@ +@@ -17,6 +17,18 @@ efi_status_t efi_obj_list_initialized = OBJ_LIST_NOT_INITIALIZED; +#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000) ++#include <linux/bitfield.h> ++#include <linux/bitops.h> ++#include <arm_ffa.h> ++#include <dm.h> ++ +/** + * efi_corstone1000_alloc_capsule_shared_buf - allocate capsule shared buffer + */ @@ -346,11 +338,62 @@ index 5437641135..1ad2fa52d7 100644 /* * Allow unaligned memory access. * -@@ -128,6 +135,14 @@ static efi_status_t efi_init_capsule(void) +@@ -120,6 +132,42 @@ static efi_status_t efi_init_secure_boot(void) + } + #endif /* CONFIG_EFI_SECURE_BOOT */ + ++#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000) ++/** ++ * efi_corstone1000_uboot-efi_started_event - notifies SE Proxy FW update service ++ * ++ * This function notifies the SE Proxy update service that uboot efi has already started ++ * ++ * Return: ++ * ++ * 0: on success, otherwise failure ++ * */ ++static int efi_corstone1000_uboot_efi_started_event(void) ++{ ++ struct ffa_send_direct_data msg = {0}; ++ int ret; ++ struct udevice *dev; ++ ++ log_debug("[%s]\n", __func__); ++ ++ ret = uclass_first_device_err(UCLASS_FFA, &dev); ++ if (ret) { ++ log_err("Cannot find FF-A bus device\n"); ++ return ret; ++ } ++ ++ /* ++ * setting the kernel started event arguments: ++ * setting capsule update interface ID(31:16) ++ * the kernel started event ID(15:0) ++ */ ++ msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) | ++ PREP_SEPROXY_EVT(CORSTONE1000_UBOOT_EFI_STARTED_EVT); /* w4 */ ++ ++ return ffa_sync_send_receive(dev, CORSTONE1000_SEPROXY_PART_ID, &msg, 0); ++} ++#endif ++ + /** + * efi_init_capsule - initialize capsule update state + * +@@ -129,6 +177,22 @@ static efi_status_t efi_init_capsule(void) { efi_status_t ret = EFI_SUCCESS; +#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000) ++ int ffa_ret; ++ ++ ffa_ret = efi_corstone1000_uboot_efi_started_event(); ++ if (ffa_ret) ++ log_err("Failure to notify SE Proxy FW update service\n"); ++ else ++ debug("SE Proxy FW update service notified\n"); ++ + ret = efi_corstone1000_alloc_capsule_shared_buf(); + if (ret != EFI_SUCCESS) { + printf("EFI: Corstone-1000: cannot allocate caspsule shared buffer\n"); @@ -358,9 +401,9 @@ index 5437641135..1ad2fa52d7 100644 + } +#endif + - if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_UPDATE)) { - ret = efi_set_variable_int(u"CapsuleMax", - &efi_guid_capsule_report, + if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)) { + u16 var_name16[12]; + -- 2.25.1 diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0012-arm-corstone1000-fix-unrecognized-filesystem-type.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0012-arm-corstone1000-fix-unrecognized-filesystem-type.patch index 6fe10eb2cc..f9fb70b50d 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0012-arm-corstone1000-fix-unrecognized-filesystem-type.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0012-arm-corstone1000-fix-unrecognized-filesystem-type.patch @@ -1,7 +1,7 @@ -From ac738fa33edec9ff712dee6d10491cb2eb7cfe3a Mon Sep 17 00:00:00 2001 +From 445dfd4a5d8f31a7efb3f2f15aa677de8b3eb602 Mon Sep 17 00:00:00 2001 From: Rui Miguel Silva <rui.silva@linaro.org> Date: Fri, 4 Mar 2022 15:56:09 +0000 -Subject: [PATCH 12/42] arm: corstone1000: fix unrecognized filesystem type +Subject: [PATCH 12/33] arm: corstone1000: fix unrecognized filesystem type Some usb sticks are not recognized by usb, just add a delay before checking status. diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0013-efi_capsule-corstone1000-pass-interface-id-and-buffe.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0013-efi_capsule-corstone1000-pass-interface-id-and-buffe.patch deleted file mode 100644 index bc03035c99..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0013-efi_capsule-corstone1000-pass-interface-id-and-buffe.patch +++ /dev/null @@ -1,74 +0,0 @@ -From baa961b6050508710e1c6b572f2e93ac5c488201 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 13/42] 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> -Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> -Upstream-Status: Pending [Not submitted to upstream yet] ---- - include/configs/corstone1000.h | 6 ++++++ - lib/efi_loader/efi_capsule.c | 11 +++++++---- - 2 files changed, 13 insertions(+), 4 deletions(-) - -diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h -index cd30499e3c..e4c7bcb96f 100644 ---- a/include/configs/corstone1000.h -+++ b/include/configs/corstone1000.h -@@ -24,6 +24,12 @@ - #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 9e8ddaac7f..bd4cc8d272 100644 ---- a/lib/efi_loader/efi_capsule.c -+++ b/lib/efi_loader/efi_capsule.c -@@ -29,6 +29,8 @@ - #ifdef CONFIG_TARGET_CORSTONE1000 - #include <arm_ffa.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; -@@ -766,11 +768,12 @@ static int __efi_runtime efi_corstone1000_buffer_ready_event(u32 capsule_image_s - log_debug("[%s]\n", __func__); - - /* -- * 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.data0 = CORSTONE1000_SEPROXY_UPDATE_SVC_ID; /* x3 */ -- msg.data1 = capsule_image_size; /* x4 */ -- msg.data2 = CORSTONE1000_BUFFER_READY_EVT; /* x5 */ -+ msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) | -+ PREP_SEPROXY_EVT(CORSTONE1000_BUFFER_READY_EVT); /* w4 */ - - return ffa_bus_ops_get()->sync_send_receive(NULL, CORSTONE1000_SEPROXY_PART_ID, &msg, 0); - } --- -2.25.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0015-efi_loader-corstone1000-remove-guid-check-from-corst.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0013-efi_loader-corstone1000-remove-guid-check-from-corst.patch index e57b944122..4ddb35ea54 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0015-efi_loader-corstone1000-remove-guid-check-from-corst.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0013-efi_loader-corstone1000-remove-guid-check-from-corst.patch @@ -1,7 +1,7 @@ -From 5e09d349ec8af6585bce777acbfd2d218fc2e8d4 Mon Sep 17 00:00:00 2001 +From 68248cd3cc95e0480ee2cbc3ebaba51967889199 Mon Sep 17 00:00:00 2001 From: Vishnu Banavath <vishnu.banavath@arm.com> Date: Sat, 11 Dec 2021 13:23:55 +0000 -Subject: [PATCH 15/42] efi_loader: corstone1000: remove guid check from +Subject: [PATCH 13/33] efi_loader: corstone1000: remove guid check from corstone1000 config option Use generic fmp guid and no separte check is required for @@ -15,10 +15,10 @@ Upstream-Status: Pending [Not submitted to upstream yet] 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c -index bd4cc8d272..ef7b358ddb 100644 +index ea084e4ed2..5314f529b4 100644 --- a/lib/efi_loader/efi_capsule.c +++ b/lib/efi_loader/efi_capsule.c -@@ -830,12 +830,6 @@ efi_status_t __efi_runtime EFIAPI efi_update_capsule( +@@ -852,12 +852,6 @@ efi_status_t __efi_runtime EFIAPI efi_update_capsule( i, &capsule->capsule_guid); #if CONFIG_IS_ENABLED(TARGET_CORSTONE1000) @@ -31,7 +31,7 @@ index bd4cc8d272..ef7b358ddb 100644 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"); -@@ -861,15 +855,7 @@ efi_status_t __efi_runtime EFIAPI efi_update_capsule( +@@ -883,15 +877,7 @@ efi_status_t __efi_runtime EFIAPI efi_update_capsule( goto out; #endif diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0014-efi_boottime-corstone1000-pass-interface-id-and-kern.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0014-efi_boottime-corstone1000-pass-interface-id-and-kern.patch deleted file mode 100644 index 658e21f04c..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0014-efi_boottime-corstone1000-pass-interface-id-and-kern.patch +++ /dev/null @@ -1,58 +0,0 @@ -From d761d59dd251ae93980f659d253576fc872f2c5f Mon Sep 17 00:00:00 2001 -From: Vishnu Banavath <vishnu.banavath@arm.com> -Date: Fri, 10 Dec 2021 20:10:41 +0000 -Subject: [PATCH 14/42] efi_boottime: corstone1000: pass interface id and - kernel event id using register w4 - -Initially the interface/event IDs are passed to the SP using register -w3 and w5. - -Now the SE proxy SP requires this arguments to be in register w4. - -This change is to pass interface ID(31:16) and kernel started -event ID(15:0) to SE proxy SP to trigger an event to -secure enclave just before ExitbootService(). - -Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com> -Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> -Upstream-Status: Pending [Not submitted to upstream yet] ---- - lib/efi_loader/efi_boottime.c | 13 ++++++++++--- - 1 file changed, 10 insertions(+), 3 deletions(-) - -diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c -index faab74474d..36a0be7ba1 100644 ---- a/lib/efi_loader/efi_boottime.c -+++ b/lib/efi_loader/efi_boottime.c -@@ -30,6 +30,11 @@ - #include <arm_ffa.h> - #endif - -+#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000) -+#include <linux/bitfield.h> -+#include <linux/bitops.h> -+#endif -+ - DECLARE_GLOBAL_DATA_PTR; - - /* Task priority level */ -@@ -2120,10 +2125,12 @@ static int efi_corstone1000_kernel_started_event(void) - log_debug("[%s]\n", __func__); - - /* -- * setting the kernel started event arguments -+ * setting the kernel started event arguments: -+ * setting capsule update interface ID(31:16) -+ * the kernel started event ID(15:0) - */ -- msg.data0 = CORSTONE1000_SEPROXY_UPDATE_SVC_ID; /* x3 */ -- msg.data2 = CORSTONE1000_KERNEL_STARTED_EVT; /* x5 */ -+ msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) | -+ PREP_SEPROXY_EVT(CORSTONE1000_KERNEL_STARTED_EVT); /* w4 */ - - return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg, 0); - } --- -2.25.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0016-efi_loader-populate-ESRT-table-if-EFI_ESRT-config-op.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0014-efi_loader-populate-ESRT-table-if-EFI_ESRT-config-op.patch index 1b88d7f1c3..c0b3fa82a4 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0016-efi_loader-populate-ESRT-table-if-EFI_ESRT-config-op.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0014-efi_loader-populate-ESRT-table-if-EFI_ESRT-config-op.patch @@ -1,7 +1,7 @@ -From e3ccad1cf9e905ec15ff772dcf53972fafcf54ee Mon Sep 17 00:00:00 2001 +From bb0eb602d3697384318cac90605259aa7fb21c9b Mon Sep 17 00:00:00 2001 From: Vishnu Banavath <vishnu.banavath@arm.com> Date: Fri, 17 Dec 2021 19:49:02 +0000 -Subject: [PATCH 16/42] efi_loader: populate ESRT table if EFI_ESRT config +Subject: [PATCH 14/33] efi_loader: populate ESRT table if EFI_ESRT config option is set This change is to call efi_esrt_populate function if CONFIG_EFI_ESRT @@ -15,10 +15,10 @@ Upstream-Status: Pending [Not submitted to upstream yet] 1 file changed, 7 insertions(+) diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c -index ef7b358ddb..8eb8fc406a 100644 +index 5314f529b4..6a06605ad9 100644 --- a/lib/efi_loader/efi_capsule.c +++ b/lib/efi_loader/efi_capsule.c -@@ -852,6 +852,13 @@ efi_status_t __efi_runtime EFIAPI efi_update_capsule( +@@ -874,6 +874,13 @@ efi_status_t __efi_runtime EFIAPI efi_update_capsule( ret = EFI_SUCCESS; } diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0017-efi_firmware-add-get_image_info-for-corstone1000.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0015-efi_firmware-add-get_image_info-for-corstone1000.patch index 7087315e45..2186330ebe 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0017-efi_firmware-add-get_image_info-for-corstone1000.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0015-efi_firmware-add-get_image_info-for-corstone1000.patch @@ -1,7 +1,7 @@ -From d8f79ab37bae283599e40018055ff9d5648fb647 Mon Sep 17 00:00:00 2001 +From 5e12999d179e84ac52e242d56c57a4d429651124 Mon Sep 17 00:00:00 2001 From: Vishnu Banavath <vishnu.banavath@arm.com> Date: Fri, 17 Dec 2021 19:50:25 +0000 -Subject: [PATCH 17/42] efi_firmware: add get_image_info for corstone1000 +Subject: [PATCH 15/33] efi_firmware: add get_image_info for corstone1000 This change is to populate get_image_info which eventually will be populated in ESRT table diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0019-efi_loader-fix-null-pointer-exception-with-get_image.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0016-efi_loader-fix-null-pointer-exception-with-get_image.patch index 24e5b46a5b..b58c1d7911 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0019-efi_loader-fix-null-pointer-exception-with-get_image.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0016-efi_loader-fix-null-pointer-exception-with-get_image.patch @@ -1,7 +1,7 @@ -From 3d28467e447f12c5aa276827aa742e7eed1d577a Mon Sep 17 00:00:00 2001 +From 957e88fc52d77e6a3024f06bebfaa713c9e99e59 Mon Sep 17 00:00:00 2001 From: Vishnu Banavath <vishnu.banavath@arm.com> Date: Fri, 14 Jan 2022 15:24:18 +0000 -Subject: [PATCH 19/42] efi_loader: fix null pointer exception with +Subject: [PATCH 16/33] efi_loader: fix null pointer exception with get_image_info get_img_info API implemented for corstone1000 target does not @@ -17,7 +17,7 @@ Upstream-Status: Pending [Not submitted to upstream yet] 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c -index 70568f2290..c883e2ff0a 100644 +index 0a38a96351..c883e2ff0a 100644 --- a/lib/efi_loader/efi_firmware.c +++ b/lib/efi_loader/efi_firmware.c @@ -39,26 +39,29 @@ static efi_status_t efi_corstone1000_img_info_get ( @@ -39,7 +39,7 @@ index 70568f2290..c883e2ff0a 100644 *package_version_name = NULL; /* not supported */ if(image_info == NULL) { -- log_info("image_info is null\n"); +- log_warning("image_info is null\n"); + log_debug("image_info is null\n"); return EFI_BUFFER_TOO_SMALL; } diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0020-arm-corstone1000-add-mmc-for-fvp.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0017-arm-corstone1000-add-mmc-for-fvp.patch index 93da253666..75fe64c2c3 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0020-arm-corstone1000-add-mmc-for-fvp.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0017-arm-corstone1000-add-mmc-for-fvp.patch @@ -1,7 +1,7 @@ -From d6c183a99a7d232ef5dbf886c49e7fb75b50ecf9 Mon Sep 17 00:00:00 2001 +From 61b5f50718431b5fff57fcaa924238135b11ed3c Mon Sep 17 00:00:00 2001 From: Rui Miguel Silva <rui.silva@linaro.org> -Date: Wed, 30 Nov 2022 15:37:22 +0000 -Subject: [PATCH 20/42] arm:corstone1000: add mmc for fvp +Date: Mon, 17 Jul 2023 16:50:53 +0100 +Subject: [PATCH 17/33] arm:corstone1000: add mmc for fvp Enable support mmc/sdcard for the corstone1000 FVP. @@ -10,15 +10,15 @@ Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> Upstream-Status: Pending [Not submitted to upstream yet] --- board/armltd/corstone1000/corstone1000.c | 28 +++++++++++++++++++----- - configs/corstone1000_defconfig | 8 ++++++- + configs/corstone1000_defconfig | 9 ++++++-- include/configs/corstone1000.h | 4 +++- - 3 files changed, 32 insertions(+), 8 deletions(-) + 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/board/armltd/corstone1000/corstone1000.c b/board/armltd/corstone1000/corstone1000.c -index 76816f8f4e..d6ca6e8961 100644 +index c840290885..ecfd8366df 100644 --- a/board/armltd/corstone1000/corstone1000.c +++ b/board/armltd/corstone1000/corstone1000.c -@@ -38,19 +38,35 @@ static struct mm_region corstone1000_mem_map[] = { +@@ -39,19 +39,35 @@ static struct mm_region corstone1000_mem_map[] = { }, { /* USB */ .virt = 0x40200000UL, @@ -61,14 +61,15 @@ index 76816f8f4e..d6ca6e8961 100644 /* OCVM */ .virt = 0x80000000UL, diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig -index 06eac3e041..f7c276a10a 100644 +index 40ba415ecb..76158fc37d 100644 --- a/configs/corstone1000_defconfig +++ b/configs/corstone1000_defconfig -@@ -40,7 +40,13 @@ CONFIG_VERSION_VARIABLE=y +@@ -40,8 +40,13 @@ CONFIG_VERSION_VARIABLE=y CONFIG_NET_RANDOM_ETHADDR=y CONFIG_REGMAP=y CONFIG_MISC=y -# CONFIG_MMC is not set +-CONFIG_NVMXIP_QSPI=y +CONFIG_CLK=y +CONFIG_CMD_MMC=y +CONFIG_DM_MMC=y @@ -80,11 +81,11 @@ index 06eac3e041..f7c276a10a 100644 CONFIG_PHY_SMSC=y CONFIG_SMC911X=y diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h -index be13b98d48..a015a1630e 100644 +index 8927b09499..1466507f80 100644 --- a/include/configs/corstone1000.h +++ b/include/configs/corstone1000.h -@@ -59,7 +59,9 @@ - #define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1 +@@ -49,7 +49,9 @@ + #define CFG_SYS_SDRAM_BASE PHYS_SDRAM_1 #define BOOT_TARGET_DEVICES(func) \ - func(USB, usb, 0) diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0021-corstone1000-add-compressed-kernel-support.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0018-corstone1000-add-compressed-kernel-support.patch index 7797880c3e..0f28cdf316 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0021-corstone1000-add-compressed-kernel-support.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0018-corstone1000-add-compressed-kernel-support.patch @@ -1,7 +1,7 @@ -From 155f20028ad5f3ba5d2362ec48abb7804eaade00 Mon Sep 17 00:00:00 2001 +From a5879f1e7d91fc31058ba75b499d77cab080d611 Mon Sep 17 00:00:00 2001 From: Jon Mason <jon.mason@arm.com> Date: Wed, 30 Nov 2022 18:59:59 +0000 -Subject: [PATCH 21/42] corstone1000: add compressed kernel support +Subject: [PATCH 18/33] corstone1000: add compressed kernel support The corstone1000 kernel has become too large to fit in the available storage. Swtiching to a compressed kernel avoids the problem, but @@ -17,10 +17,10 @@ Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig -index f7c276a10a..1179bf5f3b 100644 +index 76158fc37d..a92668389a 100644 --- a/configs/corstone1000_defconfig +++ b/configs/corstone1000_defconfig -@@ -15,7 +15,7 @@ CONFIG_FIT=y +@@ -15,7 +15,7 @@ CONFIG_DISTRO_DEFAULTS=y CONFIG_BOOTDELAY=3 CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="console=ttyAMA0 loglevel=9 ip=dhcp earlyprintk" diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0018-efi_loader-send-bootcomplete-message-to-secure-encla.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0018-efi_loader-send-bootcomplete-message-to-secure-encla.patch deleted file mode 100644 index 1fbad386de..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0018-efi_loader-send-bootcomplete-message-to-secure-encla.patch +++ /dev/null @@ -1,183 +0,0 @@ -From a6fee840a411a6a7b6c276d0a7b1d5445039e6c2 Mon Sep 17 00:00:00 2001 -From: Vishnu Banavath <vishnu.banavath@arm.com> -Date: Mon, 15 Aug 2022 15:46:18 +0100 -Subject: [PATCH 18/42] efi_loader: send bootcomplete message 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. - -Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> -Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Upstream-Status: Pending [Not submitted to upstream yet] ---- - include/configs/corstone1000.h | 2 +- - lib/efi_loader/efi_boottime.c | 43 ---------------------------------- - lib/efi_loader/efi_firmware.c | 2 +- - lib/efi_loader/efi_setup.c | 39 ++++++++++++++++++++++++++++++ - 4 files changed, 41 insertions(+), 45 deletions(-) - -diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h -index e4c7bcb96f..be13b98d48 100644 ---- a/include/configs/corstone1000.h -+++ b/include/configs/corstone1000.h -@@ -22,7 +22,7 @@ - - /* Notification events used with SE Proxy update service */ - #define CORSTONE1000_BUFFER_READY_EVT (0x1) --#define CORSTONE1000_KERNEL_STARTED_EVT (0x2) -+#define CORSTONE1000_UBOOT_EFI_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))) -diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c -index 36a0be7ba1..fea4eb7a34 100644 ---- a/lib/efi_loader/efi_boottime.c -+++ b/lib/efi_loader/efi_boottime.c -@@ -30,11 +30,6 @@ - #include <arm_ffa.h> - #endif - --#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000) --#include <linux/bitfield.h> --#include <linux/bitops.h> --#endif -- - DECLARE_GLOBAL_DATA_PTR; - - /* Task priority level */ -@@ -2108,35 +2103,6 @@ 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_send_direct_data msg = {0}; -- -- log_debug("[%s]\n", __func__); -- -- /* -- * setting the kernel started event arguments: -- * setting capsule update interface ID(31:16) -- * the kernel started event ID(15:0) -- */ -- msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) | -- PREP_SEPROXY_EVT(CORSTONE1000_KERNEL_STARTED_EVT); /* w4 */ -- -- return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg, 0); --} -- --#endif -- - /** - * efi_exit_boot_services() - stop all boot services - * @image_handle: handle of the loaded image -@@ -2243,15 +2209,6 @@ 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); - schedule(); -diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c -index 0a38a96351..70568f2290 100644 ---- a/lib/efi_loader/efi_firmware.c -+++ b/lib/efi_loader/efi_firmware.c -@@ -48,7 +48,7 @@ static efi_status_t efi_corstone1000_img_info_get ( - *package_version_name = NULL; /* not supported */ - - if(image_info == NULL) { -- log_warning("image_info is null\n"); -+ log_info("image_info is null\n"); - return EFI_BUFFER_TOO_SMALL; - } - -diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c -index 1ad2fa52d7..89f988b09c 100644 ---- a/lib/efi_loader/efi_setup.c -+++ b/lib/efi_loader/efi_setup.c -@@ -17,6 +17,9 @@ - efi_status_t efi_obj_list_initialized = OBJ_LIST_NOT_INITIALIZED; - - #if IS_ENABLED(CONFIG_TARGET_CORSTONE1000) -+#include <linux/bitfield.h> -+#include <linux/bitops.h> -+#include <arm_ffa.h> - /** - * efi_corstone1000_alloc_capsule_shared_buf - allocate capsule shared buffer - */ -@@ -126,6 +129,34 @@ static efi_status_t efi_init_secure_boot(void) - } - #endif /* CONFIG_EFI_SECURE_BOOT */ - -+#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000) -+/** -+ * efi_corstone1000_uboot-efi_started_event - notifies SE Proxy FW update service -+ * -+ * This function notifies the SE Proxy update service that uboot efi has already started -+ * -+ * Return: -+ * -+ * 0: on success, otherwise failure -+ * */ -+static int efi_corstone1000_uboot_efi_started_event(void) -+{ -+ struct ffa_send_direct_data msg = {0}; -+ -+ log_debug("[%s]\n", __func__); -+ -+ /* -+ * setting the kernel started event arguments: -+ * setting capsule update interface ID(31:16) -+ * the kernel started event ID(15:0) -+ */ -+ msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) | -+ PREP_SEPROXY_EVT(CORSTONE1000_UBOOT_EFI_STARTED_EVT); /* w4 */ -+ -+ return ffa_bus_ops_get()->sync_send_receive(NULL, CORSTONE1000_SEPROXY_PART_ID, &msg, 0); -+} -+#endif -+ - /** - * efi_init_capsule - initialize capsule update state - * -@@ -136,6 +167,14 @@ static efi_status_t efi_init_capsule(void) - efi_status_t ret = EFI_SUCCESS; - - #if IS_ENABLED(CONFIG_TARGET_CORSTONE1000) -+ int ffa_ret; -+ -+ ffa_ret = efi_corstone1000_uboot_efi_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"); -+ - ret = efi_corstone1000_alloc_capsule_shared_buf(); - if (ret != EFI_SUCCESS) { - printf("EFI: Corstone-1000: cannot allocate caspsule shared buffer\n"); --- -2.25.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0022-Introduce-external-sys-driver-to-device-tree.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0019-Introduce-external-sys-driver-to-device-tree.patch index c74e17fb90..a4c6625455 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0022-Introduce-external-sys-driver-to-device-tree.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0019-Introduce-external-sys-driver-to-device-tree.patch @@ -1,7 +1,7 @@ -From 984c431cd594c112d71ea1378bc1ac3b72806baa Mon Sep 17 00:00:00 2001 +From 0748658414dd02cec0219841a86c4e7b99bfc171 Mon Sep 17 00:00:00 2001 From: Emekcan <emekcan.aras@arm.com> Date: Wed, 30 Nov 2022 19:02:26 +0000 -Subject: [PATCH 22/42] Introduce external sys driver to device-tree +Subject: [PATCH 19/33] Introduce external sys driver to device-tree It adds external sys driver binding to u-boot device tree. @@ -14,10 +14,10 @@ Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> 1 file changed, 7 insertions(+) diff --git a/arch/arm/dts/corstone1000.dtsi b/arch/arm/dts/corstone1000.dtsi -index 4e46826f88..2c7185e139 100644 +index 533dfdf8e1..a834d38454 100644 --- a/arch/arm/dts/corstone1000.dtsi +++ b/arch/arm/dts/corstone1000.dtsi -@@ -160,5 +160,12 @@ +@@ -167,5 +167,12 @@ secure-status = "okay"; /* secure-world-only */ status = "disabled"; }; diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0023-Add-mhu-and-rpmsg-client-to-u-boot-device-tree.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0020-Add-mhu-and-rpmsg-client-to-u-boot-device-tree.patch index 5747d782d5..f3b1503cf3 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0023-Add-mhu-and-rpmsg-client-to-u-boot-device-tree.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0020-Add-mhu-and-rpmsg-client-to-u-boot-device-tree.patch @@ -1,7 +1,7 @@ -From 4167fe9079b64aaaf3eefc53063d242af8d2badd Mon Sep 17 00:00:00 2001 +From 396229d3d29d9cfd5e2567be5427a9066072e32f Mon Sep 17 00:00:00 2001 From: Emekcan <emekcan.aras@arm.com> Date: Mon, 12 Sep 2022 15:47:06 +0100 -Subject: [PATCH 23/42] Add mhu and rpmsg client to u-boot device tree +Subject: [PATCH 20/33] Add mhu and rpmsg client to u-boot device tree Adds external system controller and mhu driver to u-boot device tree. This enables communication between host and @@ -15,10 +15,10 @@ Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> 1 file changed, 50 insertions(+) diff --git a/arch/arm/dts/corstone1000.dtsi b/arch/arm/dts/corstone1000.dtsi -index 2c7185e139..61e0c33247 100644 +index a834d38454..18c4d1e19a 100644 --- a/arch/arm/dts/corstone1000.dtsi +++ b/arch/arm/dts/corstone1000.dtsi -@@ -161,6 +161,56 @@ +@@ -168,6 +168,56 @@ status = "disabled"; }; diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0024-arm-corstone1000-esrt-support.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0021-arm-corstone1000-esrt-support.patch index 9d569be9ca..369613eb90 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0024-arm-corstone1000-esrt-support.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0021-arm-corstone1000-esrt-support.patch @@ -1,7 +1,7 @@ -From f924535544515cdb350b2979b8c413cf221124b6 Mon Sep 17 00:00:00 2001 +From 0380dee4df6ef11bb08a9c44119b41c58afc562d Mon Sep 17 00:00:00 2001 From: Satish Kumar <satish.kumar01@arm.com> Date: Wed, 30 Nov 2022 19:11:43 +0000 -Subject: [PATCH 24/42] arm/corstone1000: esrt support +Subject: [PATCH 21/33] arm/corstone1000: esrt support The implementation is platform specific and would require change in future. @@ -20,10 +20,10 @@ Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> 3 files changed, 143 insertions(+), 9 deletions(-) diff --git a/include/efi_api.h b/include/efi_api.h -index 9bd70b0f18..23e427236a 100644 +index 55a4c989fc..f267ab5110 100644 --- a/include/efi_api.h +++ b/include/efi_api.h -@@ -2030,7 +2030,7 @@ struct efi_firmware_image_descriptor { +@@ -2086,7 +2086,7 @@ struct efi_firmware_image_descriptor { u32 last_attempt_status; u64 hardware_instance; efi_firmware_image_dep_t *dependencies; @@ -186,10 +186,10 @@ index c883e2ff0a..c6ab6e2182 100644 .set_image = efi_firmware_fit_set_image, .check_image = efi_firmware_check_image_unsupported, diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c -index 89f988b09c..08c742edbd 100644 +index bf90a98b5a..d20568c1c8 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c -@@ -167,14 +167,6 @@ static efi_status_t efi_init_capsule(void) +@@ -178,14 +178,6 @@ static efi_status_t efi_init_capsule(void) efi_status_t ret = EFI_SUCCESS; #if IS_ENABLED(CONFIG_TARGET_CORSTONE1000) @@ -197,14 +197,14 @@ index 89f988b09c..08c742edbd 100644 - - ffa_ret = efi_corstone1000_uboot_efi_started_event(); - if (ffa_ret) -- debug("[efi_boottime][ERROR]: Failure to notify SE Proxy FW update service\n"); +- log_err("Failure to notify SE Proxy FW update service\n"); - else -- debug("[efi_boottime][INFO]: SE Proxy FW update service notified\n"); +- debug("SE Proxy FW update service notified\n"); - ret = efi_corstone1000_alloc_capsule_shared_buf(); if (ret != EFI_SUCCESS) { printf("EFI: Corstone-1000: cannot allocate caspsule shared buffer\n"); -@@ -288,6 +280,15 @@ efi_status_t efi_init_obj_list(void) +@@ -304,6 +296,15 @@ efi_status_t efi_init_obj_list(void) if (ret != EFI_SUCCESS) goto out; @@ -212,9 +212,9 @@ index 89f988b09c..08c742edbd 100644 + int ffa_ret; + ffa_ret = efi_corstone1000_uboot_efi_started_event(); + if (ffa_ret) -+ debug("[efi_boottime][ERROR]: Failure to notify SE Proxy FW update service\n"); ++ log_err("Failure to notify SE Proxy FW update service\n"); + else -+ debug("[efi_boottime][INFO]: SE Proxy FW update service notified\n"); ++ debug("SE Proxy FW update service notified\n"); +#endif + /* Initialize variable services */ diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0026-corstone1000-enable-distro-booting-command.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0022-corstone1000-enable-distro-booting-command.patch index 57751b19be..6f04081cb5 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0026-corstone1000-enable-distro-booting-command.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0022-corstone1000-enable-distro-booting-command.patch @@ -1,26 +1,26 @@ -From 2a281a45b7dfc5c0e78f6256bf0ac122d825ce82 Mon Sep 17 00:00:00 2001 +From b3c9b57d862060b7d112725a567c0ff24184c6e1 Mon Sep 17 00:00:00 2001 From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> Date: Mon, 5 Dec 2022 17:02:32 +0000 -Subject: [PATCH 26/42] corstone1000: enable distro booting command +Subject: [PATCH 22/33] corstone1000: enable distro booting command enable distro_bootcmd Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Upstream-Status: Pending [Not submitted to upstream yet] Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> +Upstream-Status: Pending [Not submitted to upstream yet] --- include/configs/corstone1000.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h -index a015a1630e..c30a7bfa0c 100644 +index 1466507f80..8622565a87 100644 --- a/include/configs/corstone1000.h +++ b/include/configs/corstone1000.h -@@ -65,5 +65,6 @@ +@@ -55,5 +55,6 @@ #include <config_distro_bootcmd.h> -+#define CONFIG_EXTRA_ENV_SETTINGS BOOTENV ++#define CFG_EXTRA_ENV_SETTINGS BOOTENV #endif -- diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0033-corstone1000-add-fwu-metadata-store-info.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0023-corstone1000-add-fwu-metadata-store-info.patch index d4ed91216a..6b347962b3 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0033-corstone1000-add-fwu-metadata-store-info.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0023-corstone1000-add-fwu-metadata-store-info.patch @@ -1,7 +1,7 @@ -From e2fb90ab15babd146dd47b7c946674cd5a5260a1 Mon Sep 17 00:00:00 2001 +From 10265c2006291f961cc4fdbbffdec6c5f52bf73b Mon Sep 17 00:00:00 2001 From: Rui Miguel Silva <rui.silva@linaro.org> Date: Wed, 1 Feb 2023 15:58:07 +0000 -Subject: [PATCH 33/42] corstone1000: add fwu-metadata store info +Subject: [PATCH 23/33] corstone1000: add fwu-metadata store info Add fwu-mdata node and handle for the reference nvmxip-qspi. diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0034-fwu_metadata-make-sure-structures-are-packed.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0024-fwu_metadata-make-sure-structures-are-packed.patch index fedc1f2e1b..88566a6fbf 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0034-fwu_metadata-make-sure-structures-are-packed.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0024-fwu_metadata-make-sure-structures-are-packed.patch @@ -1,7 +1,7 @@ -From ac77679ffcb4b7fac01414c1492d3e1aae13f9be Mon Sep 17 00:00:00 2001 +From 046e54d0152987163355e33fe260419dfcf3b8bb Mon Sep 17 00:00:00 2001 From: Rui Miguel Silva <rui.silva@linaro.org> Date: Wed, 1 Feb 2023 16:13:24 +0000 -Subject: [PATCH 35/42] fwu_metadata: make sure structures are packed +Subject: [PATCH 24/33] fwu_metadata: make sure structures are packed The fwu metadata in the metadata partitions should/are packed to guarantee that the info is diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0025-corstone1000-add-boot-index.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0025-corstone1000-add-boot-index.patch new file mode 100644 index 0000000000..45ec44fb57 --- /dev/null +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0025-corstone1000-add-boot-index.patch @@ -0,0 +1,42 @@ +From 92f471d3195e3893f463b11d49f0db62793ca585 Mon Sep 17 00:00:00 2001 +From: Rui Miguel Silva <rui.silva@linaro.org> +Date: Mon, 17 Jul 2023 17:04:10 +0100 +Subject: [PATCH 25/33] corstone1000: add boot index + +it is expected that the firmware that runs before +u-boot somehow provide the information of the bank +(index) of it is booting. +We will need to extend tf-a to pass that info, +meanwhile just set it to the default bank. + +Upstream-Status: Pending +Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> +Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> +--- + board/armltd/corstone1000/corstone1000.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/board/armltd/corstone1000/corstone1000.c b/board/armltd/corstone1000/corstone1000.c +index ecfd8366df..ba6d024b80 100644 +--- a/board/armltd/corstone1000/corstone1000.c ++++ b/board/armltd/corstone1000/corstone1000.c +@@ -8,6 +8,7 @@ + #include <common.h> + #include <cpu_func.h> + #include <dm.h> ++#include <fwu.h> + #include <netdev.h> + #include <dm/platform_data/serial_pl01x.h> + #include <asm/armv8/mmu.h> +@@ -107,6 +108,7 @@ int dram_init_banksize(void) + return 0; + } + +-void reset_cpu(void) ++void fwu_plat_get_bootidx(uint *boot_idx) + { ++ *boot_idx = 0; + } +-- +2.25.1 + diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0025-efi_setup-discover-FF-A-bus-before-raising-EFI-start.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0025-efi_setup-discover-FF-A-bus-before-raising-EFI-start.patch deleted file mode 100644 index 568d9464c9..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0025-efi_setup-discover-FF-A-bus-before-raising-EFI-start.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 1f165f5b6e7d82611b55260b7254fee5fbebe539 Mon Sep 17 00:00:00 2001 -From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Date: Wed, 30 Nov 2022 19:14:52 +0000 -Subject: [PATCH 25/42] efi_setup: discover FF-A bus before raising EFI started - event - -add FF-A discovery to efi_corstone1000_uboot_efi_started_event() - -Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Upstream-Status: Pending [Not submitted to upstream yet] -Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> ---- - lib/efi_loader/efi_setup.c | 11 +++++++++-- - 1 file changed, 9 insertions(+), 2 deletions(-) - -diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c -index 08c742edbd..65bd626e49 100644 ---- a/lib/efi_loader/efi_setup.c -+++ b/lib/efi_loader/efi_setup.c -@@ -142,9 +142,16 @@ static efi_status_t efi_init_secure_boot(void) - static int efi_corstone1000_uboot_efi_started_event(void) - { - struct ffa_send_direct_data msg = {0}; -+ int ret; - - log_debug("[%s]\n", __func__); - -+ ret = ffa_bus_discover(NULL); -+ if (ret != 0) { -+ log_err("failure to discover FF-A bus\n"); -+ return ret; -+ } -+ - /* - * setting the kernel started event arguments: - * setting capsule update interface ID(31:16) -@@ -284,9 +291,9 @@ efi_status_t efi_init_obj_list(void) - int ffa_ret; - ffa_ret = efi_corstone1000_uboot_efi_started_event(); - if (ffa_ret) -- debug("[efi_boottime][ERROR]: Failure to notify SE Proxy FW update service\n"); -+ log_err("Failure to notify SE Proxy FW update service\n"); - else -- debug("[efi_boottime][INFO]: SE Proxy FW update service notified\n"); -+ debug("SE Proxy FW update service notified\n"); - #endif - - /* Initialize variable services */ --- -2.25.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0036-corstone1000-adjust-boot-bank-and-kernel-location.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0026-corstone1000-adjust-boot-bank-and-kernel-location.patch index 277e988b3f..9a889eaffb 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0036-corstone1000-adjust-boot-bank-and-kernel-location.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0026-corstone1000-adjust-boot-bank-and-kernel-location.patch @@ -1,7 +1,7 @@ -From 1a54c12aa6eed28a1a4e4f50d1aeb92a31cf6f52 Mon Sep 17 00:00:00 2001 +From 6ea58b2450c72036551e59186888474bcb54a194 Mon Sep 17 00:00:00 2001 From: Rui Miguel Silva <rui.silva@linaro.org> Date: Wed, 1 Feb 2023 16:17:21 +0000 -Subject: [PATCH 37/42] corstone1000: adjust boot bank and kernel location +Subject: [PATCH 26/33] corstone1000: adjust boot bank and kernel location Adjust in the env boot script the address of the bootbank with the new gpt layout, and also the diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0037-corstone1000-add-nvmxip-fwu-mdata-and-gpt-options.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0027-corstone1000-add-nvmxip-fwu-mdata-and-gpt-options.patch index a0f2bb16f5..621b9d17d5 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0037-corstone1000-add-nvmxip-fwu-mdata-and-gpt-options.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0027-corstone1000-add-nvmxip-fwu-mdata-and-gpt-options.patch @@ -1,7 +1,7 @@ -From 5e0b7e40c4702d5494378d3e120fce0136f69a79 Mon Sep 17 00:00:00 2001 +From af1bb3af4ff7bb9486dc9489d27605b8eded45b9 Mon Sep 17 00:00:00 2001 From: Rui Miguel Silva <rui.silva@linaro.org> -Date: Fri, 9 Jun 2023 13:28:06 +0100 -Subject: [PATCH 38/42] corstone1000: add nvmxip, fwu-mdata and gpt options +Date: Mon, 17 Jul 2023 17:33:52 +0100 +Subject: [PATCH 27/33] corstone1000: add nvmxip, fwu-mdata and gpt options Enable the newest features: nvmxip, fwu-metadata and gpt. Commands to print the partition info, gpt info @@ -10,29 +10,14 @@ and fwu metadata will be available. Upstream-Status: Pending Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> --- - configs/corstone1000_defconfig | 29 +++++++++++++++++++---------- - 1 file changed, 19 insertions(+), 10 deletions(-) + configs/corstone1000_defconfig | 21 ++++++++++++++------- + 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig -index 1179bf5f3b..c38113ce95 100644 +index a92668389a..4c75a01818 100644 --- a/configs/corstone1000_defconfig +++ b/configs/corstone1000_defconfig -@@ -4,18 +4,20 @@ CONFIG_TARGET_CORSTONE1000=y - CONFIG_TEXT_BASE=0x80000000 - CONFIG_SYS_MALLOC_LEN=0x2000000 - CONFIG_NR_DRAM_BANKS=1 -+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y -+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x83f00000 -+CONFIG_DM_GPIO=y - CONFIG_DEFAULT_DEVICE_TREE="corstone1000-mps3" - CONFIG_SYS_PROMPT="corstone1000# " - CONFIG_IDENT_STRING=" corstone1000 aarch64 " - CONFIG_SYS_LOAD_ADDR=0x82100000 -+CONFIG_FWU_NUM_IMAGES_PER_BANK=4 - CONFIG_DISTRO_DEFAULTS=y --CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y --CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x83f00000 - CONFIG_FIT=y +@@ -15,7 +15,7 @@ CONFIG_DISTRO_DEFAULTS=y CONFIG_BOOTDELAY=3 CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="console=ttyAMA0 loglevel=9 ip=dhcp earlyprintk" @@ -41,7 +26,7 @@ index 1179bf5f3b..c38113ce95 100644 CONFIG_CONSOLE_RECORD=y CONFIG_LOGLEVEL=7 # CONFIG_DISPLAY_CPUINFO is not set -@@ -23,11 +25,15 @@ CONFIG_LOGLEVEL=7 +@@ -23,11 +23,15 @@ CONFIG_LOGLEVEL=7 CONFIG_SYS_MAXARGS=64 CONFIG_SYS_CBSIZE=512 # CONFIG_CMD_CONSOLE is not set @@ -57,18 +42,12 @@ index 1179bf5f3b..c38113ce95 100644 CONFIG_CMD_USB=y # CONFIG_CMD_SETEXPR is not set # CONFIG_CMD_NFS is not set -@@ -39,27 +45,30 @@ CONFIG_OF_CONTROL=y - CONFIG_VERSION_VARIABLE=y - CONFIG_NET_RANDOM_ETHADDR=y +@@ -41,12 +45,7 @@ CONFIG_NET_RANDOM_ETHADDR=y CONFIG_REGMAP=y --CONFIG_MISC=y -+CONFIG_ARM_FFA_TRANSPORT=y + CONFIG_MISC=y CONFIG_CLK=y -CONFIG_CMD_MMC=y -CONFIG_DM_MMC=y -+CONFIG_FWU_MDATA=y -+CONFIG_FWU_MDATA_GPT_BLK=y -+CONFIG_MISC=y CONFIG_ARM_PL180_MMCI=y -CONFIG_MMC_SDHCI_ADMA_HELPERS=y -CONFIG_MMC_WRITE=y @@ -76,25 +55,21 @@ index 1179bf5f3b..c38113ce95 100644 CONFIG_PHYLIB=y CONFIG_PHY_SMSC=y CONFIG_SMC911X=y -+CONFIG_NVMXIP_QSPI=y - CONFIG_PHY=y - CONFIG_RAM=y - CONFIG_DM_RTC=y - CONFIG_RTC_EMULATION=y - CONFIG_DM_SERIAL=y -+CONFIG_SYSRESET=y - CONFIG_USB=y - CONFIG_USB_ISP1760=y - CONFIG_ERRNO_STR=y - CONFIG_EFI_MM_COMM_TEE=y - CONFIG_ARM_FFA_TRANSPORT=y +@@ -65,4 +64,12 @@ CONFIG_FFA_SHARED_MM_BUF_OFFSET=0 + CONFIG_FFA_SHARED_MM_BUF_ADDR=0x02000000 CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y -+CONFIG_EFI_CAPSULE_ON_DISK=y -+CONFIG_EFI_IGNORE_OSINDICATIONS=y CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y -CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y ++CONFIG_FWU_NUM_IMAGES_PER_BANK=4 ++CONFIG_FWU_MDATA=y ++CONFIG_FWU_MDATA_GPT_BLK=y ++CONFIG_SYSRESET=y ++CONFIG_EFI_CAPSULE_ON_DISK=y ++CONFIG_EFI_IGNORE_OSINDICATIONS=y +CONFIG_FWU_MULTI_BANK_UPDATE=y +# CONFIG_TOOLS_MKEFICAPSULE is not set ++CONFIG_DM_GPIO=y +\ No newline at end of file -- 2.25.1 diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0027-drivers-mtd-nvmxip-introduce-NVM-XIP-block-storage-e.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0027-drivers-mtd-nvmxip-introduce-NVM-XIP-block-storage-e.patch deleted file mode 100644 index 721ee15665..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0027-drivers-mtd-nvmxip-introduce-NVM-XIP-block-storage-e.patch +++ /dev/null @@ -1,455 +0,0 @@ -From c7567aaf75a66e204d492a8f6e2a3b4bfb8a7e45 Mon Sep 17 00:00:00 2001 -From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Date: Fri, 14 Apr 2023 13:23:25 +0100 -Subject: [PATCH 27/42] drivers/mtd/nvmxip: introduce NVM XIP block storage - emulation - -add block storage emulation for NVM XIP flash devices - -Some paltforms such as Corstone-1000 need to see NVM XIP raw flash -as a block storage device with read only capability. - -Here NVM flash devices are devices with addressable -memory (e.g: QSPI NOR flash). - -The implementation is generic and can be used by different platforms. - -Two drivers are provided as follows. - - nvmxip-blk : - - a generic block driver allowing to read from the XIP flash - - nvmxip Uclass driver : - - When a device is described in the DT and associated with - UCLASS_NVMXIP, the Uclass creates a block device and binds it with - the nvmxip-blk. - -Platforms can use multiple NVM XIP devices at the same time by defining a -DT node for each one of them. - -Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Upstream-Status: Backport [https://github.com/u-boot/u-boot/commit/c9c2c95d4cd27fe0cd41fe13a863899d268f973c] ---- - MAINTAINERS | 6 ++ - doc/develop/driver-model/index.rst | 1 + - doc/develop/driver-model/nvmxip.rst | 48 +++++++++++ - drivers/block/blk-uclass.c | 1 + - drivers/mtd/Kconfig | 2 + - drivers/mtd/Makefile | 1 + - drivers/mtd/nvmxip/Kconfig | 13 +++ - drivers/mtd/nvmxip/Makefile | 7 ++ - drivers/mtd/nvmxip/nvmxip-uclass.c | 67 ++++++++++++++++ - drivers/mtd/nvmxip/nvmxip.c | 119 ++++++++++++++++++++++++++++ - drivers/mtd/nvmxip/nvmxip.h | 32 ++++++++ - include/dm/uclass-id.h | 1 + - 12 files changed, 298 insertions(+) - create mode 100644 doc/develop/driver-model/nvmxip.rst - create mode 100644 drivers/mtd/nvmxip/Kconfig - create mode 100644 drivers/mtd/nvmxip/Makefile - create mode 100644 drivers/mtd/nvmxip/nvmxip-uclass.c - create mode 100644 drivers/mtd/nvmxip/nvmxip.c - create mode 100644 drivers/mtd/nvmxip/nvmxip.h - -diff --git a/MAINTAINERS b/MAINTAINERS -index a2f60a3b93..1dbfab5f43 100644 ---- a/MAINTAINERS -+++ b/MAINTAINERS -@@ -1202,6 +1202,12 @@ F: cmd/nvme.c - F: include/nvme.h - F: doc/develop/driver-model/nvme.rst - -+NVMXIP -+M: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -+S: Maintained -+F: doc/develop/driver-model/nvmxip.rst -+F: drivers/mtd/nvmxip/ -+ - NVMEM - M: Sean Anderson <seanga2@gmail.com> - S: Maintained -diff --git a/doc/develop/driver-model/index.rst b/doc/develop/driver-model/index.rst -index 7366ef818c..8e12bbd936 100644 ---- a/doc/develop/driver-model/index.rst -+++ b/doc/develop/driver-model/index.rst -@@ -20,6 +20,7 @@ subsystems - livetree - migration - nvme -+ nvmxip - of-plat - pci-info - pmic-framework -diff --git a/doc/develop/driver-model/nvmxip.rst b/doc/develop/driver-model/nvmxip.rst -new file mode 100644 -index 0000000000..fe087b13d2 ---- /dev/null -+++ b/doc/develop/driver-model/nvmxip.rst -@@ -0,0 +1,48 @@ -+.. SPDX-License-Identifier: GPL-2.0+ -+ -+NVM XIP Block Storage Emulation Driver -+======================================= -+ -+Summary -+------- -+ -+Non-Volatile Memory devices with addressable memory (e.g: QSPI NOR flash) could -+be used for block storage needs (e.g: parsing a GPT layout in a raw QSPI NOR flash). -+ -+The NVMXIP Uclass provides this functionality and can be used for any 64-bit platform. -+ -+The NVMXIP Uclass provides the following drivers: -+ -+ nvmxip-blk block driver: -+ -+ A generic block driver allowing to read from the XIP flash. -+ The driver belongs to UCLASS_BLK. -+ The driver implemented by drivers/mtd/nvmxip/nvmxip.c -+ -+ nvmxip Uclass driver: -+ -+ When a device is described in the DT and associated with UCLASS_NVMXIP, -+ the Uclass creates a block device and binds it with the nvmxip-blk. -+ The Uclass driver implemented by drivers/mtd/nvmxip/nvmxip-uclass.c -+ -+ The implementation is generic and can be used by different platforms. -+ -+Supported hardware -+-------------------------------- -+ -+Any 64-bit plaform. -+ -+Configuration -+---------------------- -+ -+config NVMXIP -+ This option allows the emulation of a block storage device -+ on top of a direct access non volatile memory XIP flash devices. -+ This support provides the read operation. -+ This option provides the block storage driver nvmxip-blk which -+ handles the read operation. This driver is HW agnostic and can support -+ multiple flash devices at the same time. -+ -+Contributors -+------------ -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c -index c69fc4d518..e8ab576c32 100644 ---- a/drivers/block/blk-uclass.c -+++ b/drivers/block/blk-uclass.c -@@ -28,6 +28,7 @@ static struct { - { UCLASS_AHCI, "sata" }, - { UCLASS_HOST, "host" }, - { UCLASS_NVME, "nvme" }, -+ { UCLASS_NVMXIP, "nvmxip" }, - { UCLASS_EFI_MEDIA, "efi" }, - { UCLASS_EFI_LOADER, "efiloader" }, - { UCLASS_VIRTIO, "virtio" }, -diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig -index fcdb450f77..0537ac64e3 100644 ---- a/drivers/mtd/Kconfig -+++ b/drivers/mtd/Kconfig -@@ -224,4 +224,6 @@ source "drivers/mtd/spi/Kconfig" - - source "drivers/mtd/ubi/Kconfig" - -+source "drivers/mtd/nvmxip/Kconfig" -+ - endmenu -diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile -index 3a78590aaa..c638980ea2 100644 ---- a/drivers/mtd/Makefile -+++ b/drivers/mtd/Makefile -@@ -25,6 +25,7 @@ obj-y += nand/ - obj-y += onenand/ - obj-y += spi/ - obj-$(CONFIG_MTD_UBI) += ubi/ -+obj-$(CONFIG_NVMXIP) += nvmxip/ - - #SPL/TPL build - else -diff --git a/drivers/mtd/nvmxip/Kconfig b/drivers/mtd/nvmxip/Kconfig -new file mode 100644 -index 0000000000..ef53fc3c79 ---- /dev/null -+++ b/drivers/mtd/nvmxip/Kconfig -@@ -0,0 +1,13 @@ -+# SPDX-License-Identifier: GPL-2.0+ -+# -+# Copyright 2023 Arm Limited and/or its affiliates <open-source-office@arm.com> -+# Authors: -+# Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -+ -+config NVMXIP -+ bool "NVM XIP devices support" -+ select BLK -+ help -+ This option allows the emulation of a block storage device -+ on top of a direct access non volatile memory XIP flash devices. -+ This support provides the read operation. -diff --git a/drivers/mtd/nvmxip/Makefile b/drivers/mtd/nvmxip/Makefile -new file mode 100644 -index 0000000000..07890982c7 ---- /dev/null -+++ b/drivers/mtd/nvmxip/Makefile -@@ -0,0 +1,7 @@ -+# SPDX-License-Identifier: GPL-2.0+ -+# -+# Copyright 2023 Arm Limited and/or its affiliates <open-source-office@arm.com> -+# Authors: -+# Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -+ -+obj-y += nvmxip-uclass.o nvmxip.o -diff --git a/drivers/mtd/nvmxip/nvmxip-uclass.c b/drivers/mtd/nvmxip/nvmxip-uclass.c -new file mode 100644 -index 0000000000..9f96041e3d ---- /dev/null -+++ b/drivers/mtd/nvmxip/nvmxip-uclass.c -@@ -0,0 +1,67 @@ -+// SPDX-License-Identifier: GPL-2.0+ -+/* -+ * Copyright 2023 Arm Limited and/or its affiliates <open-source-office@arm.com> -+ * -+ * Authors: -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -+ */ -+ -+#include <common.h> -+#include <dm.h> -+#include <log.h> -+#include <linux/bitops.h> -+#include "nvmxip.h" -+ -+/* LBA Macros */ -+ -+#define DEFAULT_LBA_SHIFT 10 /* 1024 bytes per block */ -+#define DEFAULT_LBA_COUNT 1024 /* block count */ -+ -+#define DEFAULT_LBA_SZ BIT(DEFAULT_LBA_SHIFT) -+ -+/** -+ * nvmxip_post_bind() - post binding treatments -+ * @dev: the NVMXIP device -+ * -+ * Create and probe a child block device. -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+static int nvmxip_post_bind(struct udevice *udev) -+{ -+ int ret; -+ struct udevice *bdev = NULL; -+ char bdev_name[NVMXIP_BLKDEV_NAME_SZ + 1]; -+ int devnum; -+ -+ devnum = uclass_id_count(UCLASS_NVMXIP); -+ snprintf(bdev_name, NVMXIP_BLKDEV_NAME_SZ, "blk#%d", devnum); -+ -+ ret = blk_create_devicef(udev, NVMXIP_BLKDRV_NAME, bdev_name, UCLASS_NVMXIP, -+ devnum, DEFAULT_LBA_SZ, -+ DEFAULT_LBA_COUNT, &bdev); -+ if (ret) { -+ log_err("[%s]: failure during creation of the block device %s, error %d\n", -+ udev->name, bdev_name, ret); -+ return ret; -+ } -+ -+ ret = blk_probe_or_unbind(bdev); -+ if (ret) { -+ log_err("[%s]: failure during probing the block device %s, error %d\n", -+ udev->name, bdev_name, ret); -+ return ret; -+ } -+ -+ log_info("[%s]: the block device %s ready for use\n", udev->name, bdev_name); -+ -+ return 0; -+} -+ -+UCLASS_DRIVER(nvmxip) = { -+ .name = "nvmxip", -+ .id = UCLASS_NVMXIP, -+ .post_bind = nvmxip_post_bind, -+}; -diff --git a/drivers/mtd/nvmxip/nvmxip.c b/drivers/mtd/nvmxip/nvmxip.c -new file mode 100644 -index 0000000000..a359e3b482 ---- /dev/null -+++ b/drivers/mtd/nvmxip/nvmxip.c -@@ -0,0 +1,119 @@ -+// SPDX-License-Identifier: GPL-2.0+ -+/* -+ * Copyright 2023 Arm Limited and/or its affiliates <open-source-office@arm.com> -+ * -+ * Authors: -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -+ */ -+ -+#include <common.h> -+#include <dm.h> -+#include <log.h> -+#include <mapmem.h> -+#include <asm/io.h> -+#include <linux/bitops.h> -+#include <linux/errno.h> -+#include "nvmxip.h" -+ -+/** -+ * nvmxip_mmio_rawread() - read from the XIP flash -+ * @address: address of the data -+ * @value: pointer to where storing the value read -+ * -+ * Read raw data from the XIP flash. -+ * -+ * Return: -+ * -+ * Always return 0. -+ */ -+static int nvmxip_mmio_rawread(const phys_addr_t address, u64 *value) -+{ -+ *value = readq(address); -+ return 0; -+} -+ -+/** -+ * nvmxip_blk_read() - block device read operation -+ * @dev: the block device -+ * @blknr: first block number to read from -+ * @blkcnt: number of blocks to read -+ * @buffer: destination buffer -+ * -+ * Read data from the block storage device. -+ * -+ * Return: -+ * -+ * number of blocks read on success. Otherwise, failure -+ */ -+static ulong nvmxip_blk_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer) -+{ -+ struct nvmxip_plat *plat = dev_get_plat(dev->parent); -+ struct blk_desc *desc = dev_get_uclass_plat(dev); -+ /* number of the u64 words to read */ -+ u32 qwords = (blkcnt * desc->blksz) / sizeof(u64); -+ /* physical address of the first block to read */ -+ phys_addr_t blkaddr = plat->phys_base + blknr * desc->blksz; -+ u64 *virt_blkaddr; -+ u64 *pdst = buffer; -+ uint qdata_idx; -+ -+ if (!pdst) -+ return -EINVAL; -+ -+ log_debug("[%s]: reading from blknr: %lu , blkcnt: %lu\n", dev->name, blknr, blkcnt); -+ -+ virt_blkaddr = map_sysmem(blkaddr, 0); -+ -+ /* assumption: the data is virtually contiguous */ -+ -+ for (qdata_idx = 0 ; qdata_idx < qwords ; qdata_idx++) -+ nvmxip_mmio_rawread((phys_addr_t)(virt_blkaddr + qdata_idx), pdst++); -+ -+ log_debug("[%s]: src[0]: 0x%llx , dst[0]: 0x%llx , src[-1]: 0x%llx , dst[-1]: 0x%llx\n", -+ dev->name, -+ *virt_blkaddr, -+ *(u64 *)buffer, -+ *(u64 *)((u8 *)virt_blkaddr + desc->blksz * blkcnt - sizeof(u64)), -+ *(u64 *)((u8 *)buffer + desc->blksz * blkcnt - sizeof(u64))); -+ -+ unmap_sysmem(virt_blkaddr); -+ -+ return blkcnt; -+} -+ -+/** -+ * nvmxip_blk_probe() - block storage device probe -+ * @dev: the block storage device -+ * -+ * Initialize the block storage descriptor. -+ * -+ * Return: -+ * -+ * Always return 0. -+ */ -+static int nvmxip_blk_probe(struct udevice *dev) -+{ -+ struct nvmxip_plat *plat = dev_get_plat(dev->parent); -+ struct blk_desc *desc = dev_get_uclass_plat(dev); -+ -+ desc->lba = plat->lba; -+ desc->log2blksz = plat->lba_shift; -+ desc->blksz = BIT(plat->lba_shift); -+ desc->bdev = dev; -+ -+ log_debug("[%s]: block storage layout\n lbas: %lu , log2blksz: %d, blksz: %lu\n", -+ dev->name, desc->lba, desc->log2blksz, desc->blksz); -+ -+ return 0; -+} -+ -+static const struct blk_ops nvmxip_blk_ops = { -+ .read = nvmxip_blk_read, -+}; -+ -+U_BOOT_DRIVER(nvmxip_blk) = { -+ .name = NVMXIP_BLKDRV_NAME, -+ .id = UCLASS_BLK, -+ .probe = nvmxip_blk_probe, -+ .ops = &nvmxip_blk_ops, -+}; -diff --git a/drivers/mtd/nvmxip/nvmxip.h b/drivers/mtd/nvmxip/nvmxip.h -new file mode 100644 -index 0000000000..f4ef37725d ---- /dev/null -+++ b/drivers/mtd/nvmxip/nvmxip.h -@@ -0,0 +1,32 @@ -+/* SPDX-License-Identifier: GPL-2.0+ */ -+/* -+ * Copyright 2023 Arm Limited and/or its affiliates <open-source-office@arm.com> -+ * -+ * Authors: -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -+ */ -+ -+#ifndef __DRIVER_NVMXIP_H__ -+#define __DRIVER_NVMXIP_H__ -+ -+#include <blk.h> -+ -+#define NVMXIP_BLKDRV_NAME "nvmxip-blk" -+#define NVMXIP_BLKDEV_NAME_SZ 20 -+ -+/** -+ * struct nvmxip_plat - the NVMXIP driver plat -+ * -+ * @phys_base: NVM XIP device base address -+ * @lba_shift: block size shift count -+ * @lba: number of blocks -+ * -+ * The NVMXIP information read from the DT. -+ */ -+struct nvmxip_plat { -+ phys_addr_t phys_base; -+ u32 lba_shift; -+ lbaint_t lba; -+}; -+ -+#endif /* __DRIVER_NVMXIP_H__ */ -diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h -index fa08a66ac8..f3564a49d9 100644 ---- a/include/dm/uclass-id.h -+++ b/include/dm/uclass-id.h -@@ -92,6 +92,7 @@ enum uclass_id { - UCLASS_NOP, /* No-op devices */ - UCLASS_NORTHBRIDGE, /* Intel Northbridge / SDRAM controller */ - UCLASS_NVME, /* NVM Express device */ -+ UCLASS_NVMXIP, /* NVM XIP devices */ - UCLASS_P2SB, /* (x86) Primary-to-Sideband Bus */ - UCLASS_PANEL, /* Display panel, such as an LCD */ - UCLASS_PANEL_BACKLIGHT, /* Backlight controller for panel */ --- -2.25.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0028-drivers-mtd-nvmxip-introduce-QSPI-XIP-driver.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0028-drivers-mtd-nvmxip-introduce-QSPI-XIP-driver.patch deleted file mode 100644 index aa3db9cb5e..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0028-drivers-mtd-nvmxip-introduce-QSPI-XIP-driver.patch +++ /dev/null @@ -1,271 +0,0 @@ -From 4b71ade0e8e5ad3692b1decb5c1d0c9472827535 Mon Sep 17 00:00:00 2001 -From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Date: Fri, 14 Apr 2023 13:44:25 +0100 -Subject: [PATCH 28/42] drivers/mtd/nvmxip: introduce QSPI XIP driver - -add nvmxip_qspi driver under UCLASS_NVMXIP - -The device associated with this driver is the parent of the blk#<id> device -nvmxip_qspi can be reused by other platforms. If the platform -has custom settings to apply before using the flash, then the platform -can provide its own parent driver belonging to UCLASS_NVMXIP and reuse -nvmxip-blk driver. The custom driver can be implemented like nvmxip_qspi in -addition to the platform custom settings. - -Platforms can use multiple NVM XIP devices at the same time by defining a -DT node for each one of them. - -For more details please refer to doc/develop/driver-model/nvmxip_qspi.rst - -Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Upstream-Status: Backport [https://github.com/u-boot/u-boot/commit/c9c2c95d4cd27fe0cd41fe13a863899d268f973c] ---- - MAINTAINERS | 1 + - doc/develop/driver-model/nvmxip.rst | 45 +++++++++++- - .../nvmxip/nvmxip_qspi.txt | 56 +++++++++++++++ - drivers/mtd/nvmxip/Kconfig | 6 ++ - drivers/mtd/nvmxip/Makefile | 1 + - drivers/mtd/nvmxip/nvmxip_qspi.c | 70 +++++++++++++++++++ - 6 files changed, 178 insertions(+), 1 deletion(-) - create mode 100644 doc/device-tree-bindings/nvmxip/nvmxip_qspi.txt - create mode 100644 drivers/mtd/nvmxip/nvmxip_qspi.c - -diff --git a/MAINTAINERS b/MAINTAINERS -index 1dbfab5f43..f81654346e 100644 ---- a/MAINTAINERS -+++ b/MAINTAINERS -@@ -1206,6 +1206,7 @@ NVMXIP - M: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> - S: Maintained - F: doc/develop/driver-model/nvmxip.rst -+F: doc/device-tree-bindings/nvmxip/nvmxip_qspi.txt - F: drivers/mtd/nvmxip/ - - NVMEM -diff --git a/doc/develop/driver-model/nvmxip.rst b/doc/develop/driver-model/nvmxip.rst -index fe087b13d2..09afdbcccf 100644 ---- a/doc/develop/driver-model/nvmxip.rst -+++ b/doc/develop/driver-model/nvmxip.rst -@@ -25,7 +25,33 @@ The NVMXIP Uclass provides the following drivers: - the Uclass creates a block device and binds it with the nvmxip-blk. - The Uclass driver implemented by drivers/mtd/nvmxip/nvmxip-uclass.c - -- The implementation is generic and can be used by different platforms. -+ nvmxip_qspi driver : -+ -+ The driver probed with the DT and is the parent of the blk#<id> device. -+ nvmxip_qspi can be reused by other platforms. If the platform -+ has custom settings to apply before using the flash, then the platform -+ can provide its own parent driver belonging to UCLASS_NVMXIP and reuse -+ nvmxip-blk. The custom driver can be implemented like nvmxip_qspi in -+ addition to the platform custom settings. -+ The nvmxip_qspi driver belongs to UCLASS_NVMXIP. -+ The driver implemented by drivers/mtd/nvmxip/nvmxip_qspi.c -+ -+ For example, if we have two NVMXIP devices described in the DT -+ The devices hierarchy is as follows: -+ -+:: -+ -+ => dm tree -+ -+ Class Index Probed Driver Name -+ ----------------------------------------------------------- -+ ... -+ nvmxip 0 [ + ] nvmxip_qspi |-- nvmxip-qspi1@08000000 -+ blk 3 [ + ] nvmxip-blk | `-- nvmxip-qspi1@08000000.blk#1 -+ nvmxip 1 [ + ] nvmxip_qspi |-- nvmxip-qspi2@08200000 -+ blk 4 [ + ] nvmxip-blk | `-- nvmxip-qspi2@08200000.blk#2 -+ -+The implementation is generic and can be used by different platforms. - - Supported hardware - -------------------------------- -@@ -43,6 +69,23 @@ config NVMXIP - handles the read operation. This driver is HW agnostic and can support - multiple flash devices at the same time. - -+config NVMXIP_QSPI -+ This option allows the emulation of a block storage device on top of a QSPI XIP flash. -+ Any platform that needs to emulate one or multiple QSPI XIP flash devices can turn this -+ option on to enable the functionality. NVMXIP config is selected automatically. -+ Platforms that need to add custom treatments before accessing to the flash, can -+ write their own driver (same as nvmxip_qspi in addition to the custom settings). -+ -+Device Tree nodes -+-------------------- -+ -+Multiple QSPI XIP flash devices can be used at the same time by describing them through DT -+nodes. -+ -+Please refer to the documentation of the DT binding at: -+ -+doc/device-tree-bindings/nvmxip/nvmxip_qspi.txt -+ - Contributors - ------------ - * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -diff --git a/doc/device-tree-bindings/nvmxip/nvmxip_qspi.txt b/doc/device-tree-bindings/nvmxip/nvmxip_qspi.txt -new file mode 100644 -index 0000000000..cc60e9efdc ---- /dev/null -+++ b/doc/device-tree-bindings/nvmxip/nvmxip_qspi.txt -@@ -0,0 +1,56 @@ -+Specifying NVMXIP information for devices -+====================================== -+ -+QSPI XIP flash device nodes -+--------------------------- -+ -+Each flash device should have its own node. -+ -+Each node must specify the following fields: -+ -+1) -+ compatible = "nvmxip,qspi"; -+ -+This allows to bind the flash device with the nvmxip_qspi driver -+If a platform has its own driver, please provide your own compatible -+string. -+ -+2) -+ reg = <0x0 0x08000000 0x0 0x00200000>; -+ -+The start address and size of the flash device. The values give here are an -+example (when the cell size is 2). -+ -+When cell size is 1, the reg field looks like this: -+ -+ reg = <0x08000000 0x00200000>; -+ -+3) -+ -+ lba_shift = <9>; -+ -+The number of bit shifts used to calculate the size in bytes of one block. -+In this example the block size is 1 << 9 = 2 ^ 9 = 512 bytes -+ -+4) -+ -+ lba = <4096>; -+ -+The number of blocks. -+ -+Example of multiple flash devices -+---------------------------------------------------- -+ -+ nvmxip-qspi1@08000000 { -+ compatible = "nvmxip,qspi"; -+ reg = <0x0 0x08000000 0x0 0x00200000>; -+ lba_shift = <9>; -+ lba = <4096>; -+ }; -+ -+ nvmxip-qspi2@08200000 { -+ compatible = "nvmxip,qspi"; -+ reg = <0x0 0x08200000 0x0 0x00100000>; -+ lba_shift = <9>; -+ lba = <2048>; -+ }; -diff --git a/drivers/mtd/nvmxip/Kconfig b/drivers/mtd/nvmxip/Kconfig -index ef53fc3c79..3ef7105026 100644 ---- a/drivers/mtd/nvmxip/Kconfig -+++ b/drivers/mtd/nvmxip/Kconfig -@@ -11,3 +11,9 @@ config NVMXIP - This option allows the emulation of a block storage device - on top of a direct access non volatile memory XIP flash devices. - This support provides the read operation. -+ -+config NVMXIP_QSPI -+ bool "QSPI XIP support" -+ select NVMXIP -+ help -+ This option allows the emulation of a block storage device on top of a QSPI XIP flash -diff --git a/drivers/mtd/nvmxip/Makefile b/drivers/mtd/nvmxip/Makefile -index 07890982c7..54eacc102e 100644 ---- a/drivers/mtd/nvmxip/Makefile -+++ b/drivers/mtd/nvmxip/Makefile -@@ -5,3 +5,4 @@ - # Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> - - obj-y += nvmxip-uclass.o nvmxip.o -+obj-$(CONFIG_NVMXIP_QSPI) += nvmxip_qspi.o -diff --git a/drivers/mtd/nvmxip/nvmxip_qspi.c b/drivers/mtd/nvmxip/nvmxip_qspi.c -new file mode 100644 -index 0000000000..7221fd1cb4 ---- /dev/null -+++ b/drivers/mtd/nvmxip/nvmxip_qspi.c -@@ -0,0 +1,70 @@ -+// SPDX-License-Identifier: GPL-2.0+ -+/* -+ * Copyright 2023 Arm Limited and/or its affiliates <open-source-office@arm.com> -+ * -+ * Authors: -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -+ */ -+ -+#include <common.h> -+#include <dm.h> -+#include <fdt_support.h> -+#include <linux/errno.h> -+#include "nvmxip.h" -+ -+#include <asm/global_data.h> -+DECLARE_GLOBAL_DATA_PTR; -+ -+#define NVMXIP_QSPI_DRV_NAME "nvmxip_qspi" -+ -+/** -+ * nvmxip_qspi_of_to_plat() -read from DT -+ * @dev: the NVMXIP device -+ * -+ * Read from the DT the NVMXIP information. -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+static int nvmxip_qspi_of_to_plat(struct udevice *dev) -+{ -+ struct nvmxip_plat *plat = dev_get_plat(dev); -+ int ret; -+ -+ plat->phys_base = (phys_addr_t)dev_read_addr(dev); -+ if (plat->phys_base == FDT_ADDR_T_NONE) { -+ log_err("[%s]: can not get base address from device tree\n", dev->name); -+ return -EINVAL; -+ } -+ -+ ret = dev_read_u32(dev, "lba_shift", &plat->lba_shift); -+ if (ret) { -+ log_err("[%s]: can not get lba_shift from device tree\n", dev->name); -+ return -EINVAL; -+ } -+ -+ ret = dev_read_u32(dev, "lba", (u32 *)&plat->lba); -+ if (ret) { -+ log_err("[%s]: can not get lba from device tree\n", dev->name); -+ return -EINVAL; -+ } -+ -+ log_debug("[%s]: XIP device base addr: 0x%llx , lba_shift: %d , lbas: %lu\n", -+ dev->name, plat->phys_base, plat->lba_shift, plat->lba); -+ -+ return 0; -+} -+ -+static const struct udevice_id nvmxip_qspi_ids[] = { -+ { .compatible = "nvmxip,qspi" }, -+ { /* sentinel */ } -+}; -+ -+U_BOOT_DRIVER(nvmxip_qspi) = { -+ .name = NVMXIP_QSPI_DRV_NAME, -+ .id = UCLASS_NVMXIP, -+ .of_match = nvmxip_qspi_ids, -+ .of_to_plat = nvmxip_qspi_of_to_plat, -+ .plat_auto = sizeof(struct nvmxip_plat), -+}; --- -2.25.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0038-nvmxip-move-header-to-include.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0028-nvmxip-move-header-to-include.patch index b745fe9b6b..aac5a1d25d 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0038-nvmxip-move-header-to-include.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0028-nvmxip-move-header-to-include.patch @@ -1,7 +1,7 @@ -From d280414229d7bbee368f40be6cde17e4f251dd0f Mon Sep 17 00:00:00 2001 +From 050c2d8577fd98f20c8b96dab3e4c42c8508b6bc Mon Sep 17 00:00:00 2001 From: Rui Miguel Silva <rui.silva@linaro.org> Date: Fri, 9 Jun 2023 13:31:53 +0100 -Subject: [PATCH 39/42] nvmxip: move header to include +Subject: [PATCH 28/33] nvmxip: move header to include Move header to include to allow external code to get the internal bdev structures to access @@ -20,10 +20,10 @@ Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> rename {drivers/mtd/nvmxip => include}/nvmxip.h (100%) diff --git a/disk/part.c b/disk/part.c -index 5ee60a7fb5..593dd0004f 100644 +index 35300df590..f57dce7a29 100644 --- a/disk/part.c +++ b/disk/part.c -@@ -270,6 +270,9 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc) +@@ -271,6 +271,9 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc) case UCLASS_NVME: puts ("NVMe"); break; diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0039-corstone1000-set-kernel_addr-based-on-boot_idx.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0029-corstone1000-set-kernel_addr-based-on-boot_idx.patch index ba2e5e17fe..6ad4648566 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0039-corstone1000-set-kernel_addr-based-on-boot_idx.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0029-corstone1000-set-kernel_addr-based-on-boot_idx.patch @@ -1,7 +1,7 @@ -From e7cb997fd59c883572994b504dbc77bc670de8f7 Mon Sep 17 00:00:00 2001 +From c547f3335ddff71a7f4915dc0c99ccbcdbf24b54 Mon Sep 17 00:00:00 2001 From: Rui Miguel Silva <rui.silva@linaro.org> -Date: Thu, 23 Feb 2023 10:35:00 +0000 -Subject: [PATCH 40/42] corstone1000: set kernel_addr based on boot_idx +Date: Tue, 18 Jul 2023 12:14:47 +0100 +Subject: [PATCH 29/33] corstone1000: set kernel_addr based on boot_idx We need to distinguish between boot banks and from which partition to load the kernel+initramfs to memory. @@ -19,17 +19,19 @@ Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> 3 files changed, 58 insertions(+), 9 deletions(-) diff --git a/board/armltd/corstone1000/corstone1000.c b/board/armltd/corstone1000/corstone1000.c -index 0a58ccd99c..b767195ccc 100644 +index ba6d024b80..a045262ebb 100644 --- a/board/armltd/corstone1000/corstone1000.c +++ b/board/armltd/corstone1000/corstone1000.c -@@ -5,13 +5,23 @@ +@@ -5,15 +5,25 @@ * Rui Miguel Silva <rui.silva@linaro.org> */ +#include <blk.h> #include <common.h> + #include <cpu_func.h> #include <dm.h> +#include <env.h> + #include <fwu.h> #include <netdev.h> +#include <nvmxip.h> +#include <part.h> @@ -46,9 +48,9 @@ index 0a58ccd99c..b767195ccc 100644 static struct mm_region corstone1000_mem_map[] = { { /* CVM */ -@@ -108,5 +118,51 @@ int dram_init_banksize(void) +@@ -110,5 +120,51 @@ int dram_init_banksize(void) - void fwu_plat_get_bootidx(int *boot_idx) + void fwu_plat_get_bootidx(uint *boot_idx) { - *boot_idx = 0; + *boot_idx = corstone1000_boot_idx; @@ -117,10 +119,10 @@ index a6ee496221..ee318b1b1c 100644 - fi; kernel_addr_r=0x88200000 diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig -index c38113ce95..20359cb181 100644 +index 4c75a01818..0232131a11 100644 --- a/configs/corstone1000_defconfig +++ b/configs/corstone1000_defconfig -@@ -22,6 +22,7 @@ CONFIG_CONSOLE_RECORD=y +@@ -20,6 +20,7 @@ CONFIG_CONSOLE_RECORD=y CONFIG_LOGLEVEL=7 # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0029-sandbox64-fix-return-unsigned-long-in-readq.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0029-sandbox64-fix-return-unsigned-long-in-readq.patch deleted file mode 100644 index c90bcc7834..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0029-sandbox64-fix-return-unsigned-long-in-readq.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 1b80dfbefd59c8ddff77960552d6c0cc2747758c Mon Sep 17 00:00:00 2001 -From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Date: Fri, 16 Dec 2022 17:20:58 +0000 -Subject: [PATCH 29/42] sandbox64: fix: return unsigned long in readq() - -make readq return unsigned long - -readq should return 64-bit data - -Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Upstream-Status: Backport [https://github.com/u-boot/u-boot/commit/c9c2c95d4cd27fe0cd41fe13a863899d268f973c] ---- - arch/sandbox/cpu/cpu.c | 2 +- - arch/sandbox/include/asm/io.h | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c -index 636d3545b9..248d17a85c 100644 ---- a/arch/sandbox/cpu/cpu.c -+++ b/arch/sandbox/cpu/cpu.c -@@ -230,7 +230,7 @@ phys_addr_t map_to_sysmem(const void *ptr) - return mentry->tag; - } - --unsigned int sandbox_read(const void *addr, enum sandboxio_size_t size) -+unsigned long sandbox_read(const void *addr, enum sandboxio_size_t size) - { - struct sandbox_state *state = state_get_current(); - -diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h -index ad6c29a4e2..31ab7289b4 100644 ---- a/arch/sandbox/include/asm/io.h -+++ b/arch/sandbox/include/asm/io.h -@@ -45,7 +45,7 @@ static inline void unmap_sysmem(const void *vaddr) - /* Map from a pointer to our RAM buffer */ - phys_addr_t map_to_sysmem(const void *ptr); - --unsigned int sandbox_read(const void *addr, enum sandboxio_size_t size); -+unsigned long sandbox_read(const void *addr, enum sandboxio_size_t size); - void sandbox_write(void *addr, unsigned int val, enum sandboxio_size_t size); - - #define readb(addr) sandbox_read((const void *)addr, SB_SIZE_8) --- -2.25.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0040-corstone1000-boot-index-from-active.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0030-corstone1000-boot-index-from-active.patch index f0e14942ad..e59a434bb9 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0040-corstone1000-boot-index-from-active.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0030-corstone1000-boot-index-from-active.patch @@ -1,7 +1,7 @@ -From ab07a26290e44fb198403b658b8f1550e959a0cc Mon Sep 17 00:00:00 2001 +From faeeeecba2a7c8c507280ce369e3779f7c63d1e4 Mon Sep 17 00:00:00 2001 From: Rui Miguel Silva <rui.silva@linaro.org> Date: Mon, 27 Feb 2023 14:40:13 +0000 -Subject: [PATCH 41/42] corstone1000: boot index from active +Subject: [PATCH 30/33] corstone1000: boot index from active In our platform, the Secure Enclave is the one who control all the boot tries and status, so, every time we get here @@ -9,17 +9,18 @@ we know that the we are booting from the active index. Upstream-Status: Pending Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> +Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> --- - board/armltd/corstone1000/corstone1000.c | 13 ++++++++++++- - 1 file changed, 12 insertions(+), 1 deletion(-) + board/armltd/corstone1000/corstone1000.c | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/board/armltd/corstone1000/corstone1000.c b/board/armltd/corstone1000/corstone1000.c -index b767195ccc..db508ac3cb 100644 +index a045262ebb..53c65506d5 100644 --- a/board/armltd/corstone1000/corstone1000.c +++ b/board/armltd/corstone1000/corstone1000.c -@@ -118,7 +118,18 @@ int dram_init_banksize(void) +@@ -120,7 +120,16 @@ int dram_init_banksize(void) - void fwu_plat_get_bootidx(int *boot_idx) + void fwu_plat_get_bootidx(uint *boot_idx) { - *boot_idx = corstone1000_boot_idx; + int ret; @@ -31,9 +32,7 @@ index b767195ccc..db508ac3cb 100644 + */ + ret = fwu_get_active_index(boot_idx); + if (ret < 0) -+ log_err("corstone1000: failed to read active index\n"); -+ -+ return ret; ++ log_err("corstone1000: failed to read active index err %d\n", ret); } int board_late_init(void) diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0030-sandbox64-add-support-for-NVMXIP-QSPI.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0030-sandbox64-add-support-for-NVMXIP-QSPI.patch deleted file mode 100644 index 941e9d10b8..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0030-sandbox64-add-support-for-NVMXIP-QSPI.patch +++ /dev/null @@ -1,161 +0,0 @@ -From 25467e433f02f40f5999ed6e6b0d3adb4c9cf16d Mon Sep 17 00:00:00 2001 -From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Date: Fri, 9 Jun 2023 13:08:37 +0100 -Subject: [PATCH 30/42] sandbox64: add support for NVMXIP QSPI - -enable NVMXIP QSPI for sandbox 64-bit - -Adding two NVM XIP QSPI storage devices. - -Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Reviewed-by: Simon Glass <sjg@chromium.org> -Upstream-Status: Backport [https://github.com/u-boot/u-boot/commit/c9c2c95d4cd27fe0cd41fe13a863899d268f973c] - -Changelog: -=============== - -v2: - -* address nits ---- - arch/sandbox/dts/sandbox64.dts | 13 +++++++++++++ - arch/sandbox/dts/test.dts | 14 ++++++++++++++ - configs/sandbox64_defconfig | 3 ++- - doc/develop/driver-model/nvmxip.rst | 2 +- - doc/device-tree-bindings/nvmxip/nvmxip_qspi.txt | 6 +++--- - drivers/mtd/nvmxip/nvmxip-uclass.c | 7 +++++++ - 6 files changed, 40 insertions(+), 5 deletions(-) - -diff --git a/arch/sandbox/dts/sandbox64.dts b/arch/sandbox/dts/sandbox64.dts -index 3eb0457089..c9a2f4b4a4 100644 ---- a/arch/sandbox/dts/sandbox64.dts -+++ b/arch/sandbox/dts/sandbox64.dts -@@ -89,6 +89,19 @@ - cs-gpios = <0>, <&gpio_a 0>; - }; - -+ nvmxip-qspi1@08000000 { -+ compatible = "nvmxip,qspi"; -+ reg = /bits/ 64 <0x08000000 0x00200000>; -+ lba_shift = <9>; -+ lba = <4096>; -+ }; -+ -+ nvmxip-qspi2@08200000 { -+ compatible = "nvmxip,qspi"; -+ reg = /bits/ 64 <0x08200000 0x00100000>; -+ lba_shift = <9>; -+ lba = <2048>; -+ }; - }; - - #include "sandbox.dtsi" -diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts -index dffe10adbf..c3ba0a225e 100644 ---- a/arch/sandbox/dts/test.dts -+++ b/arch/sandbox/dts/test.dts -@@ -1745,6 +1745,20 @@ - compatible = "u-boot,fwu-mdata-gpt"; - fwu-mdata-store = <&mmc0>; - }; -+ -+ nvmxip-qspi1@08000000 { -+ compatible = "nvmxip,qspi"; -+ reg = <0x08000000 0x00200000>; -+ lba_shift = <9>; -+ lba = <4096>; -+ }; -+ -+ nvmxip-qspi2@08200000 { -+ compatible = "nvmxip,qspi"; -+ reg = <0x08200000 0x00100000>; -+ lba_shift = <9>; -+ lba = <2048>; -+ }; - }; - - #include "sandbox_pmic.dtsi" -diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig -index 4b8a1ec42b..2dca176ae3 100644 ---- a/configs/sandbox64_defconfig -+++ b/configs/sandbox64_defconfig -@@ -260,4 +260,5 @@ CONFIG_UNIT_TEST=y - CONFIG_UT_TIME=y - CONFIG_UT_DM=y - CONFIG_ARM_FFA_TRANSPORT=y --CONFIG_SANDBOX_FFA=y -\ No newline at end of file -+CONFIG_SANDBOX_FFA=y -+CONFIG_NVMXIP_QSPI=y -\ No newline at end of file -diff --git a/doc/develop/driver-model/nvmxip.rst b/doc/develop/driver-model/nvmxip.rst -index 09afdbcccf..e85dc220b9 100644 ---- a/doc/develop/driver-model/nvmxip.rst -+++ b/doc/develop/driver-model/nvmxip.rst -@@ -56,7 +56,7 @@ The implementation is generic and can be used by different platforms. - Supported hardware - -------------------------------- - --Any 64-bit plaform. -+Any plaform supporting readq(). - - Configuration - ---------------------- -diff --git a/doc/device-tree-bindings/nvmxip/nvmxip_qspi.txt b/doc/device-tree-bindings/nvmxip/nvmxip_qspi.txt -index cc60e9efdc..882728d541 100644 ---- a/doc/device-tree-bindings/nvmxip/nvmxip_qspi.txt -+++ b/doc/device-tree-bindings/nvmxip/nvmxip_qspi.txt -@@ -16,7 +16,7 @@ If a platform has its own driver, please provide your own compatible - string. - - 2) -- reg = <0x0 0x08000000 0x0 0x00200000>; -+ reg = /bits/ 64 <0x08000000 0x00200000>; - - The start address and size of the flash device. The values give here are an - example (when the cell size is 2). -@@ -43,14 +43,14 @@ Example of multiple flash devices - - nvmxip-qspi1@08000000 { - compatible = "nvmxip,qspi"; -- reg = <0x0 0x08000000 0x0 0x00200000>; -+ reg = /bits/ 64 <0x08000000 0x00200000>; - lba_shift = <9>; - lba = <4096>; - }; - - nvmxip-qspi2@08200000 { - compatible = "nvmxip,qspi"; -- reg = <0x0 0x08200000 0x0 0x00100000>; -+ reg = /bits/ 64 <0x08200000 0x00100000>; - lba_shift = <9>; - lba = <2048>; - }; -diff --git a/drivers/mtd/nvmxip/nvmxip-uclass.c b/drivers/mtd/nvmxip/nvmxip-uclass.c -index 9f96041e3d..6d8eb177b5 100644 ---- a/drivers/mtd/nvmxip/nvmxip-uclass.c -+++ b/drivers/mtd/nvmxip/nvmxip-uclass.c -@@ -9,6 +9,9 @@ - #include <common.h> - #include <dm.h> - #include <log.h> -+#if CONFIG_IS_ENABLED(SANDBOX64) -+#include <asm/test.h> -+#endif - #include <linux/bitops.h> - #include "nvmxip.h" - -@@ -36,6 +39,10 @@ static int nvmxip_post_bind(struct udevice *udev) - char bdev_name[NVMXIP_BLKDEV_NAME_SZ + 1]; - int devnum; - -+#if CONFIG_IS_ENABLED(SANDBOX64) -+ sandbox_set_enable_memio(true); -+#endif -+ - devnum = uclass_id_count(UCLASS_NVMXIP); - snprintf(bdev_name, NVMXIP_BLKDEV_NAME_SZ, "blk#%d", devnum); - --- -2.25.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0031-corstone1000-add-NVM-XIP-QSPI-device-tree-node.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0031-corstone1000-add-NVM-XIP-QSPI-device-tree-node.patch deleted file mode 100644 index 08e9d31749..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0031-corstone1000-add-NVM-XIP-QSPI-device-tree-node.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 635848c90343a1b8a268519e3fc78ef7af2e4819 Mon Sep 17 00:00:00 2001 -From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Date: Mon, 19 Dec 2022 13:20:19 +0000 -Subject: [PATCH 31/42] corstone1000: add NVM XIP QSPI device tree node - -add QSPI flash device node for block storage access - -Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Upstream-Status: Backport [https://github.com/u-boot/u-boot/commit/c9c2c95d4cd27fe0cd41fe13a863899d268f973c] ---- - arch/arm/dts/corstone1000.dtsi | 9 ++++++++- - 1 file changed, 8 insertions(+), 1 deletion(-) - -diff --git a/arch/arm/dts/corstone1000.dtsi b/arch/arm/dts/corstone1000.dtsi -index 61e0c33247..18c4d1e19a 100644 ---- a/arch/arm/dts/corstone1000.dtsi -+++ b/arch/arm/dts/corstone1000.dtsi -@@ -1,6 +1,6 @@ - // SPDX-License-Identifier: GPL-2.0 or MIT - /* -- * Copyright (c) 2022, Arm Limited. All rights reserved. -+ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> - * Copyright (c) 2022, Linaro Limited. All rights reserved. - * - */ -@@ -38,6 +38,13 @@ - reg = <0x88200000 0x77e00000>; - }; - -+ nvmxip-qspi@08000000 { -+ compatible = "nvmxip,qspi"; -+ reg = <0x08000000 0x2000000>; -+ lba_shift = <9>; -+ lba = <65536>; -+ }; -+ - gic: interrupt-controller@1c000000 { - compatible = "arm,gic-400"; - #interrupt-cells = <3>; --- -2.25.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0041-corstone1000-enable-PSCI-reset.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0031-corstone1000-enable-PSCI-reset.patch index cad830f4c8..9ba0205c70 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0041-corstone1000-enable-PSCI-reset.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0031-corstone1000-enable-PSCI-reset.patch @@ -1,7 +1,7 @@ -From 8bf48a56aa014146a8950532906b06e191754daa Mon Sep 17 00:00:00 2001 +From 0524aa417c4989bf03366f13a2456b3bcb72fb87 Mon Sep 17 00:00:00 2001 From: Emekcan Aras <emekcan.aras@arm.com> -Date: Wed, 24 May 2023 09:12:11 +0100 -Subject: [PATCH 42/42] corstone1000: enable PSCI reset +Date: Tue, 18 Jul 2023 12:19:17 +0100 +Subject: [PATCH 31/33] corstone1000: enable PSCI reset Even though corstone1000 does not implement entire PSCI APIs,it relies on PSCI reset interface for the system reset. U-boot change the config name, so we @@ -10,21 +10,22 @@ need to enable it again. Upstream-Status: Pending [Not submitted to upstream yet] Signed-off-by: Emekcan Aras <emekcan.aras@arm.com> --- - configs/corstone1000_defconfig | 1 + - 1 file changed, 1 insertion(+) + configs/corstone1000_defconfig | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig -index 20359cb181..19fe1432ae 100644 +index 0232131a11..ccd558cfce 100644 --- a/configs/corstone1000_defconfig +++ b/configs/corstone1000_defconfig -@@ -62,6 +62,7 @@ CONFIG_DM_RTC=y - CONFIG_RTC_EMULATION=y - CONFIG_DM_SERIAL=y - CONFIG_SYSRESET=y +@@ -73,4 +73,5 @@ CONFIG_EFI_CAPSULE_ON_DISK=y + CONFIG_EFI_IGNORE_OSINDICATIONS=y + CONFIG_FWU_MULTI_BANK_UPDATE=y + # CONFIG_TOOLS_MKEFICAPSULE is not set +-CONFIG_DM_GPIO=y +\ No newline at end of file ++CONFIG_DM_GPIO=y +CONFIG_SYSRESET_PSCI=y - CONFIG_USB=y - CONFIG_USB_ISP1760=y - CONFIG_ERRNO_STR=y +\ No newline at end of file -- 2.25.1 diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0042-Enable-EFI-set-get-time-services.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0032-Enable-EFI-set-get-time-services.patch index 8911abfe20..acc35f176c 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0042-Enable-EFI-set-get-time-services.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0032-Enable-EFI-set-get-time-services.patch @@ -1,7 +1,7 @@ -From 9f326f0db8aa13fde93e2ed79055b920c8598a28 Mon Sep 17 00:00:00 2001 +From 0ba2b25a9c1dd9c63615bf6830cfb470f33a31b5 Mon Sep 17 00:00:00 2001 From: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com> -Date: Mon, 12 Jun 2023 15:14:52 +0000 -Subject: [PATCH] Enable EFI set/get time services +Date: Tue, 18 Jul 2023 12:21:39 +0100 +Subject: [PATCH 32/33] Enable EFI set/get time services SetTime_Conf and SetTime_Func tests in UEFI SCT test suite of ACS fails with unsupported return value. CONFIG_EFI_SET_TIME and @@ -10,23 +10,24 @@ services. Upstream-Status: Pending [Not submitted to upstream yet] Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com> +Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> --- - configs/corstone1000_defconfig | 2 ++ - 1 file changed, 2 insertions(+) + configs/corstone1000_defconfig | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig -index c692cc91bd..f1901dfe8b 100644 +index ccd558cfce..a0af413de8 100644 --- a/configs/corstone1000_defconfig +++ b/configs/corstone1000_defconfig -@@ -7,6 +7,8 @@ CONFIG_NR_DRAM_BANKS=1 - CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y - CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x83f00000 +@@ -74,4 +74,6 @@ CONFIG_EFI_IGNORE_OSINDICATIONS=y + CONFIG_FWU_MULTI_BANK_UPDATE=y + # CONFIG_TOOLS_MKEFICAPSULE is not set CONFIG_DM_GPIO=y +-CONFIG_SYSRESET_PSCI=y +\ No newline at end of file ++CONFIG_SYSRESET_PSCI=y +CONFIG_EFI_SET_TIME=y +CONFIG_EFI_GET_TIME=y - CONFIG_DEFAULT_DEVICE_TREE="corstone1000-mps3" - CONFIG_SYS_PROMPT="corstone1000# " - CONFIG_IDENT_STRING=" corstone1000 aarch64 " -- -2.17.1 +2.25.1 diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0032-sandbox64-add-a-test-case-for-UCLASS_NVMXIP.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0032-sandbox64-add-a-test-case-for-UCLASS_NVMXIP.patch deleted file mode 100644 index 923eac9bba..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0032-sandbox64-add-a-test-case-for-UCLASS_NVMXIP.patch +++ /dev/null @@ -1,219 +0,0 @@ -From 0ecb61da60febc66e589d6fbf439478af1c88283 Mon Sep 17 00:00:00 2001 -From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Date: Mon, 12 Jun 2023 17:33:54 +0100 -Subject: [PATCH 32/42] sandbox64: add a test case for UCLASS_NVMXIP - -provide a test for NVM XIP devices - -The test case allows to make sure of the following: - -- The NVM XIP QSPI devices are probed -- The DT entries are read correctly -- the data read from the flash by the NVMXIP block driver is correct - -Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Upstream-Status: Backport [https://github.com/u-boot/u-boot/commit/c9c2c95d4cd27fe0cd41fe13a863899d268f973c] - -Changelog: -=============== - -v2: - -* address nits ---- - MAINTAINERS | 1 + - test/dm/Makefile | 6 +- - test/dm/nvmxip.c | 145 +++++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 151 insertions(+), 1 deletion(-) - create mode 100644 test/dm/nvmxip.c - -diff --git a/MAINTAINERS b/MAINTAINERS -index f81654346e..6692ce9974 100644 ---- a/MAINTAINERS -+++ b/MAINTAINERS -@@ -1208,6 +1208,7 @@ S: Maintained - F: doc/develop/driver-model/nvmxip.rst - F: doc/device-tree-bindings/nvmxip/nvmxip_qspi.txt - F: drivers/mtd/nvmxip/ -+F: test/dm/nvmxip.c - - NVMEM - M: Sean Anderson <seanga2@gmail.com> -diff --git a/test/dm/Makefile b/test/dm/Makefile -index 85e99e1c12..963fa927f7 100644 ---- a/test/dm/Makefile -+++ b/test/dm/Makefile -@@ -1,7 +1,7 @@ - # SPDX-License-Identifier: GPL-2.0+ - # - # Copyright (c) 2013 Google, Inc --# (C) Copyright 2022 ARM Limited -+# Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> - - obj-$(CONFIG_UT_DM) += test-dm.o - -@@ -18,6 +18,10 @@ obj-$(CONFIG_UT_DM) += test-uclass.o - obj-$(CONFIG_UT_DM) += core.o - obj-$(CONFIG_UT_DM) += read.o - obj-$(CONFIG_UT_DM) += phys2bus.o -+ifeq ($(CONFIG_NVMXIP_QSPI)$(CONFIG_SANDBOX64),yy) -+obj-y += nvmxip.o -+endif -+ - ifneq ($(CONFIG_SANDBOX),) - ifeq ($(CONFIG_ACPIGEN),y) - obj-y += acpi.o -diff --git a/test/dm/nvmxip.c b/test/dm/nvmxip.c -new file mode 100644 -index 0000000000..e934748eb5 ---- /dev/null -+++ b/test/dm/nvmxip.c -@@ -0,0 +1,145 @@ -+// SPDX-License-Identifier: GPL-2.0+ -+/* -+ * Functional tests for UCLASS_FFA class -+ * -+ * Copyright 2023 Arm Limited and/or its affiliates <open-source-office@arm.com> -+ * -+ * Authors: -+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -+ */ -+ -+#include <common.h> -+#include <blk.h> -+#include <console.h> -+#include <dm.h> -+#include <mapmem.h> -+#include <dm/test.h> -+#include <linux/bitops.h> -+#include <test/test.h> -+#include <test/ut.h> -+#include "../../drivers/mtd/nvmxip/nvmxip.h" -+ -+/* NVMXIP devices described in the device tree */ -+#define SANDBOX_NVMXIP_DEVICES 2 -+ -+/* reference device tree data for the probed devices */ -+static struct nvmxip_plat nvmqspi_refdata[SANDBOX_NVMXIP_DEVICES] = { -+ {0x08000000, 9, 4096}, {0x08200000, 9, 2048} -+}; -+ -+#define NVMXIP_BLK_START_PATTERN 0x1122334455667788ULL -+#define NVMXIP_BLK_END_PATTERN 0xa1a2a3a4a5a6a7a8ULL -+ -+/** -+ * dm_nvmxip_flash_sanity() - check flash data -+ * @uts: test state -+ * @device_idx: the NVMXIP device index -+ * @buffer: the user buffer where the blocks data is copied to -+ * -+ * Mode 1: When buffer is NULL, initialize the flash with pattern data at the start -+ * and at the end of each block. This pattern data will be used to check data consistency -+ * when verifying the data read. -+ * Mode 2: When the user buffer is provided in the argument (not NULL), compare the data -+ * of the start and the end of each block in the user buffer with the expected pattern data. -+ * Return an error when the check fails. -+ * -+ * Return: -+ * -+ * 0 on success. Otherwise, failure -+ */ -+static int dm_nvmxip_flash_sanity(struct unit_test_state *uts, u8 device_idx, void *buffer) -+{ -+ int i; -+ u64 *ptr; -+ u8 *base; -+ unsigned long blksz; -+ -+ blksz = BIT(nvmqspi_refdata[device_idx].lba_shift); -+ -+ if (!buffer) { -+ /* Mode 1: point at the flash start address. Pattern data will be written */ -+ base = map_sysmem(nvmqspi_refdata[device_idx].phys_base, 0); -+ } else { -+ /* Mode 2: point at the user buffer containing the data read and to be verified */ -+ base = buffer; -+ } -+ -+ for (i = 0; i < nvmqspi_refdata[device_idx].lba ; i++) { -+ ptr = (u64 *)(base + i * blksz); -+ -+ /* write an 8 bytes pattern at the start of the current block */ -+ if (!buffer) -+ *ptr = NVMXIP_BLK_START_PATTERN; -+ else -+ ut_asserteq_64(NVMXIP_BLK_START_PATTERN, *ptr); -+ -+ ptr = (u64 *)((u8 *)ptr + blksz - sizeof(u64)); -+ -+ /* write an 8 bytes pattern at the end of the current block */ -+ if (!buffer) -+ *ptr = NVMXIP_BLK_END_PATTERN; -+ else -+ ut_asserteq_64(NVMXIP_BLK_END_PATTERN, *ptr); -+ } -+ -+ if (!buffer) -+ unmap_sysmem(base); -+ -+ return 0; -+} -+ -+/** -+ * dm_test_nvmxip() - check flash data -+ * @uts: test state -+ * Return: -+ * -+ * CMD_RET_SUCCESS on success. Otherwise, failure -+ */ -+static int dm_test_nvmxip(struct unit_test_state *uts) -+{ -+ struct nvmxip_plat *plat_data = NULL; -+ struct udevice *dev = NULL, *bdev = NULL; -+ u8 device_idx; -+ void *buffer = NULL; -+ unsigned long flashsz; -+ -+ /* set the flash content first for both devices */ -+ dm_nvmxip_flash_sanity(uts, 0, NULL); -+ dm_nvmxip_flash_sanity(uts, 1, NULL); -+ -+ /* probing all NVM XIP QSPI devices */ -+ for (device_idx = 0, uclass_first_device(UCLASS_NVMXIP, &dev); -+ dev; -+ uclass_next_device(&dev), device_idx++) { -+ plat_data = dev_get_plat(dev); -+ -+ /* device tree entries checks */ -+ ut_assertok(nvmqspi_refdata[device_idx].phys_base != plat_data->phys_base); -+ ut_assertok(nvmqspi_refdata[device_idx].lba_shift != plat_data->lba_shift); -+ ut_assertok(nvmqspi_refdata[device_idx].lba != plat_data->lba); -+ -+ /* before reading all the flash blocks, let's calculate the flash size */ -+ flashsz = plat_data->lba << plat_data->lba_shift; -+ -+ /* allocate the user buffer where to copy the blocks data to */ -+ buffer = calloc(flashsz, 1); -+ ut_assertok(!buffer); -+ -+ /* the block device is the child of the parent device probed with DT */ -+ ut_assertok(device_find_first_child(dev, &bdev)); -+ -+ /* reading all the flash blocks */ -+ ut_asserteq(plat_data->lba, blk_read(bdev, 0, plat_data->lba, buffer)); -+ -+ /* compare the data read from flash with the expected data */ -+ dm_nvmxip_flash_sanity(uts, device_idx, buffer); -+ -+ free(buffer); -+ } -+ -+ ut_assertok(device_idx != SANDBOX_NVMXIP_DEVICES); -+ -+ return CMD_RET_SUCCESS; -+} -+ -+DM_TEST(dm_test_nvmxip, UT_TESTF_SCAN_FDT | UT_TESTF_CONSOLE_REC); --- -2.25.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0033-Increase-the-unzipped-Kernel-size.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0033-Increase-the-unzipped-Kernel-size.patch new file mode 100644 index 0000000000..63c42c70b7 --- /dev/null +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0033-Increase-the-unzipped-Kernel-size.patch @@ -0,0 +1,29 @@ +From df23489adcba1cdcbcb4fefbed0896fc1f408700 Mon Sep 17 00:00:00 2001 +From: Emekcan Aras <emekcan.aras@arm.com> +Date: Wed, 2 Aug 2023 17:07:05 +0100 +Subject: [PATCH] Increase the unzipped Kernel size + +Increases the unzipped kernel size for corstone1000. + +Upstream-Status: Pending [Not submitted to upstream yet] +Signed-off-by: Emekcan Aras <emekcan.aras@arm.com> +--- + configs/corstone1000_defconfig | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig +index a0af413de8..54a5bca354 100644 +--- a/configs/corstone1000_defconfig ++++ b/configs/corstone1000_defconfig +@@ -15,7 +15,7 @@ CONFIG_DISTRO_DEFAULTS=y + CONFIG_BOOTDELAY=3 + CONFIG_USE_BOOTARGS=y + CONFIG_BOOTARGS="console=ttyAMA0 loglevel=9 ip=dhcp earlyprintk" +-CONFIG_BOOTCOMMAND="echo Loading kernel from $kernel_addr to memory ... ; unzip $kernel_addr 0x90000000; loadm 0x90000000 $kernel_addr_r 0xf00000; usb start; usb reset; run distro_bootcmd; bootefi $kernel_addr_r $fdtcontroladdr;" ++CONFIG_BOOTCOMMAND="echo Loading kernel from $kernel_addr to memory ... ; unzip $kernel_addr 0x90000000; loadm 0x90000000 $kernel_addr_r 0xfb0000; usb start; usb reset; run distro_bootcmd; bootefi $kernel_addr_r $fdtcontroladdr;" + CONFIG_CONSOLE_RECORD=y + CONFIG_LOGLEVEL=7 + # CONFIG_DISPLAY_CPUINFO is not set +-- +2.17.1 + diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0035-corstone1000-add-boot-index.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0035-corstone1000-add-boot-index.patch deleted file mode 100644 index d9568563e6..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0035-corstone1000-add-boot-index.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 92948559987d02baf9f690d9bbdc96d1179264ef Mon Sep 17 00:00:00 2001 -From: Rui Miguel Silva <rui.silva@linaro.org> -Date: Wed, 1 Feb 2023 16:15:30 +0000 -Subject: [PATCH 36/42] corstone1000: add boot index - -it is expected that the firmware that runs before -u-boot somehow provide the information of the bank -(index) of it is booting. -We will need to extend tf-a to pass that info, -meanwhile just set it to the default bank. - -Upstream-Status: Pending -Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> ---- - board/armltd/corstone1000/corstone1000.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/board/armltd/corstone1000/corstone1000.c b/board/armltd/corstone1000/corstone1000.c -index d6ca6e8961..0a58ccd99c 100644 ---- a/board/armltd/corstone1000/corstone1000.c -+++ b/board/armltd/corstone1000/corstone1000.c -@@ -106,6 +106,7 @@ int dram_init_banksize(void) - return 0; - } - --void reset_cpu(ulong addr) -+void fwu_plat_get_bootidx(int *boot_idx) - { -+ *boot_idx = 0; - } --- -2.25.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0043-corstone1000-fix-compilation-warnings-in-fwu_plat_get_bootidx.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0043-corstone1000-fix-compilation-warnings-in-fwu_plat_get_bootidx.patch deleted file mode 100644 index e574103ec9..0000000000 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0043-corstone1000-fix-compilation-warnings-in-fwu_plat_get_bootidx.patch +++ /dev/null @@ -1,47 +0,0 @@ -From dfebda98ce08d0cab411521ab3d9e832ed1b4608 Mon Sep 17 00:00:00 2001 -From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -Date: Thu, 15 Jun 2023 16:51:49 +0100 -Subject: [PATCH] corstone1000: fix compilation warnings in - fwu_plat_get_bootidx() - -Upstream-Status: Pending [Not submitted to upstream yet] -Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> ---- - board/armltd/corstone1000/corstone1000.c | 7 +++---- - 1 file changed, 3 insertions(+), 4 deletions(-) - -diff --git a/board/armltd/corstone1000/corstone1000.c b/board/armltd/corstone1000/corstone1000.c -index db508ac3cb..2e1ace5d04 100644 ---- a/board/armltd/corstone1000/corstone1000.c -+++ b/board/armltd/corstone1000/corstone1000.c -@@ -9,6 +9,7 @@ - #include <common.h> - #include <dm.h> - #include <env.h> -+#include <fwu.h> - #include <netdev.h> - #include <nvmxip.h> - #include <part.h> -@@ -116,7 +117,7 @@ int dram_init_banksize(void) - return 0; - } - --void fwu_plat_get_bootidx(int *boot_idx) -+void fwu_plat_get_bootidx(uint *boot_idx) - { - int ret; - -@@ -127,9 +128,7 @@ void fwu_plat_get_bootidx(int *boot_idx) - */ - ret = fwu_get_active_index(boot_idx); - if (ret < 0) -- log_err("corstone1000: failed to read active index\n"); -- -- return ret; -+ log_err("corstone1000: failed to read active index err %d\n", ret); - } - - int board_late_init(void) --- -2.25.1 - diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone500/0001-armv7-adding-generic-timer-access-through-MMIO.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone500/0001-armv7-adding-generic-timer-access-through-MMIO.patch index 3d8545ff09..1d28631a21 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone500/0001-armv7-adding-generic-timer-access-through-MMIO.patch +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone500/0001-armv7-adding-generic-timer-access-through-MMIO.patch @@ -20,7 +20,6 @@ the u-boot initcall level (timer_init) before u-boot relocation. Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> -%% original patch: 0001-armv7-adding-generic-timer-access-through-MMIO.patch Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> --- diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot_%.bbappend b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot_%.bbappend index 07ba7a1873..6c0d49046a 100644 --- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot_%.bbappend +++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot_%.bbappend @@ -18,49 +18,39 @@ EXTRA_OEMAKE:append:corstone1000 = ' DEVICE_TREE=${CORSTONE1000_DEVICE_TREE}' SYSROOT_DIRS:append:corstone1000 = " /boot" SRC_URI:append:corstone1000 = " \ - file://0001-arm64-smccc-add-support-for-SMCCCv1.2-x0-x17-registe.patch \ - file://0002-lib-uuid-introduce-uuid_str_to_le_bin-function.patch \ - file://0003-arm_ffa-introduce-Arm-FF-A-low-level-driver.patch \ - file://0004-arm_ffa-efi-unmap-RX-TX-buffers.patch \ - file://0005-arm_ffa-introduce-armffa-command.patch \ - file://0006-arm_ffa-introduce-the-FF-A-Sandbox-driver.patch \ - file://0007-arm_ffa-introduce-Sandbox-test-cases-for-UCLASS_FFA.patch \ - file://0008-arm_ffa-introduce-armffa-command-Sandbox-test.patch \ - file://0009-arm_ffa-efi-introduce-FF-A-MM-communication.patch \ - file://0010-arm_ffa-efi-corstone1000-enable-MM-communication.patch \ - file://0011-efi-corstone1000-introduce-EFI-capsule-update.patch \ - file://0012-arm-corstone1000-fix-unrecognized-filesystem-type.patch \ - file://0013-efi_capsule-corstone1000-pass-interface-id-and-buffe.patch \ - file://0014-efi_boottime-corstone1000-pass-interface-id-and-kern.patch \ - file://0015-efi_loader-corstone1000-remove-guid-check-from-corst.patch \ - file://0016-efi_loader-populate-ESRT-table-if-EFI_ESRT-config-op.patch \ - file://0017-efi_firmware-add-get_image_info-for-corstone1000.patch \ - file://0018-efi_loader-send-bootcomplete-message-to-secure-encla.patch \ - file://0019-efi_loader-fix-null-pointer-exception-with-get_image.patch \ - file://0020-arm-corstone1000-add-mmc-for-fvp.patch \ - file://0021-corstone1000-add-compressed-kernel-support.patch \ - file://0022-Introduce-external-sys-driver-to-device-tree.patch \ - file://0023-Add-mhu-and-rpmsg-client-to-u-boot-device-tree.patch \ - file://0024-arm-corstone1000-esrt-support.patch \ - file://0025-efi_setup-discover-FF-A-bus-before-raising-EFI-start.patch \ - file://0026-corstone1000-enable-distro-booting-command.patch \ - file://0027-drivers-mtd-nvmxip-introduce-NVM-XIP-block-storage-e.patch \ - file://0028-drivers-mtd-nvmxip-introduce-QSPI-XIP-driver.patch \ - file://0029-sandbox64-fix-return-unsigned-long-in-readq.patch \ - file://0030-sandbox64-add-support-for-NVMXIP-QSPI.patch \ - file://0031-corstone1000-add-NVM-XIP-QSPI-device-tree-node.patch \ - file://0032-sandbox64-add-a-test-case-for-UCLASS_NVMXIP.patch \ - file://0033-corstone1000-add-fwu-metadata-store-info.patch \ - file://0034-fwu_metadata-make-sure-structures-are-packed.patch \ - file://0035-corstone1000-add-boot-index.patch \ - file://0036-corstone1000-adjust-boot-bank-and-kernel-location.patch \ - file://0037-corstone1000-add-nvmxip-fwu-mdata-and-gpt-options.patch \ - file://0038-nvmxip-move-header-to-include.patch \ - file://0039-corstone1000-set-kernel_addr-based-on-boot_idx.patch \ - file://0040-corstone1000-boot-index-from-active.patch \ - file://0041-corstone1000-enable-PSCI-reset.patch \ - file://0042-Enable-EFI-set-get-time-services.patch \ - file://0043-corstone1000-fix-compilation-warnings-in-fwu_plat_get_bootidx.patch \ + file://0001-FF-A-v15-arm64-smccc-add-support-for-SMCCCv1.2-x0-x1.patch \ + file://0002-FF-A-v15-lib-uuid-introduce-uuid_str_to_le_bin-funct.patch \ + file://0003-FF-A-v15-lib-uuid-introduce-testcase-for-uuid_str_to.patch \ + file://0004-FF-A-v15-arm_ffa-introduce-Arm-FF-A-support.patch \ + file://0005-FF-A-v15-arm_ffa-introduce-armffa-command.patch \ + file://0006-FF-A-v15-arm_ffa-introduce-sandbox-FF-A-support.patch \ + file://0007-FF-A-v15-arm_ffa-introduce-sandbox-test-cases-for-UC.patch \ + file://0008-FF-A-v15-arm_ffa-introduce-armffa-command-Sandbox-te.patch \ + file://0009-FF-A-v15-arm_ffa-efi-introduce-FF-A-MM-communication.patch \ + file://0010-FF-A-v15-arm_ffa-efi-corstone1000-enable-MM-communic.patch \ + file://0011-efi-corstone1000-fwu-introduce-EFI-capsule-update.patch \ + file://0012-arm-corstone1000-fix-unrecognized-filesystem-type.patch \ + file://0013-efi_loader-corstone1000-remove-guid-check-from-corst.patch \ + file://0014-efi_loader-populate-ESRT-table-if-EFI_ESRT-config-op.patch \ + file://0015-efi_firmware-add-get_image_info-for-corstone1000.patch \ + file://0016-efi_loader-fix-null-pointer-exception-with-get_image.patch \ + file://0017-arm-corstone1000-add-mmc-for-fvp.patch \ + file://0018-corstone1000-add-compressed-kernel-support.patch \ + file://0019-Introduce-external-sys-driver-to-device-tree.patch \ + file://0020-Add-mhu-and-rpmsg-client-to-u-boot-device-tree.patch \ + file://0021-arm-corstone1000-esrt-support.patch \ + file://0022-corstone1000-enable-distro-booting-command.patch \ + file://0023-corstone1000-add-fwu-metadata-store-info.patch \ + file://0024-fwu_metadata-make-sure-structures-are-packed.patch \ + file://0025-corstone1000-add-boot-index.patch \ + file://0026-corstone1000-adjust-boot-bank-and-kernel-location.patch \ + file://0027-corstone1000-add-nvmxip-fwu-mdata-and-gpt-options.patch \ + file://0028-nvmxip-move-header-to-include.patch \ + file://0029-corstone1000-set-kernel_addr-based-on-boot_idx.patch \ + file://0030-corstone1000-boot-index-from-active.patch \ + file://0031-corstone1000-enable-PSCI-reset.patch \ + file://0032-Enable-EFI-set-get-time-services.patch \ + file://0033-Increase-the-unzipped-Kernel-size.patch \ " # diff --git a/meta-arm/meta-arm/recipes-bsp/uefi/edk2-firmware_202211.bb b/meta-arm/meta-arm-bsp/recipes-bsp/uefi/edk2-firmware_202211.bb index 386bed4ba4..378f58547e 100644 --- a/meta-arm/meta-arm/recipes-bsp/uefi/edk2-firmware_202211.bb +++ b/meta-arm/meta-arm-bsp/recipes-bsp/uefi/edk2-firmware_202211.bb @@ -1,4 +1,4 @@ SRCREV_edk2 ?= "fff6d81270b57ee786ea18ad74f43149b9f03494" SRCREV_edk2-platforms ?= "982212662c71b6c734b7578526071d6b78da3bcc" -require edk2-firmware.inc +require recipes-bsp/uefi/edk2-firmware.inc diff --git a/meta-arm/meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0003-HACK-disable-instruction-cache-and-data-cache.patch b/meta-arm/meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0003-HACK-disable-instruction-cache-and-data-cache.patch index e8f4cc44dc..ebe4d72661 100644 --- a/meta-arm/meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0003-HACK-disable-instruction-cache-and-data-cache.patch +++ b/meta-arm/meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0003-HACK-disable-instruction-cache-and-data-cache.patch @@ -12,7 +12,6 @@ and D cache until a proper fix is found. Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com> -%% original patch: 0003-HACK-disable-instruction-cache-and-data-cache.patch diff --git a/core/arch/arm/kernel/entry_a64.S b/core/arch/arm/kernel/entry_a64.S index 875b6e69..594d6928 100644 diff --git a/meta-arm/meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0004-Handle-logging-syscall.patch b/meta-arm/meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0004-Handle-logging-syscall.patch index 67d987257b..ca4405d83b 100644 --- a/meta-arm/meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0004-Handle-logging-syscall.patch +++ b/meta-arm/meta-arm-bsp/recipes-security/optee/files/optee-os/n1sdp/0004-Handle-logging-syscall.patch @@ -9,7 +9,6 @@ Subject: [PATCH] Handle logging syscall Signed-off-by: Balint Dobszay <balint.dobszay@arm.com> Change-Id: Ib8151cc9c66aea8bcc8fe8b1ecdc3f9f9c5f14e4 -%% original patch: 0004-Handle-logging-syscall.patch diff --git a/core/arch/arm/kernel/spmc_sp_handler.c b/core/arch/arm/kernel/spmc_sp_handler.c index e0fa0aa6..c7a45387 100644 diff --git a/meta-arm/meta-arm-bsp/recipes-security/trusted-services/corstone1000/psa-apitest/0001-corstone1000-port-crypto-config.patch b/meta-arm/meta-arm-bsp/recipes-security/trusted-services/corstone1000/psa-apitest/0001-corstone1000-port-crypto-config.patch index c7289562bd..072b50b4ff 100644 --- a/meta-arm/meta-arm-bsp/recipes-security/trusted-services/corstone1000/psa-apitest/0001-corstone1000-port-crypto-config.patch +++ b/meta-arm/meta-arm-bsp/recipes-security/trusted-services/corstone1000/psa-apitest/0001-corstone1000-port-crypto-config.patch @@ -9,7 +9,6 @@ Subject: [PATCH] corstone1000: port crypto config Signed-off-by: Satish Kumar <satish.kumar01@arm.com> -%% original patch: 0002-corstone1000-port-crypto-config.patch Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> --- diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/androidclang_r416183b.bb b/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/androidclang_r416183b.bb deleted file mode 100644 index 963fd60e37..0000000000 --- a/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/androidclang_r416183b.bb +++ /dev/null @@ -1,52 +0,0 @@ -# SPDX-License-Identifier: MIT -# -# Copyright (c) 2021 Arm Limited -# - -SUMMARY = "Android Clang compiler" -DESCRIPTION = "Android Clang compiler, version r416183b. This is based on Clang 12.0.5 \ -Intended usage is to build kernel images that match the output of the Android (hermetic) \ -build system" - -LICENSE = "MIT" - -LIC_FILES_CHKSUM = "file://MODULE_LICENSE_MIT;md5=d41d8cd98f00b204e9800998ecf8427e" - -ANDROID_CLANG_VERSION = "clang-r416183b" -ANDROID_CLANG_HASH = "bd96dfe349c962681f0e5388af874c771ef96670" - -COMPATIBLE_HOST = "x86_64.*-linux" - -SRC_URI = "https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/${ANDROID_CLANG_HASH}/${ANDROID_CLANG_VERSION}.tar.gz;subdir=${ANDROID_CLANG_VERSION}" - -# We need to set the checksum to "ignore" because the tarball is dynamically generated and has a new checksum every time -# (the contents are the same, but the time stamp differs) -BB_STRICT_CHECKSUM = "ignore" - -S = "${WORKDIR}/${ANDROID_CLANG_VERSION}" - -FILES:${PN} = "${libexecdir} ${bindir}" - -do_install() { - install -d ${D}${libexecdir}/${ANDROID_CLANG_VERSION}/ - - cp --no-preserve=ownership -r ${S}/. ${D}${libexecdir}/${ANDROID_CLANG_VERSION}/ - # Strip bad RPATHs in the embedded python3 - chrpath -d ${D}${libexecdir}/${ANDROID_CLANG_VERSION}/python3/lib/python*/lib-dynload/*.so - - install -d ${D}${bindir} - # Symlink all executables into bindir - for f in ${D}${libexecdir}/${ANDROID_CLANG_VERSION}/bin/*; do - ln -rs $f ${D}${bindir}/$(basename $f) - done -} - -INHIBIT_DEFAULT_DEPS = "1" - -INSANE_SKIP:${PN} = "already-stripped libdir staticdev file-rdeps arch dev-so" - -INHIBIT_SYSROOT_STRIP = "1" -INHIBIT_PACKAGE_STRIP = "1" -INHIBIT_PACKAGE_DEBUG_SPLIT = "1" - -BBCLASSEXTEND = "native nativesdk" diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/arm-binary-toolchain.inc b/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/arm-binary-toolchain.inc index 44adfc8b61..0e039a5be1 100644 --- a/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/arm-binary-toolchain.inc +++ b/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/arm-binary-toolchain.inc @@ -5,11 +5,11 @@ FILES:${PN} = "${libexecdir} ${bindir}" BINNAME = "${@d.getVar("BPN").strip("gcc-")}" do_install() { - install -d ${D}${bindir} ${D}${libexecdir}/${BPN}/ - cp -r ${S}/. ${D}${libexecdir}/${BPN} + install -d ${D}${bindir} ${D}${libexecdir}/${BP}/ + cp -r ${S}/. ${D}${libexecdir}/${BP} # Symlink all executables into bindir - for f in ${D}${libexecdir}/${BPN}/bin/*; do + for f in ${D}${libexecdir}/${BP}/bin/*; do ln -rs $f ${D}${bindir}/$(basename $f) done } diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-aarch64-none-elf_12.2.rel1.bb b/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-aarch64-none-elf_12.3.rel1.bb index db8851eb06..7d06f2911a 100644 --- a/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-aarch64-none-elf_12.2.rel1.bb +++ b/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-aarch64-none-elf_12.3.rel1.bb @@ -12,8 +12,8 @@ LIC_FILES_CHKSUM:aarch64 = "file://share/doc/gcc/Copying.html;md5=0aef214b835259 LIC_FILES_CHKSUM:x86-64 = "file://share/doc/gcc/Copying.html;md5=7ba3bc8ef145b48e2756a844db2029a3" SRC_URI = "https://developer.arm.com/-/media/Files/downloads/gnu/${PV}/binrel/arm-gnu-toolchain-${PV}-${HOST_ARCH}-${BINNAME}.tar.xz;name=gcc-${HOST_ARCH}" -SRC_URI[gcc-aarch64.sha256sum] = "570a9bd42e2067d79d59b0747891681ebec66f30d989d17a05856563fe38f78b" -SRC_URI[gcc-x86_64.sha256sum] = "62d66e0ad7bd7f2a183d236ee301a5c73c737c886c7944aa4f39415aab528daf" +SRC_URI[gcc-aarch64.sha256sum] = "76ba68db4390b50f0a16386c6a011ec611a35a517ae40b7be008ca7920cfa59f" +SRC_URI[gcc-x86_64.sha256sum] = "382c8c786285e415bc0ff4df463e101f76d6f69a894b03f132368147c37f0ba7" S = "${WORKDIR}/arm-gnu-toolchain-${PV}-${HOST_ARCH}-${BINNAME}" diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-arm-none-eabi-11.2_11.2-2022.02.bb b/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-arm-none-eabi-11.2_11.2-2022.02.bb new file mode 100644 index 0000000000..7fab1e130c --- /dev/null +++ b/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-arm-none-eabi-11.2_11.2-2022.02.bb @@ -0,0 +1,23 @@ +# Copyright (C) 2019 Garmin Ltd. or its subsidiaries +# Released under the MIT license (see COPYING.MIT for the terms) + +require arm-binary-toolchain.inc + +COMPATIBLE_HOST = "(x86_64|aarch64).*-linux" + +SUMMARY = "Arm GNU Toolchain - AArch32 bare-metal target (arm-none-eabi)" +LICENSE = "GPL-3.0-with-GCC-exception & GPL-3.0-only" + +LIC_FILES_CHKSUM:aarch64 = "file://share/doc/gcc/Copying.html;md5=be4f8b5ff7319cd54f6c52db5d6f36b0" +LIC_FILES_CHKSUM:x86-64 = "file://share/doc/gcc/Copying.html;md5=1f07179249795891179bb3798bac7887" + +BINNAME = "arm-none-eabi" + +SRC_URI = "https://developer.arm.com/-/media/Files/downloads/gnu/${PV}/binrel/gcc-arm-${PV}-${HOST_ARCH}-${BINNAME}.tar.xz;name=gcc-${HOST_ARCH}" +SRC_URI[gcc-aarch64.sha256sum] = "ef1d82e5894e3908cb7ed49c5485b5b95deefa32872f79c2b5f6f5447cabf55f" +SRC_URI[gcc-x86_64.sha256sum] = "8c5acd5ae567c0100245b0556941c237369f210bceb196edfe5a2e7532c60326" + +S = "${WORKDIR}/gcc-arm-${PV}-${HOST_ARCH}-${BINNAME}" + +UPSTREAM_CHECK_URI = "https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/downloads" +UPSTREAM_CHECK_REGEX = "${BPN}-(?P<pver>.+)-${HOST_ARCH}-linux\.tar\.\w+" diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-arm-none-eabi_12.2.rel1.bb b/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-arm-none-eabi_12.3.rel1.bb index 48ddd16317..6c33ec65b5 100644 --- a/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-arm-none-eabi_12.2.rel1.bb +++ b/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-arm-none-eabi_12.3.rel1.bb @@ -12,8 +12,8 @@ LIC_FILES_CHKSUM:aarch64 = "file://share/doc/gcc/Copying.html;md5=0aef214b835259 LIC_FILES_CHKSUM:x86-64 = "file://share/doc/gcc/Copying.html;md5=7ba3bc8ef145b48e2756a844db2029a3" SRC_URI = "https://developer.arm.com/-/media/Files/downloads/gnu/${PV}/binrel/arm-gnu-toolchain-${PV}-${HOST_ARCH}-${BINNAME}.tar.xz;name=gcc-${HOST_ARCH}" -SRC_URI[gcc-aarch64.sha256sum] = "7ee332f7558a984e239e768a13aed86c6c3ac85c90b91d27f4ed38d7ec6b3e8c" -SRC_URI[gcc-x86_64.sha256sum] = "84be93d0f9e96a15addd490b6e237f588c641c8afdf90e7610a628007fc96867" +SRC_URI[gcc-aarch64.sha256sum] = "14c0487d5753f6071d24e568881f7c7e67f80dd83165dec5164b3731394af431" +SRC_URI[gcc-x86_64.sha256sum] = "12a2815644318ebcceaf84beabb665d0924b6e79e21048452c5331a56332b309" S = "${WORKDIR}/arm-gnu-toolchain-${PV}-${HOST_ARCH}-${BINNAME}" diff --git a/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/files/rwx.patch b/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/files/rwx.patch deleted file mode 100644 index b279cfeae0..0000000000 --- a/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/files/rwx.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 1d548c77d07fc9a83e3e9aa28a23aa19a0177e3b Mon Sep 17 00:00:00 2001 -From: Jon Mason <jon.mason@arm.com> -Date: Wed, 18 Jan 2023 15:13:37 -0500 -Subject: [PATCH] arm/trusted-firmware-m: disable fatal warnings - -Signed-off-by: Jon Mason <jon.mason@arm.com> -Upstream-Status: Inappropriate - ---- - toolchain_GNUARM.cmake | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/toolchain_GNUARM.cmake b/toolchain_GNUARM.cmake -index 7978eaca68..88395f922a 100644 ---- a/toolchain_GNUARM.cmake -+++ b/toolchain_GNUARM.cmake -@@ -66,7 +66,6 @@ macro(tfm_toolchain_reset_linker_flags) - --entry=Reset_Handler - --specs=nano.specs - LINKER:-check-sections -- LINKER:-fatal-warnings - LINKER:--gc-sections - LINKER:--no-wchar-size-warning - ${MEMORY_USAGE_FLAG} diff --git a/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m-1.7.0-src.inc b/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m-1.8.0-src.inc index 6a209c3763..393ce43923 100644 --- a/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m-1.7.0-src.inc +++ b/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m-1.8.0-src.inc @@ -3,7 +3,7 @@ LICENSE = "BSD-2-Clause & BSD-3-Clause & Apache-2.0" LIC_FILES_CHKSUM = "file://license.rst;md5=07f368487da347f3c7bd0fc3085f3afa \ - file://../tf-m-tests/license.rst;md5=02d06ffb8d9f099ff4961c0cb0183a18 \ + file://../tf-m-tests/license.rst;md5=4481bae2221b0cfca76a69fb3411f390 \ file://../mbedtls/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57 \ file://../mcuboot/LICENSE;md5=b6ee33f1d12a5e6ee3de1e82fb51eeb8" @@ -22,24 +22,24 @@ SRC_URI = "${SRC_URI_TRUSTED_FIRMWARE_M};branch=${SRCBRANCH_tfm};name=tfm;dests " # The required dependencies are documented in tf-m/config/config_default.cmake -# TF-Mv1.7.0 +# TF-Mv1.8.0 SRCBRANCH_tfm ?= "master" -SRCREV_tfm = "b725a1346cdb9ec75b1adcdc4c84705881e8fd4e" -# TF-Mv1.7.0 +SRCREV_tfm = "35ac80c8581d483da7d18cb8bcd20aaed096550c" +# TF-Mv1.8.0 SRCBRANCH_tfm-tests ?= "master" -SRCREV_tfm-tests = "4c4b58041c6c01670266690538a780b4a23d08b8" -# mbedtls-3.2.1 +SRCREV_tfm-tests = "1273c5bcd3d8ade60d51524797e0b22b6fd7eea1" +# mbedtls-3.4.0 SRCBRANCH_mbedtls ?= "master" -SRCREV_mbedtls = "869298bffeea13b205343361b7a7daf2b210e33d" -# v1.9.0 +SRCREV_mbedtls = "1873d3bfc2da771672bd8e7e8f41f57e0af77f33" +# mcuboot v1.10.0 SRCBRANCH_mcuboot ?= "main" -SRCREV_mcuboot = "c657cbea75f2bb1faf1fceacf972a0537a8d26dd" -# qcbor +SRCREV_mcuboot = "23d28832f02dcdc18687782c6cd8ba99e9b274d2" +# QCBOR v1.2 SRCBRANCH_qcbor ?= "master" SRCREV_qcbor = "b0e7033268e88c9f27146fa9a1415ef4c19ebaff" -# TF-Mv1.7.0 +# TF-Mv1.8.0 SRCBRANCH_tfm-extras ?= "master" -SRCREV_tfm-extras = "daacaa6df3881e205bc03d75fc8fb688afe9f0f1" +SRCREV_tfm-extras = "504ae9a9a50981e9dd4d8accec8261a1dba9e965" SRCREV_FORMAT = "tfm" diff --git a/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m-scripts-native_1.7.0.bb b/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m-scripts-native_1.8.0.bb index 504846e012..10b141d702 100644 --- a/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m-scripts-native_1.7.0.bb +++ b/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m-scripts-native_1.8.0.bb @@ -1,2 +1,2 @@ -require recipes-bsp/trusted-firmware-m/trusted-firmware-m-1.7.0-src.inc +require recipes-bsp/trusted-firmware-m/trusted-firmware-m-1.8.0-src.inc require recipes-bsp/trusted-firmware-m/trusted-firmware-m-scripts-native.inc diff --git a/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m.inc b/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m.inc index 02acfb8b79..1747c65487 100644 --- a/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m.inc +++ b/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m.inc @@ -8,8 +8,6 @@ DESCRIPTION = "Trusted Firmware-M" HOMEPAGE = "https://git.trustedfirmware.org/trusted-firmware-m.git" PROVIDES = "virtual/trusted-firmware-m" -SRC_URI += "file://rwx.patch" - UPSTREAM_CHECK_GITTAGREGEX = "^TF-Mv(?P<pver>\d+(\.\d+)+)$" # Note to future readers of this recipe: until the CMakeLists don't abuse @@ -24,10 +22,13 @@ INHIBIT_DEFAULT_DEPS = "1" PACKAGE_ARCH = "${MACHINE_ARCH}" +# At present, TF-M needs GCC >10 but <11.3 so use 11.2: +# https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git/tree/docs/getting_started/tfm_getting_started.rst?h=TF-Mv1.8.0#n214 +# # See tools/requirements.txt for Python dependencies DEPENDS += "cmake-native \ ninja-native \ - gcc-arm-none-eabi-native \ + gcc-arm-none-eabi-11.2-native \ python3-cbor2-native \ python3-click-native \ python3-cryptography-native \ diff --git a/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.7.0.bb b/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.8.0.bb index 32e6ed3417..5794c1ee9d 100644 --- a/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.7.0.bb +++ b/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.8.0.bb @@ -1,2 +1,2 @@ -require recipes-bsp/trusted-firmware-m/trusted-firmware-m-1.7.0-src.inc +require recipes-bsp/trusted-firmware-m/trusted-firmware-m-1.8.0-src.inc require recipes-bsp/trusted-firmware-m/trusted-firmware-m.inc diff --git a/meta-arm/meta-arm/recipes-bsp/uefi/edk2-firmware.inc b/meta-arm/meta-arm/recipes-bsp/uefi/edk2-firmware.inc index 4b9eda39c7..20eea36bbd 100644 --- a/meta-arm/meta-arm/recipes-bsp/uefi/edk2-firmware.inc +++ b/meta-arm/meta-arm/recipes-bsp/uefi/edk2-firmware.inc @@ -18,7 +18,6 @@ SRCBRANCH_edk2_platforms = "master" SRC_URI = "\ ${SRC_URI_EDK2};branch=${SRCBRANCH_edk2_platforms};name=edk2;destsuffix=edk2 \ ${SRC_URI_EDK2_PLATFORMS};branch=${SRCBRANCH_edk2};name=edk2-platforms;destsuffix=edk2/edk2-platforms \ - file://default.patch;patchdir=edk2-platforms \ " SRCREV_FORMAT = "edk2_edk2-platforms" diff --git a/meta-arm/meta-arm/recipes-bsp/uefi/edk2-firmware_%.bbappend b/meta-arm/meta-arm/recipes-bsp/uefi/edk2-firmware_2023%.bbappend index 19b335417c..19b335417c 100644 --- a/meta-arm/meta-arm/recipes-bsp/uefi/edk2-firmware_%.bbappend +++ b/meta-arm/meta-arm/recipes-bsp/uefi/edk2-firmware_2023%.bbappend diff --git a/meta-arm/meta-arm/recipes-bsp/uefi/edk2-firmware_202302.bb b/meta-arm/meta-arm/recipes-bsp/uefi/edk2-firmware_202302.bb index fa26c3e3aa..02738d318b 100644 --- a/meta-arm/meta-arm/recipes-bsp/uefi/edk2-firmware_202302.bb +++ b/meta-arm/meta-arm/recipes-bsp/uefi/edk2-firmware_202302.bb @@ -1,4 +1,6 @@ SRCREV_edk2 ?= "f80f052277c88a67c55e107b550f504eeea947d3" SRCREV_edk2-platforms ?= "65e001a7f2abedf7799cfb36b057326c1540bd47" +SRC_URI:append = " file://default.patch;patchdir=edk2-platforms" + require edk2-firmware.inc diff --git a/meta-arm/meta-arm/recipes-devtools/fvp/fvp-base-a-aem_11.20.15.bb b/meta-arm/meta-arm/recipes-devtools/fvp/fvp-base-a-aem_11.22.14.bb index 4c62822ed1..606f97723f 100644 --- a/meta-arm/meta-arm/recipes-devtools/fvp/fvp-base-a-aem_11.20.15.bb +++ b/meta-arm/meta-arm/recipes-devtools/fvp/fvp-base-a-aem_11.22.14.bb @@ -3,10 +3,10 @@ require fvp-envelope.inc SUMMARY = "Arm Fixed Virtual Platform - Armv-A Base RevC Architecture Envelope Model FVP" LIC_FILES_CHKSUM = "file://license_terms/license_agreement.txt;md5=1a33828e132ba71861c11688dbb0bd16 \ file://license_terms/third_party_licenses/third_party_licenses.txt;md5=34a1ba318d745f05e6197def68ea5411 \ - file://license_terms/third_party_licenses/arm_license_management_utilities/third_party_licenses.txt;md5=2e53bda6ff2db4c35d69944b93926c9f" + file://license_terms/third_party_licenses/arm_license_management_utilities/third_party_licenses.txt;md5=c09526c02e631abb95ad61528892552d" -SRC_URI[fvp-aarch64.sha256sum] = "e14e6cbd5c3ec8e1e2e79965e994c9235e136480e102f5c43de31162263b6361" -SRC_URI[fvp-x86_64.sha256sum] = "f9db2076e3a63e2f8eb2ea9ed60f30db04e5f81f535bc7e3ed24e270d857ea6f" +SRC_URI[fvp-aarch64.sha256sum] = "6964dbe0e297a5a6b5abd290d09e883923b5150e087f285fcfb80077525bfe6e" +SRC_URI[fvp-x86_64.sha256sum] = "eb0f5ca855fb8b0321e137b82306ac8a6b534a5625366ff10e20b3f68df533a4" MODEL_CODE = "FVP_Base_RevC-2xAEMvA" diff --git a/meta-arm/meta-arm/recipes-devtools/fvp/fvp-base-r-aem_11.20.15.bb b/meta-arm/meta-arm/recipes-devtools/fvp/fvp-base-r-aem_11.22.14.bb index 3f8139ca4a..89c83eabae 100644 --- a/meta-arm/meta-arm/recipes-devtools/fvp/fvp-base-r-aem_11.20.15.bb +++ b/meta-arm/meta-arm/recipes-devtools/fvp/fvp-base-r-aem_11.22.14.bb @@ -3,8 +3,8 @@ require fvp-envelope.inc SUMMARY = "Arm Fixed Virtual Platform - Armv8-R Base Architecture Envelope Model FVP" LIC_FILES_CHKSUM = "file://license_terms/license_agreement.txt;md5=1a33828e132ba71861c11688dbb0bd16 \ file://license_terms/third_party_licenses/third_party_licenses.txt;md5=34a1ba318d745f05e6197def68ea5411 \ - file://license_terms/third_party_licenses/arm_license_management_utilities/third_party_licenses.txt;md5=2e53bda6ff2db4c35d69944b93926c9f" + file://license_terms/third_party_licenses/arm_license_management_utilities/third_party_licenses.txt;md5=c09526c02e631abb95ad61528892552d" -SRC_URI[fvp-x86_64.sha256sum] = "c252616489b79fffa3bb721255b1c99ff4ee8c38e4beebce4fa05862a3195fe9" +SRC_URI[fvp-x86_64.sha256sum] = "e819bfbccd91749345e3c7c6db22cbe41e02223118eb6395a4307ca81b175f7a" MODEL_CODE = "FVP_Base_AEMv8R" diff --git a/meta-arm/meta-arm/recipes-kernel/linux/files/generic-arm64-kmeta/generic-arm64-preempt-rt-tweaks.cfg b/meta-arm/meta-arm/recipes-kernel/linux/files/generic-arm64-kmeta/generic-arm64-preempt-rt-tweaks.cfg new file mode 100644 index 0000000000..84e0dd71ca --- /dev/null +++ b/meta-arm/meta-arm/recipes-kernel/linux/files/generic-arm64-kmeta/generic-arm64-preempt-rt-tweaks.cfg @@ -0,0 +1,4 @@ +# These configurations have a dependency on !PREEMPT_RT. Set them to `n` to +# avoid complain when do_kernel_configcheck. +CONFIG_LEDS_TRIGGER_CPU=n +CONFIG_TRANSPARENT_HUGEPAGE=n diff --git a/meta-arm/meta-arm/recipes-kernel/linux/files/generic-arm64-kmeta/generic-arm64-preempt-rt.scc b/meta-arm/meta-arm/recipes-kernel/linux/files/generic-arm64-kmeta/generic-arm64-preempt-rt.scc new file mode 100644 index 0000000000..ae97c2e2a3 --- /dev/null +++ b/meta-arm/meta-arm/recipes-kernel/linux/files/generic-arm64-kmeta/generic-arm64-preempt-rt.scc @@ -0,0 +1,7 @@ +define KMACHINE generic-arm64 +define KTYPE preempt-rt +define KARCH arm64 + +kconf hardware generic-arm64-preempt-rt-tweaks.cfg +include ktypes/preempt-rt/preempt-rt.scc +include features/bluetooth/bluetooth.scc diff --git a/meta-arm/meta-arm/recipes-security/optee/optee-test/musl-workaround.patch b/meta-arm/meta-arm/recipes-security/optee/optee-test/0001-xtest-regression_1000-remove-unneeded-stat.h-include.patch index eed1bd4be1..5e075d6f49 100644 --- a/meta-arm/meta-arm/recipes-security/optee/optee-test/musl-workaround.patch +++ b/meta-arm/meta-arm/recipes-security/optee/optee-test/0001-xtest-regression_1000-remove-unneeded-stat.h-include.patch @@ -1,3 +1,8 @@ +From ddd5ad19732c9a2a9fe236662a8d264c6b2b1a0a Mon Sep 17 00:00:00 2001 +From: Jon Mason <jon.mason@arm.com> +Date: Sat, 15 Jul 2023 15:08:43 -0400 +Subject: [PATCH] xtest: regression_1000: remove unneeded stat.h include + Hack to work around musl compile error: In file included from optee-test/3.17.0-r0/recipe-sysroot/usr/include/sys/stat.h:23, from optee-test/3.17.0-r0/git/host/xtest/regression_1000.c:25: @@ -7,14 +12,19 @@ Hack to work around musl compile error: stat.h is not needed, since it is not being used in this file. So removing it. -Upstream-Status: Pending [Not submitted to upstream yet] +Upstream-Status: Backport [https://github.com/OP-TEE/optee_test/pull/688] Signed-off-by: Jon Mason <jon.mason@arm.com> +Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> +Acked-by: Jens Wiklander <jens.wiklander@linaro.org> +--- + host/xtest/regression_1000.c | 1 - + 1 file changed, 1 deletion(-) diff --git a/host/xtest/regression_1000.c b/host/xtest/regression_1000.c -index 4264884..7f1baca 100644 +index cd11f933ce43..8e338e59da21 100644 --- a/host/xtest/regression_1000.c +++ b/host/xtest/regression_1000.c -@@ -22,7 +22,6 @@ +@@ -24,7 +24,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/meta-arm/meta-arm/recipes-security/optee/optee-test_3.22.0.bb b/meta-arm/meta-arm/recipes-security/optee/optee-test_3.22.0.bb index 3b9632fa54..5d3f5a8a69 100644 --- a/meta-arm/meta-arm/recipes-security/optee/optee-test_3.22.0.bb +++ b/meta-arm/meta-arm/recipes-security/optee/optee-test_3.22.0.bb @@ -1,7 +1,7 @@ require optee-test.inc SRC_URI += " \ - file://musl-workaround.patch \ + file://0001-xtest-regression_1000-remove-unneeded-stat.h-include.patch \ " SRCREV = "a286b57f1721af215ace318d5807e63f40186df6" |