diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..9505b678 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,139 @@ +# Use our custom Crops-derived image +image: $CI_REGISTRY/$CI_PROJECT_NAMESPACE/yocto-builder:master + + # First do a common bootstrap, and then build all the targets +stages: + - bootstrap + - build + +# Common job fragment to get a worker ready +.setup: + stage: build + variables: + KAS_WORK_DIR: $CI_PROJECT_DIR/work + SSTATE_DIR: $CI_BUILDS_DIR/persist/sstate + DL_DIR: $CI_BUILDS_DIR/persist/downloads + BB_LOGCONFIG: $CI_PROJECT_DIR/kas/logging.yml + before_script: + - echo KAS_WORK_DIR = $KAS_WORK_DIR + - echo SSTATE_DIR = $SSTATE_DIR + - echo DL_DIR = $DL_DIR + - mkdir --verbose --parents $KAS_WORK_DIR $SSTATE_DIR $DL_DIR + +# Generalised fragment to do a Kas build +.build: + extends: .setup + script: + - KASFILES=$(kas/jobs-to-kas $CI_JOB_NAME) + - kas shell --update --force-checkout $KASFILES -c 'cat conf/*.conf' + - kas build $KASFILES + - ./kas/check-warnings $KAS_WORK_DIR/build/warnings.log + + +# +# First phase, bootstrap and machine coverage +# + +# Build a number of native tools first to ensure the other builders don't race +# over them +n1sdp/bootstrap: + extends: .build + stage: bootstrap + +# What percentage of machines in the layer do we build +machine-coverage: + stage: bootstrap + script: + - ./kas/check-machine-coverage + coverage: '/Coverage: \d+/' + + +# +# Second phase, the actual build jobs +# + +corstone500: + extends: .build + +corstone700-fvp: + extends: .build + +corstone700-mps3: + extends: .build + +fvp-base: + extends: .build + +fvp-base-arm32: + extends: .build + +fvp-base-arm32/external-gcc-arm32: + extends: .build + +gem5-arm64: + extends: .build + +juno: + extends: .build + +juno/clang: + extends: .build + +musca-b1: + extends: .build + +musca-s1: + extends: .build + +n1sdp: + extends: .build + +n1sdp/armgcc: + extends: .build + +qemuarm64-secureboot: + extends: .build + +qemuarm64-secureboot/clang: + extends: .build + +qemuarm64-secureboot/clang/musl: + extends: .build + +qemuarm64-secureboot/musl: + extends: .build + +sgi575: + extends: .build + +tc0: + extends: .build + + +# +# Utility tasks, not executed automatically +# + +# Report on disk usage +usage: + extends: .setup + stage: bootstrap + when: manual + script: + - du -h -s $DL_DIR $SSTATE_DIR + +# Wipe out old sstate +prune-sstate: + extends: .setup + stage: bootstrap + when: manual + script: + - find $SSTATE_DIR -type f -atime +30 -delete + +# Delete all sstate +delete-sstate: + extends: .setup + stage: bootstrap + when: manual + script: + - rm -rf $SSTATE_DIR/* diff --git a/kas/armgcc.yml b/kas/armgcc.yml new file mode 100644 index 00000000..4e05f5ef --- /dev/null +++ b/kas/armgcc.yml @@ -0,0 +1,6 @@ +header: + version: 9 + +local_conf_header: + cc: | + GCCVERSION = "arm-10.2" diff --git a/kas/base.yml b/kas/base.yml new file mode 100644 index 00000000..5a3aae44 --- /dev/null +++ b/kas/base.yml @@ -0,0 +1,44 @@ +header: + version: 9 + +distro: poky + +defaults: + repos: + refspec: master + +repos: + meta-arm: + layers: + meta-arm: + meta-arm-bsp: + meta-arm-toolchain: + + poky: + url: https://git.yoctoproject.org/git/poky + layers: + meta: + meta-poky: + +env: + BB_LOGCONFIG: "" + +local_conf_header: + base: | + CONF_VERSION = "1" + PACKAGE_CLASSES = "package_ipk" + LICENSE_FLAGS_WHITELIST += "armcompiler" + PACKAGECONFIG_remove_pn-qemu-system-native = "gtk+ sdl" + BB_NUMBER_THREADS = "16" + PARALLEL_MAKE = "-j16" + INHERIT += "rm_work" + PACKAGECONFIG_append_pn-perf = " coresight" + ERROR_QA = "${WARN_QA}" + ptest: | + DISTRO_FEATURES_remove = "ptest" + +machine: unset + +target: + - core-image-base + - perf diff --git a/kas/bootstrap.yml b/kas/bootstrap.yml new file mode 100644 index 00000000..0e05e46b --- /dev/null +++ b/kas/bootstrap.yml @@ -0,0 +1,9 @@ +header: + version: 9 + +target: + - binutils-cross-aarch64 + - gcc-cross-aarch64 + - python3-native + - opkg-native + - rpm-native diff --git a/kas/check-machine-coverage b/kas/check-machine-coverage new file mode 100755 index 00000000..53d39832 --- /dev/null +++ b/kas/check-machine-coverage @@ -0,0 +1,26 @@ +#! /usr/bin/env python3 + +from pathlib import Path +import sys + +metaarm = Path.cwd() + +if metaarm.name != "meta-arm": + print("Not running inside meta-arm") + sys.exit(1) + +# All machine configurations +machines = metaarm.glob("meta-*/conf/machine/*.conf") +machines = set(p.stem for p in machines) + +# All kas files +kas = metaarm.glob("kas/*.yml") +kas = set(p.stem for p in kas) + +missing = machines - kas +print(f"The following machines are missing: {', '.join(sorted(missing))}.") + +covered = len(machines) - len(missing) +total = len(machines) +percent = int(covered / total * 100) +print(f"Coverage: {percent}%") diff --git a/kas/check-warnings b/kas/check-warnings new file mode 100755 index 00000000..cc396423 --- /dev/null +++ b/kas/check-warnings @@ -0,0 +1,18 @@ +#! /bin/bash + +# Expects the path to a log file as $1, and if this file has any content +# then display the contents and exit with an error code. + +set -e -u + +LOGFILE=$1 + +if test -s $LOGFILE; then + echo ============================== + echo The build had warnings/errors: + echo ============================== + cat $LOGFILE + exit 1 +fi + +exit 0 diff --git a/kas/clang.yml b/kas/clang.yml new file mode 100644 index 00000000..f3524473 --- /dev/null +++ b/kas/clang.yml @@ -0,0 +1,10 @@ +header: + version: 9 + +repos: + meta-clang: + url: https://github.com/kraj/meta-clang + +local_conf_header: + clang: | + TOOLCHAIN = "clang" diff --git a/kas/corstone500.yml b/kas/corstone500.yml new file mode 100644 index 00000000..c348101d --- /dev/null +++ b/kas/corstone500.yml @@ -0,0 +1,6 @@ +header: + version: 9 + includes: + - base.yml + +machine: corstone500 diff --git a/kas/corstone700-fvp.yml b/kas/corstone700-fvp.yml new file mode 100644 index 00000000..e69fc4c0 --- /dev/null +++ b/kas/corstone700-fvp.yml @@ -0,0 +1,10 @@ +header: + version: 9 + includes: + - base.yml + +machine: corstone700-fvp + +local_conf_header: + image: | + CORE_IMAGE_EXTRA_INSTALL = "corstone700-test-app" diff --git a/kas/corstone700-mps3.yml b/kas/corstone700-mps3.yml new file mode 100644 index 00000000..3fa1a503 --- /dev/null +++ b/kas/corstone700-mps3.yml @@ -0,0 +1,6 @@ +header: + version: 9 + includes: + - corstone700-fvp.yml + +machine: corstone700-mps3 diff --git a/kas/external-gcc-arm32.yml b/kas/external-gcc-arm32.yml new file mode 100644 index 00000000..de8798e5 --- /dev/null +++ b/kas/external-gcc-arm32.yml @@ -0,0 +1,8 @@ +header: + version: 9 + +local_conf_header: + cc: | + PNBLACKLIST[gcc-cross-arm] = "Using external toolchain" + TCMODE = "external-arm" + EXTERNAL_TOOLCHAIN = "/usr/local/gcc-arm-10.2-2020.11-aarch64-arm-none-linux-gnueabihf" diff --git a/kas/fvp-base-arm32.yml b/kas/fvp-base-arm32.yml new file mode 100644 index 00000000..bb83a725 --- /dev/null +++ b/kas/fvp-base-arm32.yml @@ -0,0 +1,6 @@ +header: + version: 9 + includes: + - base.yml + +machine: fvp-base-arm32 diff --git a/kas/fvp-base.yml b/kas/fvp-base.yml new file mode 100644 index 00000000..1c3675fa --- /dev/null +++ b/kas/fvp-base.yml @@ -0,0 +1,7 @@ +header: + version: 9 + includes: + - base.yml + +machine: fvp-base + diff --git a/kas/gem5-arm64.yml b/kas/gem5-arm64.yml new file mode 100644 index 00000000..fc1b5c91 --- /dev/null +++ b/kas/gem5-arm64.yml @@ -0,0 +1,21 @@ +header: + version: 9 + includes: + - base.yml + +repos: + meta-arm: + layers: + meta-gem5: + + meta-openembedded: + url: https://git.openembedded.org/meta-openembedded + layers: + meta-oe: + +machine: gem5-arm64 + +target: + - core-image-minimal + - perf + - gem5-aarch64-native diff --git a/kas/jobs-to-kas b/kas/jobs-to-kas new file mode 100755 index 00000000..d1f2f108 --- /dev/null +++ b/kas/jobs-to-kas @@ -0,0 +1,19 @@ +#! /bin/bash + +# Read a GitLab CI job name on $1 and transform it to a +# list of Kas yaml files + +set -e -u + +# Read Job namne from $1 and split on / +IFS=/ read -r -a PARTS<<<$1 + +# Prefix each part with kas/ +PARTS=("${PARTS[@]/#/kas/}") + +# Suffix each part with .yml +PARTS=("${PARTS[@]/%/.yml}") + +# Print colon-separated +IFS=":" +echo "${PARTS[*]}" diff --git a/kas/juno.yml b/kas/juno.yml new file mode 100644 index 00000000..0badddd4 --- /dev/null +++ b/kas/juno.yml @@ -0,0 +1,6 @@ +header: + version: 9 + includes: + - base.yml + +machine: juno diff --git a/kas/logging.yml b/kas/logging.yml new file mode 100644 index 00000000..3af10295 --- /dev/null +++ b/kas/logging.yml @@ -0,0 +1,13 @@ +# Python logging configuration to write all warnings to a separate file +version: 1 + +handlers: + warnings: + class: logging.FileHandler + level: WARNING + filename: warnings.log + formatter: BitBake.logfileFormatter + +loggers: + BitBake: + handlers: [warnings] diff --git a/kas/meta-python.yml b/kas/meta-python.yml new file mode 100644 index 00000000..0b4b958e --- /dev/null +++ b/kas/meta-python.yml @@ -0,0 +1,9 @@ +header: + version: 9 + +repos: + meta-openembedded: + url: https://git.openembedded.org/meta-openembedded + layers: + meta-oe: + meta-python: diff --git a/kas/meta-zephyr.yml b/kas/meta-zephyr.yml new file mode 100644 index 00000000..aa3f97c1 --- /dev/null +++ b/kas/meta-zephyr.yml @@ -0,0 +1,8 @@ +header: + version: 9 + includes: + - meta-python.yml + +repos: + meta-zephyr: + url: https://git.yoctoproject.org/git/meta-zephyr diff --git a/kas/musca-b1.yml b/kas/musca-b1.yml new file mode 100644 index 00000000..4f5f02d8 --- /dev/null +++ b/kas/musca-b1.yml @@ -0,0 +1,11 @@ +header: + version: 9 + includes: + - base.yml + - meta-zephyr.yml + +machine: musca-b1 + +target: + - trusted-firmware-m + - zephyr-philosophers diff --git a/kas/musca-s1.yml b/kas/musca-s1.yml new file mode 100644 index 00000000..30a12d53 --- /dev/null +++ b/kas/musca-s1.yml @@ -0,0 +1,10 @@ +header: + version: 9 + includes: + - base.yml + - meta-python.yml + +machine: musca-s1 + +target: + - trusted-firmware-m diff --git a/kas/musl.yml b/kas/musl.yml new file mode 100644 index 00000000..cd58df79 --- /dev/null +++ b/kas/musl.yml @@ -0,0 +1,6 @@ +header: + version: 9 + +local_conf_header: + libc: | + TCLIBC = "musl" diff --git a/kas/n1sdp.yml b/kas/n1sdp.yml new file mode 100644 index 00000000..9e0d26a2 --- /dev/null +++ b/kas/n1sdp.yml @@ -0,0 +1,6 @@ +header: + version: 9 + includes: + - base.yml + +machine: n1sdp diff --git a/kas/qemuarm64-secureboot.yml b/kas/qemuarm64-secureboot.yml new file mode 100644 index 00000000..8236f87c --- /dev/null +++ b/kas/qemuarm64-secureboot.yml @@ -0,0 +1,11 @@ +header: + version: 9 + includes: + - base.yml + +machine: qemuarm64-secureboot + +target: + - core-image-base + - perf + - optee-examples diff --git a/kas/sgi575.yml b/kas/sgi575.yml new file mode 100644 index 00000000..43ee4b59 --- /dev/null +++ b/kas/sgi575.yml @@ -0,0 +1,6 @@ +header: + version: 9 + includes: + - base.yml + +machine: sgi575 diff --git a/kas/tc0.yml b/kas/tc0.yml new file mode 100644 index 00000000..47f95af3 --- /dev/null +++ b/kas/tc0.yml @@ -0,0 +1,6 @@ +header: + version: 9 + includes: + - base.yml + +machine: tc0 diff --git a/meta-arm-autonomy/classes/alternate-kernel.bbclass b/meta-arm-autonomy/classes/alternate-kernel.bbclass new file mode 100644 index 00000000..9ca59e2c --- /dev/null +++ b/meta-arm-autonomy/classes/alternate-kernel.bbclass @@ -0,0 +1,26 @@ +# This class is to be inherited by image recipes that want to build and install +# an alternate kernel (set via PREFERRED_PROVIDER_alternate/kernel). +# +# It is mandatory to also set the KERNEL_PACKAGE_NAME for the alternate kernel +# recipe via KERNEL_PACKAGE_NAME_pn-${PREFERRED_PROVIDER_alternate/kernel} and +# its value needs to be different from "kernel" since this is the default set +# for PREFERRED_PROVIDER_virtual/kernel. +# +# An example of these settings can be found at meta-arm-autonomy/dynamic-layers/meta-arm-bsp/conf/machine/n1sdp-extra-settings.inc +# +# When building and installing an alternate kernel, the kernel-modules packages +# for both virtual/kernel and alternate/kernel will be installed. + +PREFERRED_PROVIDER_alternate/kernel ??= "" + +python () { + alternate_kernel = d.getVar('PREFERRED_PROVIDER_alternate/kernel') + if alternate_kernel: + alternate_kernel_pkg_name = d.getVar('KERNEL_PACKAGE_NAME_pn-%s' % alternate_kernel) + if alternate_kernel_pkg_name: + d.appendVar('EXTRA_IMAGEDEPENDS', ' ' + alternate_kernel) + d.appendVar('IMAGE_INSTALL', ' kernel-modules') + d.appendVar('IMAGE_INSTALL', ' ' + alternate_kernel_pkg_name + '-modules') + else: + raise bb.parse.SkipRecipe("No KERNEL_PACKAGE_NAME_pn-%s set" % alternate_kernel ) +} diff --git a/meta-arm-autonomy/classes/xenguest-image.bbclass b/meta-arm-autonomy/classes/xenguest-image.bbclass index be1dde5f..5e5c4c78 100644 --- a/meta-arm-autonomy/classes/xenguest-image.bbclass +++ b/meta-arm-autonomy/classes/xenguest-image.bbclass @@ -43,14 +43,17 @@ XENGUEST_IMAGE_KERNEL ??= "Image" # be included in the xenguest image) XENGUEST_IMAGE_DISK_SIZE ??= "${@ '4' if not d.getVar('INITRAMFS_IMAGE') else '0'}" +# set empty partition to be used by xenguest-manager for this image +XENGUEST_IMAGE_DISK_DEVICE ??= "" + # -# XENGUEST_IMAGE_DISK PARTITIONS is used to describe the partitions to setup +# XENGUEST_IMAGE_DISK_PARTITIONS is used to describe the partitions to setup # and their content. # It must be set to a space separated list of entries with each entry having -# the format num:sz:fs:[file] where: +# the format num:sz:[fs]:[file] where: # - num is a partition number -# - sz is the partition size in Gigabit -# - fs is the filesystem to use for the partition +# - sz is the partition size in MB or GB(default), e.g 1000M or 1[G] +# - fs is optional filesystem to use for the partition # - file is optionally pointing to a file to use as content of the partition # Please check image_types_xenguest.bbclass for rootfs handling of files # @@ -62,7 +65,7 @@ XENGUEST_IMAGE_DISK_PARTITIONS ??= "1:${XENGUEST_IMAGE_DISK_SIZE}:ext4:rootfs.ta # The "bridge" type will share the physical eth interface from dom0 with the # domU. This will allow the domU to have access to the external network. # The "nat" type will setup a virtual network between dom0 and domU and also -# configure and run the dhcpd on dom0 to serve the domU. +# configure and run the kea dhcp4 server on dom0 to serve the domU. # The "none" type will not affect any networking setting between on dom0 and # domU. XENGUEST_IMAGE_NETWORK_TYPE ??= "bridge" @@ -129,21 +132,27 @@ xenguest_image_create() { # create disk if needed disksize="${XENGUEST_IMAGE_DISK_SIZE}" - if [ -z "$disksize" ]; then - disksize="0" - fi - if [ $disksize -gt 0 ]; then - # setup disk size - call_xenguest_mkimage update --disk-reset-config --disk-size=$disksize + case ${disksize:=0} in + 0|0M|0G) + ;; + *) + # setup disk size + call_xenguest_mkimage update --disk-reset-config --disk-size=$disksize + + diskparts="${XENGUEST_IMAGE_DISK_PARTITIONS}" + if [ -n "$diskparts" ]; then + for arg in $diskparts; do + call_xenguest_mkimage update --disk-add-part=$arg + done + fi + diskdevice="${XENGUEST_IMAGE_DISK_DEVICE}" + if [ -n "$diskdevice" ]; then + call_xenguest_mkimage update --disk-device="${diskdevice}" + fi + + ;; + esac - diskparts="${XENGUEST_IMAGE_DISK_PARTITIONS}" - if [ -n "$diskparts" ]; then - for arg in $diskparts; do - call_xenguest_mkimage update --disk-add-part=$arg - partnum="$(expr $partnum + 1)" - done - fi - fi if [ "${XENGUEST_IMAGE_AUTOBOOT}" = "1" ]; then call_xenguest_mkimage update --set-param=GUEST_AUTOBOOT=1 diff --git a/meta-arm-autonomy/conf/distro/include/arm-autonomy-host.inc b/meta-arm-autonomy/conf/distro/include/arm-autonomy-host.inc index 822677d9..b7b6af77 100644 --- a/meta-arm-autonomy/conf/distro/include/arm-autonomy-host.inc +++ b/meta-arm-autonomy/conf/distro/include/arm-autonomy-host.inc @@ -9,10 +9,6 @@ DISTRO_FEATURES_NATIVE_append = " arm-autonomy-host" # a bbappend: RDEPENDS_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-image" RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "" -# Until we don't move to use the kea dhcp-server we build dhcp_4.4.2.bb recipe -# which depends on bind_9.11.22.bb recipe. -PREFERRED_VERSION_bind ?= "9.11%" - # Require extra machine specific settings from meta-arm-bsp dynamic-layers only # if meta-arm-bsp is in the bblayers.conf # Directory for meta-arm-autonomy/dynamic-layers/meta-arm-bsp machine extra settings diff --git a/meta-arm-autonomy/conf/layer.conf b/meta-arm-autonomy/conf/layer.conf index 936b6c10..dee0c015 100644 --- a/meta-arm-autonomy/conf/layer.conf +++ b/meta-arm-autonomy/conf/layer.conf @@ -9,7 +9,7 @@ BBFILES += " \ BBFILE_COLLECTIONS += "meta-arm-autonomy" BBFILE_PATTERN_meta-arm-autonomy = "^${LAYERDIR}/" -BBFILE_PRIORITY_meta-arm-autonomy = "6" +BBFILE_PRIORITY_meta-arm-autonomy = "5" LAYERDEPENDS_meta-arm-autonomy = " \ core \ yocto \ diff --git a/meta-arm-autonomy/conf/machine/arm64-autonomy-guest.conf b/meta-arm-autonomy/conf/machine/arm64-autonomy-guest.conf index 8b32fa7a..097b382a 100644 --- a/meta-arm-autonomy/conf/machine/arm64-autonomy-guest.conf +++ b/meta-arm-autonomy/conf/machine/arm64-autonomy-guest.conf @@ -11,7 +11,7 @@ KERNEL_IMAGETYPE = "Image" IMAGE_FSTYPES += "tar.bz2" PREFERRED_PROVIDER_virtual/kernel = "linux-yocto" -PREFERRED_VERSION_linux-yocto ?= "5.4%" +PREFERRED_VERSION_linux-yocto ?= "5.10%" DISTRO_FEATURES += "arm-autonomy-guest" diff --git a/meta-arm-autonomy/documentation/arm-autonomy-multiconfig.md b/meta-arm-autonomy/documentation/arm-autonomy-multiconfig.md new file mode 100644 index 00000000..4f4bb746 --- /dev/null +++ b/meta-arm-autonomy/documentation/arm-autonomy-multiconfig.md @@ -0,0 +1,195 @@ +arm-autonomy Multiconfig Build Environment Instructions +================== + +This documentation explains how to simplify the process of building hosts +and guests in a single bitbake command, rather than in seperate build +folders. You can read more about multiconfig in the bitbake documentation: + + - [bitbake user manual](https://www.yoctoproject.org/docs/latest/bitbake-user-manual/bitbake-user-manual.html) + +To achieve a multiconfig build, a number of different config files need to +be created in a single build directory. + +Create a new project +---------------- + +Before you start, you will need to follow the instructions in +"Create a project" from the quickstart guide, to create a new project +directory with + ``` + oe-init-build-env my-mc-project + ``` +Ensure it has all the required layers in bblayers.conf as listed in +`arm-autonomy-quickstart.md`. The result should be a directory containing: + +``` +-- conf + | -- bblayers.conf + | -- local.conf + | -- templateconf.cfg +``` + +Add multiconfig +---------------- + +Here are the steps required to make the project build both the host and any +number of guests as required. + +1. Create a new directory under `conf/` named `multiconfig/` + +2. Create two new files in this directory: +`multiconfig/host.conf` +`multiconfig/guest.conf` +These files will contain any configurations that a specific to either the +host or the guest + +``` +-- conf + | -- bblayers.conf + | -- local.conf + | -- templateconf.cfg + | -- multiconfig + | -- host.conf + | -- guest.conf +``` + +3. In `local.conf` the following config variables must be added: + +``` +MACHINE ?= "fvp-base" + +# ---Guest Config Start--- # +MC_GUEST = "guest" + +MC_GUEST_NAME = "guest1" + +MC_GUEST_IMAGERECIPE = "core-image-minimal" +MC_GUEST_MACHINE = "arm64-autonomy-guest" + +MC_GUEST_INITRAMFS_IMAGE_BUNDLE ?= "" +MC_GUEST_INITRAMFS_IMAGE ?= "" + +# Uncomment for initramfs +#MC_GUEST_INITRAMFS_IMAGE_BUNDLE = "1" +#MC_GUEST_INITRAMFS_IMAGE = "${MC_GUEST_IMAGERECIPE}" + +# These variables are set automatically, don't edit them! +MC_GUEST_FILENAME_PREFIX = "${@ 'Image-initramfs' if d.getVar('MC_GUEST_INITRAMFS_IMAGE_BUNDLE',d) else '${MC_GUEST_IMAGERECIPE}' }" + +MC_GUEST_FILENAME = "${MC_GUEST_FILENAME_PREFIX}-${MC_GUEST_MACHINE}.xenguest" + +MC_GUEST_DEP = "${@ 'virtual/kernel:do_deploy' if d.getVar('MC_GUEST_INITRAMFS_IMAGE_BUNDLE',d) else '${MC_GUEST_IMAGERECIPE}:do_image_complete'}" + +MC_DOIMAGE_MCDEPENDS += "mc:${MC_HOST}:${MC_GUEST}:${MC_GUEST_DEP} " + +BBMULTICONFIG += "${MC_GUEST} " + +ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUESTS += "file://${TOPDIR}/${MC_GUEST}/deploy/images/${MC_GUEST_MACHINE}/${MC_GUEST_FILENAME};guestname=${MC_GUEST_NAME} " +# ---Guest Config End--- # + +# ---Host Config Start--- # +MC_HOST = "host" + +BBMULTICONFIG += "${MC_HOST} " +# ---Host Config End--- # +``` + +These variables will be used in both of the multiconf files. `MC_HOST` and +`MC_GUEST` should not be altered without renaming the conf files, but most +`MC_GUEST_*` variables can be customised if you desire. + +4. Next set the contents of `multiconfig/guest.conf`: + +``` +TMPDIR = "${TOPDIR}/${MC_GUEST}" + +MACHINE = "${MC_GUEST_MACHINE}" +DISTRO_FEATURES += " arm-autonomy-guest" + +INITRAMFS_IMAGE_BUNDLE = "${MC_GUEST_INITRAMFS_IMAGE_BUNDLE}" +INITRAMFS_IMAGE = "${MC_GUEST_INITRAMFS_IMAGE}" + +IMAGE_FSTYPES += "${@ 'cpio' if d.getVar('MC_GUEST_INITRAMFS_IMAGE_BUNDLE',d) else ''}" + +# ANY OTHER GUEST CONFIG +``` + +This contents shouldn't be changed directly, rather change the equivalent +config in local.conf. You can append any other config desired for the +guest at this point, for example `XENGUEST_IMAGE_DISK_SIZE` + +Make sure not to change `${DEPLOY_DIR_IMAGE}` to anything other than +`${TMPDIR}/deploy/images`, as this is assumed by local.conf. + +5. Lastly set the contents of `multiconfig/host.conf`: + +``` +TMPDIR = "${TOPDIR}/${MC_HOST}" + +DISTRO_FEATURES += " arm-autonomy-host" +``` + +Building the image +---------------- + +To build the multiconfig image the command is: +``` +bitbake mc:host:arm-autonomy-host-image-minimal +``` + +You should see that this triggers guest tasks to be built in +parallel. Once the build completes the guest will already be in the +rootfs of the host thanks to `ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUEST` + +The deployed image including the guest will be in `host/deploy/images/` + + +Multiple Guests +---------------- + +To have multiple guests with the same config the line which appends to +`ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUEST` just needs to be duplicated with +a different guestname. + +To have different config for each guest, each will need its own config +file similar to guest.conf, ensuring TMPDIR is set to a different path, +and everything between `---Guest Config Start---` and +`---Guest Config End---` will need to be duplicated. + +Any copies of variables that start `MC_GUEST` must be altered to avoid +collisions (e.g. `MC_GUEST_2_*`), and the name of the conf file must also +be added to BBMULTICONFIG. + + +Guest with provisioned disk +---------------- + +To add guest rootfs partition to host wic image, +set `AUTONOMY_HOST_EXTRA_PARTITION` with proper wks partition entry, e.g: + +``` +AUTONOMY_HOST_EXTRA_PARTITION = "part --label provisioned-guest --source rawcopy --fstype=ext4 --ondisk sda --align 1024 \ +--sourceparams=file=${TOPDIR}/${MC_GUEST}/deploy/images/${MC_GUEST_MACHINE}/${MC_GUEST_FILENAME_PREFIX}-${MC_GUEST_MACHINE}.ext4" +``` + +inside host.conf file. + +The rest of the configuration has to be appended to guest.conf file: + +``` +XENGUEST_IMAGE_DISK_SIZE = "0" +XENGUEST_IMAGE_SRC_URI_XEN_CONFIG = "file://\${TOPDIR}/path/to/rootdisk.cfg" +XENGUEST_IMAGE_DISK_DEVICE = "_GUEST_DISK_DEVICE_" +XENGUEST_IMAGE_ROOT = "/dev/xvda" +IMAGE_ROOTFS_SIZE = "102400" +IMAGE_FSTYPES = "ext4" +``` + +content of rootdisk.cfg" + +``` +disk = ["phy:_GUEST_DISK_DEVICE_,xvda,w"] +``` + +`_GUEST_DISK_DEVICE_` should be substituted with `/dev/sdaX`, +according to wks file. diff --git a/meta-arm-autonomy/documentation/arm-autonomy-quickstart.md b/meta-arm-autonomy/documentation/arm-autonomy-quickstart.md index eb02b3a6..1b729170 100644 --- a/meta-arm-autonomy/documentation/arm-autonomy-quickstart.md +++ b/meta-arm-autonomy/documentation/arm-autonomy-quickstart.md @@ -26,11 +26,10 @@ First you must download the Yocto layers needed: - [poky](https://git.yoctoproject.org/poky) - [meta-virtualization](https://git.yoctoproject.org/meta-virtualization) - [meta-arm](https://git.yoctoproject.org/meta-arm) - - [meta-kernel](https://gitlab.com/openembedded/community/meta-kernel.git) - all other layers you might want to use For each of the downloaded layer make sure you checkout the release of Yocto -you want to use (for example zeus using `git checkout zeus`). +you want to use (for example gatesgarth using `git checkout gatesgarth`). Please follow [Yocto documentation](https://www.yoctoproject.org/docs/latest/brief-yoctoprojectqs/brief-yoctoprojectqs.html) in order to have the required dependencies. @@ -57,7 +56,6 @@ Here are the main steps to create an arm-autonomy project: bitbake-layers add-layer $LAYERDIR_BASE/meta-poky $LAYERDIR_BASE/meta-yocto-bsp \ $LAYERDIR_BASE/meta-openembedded/meta-oe $LAYERDIR_BASE/meta-openembedded/meta-python \ $LAYERDIR_BASE/meta-openembedded/meta-filesystems $LAYERDIR_BASE/meta-openembedded/meta-networking \ - $LAYERDIR_BASE/meta-virtualization $LAYERDIR_BASE/meta-kernel \ $LAYERDIR_BASE/meta-arm/meta-arm $LAYERDIR_BASE/meta-arm/meta-arm-toolchain \ $LAYERDIR_BASE/meta-arm/meta-arm-bsp $LAYERDIR_BASE/meta-arm/meta-arm-autonomy \ ``` @@ -73,7 +71,6 @@ Here are the main steps to create an arm-autonomy project: /home/user/arm-autonomy/meta-openembedded/meta-filesystems \ /home/user/arm-autonomy/meta-openembedded/meta-networking \ /home/user/arm-autonomy/meta-virtualization \ - /home/user/arm-autonomy/meta-kernel \ /home/user/arm-autonomy/meta-arm/meta-arm \ /home/user/arm-autonomy/meta-arm/meta-arm-toolchain \ /home/user/arm-autonomy/meta-arm/meta-arm-bsp \ @@ -147,6 +144,9 @@ To create a guest project: The build will create a ".xenguest" image that can be use on an host project with the xenguest-manager. +The guest can also be built as a 'multiconfig' sub project of the host, see +`meta-arm-autonomy/documentation/arm-autonomy-multiconfig.md` for more information + Include guests directly in the host image ----------------------------------------- The layer provides a way to directly include in the host project one or several @@ -209,7 +209,7 @@ and is configuring it by default to use dhcp. If you need a different type of configuration you can set XENGUEST_NETWORK_BRIDGE_CONFIG in a xenguest-network-bridge.bbappend to use a different file. -The recipe will look for the file in ${WORKDIR} so you will need to add it to +The recipe will look for the file in ${WORKDIR} so you will need to add it to SRC_URI in your bbappend. The recipe will also substitute `###BRIDGE_NAME###` with the bridge name configured in ${XENGUEST_NETWORK_BRIDGE_NAME}. diff --git a/meta-arm-autonomy/documentation/n1sdp-image-customization.md b/meta-arm-autonomy/documentation/n1sdp-image-customization.md index 9e4186c1..80c11cb3 100644 --- a/meta-arm-autonomy/documentation/n1sdp-image-customization.md +++ b/meta-arm-autonomy/documentation/n1sdp-image-customization.md @@ -11,12 +11,17 @@ perform a couple of customizations in the generated wic image: 1 MiB per physical volume, hence it needs to be taken into account when setting GUEST_PART_SIZE. -2. The wic image partition layout and contents with a custom wks file via +2. Set the boot partition size (default: 100M) via `BOOT_PART_SIZE` and + `BOOT_PART_SIZE_UNIT` (M or G) variables in any conf file. The default + bootimg is ~44M so 100M leaves just over 50M of free space. + +3. The wic image partition layout and contents with a custom wks file via `ARM_AUTONOMY_WKS_FILE` variable (default: arm-autonomy-n1sdp-efidisk.wks.in which is affected by GUEST_PART_SIZE, - GUEST_PART_SIZE_UNIT and GRUB_CFG_FILE variables). + GUEST_PART_SIZE_UNIT, BOOT_PART_SIZE, BOOT_PART_SIZE_UNIT and + GRUB_CFG_FILE variables). -3. Custom grub.cfg file via `GRUB_CFG_FILE` (default: +4. Custom grub.cfg file via `GRUB_CFG_FILE` (default: arm-autonomy-n1sdp-grub.cfg) variable to be set in any conf file. The full path or relative to `ARM_AUTONOMY_WKS_FILE` should be set. diff --git a/meta-arm-autonomy/documentation/xen-devicetree.md b/meta-arm-autonomy/documentation/xen-devicetree.md index a44dca78..0b3f41bf 100644 --- a/meta-arm-autonomy/documentation/xen-devicetree.md +++ b/meta-arm-autonomy/documentation/xen-devicetree.md @@ -70,7 +70,10 @@ The following parameters are available: This variable is only used if XEN_DEVICETREE_XEN_BOOTARGS has a value containing "dom0_mem=${XEN_DEVICETREE_DOM0_MEM}" as the memory assigned to dom0 is defined using Xen boot arguments. - This variable is set by default to "1024M". + This variable is set by default to "1024M,max:1024", and cannot be empty. + The value can simply specify a size, e.g. "1024M", but best practice is to + also provide a max, documented here: + https://wiki.xenproject.org/wiki/Xen_Project_Best_Practices - XEN_DEVICETREE_DOM0_BOOTARGS: Boot arguments to pass to Dom0 Linux when booting it. @@ -84,7 +87,8 @@ The following parameters are available: - XEN_DEVICETREE_DOM0_ADDR: This is the address from which the Linux kernel to be used for Dom0 will be copied. When using u-boot, this is the address at which you will load the kernel Image before starting Xen. - This variable is set by default to "0x80080000". + This variable is set by default to "0x80080000", and cannot be empty. + Values for this variable can be in hex (prefixed with '0x') or in decimal. - XEN_DEVICETREE_DOM0_SIZE: This is the size of the kernel loaded at ${XEN_DEVICETREE_DOM0_ADDR}. Xen will copy this amount of data inside the @@ -92,7 +96,8 @@ The following parameters are available: size but can be bigger. You must be careful not to have a value too big as it could slow down boot or copy other parts with it (like the DTB). You might need to increase this if you use a kernel with a bundled initramfs. - This variable is set by default to "0x01000000". + This variable is set by default to "0x01000000" and cannot be empty. + Values for this variable can be in hex (prefixed with '0x') or in decimal. - XEN_DEVICETREE_DTSI_MERGE: This variable contains the list of dtsi files that must be included inside the generated DTB file. By default the only one diff --git a/meta-arm-autonomy/documentation/xenguest-manager.md b/meta-arm-autonomy/documentation/xenguest-manager.md index 387af944..11df2a1d 100644 --- a/meta-arm-autonomy/documentation/xenguest-manager.md +++ b/meta-arm-autonomy/documentation/xenguest-manager.md @@ -23,7 +23,7 @@ Usage ----- xenguest-manager must be called like this: -`xenguest-manager OPERATION [OPTIONS]` +`xenguest-manager [-v(v)] OPERATION [OPTIONS]` The following operations are available: - create XENGUEST_IMAGE [GUESTNAME]: create a guest from a xenguest image file as guest GUESTNAME. If GUESTNAME is not given the image file name is used @@ -37,6 +37,9 @@ The following operations are available: - status [GUESTNAME]: print the current status of GUESTNAME. If GUESTNAME is not given, print the status of all guests. +Passing -v or -vv will increase the logging written to the logfile. +The terminal will always show only error messages, regardless of the logfile. + For a detailed help on available options please use: `xenguest-manager --help` @@ -48,16 +51,16 @@ project compilation (those can be set in your project local.conf, for example). The following parameters are available: -- XENGUEST_MANAGER_VOLUME_DEVICE: This is the device path used by the +- XENGUEST_MANAGER_VOLUME_DEVICE: This is the device path used by the xenguest-manager on the device to create LVM disks when guests have a disk configuration. This is set by default to "/dev/sda2". -- XENGUEST_MANAGER_VOLUME_NAME: This is the LVM volume name that the +- XENGUEST_MANAGER_VOLUME_NAME: This is the LVM volume name that the xenguest-manager will create and use to create guest LVM disks. This is set by default to "vg-xen". -- XENGUEST_MANAGER_GUEST_DIR: This is the directory on Dom0 where the +- XENGUEST_MANAGER_GUEST_DIR: This is the directory on Dom0 where the xenguest-manager will look for xenguest images to create during init. That's the place where xenguest images can be added to have them automatically created during next Dom0 boot. The xenguests found there will only be created @@ -65,3 +68,63 @@ The following parameters are available: name). This is set by default to "/usr/share/guests". +- XENGUEST_MANAGER_LOG_LEVEL: Set the default log level for xenguest manager. Must + be one of ERROR, INFO, VERBOSE (default: ERROR). The extra will be + written to /var/log/xenguest. + + If a verbosity argument (-v or -vv) is passed to xenguest-manager directly, it + will override the setting in xenguest-manager.conf + +Init scripts +------------ + +Shell scripts can be executed on the host when a guest is started. Depending on +when the script should be executed it should be installed in a different +directory on the target: + +- /etc/xenguest/init.pre : Executed first, prior to guest creation + +- /etc/xenguest/init.d : Executed after guest creation, but before it is started + +- /etc/xenguest/init.post : Executed after starting the guest + +Inside the directory, scripts will be executed in alphabetical order. + +Since these scripts are sourced by xenguest-manager, they can acccess functions +and variables from the parent file's scope, including: + +- ${guestname} : The name of the guest being created + +- ${guestdir} : The path to the guest directory + +- ${guestcfgfile} : The name of the config file for the starting guest + +- log() : Used to write a log to the logfile, default level INFO. + Takes an optional log level and a message body + e.g. log ERROR "blah" + + Options for log level: ERROR, INFO, VERBOSE, and FATAL, which + will call exit 1 immediately after logging the message + +- log_command() : Used to call a shell command and log that it has been + called, as well as capturing both stdout and stderr. + + By default the command output is dumped to the logfile as an error + if the command returns a status > 0, or as a verbose message if the + whole script is running in verbose mode. An optional log level can + be passed to alter the level the log should be if the command returns + a status >0, + e.g. log_command INFO "ls -lh ~" + + Options for log level: ERROR, INFO, and VERBOSE + +Attempting to call any other functions from xenguest_manager in an init script may +result in a fatal error, from which cleanup is not guarenteed. + + +Sourcing also allows the script to access params.cfg. + +An example of how to create the directory and install an init shell script can +be found in: + recipes-extended/xenguest/xenguest-network.bb +Where network-bridge.sh is installed from network-bridge.sh.in diff --git a/meta-arm-autonomy/documentation/xenguest-mkimage.md b/meta-arm-autonomy/documentation/xenguest-mkimage.md index ece17f76..fd142b77 100644 --- a/meta-arm-autonomy/documentation/xenguest-mkimage.md +++ b/meta-arm-autonomy/documentation/xenguest-mkimage.md @@ -58,12 +58,19 @@ order. ### disk.cfg and disk-files disk.cfg contains the guest disk description (disk size and disk partitions). The file contains the following entries: -- `DISK_SIZE=X`: size of the disk to create in GB +- `DISK_SIZE=X`: size of the disk to create in MB or GB(default), + e.g. 1000M or 4[G] - `DISK_PARTX=SIZE:FS:CONTENT`: create a partition number X (1 to 4) with a - size of SIZE GB, format it with filesystem FS (can be ext2, ext3, ext4, vfat - or swap) and extract CONTENT as initial partition content - (.tar[.gz|.xz|.bz2] file or img[.gz|.bz2] file to be dumped in the partition). FS and - CONTENT can be empty. + size of SIZE MB or GB(default), e.g 1000M or 2[G]. + Format it with filesystem FS (can be ext2, ext3, ext4, vfat or swap) + and extract CONTENT as initial partition content (.tar[.gz|.xz|.bz2] file + or img[.gz|.bz2] file to be dumped in the partition). + FS and CONTENT can be empty. +- `DISK_DEVICE=X`: disk or partition to be used by lvm. Setting this option + allows to bind guest disk with any partition or disk available on host, + e.g. /dev/sda3 or /dev/sdb. + This variable is not set by default, but if set, it overrides disk settings + inside xenguest-manager.conf - 'XENGUEST_VOLUME_DEVICE'. The disk-files contain files to be used for initializing the disk partitions content. Those should be used to create a LVM or a physical disk and initialize @@ -105,12 +112,12 @@ For a detailed help on available operations, please use: image file. Several script can be added and the basename of FILE is used to distinguish them (calling the option twice with the same file will update the script in the image with the second one). - --disk-size=SIZE: set the guest disk size to SIZE in GB. Calling this with 0 - disable the guest disk. + --disk-size=SIZE: set the guest disk size to SIZE in MB or GB(default), + e.g 1000M or 2[G]. Calling this with 0 disable the guest disk. - --disk-add-part=NUM:SIZE:FS:CONTENT: This is adding a partition to the xenguest image disk. The partition is described with the arguments: - NUM: partition number. - - SIZE: partition size in GB. + - SIZE: partition size in MB or GB(default), e.g 1000M or 2[G]. - FS: filesystem to format the partition with. This can be ext2, ext3, ext4, vfat of swap. If empty the partition is not formated. - CONTENT: tar of img file to use to initialize the partition. The file must diff --git a/meta-arm-autonomy/documentation/xenguest-network.md b/meta-arm-autonomy/documentation/xenguest-network.md index b731f3ed..dad2698a 100644 --- a/meta-arm-autonomy/documentation/xenguest-network.md +++ b/meta-arm-autonomy/documentation/xenguest-network.md @@ -12,9 +12,10 @@ At the moment 3 types of network arrangements are provided: - Bridge: where the guest vif is added to the created bridge interface; -- NAT: where a private subnet is created for the guest, a dhcpd is started on - the host to serve the guest and the proper iptables rules are created to - allow the guest to access the external network; +- NAT: where a private subnet is created for the guest, + a kea dhcp4 server is started on the host to serve the guest + and the proper iptables rules are created + to allow the guest to access the external network; - None: the guest vif is not connected to the bridge. @@ -55,17 +56,20 @@ The following parameters are available: contains the dom0 physical interface giving the guest direct access to the external network. The **nat** type will setup a private network between dom0 and domU, setup - the appropriate routing table, configure and run the dhcpd on dom0 to serve - the domU and apply the iptables rules to allow the guest to acess the - external network. The dhcpd configuration for the guest can be customised by - replacing the - "meta-arm-autonomy/recipes-extended/xenguest/files/dhcpd-params.cfg" file - in a xenguest-network.bbappend. The dhcpd-params.cfg file is installed in + the appropriate routing table, configure and run the kea dhcp4 server + on dom0 to serve the domU and apply the iptables rules to allow the guest + to acess the external network. The kea dhcp4 server configuration for + the guest can be customised by replacing the + "meta-arm-autonomy/recipes-extended/xenguest/files/kea-subnet4.json" file + in a xenguest-network.bbappend. The kea-subnet4.json file is installed in the xenguest image and copied to - "/etc/xenguest/guests/${guestname}/files/dhcpd-params.cfg" when the guest + "/etc/xenguest/guests/${guestname}/files/kea-subnet4.json" when the guest image is created. It will be consumed by the "/etc/xen/scripts/vif-post.d/00-vif-xenguest.hook" script which is called by "/etc/xen/scripts/vif-nat" script when starting/stopping the xenguest. + After guest start, "/etc/xenguest/init.post/xenguest-network-init-post.sh" + script is called to reload kea dhcp4 server with updated configuration, + after virtual network interface is ready. In the guest project, the NAT port forward can be customised by changing the XENGUEST_IMAGE_HOST_PORT (default: "1000 + ${domid}") and XENGUEST_IMAGE_GUEST_PORT (default: "22") variables in local.conf or diff --git a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/conf/machine/juno-extra-settings.inc b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/conf/machine/juno-extra-settings.inc index 02600c59..f8a16f40 100644 --- a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/conf/machine/juno-extra-settings.inc +++ b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/conf/machine/juno-extra-settings.inc @@ -1,4 +1,26 @@ # Extra machine settings for juno +KERNEL_ALT_IMAGETYPE = "Image.lzma" # Juno board has 2 network interfaces, add both of them to the bridge XENGUEST_NETWORK_BRIDGE_MEMBERS ?= "eth0 eth1" +XEN_DEVICETREE_DOM0_SIZE ?= "0x02400000" + +# We need to extend the wks search path to be able to find the wks file set in +# ARM_AUTONOMY_WKS_FILE. +WKS_SEARCH_PATH_prepend := "${ARM_AUTONOMY_ARM_BSP_DYNAMIC_DIR}/wic:" + +ARM_AUTONOMY_WKS_FILE ?= "arm-autonomy-juno-disk.wks.in" +# set wks file only if INITRAMFS_IMAGE_BUNDLE is not set +WKS_FILE = "${@bb.utils.contains('INITRAMFS_IMAGE_BUNDLE', '1', '',\ + '${ARM_AUTONOMY_WKS_FILE}', d)}" + +# Set the wks guest partition size and unit. It must be aligned with the sum of +# all XENGUEST_IMAGE_DISK_SIZE set for the guests. By default, LVM2 metadata is +# 1 MiB per physical volume, hence it needs to be taken into account when +# setting GUEST_PART_SIZE. The XENGUEST_IMAGE_DISK_SIZE default value is 4GiB. +GUEST_PART_SIZE ?= "4097" +GUEST_PART_SIZE_UNIT ?= "M" + +# set wic image type only if INITRAMFS_IMAGE_BUNDLE is not set +IMAGE_FSTYPES += "${@bb.utils.contains('INITRAMFS_IMAGE_BUNDLE', '1', '',\ + 'wic wic.gz wic.bmap', d)}" diff --git a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/conf/machine/n1sdp-extra-settings.inc b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/conf/machine/n1sdp-extra-settings.inc index 472dd2a1..f39e2ea3 100644 --- a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/conf/machine/n1sdp-extra-settings.inc +++ b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/conf/machine/n1sdp-extra-settings.inc @@ -14,8 +14,19 @@ WKS_FILE = "${ARM_AUTONOMY_WKS_FILE}" GUEST_PART_SIZE ?= "4097" GUEST_PART_SIZE_UNIT ?= "M" +# Set default boot partition size and unit +BOOT_PART_SIZE ?= "100" +BOOT_PART_SIZE_UNIT ?= "M" + # The GRUB_CFG_FILE affects arm-autonomy-n1sdp-efidisk.wks.in file -GRUB_CFG_FILE ?= "${ARM_AUTONOMY_ARM_BSP_DYNAMIC_DIR}/wic/arm-autonomy-n1sdp-grub.cfg" +# +# When alternate-kernel DISTRO_FEATURE is present we set the +# arm-autonomy-n1sdp-rt-grub.cfg by default. This GRUB config file has +# additional entries for booting with the PREEMPT_RT kernel. +GRUB_CFG_FILE ?= "${@bb.utils.contains('DISTRO_FEATURES','alternate-kernel', \ + '${ARM_AUTONOMY_ARM_BSP_DYNAMIC_DIR}/wic/arm-autonomy-n1sdp-rt-grub.cfg', \ + '${ARM_AUTONOMY_ARM_BSP_DYNAMIC_DIR}/wic/arm-autonomy-n1sdp-grub.cfg' \ + , d)}" # From arm-autonomy-n1sdp-efidisk.wks.in, the /boot partition is /dev/sda1, and # the "/" partition is /dev/sda2. @@ -38,3 +49,42 @@ do_image_wic[depends] += "xen:do_deploy" IMAGE_EFI_BOOT_FILES += "xen-n1sdp.efi;xen.efi" IMAGE_EFI_BOOT_FILES += "${XEN_MOD_DEVICETREE_DTBS}" +# Use 5.4 kernel until later versions have been validated for autonomy-host +PREFERRED_PROVIDER_virtual/kernel = "linux-linaro-arm" +PREFERRED_VERSION_linux-linaro-arm = "5.4%" + +# When alternate-kernel DISTRO_FEATURE is present we set the linux-linaro-arm-rt +# by default +PREFERRED_PROVIDER_alternate/kernel ?= "\ +${@bb.utils.contains('DISTRO_FEATURES', 'alternate-kernel', \ +'linux-linaro-arm-rt', '', d)}" + +KERNEL_PACKAGE_NAME_alternate/kernel ?= "kernel-rt" +# When alternate-kernel DISTRO_FEATURE is present we set the kernel-rt by +# default +KERNEL_PACKAGE_NAME_pn-linux-linaro-arm-rt = "\ +${@ d.getVar('KERNEL_PACKAGE_NAME_alternate/kernel') \ +if bb.utils.contains('DISTRO_FEATURES', 'alternate-kernel', True, False, d) \ +else 'kernel' }" + +# Relative path from DEPLOY_DIR_IMAGE of the Kernel PREEMPT_RT deployed Image +KERNEL_RT_IMAGE ?= "kernel-rt/Image-n1sdp.bin;Image-preempt-rt" +# Only include the Kernel PREEMPT_RT Image if we are building with +# alternate-kernel DISTRO_FEATURE +IMAGE_EFI_BOOT_FILES += "\ +${@ d.getVar('KERNEL_RT_IMAGE',d) or '' \ +if bb.utils.contains('DISTRO_FEATURES', 'alternate-kernel', True, False, d) and \ +d.getVar('PREFERRED_PROVIDER_alternate/kernel') else ''}" + + +EFIDIR ?= "/EFI/BOOT" +GRUB_CFG_EXTRA_FILE ?= "${ARM_AUTONOMY_ARM_BSP_DYNAMIC_DIR}/wic/arm-autonomy-n1sdp-grub.cfg;.${EFIDIR}}" + +# When alternate-kernel DISTRO_FEATURE is present we set the +# arm-autonomy-n1sdp-rt-grub.cfg by default. This GRUB config file has +# additional entries for booting with the PREEMPT_RT kernel and also includes +# the main GRUB config file set by GRUB_CFG_EXTRA_FILE. +IMAGE_EFI_BOOT_FILES += "\ +${@ d.getVar('GRUB_CFG_EXTRA_FILE',d) or '' \ +if bb.utils.contains('DISTRO_FEATURES', 'alternate-kernel', True, False, d) and \ +d.getVar('PREFERRED_PROVIDER_alternate/kernel') else ''}" diff --git a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-bsp/images/firmware-image-juno.bbappend b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-bsp/images/firmware-image-juno.bbappend index b0aae695..6b94dc9b 100644 --- a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-bsp/images/firmware-image-juno.bbappend +++ b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-bsp/images/firmware-image-juno.bbappend @@ -4,6 +4,19 @@ OVERRIDES_append = "${@bb.utils.contains('DISTRO_FEATURES', 'xen', ':xen', '', d FILESEXTRAPATHS_prepend_xen := "${THISDIR}/${PN}:" +DEPENDS_append_xen = " dos2unix-native" + +SRC_URI_append_xen = " file://add-xen-support.patch;patchdir=../" + +do_install_append_xen() { + mv -v ${D}/${UNPACK_DIR}/SOFTWARE/uEnv.txt \ + ${D}/${UNPACK_DIR}/SOFTWARE/uenvfile + for dir in $(ls ${D}/${UNPACK_DIR}/SITE1/) + do + unix2dos ${D}/${UNPACK_DIR}/SITE1/${dir}/images.txt + done +} + DEPLOY_EXTRA_DEPS ??= "" DEPLOY_EXTRA_DEPS_xen = "xen:do_deploy xen-devicetree:do_deploy" @@ -14,8 +27,24 @@ do_deploy_prepend_xen() { # xen:do_deploy and xen-devicetree:do_deploy when # INITRAMFS_IMAGE_BUNDLE = "1", we need to handle the xen and # xen-devicetree binaries copying in the do_deploy task. - cp ${DEPLOY_DIR_IMAGE}/xen-${COMPATIBLE_MACHINE}.efi \ - ${D}/${UNPACK_DIR}/SOFTWARE/xen - cp ${DEPLOY_DIR_IMAGE}/*xen.dtb \ - ${D}/${UNPACK_DIR}/SOFTWARE/ + + mkdir -p ${D}/${UNPACK_DIR}/SOFTWARE/XEN + cp -v ${DEPLOY_DIR_IMAGE}/xen-${COMPATIBLE_MACHINE}.efi \ + ${D}/${UNPACK_DIR}/SOFTWARE/XEN/xen + + for dtb in $(basename -s .dtb ${KERNEL_DEVICETREE}) + do + cp -v ${DEPLOY_DIR_IMAGE}/${dtb}-xen.dtb \ + ${D}/${UNPACK_DIR}/SOFTWARE/XEN/${dtb}.dtb + done + + bbnote "Xen binaries added under SOFTWARE/XEN directory" + + if [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" -a "${KERNEL_ALT_IMAGETYPE}" = "Image.lzma" ]; then + # KERNEL_ALT_IMAGETYPE is expected to be Image.lzma, + # however NOR flash filesystem is DOS compatible with 8.3 naming, + # so we need to replace ".lzma" with ".lzm" + cp -L -f ${DEPLOY_DIR_IMAGE}/${KERNEL_ALT_IMAGETYPE} \ + ${D}/${UNPACK_DIR}/SOFTWARE/Image.lzm + fi } diff --git a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/add-xen-support.patch b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/add-xen-support.patch new file mode 100644 index 00000000..29f1e06f --- /dev/null +++ b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/add-xen-support.patch @@ -0,0 +1,173 @@ +arm-bsp/firmware-image-juno: add xen support + +This patch adds xen and dtbs binaries entries to images-r[012].txt files. +These images-r[012].txt files contain NOR filesystem entries details, +like file offset, name, path etc. + +It also adds customization for uEnv.txt file, that allows to autoboot xen. + +Upstream-Status: Inappropriate [configuration] +Signed-off-by: Kamil Dziezyk + +diff -u a/images-r0.txt b/images-r0.txt +--- a/images-r0.txt 2020-11-25 20:25:38.677687712 +0100 ++++ b/images-r0.txt 2020-11-25 20:36:55.482194294 +0100 +@@ -1,7 +1,7 @@ + TITLE: Versatile Express Images Configuration File + + [IMAGES] +-TOTALIMAGES: 10 ;Number of Images (Max: 32) ++TOTALIMAGES: 11 ;Number of Images (Max: 32) + + NOR0UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE + NOR0ADDRESS: 0x00000000 ;Image Flash Address +@@ -17,14 +17,14 @@ + + NOR2UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE + NOR2ADDRESS: 0x00500000 ;Image Flash Address +-NOR2FILE: \SOFTWARE\Image ;Image File Name +-NOR2NAME: norkern ;Rename kernel to norkern ++NOR2FILE: \SOFTWARE\Image.lzm ;Image File Name ++NOR2NAME: norkern.lzm ;Rename kernel to norkern.lzm + NOR2LOAD: 00000000 ;Image Load Address + NOR2ENTRY: 00000000 ;Image Entry Point + + NOR3UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE + NOR3ADDRESS: 0x02900000 ;Image Flash Address +-NOR3FILE: \SOFTWARE\juno.dtb ;Image File Name ++NOR3FILE: \SOFTWARE\XEN\juno.dtb ;Image File Name + NOR3NAME: board.dtb ;Specify target filename to preserve file extension + NOR3LOAD: 00000000 ;Image Load Address + NOR3ENTRY: 00000000 ;Image Entry Point +@@ -64,8 +64,13 @@ + NOR9UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE + NOR9ADDRESS: 0x02A80000 ;Image Flash Address + NOR9NAME: uEnv.txt +-NOR9FILE: \SOFTWARE\uEnv.txt ;Image File Name ++NOR9FILE: \SOFTWARE\uenvfile ;Image File Name + NOR9LOAD: 00000000 ;Image Load Address + NOR9ENTRY: 00000000 ;Image Entry Point + +- ++NOR10UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE ++NOR10ADDRESS: 0x03000000 ;Image Flash Address ++NOR10FILE: \SOFTWARE\XEN\xen ;Image File Name ++NOR10NAME: xen ++NOR10LOAD: 00000000 ;Image Load Address ++NOR10ENTRY: 00000000 ;Image Entry Point +diff -u a/images-r1.txt b/images-r1.txt +--- a/images-r1.txt 2020-11-25 20:40:19.005177152 +0100 ++++ b/images-r1.txt 2020-11-25 20:41:17.500886263 +0100 +@@ -1,7 +1,7 @@ + TITLE: Versatile Express Images Configuration File + + [IMAGES] +-TOTALIMAGES: 10 ;Number of Images (Max: 32) ++TOTALIMAGES: 11 ;Number of Images (Max: 32) + + NOR0UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE + NOR0ADDRESS: 0x00000000 ;Image Flash Address +@@ -17,14 +17,14 @@ + + NOR2UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE + NOR2ADDRESS: 0x00500000 ;Image Flash Address +-NOR2FILE: \SOFTWARE\Image ;Image File Name +-NOR2NAME: norkern ;Rename kernel to norkern ++NOR2FILE: \SOFTWARE\Image.lzm ;Image File Name ++NOR2NAME: norkern.lzm ;Rename kernel to norkern.lzm + NOR2LOAD: 00000000 ;Image Load Address + NOR2ENTRY: 00000000 ;Image Entry Point + + NOR3UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE + NOR3ADDRESS: 0x02900000 ;Image Flash Address +-NOR3FILE: \SOFTWARE\juno-r1.dtb ;Image File Name ++NOR3FILE: \SOFTWARE\XEN\juno-r1.dtb ;Image File Name + NOR3NAME: board.dtb ;Specify target filename to preserve file extension + NOR3LOAD: 00000000 ;Image Load Address + NOR3ENTRY: 00000000 ;Image Entry Point +@@ -64,8 +64,13 @@ + NOR9UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE + NOR9ADDRESS: 0x02A80000 ;Image Flash Address + NOR9NAME: uEnv.txt +-NOR9FILE: \SOFTWARE\uEnv.txt ;Image File Name ++NOR9FILE: \SOFTWARE\uenvfile ;Image File Name + NOR9LOAD: 00000000 ;Image Load Address + NOR9ENTRY: 00000000 ;Image Entry Point + +- ++NOR10UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE ++NOR10ADDRESS: 0x03000000 ;Image Flash Address ++NOR10FILE: \SOFTWARE\XEN\xen ;Image File Name ++NOR10NAME: xen ++NOR10LOAD: 00000000 ;Image Load Address ++NOR10ENTRY: 00000000 ;Image Entry Point +diff -u a/images-r2.txt b/images-r2.txt +--- a/images-r2.txt 2020-11-25 20:40:30.625119321 +0100 ++++ b/images-r2.txt 2020-11-25 20:41:30.720820597 +0100 +@@ -1,7 +1,7 @@ + TITLE: Versatile Express Images Configuration File + + [IMAGES] +-TOTALIMAGES: 10 ;Number of Images (Max: 32) ++TOTALIMAGES: 11 ;Number of Images (Max: 32) + + NOR0UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE + NOR0ADDRESS: 0x00000000 ;Image Flash Address +@@ -17,14 +17,14 @@ + + NOR2UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE + NOR2ADDRESS: 0x00500000 ;Image Flash Address +-NOR2FILE: \SOFTWARE\Image ;Image File Name +-NOR2NAME: norkern ;Rename kernel to norkern ++NOR2FILE: \SOFTWARE\Image.lzm ;Image File Name ++NOR2NAME: norkern.lzm ;Rename kernel to norkern.lzm + NOR2LOAD: 00000000 ;Image Load Address + NOR2ENTRY: 00000000 ;Image Entry Point + + NOR3UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE + NOR3ADDRESS: 0x02900000 ;Image Flash Address +-NOR3FILE: \SOFTWARE\juno-r2.dtb ;Image File Name ++NOR3FILE: \SOFTWARE\XEN\juno-r2.dtb ;Image File Name + NOR3NAME: board.dtb ;Specify target filename to preserve file extension + NOR3LOAD: 00000000 ;Image Load Address + NOR3ENTRY: 00000000 ;Image Entry Point +@@ -64,8 +64,13 @@ + NOR9UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE + NOR9ADDRESS: 0x02A80000 ;Image Flash Address + NOR9NAME: uEnv.txt +-NOR9FILE: \SOFTWARE\uEnv.txt ;Image File Name ++NOR9FILE: \SOFTWARE\uenvfile ;Image File Name + NOR9LOAD: 00000000 ;Image Load Address + NOR9ENTRY: 00000000 ;Image Entry Point + +- ++NOR10UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE ++NOR10ADDRESS: 0x03000000 ;Image Flash Address ++NOR10FILE: \SOFTWARE\XEN\xen ;Image File Name ++NOR10NAME: xen ++NOR10LOAD: 00000000 ;Image Load Address ++NOR10ENTRY: 00000000 ;Image Entry Point +diff -u a/uEnv.txt b/uEnv.txt +--- a/uEnv.txt 2020-11-20 13:48:31.845078690 +0100 ++++ b/uEnv.txt 2020-11-25 20:30:00.572306675 +0100 +@@ -1,11 +1,16 @@ ++xen_name=xen ++xen_addr=0x84000000 + uenvcmd=run mybootcmd ++kernel_alt_name=norkern.lzm ++kernel_comp_addr_r=0x88080000 + mybootcmd=echo Loading custom boot command; \ + echo Loading kernel; \ + afs load ${kernel_name} ${kernel_addr_r} ; \ +-if test $? -eq 1; then echo Loading ${kernel_alt_name} instead of ${kernel_name}; afs load ${kernel_alt_name} ${kernel_addr_r}; fi; \ ++if test $? -eq 1; then echo Loading ${kernel_alt_name} instead of ${kernel_name}; afs load ${kernel_alt_name} ${kernel_comp_addr_r}; lzmadec ${kernel_comp_addr_r} ${kernel_addr_r}; fi; \ + echo Loading device tree; \ + afs load ${fdtfile} ${fdt_addr_r}; \ + if test $? -eq 1; then echo Loading ${fdt_alt_name} instead of ${fdtfile}; \ + afs load ${fdt_alt_name} ${fdt_addr_r}; fi; fdt addr ${fdt_addr_r}; fdt resize; \ +-booti ${kernel_addr_r} - ${fdt_addr_r}; +- ++echo Loading Xen; \ ++afs load ${xen_name} ${xen_addr}; \ ++if test $? -eq 0; then echo Booting Xen; bootefi ${xen_addr} ${fdt_addr_r}; fi; + diff --git a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/images-r0.txt b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/images-r0.txt deleted file mode 100644 index ec32ca29..00000000 --- a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/images-r0.txt +++ /dev/null @@ -1,78 +0,0 @@ -TITLE: Versatile Express Images Configuration File - -[IMAGES] -TOTALIMAGES: 11 ;Number of Images (Max: 32) - -NOR0UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR0ADDRESS: 0x00000000 ;Image Flash Address -NOR0FILE: \SOFTWARE\fip.bin ;Image File Name -NOR0LOAD: 00000000 ;Image Load Address -NOR0ENTRY: 00000000 ;Image Entry Point - -NOR1UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR1ADDRESS: 0x03EC0000 ;Image Flash Address -NOR1FILE: \SOFTWARE\bl1.bin ;Image File Name -NOR1LOAD: 00000000 ;Image Load Address -NOR1ENTRY: 00000000 ;Image Entry Point - -NOR2UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR2ADDRESS: 0x00500000 ;Image Flash Address -NOR2FILE: \SOFTWARE\Image ;Image File Name -NOR2NAME: norkern ;Rename kernel to norkern -NOR2LOAD: 00000000 ;Image Load Address -NOR2ENTRY: 00000000 ;Image Entry Point - -NOR3UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR3ADDRESS: 0x02700000 ;Image Flash Address -NOR3FILE: \SOFTWARE\juno-xen.dtb ;Image File Name -NOR3NAME: board.dtb ;Specify target filename to preserve file extension -NOR3LOAD: 00000000 ;Image Load Address -NOR3ENTRY: 00000000 ;Image Entry Point - -NOR4UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR4ADDRESS: 0x01D00000 ;Image Flash Address -NOR4FILE: \SOFTWARE\xen ;Image File Name -NOR4NAME: xen -NOR4LOAD: 00000000 ;Image Load Address -NOR4ENTRY: 00000000 ;Image Entry Point - -NOR5UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR5ADDRESS: 0x025C0000 ;Image Flash Address -NOR5FILE: \SOFTWARE\hdlcdclk.dat ;Image File Name -NOR5LOAD: 00000000 ;Image Load Address -NOR5ENTRY: 00000000 ;Image Entry Point - -NOR6UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR6ADDRESS: 0x03E40000 ;Image Flash Address -NOR6FILE: \SOFTWARE\scp_bl1.bin ;Image File Name -NOR6LOAD: 00000000 ;Image Load Address -NOR6ENTRY: 00000000 ;Image Entry Point - -NOR7UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR7ADDRESS: 0x0BF00000 ;Image Flash Address -NOR7FILE: \SOFTWARE\startup.nsh ;Image File Name -NOR7NAME: startup.nsh -NOR7LOAD: 00000000 ;Image Load Address -NOR7ENTRY: 00000000 ;Image Entry Point - -NOR8UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR8ADDRESS: 0x0BFC0000 ;Image Flash Address -NOR8FILE: \SOFTWARE\blank.img ;Image File Name -NOR8NAME: BOOTENV -NOR8LOAD: 00000000 ;Image Load Address -NOR8ENTRY: 00000000 ;Image Entry Point - -NOR9UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR9ADDRESS: 0x02600000 ;Image Flash Address -NOR9FILE: \SOFTWARE\selftest ;Image File Name -NOR9LOAD: 00000000 ;Image Load Address -NOR9ENTRY: 00000000 ;Image Entry Point - -NOR10UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR10ADDRESS: 0x02780000 ;Image Flash Address -NOR10NAME: uEnv.txt -NOR10FILE: \SOFTWARE\uEnv.txt ;Image File Name -NOR10LOAD: 00000000 ;Image Load Address -NOR10ENTRY: 00000000 ;Image Entry Point - - diff --git a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/images-r1.txt b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/images-r1.txt deleted file mode 100644 index 1372bc30..00000000 --- a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/images-r1.txt +++ /dev/null @@ -1,78 +0,0 @@ -TITLE: Versatile Express Images Configuration File - -[IMAGES] -TOTALIMAGES: 11 ;Number of Images (Max: 32) - -NOR0UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR0ADDRESS: 0x00000000 ;Image Flash Address -NOR0FILE: \SOFTWARE\fip.bin ;Image File Name -NOR0LOAD: 00000000 ;Image Load Address -NOR0ENTRY: 00000000 ;Image Entry Point - -NOR1UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR1ADDRESS: 0x03EC0000 ;Image Flash Address -NOR1FILE: \SOFTWARE\bl1.bin ;Image File Name -NOR1LOAD: 00000000 ;Image Load Address -NOR1ENTRY: 00000000 ;Image Entry Point - -NOR2UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR2ADDRESS: 0x00500000 ;Image Flash Address -NOR2FILE: \SOFTWARE\Image ;Image File Name -NOR2NAME: norkern ;Rename kernel to norkern -NOR2LOAD: 00000000 ;Image Load Address -NOR2ENTRY: 00000000 ;Image Entry Point - -NOR3UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR3ADDRESS: 0x02700000 ;Image Flash Address -NOR3FILE: \SOFTWARE\juno-r1-xen.dtb ;Image File Name -NOR3NAME: board.dtb ;Specify target filename to preserve file extension -NOR3LOAD: 00000000 ;Image Load Address -NOR3ENTRY: 00000000 ;Image Entry Point - -NOR4UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR4ADDRESS: 0x01D00000 ;Image Flash Address -NOR4FILE: \SOFTWARE\xen ;Image File Name -NOR4NAME: xen -NOR4LOAD: 00000000 ;Image Load Address -NOR4ENTRY: 00000000 ;Image Entry Point - -NOR5UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR5ADDRESS: 0x025C0000 ;Image Flash Address -NOR5FILE: \SOFTWARE\hdlcdclk.dat ;Image File Name -NOR5LOAD: 00000000 ;Image Load Address -NOR5ENTRY: 00000000 ;Image Entry Point - -NOR6UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR6ADDRESS: 0x03E40000 ;Image Flash Address -NOR6FILE: \SOFTWARE\scp_bl1.bin ;Image File Name -NOR6LOAD: 00000000 ;Image Load Address -NOR6ENTRY: 00000000 ;Image Entry Point - -NOR7UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR7ADDRESS: 0x0BF00000 ;Image Flash Address -NOR7FILE: \SOFTWARE\startup.nsh ;Image File Name -NOR7NAME: startup.nsh -NOR7LOAD: 00000000 ;Image Load Address -NOR7ENTRY: 00000000 ;Image Entry Point - -NOR8UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR8ADDRESS: 0x0BFC0000 ;Image Flash Address -NOR8FILE: \SOFTWARE\blank.img ;Image File Name -NOR8NAME: BOOTENV -NOR8LOAD: 00000000 ;Image Load Address -NOR8ENTRY: 00000000 ;Image Entry Point - -NOR9UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR9ADDRESS: 0x02600000 ;Image Flash Address -NOR9FILE: \SOFTWARE\selftest ;Image File Name -NOR9LOAD: 00000000 ;Image Load Address -NOR9ENTRY: 00000000 ;Image Entry Point - -NOR10UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR10ADDRESS: 0x02780000 ;Image Flash Address -NOR10NAME: uEnv.txt -NOR10FILE: \SOFTWARE\uEnv.txt ;Image File Name -NOR10LOAD: 00000000 ;Image Load Address -NOR10ENTRY: 00000000 ;Image Entry Point - - diff --git a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/images-r2.txt b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/images-r2.txt deleted file mode 100644 index def465e1..00000000 --- a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/images-r2.txt +++ /dev/null @@ -1,78 +0,0 @@ -TITLE: Versatile Express Images Configuration File - -[IMAGES] -TOTALIMAGES: 11 ;Number of Images (Max: 32) - -NOR0UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR0ADDRESS: 0x00000000 ;Image Flash Address -NOR0FILE: \SOFTWARE\fip.bin ;Image File Name -NOR0LOAD: 00000000 ;Image Load Address -NOR0ENTRY: 00000000 ;Image Entry Point - -NOR1UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR1ADDRESS: 0x03EC0000 ;Image Flash Address -NOR1FILE: \SOFTWARE\bl1.bin ;Image File Name -NOR1LOAD: 00000000 ;Image Load Address -NOR1ENTRY: 00000000 ;Image Entry Point - -NOR2UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR2ADDRESS: 0x00500000 ;Image Flash Address -NOR2FILE: \SOFTWARE\Image ;Image File Name -NOR2NAME: norkern ;Rename kernel to norkern -NOR2LOAD: 00000000 ;Image Load Address -NOR2ENTRY: 00000000 ;Image Entry Point - -NOR3UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR3ADDRESS: 0x02700000 ;Image Flash Address -NOR3FILE: \SOFTWARE\juno-r2-xen.dtb ;Image File Name -NOR3NAME: board.dtb ;Specify target filename to preserve file extension -NOR3LOAD: 00000000 ;Image Load Address -NOR3ENTRY: 00000000 ;Image Entry Point - -NOR4UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR4ADDRESS: 0x01D00000 ;Image Flash Address -NOR4FILE: \SOFTWARE\xen ;Image File Name -NOR4NAME: xen -NOR4LOAD: 00000000 ;Image Load Address -NOR4ENTRY: 00000000 ;Image Entry Point - -NOR5UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR5ADDRESS: 0x025C0000 ;Image Flash Address -NOR5FILE: \SOFTWARE\hdlcdclk.dat ;Image File Name -NOR5LOAD: 00000000 ;Image Load Address -NOR5ENTRY: 00000000 ;Image Entry Point - -NOR6UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR6ADDRESS: 0x03E40000 ;Image Flash Address -NOR6FILE: \SOFTWARE\scp_bl1.bin ;Image File Name -NOR6LOAD: 00000000 ;Image Load Address -NOR6ENTRY: 00000000 ;Image Entry Point - -NOR7UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR7ADDRESS: 0x0BF00000 ;Image Flash Address -NOR7FILE: \SOFTWARE\startup.nsh ;Image File Name -NOR7NAME: startup.nsh -NOR7LOAD: 00000000 ;Image Load Address -NOR7ENTRY: 00000000 ;Image Entry Point - -NOR8UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR8ADDRESS: 0x0BFC0000 ;Image Flash Address -NOR8FILE: \SOFTWARE\blank.img ;Image File Name -NOR8NAME: BOOTENV -NOR8LOAD: 00000000 ;Image Load Address -NOR8ENTRY: 00000000 ;Image Entry Point - -NOR9UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR9ADDRESS: 0x02600000 ;Image Flash Address -NOR9FILE: \SOFTWARE\selftest ;Image File Name -NOR9LOAD: 00000000 ;Image Load Address -NOR9ENTRY: 00000000 ;Image Entry Point - -NOR10UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR10ADDRESS: 0x02780000 ;Image Flash Address -NOR10NAME: uEnv.txt -NOR10FILE: \SOFTWARE\uEnv.txt ;Image File Name -NOR10LOAD: 00000000 ;Image Load Address -NOR10ENTRY: 00000000 ;Image Entry Point - - diff --git a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/uEnv.txt b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/uEnv.txt deleted file mode 100644 index 4307b696..00000000 --- a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/uEnv.txt +++ /dev/null @@ -1,15 +0,0 @@ -xen_name=xen -xen_addr=0x84000000 -uenvcmd=run mybootcmd -mybootcmd=echo Loading custom boot command; \ -echo Loading kernel; \ -afs load ${kernel_name} ${kernel_addr} ; \ -if test $? -eq 1; then echo Loading ${kernel_alt_name} instead of ${kernel_name}; afs load ${kernel_alt_name} ${kernel_addr}; fi; \ -echo Loading device tree; \ -afs load ${fdtfile} ${fdt_addr}; \ -if test $? -eq 1; then echo Loading ${fdt_alt_name} instead of ${fdtfile}; \ -afs load ${fdt_alt_name} ${fdt_addr}; fi; fdt addr ${fdt_addr}; fdt resize; \ -echo Loading Xen; \ -afs load ${xen_name} ${xen_addr}; \ -if test $? -eq 0; then echo Booting Xen; bootefi ${xen_addr} ${fdt_addr}; fi; - diff --git a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-kernel/linux/arm-autonomy-kmeta-extra/features/arm-autonomy/preempt-rt-extras.cfg b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-kernel/linux/arm-autonomy-kmeta-extra/features/arm-autonomy/preempt-rt-extras.cfg new file mode 100644 index 00000000..bf9e14b1 --- /dev/null +++ b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-kernel/linux/arm-autonomy-kmeta-extra/features/arm-autonomy/preempt-rt-extras.cfg @@ -0,0 +1,7 @@ +# Yocto kernel-cache sets CONFIG_NLS_CODEPAGE_437=m for LINUX_KERNEL_TYPR=preempt-rt +CONFIG_NLS_CODEPAGE_437=y +# Yocto kernel-cache sets CONFIG_NLS_ISO8859_1=m for LINUX_KERNEL_TYPR=preempt-rt +CONFIG_NLS_ISO8859_1=y + +# Set the timer interrupt run at 1000 Hz to have a fast response +CONFIG_HZ_1000=y diff --git a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-kernel/linux/arm-autonomy-kmeta-extra/features/arm-autonomy/preempt-rt-extras.scc b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-kernel/linux/arm-autonomy-kmeta-extra/features/arm-autonomy/preempt-rt-extras.scc new file mode 100644 index 00000000..676291b9 --- /dev/null +++ b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-kernel/linux/arm-autonomy-kmeta-extra/features/arm-autonomy/preempt-rt-extras.scc @@ -0,0 +1,3 @@ +define KFEATURE_DESCRIPTION "Extra kernel configs when building with PREEMPT_RT" + +kconf non-hardware preempt-rt-extras.cfg diff --git a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-rt-5.4/0001-xen-use-handle_fasteoi_irq-to-handle-xen-dynamic-eve.patch b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-rt-5.4/0001-xen-use-handle_fasteoi_irq-to-handle-xen-dynamic-eve.patch new file mode 100644 index 00000000..39c159fb --- /dev/null +++ b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-rt-5.4/0001-xen-use-handle_fasteoi_irq-to-handle-xen-dynamic-eve.patch @@ -0,0 +1,80 @@ +From c2971c8a3f076ea8a522ce4fbb367d112d86c13a Mon Sep 17 00:00:00 2001 +From: Stefano Stabellini +Date: Mon, 27 Apr 2020 16:15:26 -0700 +Subject: [PATCH] xen: use handle_fasteoi_irq to handle xen dynamic events + +When handling Xen events, we need to make sure the following sequence is +followed: + +- mask event +- handle event and clear event (the order does not matter) +- unmask event + +It is not possible to implement this flow with handle_edge_irq, so +switch back to handle_fasteoi_irq. Please note that Xen event irqs are +ONESHOT. Also note that handle_fasteoi_irq was in-use before the +following commit, that is partially reverted by this patch: + +7e186bdd0098 xen: do not clear and mask evtchns in __xen_evtchn_do_upcall + +PIRQ handling is left unchanged. + +This patch fixes a domU hang observed when using LinuxRT as dom0 kernel. + +Link: https://lkml.org/lkml/2020/4/27/1287 +Signed-off-by: Stefano Stabellini + +Upstream-Status: Inappropriate since the upstream solution diverges from this patch +Signed-off-by: Kamil Dziezyk +--- + drivers/xen/events/events_base.c | 13 +++---------- + 1 file changed, 3 insertions(+), 10 deletions(-) + +diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c +index 6c8843968a52..1873a19b8b24 100644 +--- a/drivers/xen/events/events_base.c ++++ b/drivers/xen/events/events_base.c +@@ -845,7 +845,7 @@ int bind_evtchn_to_irq(unsigned int evtchn) + goto out; + + irq_set_chip_and_handler_name(irq, &xen_dynamic_chip, +- handle_edge_irq, "event"); ++ handle_fasteoi_irq, "event"); + + ret = xen_irq_info_evtchn_setup(irq, evtchn); + if (ret < 0) { +@@ -978,7 +978,7 @@ int bind_virq_to_irq(unsigned int virq, unsigned int cpu, bool percpu) + handle_percpu_irq, "virq"); + else + irq_set_chip_and_handler_name(irq, &xen_dynamic_chip, +- handle_edge_irq, "virq"); ++ handle_fasteoi_irq, "virq"); + + bind_virq.virq = virq; + bind_virq.vcpu = xen_vcpu_nr(cpu); +@@ -1387,12 +1387,6 @@ static void ack_dynirq(struct irq_data *data) + clear_evtchn(evtchn); + } + +-static void mask_ack_dynirq(struct irq_data *data) +-{ +- disable_dynirq(data); +- ack_dynirq(data); +-} +- + static int retrigger_dynirq(struct irq_data *data) + { + unsigned int evtchn = evtchn_from_irq(data->irq); +@@ -1595,8 +1589,7 @@ static struct irq_chip xen_dynamic_chip __read_mostly = { + .irq_mask = disable_dynirq, + .irq_unmask = enable_dynirq, + +- .irq_ack = ack_dynirq, +- .irq_mask_ack = mask_ack_dynirq, ++ .irq_eoi = ack_dynirq, + + .irq_set_affinity = set_affinity_irq, + .irq_retrigger = retrigger_dynirq, +-- +2.17.1 + diff --git a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-rt_5.4.bbappend b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-rt_5.4.bbappend new file mode 100644 index 00000000..b0a1ecf8 --- /dev/null +++ b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-rt_5.4.bbappend @@ -0,0 +1,7 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-5.4:" + +SRC_URI_append = " \ + file://0001-xen-use-handle_fasteoi_irq-to-handle-xen-dynamic-eve.patch \ + " + +KERNEL_FEATURES += "features/arm-autonomy/preempt-rt-extras.scc" diff --git a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/wic/arm-autonomy-juno-disk.wks.in b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/wic/arm-autonomy-juno-disk.wks.in new file mode 100644 index 00000000..bfacb208 --- /dev/null +++ b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/wic/arm-autonomy-juno-disk.wks.in @@ -0,0 +1,14 @@ +# short-description: Create a disk image +# long-description: Creates a partitioned disk image that the user +# can directly dd to boot media. + +# For Juno first partition is rootfs normally populated as /dev/sda1 +part / --source rootfs --ondisk sda --fstype=ext4 --label root --align 1024 + +# Second partition to accomodate guests images normally populated as /dev/sda2 (used by XENGUEST_MANAGER_VOLUME_DEVICE) +part --label guests --source empty --ondisk sda --size="${GUEST_PART_SIZE}${GUEST_PART_SIZE_UNIT}" --system-id 8e --align 1024 + +# Third partition is user defined entry normally populated as /dev/sda3 +${AUTONOMY_HOST_EXTRA_PARTITION} + +bootloader --ptable msdos diff --git a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/wic/arm-autonomy-n1sdp-efidisk.wks.in b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/wic/arm-autonomy-n1sdp-efidisk.wks.in index d91d568d..b48ec77e 100644 --- a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/wic/arm-autonomy-n1sdp-efidisk.wks.in +++ b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/wic/arm-autonomy-n1sdp-efidisk.wks.in @@ -3,7 +3,7 @@ # can directly dd to boot media. Uses a custom grub.cfg file to configure the boot. # First boot partition normally populated as /dev/sda1 -part /boot --source bootimg-efi --sourceparams="loader=grub-efi" --ondisk sda --label msdos --active --align 1024 +part /boot --source bootimg-efi --sourceparams="loader=grub-efi" --ondisk sda --size="${BOOT_PART_SIZE}${BOOT_PART_SIZE_UNIT}" --label msdos --active --align 1024 # Second rootfs partition normally populated as /dev/sda2 part / --source rootfs --ondisk sda --fstype=ext4 --label root --align 1024 @@ -11,4 +11,7 @@ part / --source rootfs --ondisk sda --fstype=ext4 --label root --align 1024 # Third partition to accomodate guests images normally populated as /dev/sda3 (used by XENGUEST_MANAGER_VOLUME_DEVICE) part --label guests --source empty --ondisk sda --size="${GUEST_PART_SIZE}${GUEST_PART_SIZE_UNIT}" --system-id 8e --align 1024 +# Fourth partition is user defined entry normally populated as /dev/sda4 +${AUTONOMY_HOST_EXTRA_PARTITION} + bootloader --ptable msdos --configfile="${GRUB_CFG_FILE}" diff --git a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/wic/arm-autonomy-n1sdp-rt-grub.cfg b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/wic/arm-autonomy-n1sdp-rt-grub.cfg new file mode 100644 index 00000000..31d0bbf8 --- /dev/null +++ b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/wic/arm-autonomy-n1sdp-rt-grub.cfg @@ -0,0 +1,28 @@ +set term="vt100" +set default="3" +set timeout="5" + +source $prefix/arm-autonomy-n1sdp-grub.cfg + +menuentry 'N1SDP PREEMPT_RT ACPI Boot' { + linux /Image-preempt-rt $kernel_cmdline acpi=force +} + +menuentry 'N1SDP PREEMPT_RT Single-Chip Boot (Device Tree)' { + devicetree /n1sdp-single-chip.dtb + linux /Image-preempt-rt $kernel_cmdline +} + +menuentry 'N1SDP PREEMPT_RT Multi-Chip Boot (Device Tree)' { + devicetree /n1sdp-multi-chip.dtb + linux /Image-preempt-rt $kernel_cmdline +} + +menuentry 'N1SDP PREEMPT_RT Arm Autonomy (Xen) Single-Chip Boot (Device Tree)' { + # no_argumants under here is a workaround for a bug + # also any kernel or dom0 cmdline arguments has to be passed via dtb + # because any arguments put here will be ignored by xen + xen_hypervisor /xen.efi no_arguments=use_dtb_for_xen_or_kernel_cmdline + xen_module /Image-preempt-rt + devicetree /n1sdp-single-chip-xen.dtb +} diff --git a/meta-arm-autonomy/recipes-connectivity/bind/README.md b/meta-arm-autonomy/recipes-connectivity/bind/README.md deleted file mode 100644 index 5971d169..00000000 --- a/meta-arm-autonomy/recipes-connectivity/bind/README.md +++ /dev/null @@ -1,4 +0,0 @@ -For now, arm-autonomy-host-image-minimal installs the dhcp-server package and -the dchp-4.4.2 depends on bind 9.11 which recipe was copied from oe-core tree -https://git.openembedded.org/openembedded-core/tree/meta/recipes-connectivity/bind?id=087e4fafeef82cfd3d71402d6b200fe831f48697 -since it got removed in the https://git.openembedded.org/openembedded-core/commit/meta/recipes-connectivity?id=29949cd7cf3a660fb3bcf251f5127a4cdb2804ec patch. diff --git a/meta-arm-autonomy/recipes-connectivity/bind/bind/0001-avoid-start-failure-with-bind-user.patch b/meta-arm-autonomy/recipes-connectivity/bind/bind/0001-avoid-start-failure-with-bind-user.patch deleted file mode 100644 index 8db96ec0..00000000 --- a/meta-arm-autonomy/recipes-connectivity/bind/bind/0001-avoid-start-failure-with-bind-user.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 31dde3562f287429eea94b77250d184818b49063 Mon Sep 17 00:00:00 2001 -From: Chen Qi -Date: Mon, 15 Oct 2018 16:55:09 +0800 -Subject: [PATCH] avoid start failure with bind user - -Upstream-Status: Pending - -Signed-off-by: Chen Qi ---- - init.d | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/init.d b/init.d -index b2eec60..6e03936 100644 ---- a/init.d -+++ b/init.d -@@ -57,6 +57,7 @@ case "$1" in - modprobe capability >/dev/null 2>&1 || true - if [ ! -f /etc/bind/rndc.key ]; then - /usr/sbin/rndc-confgen -a -b 512 -r /dev/urandom -+ chown root:bind /etc/bind/rndc.key >/dev/null 2>&1 || true - chmod 0640 /etc/bind/rndc.key - fi - if [ -f /var/run/named/named.pid ]; then --- -2.7.4 - diff --git a/meta-arm-autonomy/recipes-connectivity/bind/bind/0001-configure.in-remove-useless-L-use_openssl-lib.patch b/meta-arm-autonomy/recipes-connectivity/bind/bind/0001-configure.in-remove-useless-L-use_openssl-lib.patch deleted file mode 100644 index 9d31b980..00000000 --- a/meta-arm-autonomy/recipes-connectivity/bind/bind/0001-configure.in-remove-useless-L-use_openssl-lib.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 2325a92f1896a2a7f586611686801b41fbc91b50 Mon Sep 17 00:00:00 2001 -From: Hongxu Jia -Date: Mon, 27 Aug 2018 15:00:51 +0800 -Subject: [PATCH] configure.in: remove useless `-L$use_openssl/lib' - -Since `--with-openssl=${STAGING_DIR_HOST}${prefix}' is used in bind recipe, -the `-L$use_openssl/lib' has a hardcoded suffix, removing it is harmless -and helpful for clean up host build path in isc-config.sh - -Upstream-Status: Inappropriate [oe-core specific] - -Signed-off-by: Hongxu Jia - ---- - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/configure.ac b/configure.ac -index e85a5c6..2bbfc58 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -1631,7 +1631,7 @@ If you don't want OpenSSL, use --without-openssl]) - fi - ;; - *) -- DST_OPENSSL_LIBS="-L$use_openssl/lib -lcrypto" -+ DST_OPENSSL_LIBS="-lcrypto" - ;; - esac - fi diff --git a/meta-arm-autonomy/recipes-connectivity/bind/bind/0001-named-lwresd-V-and-start-log-hide-build-options.patch b/meta-arm-autonomy/recipes-connectivity/bind/bind/0001-named-lwresd-V-and-start-log-hide-build-options.patch deleted file mode 100644 index 75908aa6..00000000 --- a/meta-arm-autonomy/recipes-connectivity/bind/bind/0001-named-lwresd-V-and-start-log-hide-build-options.patch +++ /dev/null @@ -1,34 +0,0 @@ -From a3af4a405baf5ff582e82aaba392dd9667d94bdc Mon Sep 17 00:00:00 2001 -From: Hongxu Jia -Date: Mon, 27 Aug 2018 21:24:20 +0800 -Subject: [PATCH] `named/lwresd -V' and start log hide build options - -The build options expose build path directories, so hide them. -[snip] -$ named -V -|built by make with *** (options are hidden) -[snip] - -Upstream-Status: Inappropriate [oe-core specific] - -Signed-off-by: Hongxu Jia ---- - bin/named/include/named/globals.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/bin/named/include/named/globals.h b/bin/named/include/named/globals.h -index ba3457e..7741da7 100644 ---- a/bin/named/include/named/globals.h -+++ b/bin/named/include/named/globals.h -@@ -68,7 +68,7 @@ EXTERN const char * ns_g_version INIT(VERSION); - EXTERN const char * ns_g_product INIT(PRODUCT); - EXTERN const char * ns_g_description INIT(DESCRIPTION); - EXTERN const char * ns_g_srcid INIT(SRCID); --EXTERN const char * ns_g_configargs INIT(CONFIGARGS); -+EXTERN const char * ns_g_configargs INIT("*** (options are hidden)"); - EXTERN const char * ns_g_builder INIT(BUILDER); - EXTERN in_port_t ns_g_port INIT(0); - EXTERN isc_dscp_t ns_g_dscp INIT(-1); --- -2.7.4 - diff --git a/meta-arm-autonomy/recipes-connectivity/bind/bind/bind-ensure-searching-for-json-headers-searches-sysr.patch b/meta-arm-autonomy/recipes-connectivity/bind/bind/bind-ensure-searching-for-json-headers-searches-sysr.patch deleted file mode 100644 index 84559e5f..00000000 --- a/meta-arm-autonomy/recipes-connectivity/bind/bind/bind-ensure-searching-for-json-headers-searches-sysr.patch +++ /dev/null @@ -1,47 +0,0 @@ -From edda20fb5a6e88548f85e39d34d6c074306e15bc Mon Sep 17 00:00:00 2001 -From: Paul Gortmaker -Date: Tue, 9 Jun 2015 11:22:00 -0400 -Subject: [PATCH] bind: ensure searching for json headers searches sysroot - -Bind can fail configure by detecting headers w/o libs[1], or -it can fail the host contamination check as per below: - -ERROR: This autoconf log indicates errors, it looked at host include and/or library paths while determining system capabilities. -Rerun configure task after fixing this. The path was 'build/tmp/work/core2-64-poky-linux/bind/9.10.2-r1/build' -ERROR: Function failed: do_qa_configure -ERROR: Logfile of failure stored in: build/tmp/work/core2-64-poky-linux/bind/9.10.2-r1/temp/log.do_configure.5242 -ERROR: Task 5 (meta/recipes-connectivity/bind/bind_9.10.2.bb, do_configure) failed with exit code '1' -NOTE: Tasks Summary: Attempted 773 tasks of which 768 didn't need to be rerun and 1 failed. -No currently running tasks (773 of 781) - -Summary: 1 task failed: - /meta/recipes-connectivity/bind/bind_9.10.2.bb, do_configure - -One way to fix it would be to unconditionally disable json in bind -configure[2] but here we fix it by using the path to where we would -put the header if we had json in the sysroot, in case someone wants -to make use of the combination some day. - -[1] https://trac.macports.org/ticket/45305 -[2] https://trac.macports.org/changeset/126406 - -Upstream-Status: Inappropriate [OE Specific] -Signed-off-by: Paul Gortmaker - ---- - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/configure.ac b/configure.ac -index 17392fd..e85a5c6 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -2449,7 +2449,7 @@ case "$use_libjson" in - libjson_libs="" - ;; - auto|yes) -- for d in /usr /usr/local /opt/local -+ for d in "${STAGING_INCDIR}" - do - if test -f "${d}/include/json/json.h" - then diff --git a/meta-arm-autonomy/recipes-connectivity/bind/bind/bind9 b/meta-arm-autonomy/recipes-connectivity/bind/bind/bind9 deleted file mode 100644 index 968679ff..00000000 --- a/meta-arm-autonomy/recipes-connectivity/bind/bind/bind9 +++ /dev/null @@ -1,2 +0,0 @@ -# startup options for the server -OPTIONS="-u bind" diff --git a/meta-arm-autonomy/recipes-connectivity/bind/bind/conf.patch b/meta-arm-autonomy/recipes-connectivity/bind/bind/conf.patch deleted file mode 100644 index aad345f9..00000000 --- a/meta-arm-autonomy/recipes-connectivity/bind/bind/conf.patch +++ /dev/null @@ -1,330 +0,0 @@ -Upstream-Status: Inappropriate [configuration] - -the patch is imported from openembedded project - -11/30/2010 - Qing He - -diff -urN bind-9.3.1.orig/conf/db.0 bind-9.3.1/conf/db.0 ---- bind-9.3.1.orig/conf/db.0 1970-01-01 01:00:00.000000000 +0100 -+++ bind-9.3.1/conf/db.0 2005-07-10 22:14:00.000000000 +0200 -@@ -0,0 +1,12 @@ -+; -+; BIND reverse data file for broadcast zone -+; -+$TTL 604800 -+@ IN SOA localhost. root.localhost. ( -+ 1 ; Serial -+ 604800 ; Refresh -+ 86400 ; Retry -+ 2419200 ; Expire -+ 604800 ) ; Negative Cache TTL -+; -+@ IN NS localhost. -diff -urN bind-9.3.1.orig/conf/db.127 bind-9.3.1/conf/db.127 ---- bind-9.3.1.orig/conf/db.127 1970-01-01 01:00:00.000000000 +0100 -+++ bind-9.3.1/conf/db.127 2005-07-10 22:14:00.000000000 +0200 -@@ -0,0 +1,13 @@ -+; -+; BIND reverse data file for local loopback interface -+; -+$TTL 604800 -+@ IN SOA localhost. root.localhost. ( -+ 1 ; Serial -+ 604800 ; Refresh -+ 86400 ; Retry -+ 2419200 ; Expire -+ 604800 ) ; Negative Cache TTL -+; -+@ IN NS localhost. -+1.0.0 IN PTR localhost. -diff -urN bind-9.3.1.orig/conf/db.empty bind-9.3.1/conf/db.empty ---- bind-9.3.1.orig/conf/db.empty 1970-01-01 01:00:00.000000000 +0100 -+++ bind-9.3.1/conf/db.empty 2005-07-10 22:14:00.000000000 +0200 -@@ -0,0 +1,14 @@ -+; BIND reverse data file for empty rfc1918 zone -+; -+; DO NOT EDIT THIS FILE - it is used for multiple zones. -+; Instead, copy it, edit named.conf, and use that copy. -+; -+$TTL 86400 -+@ IN SOA localhost. root.localhost. ( -+ 1 ; Serial -+ 604800 ; Refresh -+ 86400 ; Retry -+ 2419200 ; Expire -+ 86400 ) ; Negative Cache TTL -+; -+@ IN NS localhost. -diff -urN bind-9.3.1.orig/conf/db.255 bind-9.3.1/conf/db.255 ---- bind-9.3.1.orig/conf/db.255 1970-01-01 01:00:00.000000000 +0100 -+++ bind-9.3.1/conf/db.255 2005-07-10 22:14:00.000000000 +0200 -@@ -0,0 +1,12 @@ -+; -+; BIND reserve data file for broadcast zone -+; -+$TTL 604800 -+@ IN SOA localhost. root.localhost. ( -+ 1 ; Serial -+ 604800 ; Refresh -+ 86400 ; Retry -+ 2419200 ; Expire -+ 604800 ) ; Negative Cache TTL -+; -+@ IN NS localhost. -diff -urN bind-9.3.1.orig/conf/db.local bind-9.3.1/conf/db.local ---- bind-9.3.1.orig/conf/db.local 1970-01-01 01:00:00.000000000 +0100 -+++ bind-9.3.1/conf/db.local 2005-07-10 22:14:00.000000000 +0200 -@@ -0,0 +1,13 @@ -+; -+; BIND data file for local loopback interface -+; -+$TTL 604800 -+@ IN SOA localhost. root.localhost. ( -+ 1 ; Serial -+ 604800 ; Refresh -+ 86400 ; Retry -+ 2419200 ; Expire -+ 604800 ) ; Negative Cache TTL -+; -+@ IN NS localhost. -+@ IN A 127.0.0.1 -diff -urN bind-9.3.1.orig/conf/db.root bind-9.3.1/conf/db.root ---- bind-9.3.1.orig/conf/db.root 1970-01-01 01:00:00.000000000 +0100 -+++ bind-9.3.1/conf/db.root 2005-07-10 22:14:00.000000000 +0200 -@@ -0,0 +1,45 @@ -+ -+; <<>> DiG 9.2.3 <<>> ns . @a.root-servers.net. -+;; global options: printcmd -+;; Got answer: -+;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18944 -+;; flags: qr aa rd; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 13 -+ -+;; QUESTION SECTION: -+;. IN NS -+ -+;; ANSWER SECTION: -+. 518400 IN NS A.ROOT-SERVERS.NET. -+. 518400 IN NS B.ROOT-SERVERS.NET. -+. 518400 IN NS C.ROOT-SERVERS.NET. -+. 518400 IN NS D.ROOT-SERVERS.NET. -+. 518400 IN NS E.ROOT-SERVERS.NET. -+. 518400 IN NS F.ROOT-SERVERS.NET. -+. 518400 IN NS G.ROOT-SERVERS.NET. -+. 518400 IN NS H.ROOT-SERVERS.NET. -+. 518400 IN NS I.ROOT-SERVERS.NET. -+. 518400 IN NS J.ROOT-SERVERS.NET. -+. 518400 IN NS K.ROOT-SERVERS.NET. -+. 518400 IN NS L.ROOT-SERVERS.NET. -+. 518400 IN NS M.ROOT-SERVERS.NET. -+ -+;; ADDITIONAL SECTION: -+A.ROOT-SERVERS.NET. 3600000 IN A 198.41.0.4 -+B.ROOT-SERVERS.NET. 3600000 IN A 192.228.79.201 -+C.ROOT-SERVERS.NET. 3600000 IN A 192.33.4.12 -+D.ROOT-SERVERS.NET. 3600000 IN A 128.8.10.90 -+E.ROOT-SERVERS.NET. 3600000 IN A 192.203.230.10 -+F.ROOT-SERVERS.NET. 3600000 IN A 192.5.5.241 -+G.ROOT-SERVERS.NET. 3600000 IN A 192.112.36.4 -+H.ROOT-SERVERS.NET. 3600000 IN A 128.63.2.53 -+I.ROOT-SERVERS.NET. 3600000 IN A 192.36.148.17 -+J.ROOT-SERVERS.NET. 3600000 IN A 192.58.128.30 -+K.ROOT-SERVERS.NET. 3600000 IN A 193.0.14.129 -+L.ROOT-SERVERS.NET. 3600000 IN A 198.32.64.12 -+M.ROOT-SERVERS.NET. 3600000 IN A 202.12.27.33 -+ -+;; Query time: 81 msec -+;; SERVER: 198.41.0.4#53(a.root-servers.net.) -+;; WHEN: Sun Feb 1 11:27:14 2004 -+;; MSG SIZE rcvd: 436 -+ -diff -urN bind-9.3.1.orig/conf/named.conf bind-9.3.1/conf/named.conf ---- bind-9.3.1.orig/conf/named.conf 1970-01-01 01:00:00.000000000 +0100 -+++ bind-9.3.1/conf/named.conf 2005-07-10 22:33:46.000000000 +0200 -@@ -0,0 +1,49 @@ -+// This is the primary configuration file for the BIND DNS server named. -+// -+// If you are just adding zones, please do that in /etc/bind/named.conf.local -+ -+include "/etc/bind/named.conf.options"; -+ -+// prime the server with knowledge of the root servers -+zone "." { -+ type hint; -+ file "/etc/bind/db.root"; -+}; -+ -+// be authoritative for the localhost forward and reverse zones, and for -+// broadcast zones as per RFC 1912 -+ -+zone "localhost" { -+ type master; -+ file "/etc/bind/db.local"; -+}; -+ -+zone "127.in-addr.arpa" { -+ type master; -+ file "/etc/bind/db.127"; -+}; -+ -+zone "0.in-addr.arpa" { -+ type master; -+ file "/etc/bind/db.0"; -+}; -+ -+zone "255.in-addr.arpa" { -+ type master; -+ file "/etc/bind/db.255"; -+}; -+ -+// zone "com" { type delegation-only; }; -+// zone "net" { type delegation-only; }; -+ -+// From the release notes: -+// Because many of our users are uncomfortable receiving undelegated answers -+// from root or top level domains, other than a few for whom that behaviour -+// has been trusted and expected for quite some length of time, we have now -+// introduced the "root-delegations-only" feature which applies delegation-only -+// logic to all top level domains, and to the root domain. An exception list -+// should be specified, including "MUSEUM" and "DE", and any other top level -+// domains from whom undelegated responses are expected and trusted. -+// root-delegation-only exclude { "DE"; "MUSEUM"; }; -+ -+include "/etc/bind/named.conf.local"; -diff -urN bind-9.3.1.orig/conf/named.conf.local bind-9.3.1/conf/named.conf.local ---- bind-9.3.1.orig/conf/named.conf.local 1970-01-01 01:00:00.000000000 +0100 -+++ bind-9.3.1/conf/named.conf.local 2005-07-10 22:14:06.000000000 +0200 -@@ -0,0 +1,8 @@ -+// -+// Do any local configuration here -+// -+ -+// Consider adding the 1918 zones here, if they are not used in your -+// organization -+//include "/etc/bind/zones.rfc1918"; -+ -diff -urN bind-9.3.1.orig/conf/named.conf.options bind-9.3.1/conf/named.conf.options ---- bind-9.3.1.orig/conf/named.conf.options 1970-01-01 01:00:00.000000000 +0100 -+++ bind-9.3.1/conf/named.conf.options 2005-07-10 22:14:06.000000000 +0200 -@@ -0,0 +1,24 @@ -+options { -+ directory "/var/cache/bind"; -+ -+ // If there is a firewall between you and nameservers you want -+ // to talk to, you might need to uncomment the query-source -+ // directive below. Previous versions of BIND always asked -+ // questions using port 53, but BIND 8.1 and later use an unprivileged -+ // port by default. -+ -+ // query-source address * port 53; -+ -+ // If your ISP provided one or more IP addresses for stable -+ // nameservers, you probably want to use them as forwarders. -+ // Uncomment the following block, and insert the addresses replacing -+ // the all-0's placeholder. -+ -+ // forwarders { -+ // 0.0.0.0; -+ // }; -+ -+ auth-nxdomain no; # conform to RFC1035 -+ -+}; -+ -diff -urN bind-9.3.1.orig/conf/zones.rfc1918 bind-9.3.1/conf/zones.rfc1918 ---- bind-9.3.1.orig/conf/zones.rfc1918 1970-01-01 01:00:00.000000000 +0100 -+++ bind-9.3.1/conf/zones.rfc1918 2005-07-10 22:14:10.000000000 +0200 -@@ -0,0 +1,20 @@ -+zone "10.in-addr.arpa" { type master; file "/etc/bind/db.empty"; }; -+ -+zone "16.172.in-addr.arpa" { type master; file "/etc/bind/db.empty"; }; -+zone "17.172.in-addr.arpa" { type master; file "/etc/bind/db.empty"; }; -+zone "18.172.in-addr.arpa" { type master; file "/etc/bind/db.empty"; }; -+zone "19.172.in-addr.arpa" { type master; file "/etc/bind/db.empty"; }; -+zone "20.172.in-addr.arpa" { type master; file "/etc/bind/db.empty"; }; -+zone "21.172.in-addr.arpa" { type master; file "/etc/bind/db.empty"; }; -+zone "22.172.in-addr.arpa" { type master; file "/etc/bind/db.empty"; }; -+zone "23.172.in-addr.arpa" { type master; file "/etc/bind/db.empty"; }; -+zone "24.172.in-addr.arpa" { type master; file "/etc/bind/db.empty"; }; -+zone "25.172.in-addr.arpa" { type master; file "/etc/bind/db.empty"; }; -+zone "26.172.in-addr.arpa" { type master; file "/etc/bind/db.empty"; }; -+zone "27.172.in-addr.arpa" { type master; file "/etc/bind/db.empty"; }; -+zone "28.172.in-addr.arpa" { type master; file "/etc/bind/db.empty"; }; -+zone "29.172.in-addr.arpa" { type master; file "/etc/bind/db.empty"; }; -+zone "30.172.in-addr.arpa" { type master; file "/etc/bind/db.empty"; }; -+zone "31.172.in-addr.arpa" { type master; file "/etc/bind/db.empty"; }; -+ -+zone "168.192.in-addr.arpa" { type master; file "/etc/bind/db.empty"; }; -diff -urN bind-9.3.1.orig/init.d bind-9.3.1/init.d ---- bind-9.3.1.orig/init.d 1970-01-01 01:00:00.000000000 +0100 -+++ bind-9.3.1/init.d 2005-07-10 23:09:58.000000000 +0200 -@@ -0,0 +1,70 @@ -+#!/bin/sh -+ -+PATH=/sbin:/bin:/usr/sbin:/usr/bin -+ -+# for a chrooted server: "-u bind -t /var/lib/named" -+# Don't modify this line, change or create /etc/default/bind9. -+OPTIONS="" -+ -+test -f /etc/default/bind9 && . /etc/default/bind9 -+ -+test -x /usr/sbin/rndc || exit 0 -+ -+case "$1" in -+ start) -+ echo -n "Starting domain name service: named" -+ -+ modprobe capability >/dev/null 2>&1 || true -+ if [ ! -f /etc/bind/rndc.key ]; then -+ /usr/sbin/rndc-confgen -a -b 512 -r /dev/urandom -+ chmod 0640 /etc/bind/rndc.key -+ fi -+ if [ -f /var/run/named/named.pid ]; then -+ ps `cat /var/run/named/named.pid` > /dev/null && exit 1 -+ fi -+ -+ # dirs under /var/run can go away on reboots. -+ mkdir -p /var/run/named -+ mkdir -p /var/cache/bind -+ chmod 775 /var/run/named -+ chown root:bind /var/run/named >/dev/null 2>&1 || true -+ -+ if [ ! -x /usr/sbin/named ]; then -+ echo "named binary missing - not starting" -+ exit 1 -+ fi -+ if start-stop-daemon --start --quiet --exec /usr/sbin/named \ -+ --pidfile /var/run/named/named.pid -- $OPTIONS; then -+ if [ -x /sbin/resolvconf ] ; then -+ echo "nameserver 127.0.0.1" | /sbin/resolvconf -a lo -+ fi -+ fi -+ echo "." -+ ;; -+ -+ stop) -+ echo -n "Stopping domain name service: named" -+ if [ -x /sbin/resolvconf ]; then -+ /sbin/resolvconf -d lo -+ fi -+ /usr/sbin/rndc stop >/dev/null 2>&1 -+ echo "." -+ ;; -+ -+ reload) -+ /usr/sbin/rndc reload -+ ;; -+ -+ restart|force-reload) -+ $0 stop -+ sleep 2 -+ $0 start -+ ;; -+ -+ *) -+ echo "Usage: /etc/init.d/bind {start|stop|reload|restart|force-reload}" >&2 -+ exit 1 -+ ;; -+esac -+ -+exit 0 diff --git a/meta-arm-autonomy/recipes-connectivity/bind/bind/generate-rndc-key.sh b/meta-arm-autonomy/recipes-connectivity/bind/bind/generate-rndc-key.sh deleted file mode 100644 index ef915c0a..00000000 --- a/meta-arm-autonomy/recipes-connectivity/bind/bind/generate-rndc-key.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -if [ ! -s /etc/bind/rndc.key ]; then - echo -n "Generating /etc/bind/rndc.key:" - /usr/sbin/rndc-confgen -a -b 512 -r /dev/urandom - chown root:bind /etc/bind/rndc.key - chmod 0640 /etc/bind/rndc.key -fi diff --git a/meta-arm-autonomy/recipes-connectivity/bind/bind/init.d-add-support-for-read-only-rootfs.patch b/meta-arm-autonomy/recipes-connectivity/bind/bind/init.d-add-support-for-read-only-rootfs.patch deleted file mode 100644 index 11db95ed..00000000 --- a/meta-arm-autonomy/recipes-connectivity/bind/bind/init.d-add-support-for-read-only-rootfs.patch +++ /dev/null @@ -1,65 +0,0 @@ -Subject: init.d: add support for read-only rootfs - -Upstream-Status: Inappropriate [oe specific] - -Signed-off-by: Chen Qi ---- - init.d | 40 ++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 40 insertions(+) - -diff --git a/init.d b/init.d -index 0111ed4..24677c8 100644 ---- a/init.d -+++ b/init.d -@@ -6,8 +6,48 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin - # Don't modify this line, change or create /etc/default/bind9. - OPTIONS="" - -+test -f /etc/default/rcS && . /etc/default/rcS - test -f /etc/default/bind9 && . /etc/default/bind9 - -+# This function is here because it's possible that /var and / are on different partitions. -+is_on_read_only_partition () { -+ DIRECTORY=$1 -+ dir=`readlink -f $DIRECTORY` -+ while true; do -+ if [ ! -d "$dir" ]; then -+ echo "ERROR: $dir is not a directory" -+ exit 1 -+ else -+ for flag in `awk -v dir=$dir '{ if ($2 == dir) { print "FOUND"; split($4,FLAGS,",") } }; \ -+ END { for (f in FLAGS) print FLAGS[f] }' < /proc/mounts`; do -+ [ "$flag" = "FOUND" ] && partition="read-write" -+ [ "$flag" = "ro" ] && { partition="read-only"; break; } -+ done -+ if [ "$dir" = "/" -o -n "$partition" ]; then -+ break -+ else -+ dir=`dirname $dir` -+ fi -+ fi -+ done -+ [ "$partition" = "read-only" ] && echo "yes" || echo "no" -+} -+ -+bind_mount () { -+ olddir=$1 -+ newdir=$2 -+ mkdir -p $olddir -+ cp -a $newdir/* $olddir -+ mount --bind $olddir $newdir -+} -+ -+# Deal with read-only rootfs -+if [ "$ROOTFS_READ_ONLY" = "yes" ]; then -+ [ "$VERBOSE" != "no" ] && echo "WARN: start bind service in read-only rootfs" -+ [ `is_on_read_only_partition /etc/bind` = "yes" ] && bind_mount /var/volatile/bind/etc /etc/bind -+ [ `is_on_read_only_partition /var/named` = "yes" ] && bind_mount /var/volatile/bind/named /var/named -+fi -+ - test -x /usr/sbin/rndc || exit 0 - - case "$1" in --- -1.7.9.5 - diff --git a/meta-arm-autonomy/recipes-connectivity/bind/bind/make-etc-initd-bind-stop-work.patch b/meta-arm-autonomy/recipes-connectivity/bind/bind/make-etc-initd-bind-stop-work.patch deleted file mode 100644 index 146f3e35..00000000 --- a/meta-arm-autonomy/recipes-connectivity/bind/bind/make-etc-initd-bind-stop-work.patch +++ /dev/null @@ -1,42 +0,0 @@ -bind: make "/etc/init.d/bind stop" work - -Upstream-Status: Inappropriate [configuration] - -Add some configurations, make rndc command be able to controls -the named daemon. - -Signed-off-by: Roy Li ---- - conf/named.conf | 5 +++++ - conf/rndc.conf | 5 +++++ - 2 files changed, 10 insertions(+), 0 deletions(-) - create mode 100644 conf/rndc.conf - -diff --git a/conf/named.conf b/conf/named.conf -index 95829cf..c8899e7 100644 ---- a/conf/named.conf -+++ b/conf/named.conf -@@ -47,3 +47,8 @@ zone "255.in-addr.arpa" { - // root-delegation-only exclude { "DE"; "MUSEUM"; }; - - include "/etc/bind/named.conf.local"; -+include "/etc/bind/rndc.key" ; -+controls { -+ inet 127.0.0.1 allow { localhost; } -+ keys { rndc-key; }; -+}; -diff --git a/conf/rndc.conf b/conf/rndc.conf -new file mode 100644 -index 0000000..a0b481d ---- /dev/null -+++ b/conf/rndc.conf -@@ -0,0 +1,5 @@ -+include "/etc/bind/rndc.key"; -+options { -+ default-server localhost; -+ default-key rndc-key; -+}; - --- -1.7.5.4 - diff --git a/meta-arm-autonomy/recipes-connectivity/bind/bind/named.service b/meta-arm-autonomy/recipes-connectivity/bind/bind/named.service deleted file mode 100644 index cda56ef0..00000000 --- a/meta-arm-autonomy/recipes-connectivity/bind/bind/named.service +++ /dev/null @@ -1,22 +0,0 @@ -[Unit] -Description=Berkeley Internet Name Domain (DNS) -Wants=nss-lookup.target -Before=nss-lookup.target -After=network.target - -[Service] -Type=forking -EnvironmentFile=-/etc/default/bind9 -PIDFile=/run/named/named.pid - -ExecStartPre=@SBINDIR@/generate-rndc-key.sh -ExecStart=@SBINDIR@/named $OPTIONS - -ExecReload=@BASE_BINDIR@/sh -c '@SBINDIR@/rndc reload > /dev/null 2>&1 || @BASE_BINDIR@/kill -HUP $MAINPID' - -ExecStop=@BASE_BINDIR@/sh -c '@SBINDIR@/rndc stop > /dev/null 2>&1 || @BASE_BINDIR@/kill -TERM $MAINPID' - -PrivateTmp=true - -[Install] -WantedBy=multi-user.target diff --git a/meta-arm-autonomy/recipes-connectivity/bind/bind_9.11.22.bb b/meta-arm-autonomy/recipes-connectivity/bind/bind_9.11.22.bb deleted file mode 100644 index 7128bd38..00000000 --- a/meta-arm-autonomy/recipes-connectivity/bind/bind_9.11.22.bb +++ /dev/null @@ -1,140 +0,0 @@ -SUMMARY = "ISC Internet Domain Name Server" -HOMEPAGE = "http://www.isc.org/sw/bind/" -SECTION = "console/network" - -LICENSE = "ISC & BSD" -LIC_FILES_CHKSUM = "file://COPYRIGHT;md5=bf39058a7f64b2a934ce14dc9ec1dd45" - -DEPENDS = "openssl libcap zlib" - -SRC_URI = "https://ftp.isc.org/isc/bind9/${PV}/${BPN}-${PV}.tar.gz \ - file://conf.patch \ - file://named.service \ - file://bind9 \ - file://generate-rndc-key.sh \ - file://make-etc-initd-bind-stop-work.patch \ - file://init.d-add-support-for-read-only-rootfs.patch \ - file://bind-ensure-searching-for-json-headers-searches-sysr.patch \ - file://0001-configure.in-remove-useless-L-use_openssl-lib.patch \ - file://0001-named-lwresd-V-and-start-log-hide-build-options.patch \ - file://0001-avoid-start-failure-with-bind-user.patch \ - " - -SRC_URI[sha256sum] = "afc6d8015006f1cabf699ff19f517bb8fd9c1811e5231f26baf51c3550262ac9" - -UPSTREAM_CHECK_URI = "https://ftp.isc.org/isc/bind9/" -# stay at 9.11 until 9.16, from 9.16 follow the ESV versions divisible by 4 -UPSTREAM_CHECK_REGEX = "(?P9.(11|16|20|24|28)(\.\d+)+(-P\d+)*)/" - -# BIND >= 9.11.2 need dhcpd >= 4.4.0, -# don't report it here since dhcpd is already recent enough. -CVE_CHECK_WHITELIST += "CVE-2019-6470" - -inherit autotools update-rc.d systemd useradd pkgconfig multilib_script multilib_header - -MULTILIB_SCRIPTS = "${PN}:${bindir}/bind9-config ${PN}:${bindir}/isc-config.sh" - -# PACKAGECONFIGs readline and libedit should NOT be set at same time -PACKAGECONFIG ?= "readline" -PACKAGECONFIG[httpstats] = "--with-libxml2=${STAGING_DIR_HOST}${prefix},--without-libxml2,libxml2" -PACKAGECONFIG[readline] = "--with-readline=-lreadline,,readline" -PACKAGECONFIG[libedit] = "--with-readline=-ledit,,libedit" -PACKAGECONFIG[urandom] = "--with-randomdev=/dev/urandom,--with-randomdev=/dev/random,," -PACKAGECONFIG[python3] = "--with-python=yes --with-python-install-dir=${PYTHON_SITEPACKAGES_DIR} , --without-python, python3-ply-native," - -ENABLE_IPV6 = "--enable-ipv6=${@bb.utils.contains('DISTRO_FEATURES', 'ipv6', 'yes', 'no', d)}" -EXTRA_OECONF = " ${ENABLE_IPV6} --with-libtool --enable-threads \ - --disable-devpoll --enable-epoll --with-gost=no \ - --with-gssapi=no --with-ecdsa=yes --with-eddsa=no \ - --with-lmdb=no \ - --sysconfdir=${sysconfdir}/bind \ - --with-openssl=${STAGING_DIR_HOST}${prefix} \ - " - -inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3native distutils3-base', '', d)} - -# dhcp needs .la so keep them -REMOVE_LIBTOOL_LA = "0" - -USERADD_PACKAGES = "${PN}" -USERADD_PARAM_${PN} = "--system --home ${localstatedir}/cache/bind --no-create-home \ - --user-group bind" - -INITSCRIPT_NAME = "bind" -INITSCRIPT_PARAMS = "defaults" - -SYSTEMD_SERVICE_${PN} = "named.service" - -do_install_prepend() { - # clean host path in isc-config.sh before the hardlink created - # by "make install": - # bind9-config -> isc-config.sh - sed -i -e "s,${STAGING_LIBDIR},${libdir}," ${B}/isc-config.sh -} - -do_install_append() { - - rmdir "${D}${localstatedir}/run" - rmdir --ignore-fail-on-non-empty "${D}${localstatedir}" - install -d -o bind "${D}${localstatedir}/cache/bind" - install -d "${D}${sysconfdir}/bind" - install -d "${D}${sysconfdir}/init.d" - install -m 644 ${S}/conf/* "${D}${sysconfdir}/bind/" - install -m 755 "${S}/init.d" "${D}${sysconfdir}/init.d/bind" - if ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'true', 'false', d)}; then - sed -i -e '1s,#!.*python3,#! /usr/bin/python3,' \ - ${D}${sbindir}/dnssec-coverage \ - ${D}${sbindir}/dnssec-checkds \ - ${D}${sbindir}/dnssec-keymgr - fi - - # Install systemd related files - install -d ${D}${sbindir} - install -m 755 ${WORKDIR}/generate-rndc-key.sh ${D}${sbindir} - install -d ${D}${systemd_unitdir}/system - install -m 0644 ${WORKDIR}/named.service ${D}${systemd_unitdir}/system - sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \ - -e 's,@SBINDIR@,${sbindir},g' \ - ${D}${systemd_unitdir}/system/named.service - - install -d ${D}${sysconfdir}/default - install -m 0644 ${WORKDIR}/bind9 ${D}${sysconfdir}/default - - if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then - install -d ${D}${sysconfdir}/tmpfiles.d - echo "d /run/named 0755 bind bind - -" > ${D}${sysconfdir}/tmpfiles.d/bind.conf - fi - - oe_multilib_header isc/platform.h -} - -CONFFILES_${PN} = " \ - ${sysconfdir}/bind/named.conf \ - ${sysconfdir}/bind/named.conf.local \ - ${sysconfdir}/bind/named.conf.options \ - ${sysconfdir}/bind/db.0 \ - ${sysconfdir}/bind/db.127 \ - ${sysconfdir}/bind/db.empty \ - ${sysconfdir}/bind/db.local \ - ${sysconfdir}/bind/db.root \ - " - -ALTERNATIVE_${PN}-utils = "nslookup" -ALTERNATIVE_LINK_NAME[nslookup] = "${bindir}/nslookup" -ALTERNATIVE_PRIORITY = "100" - -PACKAGE_BEFORE_PN += "${PN}-utils" -FILES_${PN}-utils = "${bindir}/host ${bindir}/dig ${bindir}/mdig ${bindir}/nslookup ${bindir}/nsupdate" -FILES_${PN}-dev += "${bindir}/isc-config.h" -FILES_${PN} += "${sbindir}/generate-rndc-key.sh" - -PACKAGE_BEFORE_PN += "${PN}-libs" -FILES_${PN}-libs = "${libdir}/*.so*" -FILES_${PN}-staticdev += "${libdir}/*.la" - -PACKAGE_BEFORE_PN += "${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3-bind', '', d)}" -FILES_python3-bind = "${sbindir}/dnssec-coverage ${sbindir}/dnssec-checkds \ - ${sbindir}/dnssec-keymgr ${PYTHON_SITEPACKAGES_DIR}" - -RDEPENDS_${PN}-dev = "" -RDEPENDS_python3-bind = "python3-core python3-ply" diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/README.md b/meta-arm-autonomy/recipes-connectivity/dhcp/README.md deleted file mode 100644 index 4c98d0b4..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/README.md +++ /dev/null @@ -1,3 +0,0 @@ -For now, arm-autonomy-host-image-minimal installs the dhcp-server package and -the dchp recipe was copied from oe-core tree https://git.openembedded.org/openembedded-core/tree/meta/recipes-connectivity/dhcp?id=087e4fafeef82cfd3d71402d6b200fe831f48697 -since it got removed in the https://git.openembedded.org/openembedded-core/commit/meta/recipes-connectivity?id=7e3357892f204788162747e907d68f857118cf42 patch. diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp.inc b/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp.inc deleted file mode 100644 index d46130d4..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp.inc +++ /dev/null @@ -1,149 +0,0 @@ -SECTION = "console/network" -SUMMARY = "Internet Software Consortium DHCP package" -DESCRIPTION = "DHCP (Dynamic Host Configuration Protocol) is a protocol \ -which allows individual devices on an IP network to get their own \ -network configuration information from a server. DHCP helps make it \ -easier to administer devices." - -HOMEPAGE = "http://www.isc.org/" - -LICENSE = "ISC" -LIC_FILES_CHKSUM = "file://LICENSE;beginline=4;md5=004a4db50a1e20972e924a8618747c01" - -DEPENDS = "openssl bind" - -SRC_URI = "http://ftp.isc.org/isc/dhcp/${PV}/dhcp-${PV}.tar.gz \ - file://init-relay file://default-relay \ - file://init-server file://default-server \ - file://dhclient.conf file://dhcpd.conf \ - file://dhclient-systemd-wrapper \ - file://dhclient.service \ - file://dhcpd.service file://dhcrelay.service \ - file://dhcpd6.service \ - " -UPSTREAM_CHECK_URI = "http://ftp.isc.org/isc/dhcp/" -UPSTREAM_CHECK_REGEX = "(?P\d+\.\d+\.(\d+?))/" - -inherit autotools-brokensep systemd useradd update-rc.d - -USERADD_PACKAGES = "${PN}-server" -USERADD_PARAM_${PN}-server = "--system --no-create-home --home-dir /var/run/${BPN} --shell /bin/false --user-group ${BPN}" - -SYSTEMD_PACKAGES = "${PN}-server ${PN}-relay ${PN}-client" -SYSTEMD_SERVICE_${PN}-server = "dhcpd.service dhcpd6.service" -SYSTEMD_AUTO_ENABLE_${PN}-server = "disable" - -SYSTEMD_SERVICE_${PN}-relay = "dhcrelay.service" -SYSTEMD_AUTO_ENABLE_${PN}-relay = "disable" - -SYSTEMD_SERVICE_${PN}-client = "dhclient.service" -SYSTEMD_AUTO_ENABLE_${PN}-client = "disable" - -INITSCRIPT_PACKAGES = "dhcp-server" -INITSCRIPT_NAME_dhcp-server = "dhcp-server" -INITSCRIPT_PARAMS_dhcp-server = "defaults" - -CFLAGS += "-D_GNU_SOURCE" -EXTRA_OECONF = "--with-srv-lease-file=${localstatedir}/lib/dhcp/dhcpd.leases \ - --with-srv6-lease-file=${localstatedir}/lib/dhcp/dhcpd6.leases \ - --with-cli-lease-file=${localstatedir}/lib/dhcp/dhclient.leases \ - --with-cli6-lease-file=${localstatedir}/lib/dhcp/dhclient6.leases \ - --enable-paranoia --disable-static \ - --with-randomdev=/dev/random \ - --with-libbind=${STAGING_DIR_HOST} \ - --enable-libtool \ - " - -#Enable shared libs per dhcp README -do_configure_prepend () { - cp configure.ac+lt configure.ac -} - -do_install_append () { - install -d ${D}${sysconfdir}/init.d - install -d ${D}${sysconfdir}/default - install -d ${D}${sysconfdir}/dhcp - install -m 0755 ${WORKDIR}/init-relay ${D}${sysconfdir}/init.d/dhcp-relay - install -m 0644 ${WORKDIR}/default-relay ${D}${sysconfdir}/default/dhcp-relay - install -m 0755 ${WORKDIR}/init-server ${D}${sysconfdir}/init.d/dhcp-server - install -m 0644 ${WORKDIR}/default-server ${D}${sysconfdir}/default/dhcp-server - - rm -f ${D}${sysconfdir}/dhclient.conf* - rm -f ${D}${sysconfdir}/dhcpd.conf* - install -m 0644 ${WORKDIR}/dhclient.conf ${D}${sysconfdir}/dhcp/dhclient.conf - install -m 0644 ${WORKDIR}/dhcpd.conf ${D}${sysconfdir}/dhcp/dhcpd.conf - - install -d ${D}${base_sbindir}/ - if [ "${sbindir}" != "${base_sbindir}" ]; then - mv ${D}${sbindir}/dhclient ${D}${base_sbindir}/ - fi - install -m 0755 ${S}/client/scripts/linux ${D}${base_sbindir}/dhclient-script - - # Install systemd unit files - install -d ${D}${systemd_unitdir}/system - install -m 0644 ${WORKDIR}/dhcpd.service ${D}${systemd_unitdir}/system - install -m 0644 ${WORKDIR}/dhcpd6.service ${D}${systemd_unitdir}/system - install -m 0644 ${WORKDIR}/dhcrelay.service ${D}${systemd_unitdir}/system - sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_unitdir}/system/dhcpd*.service ${D}${systemd_unitdir}/system/dhcrelay.service - sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhcpd*.service - sed -i -e 's,@base_bindir@,${base_bindir},g' ${D}${systemd_unitdir}/system/dhcpd*.service - sed -i -e 's,@localstatedir@,${localstatedir},g' ${D}${systemd_unitdir}/system/dhcpd*.service - sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhcrelay.service - - install -d ${D}${base_sbindir} - install -m 0755 ${WORKDIR}/dhclient-systemd-wrapper ${D}${base_sbindir}/dhclient-systemd-wrapper - install -m 0644 ${WORKDIR}/dhclient.service ${D}${systemd_unitdir}/system - sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhclient.service - sed -i -e 's,@BASE_SBINDIR@,${base_sbindir},g' ${D}${systemd_unitdir}/system/dhclient.service -} - -PACKAGES += "dhcp-libs dhcp-server dhcp-server-config dhcp-client dhcp-relay dhcp-omshell" - -PACKAGES_remove = "${PN}" -RDEPENDS_${PN}-client += "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'iproute2', '', d)}" -RDEPENDS_${PN}-dev = "" -RDEPENDS_${PN}-staticdev = "" -FILES_${PN}-libs = "${libdir}/libdhcpctl.so.0* ${libdir}/libomapi.so.0* ${libdir}/libdhcp.so.0*" - -FILES_${PN}-server = "${sbindir}/dhcpd ${sysconfdir}/init.d/dhcp-server" -RRECOMMENDS_${PN}-server = "dhcp-server-config" - -FILES_${PN}-server-config = "${sysconfdir}/default/dhcp-server ${sysconfdir}/dhcp/dhcpd.conf" - -FILES_${PN}-relay = "${sbindir}/dhcrelay ${sysconfdir}/init.d/dhcp-relay ${sysconfdir}/default/dhcp-relay" - -FILES_${PN}-client = "${base_sbindir}/dhclient \ - ${base_sbindir}/dhclient-script \ - ${sysconfdir}/dhcp/dhclient.conf \ - ${base_sbindir}/dhclient-systemd-wrapper \ - " - -FILES_${PN}-omshell = "${bindir}/omshell" - -pkg_postinst_dhcp-server() { - mkdir -p $D/${localstatedir}/lib/dhcp - touch $D/${localstatedir}/lib/dhcp/dhcpd.leases - touch $D/${localstatedir}/lib/dhcp/dhcpd6.leases -} - -pkg_postinst_dhcp-client() { - mkdir -p $D/${localstatedir}/lib/dhcp -} - -pkg_postrm_dhcp-server() { - rm -f $D/${localstatedir}/lib/dhcp/dhcpd.leases - rm -f $D/${localstatedir}/lib/dhcp/dhcpd6.leases - - if ! rmdir $D/${localstatedir}/lib/dhcp 2>/dev/null; then - echo "Not removing ${localstatedir}/lib/dhcp as it is non-empty." - fi -} - -pkg_postrm_dhcp-client() { - rm -f $D/${localstatedir}/lib/dhcp/dhclient.leases - rm -f $D/${localstatedir}/lib/dhcp/dhclient6.leases - - if ! rmdir $D/${localstatedir}/lib/dhcp 2>/dev/null; then - echo "Not removing ${localstatedir}/lib/dhcp as it is non-empty." - fi -} diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0001-define-macro-_PATH_DHCPD_CONF-and-_PATH_DHCLIENT_CON.patch b/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0001-define-macro-_PATH_DHCPD_CONF-and-_PATH_DHCLIENT_CON.patch deleted file mode 100644 index d1b57f0b..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0001-define-macro-_PATH_DHCPD_CONF-and-_PATH_DHCLIENT_CON.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 7cc29144535a622fc671dc86eb1da65b0473a7c4 Mon Sep 17 00:00:00 2001 -From: Hongxu Jia -Date: Tue, 15 Aug 2017 16:14:22 +0800 -Subject: [PATCH 01/11] define macro _PATH_DHCPD_CONF and _PATH_DHCLIENT_CONF - -Upstream-Status: Inappropriate [OE specific] - -Rebase to 4.3.6 -Signed-off-by: Hongxu Jia ---- - includes/site.h | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -Index: dhcp-4.4.1/includes/site.h -=================================================================== ---- dhcp-4.4.1.orig/includes/site.h -+++ dhcp-4.4.1/includes/site.h -@@ -148,7 +148,8 @@ - /* Define this if you want the dhcpd.conf file to go somewhere other than - the default location. By default, it goes in /etc/dhcpd.conf. */ - --/* #define _PATH_DHCPD_CONF "/etc/dhcpd.conf" */ -+#define _PATH_DHCPD_CONF "/etc/dhcp/dhcpd.conf" -+#define _PATH_DHCLIENT_CONF "/etc/dhcp/dhclient.conf" - - /* Network API definitions. You do not need to choose one of these - if - you don't choose, one will be chosen for you in your system's config diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0001-workaround-busybox-limitation-in-linux-dhclient-script.patch b/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0001-workaround-busybox-limitation-in-linux-dhclient-script.patch deleted file mode 100644 index 2359381b..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0001-workaround-busybox-limitation-in-linux-dhclient-script.patch +++ /dev/null @@ -1,65 +0,0 @@ -From eec0503cfc36f63d777f5cb3f2719cecedcb8468 Mon Sep 17 00:00:00 2001 -From: Haris Okanovic -Date: Mon, 7 Jan 2019 13:22:09 -0600 -Subject: [PATCH] Workaround busybox limitation in Linux dhclient-script - -Busybox is a lightweight implementation of coreutils commonly used on -space-constrained embedded Linux distributions. It's implementation of -chown and chmod doesn't provide a "--reference" option added to -client/scripts/linux as of commit 9261cb14. This change works around -that limitation by using stat to read ownership and permissions flags -and simple chown/chmod calls supported in both coreutils and busybox. - - modified: client/scripts/linux - -Signed-off-by: Haris Okanovic -Upstream-Status: Pending [ISC-Bugs #48771] ---- - client/scripts/linux | 17 +++++++++++++---- - 1 file changed, 13 insertions(+), 4 deletions(-) - -diff --git a/client/scripts/linux b/client/scripts/linux -index 0c429697..2435a44b 100755 ---- a/client/scripts/linux -+++ b/client/scripts/linux -@@ -32,6 +32,17 @@ - # if your system holds ip tool in a non-standard location. - ip=/sbin/ip - -+chown_chmod_by_reference() { -+ local reference_file="$1" -+ local target_file="$2" -+ -+ local owner=$(stat -c "%u:%g" "$reference_file") -+ local perm=$(stat -c "%a" "$reference_file") -+ -+ chown "$owner" "$target_file" -+ chmod "$perm" "$target_file" -+} -+ - # update /etc/resolv.conf based on received values - # This updated version mostly follows Debian script by Andrew Pollock et al. - make_resolv_conf() { -@@ -74,8 +85,7 @@ make_resolv_conf() { - fi - - if [ -f /etc/resolv.conf ]; then -- chown --reference=/etc/resolv.conf $new_resolv_conf -- chmod --reference=/etc/resolv.conf $new_resolv_conf -+ chown_chmod_by_reference /etc/resolv.conf $new_resolv_conf - fi - mv -f $new_resolv_conf /etc/resolv.conf - # DHCPv6 -@@ -101,8 +111,7 @@ make_resolv_conf() { - fi - - if [ -f /etc/resolv.conf ]; then -- chown --reference=/etc/resolv.conf $new_resolv_conf -- chmod --reference=/etc/resolv.conf $new_resolv_conf -+ chown_chmod_by_reference /etc/resolv.conf $new_resolv_conf - fi - mv -f $new_resolv_conf /etc/resolv.conf - fi --- -2.20.0 - diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0002-dhclient-dbus.patch b/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0002-dhclient-dbus.patch deleted file mode 100644 index 101c33f6..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0002-dhclient-dbus.patch +++ /dev/null @@ -1,117 +0,0 @@ -From be7540d31c356e80ee02e90e8bf162b7ac6e5ba5 Mon Sep 17 00:00:00 2001 -From: Hongxu Jia -Date: Tue, 15 Aug 2017 14:56:56 +0800 -Subject: [PATCH 02/11] dhclient dbus - -Upstream-Status: Inappropriate [distribution] - -Rebase to 4.3.6 -Signed-off-by: Hongxu Jia ---- - client/scripts/bsdos | 5 +++++ - client/scripts/freebsd | 5 +++++ - client/scripts/linux | 5 +++++ - client/scripts/netbsd | 5 +++++ - client/scripts/openbsd | 5 +++++ - client/scripts/solaris | 5 +++++ - 6 files changed, 30 insertions(+) - -diff --git a/client/scripts/bsdos b/client/scripts/bsdos -index d69d0d8..095b143 100755 ---- a/client/scripts/bsdos -+++ b/client/scripts/bsdos -@@ -45,6 +45,11 @@ exit_with_hooks() { - . /etc/dhclient-exit-hooks - fi - # probably should do something with exit status of the local script -+ if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then -+ dbus-send --system --dest=com.redhat.dhcp \ -+ --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \ -+ 'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`" -+ fi - exit $exit_status - } - -diff --git a/client/scripts/freebsd b/client/scripts/freebsd -index 8f3e2a2..ad7fb44 100755 ---- a/client/scripts/freebsd -+++ b/client/scripts/freebsd -@@ -89,6 +89,11 @@ exit_with_hooks() { - . /etc/dhclient-exit-hooks - fi - # probably should do something with exit status of the local script -+ if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then -+ dbus-send --system --dest=com.redhat.dhcp \ -+ --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \ -+ 'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`" -+ fi - exit $exit_status - } - -diff --git a/client/scripts/linux b/client/scripts/linux -index 5fb1612..3d447b6 100755 ---- a/client/scripts/linux -+++ b/client/scripts/linux -@@ -174,6 +174,11 @@ exit_with_hooks() { - exit_status=$? - fi - -+ if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then -+ dbus-send --system --dest=com.redhat.dhcp \ -+ --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \ -+ 'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`" -+ fi - exit $exit_status - } - -diff --git a/client/scripts/netbsd b/client/scripts/netbsd -index 07383b7..aaba8e8 100755 ---- a/client/scripts/netbsd -+++ b/client/scripts/netbsd -@@ -45,6 +45,11 @@ exit_with_hooks() { - . /etc/dhclient-exit-hooks - fi - # probably should do something with exit status of the local script -+ if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then -+ dbus-send --system --dest=com.redhat.dhcp \ -+ --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \ -+ 'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`" -+ fi - exit $exit_status - } - -diff --git a/client/scripts/openbsd b/client/scripts/openbsd -index e7f4746..56b980c 100644 ---- a/client/scripts/openbsd -+++ b/client/scripts/openbsd -@@ -45,6 +45,11 @@ exit_with_hooks() { - . /etc/dhclient-exit-hooks - fi - # probably should do something with exit status of the local script -+ if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then -+ dbus-send --system --dest=com.redhat.dhcp \ -+ --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \ -+ 'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`" -+ fi - exit $exit_status - } - -diff --git a/client/scripts/solaris b/client/scripts/solaris -index af553b9..4a2aa69 100755 ---- a/client/scripts/solaris -+++ b/client/scripts/solaris -@@ -26,6 +26,11 @@ exit_with_hooks() { - . /etc/dhclient-exit-hooks - fi - # probably should do something with exit status of the local script -+ if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then -+ dbus-send --system --dest=com.redhat.dhcp \ -+ --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \ -+ 'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`" -+ fi - exit $exit_status - } - --- -1.8.3.1 - diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0003-link-with-lcrypto.patch b/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0003-link-with-lcrypto.patch deleted file mode 100644 index 5b35933a..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0003-link-with-lcrypto.patch +++ /dev/null @@ -1,35 +0,0 @@ -From d80bd792323dbd56269309f85b4506eb6b1b60e9 Mon Sep 17 00:00:00 2001 -From: Andrei Gherzan -Date: Tue, 15 Aug 2017 15:05:47 +0800 -Subject: [PATCH 03/11] link with lcrypto - -From 4.2.0 final release, -lcrypto check was removed and we compile -static libraries -from bind that are linked to libcrypto. This is why i added a patch in -order to add --lcrypto to LIBS. - -Upstream-Status: Pending -Signed-off-by: Andrei Gherzan - -Rebase to 4.3.6 -Signed-off-by: Hongxu Jia ---- - configure.ac | 4 ++++ - 1 file changed, 4 insertions(+) - -Index: dhcp-4.4.1/configure.ac -=================================================================== ---- dhcp-4.4.1.orig/configure.ac -+++ dhcp-4.4.1/configure.ac -@@ -612,6 +612,10 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], - # Look for optional headers. - AC_CHECK_HEADERS(sys/socket.h net/if_dl.h net/if6.h regex.h) - -+# find an MD5 library -+AC_SEARCH_LIBS(MD5_Init, [crypto]) -+AC_SEARCH_LIBS(MD5Init, [crypto]) -+ - # Solaris needs some libraries for functions - AC_SEARCH_LIBS(socket, [socket]) - AC_SEARCH_LIBS(inet_ntoa, [nsl]) diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0004-Fix-out-of-tree-builds.patch b/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0004-Fix-out-of-tree-builds.patch deleted file mode 100644 index 7b57730f..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0004-Fix-out-of-tree-builds.patch +++ /dev/null @@ -1,95 +0,0 @@ -From cccec0344d68dac4100b6f260ee24e7c2da9dfda Mon Sep 17 00:00:00 2001 -From: Hongxu Jia -Date: Tue, 15 Aug 2017 15:08:22 +0800 -Subject: [PATCH 04/11] Fix out of tree builds - -Upstream-Status: Pending - -RP 2013/03/21 - -Rebase to 4.3.6 - -Signed-off-by: Hongxu Jia ---- - client/Makefile.am | 4 ++-- - common/Makefile.am | 3 ++- - dhcpctl/Makefile.am | 2 ++ - omapip/Makefile.am | 1 + - relay/Makefile.am | 2 +- - server/Makefile.am | 2 +- - 6 files changed, 9 insertions(+), 5 deletions(-) - -Index: dhcp-4.4.1/common/Makefile.am -=================================================================== ---- dhcp-4.4.1.orig/common/Makefile.am -+++ dhcp-4.4.1/common/Makefile.am -@@ -1,4 +1,5 @@ --AM_CPPFLAGS = -I$(top_srcdir) -DLOCALSTATEDIR='"@localstatedir@"' -+AM_CPPFLAGS = -I$(top_srcdir)/includes -I$(top_srcdir) -DLOCALSTATEDIR='"@localstatedir@"' -+ - AM_CFLAGS = $(LDAP_CFLAGS) - - lib_LIBRARIES = libdhcp.a -Index: dhcp-4.4.1/dhcpctl/Makefile.am -=================================================================== ---- dhcp-4.4.1.orig/dhcpctl/Makefile.am -+++ dhcp-4.4.1/dhcpctl/Makefile.am -@@ -3,6 +3,8 @@ BINDLIBDNSDIR=@BINDLIBDNSDIR@ - BINDLIBISCCFGDIR=@BINDLIBISCCFGDIR@ - BINDLIBISCDIR=@BINDLIBISCDIR@ - -+AM_CPPFLAGS = -I$(top_srcdir)/includes -I$(top_srcdir) -+ - bin_PROGRAMS = omshell - lib_LIBRARIES = libdhcpctl.a - noinst_PROGRAMS = cltest -Index: dhcp-4.4.1/server/Makefile.am -=================================================================== ---- dhcp-4.4.1.orig/server/Makefile.am -+++ dhcp-4.4.1/server/Makefile.am -@@ -4,7 +4,7 @@ - # production code. Sadly, we are not there yet. - SUBDIRS = . tests - --AM_CPPFLAGS = -I.. -DLOCALSTATEDIR='"@localstatedir@"' -+AM_CPPFLAGS = -I$(top_srcdir) -DLOCALSTATEDIR='"@localstatedir@"' -I$(top_srcdir)/includes - - dist_sysconf_DATA = dhcpd.conf.example - sbin_PROGRAMS = dhcpd -Index: dhcp-4.4.1/client/Makefile.am -=================================================================== ---- dhcp-4.4.1.orig/client/Makefile.am -+++ dhcp-4.4.1/client/Makefile.am -@@ -5,7 +5,7 @@ - SUBDIRS = . tests - - AM_CPPFLAGS = -DCLIENT_PATH='"PATH=$(sbindir):/sbin:/bin:/usr/sbin:/usr/bin"' --AM_CPPFLAGS += -DLOCALSTATEDIR='"$(localstatedir)"' -+AM_CPPFLAGS += -DLOCALSTATEDIR='"$(localstatedir)"' -I$(top_srcdir)/includes - - dist_sysconf_DATA = dhclient.conf.example - sbin_PROGRAMS = dhclient -Index: dhcp-4.4.1/omapip/Makefile.am -=================================================================== ---- dhcp-4.4.1.orig/omapip/Makefile.am -+++ dhcp-4.4.1/omapip/Makefile.am -@@ -2,6 +2,7 @@ BINDLIBIRSDIR=@BINDLIBIRSDIR@ - BINDLIBDNSDIR=@BINDLIBDNSDIR@ - BINDLIBISCCFGDIR=@BINDLIBISCCFGDIR@ - BINDLIBISCDIR=@BINDLIBISCDIR@ -+AM_CPPFLAGS = -I$(top_srcdir)/includes - - lib_LIBRARIES = libomapi.a - noinst_PROGRAMS = svtest -Index: dhcp-4.4.1/relay/Makefile.am -=================================================================== ---- dhcp-4.4.1.orig/relay/Makefile.am -+++ dhcp-4.4.1/relay/Makefile.am -@@ -1,6 +1,6 @@ - SUBDIRS = . tests - --AM_CPPFLAGS = -DLOCALSTATEDIR='"@localstatedir@"' -+AM_CPPFLAGS = -DLOCALSTATEDIR='"@localstatedir@"' -I$(top_srcdir)/includes - - sbin_PROGRAMS = dhcrelay - dhcrelay_SOURCES = dhcrelay.c diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0005-dhcp-client-fix-invoke-dhclient-script-failed-on-Rea.patch b/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0005-dhcp-client-fix-invoke-dhclient-script-failed-on-Rea.patch deleted file mode 100644 index dd56381b..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0005-dhcp-client-fix-invoke-dhclient-script-failed-on-Rea.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 2e8ff0e4f6d39e346ea86b8c514ab4ccc78fa359 Mon Sep 17 00:00:00 2001 -From: Hongxu Jia -Date: Tue, 15 Aug 2017 15:24:14 +0800 -Subject: [PATCH 05/11] dhcp-client: fix invoke dhclient-script failed on - Read-only file system - -In read-only file system, '/etc' is on the readonly partition, -and '/etc/resolv.conf' is symlinked to a separate writable -partition. - -In this situation, we create temp files 'resolv.conf.dhclient-new' -in /tmp dir. - -Upstream-Status: Pending - -Signed-off-by: Hongxu Jia ---- - client/scripts/linux | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/client/scripts/linux b/client/scripts/linux -index 3d447b6..3122a75 100755 ---- a/client/scripts/linux -+++ b/client/scripts/linux -@@ -40,7 +40,7 @@ make_resolv_conf() { - # DHCPv4 - if [ -n "$new_domain_search" ] || [ -n "$new_domain_name" ] || - [ -n "$new_domain_name_servers" ]; then -- new_resolv_conf=/etc/resolv.conf.dhclient-new -+ new_resolv_conf=/tmp/resolv.conf.dhclient-new - rm -f $new_resolv_conf - - if [ -n "$new_domain_name" ]; then --- -1.8.3.1 - diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0007-Add-configure-argument-to-make-the-libxml2-dependenc.patch b/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0007-Add-configure-argument-to-make-the-libxml2-dependenc.patch deleted file mode 100644 index feb0754f..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0007-Add-configure-argument-to-make-the-libxml2-dependenc.patch +++ /dev/null @@ -1,62 +0,0 @@ -From 7107511fd209f08f9a96f8938041ae48f3295895 Mon Sep 17 00:00:00 2001 -From: Christopher Larson -Date: Tue, 15 Aug 2017 16:17:49 +0800 -Subject: [PATCH 07/11] Add configure argument to make the libxml2 dependency - explicit and determinisitic. - -Upstream-Status: Pending - -Signed-off-by: Christopher Larson - -Rebase to 4.3.6 - -Signed-off-by: Hongxu Jia ---- - configure.ac | 11 +++++++++++ - 1 file changed, 11 insertions(+) - -Index: dhcp-4.4.1/configure.ac -=================================================================== ---- dhcp-4.4.1.orig/configure.ac -+++ dhcp-4.4.1/configure.ac -@@ -642,6 +642,17 @@ if test "$have_nanosleep" = "rt"; then - LIBS="-lrt $LIBS" - fi - -+AC_ARG_WITH(libxml2, -+ AS_HELP_STRING([--with-libxml2], [link against libxml2. this is needed if bind was built with xml2 support enabled]), -+ with_libxml2="$withval", with_libxml2="no") -+ -+if test x$with_libxml2 != xno; then -+ AC_SEARCH_LIBS(xmlTextWriterStartElement, [xml2], -+ [if test x$with_libxml2 != xauto; then -+ AC_MSG_FAILURE([*** Cannot find xmlTextWriterStartElement with -lxml2 and libxml2 was requested]) -+ fi]) -+fi -+ - # check for /dev/random (declares HAVE_DEV_RANDOM) - AC_MSG_CHECKING(for random device) - AC_ARG_WITH(randomdev, -Index: dhcp-4.4.1/configure.ac+lt -=================================================================== ---- dhcp-4.4.1.orig/configure.ac+lt -+++ dhcp-4.4.1/configure.ac+lt -@@ -909,6 +909,18 @@ elif test "$want_libtool" = "yes" -a "$u - fi - AM_CONDITIONAL(INSTALL_BIND, test "$want_install_bind" = "yes") - -+AC_ARG_WITH(libxml2, -+ AS_HELP_STRING([--with-libxml2], [link against libxml2. this is needed if bind was built with xml2 support enabled]), -+ with_libxml2="$withval", with_libxml2="no") -+ -+if test x$with_libxml2 != xno; then -+ AC_SEARCH_LIBS(xmlTextWriterStartElement, [xml2],, -+ [if test x$with_libxml2 != xauto; then -+ AC_MSG_FAILURE([*** Cannot find xmlTextWriterStartElement with -lxml2 and libxml2 was requested]) -+ fi]) -+fi -+ -+ - # OpenLDAP support. - AC_ARG_WITH(ldap, - AS_HELP_STRING([--with-ldap],[enable OpenLDAP support in dhcpd (default is no)]), diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0009-remove-dhclient-script-bash-dependency.patch b/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0009-remove-dhclient-script-bash-dependency.patch deleted file mode 100644 index 912b6d63..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0009-remove-dhclient-script-bash-dependency.patch +++ /dev/null @@ -1,28 +0,0 @@ -From f3f8b7726e50e24ef3edf5fa5a17e31d39118d7e Mon Sep 17 00:00:00 2001 -From: Andre McCurdy -Date: Tue, 15 Aug 2017 15:49:31 +0800 -Subject: [PATCH 09/11] remove dhclient-script bash dependency - -Upstream-Status: Inappropriate [OE specific] - -Signed-off-by: Andre McCurdy - -Rebase to 4.3.6 -Signed-off-by: Hongxu Jia ---- - client/scripts/linux | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/client/scripts/linux b/client/scripts/linux -index 3122a75..1712d7d 100755 ---- a/client/scripts/linux -+++ b/client/scripts/linux -@@ -1,4 +1,4 @@ --#!/bin/bash -+#!/bin/sh - # dhclient-script for Linux. Dan Halbert, March, 1997. - # Updated for Linux 2.[12] by Brian J. Murrell, January 1999. - # No guarantees about this. I'm a novice at the details of Linux --- -1.8.3.1 - diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0012-dhcp-correct-the-intention-for-xml2-lib-search.patch b/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0012-dhcp-correct-the-intention-for-xml2-lib-search.patch deleted file mode 100644 index 39ba65fb..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0012-dhcp-correct-the-intention-for-xml2-lib-search.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 501543b3ef715488a142e3d301ff2733aa33eec7 Mon Sep 17 00:00:00 2001 -From: Awais Belal -Date: Wed, 25 Oct 2017 21:00:05 +0500 -Subject: [PATCH] dhcp: correct the intention for xml2 lib search - -A missing case breaks the build when libxml2 is -required and found appropriately. The third argument -to the function AC_SEARCH_LIB is action-if-found which -was mistakenly been used for the case where the library -is not found and hence breaks the configure phase -where it shoud actually pass. -We now pass on silently when action-if-found is -executed. - -Upstream-Status: Pending - -Signed-off-by: Awais Belal ---- - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -Index: dhcp-4.4.1/configure.ac -=================================================================== ---- dhcp-4.4.1.orig/configure.ac -+++ dhcp-4.4.1/configure.ac -@@ -647,7 +647,7 @@ AC_ARG_WITH(libxml2, - with_libxml2="$withval", with_libxml2="no") - - if test x$with_libxml2 != xno; then -- AC_SEARCH_LIBS(xmlTextWriterStartElement, [xml2], -+ AC_SEARCH_LIBS(xmlTextWriterStartElement, [xml2],, - [if test x$with_libxml2 != xauto; then - AC_MSG_FAILURE([*** Cannot find xmlTextWriterStartElement with -lxml2 and libxml2 was requested]) - fi]) diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0013-fixup_use_libbind.patch b/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0013-fixup_use_libbind.patch deleted file mode 100644 index fcec010b..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp/0013-fixup_use_libbind.patch +++ /dev/null @@ -1,64 +0,0 @@ -lib and include path is hardcoded for use_libbind - -use libdir and includedir vars - -Upstream-Status: Pending -Signed-off-by: Armin Kuster - -Index: dhcp-4.4.1/configure.ac+lt -=================================================================== ---- dhcp-4.4.1.orig/configure.ac+lt -+++ dhcp-4.4.1/configure.ac+lt -@@ -801,22 +801,22 @@ no) - if test ! -d "$use_libbind"; then - AC_MSG_ERROR([Cannot find bind directory at $use_libbind]) - fi -- if test ! -d "$use_libbind/include" -o \ -- ! -f "$use_libbind/include/isc/buffer.h" -+ if test ! -d "$use_libbind/$includedir" -o \ -+ ! -f "$use_libbind/$includedir/isc/buffer.h" - then -- AC_MSG_ERROR([Cannot find bind includes at $use_libbind/include]) -+ AC_MSG_ERROR([Cannot find bind includes at $use_libbind/$includedir]) - fi -- if test ! -d "$use_libbind/lib" -o \ -- \( ! -f "$use_libbind/lib/libisc.a" -a \ -- ! -f "$use_libbind/lib/libisc.la" \) -+ if test ! -d "$use_libbind/$libdir" -o \ -+ \( ! -f "$use_libbind/$libdir/libisc.a" -a \ -+ ! -f "$use_libbind/$libdir/libisc.la" \) - then -- AC_MSG_ERROR([Cannot find bind libraries at $use_libbind/lib]) -+ AC_MSG_ERROR([Cannot find bind libraries at $use_libbind/$libdir]) - fi - BINDDIR="$use_libbind" -- BINDLIBIRSDIR="$BINDDIR/lib" -- BINDLIBDNSDIR="$BINDDIR/lib" -- BINDLIBISCCFGDIR="$BINDDIR/lib" -- BINDLIBISCDIR="$BINDDIR/lib" -+ BINDLIBIRSDIR="$BINDDIR/$libdir" -+ BINDLIBDNSDIR="$BINDDIR/$libdir" -+ BINDLIBISCCFGDIR="$BINDDIR/$libdir" -+ BINDLIBISCDIR="$BINDDIR/$libdir" - DISTCHECK_LIBBIND_CONFIGURE_FLAG="--with-libbind=$use_libbind" - ;; - esac -@@ -856,14 +856,14 @@ AC_ARG_ENABLE(libtool, - - if test "$use_libbind" != "no"; then - if test "$want_libtool" = "yes" -a \ -- ! -f "$use_libbind/lib/libisc.la" -+ ! -f "$use_libbind/$libdir/libisc.la" - then -- AC_MSG_ERROR([Cannot find dynamic libraries at $use_libbind/lib]) -+ AC_MSG_ERROR([Cannot find dynamic libraries at $use_libbind/$libdir]) - fi - if test "$want_libtool" = "no" -a \ -- ! -f "$use_libbind/lib/libisc.a" -+ ! -f "$use_libbind/$libdir/libisc.a" - then -- AC_MSG_ERROR([Cannot find static libraries at $use_libbind/lib]) -+ AC_MSG_ERROR([Cannot find static libraries at $use_libbind/$libdir]) - fi - fi - diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp_4.4.2.bb b/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp_4.4.2.bb deleted file mode 100644 index cf4af826..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/dhcp_4.4.2.bb +++ /dev/null @@ -1,23 +0,0 @@ -require dhcp.inc - -SRC_URI += "file://0001-define-macro-_PATH_DHCPD_CONF-and-_PATH_DHCLIENT_CON.patch \ - file://0002-dhclient-dbus.patch \ - file://0003-link-with-lcrypto.patch \ - file://0004-Fix-out-of-tree-builds.patch \ - file://0005-dhcp-client-fix-invoke-dhclient-script-failed-on-Rea.patch \ - file://0007-Add-configure-argument-to-make-the-libxml2-dependenc.patch \ - file://0009-remove-dhclient-script-bash-dependency.patch \ - file://0012-dhcp-correct-the-intention-for-xml2-lib-search.patch \ - file://0013-fixup_use_libbind.patch \ - file://0001-workaround-busybox-limitation-in-linux-dhclient-script.patch \ -" - -SRC_URI[md5sum] = "2afdaf8498dc1edaf3012efdd589b3e1" -SRC_URI[sha256sum] = "1a7ccd64a16e5e68f7b5e0f527fd07240a2892ea53fe245620f4f5f607004521" - -LDFLAGS_append = " -pthread" - -PACKAGECONFIG ?= "" -PACKAGECONFIG[bind-httpstats] = "--with-libxml2,--without-libxml2,libxml2" - -CFLAGS += "-fcommon" diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/files/default-relay b/meta-arm-autonomy/recipes-connectivity/dhcp/files/default-relay deleted file mode 100644 index 7961f014..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/files/default-relay +++ /dev/null @@ -1,12 +0,0 @@ -# Defaults for dhcp-relay initscript -# sourced by /etc/init.d/dhcp-relay - -# What servers should the DHCP relay forward requests to? -# e.g: SERVERS="192.168.0.1" -SERVERS="" - -# On what interfaces should the DHCP relay (dhrelay) serve DHCP requests? -INTERFACES="" - -# Additional options that are passed to the DHCP relay daemon? -OPTIONS="" diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/files/default-server b/meta-arm-autonomy/recipes-connectivity/dhcp/files/default-server deleted file mode 100644 index 0385d169..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/files/default-server +++ /dev/null @@ -1,7 +0,0 @@ -# Defaults for dhcp initscript -# sourced by /etc/init.d/dhcp-server -# installed at /etc/default/dhcp-server by the maintainer scripts - -# On what interfaces should the DHCP server (dhcpd) serve DHCP requests? -# Separate multiple interfaces with spaces, e.g. "eth0 eth1". -INTERFACES="" diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/files/dhclient-systemd-wrapper b/meta-arm-autonomy/recipes-connectivity/dhcp/files/dhclient-systemd-wrapper deleted file mode 100644 index 7d0e224a..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/files/dhclient-systemd-wrapper +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh - -# In case the interface is used for nfs, skip it. -nfsroot=0 -interfaces="" -exec 9<&0 < /proc/mounts -while read dev mtpt fstype rest; do - if test $mtpt = "/" ; then - case $fstype in - nfs | nfs4) - nfsroot=1 - nfs_addr=`echo $rest | sed -e 's/^.*addr=\([0-9.]*\).*$/\1/'` - break - ;; - *) - ;; - esac - fi -done -exec 0<&9 9<&- - -if [ $nfsroot -eq 0 ]; then - interfaces="$INTERFACES" -else - if [ -x /bin/ip -o -x /sbin/ip ] ; then - nfs_iface=`ip route get $nfs_addr | grep dev | sed -e 's/^.*dev \([-a-z0-9.]*\).*$/\1/'` - fi - for i in $INTERFACES; do - if test "x$i" = "x$nfs_iface"; then - echo "dhclient skipping nfsroot interface $i" - else - interfaces="$interfaces $i" - fi - done -fi - -if test "x$interfaces" != "x"; then - /sbin/dhclient -d -cf /etc/dhcp/dhclient.conf -q -lf /var/lib/dhcp/dhclient.leases $interfaces -fi diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/files/dhclient.conf b/meta-arm-autonomy/recipes-connectivity/dhcp/files/dhclient.conf deleted file mode 100644 index 0e6dcf96..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/files/dhclient.conf +++ /dev/null @@ -1,50 +0,0 @@ -# Configuration file for /sbin/dhclient, which is included in Debian's -# dhcp3-client package. -# -# This is a sample configuration file for dhclient. See dhclient.conf's -# man page for more information about the syntax of this file -# and a more comprehensive list of the parameters understood by -# dhclient. -# -# Normally, if the DHCP server provides reasonable information and does -# not leave anything out (like the domain name, for example), then -# few changes must be made to this file, if any. -# - -#send host-name "andare.fugue.com"; -#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c; -#send dhcp-lease-time 3600; -#supersede domain-name "fugue.com home.vix.com"; -#prepend domain-name-servers 127.0.0.1; -request subnet-mask, broadcast-address, time-offset, routers, - domain-name, domain-name-servers, host-name, - netbios-name-servers, netbios-scope; -#require subnet-mask, domain-name-servers; -#timeout 60; -#retry 60; -#reboot 10; -#select-timeout 5; -#initial-interval 2; -#script "/etc/dhcp3/dhclient-script"; -#media "-link0 -link1 -link2", "link0 link1"; -#reject 192.33.137.209; - -#alias { -# interface "eth0"; -# fixed-address 192.5.5.213; -# option subnet-mask 255.255.255.255; -#} - -#lease { -# interface "eth0"; -# fixed-address 192.33.137.200; -# medium "link0 link1"; -# option host-name "andare.swiftmedia.com"; -# option subnet-mask 255.255.255.0; -# option broadcast-address 192.33.137.255; -# option routers 192.33.137.250; -# option domain-name-servers 127.0.0.1; -# renew 2 2000/1/12 00:00:01; -# rebind 2 2000/1/12 00:00:01; -# expire 2 2000/1/12 00:00:01; -#} diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/files/dhclient.service b/meta-arm-autonomy/recipes-connectivity/dhcp/files/dhclient.service deleted file mode 100644 index 9ddb4d1d..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/files/dhclient.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Dynamic Host Configuration Protocol (DHCP) -Wants=network.target -Before=network.target -After=systemd-udevd.service - -[Service] -EnvironmentFile=-@SYSCONFDIR@/default/dhcp-client -ExecStart=@BASE_SBINDIR@/dhclient-systemd-wrapper -RemainAfterExit=yes - -[Install] -WantedBy=multi-user.target diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/files/dhcpd.conf b/meta-arm-autonomy/recipes-connectivity/dhcp/files/dhcpd.conf deleted file mode 100644 index 0001c0f0..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/files/dhcpd.conf +++ /dev/null @@ -1,108 +0,0 @@ -# -# Sample configuration file for ISC dhcpd for Debian -# -# $Id: dhcpd.conf,v 1.1.1.1 2002/05/21 00:07:44 peloy Exp $ -# - -# The ddns-updates-style parameter controls whether or not the server will -# attempt to do a DNS update when a lease is confirmed. We default to the -# behavior of the version 2 packages ('none', since DHCP v2 didn't -# have support for DDNS.) -ddns-update-style none; - -# option definitions common to all supported networks... -option domain-name "example.org"; -option domain-name-servers ns1.example.org, ns2.example.org; - -default-lease-time 600; -max-lease-time 7200; - -# If this DHCP server is the official DHCP server for the local -# network, the authoritative directive should be uncommented. -#authoritative; - -# Use this to send dhcp log messages to a different log file (you also -# have to hack syslog.conf to complete the redirection). -log-facility local7; - -# No service will be given on this subnet, but declaring it helps the -# DHCP server to understand the network topology. - -#subnet 10.152.187.0 netmask 255.255.255.0 { -#} - -# This is a very basic subnet declaration. - -#subnet 10.254.239.0 netmask 255.255.255.224 { -# range 10.254.239.10 10.254.239.20; -# option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org; -#} - -# This declaration allows BOOTP clients to get dynamic addresses, -# which we don't really recommend. - -#subnet 10.254.239.32 netmask 255.255.255.224 { -# range dynamic-bootp 10.254.239.40 10.254.239.60; -# option broadcast-address 10.254.239.31; -# option routers rtr-239-32-1.example.org; -#} - -# A slightly different configuration for an internal subnet. -#subnet 10.5.5.0 netmask 255.255.255.224 { -# range 10.5.5.26 10.5.5.30; -# option domain-name-servers ns1.internal.example.org; -# option domain-name "internal.example.org"; -# option routers 10.5.5.1; -# option broadcast-address 10.5.5.31; -# default-lease-time 600; -# max-lease-time 7200; -#} - -# Hosts which require special configuration options can be listed in -# host statements. If no address is specified, the address will be -# allocated dynamically (if possible), but the host-specific information -# will still come from the host declaration. - -#host passacaglia { -# hardware ethernet 0:0:c0:5d:bd:95; -# filename "vmunix.passacaglia"; -# server-name "toccata.fugue.com"; -#} - -# Fixed IP addresses can also be specified for hosts. These addresses -# should not also be listed as being available for dynamic assignment. -# Hosts for which fixed IP addresses have been specified can boot using -# BOOTP or DHCP. Hosts for which no fixed address is specified can only -# be booted with DHCP, unless there is an address range on the subnet -# to which a BOOTP client is connected which has the dynamic-bootp flag -# set. -#host fantasia { -# hardware ethernet 08:00:07:26:c0:a5; -# fixed-address fantasia.fugue.com; -#} - -# You can declare a class of clients and then do address allocation -# based on that. The example below shows a case where all clients -# in a certain class get addresses on the 10.17.224/24 subnet, and all -# other clients get addresses on the 10.0.29/24 subnet. - -#class "foo" { -# match if substring (option vendor-class-identifier, 0, 4) = "SUNW"; -#} - -#shared-network 224-29 { -# subnet 10.17.224.0 netmask 255.255.255.0 { -# option routers rtr-224.example.org; -# } -# subnet 10.0.29.0 netmask 255.255.255.0 { -# option routers rtr-29.example.org; -# } -# pool { -# allow members of "foo"; -# range 10.17.224.10 10.17.224.250; -# } -# pool { -# deny members of "foo"; -# range 10.0.29.10 10.0.29.230; -# } -#} diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/files/dhcpd.service b/meta-arm-autonomy/recipes-connectivity/dhcp/files/dhcpd.service deleted file mode 100644 index ae4f93ec..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/files/dhcpd.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=DHCPv4 Server Daemon -Documentation=man:dhcpd(8) man:dhcpd.conf(5) -After=network.target -After=time-sync.target - -[Service] -PIDFile=@localstatedir@/run/dhcpd.pid -EnvironmentFile=@SYSCONFDIR@/default/dhcp-server -EnvironmentFile=-@SYSCONFDIR@/sysconfig/dhcp-server -ExecStartPre=@base_bindir@/touch @localstatedir@/lib/dhcp/dhcpd.leases -ExecStart=@SBINDIR@/dhcpd -f -cf @SYSCONFDIR@/dhcp/dhcpd.conf -pf @localstatedir@/run/dhcpd.pid $DHCPDARGS -q $INTERFACES - -[Install] -WantedBy=multi-user.target diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/files/dhcpd6.service b/meta-arm-autonomy/recipes-connectivity/dhcp/files/dhcpd6.service deleted file mode 100644 index 52a6224d..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/files/dhcpd6.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=DHCPv6 Server Daemon -Documentation=man:dhcpd(8) man:dhcpd.conf(5) -After=network.target -After=time-sync.target - -[Service] -PIDFile=@localstatedir@/run/dhcpd6.pid -EnvironmentFile=@SYSCONFDIR@/default/dhcp-server -EnvironmentFile=-@SYSCONFDIR@/sysconfig/dhcpd6 -ExecStartPre=@base_bindir@/touch @localstatedir@/lib/dhcp/dhcpd6.leases -ExecStart=@SBINDIR@/dhcpd -f -6 -cf @SYSCONFDIR@/dhcp/dhcpd6.conf -pf @localstatedir@/run/dhcpd6.pid $DHCPDARGS -q $INTERFACES - -[Install] -WantedBy=multi-user.target diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/files/dhcrelay.service b/meta-arm-autonomy/recipes-connectivity/dhcp/files/dhcrelay.service deleted file mode 100644 index 15ff927d..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/files/dhcrelay.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=DHCP Relay Agent Daemon -After=network.target - -[Service] -EnvironmentFile=@SYSCONFDIR@/default/dhcp-relay -ExecStart=@SBINDIR@/dhcrelay -d --no-pid -q $SERVERS - -[Install] -WantedBy=multi-user.target diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/files/init-relay b/meta-arm-autonomy/recipes-connectivity/dhcp/files/init-relay deleted file mode 100644 index 019a7e84..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/files/init-relay +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -# -# $Id: dhcp3-relay,v 1.1 2004/04/16 15:41:08 ml Exp $ -# - -# It is not safe to start if we don't have a default configuration... -if [ ! -f /etc/default/dhcp-relay ]; then - echo "/etc/default/dhcp-relay does not exist! - Aborting..." - echo "create this file to fix the problem." - exit 1 -fi - -# Read init script configuration (interfaces the daemon should listen on -# and the DHCP server we should forward requests to.) -. /etc/default/dhcp-relay - -# Build command line for interfaces (will be passed to dhrelay below.) -IFCMD="" -if test "$INTERFACES" != ""; then - for I in $INTERFACES; do - IFCMD=${IFCMD}"-i "${I}" " - done -fi - -DHCRELAYPID=/var/run/dhcrelay.pid - -case "$1" in - start) - start-stop-daemon -S -x /usr/sbin/dhcrelay -- -q $OPTIONS $IFCMD $SERVERS - ;; - stop) - start-stop-daemon -K -x /usr/sbin/dhcrelay - ;; - restart | force-reload) - $0 stop - sleep 2 - $0 start - ;; - *) - echo "Usage: /etc/init.d/dhcp-relay {start|stop|restart|force-reload}" - exit 1 -esac - -exit 0 diff --git a/meta-arm-autonomy/recipes-connectivity/dhcp/files/init-server b/meta-arm-autonomy/recipes-connectivity/dhcp/files/init-server deleted file mode 100644 index 5e693adf..00000000 --- a/meta-arm-autonomy/recipes-connectivity/dhcp/files/init-server +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -# -# $Id: dhcp3-server.init.d,v 1.4 2003/07/13 19:12:41 mdz Exp $ -# - -test -f /usr/sbin/dhcpd || exit 0 - -# It is not safe to start if we don't have a default configuration... -if [ ! -f /etc/default/dhcp-server ]; then - echo "/etc/default/dhcp-server does not exist! - Aborting..." - exit 0 -fi - -# Read init script configuration (so far only interfaces the daemon -# should listen on.) -. /etc/default/dhcp-server - -case "$1" in - start) - echo -n "Starting DHCP server: " - test -d /var/lib/dhcp/ || mkdir -p /var/lib/dhcp/ - test -f /var/lib/dhcp/dhcpd.leases || touch /var/lib/dhcp/dhcpd.leases - start-stop-daemon -S -x /usr/sbin/dhcpd -- -q $INTERFACES -user dhcp -group dhcp - echo "." - ;; - stop) - echo -n "Stopping DHCP server: dhcpd3" - start-stop-daemon -K -x /usr/sbin/dhcpd - echo "." - ;; - restart | force-reload) - $0 stop - sleep 2 - $0 start - if [ "$?" != "0" ]; then - exit 1 - fi - ;; - *) - echo "Usage: /etc/init.d/dhcp-server {start|stop|restart|force-reload}" - exit 1 -esac - -exit 0 diff --git a/meta-arm-autonomy/recipes-containers/import-docker-image/files/import_container.sh b/meta-arm-autonomy/recipes-containers/import-docker-image/files/import_container.sh new file mode 100755 index 00000000..a7646b37 --- /dev/null +++ b/meta-arm-autonomy/recipes-containers/import-docker-image/files/import_container.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +CONTAINER_IMAGE_FILE="###CONTAINER_IMAGE_FILE###" +CONTAINER_IMAGE_NAME_AND_TAG="###CONTAINER_IMAGE_NAME_AND_TAG###" +CONTAINER_IMAGE_FILE_KEEP="###CONTAINER_IMAGE_FILE_KEEP###" + +has_docker_image() { + docker image inspect "$1" >/dev/null 2>&1 +} + +start() { + # Image does not exist and image file exists: Import the image. + if ! has_docker_image ${CONTAINER_IMAGE_NAME_AND_TAG} && \ + [ -f "/usr/share/docker/images/${CONTAINER_IMAGE_FILE}" ]; then + echo "Importing ${CONTAINER_IMAGE_NAME_AND_TAG} container image..." + docker import \ + /usr/share/docker/images/${CONTAINER_IMAGE_FILE} \ + ${CONTAINER_IMAGE_NAME_AND_TAG} 2>&1 || { + echo "Import ${CONTAINER_IMAGE_NAME_AND_TAG} container image: Failed." + exit $? + } + echo "Import ${CONTAINER_IMAGE_NAME_AND_TAG} container image: Done." + + if [ "${CONTAINER_IMAGE_FILE_KEEP}" != "1" ]; then + rm /usr/share/docker/images/${CONTAINER_IMAGE_FILE} + fi + fi +} + +case "$1" in + start) + start && exit 0 + ;; + *) + echo "Usage: $0 {start}" + exit 2 +esac + +exit $? diff --git a/meta-arm-autonomy/recipes-containers/import-docker-image/import-docker-image.bb b/meta-arm-autonomy/recipes-containers/import-docker-image/import-docker-image.bb new file mode 100644 index 00000000..cdd76d5f --- /dev/null +++ b/meta-arm-autonomy/recipes-containers/import-docker-image/import-docker-image.bb @@ -0,0 +1,79 @@ +# +# This recipe imports a docker container image to the xenguest image +# Notes: +# - Users should add docker in the local.conf of their target with +# DISTRO_FEATURES += " docker" to make sure docker is installed. +# - The CONTAINER_IMAGE_FILE variable defines the docker +# container image to be imported and should be set in local.conf. +# - The CONTAINER_IMAGE_FILE_KEEP variable defines the +# behaviour that if the container image file is kept after import. +# Setting this variable to 1 means keep the container image file after +# import. This variable can be set in local.conf. +# - The CONTAINER_IMAGE_NAME_AND_TAG variable defines the name and +# tag of the imported image. The value of this variable should follow +# the format of `NAME:TAG`. This variable can be set in local.conf. +# + +DESCRIPTION = "Import a docker image to xenguest" +LICENSE = "MIT" + +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" + +CONTAINER_IMAGE_FILE ??= "" +CONTAINER_IMAGE_FILE_KEEP ??= "" +CONTAINER_IMAGE_NAME_AND_TAG ??= "local:local" + +inherit features_check +REQUIRED_DISTRO_FEATURES = "docker" + +python __anonymous() { + # Check if `CONTAINER_IMAGE_FILE` is empty. + container_image_file = d.getVar('CONTAINER_IMAGE_FILE') + if not container_image_file: + raise bb.parse.SkipRecipe("CONTAINER_IMAGE_FILE is empty") + + # In case we have a symlink we need to convert the link to its realpath. + if os.path.islink(container_image_file): + container_image_file = os.path.realpath(container_image_file) + bb.warn("Given CONTAINER_IMAGE_FILE: %s is a symlink, " + "convert the link to its realpath: %s" % + (d.getVar('CONTAINER_IMAGE_FILE'), container_image_file)) + d.setVar('CONTAINER_IMAGE_FILE', container_image_file) + + # Check if the container image file exists. + # The container image file here is either the real file or the symlink target. + if not os.path.exists(container_image_file): + raise bb.parse.SkipRecipe("CONTAINER_IMAGE_FILE: %s does not exist." % + container_image_file) + + # Here we can ensure that the CONTAINER_IMAGE_FILE exists and is valid. + # Therefore we can append this file to SRC_URI. + d.appendVar('SRC_URI', ' file://' + container_image_file + ';unpack=0') +} + +S = "${WORKDIR}" +SRC_URI = "file://import_container.sh" + +inherit update-rc.d +INITSCRIPT_PARAMS = "start 30 2 3 4 5 ." +INITSCRIPT_NAME = "import_container.sh" + +do_install() { + install -d ${D}${sysconfdir}/init.d + install -d -m 755 ${D}${datadir}/docker/images + + install -m 777 ${CONTAINER_IMAGE_FILE} ${D}${datadir}/docker/images/. + install -m 755 import_container.sh ${D}${sysconfdir}/init.d + + BASENAME_CONTAINER_IMAGE_FILE=$(basename "${CONTAINER_IMAGE_FILE}") + + sed -i "s,###CONTAINER_IMAGE_FILE###,${BASENAME_CONTAINER_IMAGE_FILE}," \ + ${D}${sysconfdir}/init.d/import_container.sh + sed -i "s,###CONTAINER_IMAGE_NAME_AND_TAG###,${CONTAINER_IMAGE_NAME_AND_TAG}," \ + ${D}${sysconfdir}/init.d/import_container.sh + sed -i "s,###CONTAINER_IMAGE_FILE_KEEP###,${CONTAINER_IMAGE_FILE_KEEP}," \ + ${D}${sysconfdir}/init.d/import_container.sh +} + +FILES_${PN} += "${datadir}/docker/images" +RDEPENDS_${PN} = "packagegroup-docker-runtime-minimal" diff --git a/meta-arm-autonomy/recipes-core/busybox/busybox/feature_tar_long_options.cfg b/meta-arm-autonomy/recipes-core/busybox/busybox/feature_tar_long_options.cfg new file mode 100644 index 00000000..151a3df9 --- /dev/null +++ b/meta-arm-autonomy/recipes-core/busybox/busybox/feature_tar_long_options.cfg @@ -0,0 +1 @@ +CONFIG_FEATURE_TAR_LONG_OPTIONS=y diff --git a/meta-arm-autonomy/recipes-core/busybox/busybox_%.bbappend b/meta-arm-autonomy/recipes-core/busybox/busybox_%.bbappend new file mode 100644 index 00000000..e3355815 --- /dev/null +++ b/meta-arm-autonomy/recipes-core/busybox/busybox_%.bbappend @@ -0,0 +1,4 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" + +# The --exclude flag in Busybox tar is required by xenguest-mkimage +SRC_URI += "file://feature_tar_long_options.cfg" diff --git a/meta-arm-autonomy/recipes-core/images/arm-autonomy-host-image-minimal.bb b/meta-arm-autonomy/recipes-core/images/arm-autonomy-host-image-minimal.bb index 188e31d6..7960a35a 100644 --- a/meta-arm-autonomy/recipes-core/images/arm-autonomy-host-image-minimal.bb +++ b/meta-arm-autonomy/recipes-core/images/arm-autonomy-host-image-minimal.bb @@ -2,7 +2,11 @@ DESCRIPTION = "Arm Autonomy stack host minimal image" -inherit core-image +# When alternate-kernel DISTRO_FEATURE is present we will build +# and install the alternate kernel +inherit ${@bb.utils.filter('DISTRO_FEATURES', 'alternate-kernel', d)} + +inherit core-image features_check LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" @@ -10,12 +14,21 @@ LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda # The ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUESTS variable can be used to include in the # image one or several xenguest images. # The list must be space separated and each entry must have the following -# format: URL[;guestname=NAME] +# format: URL[;params] # - URL can be the full path to a file or a Yocto compatible SRC_URI url -# - guestname=NAME can be used to specify the name of the guest. If not -# specified the basename of the file (without .xenguest extension) is used. +# - params encompasses two values that can be optionally set: +# - guestname=NAME can be used to specify the name of the guest. If not +# specified the default value is the basename of the file +# (without .xenguest extension). +# - guestcount=NUM can be used to created NUM guests with the same config. +# All guests after the first will have numbers appended to the guestname, +# starting from 2. In the rootfs additional xenguest files will be +# symlinks to the original. +# params should be semicolon seperated, without a space, and can appear in +# any order. +# # Here are examples of values: -# /home/mydir/myguest.xenguest;guestname=guest1 +# /home/mydir/myguest.xenguest;guestname=guest1;guestcount=3 # http://www.url.com/testguest.xenguest # # If you are using the output of an other Yocto project, you should use the @@ -50,12 +63,31 @@ EXTRA_IMAGEDEPENDS += "xen" # Build xen-devicetree to produce a xen ready devicetree EXTRA_IMAGEDEPENDS += "xen-devicetree" -python __anonymous() { - if bb.utils.contains('DISTRO_FEATURES', 'arm-autonomy-host', False, True, d): - raise bb.parse.SkipRecipe("DISTRO_FEATURES does not contain 'arm-autonomy-host'") +# Documentation for setting up a multiconfig build can be found in: +# meta-arm-autonomy/documentation/arm-autonomy-multiconfig.md - if bb.utils.contains('DISTRO_FEATURES', 'xen', False, True, d): - raise bb.parse.SkipRecipe("DISTRO_FEATURES does not contain 'xen'") +# In a multiconfig build this variable will hold a dependency string, which differs based +# on whether the guest has initramfs or not. +# It may have a space seperated list of dependency strings if mulitple guest types are +# configured +MC_DOIMAGE_MCDEPENDS ?= "" +# Example value: mc:host:guest:core-image-minimal:do_image_complete + +# In a multiconfig build the host task 'do_image' has a dependency on multiconfig guest. +# This ensures that the guest image file already exists when it is needed by the host +DO_IMAGE_MCDEPENDS := "${@ '${MC_DOIMAGE_MCDEPENDS}' if d.getVar('BBMULTICONFIG') else ''}" + +# Apply mc dependency. Empty string if multiconfig not enabled +do_image[mcdepends] += "${DO_IMAGE_MCDEPENDS}" + +REQUIRED_DISTRO_FEATURES += 'arm-autonomy-host' +REQUIRED_DISTRO_FEATURES += 'xen' + +python __anonymous() { + import re + guestfile_pattern = re.compile(r"^([^;]+);") + guestname_pattern = re.compile(r";guestname=([^;]+);?") + guestcount_pattern = re.compile(r";guestcount=(\d+);?") # Check in ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUESTS for extra guests and add them # to SRC_URI with xenguest parameter if not set @@ -65,16 +97,19 @@ python __anonymous() { # If the user just specified a file instead of file://FILE, add # the file:// prefix if guest.startswith('/'): - guestfile = '' - guestname = '' - if ';guestname=' in guest: - # user specified a guestname - guestname = guest.split(';guestname=')[1] - guestfile = guest.split(';guestname=')[0] - else: - # no guestname so use the basename - guestname = os.path.basename(guest) - guestfile = guest + guestname = os.path.basename(guest) + guestfile = guest + guestcount = "1" + f = guestfile_pattern.search(guest) + n = guestname_pattern.search(guest) + c = guestcount_pattern.search(guest) + + if f is not None: + guestfile = f.group(1) + if n is not None: + guestname = n.group(1) + if c is not None: + guestcount = c.group(1) # in case we have a link we need the destination guestfile = os.path.realpath(guestfile) @@ -83,7 +118,7 @@ python __anonymous() { raise bb.parse.SkipRecipe("ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUESTS entry does not exist: " + guest) # In case the file is a symlink make sure we use the destination - d.appendVar('SRC_URI', ' file://' + guestfile + ';guestname=' + guestname) + d.appendVar('SRC_URI', ' file://' + guestfile + ';guestname=' + guestname + ';guestcount=' + guestcount) else: # we have a Yocto URL try: @@ -106,14 +141,28 @@ python add_extern_guests () { _, _, path, _, _, parm = bb.fetch.decodeurl(entry) if 'guestname' in parm: if os.path.islink(path): - bb.fatal("Guest file is a symlink: " + path) + realpath = os.path.realpath(path) + + if not os.path.exists(realpath): + bb.fatal("ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUESTS link does not resolve: " + path) + + bb.note("Guest file is a symlink:\n " + path + "\nResolved to:\n " + realpath) + path = realpath + bb.utils.mkdirhier(guestdir) dstname = parm['guestname'] # Add file extension if not there if not dstname.endswith('.xenguest'): dstname += '.xenguest' + if not bb.utils.copyfile(path, guestdir + '/' + dstname): bb.fatal("Fail to copy Guest file " + path) + + if 'guestcount' in parm: + guestcount = int(parm['guestcount']) + 1 + + for i in range(2, guestcount): + os.symlink('./' + dstname, guestdir + '/' + dstname.replace('.xenguest', str(i) + '.xenguest')) } IMAGE_PREPROCESS_COMMAND += "add_extern_guests; " diff --git a/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb b/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb index ccbb3876..db955e16 100644 --- a/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb +++ b/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb @@ -14,10 +14,12 @@ DESCRIPTION = "Add entries in DTB for Xen and Dom0" # Please refer to documentation/xen-devicetree.md for documentation on those # parameters -XEN_DEVICETREE_DEPEND ?= "virtual/kernel:do_deploy" +# kernel size is passed to xen via xen.dtb so wee need to add +# 'virtual/kernel:do_deploy' as a dependency +XEN_DEVICETREE_DEPEND_append = " virtual/kernel:do_deploy" XEN_DEVICETREE_DTBS ?= "${KERNEL_DEVICETREE}" XEN_DEVICETREE_XEN_BOOTARGS ?= "noreboot dom0_mem=${XEN_DEVICETREE_DOM0_MEM}" -XEN_DEVICETREE_DOM0_MEM ?= "1024M" +XEN_DEVICETREE_DOM0_MEM ?= "1024M,max:1024M" XEN_DEVICETREE_DOM0_BOOTARGS ?= "console=hvc0 earlycon=xen" XEN_DEVICETREE_DOM0_ADDR ?= "0x80080000" XEN_DEVICETREE_DOM0_SIZE ?= "0x01000000" @@ -28,11 +30,36 @@ XEN_DEVICETREE_DTSI_MERGE ?= "xen.dtsi" inherit nopackages deploy DEPENDS += "dtc-native" +PACKAGE_ARCH = "${MACHINE_ARCH}" do_configure[noexec] = "1" do_compile[noexec] = "1" do_install[noexec] = "1" +# Validate xen devicetree variables +python __anonymous() { + + # Compare values of a list of variables to a regex pattern + def validate_type(pattern, var_list): + for varname in var_list: + if d.getVar(varname): + if not pattern.match(d.getVar(varname)): + raise bb.parse.SkipRecipe(d.getVar(varname) + "' is not a valid value for " + varname + "!") + else: + raise bb.parse.SkipRecipe('Required variable ' + varname + ' is empty!') + + import re + + num_vars_to_check = ['XEN_DEVICETREE_DOM0_ADDR', 'XEN_DEVICETREE_DOM0_SIZE'] + size_vars_to_check = ['XEN_DEVICETREE_DOM0_MEM'] + + num_pattern = re.compile(r'((0x[0-9a-fA-F]+)|[0-9]+)$') + size_pattern = re.compile(r'[0-9]+[MG](,max:[0-9]+[MG])?$') + + validate_type(num_pattern, num_vars_to_check) + validate_type(size_pattern, size_vars_to_check) +} + do_deploy() { if [ ! -f ${WORKDIR}/xen.dtsi.in ]; then die "xen.dtsi.in does not exist" @@ -67,6 +94,37 @@ do_deploy() { done } do_deploy[depends] += "${XEN_DEVICETREE_DEPEND}" +do_deploy[prefuncs] += "calc_xen_dtb_dom0_size" addtask deploy after do_install +python calc_xen_dtb_dom0_size() { + from math import ceil + size = 0 + if d.getVar('KERNEL_IMAGE_MAXSIZE'): + bb.note('size calculation based on KERNEL_IMAGE_MAXSIZE') + size = int(d.getVar('KERNEL_IMAGE_MAXSIZE')) * 1024 + else: + kernel = os.path.realpath(d.getVar('DEPLOY_DIR_IMAGE') + '/' +\ + d.getVar('KERNEL_IMAGETYPE')) + size = os.stat(kernel).st_size + bb.note('size calculation based on kernel Image file: %s' % kernel) + + bb.note('size in bytes: %d' % size) + # Ceil to MiB + size_required = ceil(size / (2 ** 20)) * (2 ** 20) + xen_devicetree_dom0_size = d.getVar('XEN_DEVICETREE_DOM0_SIZE') + if xen_devicetree_dom0_size[:2] == "0x": + size_defined = int(xen_devicetree_dom0_size, 16) + else: + size_defined = int(xen_devicetree_dom0_size) + + if size_required > size_defined: + bb.note ("Wrong kernel size setting inside xen dtb!\n"\ + "Required:\t%(req)d (%(req)#010X)\n"\ + "Requested:\t%(def)d (%(def)#010X)"\ + % {"req": size_required, "def": size_defined}) + bb.note ("Overriding XEN_DEVICETREE_DOM0_SIZE with "\ + "%(req)d (%(req)#010X)" % {"req": size_required}) + d.setVar('XEN_DEVICETREE_DOM0_SIZE', hex(size_required)) +} diff --git a/meta-arm-autonomy/recipes-extended/xen/xen-tools/0001-vif-nat-fix-hostname.patch b/meta-arm-autonomy/recipes-extended/xen/xen-tools/0001-vif-nat-fix-hostname.patch index 87f25e25..d2e52cef 100644 --- a/meta-arm-autonomy/recipes-extended/xen/xen-tools/0001-vif-nat-fix-hostname.patch +++ b/meta-arm-autonomy/recipes-extended/xen/xen-tools/0001-vif-nat-fix-hostname.patch @@ -1,18 +1,34 @@ -Upstream-Status: Pending +Upstream-Status: Backport Signed-off-by: Diego Sueiro +Signed-off-by: Kamil Dziezyk + +From 5499e0fc8082024bf7e2d0facd5c976e82105070 Mon Sep 17 00:00:00 2001 +From: Diego Sueiro +Date: Thu, 20 Aug 2020 11:58:20 +0100 +Subject: [PATCH] tools/hotplug: Fix hostname setting in vif-nat Setting the hostname is failing because the "$XENBUS_PATH/domain" doesn't exist anymore. To fix this we set it to dom$domid -Index: git/tools/hotplug/Linux/vif-nat -=================================================================== ---- git.orig/tools/hotplug/Linux/vif-nat -+++ git/tools/hotplug/Linux/vif-nat -@@ -86,6 +86,7 @@ router_ip=$(routing_ip "$ip") +Signed-off-by: Diego Sueiro +Reviewed-by: Bertrand Marquis +Acked-by: Wei Liu +--- + tools/hotplug/Linux/vif-nat | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/hotplug/Linux/vif-nat b/tools/hotplug/Linux/vif-nat +index a76d9c784b..26144350b3 100644 +--- a/tools/hotplug/Linux/vif-nat ++++ b/tools/hotplug/Linux/vif-nat +@@ -85,7 +85,7 @@ router_ip=$(routing_ip "$ip") + # Split the given IP/bits pair. vif_ip=`echo ${ip} | awk -F/ '{print $1}'` - hostname=$(xenstore_read "$XENBUS_PATH/domain" | tr -- '_.:/+' '-----') -+[ -z "${hostname}" ] && hostname=dom$domid +-hostname=$(xenstore_read "$XENBUS_PATH/domain" | tr -- '_.:/+' '-----') ++hostname=dom$domid if [ "$vifid" != "1" ] then hostname="$hostname-$vifid" +-- +2.17.1 diff --git a/meta-arm-autonomy/recipes-extended/xen/xen-tools/0002-vif-nat-fix-symlink-removal.patch b/meta-arm-autonomy/recipes-extended/xen/xen-tools/0002-vif-nat-fix-symlink-removal.patch deleted file mode 100644 index bcd5778a..00000000 --- a/meta-arm-autonomy/recipes-extended/xen/xen-tools/0002-vif-nat-fix-symlink-removal.patch +++ /dev/null @@ -1,45 +0,0 @@ -Upstream-Status: Pending -Signed-off-by: Diego Sueiro - -Copy temp files used to add/remove dhcpd configurations to avoid -replacing potential symlinks. - -Index: git/tools/hotplug/Linux/vif-nat -=================================================================== ---- git.orig/tools/hotplug/Linux/vif-nat -+++ git/tools/hotplug/Linux/vif-nat -@@ -99,7 +100,8 @@ dhcparg_remove_entry() - then - rm "$tmpfile" - else -- mv "$tmpfile" "$dhcpd_arg_file" -+ cp "$tmpfile" "$dhcpd_arg_file" -+ rm "$tmpfile" - fi - } - -@@ -109,11 +111,11 @@ dhcparg_add_entry() - local tmpfile=$(mktemp) - # handle Red Hat, SUSE, and Debian styles, with or without quotes - sed -e 's/^DHCPDARGS="*\([^"]*\)"*/DHCPDARGS="\1'"${dev} "'"/' \ -- "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file" -+ "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file" - sed -e 's/^DHCPD_INTERFACE="*\([^"]*\)"*/DHCPD_INTERFACE="\1'"${dev} "'"/' \ -- "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file" -+ "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file" - sed -e 's/^INTERFACES="*\([^"]*\)"*/INTERFACES="\1'"${dev} "'"/' \ -- "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file" -+ "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file" - rm -f "$tmpfile" - } - -@@ -125,7 +127,8 @@ dhcp_remove_entry() - then - rm "$tmpfile" - else -- mv "$tmpfile" "$dhcpd_conf_file" -+ cp "$tmpfile" "$dhcpd_conf_file" -+ rm "$tmpfile" - fi - dhcparg_remove_entry - } diff --git a/meta-arm-autonomy/recipes-extended/xen/xen-tools_%.bbappend b/meta-arm-autonomy/recipes-extended/xen/xen-tools_%.bbappend index 45739ffb..51e0dfa5 100644 --- a/meta-arm-autonomy/recipes-extended/xen/xen-tools_%.bbappend +++ b/meta-arm-autonomy/recipes-extended/xen/xen-tools_%.bbappend @@ -1,7 +1,6 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" SRC_URI += "file://0001-vif-nat-fix-hostname.patch \ - file://0002-vif-nat-fix-symlink-removal.patch \ " PACKAGECONFIG_remove = "\ diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/00-vif-xenguest.hook b/meta-arm-autonomy/recipes-extended/xenguest/files/00-vif-xenguest.hook index 7a2fb6ff..37ecec00 100755 --- a/meta-arm-autonomy/recipes-extended/xenguest/files/00-vif-xenguest.hook +++ b/meta-arm-autonomy/recipes-extended/xenguest/files/00-vif-xenguest.hook @@ -18,6 +18,8 @@ domid=$(xenstore_read "${XENBUS_PATH}/frontend-id") guestname=$(xenstore_read "/local/domain/${domid}/name") bridge=$(xenstore_read "${XENBUS_PATH}/bridge") +mac=$(xenstore_read "$XENBUS_PATH/mac") +kea_conf_file="/etc/kea/kea-dhcp4.conf" if [ ! -f /etc/xenguest/guests/${guestname}/params.cfg ]; then log debug "No /etc/xenguest/guests/${guestname}/params.cfg. Exiting." @@ -36,63 +38,48 @@ get_subnet_prefix() { subnetprefix=$(get_subnet_prefix) -dhcpd_remove_conf_entry() +kea_remove_conf_entry() { - local tmpfile=$(mktemp) + log debug "kea_remove_conf_entry" + claim_lock "vif-nat-kea" - # Remove the the xenguest dhcpd config file inclusion in the dhcpd - # main config - grep -v "include \"${XENGUEST_DHCPD_CONF_FILE}\";" \ - "${dhcpd_conf_file}" >"${tmpfile}" - if ! diff "${tmpfile}" "${dhcpd_conf_file}" >/dev/null - then - cp "${tmpfile}" "${dhcpd_conf_file}" - fi - rm ${tmpfile} + # Remove the the xenguest kea config file inclusion in the kea main config + sed -i "/${kea_guest_config//'/'/'\/'}/d" "${kea_conf_file}" - # Remove the generated the xenguest dhcpd file - rm ${XENGUEST_DHCPD_CONF_FILE} + # Remove interface entry 1st case: [ "dev1", "dev_to_remove" ] + sed -i "s/,\ \"$dev\"//" "${kea_conf_file}" + # Remove interface entry 2nd case: [ "dev_to_remove", "dev1" ] + sed -i "s/\"$dev\",\ //" "${kea_conf_file}" + # Remove interface entry 3rd case: [ "dev_to_remove" ] + sed -i "s/\[\ \"$dev\"\ \]/\[\ \]/" "${kea_conf_file}" + + # Remove the generated the xenguest kea subnet conf file + rm ${XENGUEST_KEA_SUBNET_CONFIG} + + keactrl reload + + release_lock "vif-nat-kea" } -# This function removes the dhcpd options added by the vif-nat script and -# adds the user provided options under the ${XENGUEST_DHCPD_HOST_OPTIONS} -# variable set in "/etc/xenguest/guests/${guestname}/files/dhcpd-params.cfg" -# file. -dhcpd_add_conf_entries() +kea_add_conf_entries() { - # We need to remove the previous added entry from vif-nat script - dhcp_remove_entry + log debug "kea_add_conf_entries" + claim_lock "vif-nat-kea" - # Include the xenguest dhcpd config file in the dhcpd main config - echo >>"${dhcpd_conf_file}" "include \"${XENGUEST_DHCPD_CONF_FILE}\";" + # Include vif in the interfaces 1st case - no other entries: + search_for='\"interfaces\": \[ ' + sed -i "/${search_for}\"*\"\ */ s/\ \]/,\ \"${dev}\"\ \]/g" "${kea_conf_file}" + sed -i "s/${search_for}]/${search_for}\"${dev}\"\ \]/g" "${kea_conf_file}" - # Generate the xenguest dhcpd file - echo -e "$(eval "echo -e \"$(cat ${XENGUEST_DHCPD_PARAMS_FILE})\"")" \ - >> "${XENGUEST_DHCPD_CONF_FILE}" + # Include the xenguest kea subnet conf file in the kea main config + search_for='\"subnet4\": \[' + sed -i "/$search_for/a $kea_guest_config" "${kea_conf_file}" - # Re-add the dhcpargs entries removed by dhcp_remove_entry call - dhcparg_add_entry -} + # Generate the xenguest kea subnet conf file + echo -e "$(eval "echo -e \"$(cat ${XENGUEST_KEA_SUBNET_TEMPLATE})\"")" \ + > "${XENGUEST_KEA_SUBNET_CONFIG}" -dhcpd_online(){ - log debug "dhcpd_online" - claim_lock "vif-nat-dhcp" - dhcpd_add_conf_entries - release_lock "vif-nat-dhcp" - "$dhcpd_init_file" restart || true -} - -dhcpd_offline(){ - log debug "dhcpd_offline" - claim_lock "vif-nat-dhcp" - dhcpd_remove_conf_entry - release_lock "vif-nat-dhcp" - "$dhcpd_init_file" restart || true # We need to ignore failure because - # ISC dhcpd 3 borks if there is nothing - # for it to do, which is the case if - # the outgoing interface is not - # configured to offer leases and there - # are no vifs. + release_lock "vif-nat-kea" } call_extra_hooks() { @@ -111,24 +98,29 @@ call_extra_hooks() { case "${XENGUEST_NETWORK_TYPE}" in nat) - XENGUEST_DHCPD_PARAMS_FILE=${XENGUEST_DHCPD_PARAMS_FILE:-"/etc/xenguest/guests/${guestname}/files/dhcpd-params.cfg"} - if [ ! -f ${XENGUEST_DHCPD_PARAMS_FILE} ]; then - log debug "No ${XENGUEST_DHCPD_PARAMS_FILE} file. Aborting" + XENGUEST_KEA_SUBNET_TEMPLATE=${XENGUEST_KEA_SUBNET_TEMPLATE:-"/etc/xenguest/guests/${guestname}/files/kea-subnet4.json"} + if [ ! -f ${XENGUEST_KEA_SUBNET_TEMPLATE} ]; then + log debug "No ${XENGUEST_KEA_SUBNET_TEMPLATE} file. Aborting" return fi - XENGUEST_DHCPD_CONF_FILE="/etc/dhcp/dhcpd.dom$domid.conf" + XENGUEST_KEA_SUBNET_CONFIG="/etc/kea/kea-subnet4.dom$domid.json" + if [ ! -d "$(dirname ${XENGUEST_KEA_SUBNET_CONFIG})" ]; then + log debug "No kea configuration directory. Aborting" + return + fi + kea_guest_config="\ \ \ \ " case "$command" in online) - dhcpd_online + kea_add_conf_entries # Enable ip forwarding and NAT for the ${bridge} interface sysctl -w net.ipv4.ip_forward=1 iptables_w -t nat -A POSTROUTING -o ${bridge} -j MASQUERADE -m comment --comment "dom${domid}" ;; offline) - dhcpd_offline + kea_remove_conf_entry # Remove the NAT iptables rules created for the dom${domid} guest_ipt_rule=$(iptables_w -t nat -vL POSTROUTING -n --line-number | grep -w dom${domid} | awk '{print $1}' | tac) diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/dhcpd-params.cfg b/meta-arm-autonomy/recipes-extended/xenguest/files/dhcpd-params.cfg deleted file mode 100644 index 0495fbdb..00000000 --- a/meta-arm-autonomy/recipes-extended/xenguest/files/dhcpd-params.cfg +++ /dev/null @@ -1,30 +0,0 @@ -# This file holds the guest dhcpd options running on Dom0. -# The "/etc/xen/scripts/vif-post.d/00-vif-xenguest.hook" called in the end of -# the vif-nat script will use this file to generate the final dhcpd -# configuration. - -# This file is added in the xenguest image and installed in dom0 under -# /etc/xenguest/guests/${guestname}/files/dhcpd-params.cfg when the guest -# image is created. -# Any customizations to it should be performed by replacing it via a bbappend. - -# The \${hostname}, \${mac}, \${vif_ip} and \${router_ip} variables are set in -# the vif-nat script context. The \${subnetprefix} variable is set in the -# 00-vif-xenguest.hook script context. - -# The "subnet" configuration node is mandatory in order to have the dhcpd -# properly running. - -host ${hostname} { - hardware ethernet ${mac}; - fixed-address ${vif_ip}; - option routers ${router_ip}; - option subnet-mask 255.255.255.0; - option broadcast-address ${subnetprefix}.255; - option domain-name-servers 8.8.8.8; - option host-name \"${hostname}\"; - option domain-name \"example.com\"; -} - -subnet ${subnetprefix}.0 netmask 255.255.255.0 { -} diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/kea-dhcp4.conf b/meta-arm-autonomy/recipes-extended/xenguest/files/kea-dhcp4.conf new file mode 100644 index 00000000..0a1cc6ad --- /dev/null +++ b/meta-arm-autonomy/recipes-extended/xenguest/files/kea-dhcp4.conf @@ -0,0 +1,30 @@ +# This file holds the minimal kea dhcp4 server configuration. +# It replaces existing kea dhcp configuration file via +# "/etc/init.d/kea-restore-default-config" on every system boot. +# The "/etc/xen/scripts/vif-post.d/00-vif-xenguest.hook" called in the end of +# the vif-nat script will append each xenguest configuration to this file, +# to generate the final dhcp configuration. +# This file can be replaced with xenguest-network.bbappend. +{ +"Dhcp4": { + "interfaces-config": { + "interfaces": [ ] + }, + "lease-database": { + "type": "memfile", + "persist": false + }, + "subnet4": [ + { + "subnet": "192.0.2.0/24" + } + ], + "loggers": [ + { + "name": "kea-dhcp4", + "output_options": [ { "output": "/var/log/kea-dhcp4.log" } ], + "severity": "INFO" + } + ] +} +} diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/kea-restore-default-config b/meta-arm-autonomy/recipes-extended/xenguest/files/kea-restore-default-config new file mode 100755 index 00000000..424fd0a6 --- /dev/null +++ b/meta-arm-autonomy/recipes-extended/xenguest/files/kea-restore-default-config @@ -0,0 +1,29 @@ +#!/bin/sh +# +# Xenguest Restore default kea dhcp4 configuration +# This script restores a dhcp4 server configuration, to prevent +# kea startup failures after random board hangs or powercuts. +# + +case "$1" in + start) + ret=$(keactrl status | grep -i "dhcpv4 server" | cut -d ' ' -f 3) + if [ "$ret" = "active" ]; then + echo "WARNING: cowardly refusing to replace dhcp4 configuration" + echo "kea dhcp4 server is up and running!" + else + echo "Resetting kea dhcp4 configuration." + cp -f /etc/kea/kea-dhcp4.conf.original /etc/kea/kea-dhcp4.conf + fi + ;; + status|stop|reload|force-reload|restart) + true + ;; + *) + # do not advertise unreasonable commands that there is no reason + # to use with this device + echo $"Usage: $0 {start|stop|status|restart|force-reload}" + exit 1 +esac + +exit $? diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/kea-subnet4.json b/meta-arm-autonomy/recipes-extended/xenguest/files/kea-subnet4.json new file mode 100644 index 00000000..9dacbb1b --- /dev/null +++ b/meta-arm-autonomy/recipes-extended/xenguest/files/kea-subnet4.json @@ -0,0 +1,35 @@ +# This file holds the guest kea dhcp4 server options running on Dom0. +# The "/etc/xen/scripts/vif-post.d/00-vif-xenguest.hook" called in the end of +# the vif-nat script will use this file to generate the final dhcp +# configuration. + +# This file is added in the xenguest image and installed in dom0 under +# /etc/xenguest/guests/${guestname}/files/kea-subnet4.json when the guest +# image is created. +# Any customizations to it should be performed by replacing it via a bbappend. + +# The \${vif_ip} and \${router_ip} variables are set in +# the vif-nat script context. The \${subnetprefix} and \${mac} variable are set in the +# 00-vif-xenguest.hook script context. + +# The "subnet" configuration node is mandatory in order to have the dhcp +# properly running. + { + \"subnet\": \"${subnetprefix}.0/24\", + \"option-data\": [ + { + \"name\": \"routers\", + \"data\": \"${router_ip}\" + }, + { + \"name\": \"domain-name-servers\", + \"data\": \"8.8.8.8, 8.8.4.4\" + } + ], + \"reservations\": [ + { + \"hw-address\": \"${mac}\", + \"ip-address\": \"${vif_ip}\" + } + ] + }, diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/logrotate-xenguest b/meta-arm-autonomy/recipes-extended/xenguest/files/logrotate-xenguest new file mode 100644 index 00000000..fefc3476 --- /dev/null +++ b/meta-arm-autonomy/recipes-extended/xenguest/files/logrotate-xenguest @@ -0,0 +1,6 @@ +/var/log/xenguest { + missingok + size 10k + copytruncate + rotate 2 +} diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/network-bridge.sh.in b/meta-arm-autonomy/recipes-extended/xenguest/files/network-bridge.sh.in index 752f4987..3f87b76e 100755 --- a/meta-arm-autonomy/recipes-extended/xenguest/files/network-bridge.sh.in +++ b/meta-arm-autonomy/recipes-extended/xenguest/files/network-bridge.sh.in @@ -1,32 +1,23 @@ #!/bin/sh # This script is setting up a virtual network interface connected to the # xenguest-network-bridge if NETWORK_BRIDGE is set to 1 in the guest params - -guestname="${1}" +# +# Since this script is sourced by xenguest-manager, it can access variables +# such as ${guestname} from the parent file's scope, as well as those in +# params.cfg, for example XENGUEST_NETWORK_TYPE BRIDGE_NAME="###BRIDGE_NAME###" -# get guest parameters -. ./params.cfg - -case "${XENGUEST_NETWORK_TYPE:-}" in +case "${XENGUEST_NETWORK_TYPE:=}" in nat) - # Create the symlinks for the files that vif-nat script expects - if [ ! -f /etc/dhcpd.conf ]; then - ln -s dhcp/dhcpd.conf /etc/dhcpd.conf - fi - if [ ! -f /etc/init.d/dhcp3-server ]; then - ln -s dhcp-server /etc/init.d/dhcp3-server - fi - if [ ! -f /etc/default/dhcp3-server ]; then - ln -s dhcp-server /etc/default/dhcp3-server - fi - echo "vif = ['script=vif-nat']" >> ${guestname}.cfg + echo "vif = ['script=vif-nat']" >> ${guestcfgfile} + log info "Network type is NAT" ;; bridge) - echo "vif = ['script=vif-bridge,bridge=${BRIDGE_NAME}']" >> ${guestname}.cfg + echo "vif = ['script=vif-bridge,bridge=${BRIDGE_NAME}']" >> ${guestcfgfile} + log info "Network type is bridge: ${BRIDGE_NAME}" ;; *) - echo "${@}: XENGUEST_NETWORK_TYPE=$XENGUEST_NETWORK_TYPE invalid" + log error "XENGUEST_NETWORK_TYPE=$XENGUEST_NETWORK_TYPE invalid" ;; esac diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-init b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-init index cd249cfd..c6b0c836 100755 --- a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-init +++ b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-init @@ -65,8 +65,10 @@ case "$1" in ;; stop) echo "Stopping xenguest" + # update guest list + guestlist=$(xenguest-manager status | grep Running | cut -d ":" -f1) for f in ${guestlist}; do - /usr/bin/xenguest-manager stop ${f} + xenguest-manager shutdown ${f} --kill done ;; reload) diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager index d55c9ffe..7e5f8685 100755 --- a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager +++ b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager @@ -7,21 +7,179 @@ this="$0" XENGUEST_CONF_BASE="/etc/xenguest" LOGFILE="/var/log/xenguest" +# Valid values for log level +LOG_LEVEL_VALID="FATAL ERROR INFO VERBOSE" + +# Log levels being written to logfile +LOG_LEVEL_LIST="ERROR INFO VERBOSE" +# Affected by -v(v) param and conf file + +# Log levels being written to terminal +VERBOSE_LOG_LEVEL="ERROR" +# Constant + +# Highest Log Level: Default is ERROR only +LOG_LEVEL="ERROR" +# Used to update LOG_LEVEL_LIST + + +# This should only be called from either log() or log_command. +# It expectd $loglevel and $text to already be in scope +function log_to_file () +{ + if [[ ${LOG_LEVEL_LIST} = *${loglevel}* ]]; then + tstamp="$(date +"%d-%m-%Y %T")" + tag="[${loglevel}]" + + printf "%s %-9s %s\n" "$tstamp" "$tag" "$text" >> ${LOGFILE} + fi +} + +# Write a log to the logfile, and to the console +# Messages are written to the log with the date and a timestamp +function log () +{ + # Inputs: + # $1 - optional level to log at, one of ${LOG_LEVEL_VALID} + # Default: INFO + # $@ - log message body + + # get loglevel from parameter and capitalise + loglevel=${1^^} + + # If no loglevel is passed use INFO + if [[ ${LOG_LEVEL_VALID} = *${loglevel:-INVALID}* ]]; then + shift + else + loglevel="INFO" + fi + + # Kill script immediately after a fatal log + killscript=0 + if [ "FATAL" = ${loglevel} ]; then + killscript=1 + # Log at error level for the user + loglevel="ERROR" + fi + + text="$*" + log_to_file + + # Write to terminal if level is high enough + if [[ ${VERBOSE_LOG_LEVEL} = *${loglevel}* ]]; then + echo "${loglevel}: ${text}" + fi + + # if Log was fatal, kill the script + if [[ ${killscript} = 1 ]]; then + exit 1 + fi +} + +# Write a shell command to the log and execute it +# The stdout and stderr output of the command is captured in a variable, +# and written to the logfile in two cases: +# 1. The script is in verbose mode +# 2. The command returns a non-zero status AND +# The loglevel parameter (default: ERROR) is in $LOG_LEVEL_LIST +# +# This means by default a non-zero status results in a log tagged [ERROR], +# but if a command is expected to fail, the tag can be reduced for visual +# clarity +log_command () +{ + # Inputs: + # $1 - optional level to write errors at, one of ${LOG_LEVEL_VALID} + # Default: ERROR + # $@ - command to execute + + # get loglevel from parameter and capitalise + loglevel=${1^^} + + # If no level passed, log output on failure at ERROR + if [[ ${LOG_LEVEL_VALID} = *"${loglevel:-INVALID}"* ]]; then + shift + else + loglevel="ERROR" + fi + + # Commands cannot be logged at FATAL. + if [ "FATAL" = ${loglevel} ]; then + loglevel="ERROR" + fi + local command="$*" + local output="" + local status=0 + + # Capture stdout and sterr to write to logfile + output=$(eval "${command} 2>&1") + status=$? + # If command failed, or verbose mode, write log + if [[ ${status} -ne 0 ]] || [[ ${LOG_LEVEL_LIST} = *VERBOSE* ]]; then + + # if command didn't fail write it at verbose level + if [[ ${status} -eq 0 ]]; then + loglevel="VERBOSE" + fi + # otherwise write it at ${loglevel} from arguments + + local append_to="/dev/null" + # If we are writing ${loglevel} logs to file, use file as append_to + if [[ ${LOG_LEVEL_LIST} = *${loglevel}* ]]; then + append_to=${LOGFILE} + fi + + # Log that command was called + text="> ${command}" + log_to_file + + # Write command output to logfile or /dev/null, indent to match rest of logs + if [[ -n ${output} ]]; then + echo "${output}" | sed 's/^/ /' >> ${append_to} + fi + # Log exit status + text="< Exited with status ${status}" + log_to_file + fi + # Ensure return status is captured + return $status +} + +# Sources a shell script and logs it +log_source () +{ + local script=${1} + log verbose "> source ${script}" + + ( . ${script} ) + + status=$? + log verbose "< Exited with status ${status}" + + return $status +} + if [ ! -f ${XENGUEST_CONF_BASE}/xenguest-manager.conf ]; then - echo "Cannot find xenguest manager configuration" - exit 1 + log fatal "Cannot find xenguest manager configuration" fi # Following variables must be set in configuration: # XENGUEST_VOLUME_DEVICE: device to use for lvm # XENGUEST_VOLUME_NAME: lvm volume name to create on device +# Optionally set: +# XENGUEST_LOG_LEVEL: the loglevel for terminal and logfile source ${XENGUEST_CONF_BASE}/xenguest-manager.conf -PREF="xenguest:" +# Check that VERBOSE level from config file is valid +if [[ ${LOG_LEVEL_LIST} = *${XENGUEST_LOG_LEVEL}* ]]; then + LOG_LEVEL=${XENGUEST_LOG_LEVEL} +else + log error "Invalid log level '${XENGUEST_LOG_LEVEL}' found in xenguest-manager.conf" +fi function usage() { cat < '1000M' +check_size() { + local disksize="${1}" + + [ -n "${disksize}" ] || disksize="invalid" + + # disksize may have appended M or G suffix, let's extract it + # ${var:offset:length}, where #var is var length + local lastchar="${disksize:${#disksize}-1}" + case "${lastchar}" in + [0-9]) + # backwards compatibility + is_integer "${disksize}" + echo -e "$((${disksize} * 1000))M" + return + ;; + G|M) + if [ "${#disksize}" -gt "1" ]; then + local size="${disksize::${#disksize}-1}" + is_integer "${size}" + # convert GB to MB + [ "${lastchar}" = "M" ] || size=$((${size} * 1000)) + echo -e "${size}M" + return + fi + ;; + *) + ;; + esac + + log fatal "Invalid size format '${1}'. Supported size format is e.g 1000M or 2[G]" +} + +# Private +function xenguest_volume_init() +{ + # Inputs: + # $1 - diskdevice + # $2 - volumename + # + # Outputs: + # 0 - success + # 1 - failure + + local diskdevice + local volumename + + diskdevice="${1}" + volumename="${2}" + + log info "Attempting to initialise xenguest volume '${volumename}'" + + check_private + + if [ -z "${diskdevice}" -o ! -b "${diskdevice}" ]; then + log error "Invalid volume device in configuration: '${diskdevice}'" return 1 fi - if [ -z "${XENGUEST_VOLUME_NAME:-}" ]; then - echo "${PREF} No volume name in configuration, using vg-xen..." - XENGUEST_VOLUME_NAME="vg-xen" + if [ -z "${volumename}" ]; then + log error "Invalid volume name in configuration: '${volumename}'" + return 1 fi - pvs ${XENGUEST_VOLUME_DEVICE} > /dev/null 2>&1 + log_command verbose "pvs ${diskdevice}" if [ $? -ne 0 ]; then # Check if there is no filesystem in the block device - echo "lsblk -n -o FSTYPE ${XENGUEST_VOLUME_DEVICE}" >> ${LOGFILE} 2>&1 - filesystem=$(lsblk -n -o FSTYPE ${XENGUEST_VOLUME_DEVICE} 2>> ${LOGFILE}) + log verbose "Checking for existing filesystem" + filesystem=$(lsblk -n -o FSTYPE ${diskdevice}) if [[ $? -eq 0 && -z "$filesystem" ]]; then - echo "${PREF} Initialize lvm on ${XENGUEST_VOLUME_DEVICE}" - echo "pvcreate -f ${XENGUEST_VOLUME_DEVICE}" >> ${LOGFILE} 2>&1 - pvcreate -f ${XENGUEST_VOLUME_DEVICE} >> ${LOGFILE} 2>&1 + log verbose "No filesystem found" + log info "Initializing lvm on ${diskdevice}" + log_command "pvcreate -f ${diskdevice}" if [ $? -ne 0 ]; then - echo "${PREF} Error: initialing lvm on " \ - "${XENGUEST_VOLUME_DEVICE} failed." | tee -a ${LOGFILE} + log error "Initialing lvm on ${diskdevice} failed." return 1 fi else [ -z "$filesystem" ] || \ - echo "${PREF} Error: The ${XENGUEST_VOLUME_DEVICE} is already " \ - "formatted as $filesystem." | tee -a ${LOGFILE} + log error "${diskdevice} is already formatted as $filesystem." return 1 fi fi - vgs ${XENGUEST_VOLUME_NAME} > /dev/null 2>&1 + log_command verbose "vgs ${volumename}" if [ $? -ne 0 ]; then - echo "${PREF} Create ${XENGUEST_VOLUME_NAME} volume" - echo "vgcreate ${XENGUEST_VOLUME_NAME} ${XENGUEST_VOLUME_DEVICE}" \ - >> ${LOGFILE} 2>&1 - vgcreate ${XENGUEST_VOLUME_NAME} ${XENGUEST_VOLUME_DEVICE} \ - >> ${LOGFILE} 2>&1 + log info "Creating ${volumename} volume" + log_command "vgcreate ${volumename} ${diskdevice}" if [ $? -ne 0 ]; then - echo "${PREF} Error: creating ${XENGUEST_VOLUME_NAME} volume " \ - "failed." | tee -a ${LOGFILE} + log error "Creating ${volumename} volume failed." return 1 fi fi + log info "xenguest volume '${volumename}' initialised successfully" + return 0 } +# Private # Detach a disk we attached to xen function xenguest_detach_disk() { - echo "xl block-detach 0 \$\(xl block-list 0 | " \ - "grep \"domain/0\" | awk '{print \$1}'\)" \ - >> ${LOGFILE} 2>&1 - xl block-detach 0 $(xl block-list 0 | \ - grep "domain/0" | awk '{print $1}') \ - >> ${LOGFILE} 2>&1 + log verbose "Attempting to detach partition '${part}'" + + check_private + + log_command "xl block-detach 0 \$(xl block-list 0 | grep \"domain/0\" | awk '{print \$1}')" if [ $? -ne 0 ]; then - echo "${PREF} Error detaching partition ${part}" + log error "Detaching partition '${part}' failed." return 1 fi + + log verbose "Partition '${part}' detached successfully" } +#Private +function xenguest_volume_remove() +{ + # Inputs: + # $1 - volumename + # $2 - guestname + + local volumename + local guestname + + volumename="${1}" + guestname="${2}" + + devname="/dev/${volumename}/${guestname}" + + # Remove volume if it exists + log verbose "Checking for volume ${devname}" + log_command verbose "lvs ${volumename}/${guestname}" + if [ $? -eq 0 ]; then + log info "Removing volume ${devname}" + log_command "lvremove -y ${devname}" + if [ $? -ne 0 ]; then + log error "Removing volume ${devname} failed." + return 1 + else + log verbose "Volume ${devname} removed successfully" + return 0 + fi + fi + + log verbose "Volume ${devname} not found" +} + +# Private function xenguest_disk_init() { # Inputs: @@ -138,64 +407,71 @@ function xenguest_disk_init() guestname="$1" guestfile="$2" - devname="/dev/${XENGUEST_VOLUME_NAME}/${guestname}" + + log info "Attempting to initialise disk for guest '${guestname}'" + + check_private source ${XENGUEST_CONF_BASE}/guests/${guestname}/disk.cfg + if [ -z "${DISK_DEVICE}" ]; then + log info "Using disk device and volume name from xenguest-manager.conf" + # By default guest is using disk defined inside xenguest-manager.conf + diskdevice="${XENGUEST_VOLUME_DEVICE}" + volumename="${XENGUEST_VOLUME_NAME}" + else + log info "Using disk device set in disk.cfg" + # If guest configuration contains custom disk setting, + # overwrite default one + diskdevice="${DISK_DEVICE}" + volumename="vg-xen-$(basename ${diskdevice})" + fi - if [ ${DISK_SIZE:-0} -eq 0 ]; then - echo "${PREF} No disk for ${guestname}" + log verbose "Disk Device = ${diskdevice}" + log verbose "Volume Name = ${volumename}" + + devname="/dev/${volumename}/${guestname}" + + DISK_SIZE=$(check_size "${DISK_SIZE}") + if [ -z "${DISK_SIZE}" ] || [ "${DISK_SIZE}" = "0M" ]; then + log info "No disk for ${guestname}" return fi - echo "${PREF} Create ${guestname} disk." - # Init our volume - xenguest_volume_init ${guestname} + xenguest_volume_init "${diskdevice}" "${volumename}" if [ $? -ne 0 ]; then return 1 fi - echo "${PREF} Create hard drive for ${guestname}." \ - "This might take a while..." - + log info "Creating hard drive for guest '${guestname}'. This might take a while..." # Remove volume if it already exist - echo "lvs ${XENGUEST_VOLUME_NAME}/${guestname}" >> ${LOGFILE} 2>&1 - lvs ${XENGUEST_VOLUME_NAME}/${guestname} >> ${LOGFILE} 2>&1 - if [ $? -eq 0 ]; then - echo "lvremove -y ${devname}" >> ${LOGFILE} 2>&1 - lvremove -y ${devname} >> ${LOGFILE} 2>&1 - if [ $? -ne 0 ]; then - echo "${PREF} Error removing volume ${guestname}" - return 1 - fi + xenguest_volume_remove ${volumename} ${guestname} + if [ $? -ne 0 ]; then + return 1 fi # Create volume - echo "lvcreate -y -L ${DISK_SIZE}G -n ${guestname} ${XENGUEST_VOLUME_NAME}" \ - >> ${LOGFILE} 2>&1 - lvcreate -y -L ${DISK_SIZE}G -n ${guestname} ${XENGUEST_VOLUME_NAME} \ - >> ${LOGFILE} 2>&1 + log info "Creating volume '${volumename}/${guestname}'" + log_command "lvcreate -y -L ${DISK_SIZE} -n ${guestname} ${volumename}" if [ $? -ne 0 ]; then - echo "${PREF} Error creating volume ${guestname}" + log error "Creating volume '${volumename}/${guestname}' failed." return 1 fi # Add partition table - echo "parted -s ${devname} mklabel msdos" >> ${LOGFILE} 2>&1 - parted -s ${devname} mklabel msdos >> ${LOGFILE} 2>&1 + log verbose "Creating partition table on ${devname}" + log_command "parted -s \"${devname}\" mklabel msdos" if [ $? -ne 0 ]; then - echo "${PREF} Error creating partition table on ${guestname}" + log error "Creating partition table on ${devname} failed." return 1 fi # Setup disk name in xen configuration - echo "xenguest-mkimage update ${XENGUEST_CONF_BASE}/guests/${guestname}" \ - "--xen-disk=${devname}" >> ${LOGFILE} 2>&1 - xenguest-mkimage update ${XENGUEST_CONF_BASE}/guests/${guestname} \ - --xen-disk=${devname} >> ${LOGFILE} 2>&1 + log verbose "Setting disk name in xen configuration" + log_command "xenguest-mkimage update \"${XENGUEST_CONF_BASE}/guests/${guestname}\" --xen-disk=\"${devname}\"" if [ $? -ne 0 ]; then - echo "${PREF} Error setting disk in xen configuration" + log error "Setting disk name in xen configuration failed." return 1 fi @@ -206,15 +482,37 @@ function xenguest_disk_init() # with a : separated list defining the partition: # DISK_PART3="4:ext4:disk.tgz" means that partition 3 should be 4G formated # with ext4 and initialized with the content of disk.tgz - for part in $(seq 1 4); do - eval partdesc="\${DISK_PART${part}:-0}" + # Keep user defined partition order, + # even if previous partitions are not defined. + # Create 2MB partitions in this case + lastpart="0" + for partidx in $(seq 1 4); do + local _part="DISK_PART${partidx}" + if [ -n "${!_part:=}" ]; then + lastpart="${partidx}" + fi + done + + if [ "${lastpart}" -eq "0" ]; then + # Nothing to be added here + # No partition definition found + return + fi + + for part in $(seq 1 "${lastpart}"); do + eval partdesc="\${DISK_PART${part}:=}" size=$(echo ${partdesc} | sed -e "s/\(.*\):.*:.*/\1/") fstype=$(echo ${partdesc} | sed -e "s/.*:\(.*\):.*/\1/") content=$(echo ${partdesc} | sed -e "s/.*:.*:\(.*\)/\1/") - if [ "${size}" -ne 0 ]; then - # Size is expressed in GB, pass it in MB - size=$(expr ${size} \* 1024) + local _part="DISK_PART${part}" + [ -n "${!_part:=}" ] || size="2M" + + size=$(check_size "${size}") + if [ -n "${size}" ] && [ "${size}" != "0M" ]; then + # size has appended M or G suffix, let's extract just the value + # ${var:offset:length}, where #var is var length + size="${size::${#size}-1}" partend=$(expr ${partstart} + ${size}) # Let first MB of disk free for partition table @@ -223,12 +521,10 @@ function xenguest_disk_init() fi # Create partition - echo "parted -s ${devname} unit MB mkpart primary ${partstart}" \ - "${partend}" >> ${LOGFILE} 2>&1 - parted -s ${devname} unit MB mkpart primary ${partstart} \ - ${partend} >> ${LOGFILE} 2>&1 + log verbose "Adding partition ${part}" + log_command "parted -s \"${devname}\" unit MB mkpart primary \"${partstart}\" \"${partend}\"" if [ $? -ne 0 ]; then - echo "${PREF} Error adding partition ${part}" + log error "Adding partition ${part} failed." return 1 fi @@ -236,8 +532,8 @@ function xenguest_disk_init() partstart="${partend}" # Sync to see the created partition - echo "sync" >> ${LOGFILE} 2>&1 - sync >> ${LOGFILE} 2>&1 + log verbose "Sync created partition" + log_command "sync" # Prepare format command if [ -n "${fstype}" ]; then @@ -249,8 +545,7 @@ function xenguest_disk_init() formatcmd="mkswap" ;; *) - echo "${PREF} partition ${part} of ${guestname}" \ - "fstype is invalid: ${fstype}" + log error "Partition ${part} of ${guestname} fstype is invalid '${fstype}'" return 1 ;; esac @@ -259,10 +554,10 @@ function xenguest_disk_init() fi # Attach disk to xen - echo "xl block-attach 0 phy:${devname} xvda w" >> ${LOGFILE} 2>&1 - xl block-attach 0 phy:${devname} xvda w >> ${LOGFILE} 2>&1 + log verbose "Attaching partition ${part}" + log_command "xl block-attach 0 \"phy:${devname}\" xvda w" if [ $? -ne 0 ]; then - echo "${PREF} Error attaching partition ${part}" + log error "Attaching partition ${part} failed." return 1 fi @@ -278,15 +573,17 @@ function xenguest_disk_init() done if [ ! -b /dev/xvda${part} ]; then - echo "${PREF} Partition ${part} creation error" + log error "Partition ${part} creation failed." return 2 fi + log verbose "/dev/xvda${part} created" + if [ -n "${formatcmd}" ]; then - echo "${formatcmd} /dev/xvda${part}" >> ${LOGFILE} 2>&1 - ${formatcmd} /dev/xvda${part} + log info "Creating filesystem for partition '${part}'" + log_command "${formatcmd} /dev/xvda${part}" if [ $? -ne 0 ]; then - echo "${PREF} Cannot create partition ${part} FS" + log error "Creating filesystem for partition '${part}' failed." return 2 fi fi @@ -306,17 +603,15 @@ function xenguest_disk_init() ;; *) # invalid/unknown compression type - echo "${PREF} Invalid file format in disk ${content}" + log error "Invalid file format in disk ${content}" return 2 ;; esac # dd into partition - echo "xenguest-mkimage extract-disk-file ${guestfile} " \ - "${content} | ${decompress} | dd of=/dev/xvda${part} " >> ${LOGFILE} 2>&1 - xenguest-mkimage extract-disk-file ${guestfile} ${content} \ - | ${decompress} | dd of=/dev/xvda${part} >> ${LOGFILE} 2>&1 + log verbose "Populating partition '${part}'" + log_command "xenguest-mkimage extract-disk-file ${guestfile} ${content} | ${decompress} | dd of=/dev/xvda${part} " if [ $? -ne 0 ]; then - echo "${PREF} Cannot populate partition ${part}" + log error "Populating partition '${part}' failed." return 2 fi ;; @@ -337,37 +632,33 @@ function xenguest_disk_init() ;; *) # invalid/unknown tar type - echo "${PREF} Invalid file format in disk ${content}" + log error "Invalid file format in disk ${content}" return 2 ;; esac # must mount the partition and extract mntdir=$(mktemp -d) - echo "mount /dev/xvda${part} ${mntdir}" >> ${LOGFILE} 2>&1 - mount /dev/xvda${part} ${mntdir} >> ${LOGFILE} 2>&1 + log verbose "Mounting partition '${part}'" + log_command "mount /dev/xvda${part} ${mntdir}" if [ $? -ne 0 ]; then - echo "${PREF} Cannot mount partition ${part}" + log error "Mounting partition '${part}' failed." rm -rf ${mntdir} return 2 fi # tar and unmount - echo "xenguest-mkimage extract-disk-file ${guestfile}" \ - "${content} | tar -C ${mntdir} -x${tararg}f - " \ - >> ${LOGFILE} 2>&1 - xenguest-mkimage extract-disk-file ${guestfile} ${content} \ - | tar -C ${mntdir} -x${tararg}f - >> ${LOGFILE} 2>&1 + log_command "xenguest-mkimage extract-disk-file ${guestfile} ${content} |" \ + "tar -C ${mntdir} -x${tararg}f - " if [ $? -ne 0 ]; then - echo "${PREF} Cannot populate partition ${part}" + log error "Cannot populate partition ${part}" umount ${mntdir} rm -rf ${mntdir} return 2 fi - echo "umount ${mntdir}" >> ${LOGFILE} 2>&1 - umount ${mntdir} >> ${LOGFILE} 2>&1 + log_command "umount ${mntdir}" if [ $? -ne 0 ]; then - echo "${PREF} Error unmounting ${part}" + log error "Unmounting ${part} failed." rm -rf ${mntdir} return 2 fi @@ -386,39 +677,42 @@ function xenguest_disk_init() fi done + log info "Initialised disk for guest '${guestname}' successfully" + } +# Private function xenguest_guest_create() { - guestfile="$1" - guestname="$2" - # extract xenguest tar # put xen config in etc ? # if disk config file: # disk init # add partititions - echo "${PREF} Create ${guestname} using ${guestfile}" - rm -rf ${XENGUEST_CONF_BASE}/guests/${guestname} - mkdir -p ${XENGUEST_CONF_BASE}/guests/${guestname} + guestfile="$1" + guestname="$2" - echo "xenguest-mkimage extract-config ${guestfile}" \ - "${XENGUEST_CONF_BASE}/guests/${guestname}" >> ${LOGFILE} 2>&1 - xenguest-mkimage extract-config ${guestfile} \ - ${XENGUEST_CONF_BASE}/guests/${guestname} >> ${LOGFILE} 2>&1 + log info "Attempting to create guest '${guestname}' using ${guestfile}" + + check_private + + log verbose "Cleaning up old directory" + log_command verbose "rm -rf ${XENGUEST_CONF_BASE}/guests/${guestname}" + log verbose "Creating directory for guest '${guestname}'" + log_command "mkdir -p ${XENGUEST_CONF_BASE}/guests/${guestname}" + + log verbose "Extracting guest image" + log_command "xenguest-mkimage extract-config ${guestfile} ${XENGUEST_CONF_BASE}/guests/${guestname}" if [ $? -ne 0 ]; then - echo "${PREF} Error extracting guest image" - exit 1 + log fatal "Extracting guest image failed." fi # Set guest name inside config - echo "xenguest-mkimage update ${XENGUEST_CONF_BASE}/guests/${guestname}" \ - "--xen-name=${guestname}" >> ${LOGFILE} 2>&1 - xenguest-mkimage update ${XENGUEST_CONF_BASE}/guests/${guestname} \ - --xen-name=${guestname} >> ${LOGFILE} 2>&1 + log verbose "Setting guest name" + log_command "xenguest-mkimage update ${XENGUEST_CONF_BASE}/guests/${guestname} --xen-name=${guestname}" if [ $? -ne 0 ]; then - echo "${PREF} Error setting guest name" + log error "Setting guest name failed." xenguest_guest_remove ${guestname} exit 1 fi @@ -426,7 +720,7 @@ function xenguest_guest_create() xenguest_disk_init ${guestname} ${guestfile} disk_init_status=$? if [ $disk_init_status -ne 0 ]; then - echo "${PREF} Error: ${guestname} disk creation failed." + log error "Disk creation for guest '${guestname}' failed." if [ $disk_init_status -eq 2 ]; then xenguest_detach_disk fi @@ -434,169 +728,293 @@ function xenguest_guest_create() exit 1 fi + log info "Guest '${guestname}' created successfully" + } +# Private function xenguest_guest_remove() { guestname="$1" - devname="/dev/${XENGUEST_VOLUME_NAME}/${guestname}" + log info "Attempting to remove guest '${guestname}'" - # check if guest had a volume - echo "lvs ${XENGUEST_VOLUME_NAME}/${guestname}" >> ${LOGFILE} 2>&1 - lvs ${XENGUEST_VOLUME_NAME}/${guestname} >> ${LOGFILE} 2>&1 - if [ $? -eq 0 ]; then - # Remove guest volume - echo "${PREF} Removing ${guestname} volume. This might take a while..." - echo "lvremove -y ${devname}" >> ${LOGFILE} 2>&1 - lvremove -y ${devname} >> ${LOGFILE} 2>&1 - if [ $? -ne 0 ]; then - echo "${PREF} Error removing volume ${guestname}" - exit 1 - fi + check_private + + source ${XENGUEST_CONF_BASE}/guests/${guestname}/disk.cfg + if [ -z "${DISK_DEVICE}" ]; then + # By default guest is using disk defined inside xenguest-manager.conf + diskdevice="${XENGUEST_VOLUME_DEVICE}" + volumename="${XENGUEST_VOLUME_NAME}" + else + # If guest configuration contains custom disk setting, + # overwrite default one + diskdevice="${DISK_DEVICE}" + volumename="vg-xen-$(basename ${diskdevice})" fi + devname="/dev/${volumename}/${guestname}" + + # find and remove guest volume + xenguest_volume_remove ${volumename} ${guestname} + status=$? # remove guest files - echo "${PREF} Removing ${guestname} configuration files." - rm -rf ${XENGUEST_CONF_BASE}/guests/${guestname} + log info "Removing configuration files for guest '${guestname}'." + log_command "rm -rf ${XENGUEST_CONF_BASE}/guests/${guestname}" + + if [ ${status} -ne 0 ]; then + # Shouldn't log success message if volume removal fails + exit 1 + fi + + log info "Removed guest '${guestname}' successfully" } +# Private +function xenguest_call_inits() +{ + # Inputs: + # $1 - script directory + + local scriptdir + local guestdir + local guestcfgfile + local guestname + + scriptdir="${1}" + guestdir="${2}" + guestcfgfile="${3}" + guestname="${4}" + + log "Attempting to call all init scripts in ${scriptdir}" + + check_private + + + init_scripts="$(find ${XENGUEST_CONF_BASE}/${scriptdir} -type f 2> /dev/null | \ + sort) $(find ${guestdir}/${scriptdir} -type f 2> /dev/null | sort)" + for f in ${init_scripts}; do + if [ -x "$f" ]; then + log_source $f + if [ $? -ne 0 ]; then + rm -f ${guestcfgfile} + popd > /dev/null 2>&1 + log fatal "Error during init script $(basename $f) of ${guestname}" + fi + else + log fatal "$f is not executable. Exiting..." + fi + done + + if [ "${init_scripts}" = " " ]; then + log "No scripts found" + else + log "All init scripts in ${scriptdir} completed successfully" + fi +} + +# Private function xenguest_guest_start() { guestname="${1}" guestdir=${XENGUEST_CONF_BASE}/guests/${guestname} + log info "Attempting to start guest '${guestname}'" + + check_private + + guestcfgfile=$(mktemp -u "${guestname}.XXXXXX" --tmpdir="${guestdir}" --suffix=".cfg") + # Get guest configuration source ${guestdir}/params.cfg pushd ${guestdir} > /dev/null 2>&1 # create config by merging all configurations together - cat guest.cfg $(find guest.d -type f 2> /dev/null) > ${guestname}.cfg + cat guest.cfg $(find guest.d -type f 2> /dev/null) > ${guestcfgfile} # Build init script lists (ignore non existing dirs errors, # sort alphabetically and run global scripts first) - init_pre="$(find ${XENGUEST_CONF_BASE}/init.pre -type f 2> /dev/null | \ - sort) $(find ${guestdir}/init.pre -type f 2> /dev/null | sort)" - init_d="$(find ${XENGUEST_CONF_BASE}/init.d -type f 2> /dev/null | \ - sort) $(find ${guestdir}/init.d -type f 2> /dev/null | sort)" - init_post="$(find ${XENGUEST_CONF_BASE}/init.post -type f 2> /dev/null | \ - sort) $(find ${guestdir}/init.post -type f 2> /dev/null | sort)" + # + # These scripts are sourced throughout the start operation if they + # are executable + init_pre="init.pre" + init_d="init.d" + init_post="init.post" # call pre init scripts - for f in ${init_pre}; do - echo "$f ${guestname}" >> ${LOGFILE} 2>&1 - $f ${guestname} >> ${LOGFILE} 2>&1 - if [ $? -ne 0 ]; then - rm -f ${guestname}.cfg - popd > /dev/null 2>&1 - echo "${PREF} Error during pre init script of ${guestname}" - exit 1 - fi - done + xenguest_call_inits "${init_pre}" "${guestdir}" "${guestcfgfile}" "${guestname}" # Create non started guest - echo "xl create -p ${guestname}.cfg" >> ${LOGFILE} 2>&1 - xl create -p ${guestname}.cfg >> ${LOGFILE} 2>&1 + log verbose "Initiating ${guestname}" + log_command "xl create -p ${guestcfgfile}" if [ $? -ne 0 ]; then - rm -f ${guestname}.cfg + rm -f ${guestcfgfile} popd > /dev/null 2>&1 - echo "${PREF} Error starting ${guestname}" - exit 1 + log fatal "Initiating ${guestname} failed." fi # call init scripts - for f in ${init_d}; do - echo "$f ${guestname}" >> ${LOGFILE} 2>&1 - $f ${guestname} >> ${LOGFILE} 2>&1 - if [ $? -ne 0 ]; then - rm -f ${guestname}.cfg - echo "xl destroy ${guestname}" >> ${LOGFILE} 2>&1 - xl destroy ${guestname} >> ${LOGFILE} 2>&1 - popd > /dev/null 2>&1 - echo "${PREF} Error during init script of ${guestname}" - exit 1 - fi - done + xenguest_call_inits "${init_d}" "${guestdir}" "${guestcfgfile}" "${guestname}" # Start guest - echo "xl unpause ${guestname}" >> ${LOGFILE} 2>&1 - xl unpause ${guestname} >> ${LOGFILE} 2>&1 + log info "Starting ${guestname}" + log_command "xl unpause ${guestname}" if [ $? -ne 0 ]; then - rm -f ${guestname}.cfg + rm -f ${guestcfgfile} popd > /dev/null 2>&1 - echo "${PREF} Error starting ${guestname}" - exit 1 + log fatal "Starting ${guestname} failed." fi # call post init scripts - for f in ${init_post}; do - echo "$f ${guestname}" >> ${LOGFILE} 2>&1 - $f ${guestname} >> ${LOGFILE} 2>&1 - if [ $? -ne 0 ]; then - rm -f ${guestname}.cfg - echo "xl destroy ${guestname}" >> ${LOGFILE} 2>&1 - xl destroy ${guestname} >> ${LOGFILE} 2>&1 - popd > /dev/null 2>&1 - echo "${PREF} Error during post init script of ${guestname}" - exit 1 - fi - done + xenguest_call_inits "${init_post}" "${guestdir}" "${guestcfgfile}" "${guestname}" - rm -f ${guestname}.cfg + rm -f ${guestcfgfile} popd > /dev/null 2>&1 + + log info "Guest '${guestname}' started successfully" } +# Private function xenguest_guest_stop() { + local guestname + local extra_arg + guestname="${1}" - echo "xl shutdown ${guestname}" >> ${LOGFILE} 2>&1 - xl shutdown ${guestname} >> ${LOGFILE} 2>&1 + extra_arg="${2}" + + shutdown_args="" + + log info "Attempting to stop guest '${guestname}'" + + if [[ ${extra_arg} != "--nowait" ]]; then + shutdown_args+=" -w" + fi + + check_private + + log_command "xl shutdown ${shutdown_args} ${guestname}" if [ $? -ne 0 ]; then - echo "${PREF} Error stopping ${guestname}" - exit 1 + if [[ ${extra_arg} == "--kill" ]]; then + log info "Stopping '${guestname}' failed, calling kill..." + xenguest_guest_kill "${guestname}" + else + log fatal "Stopping guest '${guestname}' failed." + fi + fi + if [[ "${extra_arg}" != "--nowait" ]]; then + log info "Guest '${guestname}' stopped successfully" + else + log info "xl shutdown exited successfully for guest '${guestname}'." fi } +# Private +function xenguest_guest_kill() +{ + local guestname + + guestname="${1}" + log "Attempting to kill guest '${guestname}'" + + check_private + + log_command "xl destroy ${guestname}" + if [ $? -ne 0 ]; then + log "fatal:Killing guest '${guestname}' failed." + fi + log "Guest '${guestname}' killed successfully" +} + +# Private function check_guest_arg() { + check_private + cmd="${1}" guestname="${2:-}" if [ -z "${guestname:-}" ]; then - echo "${PREF} Usage ${this} ${cmd} GUESTNAME" - exit 1 + log fatal "Usage ${this} ${cmd} GUESTNAME" fi } +# Public function check_guest_exist() { guestname="${1}" if [ ! -f ${XENGUEST_CONF_BASE}/guests/${guestname}/guest.cfg -o \ ! -f ${XENGUEST_CONF_BASE}/guests/${guestname}/params.cfg ]; then - echo "${PREF} Invalid guest name: ${guestname}" - exit 1 + log fatal "Invalid guest name '${guestname}'" + fi + + log verbose "Guest '${guestname}' found: ${XENGUEST_CONF_BASE}/guests/${guestname}/" +} + +# Public +function xenguest_list_guests() +{ + guestlist="" + if [ -d ${XENGUEST_CONF_BASE}/guests ]; then + guestlist=$(find ${XENGUEST_CONF_BASE}/guests -mindepth 1 -maxdepth 1 -type d -exec sh -c 'if [ -f {}/guest.cfg ]; then basename {}; fi' \;) + else + log "Info: Guests directory ${XENGUEST_CONF_BASE}/guests not found" fi } +# Public +function xl_list_contains() +{ + guestname="${1}" + # Select first column of xl list, and find guestname exactly using regex + running=$(xl list | awk 'NR > 1 {print $1}' | grep "^${guestname}$" || echo) + if [ "${running}" = "${guestname}" ]; then + log verbose "Guest '${guestname}' is running" + return 0 + fi + + log verbose "Guest '${guestname}' is not running" + + return 1 +} + +# Public function check_guest_running() { guestname="${1}" - running=$(xl list | awk 'NR > 1 {print $1}' | grep "${guestname}" || echo) - if [ ! "${running}" = "${guestname}" ]; then - echo "${PREF} Guest ${guestname} is not running" - exit 1 + if ! xl_list_contains $guestname; then + log fatal "Cannot ${cmd} guest '${guestname}', already stopped" fi } +# Public function check_guest_not_running() { guestname="${1}" - running=$(xl list | awk 'NR > 1 {print $1}' | grep "${guestname}" || echo) - if [ "${running}" = "${guestname}" ]; then - echo "${PREF} Guest ${guestname} is running" - exit 1 + if xl_list_contains $guestname; then + log fatal "Cannot ${cmd} guest '${guestname}', already started" fi } +## Entry Point ## + +# Check for verbose level arguments, and shift if found +case ${1:-help} in + -v|-V) + LOG_LEVEL="INFO" + shift + ;; + -vv|-VV) + LOG_LEVEL="VERBOSE" + shift + ;; +esac + +# Limit Verbose list to only those desired to be shown +LOG_LEVEL_LIST=${LOG_LEVEL_LIST//${LOG_LEVEL}*/${LOG_LEVEL}} + +log "" +log "Arguments: $*" + cmd="${1:-help}" arg1="${2:-}" arg2="${3:-}" @@ -606,61 +1024,63 @@ case ${cmd} in usage exit 0 ;; - esac # Check if we have a valid Dom0 booted with Xen -ERROR_MSG=$(xl info 2>&1) +log_command "xl info" if [ $? -ne 0 ]; then - echo "ERROR: Xen environment is not valid!!!" | tee -a ${LOGFILE} - echo "ERROR: Check if Xen has booted and the kernel configuration." \ - | tee -a ${LOGFILE} - echo "ERROR: Output from 'xl info' command:" | tee -a ${LOGFILE} - echo "$ERROR_MSG" | tee -a ${LOGFILE} - exit 1 + log error "Xen environment is not valid!!!" + log error "Check if Xen has booted and the kernel configuration." + log fatal "More information in the logfile: ${LOGFILE}" fi case ${cmd} in check-xen) + log verbose "Valid Xen environment found" exit 0 ;; create) guestfile="${arg1}" guestname="${arg2}" - if [ -z "${guestfile}" -o ! -f "${guestfile}" ]; then - echo "${PREF} Usage ${this} create XENGUEST_FILE [NAME]" - exit 1 + # guestfile invalid if empty + if [ -z "${guestfile}" ]; then + log fatal "Usage ${this} create XENGUEST_FILE [NAME]" fi + # Set Guest name before resolving any symlinks if [ -z "${guestname}" ]; then guestname=$(basename ${guestfile} .xenguest) + log info "guestname argument not provided, using '${guestname}'" fi - + # Check for and resolve symlink + if [ -L "${guestfile}" ]; then + errmsg="'${guestfile}' is a broken symlink" + guestfile=$(readlink -e "${guestfile}") + if [ -z "${guestfile}" ]; then + log fatal "${errmsg}" + else + log info "Guestfile symlink resolved to path '${guestfile}'" + fi + fi + # Check that guestfile is a valid file + if [ ! -f "${guestfile}" ]; then + log fatal "File '${guestfile}' not found" + fi + # Check if guest already exists if [ -f ${XENGUEST_CONF_BASE}/guests/${guestname}/guest.cfg ]; then - # Guest already exist - echo "${PREF} A guest ${guestname} already exist" - exit 1 + log fatal "Guest '${guestname}' already exists" fi xenguest_guest_create ${guestfile} ${guestname} - echo "${PREF} ${guestname} created." ;; remove) guestname="${arg1:-}" check_guest_arg ${cmd} ${guestname} check_guest_exist ${guestname} - # We need to stop the guest first - running=$(xl list | awk 'NR > 1 {print $1}' | grep "${guestname}" \ - || echo) - if [ "${running}" = "${guestname}" ]; then - echo "xl destroy ${guestname}" >> ${LOGFILE} 2>&1 - xl destroy ${guestname} >> ${LOGFILE} 2>&1 - if [ $? -ne 0 ]; then - echo "${PREF} Error killing ${guestname}" - exit 1 - fi + # We need to stop the guest first if it is running + if xl_list_contains $guestname; then + xenguest_guest_kill ${guestname} fi xenguest_guest_remove ${guestname} - echo "${PREF} ${guestname} removed." ;; start) guestname="${arg1:-}" @@ -671,55 +1091,49 @@ case ${cmd} in ;; stop|shutdown) guestname="${arg1:-}" + extra_arg="${arg2:-}" check_guest_arg ${cmd} ${guestname} check_guest_exist ${guestname} check_guest_running ${guestname} - xenguest_guest_stop ${guestname} + xenguest_guest_stop "${guestname}" "${extra_arg}" ;; kill|destroy) guestname="${arg1:-}" check_guest_arg ${cmd} ${guestname} check_guest_exist ${guestname} check_guest_running ${guestname} - echo "xl destroy ${guestname}" >> ${LOGFILE} 2>&1 - xl destroy ${guestname} >> ${LOGFILE} 2>&1 - if [ $? -ne 0 ]; then - echo "${PREF} Error killing ${guestname}" - exit 1 - fi + xenguest_guest_kill ${guestname} ;; list) - if [ -d ${XENGUEST_CONF_BASE}/guests ]; then - for f in $(find ${XENGUEST_CONF_BASE}/guests -mindepth 1 \ - -maxdepth 1 -type d -exec basename {} \;); do - if [ -f ${XENGUEST_CONF_BASE}/guests/$f/guest.cfg ]; then - echo "$f" - fi - done - fi + xenguest_list_guests + echo ${guestlist} | tr " " "\n" ;; status) + + single_status() { + guestname="${1}" + check_guest_exist ${guestname} + if xl_list_contains $guestname; then + echo "${guestname} Running" + else + echo "${guestname} Stopped" + fi + } + guestname="${arg1}" if [ -n "${guestname}" ]; then - check_guest_exist ${guestname} - if xl list | awk 'NR > 1 {print $1}' | grep "${guestname}" > \ - /dev/null 2>&1; then - echo "${guestname}: Running" - else - echo "${guestname}: Stopped" - fi + single_status ${guestname} else - guestlist=$($this list) + xenguest_list_guests if [ -n "${guestlist}" ]; then for f in ${guestlist}; do - $this status $f + single_status $f done fi fi ;; *) - echo "${PREF} Invalid argument ${cmd}" - exit 1 + log fatal "Invalid argument: ${cmd}" ;; esac diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-mkimage b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-mkimage index a3f987ae..29e09115 100755 --- a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-mkimage +++ b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-mkimage @@ -110,7 +110,8 @@ Init configuration Disk configuration --disk-reset-config reset disk guest configuration to default (no disk) ---disk-size=SZ set guest disk size (in GB) +--disk-size=SZ set guest disk size in MB or GB(default), + e.g 1000M or 2[G]. --disk-device=DEV set device to be used to create the guest disk if unset or set to an empty string, the volume will be create in the default manager volume group. @@ -127,7 +128,7 @@ Disk configuration --disk-rm-part=ID remove partition ID from the guest disk --disk-add-file=SRC:DST add file SRC as disk file DST in the xenguest image. DST can then be used as a partition CONTENT. ---disk--rm-file=DST remove disk file DST from the xenguest image. +--disk-rm-file=DST remove disk file DST from the xenguest image. EOF } @@ -370,13 +371,159 @@ disk_config_rm_part() { sed -i "/DISK_PART${partid}=.*/d" ${IMAGE_TMPDIR}/disk.cfg } +is_integer() { + if ! [[ "${1}" =~ ^[0-9]+$ ]]; then + >&2 echo "error: invalid number '${1}'"; exit 1 + fi +} + +# check size and convert it to MB, e.g '1[G]' => '1000M' +check_size() { + local disksize="${1}" + + [ -n "${disksize}" ] || disksize="invalid" + + # disksize may have appended M or G suffix, let's extract it + # ${var:offset:length}, where #var is var length + local lastchar="${disksize:${#disksize}-1}" + case "${lastchar}" in + [0-9]) + # backwards compatibility + is_integer "${disksize}" + echo -e "$((${disksize} * 1000))M" + return + ;; + G|M) + if [ "${#disksize}" -gt "1" ]; then + local size="${disksize::${#disksize}-1}" + is_integer "${size}" + # convert GB to MB + [ "${lastchar}" = "M" ] || size=$((${size} * 1000)) + echo -e "${size}M" + return + fi + ;; + *) + ;; + esac + + >&2 echo -e "Invalid size format '${1}'" \ + "\n\tSupported size format is e.g 1000M or 2[G]" + exit 1 +} + +disk_config_get_size() { + disksize=$(echo -e "$( . ${IMAGE_TMPDIR}/disk.cfg && echo $DISK_SIZE)") + check_size "${disksize}" +} + +disk_config_get_parts() { + echo -e "$( . ${IMAGE_TMPDIR}/disk.cfg && \ + typeset -p | awk '$3 ~ /^DISK_PART/ { print $3 }')" +} + +disk_config_get_free_space() { + disk_usage="0" + for partinfo in $(disk_config_get_parts) + do + partsize=$(echo "${partinfo}" | cut -d '"' -f2 | sed -e "s/:.*//") + sizeMB=$(check_size "${partsize}") + [ -n "${sizeMB}" ] || exit 1 + disk_usage=$((${sizeMB::${#sizeMB}-1} + $disk_usage)) + done + + disk_size=$(disk_config_get_size) + echo -e "$((${disk_size::${#disk_size}-1} - ${disk_usage}))M" +} + +disk_check_partition_format() { + local partformat="${1}" + # if partformat is not defined let's skip this check + [ -n "${partformat}" ] || return 0 + + case "${partformat}" in + vfat|ext2|ext3|ext4|swap) + ;; + *) + # invalid/unknown fstype + echo "Invalid file fstype ${partformat}" + exit 1 + ;; + esac +} + +disk_check_partition_content() { + local partcontent="${1}" + # if partcontent is not defined let's skip this check + [ -n "${partcontent}" ] || return 0 + + case "${partcontent}" in + *.img*) + case "${partcontent}" in + *.img.gz|*.img.bz2|*.img) + ;; + *) + # invalid/unknown compression type + echo "Invalid file format in disk ${partcontent}" + exit 1 + ;; + esac + ;; + *.tar*) + case "${partcontent}" in + *.tar.gz|*.tar.bz2|*.tar.xz|*.tar) + ;; + *) + # invalid/unknown tar type + echo "Invalid file format in disk ${partcontent}" + exit 1 + ;; + esac + ;; + *) + #invalid content type + echo "Unsupported content type ${partcontent}!" + exit 1 + ;; + esac + # do not allow to create multiple partitions the same content + if grep ":${partcontent}\"" <<< "$(disk_config_get_parts)"; then + echo "Error ${partcontent} is already inside guest image" + exit 1 + fi +} + disk_config_add_part() { partconf="${1}" partid=$(echo ${partconf} | sed -e "s/:.*//") partinfo=$(echo ${partconf} | sed -e "s/[^:]*://") + partsize=$(echo ${partinfo} | cut -d ":" -f1) + partformat=$(echo ${partinfo} | cut -d ":" -f2) + partcontent=$(echo ${partinfo} | cut -d ":" -f3) + + # check size "ID:*SIZE*:FORMAT:CONTENT" + partsizeMB=$(check_size "${partsize}") # Make sure we don't add the same partition twice - disk_config_rm_part ${partid} + disk_config_rm_part "${partid}" + + # check available disk space + freespace=$(disk_config_get_free_space) + if ((${partsizeMB::${#partsizeMB}-1} > ${freespace::${#freespace}-1})) + then + echo -e "Not enough free disk space(${freespace}) for partition "\ + "'${partconf}'!"\ + "\tTo adjust disk size use '--disk-size' parameter"\ + "\tor shrink the partition with '--disk-add-part' parameter" + exit 1 + fi + + # check format "ID:SIZE:*FORMAT*:CONTENT" + disk_check_partition_format "${partformat}" + + # check content "ID:SIZE:FORMAT:*CONTENT*" + disk_check_partition_content "${partcontent}" + echo "DISK_PART${partid}=\"${partinfo}\"" >> \ ${IMAGE_TMPDIR}/disk.cfg } @@ -742,11 +889,13 @@ for arg in "${@}"; do disk_config_reset ;; --disk-size=*) - sed -i "s/DISK_SIZE=.*/DISK_SIZE=\"${optarg}\"/" \ + size=$(check_size "${optarg}") + [ -n "size" ] || exit 1 + sed -i "s/DISK_SIZE=.*/DISK_SIZE=\"${size}\"/" \ ${IMAGE_TMPDIR}/disk.cfg ;; --disk-device=*) - sed -i "s/DISK_DEVICE=.*/DISK_SIZE=\"${optarg}\"/" \ + sed -i "s@DISK_DEVICE=.*@DISK_DEVICE=\"${optarg}\"@" \ ${IMAGE_TMPDIR}/disk.cfg ;; --disk-add-part=*) diff --git a/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-network-init-post.sh b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-network-init-post.sh new file mode 100755 index 00000000..ce5e6de6 --- /dev/null +++ b/meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-network-init-post.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# This script is to reload kea dhcp4 server when guest interface will be ready + +# include locking functions +. /etc/xen/scripts/locking.sh +set +u + +# $1 is vif name, e.g. "vif/15/0" +# returns 0 on success, +# 1 otherwize +# + +check_if_vif_is_ready() { + ret=($(xl network-list "${guestname}" | grep "${1}")) + # ${ret[4]} is network interface status value + # 1 means vif is not ready + # 4 means vif is ready + [ "${ret[4]}" = "4" ] && return 0 + return 1 +} + +case "${XENGUEST_NETWORK_TYPE:-}" in + nat) + vif_name="$(xl network-list ${guestname} | grep -o vif.*)" + + for try in {1..20} + do + if check_if_vif_is_ready "${vif_name}"; then + claim_lock "vif-nat-kea" + keactrl reload + release_lock "vif-nat-kea" + exit 0 + fi + log info "Waiting for ${vif_name} - network interface is not ready..." + log info "try #${try}" + sleep 1 + done + log error "Failed to get ${vif_name}. network interface ready!" + exit 1 + ;; + *) + log verbose "No action needed" + ;; +esac diff --git a/meta-arm-autonomy/recipes-extended/xenguest/xenguest-base-image.bb b/meta-arm-autonomy/recipes-extended/xenguest/xenguest-base-image.bb index d164a811..4cc96aa6 100644 --- a/meta-arm-autonomy/recipes-extended/xenguest/xenguest-base-image.bb +++ b/meta-arm-autonomy/recipes-extended/xenguest/xenguest-base-image.bb @@ -47,12 +47,13 @@ XENGUEST_IMAGE_SRC_URI_DISK_FILES ??= "" # Add xen files # Any extrafiles files to be added to XENGUEST_IMAGE_SRC_URI_XEN_FILES should # be performed via XENGUEST_IMAGE_SRC_URI_XEN_FILES_append. -# The dhcpd-params.cfg holds the dhcpd configuration for Dom0. And it is used -# when XENGUEST_IMAGE_NETWORK_TYPE="nat". Any customizations to it should be -# performed by replacing it via a xenguest-network.bbappend. +# The kea-subnet4.json holds the kea dhcp4 subnet configuration for Dom0. +# And it is used when XENGUEST_IMAGE_NETWORK_TYPE="nat". +# Any customizations to it should be performed by replacing it +# via a xenguest-network.bbappend. # The XENGUEST_IMAGE_NAT_PORT_FORWARD_SCRIPT file is only added if the # variable is set. -XENGUEST_IMAGE_SRC_URI_XEN_FILES = "file://dhcpd-params.cfg \ +XENGUEST_IMAGE_SRC_URI_XEN_FILES = "file://kea-subnet4.json \ ${@ "file://" + d.getVar('XENGUEST_IMAGE_NAT_PORT_FORWARD_SCRIPT') \ if d.getVar('XENGUEST_IMAGE_NAT_PORT_FORWARD_SCRIPT') else "" } \ " diff --git a/meta-arm-autonomy/recipes-extended/xenguest/xenguest-manager.bb b/meta-arm-autonomy/recipes-extended/xenguest/xenguest-manager.bb index bd7963fb..d7b256f4 100644 --- a/meta-arm-autonomy/recipes-extended/xenguest/xenguest-manager.bb +++ b/meta-arm-autonomy/recipes-extended/xenguest/xenguest-manager.bb @@ -2,6 +2,16 @@ # # xenguest-manager is a tool to control xen guest (e.g. create, start, stop) # +# By default xenguest-manager logs to /var/log when in verbose mode, which is a +# Volatile directory. To persist logs across reboots the following needs to be +# added to either local.conf or distro.conf +# +# VOLATILE_LOG_DIR="no" +# +# Read more here: https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#var-VOLATILE_LOG_DIR +# +# When this is enabled, logrotate will monitor the file to ensure it does not grow +# excessively large. See files/logrotate-xenguest DESCRIPTION = "Xen Guest Manager" LICENSE = "MIT" @@ -9,6 +19,7 @@ LICENSE = "MIT" SRC_URI = " \ file://xenguest-manager \ file://xenguest-init \ + file://logrotate-xenguest \ " LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" @@ -17,14 +28,16 @@ S = "${WORKDIR}" # Please refer to documentation/xenguest-manager.md for documentation on those # parameters XENGUEST_MANAGER_VOLUME_DEVICE ?= "/dev/sda2" -XENGUEST_MANAGER_VOLUME_NAME ?= "vg-xen" +XENGUEST_MANAGER_VOLUME_NAME ?= "vg-xen-$(basename ${XENGUEST_MANAGER_VOLUME_DEVICE})" XENGUEST_MANAGER_GUEST_DIR ?= "${datadir}/guests/" +XENGUEST_MANAGER_LOG_LEVEL ?= "ERROR" # We add an init script to create and start guests automatically +# run start script after xen-tools and run stop script before xen-tools INITSCRIPT_NAME = "xenguest" -INITSCRIPT_PARAMS = "defaults 90" +INITSCRIPT_PARAMS = "start 90 2 3 4 5 . stop 79 0 1 6 ." -inherit update-rc.d +inherit allarch update-rc.d do_compile() { echo "XENGUEST_VOLUME_DEVICE=\"${XENGUEST_MANAGER_VOLUME_DEVICE}\"" > \ @@ -33,6 +46,8 @@ do_compile() { xenguest-manager.conf echo "XENGUEST_GUEST_DIR=\"${XENGUEST_MANAGER_GUEST_DIR}\"" >> \ xenguest-manager.conf + echo "XENGUEST_LOG_LEVEL=\"${XENGUEST_MANAGER_LOG_LEVEL}\"" >> \ + xenguest-manager.conf } do_install() { @@ -43,10 +58,13 @@ do_install() { install -d -m 755 ${D}${sysconfdir}/init.d install -m 755 xenguest-init ${D}${sysconfdir}/init.d/${INITSCRIPT_NAME} install -d -m 755 ${D}${XENGUEST_GUEST_DIR} + install -d -m 755 ${D}${sysconfdir}/logrotate.d + install -m 644 logrotate-xenguest ${D}${sysconfdir}/logrotate.d/xenguest } # Things that we need on the target -RDEPENDS_${PN} += "bash tar xenguest-mkimage lvm2 xen-tools parted e2fsprogs dosfstools" +RDEPENDS_${PN} += "bash xenguest-mkimage lvm2 xen-tools parted e2fsprogs \ + dosfstools logrotate" FILES_${PN} += "${bindir}/xenguest-manager \ ${sysconfdir}/xenguest" diff --git a/meta-arm-autonomy/recipes-extended/xenguest/xenguest-mkimage.bb b/meta-arm-autonomy/recipes-extended/xenguest/xenguest-mkimage.bb index 6ea5fb10..047ca9f9 100644 --- a/meta-arm-autonomy/recipes-extended/xenguest/xenguest-mkimage.bb +++ b/meta-arm-autonomy/recipes-extended/xenguest/xenguest-mkimage.bb @@ -17,6 +17,8 @@ S = "${WORKDIR}" # Can be built native also to produce xenguest images during Yocto build BBCLASSEXTEND = "native" +inherit allarch + do_configure[noexec] = "1" do_compile[noexec] = "1" @@ -25,7 +27,7 @@ do_install() { install -m 755 xenguest-mkimage ${D}${bindir}/. } -# We need bash and tar -RDEPENDS_${PN} = "bash tar" +# We need bash +RDEPENDS_${PN} = "bash" FILES_${PN} = "${bindir}/xenguest-mkimage" diff --git a/meta-arm-autonomy/recipes-extended/xenguest/xenguest-network.bb b/meta-arm-autonomy/recipes-extended/xenguest/xenguest-network.bb index 64426877..5f186593 100644 --- a/meta-arm-autonomy/recipes-extended/xenguest/xenguest-network.bb +++ b/meta-arm-autonomy/recipes-extended/xenguest/xenguest-network.bb @@ -21,14 +21,25 @@ SRC_URI = " \ file://xenguest-network-bridge-dhcp.cfg.in \ file://network-bridge.sh.in \ file://00-vif-xenguest.hook \ + file://xenguest-network-init-post.sh \ + file://kea-dhcp4.conf \ + file://kea-restore-default-config \ " +PACKAGES =+ "${PN}-kea-dhcp4" # Bridge configurator needs to run before S01networking init script # Prefix with a_ to make sure it is executed in runlevel 01 before others -INITSCRIPT_NAME = "a_xenguest-network-bridge" -INITSCRIPT_PARAMS = "defaults 01" +# run start script before ifupdown and run stop script after ifupdown +INITSCRIPT_PACKAGES = "${PN} ${PN}-kea-dhcp4" +INITSCRIPT_NAME_${PN} = "a_xenguest-network-bridge" +INITSCRIPT_PARAMS_${PN} = "start 01 2 3 4 5 . stop 81 0 1 6 ." -inherit update-rc.d +# Kea configuration needs to be restored before kea init scripts: +# Kea dhcp4 server is 30, so lets use 20, to have higher priority +INITSCRIPT_NAME_${PN}-kea-dhcp4 = "kea-restore-default-config" +INITSCRIPT_PARAMS_${PN}-kea-dhcp4 = "defaults 20" + +inherit allarch update-rc.d do_install() { cat ${WORKDIR}/xenguest-network-bridge.in \ @@ -43,7 +54,7 @@ do_install() { > ${WORKDIR}/network-bridge.sh install -d -m 755 ${D}${sysconfdir}/init.d install -m 755 ${WORKDIR}/xenguest-network-bridge \ - ${D}${sysconfdir}/init.d/${INITSCRIPT_NAME} + ${D}${sysconfdir}/init.d/${INITSCRIPT_NAME_${PN}} install -d -m 755 ${D}${sysconfdir}/network/interfaces.d install -m 755 ${WORKDIR}/xenguest-network-bridge.cfg \ ${D}${sysconfdir}/network/interfaces.d/. @@ -54,11 +65,22 @@ do_install() { install -d ${D}${sysconfdir}/xen/scripts/vif-post.d install -m 755 ${WORKDIR}/00-vif-xenguest.hook \ ${D}${sysconfdir}/xen/scripts/vif-post.d/. + + install -d -m 755 ${D}${sysconfdir}/xenguest/init.post + install -m 755 ${WORKDIR}/xenguest-network-init-post.sh \ + ${D}${sysconfdir}/xenguest/init.post/. + + install -m 755 ${WORKDIR}/kea-restore-default-config \ + ${D}${sysconfdir}/init.d/. + install -d -m 755 ${D}${sysconfdir}/kea/ + install -m 755 ${WORKDIR}/kea-dhcp4.conf \ + ${D}${sysconfdir}/kea/kea-dhcp4.conf.original } RDEPENDS_${PN} += "bridge-utils \ iptables \ - dhcp-server \ + kea \ + ${PN}-kea-dhcp4 \ kernel-module-xt-tcpudp \ kernel-module-xt-physdev \ kernel-module-xt-comment \ @@ -68,3 +90,7 @@ RDEPENDS_${PN} += "bridge-utils \ FILES_${PN} += "${sysconfdir}/network/interfaces.d/xenguest-network-bridge.cfg" FILES_${PN} += "${sysconfdir}/xenguest/init.pre/network-bridge.sh" FILES_${PN} += "${sysconfdir}/xen/scripts/vif-post.d/00-vif-xenguest.hook" + +FILES_${PN}-kea-dhcp4 = "${sysconfdir}/kea/kea-dhcp4.conf.original" +FILES_${PN}-kea-dhcp4 += "${sysconfdir}/init.d/${INITSCRIPT_NAME_${PN}-kea-dhcp4}" +FILES_${PN}-kea-dhcp4 += "${sysconfdir}/xenguest/init.post/xenguest-network-init-post.sh" diff --git a/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/docker-minimal.cfg b/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/docker-minimal.cfg index 7225c595..62b2d84b 100644 --- a/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/docker-minimal.cfg +++ b/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/docker-minimal.cfg @@ -1,3 +1,4 @@ +CONFIG_OVERLAY_FS=y CONFIG_NAMESPACES=y CONFIG_NET_NS=y CONFIG_PID_NS=y diff --git a/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-common.cfg b/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-common.cfg new file mode 100644 index 00000000..1e614033 --- /dev/null +++ b/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-common.cfg @@ -0,0 +1,31 @@ +CONFIG_PARAVIRT=y +CONFIG_XEN=y + +CONFIG_BLOCK=y + +CONFIG_SCSI=y + +CONFIG_NET=y + +CONFIG_HVC_IRQ=y + +CONFIG_HVC_XEN=y + +CONFIG_WATCHDOG=y +CONFIG_XEN_WDT=y + +CONFIG_XEN_BALLOON=y + +CONFIG_XEN_DEV_EVTCHN=y + +CONFIG_XENFS=y +CONFIG_XEN_COMPAT_XENFS=y + +CONFIG_XEN_SYS_HYPERVISOR=y + +CONFIG_XEN_GNTDEV=y +CONFIG_XEN_GRANT_DEV_ALLOC=y +CONFIG_SWIOTLB_XEN=y + +CONFIG_XEN_EFI=y +CONFIG_XEN_AUTO_XLATE=y diff --git a/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-common.scc b/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-common.scc new file mode 100644 index 00000000..f359d8c2 --- /dev/null +++ b/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-common.scc @@ -0,0 +1,3 @@ +define KFEATURE_DESCRIPTION "Common XEN (Host and Guest) configs and patches on autonomy systems" + +kconf non-hardware xen-common.cfg diff --git a/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-guest.cfg b/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-guest.cfg index e4e44a9c..bb2cbd53 100644 --- a/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-guest.cfg +++ b/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-guest.cfg @@ -1,27 +1,15 @@ -CONFIG_PARAVIRT=y -CONFIG_XEN=y - -CONFIG_BLOCK=y CONFIG_XEN_BLKDEV_FRONTEND=y -CONFIG_SCSI=y CONFIG_XEN_SCSI_FRONTEND=y -CONFIG_NET=y CONFIG_XEN_NETDEV_FRONTEND=y CONFIG_INPUT=y CONFIG_INPUT_MISC=y CONFIG_INPUT_XEN_KBDDEV_FRONTEND=y -CONFIG_HVC_IRQ=y - -CONFIG_HVC_XEN=y CONFIG_HVC_XEN_FRONTEND=y -CONFIG_WATCHDOG=y -CONFIG_XEN_WDT=y - CONFIG_FB_SYS_FILLRECT=y CONFIG_FB_SYS_COPYAREA=y CONFIG_FB_SYS_IMAGEBLIT=y @@ -29,21 +17,7 @@ CONFIG_FB_SYS_FOPS=y CONFIG_FB_DEFERRED_IO=y CONFIG_XEN_FBDEV_FRONTEND=y -CONFIG_XEN_BALLOON=y - -CONFIG_XEN_DEV_EVTCHN=y - -CONFIG_XENFS=y -CONFIG_XEN_COMPAT_XENFS=y - -CONFIG_XEN_SYS_HYPERVISOR=y CONFIG_XEN_XENBUS_FRONTEND=y -CONFIG_XEN_GNTDEV=y -CONFIG_XEN_GRANT_DEV_ALLOC=y -CONFIG_SWIOTLB_XEN=y - -CONFIG_XEN_EFI=y -CONFIG_XEN_AUTO_XLATE=y CONFIG_DRM=y CONFIG_DRM_XEN=y diff --git a/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-guest.scc b/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-guest.scc index b6811777..17ded00d 100644 --- a/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-guest.scc +++ b/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-guest.scc @@ -1,5 +1,3 @@ define KFEATURE_DESCRIPTION "Enable XEN Guest Frontend Drivers" kconf non-hardware xen-guest.cfg - -patch 0001-xen-arm-do-not-setup-the-runstate-info-page-if-kpti-.patch diff --git a/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-host-iptables.scc b/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-host-iptables.scc index 8f8ba45a..08200640 100644 --- a/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-host-iptables.scc +++ b/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-host-iptables.scc @@ -5,5 +5,6 @@ define KFEATURE_DESCRIPTION "Enable netfilter + conn tracking + extras" define KFEATURE_COMPATIBILITY all +include cfg/net/bridge.scc include features/netfilter/netfilter.scc kconf non-hardware netfilter-extra.cfg diff --git a/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-host.cfg b/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-host.cfg index d457cb84..54bd605c 100644 --- a/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-host.cfg +++ b/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-host.cfg @@ -1,38 +1,10 @@ -CONFIG_PARAVIRT=y -CONFIG_XEN=y - -CONFIG_BLOCK=y CONFIG_XEN_BLKDEV_BACKEND=y -CONFIG_SCSI=y CONFIG_TARGET_CORE=y CONFIG_XEN_SCSI_BACKEND=y -CONFIG_NET=y CONFIG_XEN_NETDEV_BACKEND=y -CONFIG_HVC_IRQ=y - -CONFIG_HVC_XEN=y - -CONFIG_WATCHDOG=y -CONFIG_XEN_WDT=y - -CONFIG_XEN_BALLOON=y - -CONFIG_XEN_DEV_EVTCHN=y - -CONFIG_XENFS=y -CONFIG_XEN_COMPAT_XENFS=y - -CONFIG_XEN_SYS_HYPERVISOR=y -CONFIG_XEN_GNTDEV=y -CONFIG_XEN_GRANT_DEV_ALLOC=y -CONFIG_SWIOTLB_XEN=y - -CONFIG_XEN_EFI=y -CONFIG_XEN_AUTO_XLATE=y - # For LVM2 we need Multiple Devices and Device Mapper support CONFIG_MD=y CONFIG_BLK_DEV_DM=y diff --git a/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-host.scc b/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-host.scc index 61b96a2d..71857753 100644 --- a/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-host.scc +++ b/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/xen-host.scc @@ -1,5 +1,3 @@ define KFEATURE_DESCRIPTION "Enable XEN Host Drivers on autonomy systems" kconf non-hardware xen-host.cfg - -patch 0001-xen-arm-do-not-setup-the-runstate-info-page-if-kpti-.patch diff --git a/meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/0001-xen-arm-do-not-setup-the-runstate-info-page-if-kpti-.patch b/meta-arm-autonomy/recipes-kernel/linux/files/0001-xen-arm-do-not-setup-the-runstate-info-page-if-kpti-.patch similarity index 100% rename from meta-arm-autonomy/recipes-kernel/linux/arm-autonomy-kmeta/features/arm-autonomy/0001-xen-arm-do-not-setup-the-runstate-info-page-if-kpti-.patch rename to meta-arm-autonomy/recipes-kernel/linux/files/0001-xen-arm-do-not-setup-the-runstate-info-page-if-kpti-.patch diff --git a/meta-arm-autonomy/recipes-kernel/linux/linux-arm-autonomy.inc b/meta-arm-autonomy/recipes-kernel/linux/linux-arm-autonomy.inc index d59ca8ff..89c9fce1 100644 --- a/meta-arm-autonomy/recipes-kernel/linux/linux-arm-autonomy.inc +++ b/meta-arm-autonomy/recipes-kernel/linux/linux-arm-autonomy.inc @@ -7,6 +7,11 @@ FILESEXTRAPATHS_prepend := "${THISDIR}:" # SRC_URI_append = " file://arm-autonomy-kmeta;type=kmeta;name=arm-autonomy-kmeta;destsuffix=arm-autonomy-kmeta" +# Add common Xen (host and guest) configs and patches +KERNEL_FEATURES += "${@bb.utils.contains_any('DISTRO_FEATURES', \ + 'arm-autonomy-host arm-autonomy-guest', \ + 'features/arm-autonomy/xen-common.scc', '', d)}" + # Add xen host drivers to kernel if arm-autonomy-host is activated KERNEL_FEATURES += "${@bb.utils.contains('DISTRO_FEATURES', \ @@ -20,6 +25,7 @@ KERNEL_FEATURES += "${@bb.utils.contains('DISTRO_FEATURES', \ KERNEL_FEATURES += "${@bb.utils.contains('DISTRO_FEATURES', \ 'arm-autonomy-guest', 'features/arm-autonomy/xen-guest.scc', '', d)}" + # Add support for arm64-autonomy-guest machine COMPATIBLE_MACHINE_arm64-autonomy-guest = "arm64-autonomy-guest" KMACHINE_arm64-autonomy-guest = "arm64-autonomy-guest" @@ -27,3 +33,13 @@ KMACHINE_arm64-autonomy-guest = "arm64-autonomy-guest" # Add Minimal Kernel Configs for Docker runtime KERNEL_FEATURES += "${@bb.utils.contains('DISTRO_FEATURES', \ 'docker', 'features/arm-autonomy/docker-minimal.scc', '', d)}" + +python() { + from distutils.version import LooseVersion + + kernelVersion = d.getVar('LINUX_VERSION') + + if kernelVersion and LooseVersion(kernelVersion) < '5.10': + if oe.utils.any_distro_features(d, "arm-autonomy-host arm-autonomy-guest"): + d.appendVar('SRC_URI', ' file://files/0001-xen-arm-do-not-setup-the-runstate-info-page-if-kpti-.patch' ) +} diff --git a/meta-arm-autonomy/scripts/lib/wic/plugins/source/empty.py b/meta-arm-autonomy/scripts/lib/wic/plugins/source/empty.py deleted file mode 100644 index 041617d6..00000000 --- a/meta-arm-autonomy/scripts/lib/wic/plugins/source/empty.py +++ /dev/null @@ -1,32 +0,0 @@ -# -# SPDX-License-Identifier: MIT -# - -# The empty wic plugin is used to create unformatted empty partitions for wic -# images. -# To use it you must pass "empty" as argument for the "--source" parameter in -# the wks file. For example: -# part foo --source empty --ondisk sda --size="1024" --align 1024 - -import logging - -from wic.pluginbase import SourcePlugin - -logger = logging.getLogger('wic') - -class EmptyPartitionPlugin(SourcePlugin): - """ - Populate unformatted empty partition. - """ - - name = 'empty' - - @classmethod - def do_prepare_partition(cls, part, source_params, cr, cr_workdir, - oe_builddir, bootimg_dir, kernel_dir, - rootfs_dir, native_sysroot): - """ - Called to do the actual content population for a partition i.e. it - 'prepares' the partition to be incorporated into the image. - """ - return diff --git a/meta-arm-bsp/conf/layer.conf b/meta-arm-bsp/conf/layer.conf index f9c2422a..445697ff 100644 --- a/meta-arm-bsp/conf/layer.conf +++ b/meta-arm-bsp/conf/layer.conf @@ -7,11 +7,14 @@ BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ BBFILE_COLLECTIONS += "meta-arm-bsp" BBFILE_PATTERN_meta-arm-bsp = "^${LAYERDIR}/" -BBFILE_PRIORITY_meta-arm-bsp = "6" +BBFILE_PRIORITY_meta-arm-bsp = "5" LAYERSERIES_COMPAT_meta-arm-bsp = "gatesgarth" -LAYERDEPENDS_meta-arm-bsp = "core meta-arm meta-kernel" +LAYERDEPENDS_meta-arm-bsp = "core meta-arm" # This won't be used by layerindex-fetch, but works everywhere else LAYERDEPENDS_meta-arm-bsp_append_musca-b1 = " meta-python" LAYERDEPENDS_meta-arm-bsp_append_musca-s1 = " meta-python" + +# Additional license directories. +LICENSE_PATH += "${LAYERDIR}/custom-licenses" diff --git a/meta-arm-bsp/conf/machine/a5ds.conf b/meta-arm-bsp/conf/machine/a5ds.conf deleted file mode 100644 index f7d35e73..00000000 --- a/meta-arm-bsp/conf/machine/a5ds.conf +++ /dev/null @@ -1,23 +0,0 @@ -# Configuration for Cortex-A5 DesignStart development board - -#@TYPE: Machine -#@NAME: a5ds machine -#@DESCRIPTION: Machine configuration for Cortex-A5 DesignStart - -require conf/machine/include/tune-cortexa5.inc - -PREFERRED_PROVIDER_virtual/kernel ?= "linux-stable" -PREFERRED_VERSION_linux-stable ?= "5.3%" -KBUILD_DEFCONFIG = "multi_v7_defconfig" - -EXTRA_IMAGEDEPENDS += "virtual/trusted-firmware-a u-boot" - -SERIAL_CONSOLES = "115200;ttyAMA0" - -IMAGE_FSTYPES += "tar.bz2 cpio.gz" - -# Cortex-a5 u-boot configuration -UBOOT_MACHINE = "designstart_ca5_defconfig" -UBOOT_IMAGE_ENTRYPOINT = "0x84000000" -UBOOT_IMAGE_LOADADDRESS = "0x84000000" - diff --git a/meta-arm-bsp/conf/machine/corstone500.conf b/meta-arm-bsp/conf/machine/corstone500.conf new file mode 100644 index 00000000..ec1d9e2f --- /dev/null +++ b/meta-arm-bsp/conf/machine/corstone500.conf @@ -0,0 +1,32 @@ +#@TYPE: Machine +#@NAME: Corstone-500 machine +#@DESCRIPTION: Machine configuration for the Corstone-500 platform + +require conf/machine/include/tune-cortexa5.inc + +# +# Corstone-500 is built against poky-tiny distro. +# poky-tiny sets PREFERRED_PROVIDER_virtual/kernel to linux-yocto-tiny. +# Since distro config is evaluated after the machine config, we need to +# use the strongest override possible (forcevariable) so the +# PREFERRED_PROVIDER_virtual/kernel specified in the machine config will +# apply. +# +PREFERRED_PROVIDER_virtual/kernel_forcevariable = "linux-yocto" +PREFERRED_VERSION_linux-yocto ?= "5.3%" +KBUILD_DEFCONFIG = "multi_v7_defconfig" +KCONFIG_MODE = "--alldefconfig" + +PREFERRED_VERSION_trusted-firmware-a ?= "2.3%" + +EXTRA_IMAGEDEPENDS += "virtual/trusted-firmware-a u-boot" + +SERIAL_CONSOLES = "115200;ttyAMA0" + +IMAGE_FSTYPES += "tar.bz2 cpio.gz" + +# Corstone-500 u-boot configuration +UBOOT_MACHINE = "designstart_ca5_defconfig" +UBOOT_IMAGE_ENTRYPOINT = "0x84000000" +UBOOT_IMAGE_LOADADDRESS = "0x84000000" +PREFERRED_VERSION_u-boot ?= "2020.07" \ No newline at end of file diff --git a/meta-arm-bsp/conf/machine/foundation-armv8.conf b/meta-arm-bsp/conf/machine/foundation-armv8.conf deleted file mode 100644 index 0ec6ecd1..00000000 --- a/meta-arm-bsp/conf/machine/foundation-armv8.conf +++ /dev/null @@ -1,17 +0,0 @@ -# Configuration for Armv8-A Foundation - -#@TYPE: Machine -#@NAME: Armv8-A Foundation Platform machine -#@DESCRIPTION: Machine configuration for Armv8-A Foundation Platform model - -require conf/machine/fvp-common.inc -require conf/machine/include/arm/arch-armv8a.inc - -TUNE_FEATURES = "aarch64" - -# FVP u-boot configuration -UBOOT_MACHINE = "vexpress_aemv8a_semi_defconfig" - -KERNEL_IMAGETYPE = "Image" - -KERNEL_DEVICETREE = "arm/foundation-v8-gicv3-psci.dtb" diff --git a/meta-arm-bsp/conf/machine/fvp-base-arm32.conf b/meta-arm-bsp/conf/machine/fvp-base-arm32.conf index 3c3e5acf..9e821b74 100644 --- a/meta-arm-bsp/conf/machine/fvp-base-arm32.conf +++ b/meta-arm-bsp/conf/machine/fvp-base-arm32.conf @@ -9,8 +9,6 @@ require conf/machine/include/arm/arch-armv7a.inc KERNEL_IMAGETYPE = "zImage" -PREFERRED_VERSION_trusted-firmware-a ?= "2.2%" - # FVP u-boot configuration UBOOT_MACHINE = "vexpress_aemv8a_aarch32_defconfig" diff --git a/meta-arm-bsp/conf/machine/fvp-common.inc b/meta-arm-bsp/conf/machine/fvp-common.inc index da45026a..94aa2bfe 100644 --- a/meta-arm-bsp/conf/machine/fvp-common.inc +++ b/meta-arm-bsp/conf/machine/fvp-common.inc @@ -29,7 +29,10 @@ DISK_IMG_PARTITION3_CONTENT = "" SERIAL_CONSOLES = "115200;ttyAMA0" PREFERRED_PROVIDER_virtual/kernel ?= "linux-yocto" -PREFERRED_VERSION_linux-yocto ?= "5.4%" +PREFERRED_VERSION_linux-yocto ?= "5.10%" + +PREFERRED_VERSION_u-boot ?= "2020.10" +PREFERRED_VERSION_trusted-firmware-a ?= "2.4%" EXTRA_IMAGEDEPENDS += "virtual/trusted-firmware-a u-boot" diff --git a/meta-arm-bsp/conf/machine/include/arm/arch-armv7em.inc b/meta-arm-bsp/conf/machine/include/arm/arch-armv7em.inc index 4f21c6ab..197286fd 100755 --- a/meta-arm-bsp/conf/machine/include/arm/arch-armv7em.inc +++ b/meta-arm-bsp/conf/machine/include/arm/arch-armv7em.inc @@ -11,7 +11,6 @@ TUNECONFLICTS[armv7em] = "armv4 armv5 armv6 armv7a" require conf/machine/include/arm/arch-armv7m.inc - AVAILTUNES += "armv7em" ARMPKGARCH_tune-armv7em = "armv7em" TUNE_FEATURES_tune-armv7em = "armv7em" diff --git a/meta-arm-bsp/conf/machine/include/arm/arch-armv7m.inc b/meta-arm-bsp/conf/machine/include/arm/arch-armv7m.inc index af82e6ce..c659e8bf 100755 --- a/meta-arm-bsp/conf/machine/include/arm/arch-armv7m.inc +++ b/meta-arm-bsp/conf/machine/include/arm/arch-armv7m.inc @@ -1,15 +1,3 @@ -# -# Tune Settings for Cortex-M3 -# -TUNEVALID[cortexm3] = "Enable Cortex-M3 specific processor optimizations" -TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'cortexm3', ' -mcpu=cortex-m3', '', d)}" - - -AVAILTUNES += "cortexm3" -ARMPKGARCH_tune-cortexm3 = "cortexm3" -TUNE_FEATURES_tune-cortexm3 = "${TUNE_FEATURES_tune-armv7m} cortexm3" -PACKAGE_EXTRA_ARCHS_tune-cortexm3 = "${PACKAGE_EXTRA_ARCHS_tune-armv7m} cortexm3" - # # Defaults for ARMv7-m # @@ -23,7 +11,6 @@ TUNECONFLICTS[armv7m] = "armv4 armv5 armv6 armv7a" require conf/machine/include/arm/arch-armv6m.inc - AVAILTUNES += "armv7m" ARMPKGARCH_tune-armv7m = "armv7m" TUNE_FEATURES_tune-armv7m = "armv7m" diff --git a/meta-arm-bsp/conf/machine/include/arm/arch-armv8-1m-main.inc b/meta-arm-bsp/conf/machine/include/arm/arch-armv8-1m-main.inc index 505897ab..fc8add4d 100755 --- a/meta-arm-bsp/conf/machine/include/arm/arch-armv8-1m-main.inc +++ b/meta-arm-bsp/conf/machine/include/arm/arch-armv8-1m-main.inc @@ -12,7 +12,6 @@ TUNECONFLICTS[armv8-1m-main] = "armv4 armv5 armv6 armv7a" require conf/machine/include/arm/arch-armv8m-main.inc - AVAILTUNES += "armv8-1m-main" ARMPKGARCH_tune-armv8-1m-main = "armv8-1m-main" TUNE_FEATURES_tune-armv8-1m-main = "armv8-1m-main" diff --git a/meta-arm-bsp/conf/machine/include/arm/arch-armv8-2a.inc b/meta-arm-bsp/conf/machine/include/arm/arch-armv8-2a.inc index 528c34ea..0af949ed 100644 --- a/meta-arm-bsp/conf/machine/include/arm/arch-armv8-2a.inc +++ b/meta-arm-bsp/conf/machine/include/arm/arch-armv8-2a.inc @@ -7,7 +7,6 @@ MACHINEOVERRIDES =. "${@bb.utils.contains('TUNE_FEATURES', 'armv8-2a', 'armv8-2a require conf/machine/include/arm/arch-armv8a.inc - AVAILTUNES += "armv8-2a armv8-2a-crypto" ARMPKGARCH_tune-armv8-2a ?= "armv8-2a" ARMPKGARCH_tune-armv8-2a-crypto ?= "armv8-2a" diff --git a/meta-arm-bsp/conf/machine/include/arm/arch-armv8m-base.inc b/meta-arm-bsp/conf/machine/include/arm/arch-armv8m-base.inc index 5df17281..04cdf7d7 100755 --- a/meta-arm-bsp/conf/machine/include/arm/arch-armv8m-base.inc +++ b/meta-arm-bsp/conf/machine/include/arm/arch-armv8m-base.inc @@ -11,7 +11,6 @@ TUNECONFLICTS[armv8m-base] = "armv4 armv5 armv6 armv7a" require conf/machine/include/arm/arch-armv7m.inc - AVAILTUNES += "armv8m-base" ARMPKGARCH_tune-armv8m-base = "armv8m-base" TUNE_FEATURES_tune-armv8m-base = "armv8m-base" diff --git a/meta-arm-bsp/conf/machine/include/arm/arch-armv8m-main.inc b/meta-arm-bsp/conf/machine/include/arm/arch-armv8m-main.inc index a03c01ca..f2e078d0 100755 --- a/meta-arm-bsp/conf/machine/include/arm/arch-armv8m-main.inc +++ b/meta-arm-bsp/conf/machine/include/arm/arch-armv8m-main.inc @@ -1,19 +1,36 @@ # -# -# Defaults for ARMv8-M.main +# Defaults for ARMv8-m.main # DEFAULTTUNE ?= "armv8m-main" +require conf/machine/include/arm/arch-armv8m-base.inc + TUNEVALID[armv8m-main] = "Enable instructions for ARMv8-m.main" -TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'armv8m-main', ' -march=armv8-m.main', '', d)}" +TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'armv8m-main', ' -march=armv8-m.main${MARCH_DSP}${MARCH_FPU}', '', d)}" MACHINEOVERRIDES =. "${@bb.utils.contains('TUNE_FEATURES', 'armv8m-main', 'armv8m-main:', '', d)}" TUNECONFLICTS[armv8m-main] = "armv4 armv5 armv6 armv7a" -require conf/machine/include/arm/arch-armv8m-base.inc +# FIXME - below taken from meta/conf/machine/include/arm/arch-armv5-dsp.inc and should be put into something more generic +TUNEVALID[dsp] = "ARM DSP functionality" +ARMPKGSFX_DSP = "${@bb.utils.contains('TUNE_FEATURES', [ 'dsp' ], 'e', '', d)}" +MARCH_DSP = "${@bb.utils.contains('TUNE_FEATURES', [ 'dsp' ], '+dsp', '+nodsp', d)}" +# FIXME - Below belongs in meta/conf/machine/include/arm/feature-arm-neon.inc +TUNEVALID[vfpv5spd16] = "Enable Vector Floating Point Version 5, Single Precision. with 16 registers (fpv5-sp-d16) unit." +TUNE_CCARGS_MFPU .= "${@bb.utils.contains('TUNE_FEATURES', 'vfpv5spd16', 'fpv5-sp-d16', '', d)}" +MARCH_FPU = "${@bb.utils.contains('TUNE_FEATURES', [ 'vfpv5spd16' ], '+fp', '+nofp', d)}" -AVAILTUNES += "armv8m-main" -ARMPKGARCH_tune-armv8m-main = "armv8m-main" -TUNE_FEATURES_tune-armv8m-main = "armv8m-main" -PACKAGE_EXTRA_ARCHS_tune-armv8m-main = "armv8m-main" +AVAILTUNES += "armv8m-main armv8m-mainearmv8m-main-vfpv5spd16 armv8m-maine-vfpv5spd16" +ARMPKGARCH_tune-armv8m-main = "armv8m-main" +ARMPKGARCH_tune-armv8m-maine = "armv8m-main" +ARMPKGARCH_tune-armv8m-main-vfpv5spd16 = "armv8m-main" +ARMPKGARCH_tune-armv8m-maine-vfpv5spd16 = "armv8m-main" +TUNE_FEATURES_tune-armv8m-main = "armv8m-main" +TUNE_FEATURES_tune-armv8m-maine = "${TUNE_FEATURES_tune-armv8m-main} dsp" +TUNE_FEATURES_tune-armv8m-main-vfpv5spd16 = "${TUNE_FEATURES_tune-armv8m-main} vfpv5spd16" +TUNE_FEATURES_tune-armv8m-maine-vfpv5spd16 = "${TUNE_FEATURES_tune-armv8m-main-vfpv5spd16} dsp" +PACKAGE_EXTRA_ARCHS_tune-armv8m-main = "armv8m-main" +PACKAGE_EXTRA_ARCHS_tune-armv8m-maine = "${PACKAGE_EXTRA_ARCHS_tune-armv8m-main} armv8m-maine" +PACKAGE_EXTRA_ARCHS_tune-armv8m-main-vfpv5spd16 = "${PACKAGE_EXTRA_ARCHS_tune-armv8m-main} armv8m-main-fpv5-spd16" +PACKAGE_EXTRA_ARCHS_tune-armv8m-maine-vfpv5spd16 = "${PACKAGE_EXTRA_ARCHS_tune-armv8m-main} armv8m-maine-fpv5-spd16" diff --git a/meta-arm-bsp/conf/machine/include/corstone700.inc b/meta-arm-bsp/conf/machine/include/corstone700.inc index 91f290f6..ab3e2a42 100644 --- a/meta-arm-bsp/conf/machine/include/corstone700.inc +++ b/meta-arm-bsp/conf/machine/include/corstone700.inc @@ -8,14 +8,13 @@ TFA_PLATFORM = "corstone700" SERIAL_CONSOLES ?= "115200;ttyAMA0" -PREFERRED_PROVIDER_virtual/kernel_corstone700 = "linux-stable" -PREFERRED_VERSION_linux-stable ?= "5.6%" +PREFERRED_PROVIDER_virtual/kernel_corstone700 = "linux-yocto" +PREFERRED_VERSION_linux-yocto ?= "5.6%" PREFERRED_PROVIDER_virtual/trusted-firmware-a ?= "trusted-firmware-a" PREFERRED_VERSION_trusted-firmware-a ?= "2.3%" -PREFERRED_PROVIDER_virtual/control-processor-firmware ?= "scp-firmware" -PREFERRED_VERSION_control-processor-firmware ?= "2.6.0" +PREFERRED_PROVIDER_virtual/control-processor-firmware ?= "boot-firmware" EXTRA_IMAGEDEPENDS += " \ virtual/trusted-firmware-a \ diff --git a/meta-arm-bsp/conf/machine/include/tune-cortexm1.inc b/meta-arm-bsp/conf/machine/include/tune-cortexm1.inc index 0bcdbe2a..ed36361b 100755 --- a/meta-arm-bsp/conf/machine/include/tune-cortexm1.inc +++ b/meta-arm-bsp/conf/machine/include/tune-cortexm1.inc @@ -8,7 +8,6 @@ TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'cortexm1', ' -mcpu=cortex require conf/machine/include/arm/arch-armv6m.inc - AVAILTUNES += "cortexm1" ARMPKGARCH_tune-cortexm1 = "cortexm1" TUNE_FEATURES_tune-cortexm1 = "${TUNE_FEATURES_tune-armv6m} cortexm1" diff --git a/meta-arm-bsp/conf/machine/include/tune-cortexm23.inc b/meta-arm-bsp/conf/machine/include/tune-cortexm23.inc index 12d4c141..e2e0a345 100755 --- a/meta-arm-bsp/conf/machine/include/tune-cortexm23.inc +++ b/meta-arm-bsp/conf/machine/include/tune-cortexm23.inc @@ -8,7 +8,6 @@ TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'cortexm23', ' -mcpu=corte require conf/machine/include/arm/arch-armv8m-base.inc - AVAILTUNES += "cortexm23" ARMPKGARCH_tune-cortexm23 = "cortexm23" TUNE_FEATURES_tune-cortexm23 = "${TUNE_FEATURES_tune-armv8m-base} cortexm23" diff --git a/meta-arm-bsp/conf/machine/include/tune-cortexm3.inc b/meta-arm-bsp/conf/machine/include/tune-cortexm3.inc index 605c9a7d..f837ad2c 100755 --- a/meta-arm-bsp/conf/machine/include/tune-cortexm3.inc +++ b/meta-arm-bsp/conf/machine/include/tune-cortexm3.inc @@ -8,7 +8,6 @@ TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'cortexm3', ' -mcpu=cortex require conf/machine/include/arm/arch-armv7m.inc - AVAILTUNES += "cortexm3" ARMPKGARCH_tune-cortexm3 = "cortexm3" TUNE_FEATURES_tune-cortexm3 = "${TUNE_FEATURES_tune-armv7m} cortexm3" diff --git a/meta-arm-bsp/conf/machine/include/tune-cortexm33.inc b/meta-arm-bsp/conf/machine/include/tune-cortexm33.inc index d9c88aa1..105a6058 100755 --- a/meta-arm-bsp/conf/machine/include/tune-cortexm33.inc +++ b/meta-arm-bsp/conf/machine/include/tune-cortexm33.inc @@ -1,15 +1,17 @@ # # Tune Settings for Cortex-M33 # -DEFAULTTUNE ?= "armv8m" +DEFAULTTUNE ?= "cortexm33" -TUNEVALID[armv8m] = "Enable instructions for ARMv8-m" -TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'armv8m', ' -march=armv7-m', '', d)}" +TUNEVALID[cortexm33] = "Enable Cortex-M33 specific processor optimizations" +TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'cortexm33', ' -mcpu=cortex-m33', '', d)}" require conf/machine/include/arm/arch-armv8m-main.inc -AVAILTUNES += "armv8m" -ARMPKGARCH_tune-armv8m ?= "armv8m" -TUNE_FEATURES_tune-armv8m = "armv8m" -PACKAGE_EXTRA_ARCHS_tune-armv8m = "armv8m" - +# GCC thnks that DSP and VFP are required, but Arm docs say it is +# optional. So forcing below so that compiling works, but this should +# be fixed in GCC +AVAILTUNES += "cortexm33" +ARMPKGARCH_tune-cortexm33 = "cortexm33" +TUNE_FEATURES_tune-cortexm33 = "${TUNE_FEATURES_tune-armv8m-maine-vfpv5spd16} cortexm33" +PACKAGE_EXTRA_ARCHS_tune-cortexm33 = "${PACKAGE_EXTRA_ARCHS_tune-armv8m-maine-vfpv5spd16} cortexm33e-fpv5-spd16" diff --git a/meta-arm-bsp/conf/machine/include/tune-cortexm35p.inc b/meta-arm-bsp/conf/machine/include/tune-cortexm35p.inc index 562ee81c..7d734216 100755 --- a/meta-arm-bsp/conf/machine/include/tune-cortexm35p.inc +++ b/meta-arm-bsp/conf/machine/include/tune-cortexm35p.inc @@ -1,15 +1,17 @@ # # Tune Settings for Cortex-M35P # -DEFAULTTUNE ?= "cortexm33p" +DEFAULTTUNE ?= "cortexm35p" TUNEVALID[cortexm35p] = "Enable Cortex-M35p specific processor optimizations" TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'cortexm35p', ' -mcpu=cortex-m35p', '', d)}" require conf/machine/include/arm/arch-armv8m-main.inc - +# GCC thnks that DSP and VFP are required, but Arm docs say it is +# optional. So forcing below so that compiling works, but this should +# be fixed in GCC AVAILTUNES += "cortexm35p" ARMPKGARCH_tune-cortexm35p = "cortexm35p" -TUNE_FEATURES_tune-cortexm35p = "${TUNE_FEATURES_tune-armv8m-main} cortexm35p" -PACKAGE_EXTRA_ARCHS_tune-cortexm35p = "${PACKAGE_EXTRA_ARCHS_tune-armv8m-main} cortexm35p" +TUNE_FEATURES_tune-cortexm35p = "${TUNE_FEATURES_tune-armv8m-maine-vfpv5spd16} cortexm35p" +PACKAGE_EXTRA_ARCHS_tune-cortexm35p = "${PACKAGE_EXTRA_ARCHS_tune-armv8m-maine-vfpv5spd16} cortexm35pe-fpv5-spd16" diff --git a/meta-arm-bsp/conf/machine/include/tune-cortexm4.inc b/meta-arm-bsp/conf/machine/include/tune-cortexm4.inc index 74aa27c2..8f498f50 100755 --- a/meta-arm-bsp/conf/machine/include/tune-cortexm4.inc +++ b/meta-arm-bsp/conf/machine/include/tune-cortexm4.inc @@ -8,7 +8,6 @@ TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'cortexm4', ' -mcpu=cortex require conf/machine/include/arm/arch-armv7em.inc - AVAILTUNES += "cortexm4" ARMPKGARCH_tune-cortexm4 = "cortexm4" TUNE_FEATURES_tune-cortexm4 = "${TUNE_FEATURES_tune-armv7em} cortexm4" diff --git a/meta-arm-bsp/conf/machine/include/tune-cortexm55.inc b/meta-arm-bsp/conf/machine/include/tune-cortexm55.inc index 3f7f3d73..b92aff15 100755 --- a/meta-arm-bsp/conf/machine/include/tune-cortexm55.inc +++ b/meta-arm-bsp/conf/machine/include/tune-cortexm55.inc @@ -8,7 +8,6 @@ TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'cortexm55', ' -mcpu=corte require conf/machine/include/arm/arch-armv8-1m-main.inc - AVAILTUNES += "cortexm55" ARMPKGARCH_tune-cortexm55 = "cortexm55" TUNE_FEATURES_tune-cortexm55 = "${TUNE_FEATURES_tune-armv8-1m-main} cortexm55" diff --git a/meta-arm-bsp/conf/machine/include/tune-cortexm7.inc b/meta-arm-bsp/conf/machine/include/tune-cortexm7.inc index 84091084..21b7c011 100755 --- a/meta-arm-bsp/conf/machine/include/tune-cortexm7.inc +++ b/meta-arm-bsp/conf/machine/include/tune-cortexm7.inc @@ -8,7 +8,6 @@ TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'cortexm7', ' -mcpu=cortex require conf/machine/include/arm/arch-armv7em.inc - AVAILTUNES += "cortexm7" ARMPKGARCH_tune-cortexm7 = "cortexm7" TUNE_FEATURES_tune-cortexm7 = "${TUNE_FEATURES_tune-armv7em} cortexm7" diff --git a/meta-arm-bsp/conf/machine/juno.conf b/meta-arm-bsp/conf/machine/juno.conf index 50c9d2fc..8cff6c40 100644 --- a/meta-arm-bsp/conf/machine/juno.conf +++ b/meta-arm-bsp/conf/machine/juno.conf @@ -20,7 +20,9 @@ SERIAL_CONSOLES = "115200;ttyAMA0" # Use kernel provided by yocto PREFERRED_PROVIDER_virtual/kernel ?= "linux-yocto" PREFERRED_VERSION_linux-yocto ?= "5.4%" +PREFERRED_VERSION_scp-firmware ?= "2.6%" PREFERRED_VERSION_trusted-firmware-a ?= "2.3%" +PREFERRED_VERSION_u-boot ?= "2020.07" EXTRA_IMAGEDEPENDS += "virtual/trusted-firmware-a u-boot firmware-image-juno" diff --git a/meta-arm-bsp/conf/machine/musca-b1.conf b/meta-arm-bsp/conf/machine/musca-b1.conf index 50b2f05a..5300b754 100644 --- a/meta-arm-bsp/conf/machine/musca-b1.conf +++ b/meta-arm-bsp/conf/machine/musca-b1.conf @@ -4,16 +4,15 @@ #@NAME: Musca-B1 machine #@DESCRIPTION: Machine configuration for Musca-B1 -EXTRA_IMAGEDEPENDS += "virtual/trusted-firmware-m" -PREFERRED_VERSION_trusted-firmware-m = "1.0" - +DEFAULTTUNE ?= "armv8m-main" require conf/machine/include/tune-cortexm33.inc # GLIBC will not work with Cortex-M. TCLIBC = "newlib" # For runqemu -require conf/machine/include/qemu.inc +IMAGE_FSTYPES += "ext4" +IMAGE_CLASSES += "qemuboot" QB_SYSTEM_NAME = "qemu-system-arm" QB_MACHINE = "-machine musca-b1" QB_CPU = "-cpu cortex-m33" @@ -24,3 +23,5 @@ QB_MEM = "512k" ZEPHYR_BOARD = "v2m_musca_b1" ZEPHYR_INHERIT_CLASSES += "zephyr-qemuboot" ARCH_musca-b1 = "arm" + +TFM_PLATFORM = "MUSCA_B1" diff --git a/meta-arm-bsp/conf/machine/musca-s1.conf b/meta-arm-bsp/conf/machine/musca-s1.conf index 66e0a35c..c4131a82 100644 --- a/meta-arm-bsp/conf/machine/musca-s1.conf +++ b/meta-arm-bsp/conf/machine/musca-s1.conf @@ -4,10 +4,9 @@ #@NAME: Musca-S1 machine #@DESCRIPTION: Machine configuration for Musca-S1 -EXTRA_IMAGEDEPENDS += "virtual/trusted-firmware-m" -PREFERRED_VERSION_trusted-firmware-m = "1.0" - require conf/machine/include/tune-cortexm33.inc # GLIBC will not work with Cortex-M. TCLIBC = "newlib" + +TFM_PLATFORM = "MUSCA_S1" diff --git a/meta-arm-bsp/conf/machine/n1sdp.conf b/meta-arm-bsp/conf/machine/n1sdp.conf index 4649826f..0fc4bb89 100644 --- a/meta-arm-bsp/conf/machine/n1sdp.conf +++ b/meta-arm-bsp/conf/machine/n1sdp.conf @@ -8,7 +8,7 @@ require conf/machine/include/tune-neoversen1.inc KERNEL_IMAGETYPE = "Image" -IMAGE_FSTYPES += "wic tar.bz2 ext4" +IMAGE_FSTYPES += "wic wic.gz wic.bmap tar.bz2 ext4" SERIAL_CONSOLES = "115200;ttyAMA0" @@ -17,23 +17,27 @@ WKS_FILE ?= "n1sdp-efidisk.wks" IMAGE_EFI_BOOT_FILES ?= "n1sdp-multi-chip.dtb n1sdp-single-chip.dtb" WKS_FILE_DEPENDS_append = " ${EXTRA_IMAGEDEPENDS}" -# Use kernel provided by linaro (Contains support for SCMi or HDMI) -PREFERRED_PROVIDER_virtual/kernel ?= "linux-linaro-arm" -PREFERRED_VERSION_linux-linaro-arm ?= "5.4%" +# Use kernel provided by yocto +PREFERRED_PROVIDER_virtual/kernel ?= "linux-yocto" +PREFERRED_VERSION_linux-yocto ?= "5.10%" # RTL8168E Gigabit Ethernet Controller is attached to the PCIe interface MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "linux-firmware-rtl8168" -# Trusted firmware v2.3 version -PREFERRED_PROVIDER_virtual/trusted-firmware-a ?= "trusted-firmware-a" -PREFERRED_VERSION_trusted-firmware-a ?= "2.3%" +PREFERRED_VERSION_trusted-firmware-a ?= "2.4%" EXTRA_IMAGEDEPENDS += "virtual/trusted-firmware-a" EXTRA_IMAGEDEPENDS += "virtual/control-processor-firmware" +PREFERRED_VERSION_scp-firmware ?= "2.7%" + #UEFI EDK2 firmware EXTRA_IMAGEDEPENDS += "virtual/uefi-firmware" +PREFERRED_VERSION_edk2-firmware ?= "201911%" #grub-efi EFI_PROVIDER ?= "grub-efi" MACHINE_FEATURES += "efi" + +# SD-Card firmware +EXTRA_IMAGEDEPENDS += "sdcard-image-n1sdp" diff --git a/meta-arm-bsp/conf/machine/sgi575.conf b/meta-arm-bsp/conf/machine/sgi575.conf index 1b6498c9..860b6d76 100644 --- a/meta-arm-bsp/conf/machine/sgi575.conf +++ b/meta-arm-bsp/conf/machine/sgi575.conf @@ -16,10 +16,13 @@ EXTRA_IMAGEDEPENDS += "virtual/trusted-firmware-a" # Use kernel provided by linaro KERNEL_IMAGETYPE ?= "Image" -PREFERRED_PROVIDER_virtual/kernel ?= "linux-stable" -PREFERRED_VERSION_linux-stable ?= "5.7%" +PREFERRED_PROVIDER_virtual/kernel ?= "linux-yocto" +PREFERRED_VERSION_linux-yocto ?= "5.7%" +KCONFIG_MODE = "--alldefconfig" SERIAL_CONSOLES = "115200;ttyAMA0" +PREFERRED_VERSION_edk2-firmware ?= "202011%" + #grub-efi EFI_PROVIDER ?= "grub-efi" MACHINE_FEATURES += "efi" diff --git a/meta-arm-bsp/conf/machine/tc0.conf b/meta-arm-bsp/conf/machine/tc0.conf index 9f15ac8c..eda33241 100644 --- a/meta-arm-bsp/conf/machine/tc0.conf +++ b/meta-arm-bsp/conf/machine/tc0.conf @@ -10,30 +10,34 @@ require conf/machine/include/arm/arch-armv8a.inc # Das U-boot UBOOT_MACHINE ?= "total_compute_defconfig" - -# Trusted firmware A v2.3 -PREFERRED_PROVIDER_virtual/trusted-firmware-a ?= "trusted-firmware-a" -PREFERRED_VERSION_trusted-firmware-a ?= "2.3%" - -PREFERRED_PROVIDER_virtual/kernel ?= "linux-arm64-ack" -PREFERRED_VERSION_linux-arm64-ack ?= "5.4" - -# Cannot use the default zImage on arm64 -KERNEL_IMAGETYPE = "Image" -KERNEL_IMAGETYPES += " fitImage " -KERNEL_CLASSES = " kernel-fitimage " - -IMAGE_FSTYPES += "cpio.gz" -INITRAMFS_IMAGE = "core-image-minimal" - +PREFERRED_VERSION_u-boot ?= "2020.10" UBOOT_RD_LOADADDRESS = "0x88000000" UBOOT_RD_ENTRYPOINT = "0x88000000" UBOOT_LOADADDRESS = "0x80080000" UBOOT_ENTRYPOINT = "0x80080000" +# Below options will generate a key to sign the kernel Image and INITRAMFS_IMAGE +# according to the default parameters of kernel-fitimage.bbclass. If the user +# would prefer to use their own keys, disable the key generation using the +# FIT_GENERATE_KEYS parameter and specify the location of the keys using the +# below paramters. UBOOT_SIGN_ENABLE = "1" UBOOT_MKIMAGE_DTCOPTS = "-I dts -O dtb" UBOOT_SIGN_KEYNAME = "dev_key" UBOOT_SIGN_KEYDIR = "${DEPLOY_DIR_IMAGE}/keys" FIT_GENERATE_KEYS = "1" +PREFERRED_PROVIDER_virtual/trusted-firmware-a ?= "trusted-firmware-a" +PREFERRED_VERSION_trusted-firmware-a ?= "2.4%" + +PREFERRED_PROVIDER_virtual/kernel ?= "linux-arm64-ack" +PREFERRED_VERSION_linux-arm64-ack ?= "5.4" + +# Cannot use the default zImage on arm64 +KERNEL_IMAGETYPE = "Image" +KERNEL_IMAGETYPES += "fitImage" +KERNEL_CLASSES = " kernel-fitimage " + +IMAGE_FSTYPES += "cpio.gz" +INITRAMFS_IMAGE ?= "core-image-minimal" + SERIAL_CONSOLES = "115200;ttyAMA0" diff --git a/meta-arm-bsp/custom-licenses/STM-SLA0044-Rev5 b/meta-arm-bsp/custom-licenses/STM-SLA0044-Rev5 new file mode 100644 index 00000000..edb5cd55 --- /dev/null +++ b/meta-arm-bsp/custom-licenses/STM-SLA0044-Rev5 @@ -0,0 +1,18 @@ +SLA0044 Rev5/February 2018 + +BY INSTALLING COPYING, DOWNLOADING, ACCESSING OR OTHERWISE USING THIS SOFTWARE OR ANY PART THEREOF (AND THE RELATED DOCUMENTATION) FROM STMICROELECTRONICS INTERNATIONAL N.V, SWISS BRANCH AND/OR ITS AFFILIATED COMPANIES (STMICROELECTRONICS), THE RECIPIENT, ON BEHALF OF HIMSELF OR HERSELF, OR ON BEHALF OF ANY ENTITY BY WHICH SUCH RECIPIENT IS EMPLOYED AND/OR ENGAGED AGREES TO BE BOUND BY THIS SOFTWARE LICENSE AGREEMENT. + +Under STMicroelectronics’ intellectual property rights, the redistribution, reproduction and use in source and binary forms of the software or any part thereof, with or without modification, are permitted provided that the following conditions are met: +1. Redistribution of source code (modified or not) must retain any copyright notice, this list of conditions and the disclaimer set forth below as items 10 and 11. +2. Redistributions in binary form, except as embedded into microcontroller or microprocessor device manufactured by or for STMicroelectronics or a software update for such device, must reproduce any copyright notice provided with the binary code, this list of conditions, and the disclaimer set forth below as items 10 and 11, in documentation and/or other materials provided with the distribution. +3. Neither the name of STMicroelectronics nor the names of other contributors to this software may be used to endorse or promote products derived from this software or part thereof without specific written permission. +4. This software or any part thereof, including modifications and/or derivative works of this software, must be used and execute solely and exclusively on or in combination with a microcontroller or microprocessor device manufactured by or for STMicroelectronics. +5. No use, reproduction or redistribution of this software partially or totally may be done in any manner that would subject this software to any Open Source Terms. “Open Source Terms” shall mean any open source license which requires as part of distribution of software that the source code of such software is distributed therewith or otherwise made available, or open source license that substantially complies with the Open Source definition specified at www.opensource.org and any other comparable open source license such as for example GNU General Public License (GPL), Eclipse Public License (EPL), Apache Software License, BSD license or MIT license. +6. STMicroelectronics has no obligation to provide any maintenance, support or updates for the software. +7. The software is and will remain the exclusive property of STMicroelectronics and its licensors. The recipient will not take any action that jeopardizes STMicroelectronics and its licensors' proprietary rights or acquire any rights in the software, except the limited rights specified hereunder. +8. The recipient shall comply with all applicable laws and regulations affecting the use of the software or any part thereof including any applicable export control law or regulation. +9. Redistribution and use of this software or any part thereof other than as permitted under this license is void and will automatically terminate your rights under this license. +10. THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS, WHICH ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +11. EXCEPT AS EXPRESSLY PERMITTED HEREUNDER, NO LICENSE OR OTHER RIGHTS, WHETHER EXPRESS OR IMPLIED, ARE GRANTED UNDER ANY PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF STMICROELECTRONICS OR ANY THIRD PARTY. + + diff --git a/meta-arm-bsp/documentation/a5ds.md b/meta-arm-bsp/documentation/corstone500.md similarity index 67% rename from meta-arm-bsp/documentation/a5ds.md rename to meta-arm-bsp/documentation/corstone500.md index 38c719a8..92f8a984 100644 --- a/meta-arm-bsp/documentation/a5ds.md +++ b/meta-arm-bsp/documentation/corstone500.md @@ -1,19 +1,19 @@ -# Cortex-A5 DesignStart A5DS Platform Support in meta-arm-bsp +# Corstone-500 Platform Support in meta-arm-bsp ## Howto Build and Run ### Configuration: In the local.conf file, MACHINE should be set as follow: -MACHINE ?= "a5ds" -DISTRO ?= "iota-tiny" +MACHINE ?= "corstone500" +DISTRO ?= "poky-tiny" Or set environment variables with that values: -MACHINE "a5ds" -DISTRO "iota-tiny" +MACHINE "corstone500" +DISTRO "poky-tiny" ### Build: -``bash$ bitbake iota-tiny-image``` +``bash$ bitbake arm-reference-image``` ### Run: To run the result in a Fixed Virtual Platform please get: diff --git a/meta-arm-bsp/documentation/corstone700.md b/meta-arm-bsp/documentation/corstone700.md new file mode 100644 index 00000000..6a5fe0f5 --- /dev/null +++ b/meta-arm-bsp/documentation/corstone700.md @@ -0,0 +1,21 @@ +# Corstone-700 + +## Overview + +Corstone-700 is a flexible compute architecture combining Cortex-A and Cortex-M +processors and a secure enclave, aimed at building secure IoT SoCs. There are +machines for both Corstone-700 for Fixed Virtual Platform (`corstone700-fvp`) +and Corstone-700 for MPS3 FPGA (`corstone700-mps3`). + +Further details are available in the [User Guide]. + +## Building + +Corstone-700 is tested in 'tiny' configurations, such as `DISTRO="poky-tiny"`. + +## Running + +For detailed instructions as to how to run the image in a FVP model, or on the +MPS3 board, see the [User Guide]. + +[User Guide]: https://git.linaro.org/landing-teams/working/arm/arm-reference-platforms.git/about/docs/corstone-700/user-guide.rst diff --git a/meta-arm-bsp/documentation/foundation-armv8.md b/meta-arm-bsp/documentation/foundation-armv8.md deleted file mode 100644 index dacdce38..00000000 --- a/meta-arm-bsp/documentation/foundation-armv8.md +++ /dev/null @@ -1,51 +0,0 @@ -# Armv8-A Base Platform Support in meta-arm-bsp - -## Howto Build and Run - -### Configuration: -In the local.conf file, MACHINE should be set as follow: -MACHINE ?= "foundation-v8" - -### Build: -```bash$ bitbake core-image-minimal``` - -### Run: -To Run the Fixed Virtual Platform simulation tool you must download "Armv8-A -Foundation Platform" from Arm developer (This might require the user to -register) from this address: -https://developer.arm.com/tools-and-software/simulation-models/fixed-virtual-platforms -and install it on your host PC. - -Fast Models Fixed Virtual Platforms (FVP) Reference Guide: -https://developer.arm.com/docs/100966/latest - -Armv8‑A Foundation Platform User Guide: -https://developer.arm.com/docs/100961/latest/ - - -Once done, do the following to build and run an image: -```bash$ bitbake core-image-minimal``` -```bash$ export YOCTO_DEPLOY_IMGS_DIR=""``` -```bash$ cd ``` -``` -bash$ ./Foundation_Platform --cores=4 --no-sve --gicv3 \ - --data=${YOCTO_DEPLOY_IMGS_DIR}/bl1-fvp.bin@0x0 \ - --data=${YOCTO_DEPLOY_IMGS_DIR}/fip-fvp.bin@0x8000000 \ - --data=${YOCTO_DEPLOY_IMGS_DIR}/Image@0x80080000 \ - --data=${YOCTO_DEPLOY_IMGS_DIR}/foundation-v8-gicv3-psci.dtb@0x83000000 \ - --block-device=${YOCTO_DEPLOY_IMGS_DIR}/core-image-minimal-foundation-armv8.disk.img -``` - -If you have built a configuration without a ramdisk, you can use the following -command in U-boot to start Linux: -```VExpress64# booti 0x80080000 - 0x83000000``` - -## Devices supported in the kernel -- serial -- virtio disk -- network -- watchdog -- rtc - -## Devices not supported or not functional -None diff --git a/meta-arm-bsp/documentation/n1sdp.md b/meta-arm-bsp/documentation/n1sdp.md new file mode 100644 index 00000000..d8661a5c --- /dev/null +++ b/meta-arm-bsp/documentation/n1sdp.md @@ -0,0 +1,78 @@ +# N1SDP Development Platform Support in meta-arm-bsp + +## Overview +The N1SDP provides access to the Arm Neoverse N1 SoC. The N1SDP enables software development for key enterprise technology +and general Arm software development. The N1SDP consists of the N1 board containing the N1 SoC. +The N1 SoC contains two dual-core Arm Neoverse N1 processor clusters. + +The system demonstrates Arm technology in the context of Cache-Coherent Interconnect for Accelerators (CCIX) protocol by: + +- Running coherent traffic between the N1 SoC and an accelerator card. +- Coherent communication between two N1 SoCs. +- Enabling development of CCIX-enabled FPGA accelerators. + +Further information on N1SDP can be found at +https://community.arm.com/developer/tools-software/oss-platforms/w/docs/458/neoverse-n1-sdp + +## Configuration: +In the local.conf file, MACHINE should be set as follow: +MACHINE ?= "n1sdp" + +## Building +```bash$ bitbake core-image-minimal``` + +## Running + +# Update Firmware on SD card: + +(*) To use n1sdp board in single chip mode, flash: + n1sdp-board-firmware_primary.tar.gz firmware. + +(*) To use n1sdp board in multi chip mode, flash: + n1sdp-board-firmware_primary.tar.gz firmware to primary board, + n1sdp-board-firmware_secondary.tar.gz firmware to secondary board. + +The SD card content is generated during the build here: + tmp/deploy/images/n1sdp/n1sdp-board-firmware_primary.tar.gz + tmp/deploy/images/n1sdp/n1sdp-board-firmware_secondary.tar.gz + + +Its content must be written on the N1SDP firmware SD card. +To do this: +- insert the sdcard of the N1SDP in an SD card reader and mount it: +```bash$ sudo mount /dev/sdx1 /mnt``` +(replace sdx by the device of the SD card) + +- erase its content and put the new one: +```bash$ sudo rm -rf /mnt/*``` +```bash$ sudo tar --no-same-owner -xzf tmp/deploy/images/n1sdp/n1sdp-board-firmware_primary.tar.gz -C /mnt/``` +```bash$ sudo umount /mnt``` + +- reinsert the SD card in the N1SDP board + +Firmware tarball contains iofpga configuration files, scp and uefi binaries. + +**NOTE**: +If the N1SDP board was manufactured after November 2019 (Serial Number greater +than 36253xxx), a different PMIC firmware image must be used to prevent +potential damage to the board. More details can be found in [1]. +The `MB/HBI0316A/io_v123f.txt` file located in the microSD needs to be updated. +To update it, set the PMIC image (300k_8c2.bin) to be used in the newer models +by running the following commands on your host PC: + + $ sudo umount /dev/sdx1 + $ sudo mount /dev/sdx1 /mnt + $ sudo sed -i '/^MBPMIC: pms_0V85.bin/s/^/;/g' /mnt/MB/HBI0316A/io_v123f.txt + $ sudo sed -i '/^;MBPMIC: 300k_8c2.bin/s/^;//g' /mnt/MB/HBI0316A/io_v123f.txt + $ sudo umount /mnt + +# Prepare an USB hard drive: + +Grub boot partition is placed on first partition of the *.wic image, +Linux root file system is placed on the second partition of the *.wic image: + tmp/deploy/images/n1sdp/core-image-minimal-n1sdp.wic + +This *.wic image should be copied to USB stick with simple dd call. + + +[1]: https://community.arm.com/developer/tools-software/oss-platforms/w/docs/604/notice-potential-damage-to-n1sdp-boards-if-using-latest-firmware-release diff --git a/meta-arm-bsp/documentation/tc0.md b/meta-arm-bsp/documentation/tc0.md index 694e0675..9ea4f7c2 100644 --- a/meta-arm-bsp/documentation/tc0.md +++ b/meta-arm-bsp/documentation/tc0.md @@ -15,9 +15,12 @@ https://git.linaro.org/landing-teams/working/arm/arm-reference-platforms.git/tre In the local.conf file, MACHINE should be set as follows: MACHINE = "tc0" -To build the required binaries for tc0, run the commmand for the required image, -for e.g for core-image-minimal: -```bash$ bitbake core-image-minimal``` +To build the required binaries for tc0, run the commmand: +```bash$ bitbake tc0-artifacts-image``` + +Trusted-firmware-a is the final component to be built with the rest of the +components dependent of it, therefore building tc0-artifacts-image which depends +on trusted-firmware-a will build all the required binaries. ## Running To run the produced binaries in a TC0 Fixed Virtual Platform please get diff --git a/meta-arm-bsp/recipes-bsp/boot-firmware/boot-firmware_git.bb b/meta-arm-bsp/recipes-bsp/boot-firmware/boot-firmware_git.bb new file mode 100644 index 00000000..c7242d19 --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/boot-firmware/boot-firmware_git.bb @@ -0,0 +1,61 @@ +SUMMARY = "Boot Processor firmware for Corstone700" +DESCRIPTION = "Boot Processor firmware" + +LICENSE = "BSD-3-Clause & Apache-2.0" +LIC_FILES_CHKSUM = "file://license.md;md5=e44b2531cd6ffe9dece394dbe988d9a0 \ + file://cmsis/LICENSE.txt;md5=e3fc50a88d0a364313df4b21ef20c29e" + +SRC_URI = "gitsm://git.linaro.org/landing-teams/working/arm/boot-firmware.git;protocol=https" +SRCREV = "af7eeb1bb8c5a85a5e5a76d48acc6fe864d715a9" +PV = "2020.02.10+git${SRCPV}" + +PROVIDES += "virtual/control-processor-firmware" + +DEPENDS = "virtual/arm-none-eabi-gcc-native virtual/trusted-firmware-a" + +inherit deploy + +B = "${WORKDIR}/build" +S = "${WORKDIR}/git" + +PACKAGE_ARCH = "${MACHINE_ARCH}" +COMPATIBLE_MACHINE = "(corstone700-*)" +SCP_PLATFORM = "corstone-700" + +LDFLAGS[unexport] = "1" + +do_configure[noexec] = "1" + +EXTRA_OEMAKE = "PRODUCT='${SCP_PLATFORM}' \ + BUILD_PATH=${B} \ + CROSS_COMPILE='arm-none-eabi-' \ + V=y \ + " + +do_compile() { + oe_runmake -C ${S}/tools/spitoc CC=${BUILD_CC} all + oe_runmake -C ${S} +} +do_compile[cleandirs] += "${B}" + +do_install() { + install -D -p -m 0644 ${B}/product/${SCP_PLATFORM}/se_ramfw/release/bin/firmware.bin ${D}/firmware/se_ramfw.bin + install -D -p -m 0644 ${B}/product/${SCP_PLATFORM}/se_romfw/release/bin/firmware.bin ${D}/firmware/se_romfw.bin + ${S}/tools/spitoc/spitoc \ + --seram ${D}/firmware/se_ramfw.bin \ + --offset 1 \ + --fip ${RECIPE_SYSROOT}/firmware/fip.bin-${TFA_PLATFORM} \ + --offset 33 \ + --out ${D}/firmware/spitoc.bin +} + +FILES_${PN} = "/firmware" +SYSROOT_DIRS += "/firmware" +# Skip QA check for relocations in .text of elf binaries +INSANE_SKIP_${PN} = "textrel" + +do_deploy() { + # Copy the images to deploy directory + cp -rf ${D}/firmware/* ${DEPLOYDIR}/ +} +addtask deploy after do_install diff --git a/meta-arm-bsp/recipes-bsp/external-system/external-system_0.1.0.bb b/meta-arm-bsp/recipes-bsp/external-system/external-system_0.1.0.bb index 84da7ceb..a8052c6e 100644 --- a/meta-arm-bsp/recipes-bsp/external-system/external-system_0.1.0.bb +++ b/meta-arm-bsp/recipes-bsp/external-system/external-system_0.1.0.bb @@ -2,7 +2,7 @@ SUMMARY = "External system Cortex-M3 Firmware" DESCRIPTION = "Firmware to be loaded and run in External System Harness in\ support to the main application CPU." HOMEPAGE = "https://git.linaro.org/landing-teams/working/arm/external-system.git" -DEPENDS = "coreutils-native gcc-arm-none-eabi-native" +DEPENDS = "gcc-arm-none-eabi-native" LICENSE = "BSD-3-Clause" LIC_FILES_CHKSUM = "file://license.md;md5=e44b2531cd6ffe9dece394dbe988d9a0" diff --git a/meta-arm-bsp/recipes-bsp/hafnium/files/tc0/0001-Revert-FFA-Set-and-verify-allocator-of-memory-handle.patch b/meta-arm-bsp/recipes-bsp/hafnium/files/tc0/0001-Revert-FFA-Set-and-verify-allocator-of-memory-handle.patch new file mode 100644 index 00000000..dcf7725d --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/hafnium/files/tc0/0001-Revert-FFA-Set-and-verify-allocator-of-memory-handle.patch @@ -0,0 +1,256 @@ +From 7a8b0d634b23e77bb6c84f1b34c5cc031aa8c105 Mon Sep 17 00:00:00 2001 +From: Arunachalam Ganapathy +Date: Mon, 12 Apr 2021 10:08:29 +0100 +Subject: [PATCH 1/3] Revert "FFA: Set and verify allocator of memory handle" + +This reverts commit 917d2f2dc46b20625156e9067329e04c7fec587d. +Reverting this commit enables memory sharing between SPs + +Upstream-Status: Inappropriate [will not be submitted as its only required for ACK 5.4] +--- + inc/hf/arch/ffa_memory_handle.h | 25 ---------------- + inc/vmapi/hf/ffa.h | 14 ++++----- + src/api.c | 4 +-- + src/arch/aarch64/hypervisor/BUILD.gn | 1 - + .../aarch64/hypervisor/ffa_memory_handle.c | 29 ------------------- + src/arch/fake/hypervisor/BUILD.gn | 1 - + src/arch/fake/hypervisor/ffa_memory_handle.c | 20 ------------- + src/ffa_memory.c | 19 ++++-------- + 8 files changed, 14 insertions(+), 99 deletions(-) + delete mode 100644 inc/hf/arch/ffa_memory_handle.h + delete mode 100644 src/arch/aarch64/hypervisor/ffa_memory_handle.c + delete mode 100644 src/arch/fake/hypervisor/ffa_memory_handle.c + +diff --git a/inc/hf/arch/ffa_memory_handle.h b/inc/hf/arch/ffa_memory_handle.h +deleted file mode 100644 +index 9eba5d4..0000000 +--- a/inc/hf/arch/ffa_memory_handle.h ++++ /dev/null +@@ -1,25 +0,0 @@ +-/* +- * Copyright 2021 The Hafnium Authors. +- * +- * Use of this source code is governed by a BSD-style +- * license that can be found in the LICENSE file or at +- * https://opensource.org/licenses/BSD-3-Clause. +- */ +- +-#ifndef FFA_MEMORY_HANDLE_H +-#define FFA_MEMORY_HANDLE_H +- +-#include "hf/ffa.h" +- +-/** +- * Encodes memory handle according to section 5.10.2 of the FF-A v1.0 spec. +- */ +-ffa_memory_handle_t ffa_memory_handle_make(uint64_t index); +- +-/** +- * Checks whether given handle was allocated by current world, according to +- * handle encoding rules. +- */ +-bool ffa_memory_handle_allocated_by_current_world(ffa_memory_handle_t handle); +- +-#endif +diff --git a/inc/vmapi/hf/ffa.h b/inc/vmapi/hf/ffa.h +index a79f2eb..a948930 100644 +--- a/inc/vmapi/hf/ffa.h ++++ b/inc/vmapi/hf/ffa.h +@@ -189,23 +189,21 @@ ATTR_FUNCTION_SET(memory_shareability, ffa_memory_attributes_t, + ATTR_FUNCTION_GET(memory_shareability, ffa_memory_attributes_t, + FFA_MEMORY_SHAREABILITY_OFFSET, FFA_MEMORY_SHAREABILITY_MASK) + +-/** +- * A globally-unique ID assigned by the hypervisor for a region of memory being +- * sent between VMs. +- */ +-typedef uint64_t ffa_memory_handle_t; +- + #define FFA_MEMORY_HANDLE_ALLOCATOR_MASK \ + ((ffa_memory_handle_t)(UINT64_C(1) << 63)) + #define FFA_MEMORY_HANDLE_ALLOCATOR_HYPERVISOR \ + ((ffa_memory_handle_t)(UINT64_C(1) << 63)) +- +-#define FFA_MEMORY_HANDLE_ALLOCATOR_SPMC (UINT64_C(0) << 63) + #define FFA_MEMORY_HANDLE_INVALID (~UINT64_C(0)) + + /** The ID of a VM. These are assigned sequentially starting with an offset. */ + typedef uint16_t ffa_vm_id_t; + ++/** ++ * A globally-unique ID assigned by the hypervisor for a region of memory being ++ * sent between VMs. ++ */ ++typedef uint64_t ffa_memory_handle_t; ++ + /** + * A count of VMs. This has the same range as the VM IDs but we give it a + * different name to make the different semantics clear. +diff --git a/src/api.c b/src/api.c +index fa5c9b7..16626b6 100644 +--- a/src/api.c ++++ b/src/api.c +@@ -9,7 +9,6 @@ + #include "hf/api.h" + + #include "hf/arch/cpu.h" +-#include "hf/arch/ffa_memory_handle.h" + #include "hf/arch/mm.h" + #include "hf/arch/other_world.h" + #include "hf/arch/timer.h" +@@ -2158,7 +2157,8 @@ struct ffa_value api_ffa_mem_reclaim(ffa_memory_handle_t handle, + struct vm *to = current->vm; + struct ffa_value ret; + +- if (ffa_memory_handle_allocated_by_current_world(handle)) { ++ if ((handle & FFA_MEMORY_HANDLE_ALLOCATOR_MASK) == ++ FFA_MEMORY_HANDLE_ALLOCATOR_HYPERVISOR) { + struct vm_locked to_locked = vm_lock(to); + + ret = ffa_memory_reclaim(to_locked, handle, flags, +diff --git a/src/arch/aarch64/hypervisor/BUILD.gn b/src/arch/aarch64/hypervisor/BUILD.gn +index 8f57598..0f9c15e 100644 +--- a/src/arch/aarch64/hypervisor/BUILD.gn ++++ b/src/arch/aarch64/hypervisor/BUILD.gn +@@ -17,7 +17,6 @@ offset_size_header("offsets") { + source_set("other_world") { + public_configs = [ "//src/arch/aarch64:config" ] + sources = [ +- "ffa_memory_handle.c", + "other_world.c", + ] + deps = [ +diff --git a/src/arch/aarch64/hypervisor/ffa_memory_handle.c b/src/arch/aarch64/hypervisor/ffa_memory_handle.c +deleted file mode 100644 +index 647186d..0000000 +--- a/src/arch/aarch64/hypervisor/ffa_memory_handle.c ++++ /dev/null +@@ -1,29 +0,0 @@ +-/* +- * Copyright 2021 The Hafnium Authors. +- * +- * Use of this source code is governed by a BSD-style +- * license that can be found in the LICENSE file or at +- * https://opensource.org/licenses/BSD-3-Clause. +- */ +- +-#include "hf/arch/ffa_memory_handle.h" +- +-ffa_memory_handle_t ffa_memory_handle_make(uint64_t index) +-{ +-#if SECURE_WORLD == 1 +- return (index & ~FFA_MEMORY_HANDLE_ALLOCATOR_MASK) | +- FFA_MEMORY_HANDLE_ALLOCATOR_SPMC; +-#else +- return index | FFA_MEMORY_HANDLE_ALLOCATOR_HYPERVISOR; +-#endif +-} +- +-bool ffa_memory_handle_allocated_by_current_world(ffa_memory_handle_t handle) +-{ +- return (handle & FFA_MEMORY_HANDLE_ALLOCATOR_MASK) == +-#if SECURE_WORLD == 1 +- FFA_MEMORY_HANDLE_ALLOCATOR_SPMC; +-#else +- FFA_MEMORY_HANDLE_ALLOCATOR_HYPERVISOR; +-#endif +-} +diff --git a/src/arch/fake/hypervisor/BUILD.gn b/src/arch/fake/hypervisor/BUILD.gn +index 8f28802..97a82f6 100644 +--- a/src/arch/fake/hypervisor/BUILD.gn ++++ b/src/arch/fake/hypervisor/BUILD.gn +@@ -16,7 +16,6 @@ source_set("hypervisor") { + + source_set("other_world") { + sources = [ +- "ffa_memory_handle.c", + "other_world.c", + ] + } +diff --git a/src/arch/fake/hypervisor/ffa_memory_handle.c b/src/arch/fake/hypervisor/ffa_memory_handle.c +deleted file mode 100644 +index 9091295..0000000 +--- a/src/arch/fake/hypervisor/ffa_memory_handle.c ++++ /dev/null +@@ -1,20 +0,0 @@ +-/* +- * Copyright 2021 The Hafnium Authors. +- * +- * Use of this source code is governed by a BSD-style +- * license that can be found in the LICENSE file or at +- * https://opensource.org/licenses/BSD-3-Clause. +- */ +- +-#include "hf/arch/ffa_memory_handle.h" +- +-ffa_memory_handle_t ffa_memory_handle_make(uint64_t index) +-{ +- return index; +-} +- +-bool ffa_memory_handle_allocated_by_current_world(ffa_memory_handle_t handle) +-{ +- (void)handle; +- return true; +-} +diff --git a/src/ffa_memory.c b/src/ffa_memory.c +index 8b28191..00ec68c 100644 +--- a/src/ffa_memory.c ++++ b/src/ffa_memory.c +@@ -8,7 +8,6 @@ + + #include "hf/ffa_memory.h" + +-#include "hf/arch/ffa_memory_handle.h" + #include "hf/arch/other_world.h" + + #include "hf/api.h" +@@ -121,14 +120,6 @@ static struct ffa_memory_share_state share_states[MAX_MEM_SHARES]; + alignas(PAGE_SIZE) static uint8_t + tee_retrieve_buffer[HF_MAILBOX_SIZE * MAX_FRAGMENTS]; + +-/** +- * Extracts the index from a memory handle allocated by Hafnium's current world. +- */ +-uint64_t ffa_memory_handle_get_index(ffa_memory_handle_t handle) +-{ +- return handle & ~FFA_MEMORY_HANDLE_ALLOCATOR_MASK; +-} +- + /** + * Initialises the next available `struct ffa_memory_share_state` and sets + * `share_state_ret` to a pointer to it. If `handle` is +@@ -159,7 +150,8 @@ static bool allocate_share_state( + + if (handle == FFA_MEMORY_HANDLE_INVALID) { + memory_region->handle = +- ffa_memory_handle_make(i); ++ i | ++ FFA_MEMORY_HANDLE_ALLOCATOR_HYPERVISOR; + } else { + memory_region->handle = handle; + } +@@ -213,7 +205,7 @@ static bool get_share_state(struct share_states_locked share_states, + struct ffa_memory_share_state **share_state_ret) + { + struct ffa_memory_share_state *share_state; +- uint64_t index; ++ uint32_t index; + + CHECK(share_states.share_states != NULL); + CHECK(share_state_ret != NULL); +@@ -222,8 +214,9 @@ static bool get_share_state(struct share_states_locked share_states, + * First look for a share_state allocated by us, in which case the + * handle is based on the index. + */ +- if (ffa_memory_handle_allocated_by_current_world(handle)) { +- index = ffa_memory_handle_get_index(handle); ++ if ((handle & FFA_MEMORY_HANDLE_ALLOCATOR_MASK) == ++ FFA_MEMORY_HANDLE_ALLOCATOR_HYPERVISOR) { ++ index = handle & ~FFA_MEMORY_HANDLE_ALLOCATOR_MASK; + if (index < MAX_MEM_SHARES) { + share_state = &share_states.share_states[index]; + if (share_state->share_func != 0) { +-- +2.29.2 + diff --git a/meta-arm-bsp/recipes-bsp/hafnium/files/tc0/0002-FF-A-Fix-to-fetch-proper-vCPU-index-for-UP-SP.patch b/meta-arm-bsp/recipes-bsp/hafnium/files/tc0/0002-FF-A-Fix-to-fetch-proper-vCPU-index-for-UP-SP.patch new file mode 100644 index 00000000..894bb001 --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/hafnium/files/tc0/0002-FF-A-Fix-to-fetch-proper-vCPU-index-for-UP-SP.patch @@ -0,0 +1,99 @@ +From f080a6ae839b48188131648363c9e050f496f205 Mon Sep 17 00:00:00 2001 +From: Arunachalam Ganapathy +Date: Mon, 12 Apr 2021 10:22:26 +0100 +Subject: [PATCH 3/3] FF-A: Fix to fetch proper vCPU index for UP SP + +When switching the context between SPs, fetch the vCPU index using +api_vm_get_vcpu() helper routine. This routine gets the vCPU at index 0 +for UP SP. + +Rename function api_ffa_msg_send_direct_get_receiver_vcpu() to +api_vm_get_vcpu() as it is used both in direct message request +and response. + +Signed-off-by: Arunachalam Ganapathy +Change-Id: I45a60427f8c2d1b5058443536d972495728ee0c2 +Upstream-Status: Pending [Not submitted to upstream yet] +--- + src/api.c | 44 +++++++++++++++++++++----------------------- + 1 file changed, 21 insertions(+), 23 deletions(-) + +diff --git a/src/api.c b/src/api.c +index 16626b6..4c8034e 100644 +--- a/src/api.c ++++ b/src/api.c +@@ -63,6 +63,25 @@ void api_init(struct mpool *ppool) + mpool_init_from(&api_page_pool, ppool); + } + ++/** ++ * Get target VM vCPU. ++ * If VM is UP then return first vCPU. ++ * If VM is MP then return vCPU whose index matches current CPU index. ++ */ ++static struct vcpu *api_vm_get_vcpu(struct vm *vm, struct vcpu *current) ++{ ++ ffa_vcpu_index_t current_cpu_index = cpu_index(current->cpu); ++ struct vcpu *vcpu = NULL; ++ ++ if (vm->vcpu_count == 1) { ++ vcpu = vm_get_vcpu(vm, 0); ++ } else if (current_cpu_index < vm->vcpu_count) { ++ vcpu = vm_get_vcpu(vm, current_cpu_index); ++ } ++ ++ return vcpu; ++} ++ + /** + * Switches the physical CPU back to the corresponding vCPU of the VM whose ID + * is given as argument of the function. +@@ -80,7 +99,7 @@ static struct vcpu *api_switch_to_vm(struct vcpu *current, + ffa_vm_id_t to_id) + { + struct vm *to_vm = vm_find(to_id); +- struct vcpu *next = vm_get_vcpu(to_vm, cpu_index(current->cpu)); ++ struct vcpu *next = api_vm_get_vcpu(to_vm, current); + + CHECK(next != NULL); + +@@ -1630,26 +1649,6 @@ struct ffa_value api_ffa_features(uint32_t function_id) + } + } + +-/** +- * Get target VM vCPU for direct messaging request. +- * If VM is UP then return first vCPU. +- * If VM is MP then return vCPU whose index matches current CPU index. +- */ +-static struct vcpu *api_ffa_msg_send_direct_get_receiver_vcpu( +- struct vm *vm, struct vcpu *current) +-{ +- ffa_vcpu_index_t current_cpu_index = cpu_index(current->cpu); +- struct vcpu *vcpu = NULL; +- +- if (vm->vcpu_count == 1) { +- vcpu = vm_get_vcpu(vm, 0); +- } else if (current_cpu_index < vm->vcpu_count) { +- vcpu = vm_get_vcpu(vm, current_cpu_index); +- } +- +- return vcpu; +-} +- + /** + * FF-A specification states that x2/w2 Must Be Zero for direct messaging + * interfaces. +@@ -1733,8 +1732,7 @@ struct ffa_value api_ffa_msg_send_direct_req(ffa_vm_id_t sender_vm_id, + * number of PEs in the system. It further states that MP partitions + * accepting direct request messages cannot migrate. + */ +- receiver_vcpu = +- api_ffa_msg_send_direct_get_receiver_vcpu(receiver_vm, current); ++ receiver_vcpu = api_vm_get_vcpu(receiver_vm, current); + if (receiver_vcpu == NULL) { + return ffa_error(FFA_INVALID_PARAMETERS); + } +-- +2.29.2 + diff --git a/meta-arm-bsp/recipes-bsp/hafnium/files/tc0/0003-tc0-Theodul-GICR-changes.patch b/meta-arm-bsp/recipes-bsp/hafnium/files/tc0/0003-tc0-Theodul-GICR-changes.patch new file mode 100644 index 00000000..d3bb76b1 --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/hafnium/files/tc0/0003-tc0-Theodul-GICR-changes.patch @@ -0,0 +1,32 @@ +From fd177558a1da73fa7e10f8b2997864bb76d66dc8 Mon Sep 17 00:00:00 2001 +From: Arunachalam Ganapathy +Date: Thu, 15 Apr 2021 10:46:33 +0100 +Subject: [PATCH] tc0: Add Theodul DSU support and GICR changes + +Signed-off-by: Arunachalam Ganapathy +Change-Id: I4a9b7e4350410fdacccd8c12ff03a61b7e64e98b +Upstream-Status: Pending [Not submitted to upstream yet] +--- + project/reference/BUILD.gn | 4 ++-- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/project/reference/BUILD.gn b/project/reference/BUILD.gn +index 5596009..ffcaab7 100644 +--- a/project/reference/BUILD.gn ++++ b/project/reference/BUILD.gn +@@ -160,9 +160,9 @@ aarch64_toolchains("secure_tc0") { + iommu = "//src/iommu:absent" + gic_version = 3 + gicd_base_address = "0x30000000" +- gicr_base_address = "0x30140000" +- heap_pages = 60 +- max_cpus = 4 ++ gicr_base_address = "0x30080000" ++ heap_pages = 80 ++ max_cpus = 8 + max_vms = 16 + toolchain_args = { + plat_psci = "//src/arch/aarch64/plat/psci:spmc" +-- +2.29.2 + diff --git a/meta-arm-bsp/recipes-bsp/hafnium/hafnium-tc0.inc b/meta-arm-bsp/recipes-bsp/hafnium/hafnium-tc0.inc new file mode 100644 index 00000000..e7eed112 --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/hafnium/hafnium-tc0.inc @@ -0,0 +1,19 @@ +# TC0 specific configuration + +# Intermediate SHA with 2.4 baseline version, required for OP-TEE SEL1 support +SRCREV = "2904b2c5361f06d35c324f37d2e71e3278d351a7" +PV = "2.4+git${SRCPV}" + +FILESEXTRAPATHS_prepend_tc0 := "${THISDIR}/files/tc0:" + +SRC_URI_append = " \ + file://0001-Revert-FFA-Set-and-verify-allocator-of-memory-handle.patch \ + file://0002-FF-A-Fix-to-fetch-proper-vCPU-index-for-UP-SP.patch \ + file://0003-tc0-Theodul-GICR-changes.patch \ + " + +COMPATIBLE_MACHINE = "tc0" + +HAFNIUM_PROJECT = "reference" +HAFNIUM_PLATFORM = "secure_tc0" +HAFNIUM_INSTALL_TARGET = "hafnium" diff --git a/meta-arm-bsp/recipes-bsp/hafnium/hafnium_2.4.bbappend b/meta-arm-bsp/recipes-bsp/hafnium/hafnium_2.4.bbappend new file mode 100644 index 00000000..a6e6874d --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/hafnium/hafnium_2.4.bbappend @@ -0,0 +1,6 @@ +# Machine specific configurations + +MACHINE_HAFNIUM_REQUIRE ?= "" +MACHINE_HAFNIUM_REQUIRE_tc0 = "hafnium-tc0.inc" + +require ${MACHINE_HAFNIUM_REQUIRE} diff --git a/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/images-r0.txt b/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/images-r0.txt index 286dac74..f6ac5330 100644 --- a/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/images-r0.txt +++ b/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/images-r0.txt @@ -23,14 +23,14 @@ NOR2LOAD: 00000000 ;Image Load Address NOR2ENTRY: 00000000 ;Image Entry Point NOR3UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR3ADDRESS: 0x02700000 ;Image Flash Address +NOR3ADDRESS: 0x02900000 ;Image Flash Address NOR3FILE: \SOFTWARE\juno.dtb ;Image File Name NOR3NAME: board.dtb ;Specify target filename to preserve file extension NOR3LOAD: 00000000 ;Image Load Address NOR3ENTRY: 00000000 ;Image Entry Point NOR4UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR4ADDRESS: 0x025C0000 ;Image Flash Address +NOR4ADDRESS: 0x029C0000 ;Image Flash Address NOR4FILE: \SOFTWARE\hdlcdclk.dat ;Image File Name NOR4LOAD: 00000000 ;Image Load Address NOR4ENTRY: 00000000 ;Image Entry Point @@ -56,13 +56,13 @@ NOR7LOAD: 00000000 ;Image Load Address NOR7ENTRY: 00000000 ;Image Entry Point NOR8UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR8ADDRESS: 0x02600000 ;Image Flash Address +NOR8ADDRESS: 0x02A00000 ;Image Flash Address NOR8FILE: \SOFTWARE\selftest ;Image File Name NOR8LOAD: 00000000 ;Image Load Address NOR8ENTRY: 00000000 ;Image Entry Point NOR9UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR9ADDRESS: 0x02780000 ;Image Flash Address +NOR9ADDRESS: 0x02A80000 ;Image Flash Address NOR9NAME: uEnv.txt NOR9FILE: \SOFTWARE\uEnv.txt ;Image File Name NOR9LOAD: 00000000 ;Image Load Address diff --git a/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/images-r1.txt b/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/images-r1.txt index f84caaf9..a6291da2 100644 --- a/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/images-r1.txt +++ b/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/images-r1.txt @@ -23,14 +23,14 @@ NOR2LOAD: 00000000 ;Image Load Address NOR2ENTRY: 00000000 ;Image Entry Point NOR3UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR3ADDRESS: 0x02700000 ;Image Flash Address +NOR3ADDRESS: 0x02900000 ;Image Flash Address NOR3FILE: \SOFTWARE\juno-r1.dtb ;Image File Name NOR3NAME: board.dtb ;Specify target filename to preserve file extension NOR3LOAD: 00000000 ;Image Load Address NOR3ENTRY: 00000000 ;Image Entry Point NOR4UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR4ADDRESS: 0x025C0000 ;Image Flash Address +NOR4ADDRESS: 0x029C0000 ;Image Flash Address NOR4FILE: \SOFTWARE\hdlcdclk.dat ;Image File Name NOR4LOAD: 00000000 ;Image Load Address NOR4ENTRY: 00000000 ;Image Entry Point @@ -56,13 +56,13 @@ NOR7LOAD: 00000000 ;Image Load Address NOR7ENTRY: 00000000 ;Image Entry Point NOR8UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR8ADDRESS: 0x02600000 ;Image Flash Address +NOR8ADDRESS: 0x02A00000 ;Image Flash Address NOR8FILE: \SOFTWARE\selftest ;Image File Name NOR8LOAD: 00000000 ;Image Load Address NOR8ENTRY: 00000000 ;Image Entry Point NOR9UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR9ADDRESS: 0x02780000 ;Image Flash Address +NOR9ADDRESS: 0x02A80000 ;Image Flash Address NOR9NAME: uEnv.txt NOR9FILE: \SOFTWARE\uEnv.txt ;Image File Name NOR9LOAD: 00000000 ;Image Load Address diff --git a/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/images-r2.txt b/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/images-r2.txt index 149e0c4c..16a6a5fe 100644 --- a/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/images-r2.txt +++ b/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/images-r2.txt @@ -23,14 +23,14 @@ NOR2LOAD: 00000000 ;Image Load Address NOR2ENTRY: 00000000 ;Image Entry Point NOR3UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR3ADDRESS: 0x02700000 ;Image Flash Address +NOR3ADDRESS: 0x02900000 ;Image Flash Address NOR3FILE: \SOFTWARE\juno-r2.dtb ;Image File Name NOR3NAME: board.dtb ;Specify target filename to preserve file extension NOR3LOAD: 00000000 ;Image Load Address NOR3ENTRY: 00000000 ;Image Entry Point NOR4UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR4ADDRESS: 0x025C0000 ;Image Flash Address +NOR4ADDRESS: 0x029C0000 ;Image Flash Address NOR4FILE: \SOFTWARE\hdlcdclk.dat ;Image File Name NOR4LOAD: 00000000 ;Image Load Address NOR4ENTRY: 00000000 ;Image Entry Point @@ -56,13 +56,13 @@ NOR7LOAD: 00000000 ;Image Load Address NOR7ENTRY: 00000000 ;Image Entry Point NOR8UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR8ADDRESS: 0x02600000 ;Image Flash Address +NOR8ADDRESS: 0x02A00000 ;Image Flash Address NOR8FILE: \SOFTWARE\selftest ;Image File Name NOR8LOAD: 00000000 ;Image Load Address NOR8ENTRY: 00000000 ;Image Entry Point NOR9UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE -NOR9ADDRESS: 0x02780000 ;Image Flash Address +NOR9ADDRESS: 0x02A80000 ;Image Flash Address NOR9NAME: uEnv.txt NOR9FILE: \SOFTWARE\uEnv.txt ;Image File Name NOR9LOAD: 00000000 ;Image Load Address diff --git a/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/uEnv.txt b/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/uEnv.txt index 93eb5fb0..77c02e36 100644 --- a/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/uEnv.txt +++ b/meta-arm-bsp/recipes-bsp/images/firmware-image-juno/uEnv.txt @@ -1,11 +1,11 @@ uenvcmd=run mybootcmd mybootcmd=echo Loading custom boot command; \ echo Loading kernel; \ -afs load ${kernel_name} ${kernel_addr} ; \ -if test $? -eq 1; then echo Loading ${kernel_alt_name} instead of ${kernel_name}; afs load ${kernel_alt_name} ${kernel_addr}; fi; \ +afs load ${kernel_name} ${kernel_addr_r} ; \ +if test $? -eq 1; then echo Loading ${kernel_alt_name} instead of ${kernel_name}; afs load ${kernel_alt_name} ${kernel_addr_r}; fi; \ echo Loading device tree; \ -afs load ${fdtfile} ${fdt_addr}; \ +afs load ${fdtfile} ${fdt_addr_r}; \ if test $? -eq 1; then echo Loading ${fdt_alt_name} instead of ${fdtfile}; \ -afs load ${fdt_alt_name} ${fdt_addr}; fi; fdt addr ${fdt_addr}; fdt resize; \ -booti ${kernel_addr} - ${fdt_addr}; +afs load ${fdt_alt_name} ${fdt_addr_r}; fi; fdt addr ${fdt_addr_r}; fdt resize; \ +booti ${kernel_addr_r} - ${fdt_addr_r}; diff --git a/meta-arm-bsp/recipes-bsp/images/n1sdp-board-firmware_2020.07.27.bb b/meta-arm-bsp/recipes-bsp/images/n1sdp-board-firmware_2020.07.27.bb new file mode 100644 index 00000000..1551ac99 --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/images/n1sdp-board-firmware_2020.07.27.bb @@ -0,0 +1,34 @@ +SUMMARY = "Board Firmware binaries for N1SDP" +SECTION = "firmware" + +LICENSE = "STM-SLA0044-Rev5" +LIC_FILES_CHKSUM = "file://LICENSES/STM.TXT;md5=4b8dab81d0bfc0a5f63c9a983402705b" + +inherit deploy + +INHIBIT_DEFAULT_DEPS = "1" + +PACKAGE_ARCH = "${MACHINE_ARCH}" +COMPATIBLE_MACHINE = "n1sdp" + +SRC_URI = "https://git.linaro.org/landing-teams/working/arm/n1sdp-board-firmware.git/snapshot/${BPN}-N1SDP-${PV}.tar.gz" +SRC_URI[sha256sum] = "57feba404026f2d6d49c167d63e0e84653ad8b808b13e2244b81fea9e0d58d66" + +S = "${WORKDIR}/${BPN}-N1SDP-${PV}" + +INSTALL_DIR = "/n1sdp-board-firmware_source" + +do_install() { + rm -rf ${S}/SOFTWARE + install -d ${D}${INSTALL_DIR} + cp -Rp --no-preserve=ownership ${S}/* ${D}${INSTALL_DIR} +} + +FILES_${PN} = "${INSTALL_DIR}" +SYSROOT_DIRS += "${INSTALL_DIR}" + +do_deploy() { + install -d ${DEPLOYDIR}${INSTALL_DIR} + cp -Rp --no-preserve=ownership ${S}/* ${DEPLOYDIR}${INSTALL_DIR} +} +addtask deploy after do_install before do_build diff --git a/meta-arm-bsp/recipes-bsp/images/sdcard-image-n1sdp_0.1.bb b/meta-arm-bsp/recipes-bsp/images/sdcard-image-n1sdp_0.1.bb new file mode 100644 index 00000000..0ef68b9b --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/images/sdcard-image-n1sdp_0.1.bb @@ -0,0 +1,80 @@ +SUMMARY = "Firmware image recipe for generating SD-Card artifacts." + +inherit deploy nopackages + +DEPENDS = "virtual/uefi-firmware \ + virtual/control-processor-firmware \ + n1sdp-board-firmware" + +LICENSE = "MIT" +PACKAGE_ARCH = "${MACHINE_ARCH}" +COMPATIBLE_MACHINE = "n1sdp" +RM_WORK_EXCLUDE += "${PN}" +do_configure[noexec] = "1" +do_compile[noexec] = "1" +do_install[noexec] = "1" + +FIRMWARE_DIR = "n1sdp-board-firmware_source" +PRIMARY_DIR = "${WORKDIR}/n1sdp-board-firmware_primary" +SECONDARY_DIR = "${WORKDIR}/n1sdp-board-firmware_secondary" + +SOC_BINARIES = "mcp_fw.bin scp_fw.bin mcp_rom.bin scp_rom.bin" + +prepare_package() { + cd ${WORKDIR} + + # Master/Primary + cp -av ${RECIPE_SYSROOT}/${FIRMWARE_DIR}/* ${PRIMARY_DIR} + mkdir -p ${PRIMARY_DIR}/SOFTWARE/ + + # Copy uefi binary + cp -v ${RECIPE_SYSROOT}/firmware/uefi.bin ${PRIMARY_DIR}/SOFTWARE/ + + # Copy SOC binaries + for f in ${SOC_BINARIES}; do + cp -v ${RECIPE_SYSROOT}/firmware/${f} ${PRIMARY_DIR}/SOFTWARE/ + done + + sed -i -e 's|^C2C_ENABLE.*|C2C_ENABLE: TRUE ;C2C enable TRUE/FALSE|' \ + ${PRIMARY_DIR}/MB/HBI0316A/io_v123f.txt + sed -i -e 's|^C2C_SIDE.*|C2C_SIDE: MASTER ;C2C side SLAVE/MASTER|' \ + ${PRIMARY_DIR}/MB/HBI0316A/io_v123f.txt + sed -i -e 's|.*SOCCON: 0x1170.*PLATFORM_CTRL.*|SOCCON: 0x1170 0x00000100 ;SoC SCC PLATFORM_CTRL|' \ + ${PRIMARY_DIR}/MB/HBI0316A/io_v123f.txt + + # Slave/Secondary + cp -av ${RECIPE_SYSROOT}/${FIRMWARE_DIR}/* ${SECONDARY_DIR} + mkdir -p ${SECONDARY_DIR}/SOFTWARE/ + + # Copy SOC binaries + for f in ${SOC_BINARIES}; do + cp -v ${RECIPE_SYSROOT}/firmware/${f} ${SECONDARY_DIR}/SOFTWARE/ + done + + sed -i -e 's|^C2C_ENABLE.*|C2C_ENABLE: TRUE ;C2C enable TRUE/FALSE|' \ + ${SECONDARY_DIR}/MB/HBI0316A/io_v123f.txt + sed -i -e 's|^C2C_SIDE.*|C2C_SIDE: SLAVE ;C2C side SLAVE/MASTER|' \ + ${SECONDARY_DIR}/MB/HBI0316A/io_v123f.txt + sed -i -e 's|.*SOCCON: 0x1170.*PLATFORM_CTRL.*|SOCCON: 0x1170 0x00000101 ;SoC SCC PLATFORM_CTRL|' \ + ${SECONDARY_DIR}/MB/HBI0316A/io_v123f.txt + sed -i -e '/^TOTALIMAGES:/ s|5|4|' ${SECONDARY_DIR}/MB/HBI0316A/images.txt + sed -i -e 's|^IMAGE4|;&|' ${SECONDARY_DIR}/MB/HBI0316A/images.txt +} + +do_deploy() { + # prepare Master & Slave packages + prepare_package + + for dir in ${PRIMARY_DIR} ${SECONDARY_DIR}; do + dir_name=$(basename ${dir}) + mkdir -p ${D}/${dir_name} + cp -av ${dir} ${D} + + # Compress the files + tar -C ${D}/${dir_name} -zcvf ${DEPLOYDIR}/${dir_name}.tar.gz ./ + done +} +do_deploy[dirs] += "${PRIMARY_DIR} ${SECONDARY_DIR}" +do_deploy[cleandirs] += "${PRIMARY_DIR} ${SECONDARY_DIR}" +do_deploy[umask] = "022" +addtask deploy after do_prepare_recipe_sysroot diff --git a/meta-arm-bsp/recipes-bsp/images/tc0-artifacts-image.bb b/meta-arm-bsp/recipes-bsp/images/tc0-artifacts-image.bb new file mode 100644 index 00000000..43c1edac --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/images/tc0-artifacts-image.bb @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (c) 2020 Arm Limited +# +SUMMARY = "Total Compute Images" +DESCRIPTION = "Build all the images required for Total Compute platform" +LICENSE = "Apache-2.0" + +inherit nopackages + +# The last image to be built is trusted-firmware-a +DEPENDS += " trusted-firmware-a" diff --git a/meta-arm-bsp/recipes-bsp/scp-firmware/files/n1sdp/0001-product-n1sdp-set-CCIX-speed-to-GEN3-to-work-with-in.patch b/meta-arm-bsp/recipes-bsp/scp-firmware/files/n1sdp/0001-product-n1sdp-set-CCIX-speed-to-GEN3-to-work-with-in.patch index fbc04f49..1f6f696b 100644 --- a/meta-arm-bsp/recipes-bsp/scp-firmware/files/n1sdp/0001-product-n1sdp-set-CCIX-speed-to-GEN3-to-work-with-in.patch +++ b/meta-arm-bsp/recipes-bsp/scp-firmware/files/n1sdp/0001-product-n1sdp-set-CCIX-speed-to-GEN3-to-work-with-in.patch @@ -1,13 +1,9 @@ -Upstream-Status: Inappropriate [will not be submitted as its only required till hardware gets fixed] - -The patch is picked from git repo: -https://git.linaro.org/landing-teams/working/arm/n1sdp-pcie-quirk.git/tree/scp/0001-product-n1sdp-set-CCIX-speed-to-GEN3-to-work-with-in.patch - +Upstream-Status: Backport Signed-off-by: Khasim Syed Mohammed -From a6d545cf9b6c46f2ea415d64fa81eb4771cfb51c Mon Sep 17 00:00:00 2001 +From 3deb59c5f4c64aa092bb3a4ebc018acf3f746f47 Mon Sep 17 00:00:00 2001 From: Jagadeesh Ujja -Date: Thu, 28 May 2020 16:19:12 +0530 +Date: Tue, 10 Nov 2020 12:31:04 +0530 Subject: [PATCH] product/n1sdp: set CCIX speed to GEN3 to work with interposer C2C setup @@ -15,23 +11,22 @@ Set CCIX speed to GEN3 to work with interposer C2C setup In this use case set downstream/upstream port transmitter preset value to 4. -Change-Id: I16e72a5eaa105386a64ab4ffe56f67134c670313 Signed-off-by: Jagadeesh Ujja +Change-Id: I635566574babbb7591b5bba97105f76f1f8e550a --- - .../module/n1sdp_pcie/src/mod_n1sdp_pcie.c | 33 +++++++++++++++---- - 1 file changed, 26 insertions(+), 7 deletions(-) + .../module/n1sdp_pcie/src/mod_n1sdp_pcie.c | 30 ++++++++++++++----- + 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/product/n1sdp/module/n1sdp_pcie/src/mod_n1sdp_pcie.c b/product/n1sdp/module/n1sdp_pcie/src/mod_n1sdp_pcie.c -index 19fa5a5..a93e6cc 100644 +index 901e0464..ba02144f 100644 --- a/product/n1sdp/module/n1sdp_pcie/src/mod_n1sdp_pcie.c +++ b/product/n1sdp/module/n1sdp_pcie/src/mod_n1sdp_pcie.c -@@ -206,7 +206,13 @@ static int n1sdp_pcie_phy_init(fwk_id_t id) +@@ -206,7 +206,12 @@ static int n1sdp_pcie_phy_init(fwk_id_t id) if (dev_ctx == NULL) return FWK_E_PARAM; - gen_speed = dev_ctx->config->ccix_capable ? PCIE_GEN_4 : PCIE_GEN_3; -+ if ((n1sdp_get_chipid() != 0x0) || -+ !dev_ctx->config->ccix_capable || ++ if ((n1sdp_get_chipid() != 0x0) || !dev_ctx->config->ccix_capable || + pcie_ctx.c2c_api->is_slave_alive()) + gen_speed = PCIE_GEN_3; + else @@ -40,13 +35,12 @@ index 19fa5a5..a93e6cc 100644 lane_count = LAN_COUNT_IN_X_16; FWK_LOG_INFO("[%s] Initializing PHY...", pcie_type[did]); -@@ -239,7 +245,13 @@ static int n1sdp_pcie_controller_init(fwk_id_t id, bool ep_mode) +@@ -239,7 +244,12 @@ static int n1sdp_pcie_controller_init(fwk_id_t id, bool ep_mode) if (dev_ctx == NULL) return FWK_E_PARAM; - gen_speed = dev_ctx->config->ccix_capable ? PCIE_GEN_4 : PCIE_GEN_3; -+ if ((n1sdp_get_chipid() != 0x0) || -+ !dev_ctx->config->ccix_capable || ++ if ((n1sdp_get_chipid() != 0x0) || !dev_ctx->config->ccix_capable || + pcie_ctx.c2c_api->is_slave_alive()) + gen_speed = PCIE_GEN_3; + else @@ -55,13 +49,12 @@ index 19fa5a5..a93e6cc 100644 lane_count = LAN_COUNT_IN_X_16; if (ep_mode) { -@@ -282,12 +294,19 @@ static int n1sdp_pcie_link_training(fwk_id_t id, bool ep_mode) +@@ -282,12 +292,18 @@ static int n1sdp_pcie_link_training(fwk_id_t id, bool ep_mode) if (dev_ctx == NULL) return FWK_E_PARAM; - gen_speed = dev_ctx->config->ccix_capable ? PCIE_GEN_4 : PCIE_GEN_3; -+ if ((n1sdp_get_chipid() != 0x0) || -+ !dev_ctx->config->ccix_capable || ++ if ((n1sdp_get_chipid() != 0x0) || !dev_ctx->config->ccix_capable || + pcie_ctx.c2c_api->is_slave_alive()) { + gen_speed = PCIE_GEN_3; + down_stream_tx_preset = PCIE_RC_TX_PRESET_VALUE; @@ -81,5 +74,5 @@ index 19fa5a5..a93e6cc 100644 if (gen_speed >= PCIE_GEN_3 && !ep_mode) { FWK_LOG_INFO( -- -2.25.0 +2.25.1 diff --git a/meta-arm-bsp/recipes-bsp/scp-firmware/files/tc0/0001-product-tc0-add-clock-and-dvfs-support-for-all-cores.patch b/meta-arm-bsp/recipes-bsp/scp-firmware/files/tc0/0001-product-tc0-add-clock-and-dvfs-support-for-all-cores.patch new file mode 100644 index 00000000..50a52dd7 --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/scp-firmware/files/tc0/0001-product-tc0-add-clock-and-dvfs-support-for-all-cores.patch @@ -0,0 +1,817 @@ +From 6be977b3196b555cdee0758a380102264410f651 Mon Sep 17 00:00:00 2001 +From: Usama Arif +Date: Sun, 31 Jan 2021 22:13:07 +0000 +Subject: [PATCH 1/2] product/tc0: add clock and dvfs support for all cores. + +This patch corrects the OPPs of cores 0-3 (klein cores) +and adds the right OPPs for matterhorn cores. + +Signed-off-by: Usama Arif +Change-Id: I1070d71c29ca2d06f9945708c135fa812b172003 + +Upstream-Status: Backport [https://github.com/ARM-software/SCP-firmware/commit/a550dd1042ecc1e6191ea2636b67d370ee865024] +Signed-off-by: Arunachalam Ganapathy +--- + product/tc0/include/clock_soc.h | 15 +++- + product/tc0/include/scp_soc_mmap.h | 4 + + product/tc0/include/tc0_timer.h | 3 +- + product/tc0/scp_ramfw/config_clock.c | 18 +++- + product/tc0/scp_ramfw/config_css_clock.c | 105 +++++++++++++++++++--- + product/tc0/scp_ramfw/config_dvfs.c | 62 +++++++++++-- + product/tc0/scp_ramfw/config_mock_psu.c | 16 +++- + product/tc0/scp_ramfw/config_pik_clock.c | 77 +++++++++++++--- + product/tc0/scp_ramfw/config_psu.c | 11 ++- + product/tc0/scp_ramfw/config_scmi_perf.c | 1 + + product/tc0/scp_ramfw/config_system_pll.c | 19 +++- + product/tc0/scp_romfw/config_clock.c | 6 +- + product/tc0/scp_romfw/config_css_clock.c | 40 ++++----- + product/tc0/scp_romfw/config_pik_clock.c | 20 ++--- + product/tc0/scp_romfw/config_system_pll.c | 6 +- + 15 files changed, 327 insertions(+), 76 deletions(-) + +diff --git a/product/tc0/include/clock_soc.h b/product/tc0/include/clock_soc.h +index 3e05bbab..2c2805c0 100644 +--- a/product/tc0/include/clock_soc.h ++++ b/product/tc0/include/clock_soc.h +@@ -17,7 +17,8 @@ + * PLL clock indexes. + */ + enum clock_pll_idx { +- CLOCK_PLL_IDX_CPU0, ++ CLOCK_PLL_IDX_CPU_KLEIN, ++ CLOCK_PLL_IDX_CPU_MATTERHORN, + CLOCK_PLL_IDX_SYS, + CLOCK_PLL_IDX_INTERCONNECT, + CLOCK_PLL_IDX_DPU, +@@ -30,11 +31,15 @@ enum clock_pll_idx { + * PIK clock indexes. + */ + enum clock_pik_idx { ++ CLOCK_PIK_IDX_INTERCONNECT, + CLOCK_PIK_IDX_CLUS0_CPU0, + CLOCK_PIK_IDX_CLUS0_CPU1, + CLOCK_PIK_IDX_CLUS0_CPU2, + CLOCK_PIK_IDX_CLUS0_CPU3, +- CLOCK_PIK_IDX_INTERCONNECT, ++ CLOCK_PIK_IDX_CLUS0_CPU4, ++ CLOCK_PIK_IDX_CLUS0_CPU5, ++ CLOCK_PIK_IDX_CLUS0_CPU6, ++ CLOCK_PIK_IDX_CLUS0_CPU7, + CLOCK_PIK_IDX_SCP, + CLOCK_PIK_IDX_GIC, + CLOCK_PIK_IDX_PCLKSCP, +@@ -48,7 +53,8 @@ enum clock_pik_idx { + * CSS clock indexes. + */ + enum clock_css_idx { +- CLOCK_CSS_IDX_CPU_GROUP0, ++ CLOCK_CSS_IDX_CPU_GROUP_KLEIN, ++ CLOCK_CSS_IDX_CPU_GROUP_MATTERHORN, + CLOCK_CSS_IDX_DPU, + CLOCK_CSS_IDX_COUNT + }; +@@ -58,7 +64,8 @@ enum clock_css_idx { + */ + enum clock_idx { + CLOCK_IDX_INTERCONNECT, +- CLOCK_IDX_CPU_GROUP0, ++ CLOCK_IDX_CPU_GROUP_KLEIN, ++ CLOCK_IDX_CPU_GROUP_MATTERHORN, + CLOCK_IDX_DPU, + CLOCK_IDX_PIXEL_0, + CLOCK_IDX_PIXEL_1, +diff --git a/product/tc0/include/scp_soc_mmap.h b/product/tc0/include/scp_soc_mmap.h +index 14f8a8d5..774bbc29 100644 +--- a/product/tc0/include/scp_soc_mmap.h ++++ b/product/tc0/include/scp_soc_mmap.h +@@ -22,5 +22,9 @@ + #define SCP_PLL_CPU1 (SCP_PLL_BASE + 0x00000104) + #define SCP_PLL_CPU2 (SCP_PLL_BASE + 0x00000108) + #define SCP_PLL_CPU3 (SCP_PLL_BASE + 0x0000010C) ++#define SCP_PLL_CPU4 (SCP_PLL_BASE + 0x00000110) ++#define SCP_PLL_CPU5 (SCP_PLL_BASE + 0x00000114) ++#define SCP_PLL_CPU6 (SCP_PLL_BASE + 0x00000118) ++#define SCP_PLL_CPU7 (SCP_PLL_BASE + 0x0000011C) + + #endif /* SCP_SOC_MMAP_H */ +diff --git a/product/tc0/include/tc0_timer.h b/product/tc0/include/tc0_timer.h +index 03d6893c..6f4bf06c 100644 +--- a/product/tc0/include/tc0_timer.h ++++ b/product/tc0/include/tc0_timer.h +@@ -9,7 +9,8 @@ + #define CONFIG_TIMER_H + + enum config_timer_refclk_sub_element_idx { +- CONFIG_TIMER_DVFS_CPU, ++ CONFIG_TIMER_DVFS_CPU_KLEIN, ++ CONFIG_TIMER_DVFS_CPU_MATTERHORN, + CONFIG_TIMER_SUB_ELEMENT_IDX_COUNT, + }; + +diff --git a/product/tc0/scp_ramfw/config_clock.c b/product/tc0/scp_ramfw/config_clock.c +index db545119..98863a01 100644 +--- a/product/tc0/scp_ramfw/config_clock.c ++++ b/product/tc0/scp_ramfw/config_clock.c +@@ -32,13 +32,25 @@ static const struct fwk_element clock_dev_desc_table[] = { + MOD_PIK_CLOCK_API_TYPE_CLOCK), + }), + }, +- [CLOCK_IDX_CPU_GROUP0] = ++ [CLOCK_IDX_CPU_GROUP_KLEIN] = + { +- .name = "CPU_GROUP0", ++ .name = "CPU_GROUP_KLEIN", + .data = &((struct mod_clock_dev_config){ + .driver_id = FWK_ID_ELEMENT_INIT( + FWK_MODULE_IDX_CSS_CLOCK, +- CLOCK_CSS_IDX_CPU_GROUP0), ++ CLOCK_CSS_IDX_CPU_GROUP_KLEIN), ++ .api_id = FWK_ID_API_INIT( ++ FWK_MODULE_IDX_CSS_CLOCK, ++ MOD_CSS_CLOCK_API_TYPE_CLOCK), ++ }), ++ }, ++ [CLOCK_IDX_CPU_GROUP_MATTERHORN] = ++ { ++ .name = "CPU_GROUP_MATTERHORN", ++ .data = &((struct mod_clock_dev_config){ ++ .driver_id = FWK_ID_ELEMENT_INIT( ++ FWK_MODULE_IDX_CSS_CLOCK, ++ CLOCK_CSS_IDX_CPU_GROUP_MATTERHORN), + .api_id = FWK_ID_API_INIT( + FWK_MODULE_IDX_CSS_CLOCK, + MOD_CSS_CLOCK_API_TYPE_CLOCK), +diff --git a/product/tc0/scp_ramfw/config_css_clock.c b/product/tc0/scp_ramfw/config_css_clock.c +index 1ad285ae..14a23d63 100644 +--- a/product/tc0/scp_ramfw/config_css_clock.c ++++ b/product/tc0/scp_ramfw/config_css_clock.c +@@ -17,7 +17,60 @@ + #include + #include + +-static const struct mod_css_clock_rate rate_table_cpu_group[] = { ++static const struct mod_css_clock_rate rate_table_cpu_group_klein[] = { ++ { ++ /* Super Underdrive */ ++ .rate = 768 * FWK_MHZ, ++ .pll_rate = 768 * FWK_MHZ, ++ .clock_source = MOD_PIK_CLOCK_CLUSCLK_SOURCE_PLL0, ++ .clock_div_type = MOD_PIK_CLOCK_MSCLOCK_DIVIDER_DIV_EXT, ++ .clock_div = 1, ++ .clock_mod_numerator = 1, ++ .clock_mod_denominator = 1, ++ }, ++ { ++ /* Underdrive */ ++ .rate = 1153 * FWK_MHZ, ++ .pll_rate = 1153 * FWK_MHZ, ++ .clock_source = MOD_PIK_CLOCK_CLUSCLK_SOURCE_PLL0, ++ .clock_div_type = MOD_PIK_CLOCK_MSCLOCK_DIVIDER_DIV_EXT, ++ .clock_div = 1, ++ .clock_mod_numerator = 1, ++ .clock_mod_denominator = 1, ++ }, ++ { ++ /* Nominal */ ++ .rate = 1537 * FWK_MHZ, ++ .pll_rate = 1537 * FWK_MHZ, ++ .clock_source = MOD_PIK_CLOCK_CLUSCLK_SOURCE_PLL0, ++ .clock_div_type = MOD_PIK_CLOCK_MSCLOCK_DIVIDER_DIV_EXT, ++ .clock_div = 1, ++ .clock_mod_numerator = 1, ++ .clock_mod_denominator = 1, ++ }, ++ { ++ /* Overdrive */ ++ .rate = 1844 * FWK_MHZ, ++ .pll_rate = 1844 * FWK_MHZ, ++ .clock_source = MOD_PIK_CLOCK_CLUSCLK_SOURCE_PLL0, ++ .clock_div_type = MOD_PIK_CLOCK_MSCLOCK_DIVIDER_DIV_EXT, ++ .clock_div = 1, ++ .clock_mod_numerator = 1, ++ .clock_mod_denominator = 1, ++ }, ++ { ++ /* Super Overdrive */ ++ .rate = 2152 * FWK_MHZ, ++ .pll_rate = 2152 * FWK_MHZ, ++ .clock_source = MOD_PIK_CLOCK_CLUSCLK_SOURCE_PLL0, ++ .clock_div_type = MOD_PIK_CLOCK_MSCLOCK_DIVIDER_DIV_EXT, ++ .clock_div = 1, ++ .clock_mod_numerator = 1, ++ .clock_mod_denominator = 1, ++ }, ++}; ++ ++static const struct mod_css_clock_rate rate_table_cpu_group_matterhorn[] = { + { + /* Super Underdrive */ + .rate = 946 * FWK_MHZ, +@@ -70,39 +123,71 @@ static const struct mod_css_clock_rate rate_table_cpu_group[] = { + }, + }; + +-static const fwk_id_t member_table_cpu_group_0[] = { ++static const fwk_id_t member_table_cpu_group_klein[] = { + FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PIK_CLOCK, CLOCK_PIK_IDX_CLUS0_CPU0), + FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PIK_CLOCK, CLOCK_PIK_IDX_CLUS0_CPU1), + FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PIK_CLOCK, CLOCK_PIK_IDX_CLUS0_CPU2), + FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PIK_CLOCK, CLOCK_PIK_IDX_CLUS0_CPU3), + }; + ++static const fwk_id_t member_table_cpu_group_matterhorn[] = { ++ FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PIK_CLOCK, CLOCK_PIK_IDX_CLUS0_CPU4), ++ FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PIK_CLOCK, CLOCK_PIK_IDX_CLUS0_CPU5), ++ FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PIK_CLOCK, CLOCK_PIK_IDX_CLUS0_CPU6), ++ FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PIK_CLOCK, CLOCK_PIK_IDX_CLUS0_CPU7), ++}; ++ ++ + static const fwk_id_t member_table_dpu[] = { + FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PIK_CLOCK, CLOCK_PIK_IDX_DPU), + }; + + static const struct fwk_element css_clock_element_table[] = { +- [CLOCK_CSS_IDX_CPU_GROUP0] = ++ [CLOCK_CSS_IDX_CPU_GROUP_KLEIN] = ++ { ++ .name = "CPU_GROUP_KLEIN", ++ .data = &((struct mod_css_clock_dev_config){ ++ .clock_type = MOD_CSS_CLOCK_TYPE_INDEXED, ++ .rate_table = rate_table_cpu_group_klein, ++ .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group_klein), ++ .clock_switching_source = ++ MOD_PIK_CLOCK_CLUSCLK_SOURCE_SYSREFCLK, ++ .pll_id = FWK_ID_ELEMENT_INIT( ++ FWK_MODULE_IDX_SYSTEM_PLL, ++ CLOCK_PLL_IDX_CPU_KLEIN), ++ .pll_api_id = FWK_ID_API_INIT( ++ FWK_MODULE_IDX_SYSTEM_PLL, ++ MOD_SYSTEM_PLL_API_TYPE_DEFAULT), ++ .member_table = member_table_cpu_group_klein, ++ .member_count = FWK_ARRAY_SIZE(member_table_cpu_group_klein), ++ .member_api_id = FWK_ID_API_INIT( ++ FWK_MODULE_IDX_PIK_CLOCK, ++ MOD_PIK_CLOCK_API_TYPE_CSS), ++ .initial_rate = 1537 * FWK_MHZ, ++ .modulation_supported = true, ++ }), ++ }, ++ [CLOCK_CSS_IDX_CPU_GROUP_MATTERHORN] = + { +- .name = "CPU_GROUP_0", ++ .name = "CPU_GROUP_MATTERHORN", + .data = &((struct mod_css_clock_dev_config){ + .clock_type = MOD_CSS_CLOCK_TYPE_INDEXED, +- .rate_table = rate_table_cpu_group, +- .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group), ++ .rate_table = rate_table_cpu_group_matterhorn, ++ .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group_matterhorn), + .clock_switching_source = + MOD_PIK_CLOCK_CLUSCLK_SOURCE_SYSREFCLK, + .pll_id = FWK_ID_ELEMENT_INIT( + FWK_MODULE_IDX_SYSTEM_PLL, +- CLOCK_PLL_IDX_CPU0), ++ CLOCK_PLL_IDX_CPU_MATTERHORN), + .pll_api_id = FWK_ID_API_INIT( + FWK_MODULE_IDX_SYSTEM_PLL, + MOD_SYSTEM_PLL_API_TYPE_DEFAULT), +- .member_table = member_table_cpu_group_0, +- .member_count = FWK_ARRAY_SIZE(member_table_cpu_group_0), ++ .member_table = member_table_cpu_group_matterhorn, ++ .member_count = FWK_ARRAY_SIZE(member_table_cpu_group_matterhorn), + .member_api_id = FWK_ID_API_INIT( + FWK_MODULE_IDX_PIK_CLOCK, + MOD_PIK_CLOCK_API_TYPE_CSS), +- .initial_rate = 2271 * FWK_MHZ, ++ .initial_rate = 1893 * FWK_MHZ, + .modulation_supported = true, + }), + }, +diff --git a/product/tc0/scp_ramfw/config_dvfs.c b/product/tc0/scp_ramfw/config_dvfs.c +index a0b59b2b..4b952ef8 100644 +--- a/product/tc0/scp_ramfw/config_dvfs.c ++++ b/product/tc0/scp_ramfw/config_dvfs.c +@@ -16,7 +16,35 @@ + #include + #include + +-static struct mod_dvfs_opp opps[] = { { ++static struct mod_dvfs_opp opps_klein[] = { { ++ .level = 768 * 1000000UL, ++ .frequency = 768 * FWK_KHZ, ++ .voltage = 550, ++ }, ++ { ++ .level = 1153 * 1000000UL, ++ .frequency = 1153 * FWK_KHZ, ++ .voltage = 650, ++ }, ++ { ++ .level = 1537 * 1000000UL, ++ .frequency = 1537 * FWK_KHZ, ++ .voltage = 750, ++ }, ++ { ++ .level = 1844 * 1000000UL, ++ .frequency = 1844 * FWK_KHZ, ++ .voltage = 850, ++ }, ++ { ++ .level = 2152 * 1000000UL, ++ .frequency = 2152 * FWK_KHZ, ++ .voltage = 950, ++ }, ++ { 0 } }; ++ ++ ++static struct mod_dvfs_opp opps_matterhorn[] = { { + .level = 946 * 1000000UL, + .frequency = 946 * FWK_KHZ, + .voltage = 550, +@@ -43,11 +71,26 @@ static struct mod_dvfs_opp opps[] = { { + }, + { 0 } }; + +-static const struct mod_dvfs_domain_config cpu_group = { ++static const struct mod_dvfs_domain_config cpu_group_klein = { + .psu_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PSU, 0), +- .clock_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_CLOCK, CLOCK_IDX_CPU_GROUP0), ++ .clock_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_CLOCK, CLOCK_IDX_CPU_GROUP_KLEIN), ++ .alarm_id = ++ FWK_ID_SUB_ELEMENT_INIT(FWK_MODULE_IDX_TIMER, 0, CONFIG_TIMER_DVFS_CPU_KLEIN), ++ .notification_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SCMI_PERF), ++ .updates_api_id = FWK_ID_API_INIT( ++ FWK_MODULE_IDX_SCMI_PERF, ++ MOD_SCMI_PERF_DVFS_UPDATE_API), ++ .retry_ms = 1, ++ .latency = 1200, ++ .sustained_idx = 2, ++ .opps = opps_klein, ++}; ++ ++static const struct mod_dvfs_domain_config cpu_group_matterhorn = { ++ .psu_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PSU, 1), ++ .clock_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_CLOCK, CLOCK_IDX_CPU_GROUP_MATTERHORN), + .alarm_id = +- FWK_ID_SUB_ELEMENT_INIT(FWK_MODULE_IDX_TIMER, 0, CONFIG_TIMER_DVFS_CPU), ++ FWK_ID_SUB_ELEMENT_INIT(FWK_MODULE_IDX_TIMER, 0, CONFIG_TIMER_DVFS_CPU_MATTERHORN), + .notification_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SCMI_PERF), + .updates_api_id = FWK_ID_API_INIT( + FWK_MODULE_IDX_SCMI_PERF, +@@ -55,13 +98,18 @@ static const struct mod_dvfs_domain_config cpu_group = { + .retry_ms = 1, + .latency = 1200, + .sustained_idx = 2, +- .opps = opps, ++ .opps = opps_matterhorn, + }; + + static const struct fwk_element element_table[] = { [0] = + { +- .name = "CPU_GROUP", +- .data = &cpu_group, ++ .name = "CPU_GROUP_KLEIN", ++ .data = &cpu_group_klein, ++ }, ++ [1] = ++ { ++ .name = "CPU_GROUP_MATTERHORN", ++ .data = &cpu_group_matterhorn, + }, + { 0 } }; + +diff --git a/product/tc0/scp_ramfw/config_mock_psu.c b/product/tc0/scp_ramfw/config_mock_psu.c +index 1f9411ca..2d3742f2 100644 +--- a/product/tc0/scp_ramfw/config_mock_psu.c ++++ b/product/tc0/scp_ramfw/config_mock_psu.c +@@ -12,7 +12,21 @@ + + static const struct fwk_element element_table[] = { + { +- .name = "DVFS_GROUP0", ++ .name = "DVFS_GROUP_KLEIN", ++ .data = ++ &(const struct mod_mock_psu_element_cfg){ ++ .async_alarm_id = FWK_ID_NONE_INIT, ++ .async_alarm_api_id = FWK_ID_NONE_INIT, ++ ++ .async_response_id = FWK_ID_NONE_INIT, ++ .async_response_api_id = FWK_ID_NONE_INIT, ++ ++ .default_enabled = true, ++ .default_voltage = 550, ++ }, ++ }, ++ { ++ .name = "DVFS_GROUP_MATTERHORN", + .data = + &(const struct mod_mock_psu_element_cfg){ + .async_alarm_id = FWK_ID_NONE_INIT, +diff --git a/product/tc0/scp_ramfw/config_pik_clock.c b/product/tc0/scp_ramfw/config_pik_clock.c +index d2c03865..38837a91 100644 +--- a/product/tc0/scp_ramfw/config_pik_clock.c ++++ b/product/tc0/scp_ramfw/config_pik_clock.c +@@ -21,9 +21,18 @@ + /* + * Rate lookup tables + */ +-static struct mod_pik_clock_rate rate_table_cpu_group[] = { ++static struct mod_pik_clock_rate rate_table_cpu_group_klein[] = { + { +- .rate = 1750 * FWK_MHZ, ++ .rate = 1537 * FWK_MHZ, ++ .source = MOD_PIK_CLOCK_CLUSCLK_SOURCE_PLL0, ++ .divider_reg = MOD_PIK_CLOCK_MSCLOCK_DIVIDER_DIV_EXT, ++ .divider = 1, /* Rate adjusted via CPU PLL */ ++ }, ++}; ++ ++static struct mod_pik_clock_rate rate_table_cpu_group_matterhorn[] = { ++ { ++ .rate = 1893 * FWK_MHZ, + .source = MOD_PIK_CLOCK_CLUSCLK_SOURCE_PLL0, + .divider_reg = MOD_PIK_CLOCK_MSCLOCK_DIVIDER_DIV_EXT, + .divider = 1, /* Rate adjusted via CPU PLL */ +@@ -103,8 +112,8 @@ static const struct fwk_element pik_clock_element_table[] = { + .control_reg = &CLUSTER_PIK_PTR(0)->CORECLK[0].CTRL, + .divext_reg = &CLUSTER_PIK_PTR(0)->CORECLK[0].DIV, + .modulator_reg = &CLUSTER_PIK_PTR(0)->CORECLK[0].MOD, +- .rate_table = rate_table_cpu_group, +- .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group), ++ .rate_table = rate_table_cpu_group_klein, ++ .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group_klein), + }), + }, + [CLOCK_PIK_IDX_CLUS0_CPU1] = { +@@ -115,8 +124,8 @@ static const struct fwk_element pik_clock_element_table[] = { + .control_reg = &CLUSTER_PIK_PTR(0)->CORECLK[1].CTRL, + .divext_reg = &CLUSTER_PIK_PTR(0)->CORECLK[1].DIV, + .modulator_reg = &CLUSTER_PIK_PTR(0)->CORECLK[1].MOD, +- .rate_table = rate_table_cpu_group, +- .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group), ++ .rate_table = rate_table_cpu_group_klein, ++ .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group_klein), + }), + }, + [CLOCK_PIK_IDX_CLUS0_CPU2] = { +@@ -127,8 +136,8 @@ static const struct fwk_element pik_clock_element_table[] = { + .control_reg = &CLUSTER_PIK_PTR(0)->CORECLK[2].CTRL, + .divext_reg = &CLUSTER_PIK_PTR(0)->CORECLK[2].DIV, + .modulator_reg = &CLUSTER_PIK_PTR(0)->CORECLK[2].MOD, +- .rate_table = rate_table_cpu_group, +- .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group), ++ .rate_table = rate_table_cpu_group_klein, ++ .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group_klein), + }), + }, + [CLOCK_PIK_IDX_CLUS0_CPU3] = { +@@ -139,8 +148,56 @@ static const struct fwk_element pik_clock_element_table[] = { + .control_reg = &CLUSTER_PIK_PTR(0)->CORECLK[3].CTRL, + .divext_reg = &CLUSTER_PIK_PTR(0)->CORECLK[3].DIV, + .modulator_reg = &CLUSTER_PIK_PTR(0)->CORECLK[3].MOD, +- .rate_table = rate_table_cpu_group, +- .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group), ++ .rate_table = rate_table_cpu_group_klein, ++ .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group_klein), ++ }), ++ }, ++ [CLOCK_PIK_IDX_CLUS0_CPU4] = { ++ .name = "CLUS0_CPU4", ++ .data = &((struct mod_pik_clock_dev_config) { ++ .type = MOD_PIK_CLOCK_TYPE_CLUSTER, ++ .is_group_member = true, ++ .control_reg = &CLUSTER_PIK_PTR(0)->CORECLK[4].CTRL, ++ .divext_reg = &CLUSTER_PIK_PTR(0)->CORECLK[4].DIV, ++ .modulator_reg = &CLUSTER_PIK_PTR(0)->CORECLK[4].MOD, ++ .rate_table = rate_table_cpu_group_matterhorn, ++ .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group_matterhorn), ++ }), ++ }, ++ [CLOCK_PIK_IDX_CLUS0_CPU5] = { ++ .name = "CLUS0_CPU5", ++ .data = &((struct mod_pik_clock_dev_config) { ++ .type = MOD_PIK_CLOCK_TYPE_CLUSTER, ++ .is_group_member = true, ++ .control_reg = &CLUSTER_PIK_PTR(0)->CORECLK[5].CTRL, ++ .divext_reg = &CLUSTER_PIK_PTR(0)->CORECLK[5].DIV, ++ .modulator_reg = &CLUSTER_PIK_PTR(0)->CORECLK[5].MOD, ++ .rate_table = rate_table_cpu_group_matterhorn, ++ .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group_matterhorn), ++ }), ++ }, ++ [CLOCK_PIK_IDX_CLUS0_CPU6] = { ++ .name = "CLUS0_CPU6", ++ .data = &((struct mod_pik_clock_dev_config) { ++ .type = MOD_PIK_CLOCK_TYPE_CLUSTER, ++ .is_group_member = true, ++ .control_reg = &CLUSTER_PIK_PTR(0)->CORECLK[6].CTRL, ++ .divext_reg = &CLUSTER_PIK_PTR(0)->CORECLK[6].DIV, ++ .modulator_reg = &CLUSTER_PIK_PTR(0)->CORECLK[6].MOD, ++ .rate_table = rate_table_cpu_group_matterhorn, ++ .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group_matterhorn), ++ }), ++ }, ++ [CLOCK_PIK_IDX_CLUS0_CPU7] = { ++ .name = "CLUS0_CPU7", ++ .data = &((struct mod_pik_clock_dev_config) { ++ .type = MOD_PIK_CLOCK_TYPE_CLUSTER, ++ .is_group_member = true, ++ .control_reg = &CLUSTER_PIK_PTR(0)->CORECLK[7].CTRL, ++ .divext_reg = &CLUSTER_PIK_PTR(0)->CORECLK[7].DIV, ++ .modulator_reg = &CLUSTER_PIK_PTR(0)->CORECLK[7].MOD, ++ .rate_table = rate_table_cpu_group_matterhorn, ++ .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group_matterhorn), + }), + }, + [CLOCK_PIK_IDX_INTERCONNECT] = { +diff --git a/product/tc0/scp_ramfw/config_psu.c b/product/tc0/scp_ramfw/config_psu.c +index 8e3bcb5a..3bf0f7fd 100644 +--- a/product/tc0/scp_ramfw/config_psu.c ++++ b/product/tc0/scp_ramfw/config_psu.c +@@ -14,7 +14,7 @@ + + static const struct fwk_element element_table[] = { + { +- .name = "DVFS_GROUP0", ++ .name = "DVFS_GROUP_KLEIN", + .data = + &(const struct mod_psu_element_cfg){ + .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_MOCK_PSU, 0), +@@ -22,6 +22,15 @@ static const struct fwk_element element_table[] = { + FWK_MODULE_IDX_MOCK_PSU, + MOD_MOCK_PSU_API_IDX_DRIVER) }, + }, ++ { ++ .name = "DVFS_GROUP_MATTERHORN", ++ .data = ++ &(const struct mod_psu_element_cfg){ ++ .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_MOCK_PSU, 1), ++ .driver_api_id = FWK_ID_API_INIT( ++ FWK_MODULE_IDX_MOCK_PSU, ++ MOD_MOCK_PSU_API_IDX_DRIVER) }, ++ }, + { 0 } + }; + +diff --git a/product/tc0/scp_ramfw/config_scmi_perf.c b/product/tc0/scp_ramfw/config_scmi_perf.c +index f2be2253..6ef6146b 100644 +--- a/product/tc0/scp_ramfw/config_scmi_perf.c ++++ b/product/tc0/scp_ramfw/config_scmi_perf.c +@@ -15,6 +15,7 @@ + + static const struct mod_scmi_perf_domain_config domains[] = { + [0] = {}, ++ [1] = {}, + }; + + const struct fwk_module_config config_scmi_perf = { +diff --git a/product/tc0/scp_ramfw/config_system_pll.c b/product/tc0/scp_ramfw/config_system_pll.c +index b55dd642..37578855 100644 +--- a/product/tc0/scp_ramfw/config_system_pll.c ++++ b/product/tc0/scp_ramfw/config_system_pll.c +@@ -18,14 +18,27 @@ + + static const struct fwk_element system_pll_element_table[] = + { +- [CLOCK_PLL_IDX_CPU0] = ++ [CLOCK_PLL_IDX_CPU_KLEIN] = + { +- .name = "CPU_PLL_0", ++ .name = "CPU_PLL_KLEIN", + .data = &((struct mod_system_pll_dev_config){ + .control_reg = (void *)SCP_PLL_CPU0, + .status_reg = (void *)&SCP_PIK_PTR->PLL_STATUS[1], + .lock_flag_mask = PLL_STATUS_CPUPLLLOCK(0), +- .initial_rate = 1750 * FWK_MHZ, ++ .initial_rate = 1537 * FWK_MHZ, ++ .min_rate = MOD_SYSTEM_PLL_MIN_RATE, ++ .max_rate = MOD_SYSTEM_PLL_MAX_RATE, ++ .min_step = MOD_SYSTEM_PLL_MIN_INTERVAL, ++ }), ++ }, ++ [CLOCK_PLL_IDX_CPU_MATTERHORN] = ++ { ++ .name = "CPU_PLL_MATTERHORN", ++ .data = &((struct mod_system_pll_dev_config){ ++ .control_reg = (void *)SCP_PLL_CPU4, ++ .status_reg = (void *)&SCP_PIK_PTR->PLL_STATUS[1], ++ .lock_flag_mask = PLL_STATUS_CPUPLLLOCK(0), ++ .initial_rate = 1893 * FWK_MHZ, + .min_rate = MOD_SYSTEM_PLL_MIN_RATE, + .max_rate = MOD_SYSTEM_PLL_MAX_RATE, + .min_step = MOD_SYSTEM_PLL_MIN_INTERVAL, +diff --git a/product/tc0/scp_romfw/config_clock.c b/product/tc0/scp_romfw/config_clock.c +index f43b61b0..96806211 100644 +--- a/product/tc0/scp_romfw/config_clock.c ++++ b/product/tc0/scp_romfw/config_clock.c +@@ -35,13 +35,13 @@ static const struct fwk_element clock_dev_desc_table[] = { + + }), + }, +- [CLOCK_IDX_CPU_GROUP0] = ++ [CLOCK_IDX_CPU_GROUP_KLEIN] = + { +- .name = "CPU_GROUP0", ++ .name = "CPU_GROUP_KLEIN", + .data = &((struct mod_clock_dev_config){ + .driver_id = FWK_ID_ELEMENT_INIT( + FWK_MODULE_IDX_CSS_CLOCK, +- CLOCK_CSS_IDX_CPU_GROUP0), ++ CLOCK_CSS_IDX_CPU_GROUP_KLEIN), + .api_id = FWK_ID_API_INIT( + FWK_MODULE_IDX_CSS_CLOCK, + MOD_CSS_CLOCK_API_TYPE_CLOCK), +diff --git a/product/tc0/scp_romfw/config_css_clock.c b/product/tc0/scp_romfw/config_css_clock.c +index fcb9bbbb..ca284ee7 100644 +--- a/product/tc0/scp_romfw/config_css_clock.c ++++ b/product/tc0/scp_romfw/config_css_clock.c +@@ -17,11 +17,11 @@ + #include + #include + +-static const struct mod_css_clock_rate rate_table_cpu_group[] = { ++static const struct mod_css_clock_rate rate_table_cpu_group_klein[] = { + { + /* Super Underdrive */ +- .rate = 946 * FWK_MHZ, +- .pll_rate = 946 * FWK_MHZ, ++ .rate = 768 * FWK_MHZ, ++ .pll_rate = 768 * FWK_MHZ, + .clock_source = MOD_PIK_CLOCK_CLUSCLK_SOURCE_PLL0, + .clock_div_type = MOD_PIK_CLOCK_MSCLOCK_DIVIDER_DIV_EXT, + .clock_div = 1, +@@ -30,8 +30,8 @@ static const struct mod_css_clock_rate rate_table_cpu_group[] = { + }, + { + /* Underdrive */ +- .rate = 1419 * FWK_MHZ, +- .pll_rate = 1419 * FWK_MHZ, ++ .rate = 1153 * FWK_MHZ, ++ .pll_rate = 1153 * FWK_MHZ, + .clock_source = MOD_PIK_CLOCK_CLUSCLK_SOURCE_PLL0, + .clock_div_type = MOD_PIK_CLOCK_MSCLOCK_DIVIDER_DIV_EXT, + .clock_div = 1, +@@ -40,8 +40,8 @@ static const struct mod_css_clock_rate rate_table_cpu_group[] = { + }, + { + /* Nominal */ +- .rate = 1893 * FWK_MHZ, +- .pll_rate = 1893 * FWK_MHZ, ++ .rate = 1537 * FWK_MHZ, ++ .pll_rate = 1537 * FWK_MHZ, + .clock_source = MOD_PIK_CLOCK_CLUSCLK_SOURCE_PLL0, + .clock_div_type = MOD_PIK_CLOCK_MSCLOCK_DIVIDER_DIV_EXT, + .clock_div = 1, +@@ -50,8 +50,8 @@ static const struct mod_css_clock_rate rate_table_cpu_group[] = { + }, + { + /* Overdrive */ +- .rate = 2271 * FWK_MHZ, +- .pll_rate = 2271 * FWK_MHZ, ++ .rate = 1844 * FWK_MHZ, ++ .pll_rate = 1844 * FWK_MHZ, + .clock_source = MOD_PIK_CLOCK_CLUSCLK_SOURCE_PLL0, + .clock_div_type = MOD_PIK_CLOCK_MSCLOCK_DIVIDER_DIV_EXT, + .clock_div = 1, +@@ -60,8 +60,8 @@ static const struct mod_css_clock_rate rate_table_cpu_group[] = { + }, + { + /* Super Overdrive */ +- .rate = 2650 * FWK_MHZ, +- .pll_rate = 2650 * FWK_MHZ, ++ .rate = 2152 * FWK_MHZ, ++ .pll_rate = 2152 * FWK_MHZ, + .clock_source = MOD_PIK_CLOCK_CLUSCLK_SOURCE_PLL0, + .clock_div_type = MOD_PIK_CLOCK_MSCLOCK_DIVIDER_DIV_EXT, + .clock_div = 1, +@@ -70,7 +70,7 @@ static const struct mod_css_clock_rate rate_table_cpu_group[] = { + }, + }; + +-static const fwk_id_t member_table_cpu_group_0[] = { ++static const fwk_id_t member_table_cpu_group_klein[] = { + FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PIK_CLOCK, CLOCK_PIK_IDX_CLUS0_CPU0), + FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PIK_CLOCK, CLOCK_PIK_IDX_CLUS0_CPU1), + FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PIK_CLOCK, CLOCK_PIK_IDX_CLUS0_CPU2), +@@ -78,27 +78,27 @@ static const fwk_id_t member_table_cpu_group_0[] = { + }; + + static const struct fwk_element css_clock_element_table[] = { +- [CLOCK_CSS_IDX_CPU_GROUP0] = ++ [CLOCK_CSS_IDX_CPU_GROUP_KLEIN] = + { +- .name = "CPU_GROUP_0", ++ .name = "CPU_GROUP_KLEIN", + .data = &((struct mod_css_clock_dev_config){ + .clock_type = MOD_CSS_CLOCK_TYPE_INDEXED, +- .rate_table = rate_table_cpu_group, +- .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group), ++ .rate_table = rate_table_cpu_group_klein, ++ .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group_klein), + .clock_switching_source = + MOD_PIK_CLOCK_CLUSCLK_SOURCE_SYSREFCLK, + .pll_id = FWK_ID_ELEMENT_INIT( + FWK_MODULE_IDX_SYSTEM_PLL, +- CLOCK_PLL_IDX_CPU0), ++ CLOCK_PLL_IDX_CPU_KLEIN), + .pll_api_id = FWK_ID_API_INIT( + FWK_MODULE_IDX_SYSTEM_PLL, + MOD_SYSTEM_PLL_API_TYPE_DEFAULT), +- .member_table = member_table_cpu_group_0, +- .member_count = FWK_ARRAY_SIZE(member_table_cpu_group_0), ++ .member_table = member_table_cpu_group_klein, ++ .member_count = FWK_ARRAY_SIZE(member_table_cpu_group_klein), + .member_api_id = FWK_ID_API_INIT( + FWK_MODULE_IDX_PIK_CLOCK, + MOD_PIK_CLOCK_API_TYPE_CSS), +- .initial_rate = 2271 * FWK_MHZ, ++ .initial_rate = 1537 * FWK_MHZ, + .modulation_supported = true, + }), + }, +diff --git a/product/tc0/scp_romfw/config_pik_clock.c b/product/tc0/scp_romfw/config_pik_clock.c +index ba7c3ddc..2c883084 100644 +--- a/product/tc0/scp_romfw/config_pik_clock.c ++++ b/product/tc0/scp_romfw/config_pik_clock.c +@@ -19,9 +19,9 @@ + /* + * Rate lookup tables + */ +-static struct mod_pik_clock_rate rate_table_cpu_group[] = { ++static struct mod_pik_clock_rate rate_table_cpu_group_klein[] = { + { +- .rate = 1750 * FWK_MHZ, ++ .rate = 1537 * FWK_MHZ, + .source = MOD_PIK_CLOCK_CLUSCLK_SOURCE_PLL0, + .divider_reg = MOD_PIK_CLOCK_MSCLOCK_DIVIDER_DIV_EXT, + .divider = 1, /* Rate adjusted via CPU PLL */ +@@ -94,8 +94,8 @@ static const struct fwk_element + .control_reg = &CLUSTER_PIK_PTR(0)->CORECLK[0].CTRL, + .divext_reg = &CLUSTER_PIK_PTR(0)->CORECLK[0].DIV, + .modulator_reg = &CLUSTER_PIK_PTR(0)->CORECLK[0].MOD, +- .rate_table = rate_table_cpu_group, +- .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group), ++ .rate_table = rate_table_cpu_group_klein, ++ .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group_klein), + }), + }, + [CLOCK_PIK_IDX_CLUS0_CPU1] = +@@ -107,8 +107,8 @@ static const struct fwk_element + .control_reg = &CLUSTER_PIK_PTR(0)->CORECLK[1].CTRL, + .divext_reg = &CLUSTER_PIK_PTR(0)->CORECLK[1].DIV, + .modulator_reg = &CLUSTER_PIK_PTR(0)->CORECLK[1].MOD, +- .rate_table = rate_table_cpu_group, +- .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group), ++ .rate_table = rate_table_cpu_group_klein, ++ .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group_klein), + }), + }, + [CLOCK_PIK_IDX_CLUS0_CPU2] = +@@ -120,8 +120,8 @@ static const struct fwk_element + .control_reg = &CLUSTER_PIK_PTR(0)->CORECLK[2].CTRL, + .divext_reg = &CLUSTER_PIK_PTR(0)->CORECLK[2].DIV, + .modulator_reg = &CLUSTER_PIK_PTR(0)->CORECLK[2].MOD, +- .rate_table = rate_table_cpu_group, +- .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group), ++ .rate_table = rate_table_cpu_group_klein, ++ .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group_klein), + }), + }, + [CLOCK_PIK_IDX_CLUS0_CPU3] = +@@ -133,8 +133,8 @@ static const struct fwk_element + .control_reg = &CLUSTER_PIK_PTR(0)->CORECLK[3].CTRL, + .divext_reg = &CLUSTER_PIK_PTR(0)->CORECLK[3].DIV, + .modulator_reg = &CLUSTER_PIK_PTR(0)->CORECLK[3].MOD, +- .rate_table = rate_table_cpu_group, +- .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group), ++ .rate_table = rate_table_cpu_group_klein, ++ .rate_count = FWK_ARRAY_SIZE(rate_table_cpu_group_klein), + }), + }, + [CLOCK_PIK_IDX_INTERCONNECT] = +diff --git a/product/tc0/scp_romfw/config_system_pll.c b/product/tc0/scp_romfw/config_system_pll.c +index e6b578ff..8440f126 100644 +--- a/product/tc0/scp_romfw/config_system_pll.c ++++ b/product/tc0/scp_romfw/config_system_pll.c +@@ -17,14 +17,14 @@ + #include + + static const struct fwk_element system_pll_element_table[] = { +- [CLOCK_PLL_IDX_CPU0] = ++ [CLOCK_PLL_IDX_CPU_KLEIN] = + { +- .name = "CPU_PLL_0", ++ .name = "CPU_PLL_KLEIN", + .data = &((struct mod_system_pll_dev_config){ + .control_reg = (void *)SCP_PLL_CPU0, + .status_reg = (void *)&SCP_PIK_PTR->PLL_STATUS[1], + .lock_flag_mask = PLL_STATUS_CPUPLLLOCK(0), +- .initial_rate = 1750 * FWK_MHZ, ++ .initial_rate = 1537 * FWK_MHZ, + .min_rate = MOD_SYSTEM_PLL_MIN_RATE, + .max_rate = MOD_SYSTEM_PLL_MAX_RATE, + .min_step = MOD_SYSTEM_PLL_MIN_INTERVAL, +-- +2.29.2 + diff --git a/meta-arm-bsp/recipes-bsp/scp-firmware/files/tc0/0002-module-cmn_booker-amend-CFGM-base-address.patch b/meta-arm-bsp/recipes-bsp/scp-firmware/files/tc0/0002-module-cmn_booker-amend-CFGM-base-address.patch new file mode 100644 index 00000000..decd0749 --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/scp-firmware/files/tc0/0002-module-cmn_booker-amend-CFGM-base-address.patch @@ -0,0 +1,125 @@ +From 492c5d094b5c9aaeffe076265840056a2b9d57ac Mon Sep 17 00:00:00 2001 +From: Usama Arif +Date: Tue, 23 Feb 2021 15:06:46 +0000 +Subject: [PATCH 2/2] module/cmn_booker: amend CFGM base address + +The CFGM base address calculation depends on the number of ports +per XP. + +Signed-off-by: Usama Arif +Change-Id: Iabb9e76b86ee80b345857deb86e9acd4cec5988c + +Upstream-Status: Backport [https://github.com/ARM-software/SCP-firmware/commit/5abe1656f27216f633b3fc29e20ff64340f47bfe] +Signed-off-by: Arunachalam Ganapathy +--- + module/cmn_booker/include/mod_cmn_booker.h | 7 +++++++ + module/cmn_booker/src/cmn_booker.c | 18 +++++++++++++++--- + module/cmn_booker/src/cmn_booker.h | 5 +++-- + module/cmn_booker/src/mod_cmn_booker.c | 2 +- + product/tc0/scp_romfw/config_cmn_booker.c | 1 + + 5 files changed, 27 insertions(+), 6 deletions(-) + +diff --git a/module/cmn_booker/include/mod_cmn_booker.h b/module/cmn_booker/include/mod_cmn_booker.h +index 5d395521..a172b336 100644 +--- a/module/cmn_booker/include/mod_cmn_booker.h ++++ b/module/cmn_booker/include/mod_cmn_booker.h +@@ -127,6 +127,13 @@ struct mod_cmn_booker_config { + * to a CAL port, node id of HN-F will be a odd number). + */ + bool hnf_cal_mode; ++ ++ /*! \ ++ * \brief Number of device ports per XP ++ * \details The calculation for CFGM base address depends on the number of ++ * ports per cross point ++ */ ++ unsigned int ports_per_xp; + }; + + /*! +diff --git a/module/cmn_booker/src/cmn_booker.c b/module/cmn_booker/src/cmn_booker.c +index d6e90964..277415ef 100644 +--- a/module/cmn_booker/src/cmn_booker.c ++++ b/module/cmn_booker/src/cmn_booker.c +@@ -196,7 +196,7 @@ unsigned int get_node_pos_y(void *node_base) + + struct cmn_booker_cfgm_reg *get_root_node(uintptr_t base, + unsigned int hnd_node_id, unsigned int mesh_size_x, +- unsigned int mesh_size_y) ++ unsigned int mesh_size_y, unsigned int ports_per_xp) + { + unsigned int node_pos_x; + unsigned int node_pos_y; +@@ -217,11 +217,23 @@ struct cmn_booker_cfgm_reg *get_root_node(uintptr_t base, + node_port = (hnd_node_id >> CMN_BOOKER_NODE_ID_PORT_POS) & + CMN_BOOKER_NODE_ID_PORT_MASK; + ++ /* Calculate node address offset */ ++ if(ports_per_xp > 4) ++ { ++ // Single XP configuration, upto 6 device ports allowed ++ offset = ((node_port & 0x3) << CMN_BOOKER_ROOT_NODE_OFFSET_PORT_POS); ++ } else if(ports_per_xp > 2) ++ { ++ // XPs which have more than 2 device ports ++ offset = (((node_port)>>1) << CMN_BOOKER_ROOT_NODE_OFFSET_PORT_POS); ++ }else ++ { ++ offset = (node_port << CMN_BOOKER_ROOT_NODE_OFFSET_PORT_POS); ++ } + /* Calculate node address offset */ + offset = (node_pos_y << CMN_BOOKER_ROOT_NODE_OFFSET_Y_POS) | + (node_pos_x << (CMN_BOOKER_ROOT_NODE_OFFSET_Y_POS + +- encoding_bits)) | +- (node_port << CMN_BOOKER_ROOT_NODE_OFFSET_PORT_POS); ++ encoding_bits)) | offset; + + return (struct cmn_booker_cfgm_reg *)(base + offset); + } +diff --git a/module/cmn_booker/src/cmn_booker.h b/module/cmn_booker/src/cmn_booker.h +index 9a89f173..b0d59804 100644 +--- a/module/cmn_booker/src/cmn_booker.h ++++ b/module/cmn_booker/src/cmn_booker.h +@@ -417,12 +417,13 @@ unsigned int get_node_pos_y(void *node_base); + * \param base CMN BOOKER peripheral base address + * \param hnd_node_id HN-D node identifier containing the global configuration + * \param mesh_size_x Size of the mesh along the x-axis +- * \param mesh_size_y Size of the mesh along the x-axis ++ * \param mesh_size_y Size of the mesh along the y-axis ++ * \param mesh_size_y Device ports per XP + * + * \return Pointer to the root node descriptor + */ + struct cmn_booker_cfgm_reg *get_root_node(uintptr_t base, + unsigned int hnd_node_id, unsigned int mesh_size_x, +- unsigned int mesh_size_y); ++ unsigned int mesh_size_y, unsigned int ports_per_xp); + + #endif /* CMN_BOOKER_H */ +diff --git a/module/cmn_booker/src/mod_cmn_booker.c b/module/cmn_booker/src/mod_cmn_booker.c +index cbff273e..09fc8884 100644 +--- a/module/cmn_booker/src/mod_cmn_booker.c ++++ b/module/cmn_booker/src/mod_cmn_booker.c +@@ -536,7 +536,7 @@ static int cmn_booker_init(fwk_id_t module_id, unsigned int element_count, + return FWK_E_DATA; + + ctx->root = get_root_node(config->base, config->hnd_node_id, +- config->mesh_size_x, config->mesh_size_y); ++ config->mesh_size_x, config->mesh_size_y, config->ports_per_xp); + + ctx->config = config; + +diff --git a/product/tc0/scp_romfw/config_cmn_booker.c b/product/tc0/scp_romfw/config_cmn_booker.c +index a076d8d7..d13138b2 100644 +--- a/product/tc0/scp_romfw/config_cmn_booker.c ++++ b/product/tc0/scp_romfw/config_cmn_booker.c +@@ -116,5 +116,6 @@ const struct fwk_module_config config_cmn_booker = { + .clock_id = + FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_CLOCK, CLOCK_IDX_INTERCONNECT), + .hnf_cal_mode = false, ++ .ports_per_xp = 4, + }), + }; +-- +2.29.2 + diff --git a/meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware-corstone700.inc b/meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware-corstone700.inc deleted file mode 100644 index 16437c56..00000000 --- a/meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware-corstone700.inc +++ /dev/null @@ -1,37 +0,0 @@ -# Corstone700 specific SCP configurations and build instructions - -SUMMARY = "Boot Processor firmware" -DESCRIPTION = "Boot Processor firmware" -DEPENDS += "virtual/trusted-firmware-a" - -LIC_FILES_CHKSUM = "file://license.md;md5=e44b2531cd6ffe9dece394dbe988d9a0 \ - file://cmsis/LICENSE.txt;md5=e3fc50a88d0a364313df4b21ef20c29e" - -COMPATIBLE_MACHINE = "(corstone700-*)" -SCP_PLATFORM = "corstone-700" - -# boot-firmware project is a fork of scp-firmware -SRC_URI = "gitsm://git.linaro.org/landing-teams/working/arm/boot-firmware.git;protocol=https;branch=master" -SRCREV = "a4dd1b60218b5172a94e6f44c96384b84a77588c" -PV = "0.1.0~git${SRCPV}" - -B = "${WORKDIR}/build" - -EXTRA_OEMAKE = "PRODUCT='${SCP_PLATFORM}' \ - BUILD_PATH=${B} \ - CROSS_COMPILE='arm-none-eabi-' \ - " -do_compile_append() { - oe_runmake -C ${S}/tools/spitoc CC=${BUILD_CC} clean all -} - -do_install() { - install -D -p -m 0644 ${B}/product/${SCP_PLATFORM}/se_ramfw/release/bin/firmware.bin ${D}/firmware/se_ramfw.bin - install -D -p -m 0644 ${B}/product/${SCP_PLATFORM}/se_romfw/release/bin/firmware.bin ${D}/firmware/se_romfw.bin - ${S}/tools/spitoc/spitoc \ - --seram ${D}/firmware/se_ramfw.bin \ - --offset 1 \ - --fip ${RECIPE_SYSROOT}/firmware/fip.bin-${TFA_PLATFORM} \ - --offset 33 \ - --out ${D}/firmware/spitoc.bin -} diff --git a/meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware-n1sdp.inc b/meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware-n1sdp.inc index efa3acb1..635ec399 100644 --- a/meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware-n1sdp.inc +++ b/meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware-n1sdp.inc @@ -1,6 +1,5 @@ # N1SDP specific SCP configurations and build instructions -SRCREV = "350be71a2ecef588b8ff5a095a0840de23506e45" SCP_PLATFORM = "n1sdp" SCP_LOG_LEVEL = "INFO" @@ -12,8 +11,6 @@ SRC_URI_append = " \ COMPATIBLE_MACHINE_n1sdp = "n1sdp" -PV = "2.6.0+git${SRCPV}" - DEPENDS += "fiptool-native" DEPENDS += "virtual/trusted-firmware-a" diff --git a/meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware-sgi575.inc b/meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware-sgi575.inc index 158f481a..a2dab3b9 100644 --- a/meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware-sgi575.inc +++ b/meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware-sgi575.inc @@ -1,7 +1,5 @@ # SGI575 specific SCP configurations and build instructions -#it’s a tested tag post-2.6.0 -SRCREV = "7a025658d8318e95dbab4259a8ff7834ae6d8061" SCP_PLATFORM = "sgi575" SCP_LOG_LEVEL = "INFO" @@ -13,7 +11,3 @@ do_install() { install -D "${B}/product/${SCP_PLATFORM}/scp_ramfw/release/bin/scp_ramfw.bin" "${D}/firmware/" install -D "${B}/product/${SCP_PLATFORM}/mcp_romfw/release/bin/mcp_romfw.bin" "${D}/firmware/" } - - -PV = "2.6.0+git${SRCPV}" - diff --git a/meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware-tc0.inc b/meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware-tc0.inc index 013bbf9a..619a63d9 100644 --- a/meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware-tc0.inc +++ b/meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware-tc0.inc @@ -1,12 +1,17 @@ # TC0 specific SCP configuration -# Intermediate SHA with 2.6 baseline version -SRC_URI = "gitsm://github.com/ARM-software/SCP-firmware.git;protocol=https" -SRCREV = "6fad1d3e2f82b2ef51e55928ac3a678a75f64ef4" +# Intermediate SHA with 2.7 baseline version, required for Theodul DSU +SRCREV = "a841e17b9a11784cddd96f3becdd7e4c54cfb44b" +PV = "2.7+git${SRCPV}" + +FILESEXTRAPATHS_prepend_tc0 := "${THISDIR}/files/tc0:" + +SRC_URI_append = " \ + file://0001-product-tc0-add-clock-and-dvfs-support-for-all-cores.patch \ + file://0002-module-cmn_booker-amend-CFGM-base-address.patch \ + " COMPATIBLE_MACHINE = "tc0" SCP_PLATFORM = "tc0" FW_TARGETS = "scp" - -PV = "2.6.0+git${SRCPV}" diff --git a/meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware_2.6%.bbappend b/meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware_2.6%.bbappend new file mode 100644 index 00000000..1ddb4974 --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware_2.6%.bbappend @@ -0,0 +1,7 @@ +# Include machine specific SCP configurations + +MACHINE_SCP_REQUIRE ?= "" + +MACHINE_SCP_REQUIRE_juno = "scp-firmware-juno.inc" + +require ${MACHINE_SCP_REQUIRE} diff --git a/meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware_%.bbappend b/meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware_2.7%.bbappend similarity index 69% rename from meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware_%.bbappend rename to meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware_2.7%.bbappend index 8a687047..443c293f 100644 --- a/meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware_%.bbappend +++ b/meta-arm-bsp/recipes-bsp/scp-firmware/scp-firmware_2.7%.bbappend @@ -3,9 +3,7 @@ MACHINE_SCP_REQUIRE ?= "" MACHINE_SCP_REQUIRE_n1sdp = "scp-firmware-n1sdp.inc" -MACHINE_SCP_REQUIRE_tc0 = "scp-firmware-tc0.inc" -MACHINE_SCP_REQUIRE_juno = "scp-firmware-juno.inc" MACHINE_SCP_REQUIRE_sgi575 = "scp-firmware-sgi575.inc" -MACHINE_SCP_REQUIRE_corstone700 = "scp-firmware-corstone700.inc" +MACHINE_SCP_REQUIRE_tc0 = "scp-firmware-tc0.inc" require ${MACHINE_SCP_REQUIRE} diff --git a/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/n1sdp/0001-n1sdp-arm-tf-disable-workaround-for-N1-Erratum-13157.patch b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/n1sdp/0001-n1sdp-arm-tf-disable-workaround-for-N1-Erratum-13157.patch index 53a6616b..c199a7b7 100644 --- a/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/n1sdp/0001-n1sdp-arm-tf-disable-workaround-for-N1-Erratum-13157.patch +++ b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/n1sdp/0001-n1sdp-arm-tf-disable-workaround-for-N1-Erratum-13157.patch @@ -26,6 +26,7 @@ software running on N1 SDP, including those that do not require mitigation. This patch is meant for performance evaluation purposes ONLY and should not be used for software that requires a seccomp computing environment. +Upstream-Status: Inappropriate Signed-off-by: James Yang --- plat/arm/board/n1sdp/platform.mk | 2 ++ diff --git a/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/tc0/0001-product-tc0-Add-support-for-Trusted-Services-Secure-.patch b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/tc0/0001-product-tc0-Add-support-for-Trusted-Services-Secure-.patch new file mode 100644 index 00000000..99e3cf28 --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/tc0/0001-product-tc0-Add-support-for-Trusted-Services-Secure-.patch @@ -0,0 +1,199 @@ +From bda42d4e1c56022692b60447279d5321f872aa2b Mon Sep 17 00:00:00 2001 +From: Davidson K +Date: Wed, 10 Mar 2021 12:07:15 +0530 +Subject: [PATCH 1/2] product/tc0: Add support for Trusted Services Secure + Partitions + +This patch adds support for the crypto and secure storage secure +partitions for the Total Compute platform. These secure partitions +have to be managed by Hafnium executing at S-EL2 + +Signed-off-by: Davidson K +Change-Id: I2df690e3a99bf6bf50e2710994a905914a07026e +Upstream-Status: Pending [Not submitted to upstream yet] +--- + Makefile | 4 + + docs/plat/arm/arm-build-options.rst | 4 + + .../fdts/tc0_spmc_ts_optee_sp_manifest.dts | 118 ++++++++++++++++++ + plat/arm/board/tc0/fdts/tc0_tb_fw_config.dts | 10 ++ + 4 files changed, 136 insertions(+) + create mode 100644 plat/arm/board/tc0/fdts/tc0_spmc_ts_optee_sp_manifest.dts + +diff --git a/Makefile b/Makefile +index b6c8b210c..d85c52bb4 100644 +--- a/Makefile ++++ b/Makefile +@@ -514,6 +514,10 @@ ifneq (${SPD},none) + ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp) + DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG + endif ++ ++ ifeq ($(findstring ts_optee_sp,$(ARM_SPMC_MANIFEST_DTS)),ts_optee_sp) ++ DTC_CPPFLAGS += -DTS_SP_FW_CONFIG ++ endif + else + # All other SPDs in spd directory + SPD_DIR := spd +diff --git a/docs/plat/arm/arm-build-options.rst b/docs/plat/arm/arm-build-options.rst +index a1d231357..32cf19291 100644 +--- a/docs/plat/arm/arm-build-options.rst ++++ b/docs/plat/arm/arm-build-options.rst +@@ -98,6 +98,10 @@ Arm Platform Build Options + device tree. This flag is defined only when ``ARM_SPMC_MANIFEST_DTS`` manifest + file name contains pattern optee_sp. + ++ - ``TS_SP_FW_CONFIG``: DTC build flag to include Trusted Services (Crypto and ++ secure-storage) as SP in tb_fw_config device tree. This flag is defined only ++ when ``ARM_SPMC_MANIFEST_DTS`` manifest file name contains pattern ts_optee_sp. ++ + For a better understanding of these options, the Arm development platform memory + map is explained in the :ref:`Firmware Design`. + +diff --git a/plat/arm/board/tc0/fdts/tc0_spmc_ts_optee_sp_manifest.dts b/plat/arm/board/tc0/fdts/tc0_spmc_ts_optee_sp_manifest.dts +new file mode 100644 +index 000000000..ac91db238 +--- /dev/null ++++ b/plat/arm/board/tc0/fdts/tc0_spmc_ts_optee_sp_manifest.dts +@@ -0,0 +1,118 @@ ++/* ++ * Copyright (c) 2020, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++/dts-v1/; ++ ++/ { ++ compatible = "arm,ffa-core-manifest-1.0"; ++ #address-cells = <2>; ++ #size-cells = <1>; ++ ++ attribute { ++ spmc_id = <0x8000>; ++ maj_ver = <0x1>; ++ min_ver = <0x0>; ++ exec_state = <0x0>; ++ load_address = <0x0 0xfd000000>; ++ entrypoint = <0x0 0xfd000000>; ++ binary_size = <0x80000>; ++ }; ++ ++ hypervisor { ++ compatible = "hafnium,hafnium"; ++ vm1 { ++ is_ffa_partition; ++ debug_name = "op-tee"; ++ load_address = <0xfd280000>; ++ vcpu_count = <8>; ++ mem_size = <0x1980000>; /* 25MB TZC DRAM */ ++ }; ++ vm2 { ++ is_ffa_partition; ++ debug_name = "secure-storage"; ++ load_address = <0xfee00000>; ++ vcpu_count = <1>; ++ mem_size = <0x200000>; /* 2MB TZC DRAM */ ++ }; ++ vm3 { ++ is_ffa_partition; ++ debug_name = "crypto"; ++ load_address = <0xfec00000>; ++ vcpu_count = <1>; ++ mem_size = <0x200000>; /* 2MB TZC DRAM */ ++ }; ++ }; ++ ++ cpus { ++ #address-cells = <0x2>; ++ #size-cells = <0x0>; ++ ++ CPU0:cpu@0 { ++ device_type = "cpu"; ++ compatible = "arm,armv8"; ++ reg = <0x0 0x0>; ++ enable-method = "psci"; ++ }; ++ ++ /* ++ * SPMC (Hafnium) requires secondary cpu nodes are declared in ++ * descending order ++ */ ++ CPU7:cpu@700 { ++ device_type = "cpu"; ++ compatible = "arm,armv8"; ++ reg = <0x0 0x700>; ++ enable-method = "psci"; ++ }; ++ ++ CPU6:cpu@600 { ++ device_type = "cpu"; ++ compatible = "arm,armv8"; ++ reg = <0x0 0x600>; ++ enable-method = "psci"; ++ }; ++ ++ CPU5:cpu@500 { ++ device_type = "cpu"; ++ compatible = "arm,armv8"; ++ reg = <0x0 0x500>; ++ enable-method = "psci"; ++ }; ++ ++ CPU4:cpu@400 { ++ device_type = "cpu"; ++ compatible = "arm,armv8"; ++ reg = <0x0 0x400>; ++ enable-method = "psci"; ++ }; ++ ++ CPU3:cpu@300 { ++ device_type = "cpu"; ++ compatible = "arm,armv8"; ++ reg = <0x0 0x300>; ++ enable-method = "psci"; ++ }; ++ ++ CPU2:cpu@200 { ++ device_type = "cpu"; ++ compatible = "arm,armv8"; ++ reg = <0x0 0x200>; ++ enable-method = "psci"; ++ }; ++ ++ CPU1:cpu@100 { ++ device_type = "cpu"; ++ compatible = "arm,armv8"; ++ reg = <0x0 0x100>; ++ enable-method = "psci"; ++ }; ++ }; ++ ++ /* 32MB of TC0_TZC_DRAM1_BASE */ ++ memory@fd000000 { ++ device_type = "memory"; ++ reg = <0x0 0xfd000000 0x2000000>; ++ }; ++}; +diff --git a/plat/arm/board/tc0/fdts/tc0_tb_fw_config.dts b/plat/arm/board/tc0/fdts/tc0_tb_fw_config.dts +index de5f95d5e..82c6ccb27 100644 +--- a/plat/arm/board/tc0/fdts/tc0_tb_fw_config.dts ++++ b/plat/arm/board/tc0/fdts/tc0_tb_fw_config.dts +@@ -27,6 +27,16 @@ + + secure-partitions { + compatible = "arm,sp"; ++#if TS_SP_FW_CONFIG ++ secure-storage { ++ uuid = <0xdc1eef48 0x4ccfb17a 0xcfdf8bac 0x141b71f7>; ++ load-address = <0xfee00000>; ++ }; ++ crypto { ++ uuid = <0xd9df52d5 0x4bb216a2 0x6dd2a49a 0xc0e8843b>; ++ load-address = <0xfec00000>; ++ }; ++#endif + #if OPTEE_SP_FW_CONFIG + op-tee { + uuid = <0x486178e0 0xe7f811e3 0xbc5e0002 0xa5d5c51b>; +-- +2.29.2 + diff --git a/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/tc0/0002-tc0-update-GICR-base-address.patch b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/tc0/0002-tc0-update-GICR-base-address.patch new file mode 100644 index 00000000..038847bd --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/tc0/0002-tc0-update-GICR-base-address.patch @@ -0,0 +1,59 @@ +From bc31cd2454854ab44aa9861b98f13848c2b474aa Mon Sep 17 00:00:00 2001 +From: Usama Arif +Date: Tue, 30 Mar 2021 16:39:19 +0100 +Subject: [PATCH 2/2] tc0: update GICR base address + +The number of ITS have changed from 4 to 1, resulting +in GICR base address change. + +Signed-off-by: Usama Arif +Change-Id: I28101f0d1faf9f3c58591b642033c3fd49a275e7 +Upstream-Status: Pending [Not submitted to upstream yet] +--- + fdts/tc0.dts | 4 ++-- + plat/arm/board/tc0/include/platform_def.h | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/fdts/tc0.dts b/fdts/tc0.dts +index 2d7611cf2..382860d9d 100644 +--- a/fdts/tc0.dts ++++ b/fdts/tc0.dts +@@ -1,5 +1,5 @@ + /* +- * Copyright (c) 2020, Arm Limited. All rights reserved. ++ * Copyright (c) 2020-2021, Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +@@ -236,7 +236,7 @@ + ranges; + interrupt-controller; + reg = <0x0 0x30000000 0 0x10000>, /* GICD */ +- <0x0 0x30140000 0 0x200000>; /* GICR */ ++ <0x0 0x30080000 0 0x200000>; /* GICR */ + interrupts = <0x1 0x9 0x4>; + }; + +diff --git a/plat/arm/board/tc0/include/platform_def.h b/plat/arm/board/tc0/include/platform_def.h +index 30b5ab716..b169d7720 100644 +--- a/plat/arm/board/tc0/include/platform_def.h ++++ b/plat/arm/board/tc0/include/platform_def.h +@@ -1,5 +1,5 @@ + /* +- * Copyright (c) 2020, Arm Limited. All rights reserved. ++ * Copyright (c) 2020-2021, Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +@@ -220,7 +220,7 @@ + /* GIC related constants */ + #define PLAT_ARM_GICD_BASE UL(0x30000000) + #define PLAT_ARM_GICC_BASE UL(0x2C000000) +-#define PLAT_ARM_GICR_BASE UL(0x30140000) ++#define PLAT_ARM_GICR_BASE UL(0x30080000) + + /* + * PLAT_CSS_MAX_SCP_BL2_SIZE is calculated using the current +-- +2.29.2 + diff --git a/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/tc0/sp_layout.json b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/tc0/sp_layout.json new file mode 100644 index 00000000..d0a4078e --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/files/tc0/sp_layout.json @@ -0,0 +1,16 @@ +{ + "secure-storage" : { + "image": "secure-storage.bin", + "pm": "secure-storage.dts" + }, + + "crypto" : { + "image": "crypto-sp.bin", + "pm": "crypto.dts" + }, + + "op-tee" : { + "image": "tee-pager_v2.bin", + "pm": "optee_manifest.dts" + } +} diff --git a/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-a5ds.inc b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-corstone500.inc similarity index 85% rename from meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-a5ds.inc rename to meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-corstone500.inc index d8927944..4d3432cb 100644 --- a/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-a5ds.inc +++ b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-corstone500.inc @@ -1,6 +1,6 @@ -# Cortex-A5 Designstart specific TFA support +# Corstone-500 specific TFA support -COMPATIBLE_MACHINE = "a5ds" +COMPATIBLE_MACHINE = "corstone500" TFA_PLATFORM = "a5ds" TFA_DEBUG = "1" TFA_UBOOT = "1" diff --git a/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-corstone700.inc b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-corstone700.inc index f48ac64a..bdffec88 100644 --- a/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-corstone700.inc +++ b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-corstone700.inc @@ -13,6 +13,9 @@ LIC_FILES_CHKSUM = "file://license.rst;md5=1dd070c98a281d18d9eefd938729b031" # fdts: corstone700: add NXP isp1763 node to device tree SRCREV_tfa = "a6f65b11529b618ff04017f64054dc661c489068" +# This is incorporated into the SRCREV above +SRC_URI_remove = "file://0001-fdts-a5ds-Fix-for-the-system-timer-issue.patch" + PV = "2.3+git${SRCPV}" EXTRA_OEMAKE_append = " \ diff --git a/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-fvp.inc b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-fvp.inc index 27031ebc..43340cdc 100644 --- a/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-fvp.inc +++ b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-fvp.inc @@ -1,11 +1,10 @@ # FVP specific TFA parameters # -# Armv8-A Base Platform FVP and Armv8-A Foundation Platform uses the same -# TFAs. +# Armv8-A Base Platform FVP # -COMPATIBLE_MACHINE = "fvp-base|foundation-armv8" +COMPATIBLE_MACHINE = "fvp-base" TFA_PLATFORM = "fvp" TFA_DEBUG = "1" TFA_MBEDTLS = "1" diff --git a/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-n1sdp.inc b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-n1sdp.inc index a9cf38fb..fbc43586 100644 --- a/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-n1sdp.inc +++ b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-n1sdp.inc @@ -11,7 +11,3 @@ TFA_UBOOT = "0" SRC_URI_append = " \ file://0001-n1sdp-arm-tf-disable-workaround-for-N1-Erratum-13157.patch \ " - -SRCREV_tfa = "dffd5192df41e77e27bb524bfe64d747c1c43522" - -PV = "2.3+git${SRCPV}" diff --git a/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-tc0.inc b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-tc0.inc index eb72e575..aa47840c 100644 --- a/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-tc0.inc +++ b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-tc0.inc @@ -1,7 +1,17 @@ -# TCO specific TFA configuration +# TC0 specific TFA configuration -# Intermediate SHA with 2.3 baseline version -SRCREV_tfa = "00ad74c7afe67b2ffaf08300710f18d3dafebb45" +# Intermediate SHA with 2.4 baseline version, required for Theodul DSU +# --- This SRC_URI will be removed once below SRCREV_tfa gets merged to TF-A master +SRC_URI = "git://git.trustedfirmware.org/TF-A/trusted-firmware-a.git;protocol=https;branch=integration;name=tfa" +SRCREV_tfa = "8078b5c5a0c2a47710df96412d88df53486e2b29" +PV = "2.4+git${SRCPV}" + +FILESEXTRAPATHS_prepend_tc0 := "${THISDIR}/files/tc0:" + +SRC_URI_append = " \ + file://0001-product-tc0-Add-support-for-Trusted-Services-Secure-.patch \ + file://0002-tc0-update-GICR-base-address.patch \ + " DEPENDS += "scp-firmware" DEPENDS += "spm" @@ -20,14 +30,27 @@ TFA_UBOOT = "1" TFA_INSTALL_TARGET = "bl1 fip" TFA_MBEDTLS = "1" +TFA_SPD = "spmd" +TFA_SPMD_SPM_AT_SEL2 = "1" + +# Set optee, crypto-sp and secure-storage as the SP. +# Set spmc manifest and sp layout file to match. +DEPENDS += "optee-os crypto-sp secure-storage" +SRC_URI_append = " file://sp_layout.json;subdir=sp_layout" + +TFA_SP_LAYOUT_FILE = "${WORKDIR}/sp_layout/sp_layout.json" +TFA_ARM_SPMC_MANIFEST_DTS = "plat/arm/board/tc0/fdts/tc0_spmc_ts_optee_sp_manifest.dts" + EXTRA_OEMAKE += "SCP_BL2=${RECIPE_SYSROOT}/firmware/scp_ramfw.bin" EXTRA_OEMAKE += "TRUSTED_BOARD_BOOT=1 GENERATE_COT=1 ARM_ROTPK_LOCATION=devel_rsa \ ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem" - -do_compile[depends] += " spm:do_deploy " -EXTRA_OEMAKE += " SPD=spmd CTX_INCLUDE_EL2_REGS=1 ARM_ARCH_MINOR=4 BL32=${DEPLOY_DIR_IMAGE}/hafnium.bin" - -# Enable test secure partitions if SP_AT_SEL1 is cactus -do_compile[depends] += " tf-a-tests:do_deploy " -EXTRA_OEMAKE += " SP_LAYOUT_FILE=${DEPLOY_DIR_IMAGE}/sp_layout.json " +do_compile_prepend() { + cp -t ${WORKDIR}/sp_layout \ + ${RECIPE_SYSROOT}/${nonarch_base_libdir}/firmware/tee-pager_v2.bin \ + ${RECIPE_SYSROOT}/${nonarch_base_libdir}/firmware/optee_manifest.dts \ + ${RECIPE_SYSROOT}/firmware/secure-storage.bin \ + ${RECIPE_SYSROOT}/firmware/secure-storage.dts \ + ${RECIPE_SYSROOT}/firmware/crypto-sp.bin \ + ${RECIPE_SYSROOT}/firmware/crypto.dts +} diff --git a/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.2.bbappend b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.2.bbappend index c6bd1113..73e15d0d 100644 --- a/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.2.bbappend +++ b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.2.bbappend @@ -1,7 +1,6 @@ # Machine specific TFAs MACHINE_TFA_REQUIRE ?= "" -MACHINE_TFA_REQUIRE_fvp-base-arm32 = "trusted-firmware-a-fvp-arm32.inc" MACHINE_TFA_REQUIRE_sgi575 = "trusted-firmware-a-sgi575.inc" require ${MACHINE_TFA_REQUIRE} diff --git a/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.3.bbappend b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.3.bbappend index 0e6fb1ea..0535278a 100644 --- a/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.3.bbappend +++ b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.3.bbappend @@ -1,11 +1,7 @@ # Machine specific TFAs MACHINE_TFA_REQUIRE ?= "" -MACHINE_TFA_REQUIRE_tc0 = "trusted-firmware-a-tc0.inc" -MACHINE_TFA_REQUIRE_a5ds = "trusted-firmware-a-a5ds.inc" -MACHINE_TFA_REQUIRE_foundation-armv8 = "trusted-firmware-a-fvp.inc" -MACHINE_TFA_REQUIRE_fvp-base = "trusted-firmware-a-fvp.inc" -MACHINE_TFA_REQUIRE_n1sdp = "trusted-firmware-a-n1sdp.inc" +MACHINE_TFA_REQUIRE_corstone500 = "trusted-firmware-a-corstone500.inc" MACHINE_TFA_REQUIRE_juno = "trusted-firmware-a-juno.inc" MACHINE_TFA_REQUIRE_corstone700 = "trusted-firmware-a-corstone700.inc" diff --git a/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.4.bbappend b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.4.bbappend new file mode 100644 index 00000000..8087f39d --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.4.bbappend @@ -0,0 +1,9 @@ +# Machine specific TFAs + +MACHINE_TFA_REQUIRE ?= "" +MACHINE_TFA_REQUIRE_fvp-base = "trusted-firmware-a-fvp.inc" +MACHINE_TFA_REQUIRE_fvp-base-arm32 = "trusted-firmware-a-fvp-arm32.inc" +MACHINE_TFA_REQUIRE_n1sdp = "trusted-firmware-a-n1sdp.inc" +MACHINE_TFA_REQUIRE_tc0 = "trusted-firmware-a-tc0.inc" + +require ${MACHINE_TFA_REQUIRE} diff --git a/meta-arm-bsp/recipes-bsp/trusted-firmware-m/trusted-firmware-m_%.bbappend b/meta-arm-bsp/recipes-bsp/trusted-firmware-m/trusted-firmware-m_%.bbappend deleted file mode 100644 index d7a099e0..00000000 --- a/meta-arm-bsp/recipes-bsp/trusted-firmware-m/trusted-firmware-m_%.bbappend +++ /dev/null @@ -1,4 +0,0 @@ -COMPATIBLE_MACHINE = "musca-b1|musca-s1" - -TFM_PLATFORM_musca-b1 = "MUSCA_B1" -TFM_PLATFORM_musca-s1 = "MUSCA_S1" diff --git a/meta-arm-bsp/recipes-bsp/u-boot/files/corstone700/0001-arm-Add-corstone700-platform.patch b/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.04/corstone700/0001-arm-Add-corstone700-platform.patch similarity index 100% rename from meta-arm-bsp/recipes-bsp/u-boot/files/corstone700/0001-arm-Add-corstone700-platform.patch rename to meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.04/corstone700/0001-arm-Add-corstone700-platform.patch diff --git a/meta-arm-bsp/recipes-bsp/u-boot/files/corstone700/0002-boot-add-bootx-command-to-start-XiP-images.patch b/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.04/corstone700/0002-boot-add-bootx-command-to-start-XiP-images.patch similarity index 100% rename from meta-arm-bsp/recipes-bsp/u-boot/files/corstone700/0002-boot-add-bootx-command-to-start-XiP-images.patch rename to meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.04/corstone700/0002-boot-add-bootx-command-to-start-XiP-images.patch diff --git a/meta-arm-bsp/recipes-bsp/u-boot/files/corstone700/0003-boot-starting-the-XIP-kernel-using-bootx-command.patch b/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.04/corstone700/0003-boot-starting-the-XIP-kernel-using-bootx-command.patch similarity index 100% rename from meta-arm-bsp/recipes-bsp/u-boot/files/corstone700/0003-boot-starting-the-XIP-kernel-using-bootx-command.patch rename to meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.04/corstone700/0003-boot-starting-the-XIP-kernel-using-bootx-command.patch diff --git a/meta-arm-bsp/recipes-bsp/u-boot/files/corstone700/0004-arm-enabling-the-arch_timer-driver.patch b/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.04/corstone700/0004-arm-enabling-the-arch_timer-driver.patch similarity index 100% rename from meta-arm-bsp/recipes-bsp/u-boot/files/corstone700/0004-arm-enabling-the-arch_timer-driver.patch rename to meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.04/corstone700/0004-arm-enabling-the-arch_timer-driver.patch diff --git a/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.07/a5ds/0001-armv7-add-mmio-timer.patch b/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.07/corstone500/0001-armv7-adding-generic-timer-access-through-MMIO.patch similarity index 58% rename from meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.07/a5ds/0001-armv7-add-mmio-timer.patch rename to meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.07/corstone500/0001-armv7-adding-generic-timer-access-through-MMIO.patch index e59afea6..8ba35be8 100644 --- a/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.07/a5ds/0001-armv7-add-mmio-timer.patch +++ b/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.07/corstone500/0001-armv7-adding-generic-timer-access-through-MMIO.patch @@ -1,21 +1,33 @@ -From 4449a6c2de38bdeb09e3158f6d9318812966243a Mon Sep 17 00:00:00 2001 +Upstream-Status: Pending [Not submitted to upstream yet] +Signed-off-by: Abdellatif El Khlifi + +From b6879fc62b5ec01e3c87c2772d3a5e0f51c35f1c Mon Sep 17 00:00:00 2001 From: Rui Miguel Silva Date: Wed, 18 Dec 2019 21:52:34 +0000 -Subject: [PATCH 1/2] armv7: add mmio timer +Subject: [PATCH] armv7: adding generic timer access through MMIO -This timer can be used by u-boot when arch-timer is not available in -core, for example, Cortex-A5. +This driver enables the ARMv7 generic timer. + +The access to the timer registers is through memory mapping (MMIO). + +This driver can be used by u-boot to access to the timer through MMIO +when arch_timer is not available in the core (access using system +instructions not possible), for example, in case of Cortex-A5. + +This driver configures and enables the generic timer at +the u-boot initcall level (timer_init) before u-boot relocation. Signed-off-by: Rui Miguel Silva +Signed-off-by: Abdellatif El Khlifi --- arch/arm/cpu/armv7/Makefile | 1 + - arch/arm/cpu/armv7/mmio_timer.c | 56 +++++++++++++++++++++++++++++++++ + arch/arm/cpu/armv7/mmio_timer.c | 64 +++++++++++++++++++++++++++++++++ scripts/config_whitelist.txt | 1 + - 3 files changed, 58 insertions(+) + 3 files changed, 66 insertions(+) create mode 100644 arch/arm/cpu/armv7/mmio_timer.c diff --git a/arch/arm/cpu/armv7/Makefile b/arch/arm/cpu/armv7/Makefile -index 8c955d0d5284..82af9c031277 100644 +index 8c955d0d52..82af9c0312 100644 --- a/arch/arm/cpu/armv7/Makefile +++ b/arch/arm/cpu/armv7/Makefile @@ -28,6 +28,7 @@ obj-$(CONFIG_ARMV7_PSCI) += psci.o psci-common.o @@ -28,10 +40,10 @@ index 8c955d0d5284..82af9c031277 100644 obj-y += s5p-common/ diff --git a/arch/arm/cpu/armv7/mmio_timer.c b/arch/arm/cpu/armv7/mmio_timer.c new file mode 100644 -index 000000000000..5d6f66172398 +index 0000000000..82ff3937b6 --- /dev/null +++ b/arch/arm/cpu/armv7/mmio_timer.c -@@ -0,0 +1,56 @@ +@@ -0,0 +1,64 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2019, Arm Limited. All rights reserved. @@ -47,22 +59,30 @@ index 000000000000..5d6f66172398 + +#define CNTCTLBASE 0x1a020000UL +#define CNTREADBASE 0x1a030000UL ++#define CNTEN (1 << 0) ++#define CNTFCREQ (1 << 8) + +static inline uint32_t mmio_read32(uintptr_t addr) +{ + return *(volatile uint32_t*)addr; +} + ++static inline void mmio_write32(uintptr_t addr, uint32_t data) ++{ ++ *(volatile uint32_t*)addr = data; ++} ++ +int timer_init(void) +{ -+ gd->arch.timer_rate_hz = mmio_read32(CNTCTLBASE); -+ ++ gd->arch.timer_rate_hz = COUNTER_FREQUENCY / CONFIG_SYS_HZ; /* calculating the frequency in ms */ ++ mmio_write32(CNTCTLBASE + 0x20, COUNTER_FREQUENCY); /* configuring CNTFID0 register: setting the base frequency */ ++ mmio_write32(CNTCTLBASE, CNTFCREQ | CNTEN); /* configuring CNTCR register: enabling the generic counter and selecting the first frequency entry */ + return 0; +} + +unsigned long long get_ticks(void) +{ -+ return ((mmio_read32(CNTCTLBASE + 0x4) << 32) | ++ return ((mmio_read32(CNTREADBASE + 0x4) << 32) | + mmio_read32(CNTREADBASE)); +} + @@ -89,7 +109,7 @@ index 000000000000..5d6f66172398 + return gd->arch.timer_rate_hz; +} diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt -index 916768f361d9..c8fd8c6e355a 100644 +index 916768f361..c8fd8c6e35 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -3075,6 +3075,7 @@ CONFIG_SYS_MMC_U_BOOT_DST @@ -101,5 +121,5 @@ index 916768f361d9..c8fd8c6e355a 100644 CONFIG_SYS_MONITOR_BASE CONFIG_SYS_MONITOR_BASE_EARLY -- -2.28.0 +2.17.1 diff --git a/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.07/a5ds/0002-board-arm-add-designstart-cortex-a5-board.patch b/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.07/corstone500/0002-board-arm-add-corstone500-board.patch similarity index 96% rename from meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.07/a5ds/0002-board-arm-add-designstart-cortex-a5-board.patch rename to meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.07/corstone500/0002-board-arm-add-corstone500-board.patch index 204bdb3c..33e1b155 100644 --- a/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.07/a5ds/0002-board-arm-add-designstart-cortex-a5-board.patch +++ b/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.07/corstone500/0002-board-arm-add-corstone500-board.patch @@ -1,4 +1,7 @@ -From eed15d394137616a18add204a85b0e9dd5b00e0b Mon Sep 17 00:00:00 2001 +Upstream-Status: Pending [Not submitted to upstream yet] +Signed-off-by: Abdellatif El Khlifi + +From f58e263f575c0520926e4737694e11da31cb4886 Mon Sep 17 00:00:00 2001 From: Rui Miguel Silva Date: Wed, 8 Jan 2020 09:48:11 +0000 Subject: [PATCH 2/2] board: arm: add designstart cortex-a5 board @@ -22,7 +25,7 @@ Signed-off-by: Rui Miguel Silva create mode 100644 include/configs/designstart_ca5.h diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig -index 54d65f84889f..7bc12f0b4300 100644 +index 54d65f8488..7bc12f0b43 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -665,6 +665,12 @@ config ARCH_BCM6858 @@ -48,7 +51,7 @@ index 54d65f84889f..7bc12f0b4300 100644 source "board/broadcom/bcm28155_ap/Kconfig" diff --git a/board/armltd/designstart/Kconfig b/board/armltd/designstart/Kconfig new file mode 100644 -index 000000000000..a9564e8655e2 +index 0000000000..a9564e8655 --- /dev/null +++ b/board/armltd/designstart/Kconfig @@ -0,0 +1,12 @@ @@ -66,7 +69,7 @@ index 000000000000..a9564e8655e2 +endif diff --git a/board/armltd/designstart/Makefile b/board/armltd/designstart/Makefile new file mode 100644 -index 000000000000..d2dc2b74ed85 +index 0000000000..d2dc2b74ed --- /dev/null +++ b/board/armltd/designstart/Makefile @@ -0,0 +1,8 @@ @@ -80,7 +83,7 @@ index 000000000000..d2dc2b74ed85 +obj-y := designstart.o diff --git a/board/armltd/designstart/designstart.c b/board/armltd/designstart/designstart.c new file mode 100644 -index 000000000000..658057a00330 +index 0000000000..658057a003 --- /dev/null +++ b/board/armltd/designstart/designstart.c @@ -0,0 +1,49 @@ @@ -135,7 +138,7 @@ index 000000000000..658057a00330 + diff --git a/configs/designstart_ca5_defconfig b/configs/designstart_ca5_defconfig new file mode 100644 -index 000000000000..a2a756740295 +index 0000000000..a2a7567402 --- /dev/null +++ b/configs/designstart_ca5_defconfig @@ -0,0 +1,37 @@ @@ -178,7 +181,7 @@ index 000000000000..a2a756740295 + diff --git a/include/configs/designstart_ca5.h b/include/configs/designstart_ca5.h new file mode 100644 -index 000000000000..6db5b1cf4ac2 +index 0000000000..6db5b1cf4a --- /dev/null +++ b/include/configs/designstart_ca5.h @@ -0,0 +1,122 @@ @@ -305,5 +308,5 @@ index 000000000000..6db5b1cf4ac2 +#define CONFIG_ENV_IS_IN_FLASH 1 +#endif -- -2.28.0 +2.17.1 diff --git a/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.07/juno/u-boot_vexpress_uenv.patch b/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.07/juno/u-boot_vexpress_uenv.patch index c68c173b..68433ed9 100644 --- a/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.07/juno/u-boot_vexpress_uenv.patch +++ b/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.07/juno/u-boot_vexpress_uenv.patch @@ -1,16 +1,39 @@ +From 5372743bab931e0f31e37c3767077abd504eca2b Mon Sep 17 00:00:00 2001 +From: Damodar Santhapuri +Date: Thu, 5 Nov 2020 22:40:48 +0530 +Subject: [PATCH] arm: juno: add custom bootcmd to autoboot from uEnv.txt file + +enable autoboot support with custom bootcmd loads uEnv.txt +from NOR to DRAM and import. + +Signed-off-by: Damodar Santhapuri +Upstream-Status: Pending +--- + include/configs/vexpress_aemv8a.h | 40 ++++++++++++++++++++++++++----- + 1 file changed, 34 insertions(+), 6 deletions(-) + diff --git a/include/configs/vexpress_aemv8a.h b/include/configs/vexpress_aemv8a.h -index 09cdd3dab5..7d6d231bd9 100644 +index 09cdd3dab5..9c9f8dfd16 100644 --- a/include/configs/vexpress_aemv8a.h +++ b/include/configs/vexpress_aemv8a.h -@@ -136,6 +136,32 @@ +@@ -131,11 +131,39 @@ + "kernel_name=norkern\0" \ + "kernel_alt_name=Image\0" \ + "kernel_addr_r=0x80080000\0" \ +- "ramdisk_name=ramdisk.img\0" \ +- "ramdisk_addr_r=0x88000000\0" \ ++ "initrd_name=ramdisk.img\0" \ ++ "initrd_addr_r=0x88000000\0" \ "fdtfile=board.dtb\0" \ "fdt_alt_name=juno\0" \ "fdt_addr_r=0x80000000\0" \ -+ "bootenvfile=uEnv.txt\0" \ -+ "bootcmd=run envboot\0" \ -+ "envboot=if run loadbootenv; then echo Loading env from ${bootenvfile}; run importbootenv; else run default_bootcmd; fi; if test -n $uenvcmd; then echo Running uenvcmd ...; run uenvcmd;fi;\0" \ ++ "fdt_high=0xffffffffffffffff\0" \ ++ "initrd_high=0xffffffffffffffff\0" \ ++ "bootenvfile=uEnv.txt\0" \ ++ "bootcmd=run envboot\0" \ ++ "envboot=if run loadbootenv; then echo Loading env from ${bootenvfile}; run importbootenv; else run default_bootcmd; fi; if test -n $uenvcmd; then echo Running uenvcmd ...; run uenvcmd;fi;\0" \ + "importbootenv=echo Importing environment from memory, size ${filesize}; env import -t ${loadaddr} ${filesize}\0" \ -+ "loadaddr=0x82000000\0" \ ++ "loadaddr=0x84000000\0" \ + "filesize=0x4000\0" \ + "loadbootenv=mw.l ${loadaddr} 0 0x1000; afs load ${bootenvfile} ${loadaddr}\0" \ + "default_bootcmd=echo running default boot command; afs load ${kernel_name} ${kernel_addr_r} ; " \ @@ -26,12 +49,32 @@ index 09cdd3dab5..7d6d231bd9 100644 + " afs load ${fdt_alt_name} ${fdt_addr_r}; "\ + "fi ; "\ + "fdt addr ${fdt_addr_r}; fdt resize; " \ -+ "if afs load ${ramdisk_name} ${ramdisk_addr_r} ; "\ ++ "if afs load ${initrd_name} ${initrd_addr_r} ; "\ + "then "\ -+ " setenv ramdisk_param ${ramdisk_addr_r}; "\ -+ " else setenv ramdisk_param -; "\ ++ " setenv initrd_param ${initrd_addr_r}; "\ ++ " else setenv initrd_param -; "\ + "fi ; " \ -+ "booti ${kernel_addr_r} ${ramdisk_param} ${fdt_addr_r}\0" ++ "booti ${kernel_addr_r} ${initrd_param} ${fdt_addr_r}\0" /* Copy the kernel and FDT to DRAM memory and boot */ #define CONFIG_BOOTCOMMAND "afs load ${kernel_name} ${kernel_addr_r} ;"\ +@@ -151,12 +179,12 @@ + " afs load ${fdt_alt_name} ${fdt_addr_r}; "\ + "fi ; "\ + "fdt addr ${fdt_addr_r}; fdt resize; " \ +- "if afs load ${ramdisk_name} ${ramdisk_addr_r} ; "\ ++ "if afs load ${initrd_name} ${initrd_addr_r} ; "\ + "then "\ +- " setenv ramdisk_param ${ramdisk_addr_r}; "\ +- " else setenv ramdisk_param -; "\ ++ " setenv initrd_param ${initrd_addr_r}; "\ ++ " else setenv initrd_param -; "\ + "fi ; " \ +- "booti ${kernel_addr_r} ${ramdisk_param} ${fdt_addr_r}" ++ "booti ${kernel_addr_r} ${initrd_param} ${fdt_addr_r}" + + + #elif CONFIG_TARGET_VEXPRESS64_BASE_FVP +-- +2.17.1 + diff --git a/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.07/fvp-base-arm32/0001-Add-vexpress_aemv8a_aarch32-variant.patch b/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.10/fvp-base-arm32/0001-Add-vexpress_aemv8a_aarch32-variant.patch similarity index 99% rename from meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.07/fvp-base-arm32/0001-Add-vexpress_aemv8a_aarch32-variant.patch rename to meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.10/fvp-base-arm32/0001-Add-vexpress_aemv8a_aarch32-variant.patch index 39c7e6ae..ccfa57ec 100644 --- a/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.07/fvp-base-arm32/0001-Add-vexpress_aemv8a_aarch32-variant.patch +++ b/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.10/fvp-base-arm32/0001-Add-vexpress_aemv8a_aarch32-variant.patch @@ -13,7 +13,7 @@ vexpress_armv8a.h. This patch is co-authored with Soby Mathew . -Upstream-status: Denied +Upstream-Status: Denied For upstream discussion, please visit https://www.mail-archive.com/u-boot@lists.denx.de/msg233429.html diff --git a/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.07/fvp-common/u-boot_vexpress_fvp.patch b/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.10/fvp-base/u-boot_vexpress_fvp.patch similarity index 93% rename from meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.07/fvp-common/u-boot_vexpress_fvp.patch rename to meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.10/fvp-base/u-boot_vexpress_fvp.patch index 9a21687e..0934e40d 100644 --- a/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.07/fvp-common/u-boot_vexpress_fvp.patch +++ b/meta-arm-bsp/recipes-bsp/u-boot/u-boot-2020.10/fvp-base/u-boot_vexpress_fvp.patch @@ -1,4 +1,5 @@ Upstream-Status: Inappropriate [OE config specific] +Signed-off-by: Anders Dellien diff --git a/configs/vexpress_aemv8a_semi_defconfig b/configs/vexpress_aemv8a_semi_defconfig index f0ac2f9da3..93fcd3026a 100644 diff --git a/meta-arm-bsp/recipes-bsp/u-boot/u-boot_%.bbappend b/meta-arm-bsp/recipes-bsp/u-boot/u-boot_%.bbappend deleted file mode 100644 index e6167571..00000000 --- a/meta-arm-bsp/recipes-bsp/u-boot/u-boot_%.bbappend +++ /dev/null @@ -1,49 +0,0 @@ -# Machine specific u-boot - -THIS_DIR := "${THISDIR}" -FILESEXTRAPATHS_prepend = "${THIS_DIR}/${BP}:" -FILESEXTRAPATHS_prepend_fvp-base = "${THIS_DIR}/${BP}/fvp-common:" -FILESEXTRAPATHS_prepend_foundation-armv8 = "${THIS_DIR}/${BP}/fvp-common:" - -# -# Cortex-A5 DesignStart KMACHINE -# -SRC_URI_append_a5ds = " file://0001-armv7-add-mmio-timer.patch \ - file://0002-board-arm-add-designstart-cortex-a5-board.patch" - -# -# FVP FOUNDATION KMACHINE -# -SRC_URI_append_foundation-armv8 = " file://u-boot_vexpress_fvp.patch" - -# -# FVP BASE KMACHINE -# -SRC_URI_append_fvp-base = " file://u-boot_vexpress_fvp.patch" - -# -# FVP BASE ARM32 KMACHINE -# -SRC_URI_append_fvp-base-arm32 = " file://0001-Add-vexpress_aemv8a_aarch32-variant.patch" - -# -# Juno KMACHINE -# -SRC_URI_append_juno = " file://u-boot_vexpress_uenv.patch" - -# -# Total Compute KMACHINE -# -SRC_URI_tc0 = "git://git.denx.de/u-boot.git \ - " -SRCREV_tc0 = "565add124de00c994652a0d2d6d1eb6b2a7c9553" -LIC_FILES_CHKSUM_tc0 = "file://Licenses/README;md5=5a7450c57ffe5ae63fd732446b988025" -# -# Corstone700 KMACHINE -# -FILESEXTRAPATHS_prepend_corstone700 := "${THISDIR}/files/corstone700:" - -SRC_URI_append_corstone700 = " file://0001-arm-Add-corstone700-platform.patch \ - file://0002-boot-add-bootx-command-to-start-XiP-images.patch \ - file://0003-boot-starting-the-XIP-kernel-using-bootx-command.patch \ - file://0004-arm-enabling-the-arch_timer-driver.patch" diff --git a/meta-arm-bsp/recipes-bsp/u-boot/u-boot_2020.04.bbappend b/meta-arm-bsp/recipes-bsp/u-boot/u-boot_2020.04.bbappend new file mode 100644 index 00000000..00b40e55 --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/u-boot/u-boot_2020.04.bbappend @@ -0,0 +1,8 @@ +# +# Corstone700 KMACHINE +# +FILESEXTRAPATHS_prepend_corstone700 := "${THISDIR}/${BP}/corstone700:" +SRC_URI_append_corstone700 = " file://0001-arm-Add-corstone700-platform.patch \ + file://0002-boot-add-bootx-command-to-start-XiP-images.patch \ + file://0003-boot-starting-the-XIP-kernel-using-bootx-command.patch \ + file://0004-arm-enabling-the-arch_timer-driver.patch" diff --git a/meta-arm-bsp/recipes-bsp/u-boot/u-boot_2020.07.bb b/meta-arm-bsp/recipes-bsp/u-boot/u-boot_2020.07.bb new file mode 100644 index 00000000..fa99a3a8 --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/u-boot/u-boot_2020.07.bb @@ -0,0 +1,26 @@ +HOMEPAGE = "http://www.denx.de/wiki/U-Boot/WebHome" +DESCRIPTION = "U-Boot, a boot loader for Embedded boards based on PowerPC, \ +ARM, MIPS and several other processors, which can be installed in a boot \ +ROM and used to initialize and test the hardware or to download and run \ +application code." +SECTION = "bootloaders" +DEPENDS += "flex-native bison-native" + +LICENSE = "GPLv2+" +LIC_FILES_CHKSUM = "file://Licenses/README;md5=30503fd321432fc713238f582193b78e" +PE = "1" + +# We use the revision in order to avoid having to fetch it from the +# repo during parse +SRCREV = "2f5fbb5b39f7b67044dda5c35e4a4b31685a3109" + +SRC_URI = "git://git.denx.de/u-boot.git \ + " + +S = "${WORKDIR}/git" +B = "${WORKDIR}/build" +do_configure[cleandirs] = "${B}" + +require recipes-bsp/u-boot/u-boot.inc + +DEPENDS += "bc-native dtc-native" diff --git a/meta-arm-bsp/recipes-bsp/u-boot/u-boot_2020.07.bbappend b/meta-arm-bsp/recipes-bsp/u-boot/u-boot_2020.07.bbappend new file mode 100644 index 00000000..add6a782 --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/u-boot/u-boot_2020.07.bbappend @@ -0,0 +1,16 @@ +# Machine specific u-boot + +THIS_DIR := "${THISDIR}" +FILESEXTRAPATHS_prepend = "${THIS_DIR}/${BP}:" + +# +# Corstone-500 MACHINE +# +SRC_URI_append_corstone500 = " \ + file://0001-armv7-adding-generic-timer-access-through-MMIO.patch \ + file://0002-board-arm-add-corstone500-board.patch" + +# +# Juno KMACHINE +# +SRC_URI_append_juno = " file://u-boot_vexpress_uenv.patch" diff --git a/meta-arm-bsp/recipes-bsp/u-boot/u-boot_2020.10.bbappend b/meta-arm-bsp/recipes-bsp/u-boot/u-boot_2020.10.bbappend new file mode 100644 index 00000000..6067981f --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/u-boot/u-boot_2020.10.bbappend @@ -0,0 +1,13 @@ +# Machine specific u-boot + +FILESEXTRAPATHS_prepend := "${THISDIR}/${BP}:" + +# +# FVP BASE +# +SRC_URI_append_fvp-base = " file://u-boot_vexpress_fvp.patch" + +# +# FVP BASE ARM32 +# +SRC_URI_append_fvp-base-arm32 = " file://0001-Add-vexpress_aemv8a_aarch32-variant.patch" diff --git a/meta-arm-bsp/recipes-bsp/uefi/edk2-firmware-fvp-base.inc b/meta-arm-bsp/recipes-bsp/uefi/edk2-firmware-fvp-base.inc new file mode 100644 index 00000000..badec193 --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/uefi/edk2-firmware-fvp-base.inc @@ -0,0 +1,7 @@ +EDK2_BUILD_RELEASE = "0" +EDK2_PLATFORM = "ArmVExpress-FVP-AArch64" +EDK2_PLATFORM_DSC = "Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc" +EDK2_BIN_NAME = "FVP_AARCH64_EFI.fd" +EDK2_ARCH = "AARCH64" + +COMPATIBLE_MACHINE = "fvp-base" diff --git a/meta-arm-bsp/recipes-bsp/uefi/edk2-firmware-n1sdp.inc b/meta-arm-bsp/recipes-bsp/uefi/edk2-firmware-n1sdp.inc index 78463ac7..07a41b0f 100644 --- a/meta-arm-bsp/recipes-bsp/uefi/edk2-firmware-n1sdp.inc +++ b/meta-arm-bsp/recipes-bsp/uefi/edk2-firmware-n1sdp.inc @@ -1,23 +1,16 @@ -SRC_URI = "\ - git://git.linaro.org/landing-teams/working/arm/edk2.git;name=edk2;destsuffix=edk2;nobranch=1 \ - git://git.linaro.org/landing-teams/working/arm/edk2-platforms.git;name=edk2-platforms;destsuffix=edk2/edk2-platforms;nobranch=1 \ -" +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" -# TAGS and commit ID as per N1SDP-2020.03.26 release -SRCREV_edk2 = "3ff8a6bffabad761279817252014d59b6069d68a" -SRCREV_edk2-platforms = "d9d32e6c8b7456d21ce365486ac563b6be36c20d" +SRC_URI += "file://initialise.patch" # N1SDP specific EDK2 configurations EDK2_BUILD_RELEASE = "0" EDK2_PLATFORM = "n1sdp" -EDK2_PLATFORM_DSC = "N1SdpPkg/N1SdpPlatform.dsc" +EDK2_PLATFORM_DSC = "Platform/ARM/N1SdpPkg/N1SdpPlatform.dsc" EDK2_BIN_NAME = "BL33_AP_UEFI.fd" EDK2_ARCH = "AARCH64" COMPATIBLE_MACHINE = "n1sdp" -PV = "201908+git${SRCPV}" - # UEFI EDK2 on N1SDP is unable to detect FS2 during boot resulting in launching of # EDK2 shell instead of launching grub. The startup.nsh will force launching of grub EFIDIR = "/EFI/BOOT" diff --git a/meta-arm-bsp/recipes-bsp/uefi/edk2-firmware-sgi575.inc b/meta-arm-bsp/recipes-bsp/uefi/edk2-firmware-sgi575.inc index 0e30a712..708cd4c4 100644 --- a/meta-arm-bsp/recipes-bsp/uefi/edk2-firmware-sgi575.inc +++ b/meta-arm-bsp/recipes-bsp/uefi/edk2-firmware-sgi575.inc @@ -1,13 +1,8 @@ -SRCREV_edk2 = "50528537b2fb0ebdf32c719a0525635c93b905c2" -SRCREV_edk2-platforms = "b972f17b329a85e6aa4d69f240d459839ba8b47c" - # SGI575 specific EDK2 configurations EDK2_BUILD_RELEASE = "0" EDK2_PLATFORM = "Sgi575" -EDK2_PLATFORM_DSC = "SgiPkg/Sgi575/Sgi575.dsc" +EDK2_PLATFORM_DSC = "Platform/ARM/SgiPkg/Sgi575/Sgi575.dsc" EDK2_BIN_NAME = "BL33_AP_UEFI.fd" EDK2_ARCH = "AARCH64" COMPATIBLE_MACHINE = "sgi575" - -PV = "202005+git${SRCPV}" diff --git a/meta-arm-bsp/recipes-bsp/uefi/edk2-firmware_201911.bbappend b/meta-arm-bsp/recipes-bsp/uefi/edk2-firmware_201911.bbappend new file mode 100644 index 00000000..cc25ee0f --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/uefi/edk2-firmware_201911.bbappend @@ -0,0 +1,8 @@ +EDK2_SRC_URI = "git://git.linaro.org/landing-teams/working/arm/edk2.git" +EDK2_PLATFORMS_SRC_URI = "git://git.linaro.org/landing-teams/working/arm/edk2-platforms.git" + +# TAGS and commit ID as per N1SDP-2020.03.26 release +SRCREV_edk2 = "3ff8a6bffabad761279817252014d59b6069d68a" +SRCREV_edk2-platforms = "d9d32e6c8b7456d21ce365486ac563b6be36c20d" + +require edk2-firmware-n1sdp.inc diff --git a/meta-arm-bsp/recipes-bsp/uefi/edk2-firmware_git.bbappend b/meta-arm-bsp/recipes-bsp/uefi/edk2-firmware_202011.bbappend similarity index 74% rename from meta-arm-bsp/recipes-bsp/uefi/edk2-firmware_git.bbappend rename to meta-arm-bsp/recipes-bsp/uefi/edk2-firmware_202011.bbappend index bef54b07..d34cd272 100644 --- a/meta-arm-bsp/recipes-bsp/uefi/edk2-firmware_git.bbappend +++ b/meta-arm-bsp/recipes-bsp/uefi/edk2-firmware_202011.bbappend @@ -2,7 +2,7 @@ MACHINE_EDK2_REQUIRE ?= "" -MACHINE_EDK2_REQUIRE_n1sdp = "edk2-firmware-n1sdp.inc" +MACHINE_EDK2_REQUIRE_fvp-base = "edk2-firmware-fvp-base.inc" MACHINE_EDK2_REQUIRE_sgi575 = "edk2-firmware-sgi575.inc" require ${MACHINE_EDK2_REQUIRE} diff --git a/meta-arm-bsp/recipes-bsp/uefi/files/n1sdp/initialise.patch b/meta-arm-bsp/recipes-bsp/uefi/files/n1sdp/initialise.patch new file mode 100644 index 00000000..86fcd154 --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/uefi/files/n1sdp/initialise.patch @@ -0,0 +1,32 @@ +These variables can be returned without being set, so assign reasonable +fallback values for the error paths. + +Upstream-Status: Pending +Signed-off-by: Ross Burton + +From ef296251231a9a646051efbed0d81131f0876e25 Mon Sep 17 00:00:00 2001 +From: Ross Burton +Date: Wed, 21 Oct 2020 17:29:17 +0100 +Subject: [PATCH] Add missing Status assignments + +--- + Platform/ARM/Drivers/CcixDxe/CcixEnumeration.c | 2 +- + Platform/ARM/N1SdpPkg/Drivers/PlatformDxe/PlatformDxe.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/Platform/ARM/Drivers/CcixDxe/CcixEnumeration.c b/Platform/ARM/Drivers/CcixDxe/CcixEnumeration.c +index b605d9adbd..6b11a8545d 100644 +--- a/edk2-platforms/Platform/ARM/Drivers/CcixDxe/CcixEnumeration.c ++++ b/edk2-platforms/Platform/ARM/Drivers/CcixDxe/CcixEnumeration.c +@@ -684 +684 @@ CcixAgentInit( +- EFI_STATUS Status; ++ EFI_STATUS Status = EFI_ABORTED; +diff --git a/Platform/ARM/N1SdpPkg/Drivers/PlatformDxe/PlatformDxe.c b/Platform/ARM/N1SdpPkg/Drivers/PlatformDxe/PlatformDxe.c +index c828165d07..e1f7f5e8ea 100644 +--- a/edk2-platforms/Platform/ARM/N1SdpPkg/Drivers/PlatformDxe/PlatformDxe.c ++++ b/edk2-platforms/Platform/ARM/N1SdpPkg/Drivers/PlatformDxe/PlatformDxe.c +@@ -26 +26 @@ ArmN1SdpPkgEntryPoint ( +- EFI_STATUS Status; ++ EFI_STATUS Status = EFI_UNSUPPORTED; +-- +2.25.1 diff --git a/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/n1sdp/n1sdp-preempt-rt.scc b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/n1sdp/n1sdp-preempt-rt.scc new file mode 100644 index 00000000..414732c7 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/n1sdp/n1sdp-preempt-rt.scc @@ -0,0 +1,6 @@ +define KMACHINE n1sdp +define KTYPE preempt-rt +define KARCH arm64 + +kconf non-hardware ktypes/developer/developer.cfg +kconf non-hardware ktypes/preempt-rt/preempt-rt.cfg diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-arm-platforms.inc b/meta-arm-bsp/recipes-kernel/linux/linux-arm-platforms.inc index 62b1dec8..39cde7a0 100644 --- a/meta-arm-bsp/recipes-kernel/linux/linux-arm-platforms.inc +++ b/meta-arm-bsp/recipes-kernel/linux/linux-arm-platforms.inc @@ -9,25 +9,15 @@ FILESEXTRAPATHS_prepend := "${THISDIR}:${THISDIR}/files:" # Arm platforms kmeta SRC_URI_KMETA = "file://arm-platforms-kmeta;type=kmeta;name=arm-platforms-kmeta;destsuffix=arm-platforms-kmeta" -SRC_URI_append_foundation-armv8 = " ${SRC_URI_KMETA}" SRC_URI_append_fvp-base = " ${SRC_URI_KMETA}" SRC_URI_append_fvp-base-arm32 = " ${SRC_URI_KMETA}" SRC_URI_append_juno = " ${SRC_URI_KMETA}" -SRC_URI_append_sgi575 = " ${SRC_URI_KMETA}" -SRC_URI_append_gem5-arm64 = " ${SRC_URI_KMETA}" SRCREV_arm-platforms-kmeta = "6147e82375aa9df8f2a162d42ea6406c79c854c5" # -# Cortex-A5 DesignStart KMACHINE +# Corstone-500 KMACHINE # -COMPATIBLE_MACHINE_a5ds = "a5ds" -KMACHINE_a5ds = "a5ds" - -# -# FVP FOUNDATION KMACHINE -# -COMPATIBLE_MACHINE_foundation-armv8 = "foundation-armv8" -KMACHINE_foundation-armv8 = "fvp" +COMPATIBLE_MACHINE_corstone500 = "corstone500" # # FVP BASE KMACHINE @@ -86,5 +76,38 @@ SRC_URI_append_tc0 = " \ file://0006-mailbox-arm_mhuv2-add-multi-word-transport-protocol-.patch \ file://0007-firmware-arm_scmi-Add-fast_switch_possible-api.patch \ file://0008-cpufreq-arm_scmi-Set-fast_switch_possible-conditiona.patch \ + file://0009-driver-firmware-Initial-version-of-ffa-driver-based-.patch \ + file://0010-tee-add-support-for-session-s-client-UUID-generation.patch \ + file://0011-tee-optee-Add-support-for-session-login-client-UUID-.patch \ + file://0012-driver-optee-Support-for-ffa-transport.patch \ + file://0013-tee-optee-fix-mem-handle-removal-in-ffa_shm_unregist.patch \ + file://0014-arm64-Add-support-for-asymmetric-AArch32-EL0-configu.patch \ + file://0015-arm64-smp-Prevent-hotplugging-the-last-AArch32-able-.patch \ + file://0016-drivers-buf-Add-userspace-ff-a-driver-buf-and-add-to.patch \ + file://0017-drivers-ffa-modify-FFA-ABIs-with-supported-conventio.patch \ " +# +# N1SDP KMACHINE +# +FILESEXTRAPATHS_prepend_n1sdp := "${THISDIR}/linux-yocto-5.10/n1sdp:" +COMPATIBLE_MACHINE_n1sdp = "n1sdp" +KBUILD_DEFCONFIG_n1sdp = "defconfig" +KCONFIG_MODE_n1sdp = "--alldefconfig" +SRC_URI_append_n1sdp = " \ + file://0001-pci_quirk-add-acs-override-for-PCI-devices.patch \ + file://0002-pcie-Add-quirk-for-the-Arm-Neoverse-N1SDP-platform.patch \ + file://0003-n1sdp-update-n1sdp-pci-quirk-for-SR-IOV-support.patch \ + file://0004-n1sdp-pcie-add-quirk-support-enabling-remote-chip-PC.patch \ + file://0005-r8169-Fix-to-avoid-duplicate-sysfs-entry-creation-er.patch \ + file://0001-arm64-defconfig-drop-unused-BACKLIGHT_GENERIC-option.patch \ + file://no-power-avs.patch \ + file://enable-realtek-R8169.cfg \ + file://enable-usb_conn_gpio.cfg \ + " + +# +# Musca B1/S2 can't run Linux +# +COMPATIBLE_MACHINE_musca-b1 = "(^$)" +COMPATIBLE_MACHINE_musca-s1 = "(^$)" diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0009-driver-firmware-Initial-version-of-ffa-driver-based-.patch b/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0009-driver-firmware-Initial-version-of-ffa-driver-based-.patch new file mode 100644 index 00000000..e5e1ff6b --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0009-driver-firmware-Initial-version-of-ffa-driver-based-.patch @@ -0,0 +1,1461 @@ +Upstream-Status: Pending [https://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux.git/commit/?h=ffa_rel_proto&id=74aeede25bd737f4930e1322f5780ec1c61b9fd5] +Signed-off-by: Arunachalam Ganapathy + +From 411f4ed69a06f213fb2abb7dbef0be5ce31ff55e Mon Sep 17 00:00:00 2001 +From: Jose Marinho +Date: Tue, 29 Oct 2019 09:28:55 +0000 +Subject: [PATCH] driver: firmware: Initial version of ffa driver based on + ffa_rel_proto + +Initial version of ffa driver based on ffa_rel_proto [1]. + +[1]: https://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux.git/log/?h=ffa_rel_proto + +Squashed in: + firmware: arm64/spci: Add initial SPCI driver + + Add initial SPCI driver + + firmware: spci: add conduit selection from DT + + The driver can use smc or hvc conduits depending on what is + specified in the spci node in the DT. + + arm64: spci/smccc: Create smc call returning on x0 to x7 + + The new smc call is SMCCCv1.2 compliant. + + arm_spci: Register Rx/Tx buffers. + + Registers the Rx/Tx buffers with the SPCI implementation at a higher EL. + The buffers are restricted to 4KB in this implementation. + + arm_spci: Add SPCI memory sharing mechanisms. + + Add mem_share and mem_reclaim to the SPCI driver interface. + These two methods allow for the basic memory sharing use-case where + normal world shares a set of pages with secure world. + The memory region description is in this implementation restricted to + 4KB (i.e. it must fit in the Tx buffer of the normal world VM). + + spci_driver/mem_share: Add lock around TX Buffer + + Ensure we aquire a lock around the TX buffer when sending information to + prevent race conditions. + + arm_spci: Expose SPCI_PARTITION_INFO_GET + + Expose the SPCI_PARTITION_INFO_GET ABI to allow querying the system for + information about a set of partitions identified by a specified UUID. + + The function expects the 128bit UUID to be discovered passed via 4 32bit + words in the format: UUID_0-UUID_1-UUID_2-UUID3 and a pointer to an + array of `spci_partition_info` structs that will allocated and populated + with the discovered partitions information by the SPCI driver. The + caller is responsible for freeing this memory allocated by the SPCI + driver. + + The function returns the number of the partitions found (and therefore + the number of elements in the array) or a negative value indicating the + error code if unsuccessful. + + This implementation currently disallows use of the NULL UUID. + + arm_spci: Implement rx_release + + SPCI: Move driver to directory + + The SPCI driver has a specific directory at drivers/firmware/spci. + + SPCI: multi-fragment memory share support + + arm_spci: use scatterlist in mem_share interface + + Previously an array of page* was passed in the mem_share interface. + This commit introduces a scatterlist as partameter to mem_share function. + + arm_spci: Add RX_RELEASE return to spci_rx_release + + A Hypervisor can return SPCI_RX_RELEASE when the PVM calls + SPCI_RX_RELEASE to signal that other VMs need to be scheduled. + + arm_spci: Change spci_memory_reclaim declaration + + Function takes an enum mem_clear_t flag to denote if memory should be + cleared upon reclaim. + + arm_spci: Allow nil UUID in spci_parition_info_get + + Previously the nil UUID was disallowed. + + arm_spci: Add support for non-Tx buffer mem_share + + This commit introduces the buffer*, buffer_size parameters to the + mem_share function. The buffer can be used alternatively to the Tx + buffer. The mem_share function will populate the IPA-contiguous memory + pointed to by buffer using the information in sg. + + The buffer* must be NULL is mem_share should use the Tx buffer. + The buffer*, if non-NULL, must point to a IPA-contiguous memory region + of size multiple of 4kiB. + + arm_spci: Support pause/resume in mem_share handle + + The Hypervisor is allowed to return SPCI_MEM_OPS_PAUSE if a mem_share + operation is taking too long. The PVM must reply with + SPCI_MEM_OPS_RESUME. + + arm_spci: Ammend debug print. + + arm_spci: add missing fields in mem descriptor + + The sender_id, vm_id fields were not properly filled in the mem_share + function. + + arm_spci: mem_share selection of Tx or alloc buf + + This commit allows the mem_share invokation to select the tx buffer or a + dynamically allocated buffer to be used for the transfer of the memory + region description. + + if use_tx == true: the tx_lock is held until the memory region is fully + transmitted. + + if use_tx == false: the tx_lock is very briefly held in the preamble + and postamble of the mem_share procedure. + + arm_spci: Allow compilation for arm arch [smcccv1_2 bits] + + arm_spci: Allow compilation for arm arch [arm_spci bits] + + Implement SPCI features + + Currently only SPCI_Direct_Req is checked during SPCI driver + initialisation. + + arm_spci: add err print when features does not report direct_req support + + arm_spci: refactor mem_share implementation for EAC [arm_spci bits] + + arm_spci: introduce support for SPCI_INTERRUPT + + A SP while executing in the context of a SPCI_MSG_SEND_DIRECT_REQ + may be interrupted. In which case the scheduler must be instructed and + be provided with the necessary information to resume the interrupted SP. + + arm_ffa: optee: Swap spci/SPCI for ffa/FFA. [arm_ffa bits] + + arm_ffa: Implement ffa_version discovery. + + arm_ffa: corrections to EAC support. + + arm_ffa: cast status return to signed for compare + + arm_ffa: rename 1st member of arm_smcccv1_2_return [arm-smcccv1_2.h bits] + + The smcccv1_2_return.func is renamed to arg0. + + arm_ffa: rename 1st member of arm_smcccv1_2_return [arm_ffa bits] + + The smcccv1_2_return.func is renamed to arg0. + + arm_ffa: set the default shareability to inner. + + Pages are shared with inner shareability attribute set in S2. + + arm_ffa: remove some panic calls + + Some panics were swaped by pr_warns and an error code return when the + error condition being signaled is predicted by the FFA spec. The panics + issued when an unexpected status is returned from EL2 or + EL3 (behaviour deviating from the FFA spec) are left in the driver. + + arm_ffa: fix warnings and remove debug print + + Fixed few warnings related to unused variable and in pr_warn prints + + arm_ffa: correct checkpatch warnings + + arm_ffa.h: Split memory access permissions + + Split the FF-A instruction and data access permissions. + This allows for specifying one attribute but not the other. This is + required for lenders of memory for which must not specify the + instruction access permission. + +Signed-off-by: Jose Marinho +Signed-off-by: Marc Bonnici +Signed-off-by: Arunachalam Ganapathy +Change-Id: I7bd8cf453e99498ab4df1f01092137a67116d15d +--- + arch/arm/kernel/Makefile | 1 + + arch/arm/kernel/smcccv1_2-call.S | 58 +++ + arch/arm64/kernel/Makefile | 2 +- + arch/arm64/kernel/smccc_v1_2-call.S | 24 + + drivers/firmware/Kconfig | 11 + + drivers/firmware/Makefile | 1 + + drivers/firmware/ffa/Makefile | 6 + + drivers/firmware/ffa/arm_ffa.c | 782 ++++++++++++++++++++++++++++ + include/linux/arm-smcccv1_2.h | 51 ++ + include/linux/arm_ffa.h | 235 +++++++++ + 10 files changed, 1170 insertions(+), 1 deletion(-) + create mode 100644 arch/arm/kernel/smcccv1_2-call.S + create mode 100644 arch/arm64/kernel/smccc_v1_2-call.S + create mode 100644 drivers/firmware/ffa/Makefile + create mode 100644 drivers/firmware/ffa/arm_ffa.c + create mode 100644 include/linux/arm-smcccv1_2.h + create mode 100644 include/linux/arm_ffa.h + +diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile +index 8cad59465af3..5be97585d130 100644 +--- a/arch/arm/kernel/Makefile ++++ b/arch/arm/kernel/Makefile +@@ -101,5 +101,6 @@ obj-$(CONFIG_SMP) += psci_smp.o + endif + + obj-$(CONFIG_HAVE_ARM_SMCCC) += smccc-call.o ++obj-$(CONFIG_HAVE_ARM_SMCCC) += smcccv1_2-call.o + + extra-y := $(head-y) vmlinux.lds +diff --git a/arch/arm/kernel/smcccv1_2-call.S b/arch/arm/kernel/smcccv1_2-call.S +new file mode 100644 +index 000000000000..9a577c4045a7 +--- /dev/null ++++ b/arch/arm/kernel/smcccv1_2-call.S +@@ -0,0 +1,58 @@ ++/* SPDX-License-Identifier: GPL-2.0-only */ ++/* ++ * Copyright (c) 2020, Linaro Limited ++ */ ++#include ++ ++#include ++#include ++#include ++#include ++ ++ /* ++ * Wrap c macros in asm macros to delay expansion until after the ++ * SMCCC asm macro is expanded. ++ */ ++ .macro SMCCC_SMC ++ __SMC(0) ++ .endm ++ ++ .macro SMCCC_HVC ++ __HVC(0) ++ .endm ++ ++ .macro SMCCC instr ++UNWIND( .fnstart) ++ mov r12, sp ++ push {r4-r7} ++UNWIND( .save {r4-r7}) ++ ldm r12, {r4-r7} ++ \instr ++ ldr r12, [sp, #(4 * 8)] ++ stm r12, {r0-r7} ++ pop {r4-r7} ++ bx lr ++UNWIND( .fnend) ++ .endm ++ ++/* ++ * void smccc_smc(unsigned long a0, unsigned long a1, unsigned long a2, ++ * unsigned long a3, unsigned long a4, unsigned long a5, ++ * unsigned long a6, unsigned long a7, struct arm_smccc_res *res, ++ * struct arm_smccc_quirk *quirk) ++ */ ++ENTRY(__arm_smcccv1_2_smc) ++ SMCCC SMCCC_SMC ++ENDPROC(__arm_smcccv1_2_smc) ++EXPORT_SYMBOL(__arm_smcccv1_2_smc) ++ ++/* ++ * void smccc_hvc(unsigned long a0, unsigned long a1, unsigned long a2, ++ * unsigned long a3, unsigned long a4, unsigned long a5, ++ * unsigned long a6, unsigned long a7, struct arm_smccc_res *res, ++ * struct arm_smccc_quirk *quirk) ++ */ ++ENTRY(__arm_smcccv1_2_hvc) ++ SMCCC SMCCC_HVC ++ENDPROC(__arm_smcccv1_2_hvc) ++EXPORT_SYMBOL(__arm_smcccv1_2_hvc) +diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile +index b3995329d9e5..4327ef6f4f8d 100644 +--- a/arch/arm64/kernel/Makefile ++++ b/arch/arm64/kernel/Makefile +@@ -19,7 +19,7 @@ obj-y := debug-monitors.o entry.o irq.o fpsimd.o \ + return_address.o cpuinfo.o cpu_errata.o \ + cpufeature.o alternative.o cacheinfo.o \ + smp.o smp_spin_table.o topology.o smccc-call.o \ +- syscall.o ++ syscall.o smccc_v1_2-call.o + + extra-$(CONFIG_EFI) := efi-entry.o + +diff --git a/arch/arm64/kernel/smccc_v1_2-call.S b/arch/arm64/kernel/smccc_v1_2-call.S +new file mode 100644 +index 000000000000..518e849409ed +--- /dev/null ++++ b/arch/arm64/kernel/smccc_v1_2-call.S +@@ -0,0 +1,24 @@ ++/* SPDX-License-Identifier: GPL-2.0-only */ ++/* ++ * Copyright (C) 2019 Arm Ltd. ++ */ ++ ++#include ++ ++.macro SMC_CALL conduit ++ \conduit #0 ++ ldr x8, [sp] ++ stp x0, x1, [x8] ++ stp x2, x3, [x8, #16] ++ stp x4, x5, [x8, #32] ++ stp x6, x7, [x8, #48] ++ ret ++.endm ++ ++ENTRY(__arm_smcccv1_2_hvc) ++ SMC_CALL hvc ++ENDPROC(__arm_smcccv1_2_hvc) ++ ++ENTRY(__arm_smcccv1_2_smc) ++ SMC_CALL smc ++ENDPROC(__arm_smcccv1_2_smc) +diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig +index 1bc0e965f2e9..3bcf3d4514e4 100644 +--- a/drivers/firmware/Kconfig ++++ b/drivers/firmware/Kconfig +@@ -77,6 +77,17 @@ config ARM_SDE_INTERFACE + standard for registering callbacks from the platform firmware + into the OS. This is typically used to implement RAS notifications. + ++config ARM_FFA_TRANSPORT ++ bool "ARM Secure Partition Client Interface (FFA)" ++ depends on ARM64 || ARM ++ help ++ The Secure Partition Client Interface (FFA) is an Arm standard for ++ communication and memory sharing between entities managed by SMCCC ++ compliant firmware. ++ ++ This driver provides interface for all the client drivers making ++ use of the features offered by FFA. ++ + config EDD + tristate "BIOS Enhanced Disk Drive calls determine boot disk" + depends on X86 +diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile +index 64f5391e5749..10041c5f4d07 100644 +--- a/drivers/firmware/Makefile ++++ b/drivers/firmware/Makefile +@@ -29,6 +29,7 @@ obj-$(CONFIG_TURRIS_MOX_RWTM) += turris-mox-rwtm.o + + obj-$(CONFIG_ARM_SCMI_PROTOCOL) += arm_scmi/ + obj-y += psci/ ++obj-y += ffa/ + obj-y += broadcom/ + obj-y += meson/ + obj-$(CONFIG_GOOGLE_FIRMWARE) += google/ +diff --git a/drivers/firmware/ffa/Makefile b/drivers/firmware/ffa/Makefile +new file mode 100644 +index 000000000000..37f4ccae197b +--- /dev/null ++++ b/drivers/firmware/ffa/Makefile +@@ -0,0 +1,6 @@ ++# SPDX-License-Identifier: GPL-2.0 ++# ++# Makefile for the linux kernel. ++# ++obj-$(CONFIG_ARM_FFA_TRANSPORT) += arm_ffa.o ++ccflags-y += -Og +diff --git a/drivers/firmware/ffa/arm_ffa.c b/drivers/firmware/ffa/arm_ffa.c +new file mode 100644 +index 000000000000..21838f8c4632 +--- /dev/null ++++ b/drivers/firmware/ffa/arm_ffa.c +@@ -0,0 +1,782 @@ ++// SPDX-License-Identifier: GPL-2.0-only ++/* ++ * Secure Partitions Communication Interface (FFA) Protocol driver ++ * ++ * FFA is a system message passing and memory sharing protocol allowing for ++ * execution contexts to exchange information with other execution contexts ++ * residing on other Secure Partitions or Virtual Machines managed by any FFA ++ * compliant firmware framework. ++ * ++ * Copyright (C) 2019, 2020 Arm Ltd. ++ */ ++#define DEBUG ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++ ++static DEFINE_MUTEX(rx_lock); ++static DEFINE_MUTEX(tx_lock); ++ ++static ffa_sp_id_t vm_id; ++ ++static struct page *rx_buffer; ++static struct page *tx_buffer; ++ ++static struct arm_smcccv1_2_return ++(*arm_ffa_smccc)(u32 func, u64 arg1, u64 arg2, u64 arg3, u64 arg4, ++ u64 arg5, u64 arg6, u64 arg7); ++ ++#define FFA_DEFINE_CALL(conduit) \ ++static struct arm_smcccv1_2_return \ ++arm_ffa_##conduit(u32 func, u64 arg1, u64 arg2, u64 arg3, u64 arg4, \ ++ u64 arg5, u64 arg6, u64 arg7) \ ++{ \ ++ struct arm_smcccv1_2_return smccc_ret; \ ++ \ ++ __arm_smcccv1_2_##conduit(func, arg1, arg2, arg3, arg4, arg5, \ ++ arg6, arg7, &smccc_ret); \ ++ \ ++ return smccc_ret; \ ++} ++ ++FFA_DEFINE_CALL(smc) ++FFA_DEFINE_CALL(hvc) ++ ++static u32 sender_receiver_pack(u32 src_id, u32 dst_id) ++{ ++ return (((src_id << 16) & 0xffff0000) | (dst_id & 0xffff)); ++} ++ ++int ffa_msg_send(ffa_sp_id_t dst_id, u32 len, u32 attributes) ++{ ++ struct arm_smcccv1_2_return msg_send_return; ++ ++ /* w1[32:16] Sender endpoint ID, w1[15:0] destination endpoint id. */ ++ u32 sender_receiver = sender_receiver_pack(vm_id, dst_id); ++ ++ msg_send_return = arm_ffa_smccc(FFA_MSG_SEND_32, sender_receiver, ++ 0, len, attributes, 0, 0, 0); ++ ++ if (msg_send_return.arg0 == FFA_ERROR_32) { ++ switch ((int)msg_send_return.arg2) { ++ case FFA_INVALID_PARAMETERS: ++ return -ENXIO; ++ case FFA_DENIED: ++ case FFA_BUSY: ++ return -EAGAIN; ++ default: ++ panic("%s: Unhandled return code (%lld)\n", __func__, ++ msg_send_return.arg2); ++ } ++ } ++ return 0; ++} ++ ++struct arm_smcccv1_2_return ++ffa_msg_send_direct_req(ffa_sp_id_t dst_id, u64 w3, u64 w4, u64 w5, ++ u64 w6, u64 w7) ++{ ++ struct arm_smcccv1_2_return ret; ++ ++ /* w1[32:16] Sender endpoint ID, w1[15:0] destination endpoint id. */ ++ u32 sender_receiver = sender_receiver_pack(vm_id, dst_id); ++ ++ ret = arm_ffa_smccc(FFA_MSG_SEND_DIRECT_REQ_32, sender_receiver, 0, ++ w3, w4, w5, w6, w7); ++ ++ while (ret.arg0 != FFA_MSG_SEND_DIRECT_RESP_32 && ++ ret.arg0 != FFA_SUCCESS_32) { ++ if (ret.arg0 == FFA_ERROR_32) { ++ pr_err("%s: Error sending message %llu\n", __func__, ++ ret.arg0); ++ switch ((int)ret.arg1) { ++ case FFA_INVALID_PARAMETERS: ++ ret.arg0 = -ENXIO; ++ goto out; ++ ++ case FFA_DENIED: ++ case FFA_NOT_SUPPORTED: ++ ret.arg0 = -EIO; ++ goto out; ++ ++ case FFA_BUSY: ++ ret.arg0 = -EAGAIN; ++ goto out; ++ } ++ } else if (ret.arg0 == FFA_INTERRUPT_32) { ++ ret = arm_ffa_smccc(FFA_RUN_32, ret.arg1, ++ 0, 0, 0, 0, 0, 0); ++ } ++ ++ } ++ ++ ret.arg0 = 0; ++ ++out: ++ return ret; ++} ++ ++static int ffa_share_next_frag(u64 handle, u32 frag_len, u32 *tx_offset) ++{ ++ ++ struct arm_smcccv1_2_return smccc_return; ++ u32 handle_high = (handle >> 32) & 0xffffffff; ++ u32 handle_low = handle & 0xffffffff; ++ ++ smccc_return = ++ arm_ffa_smccc(FFA_MEM_FRAG_TX_32, handle_low, ++ handle_high, frag_len, 0, 0, 0, 0); ++ ++ while (smccc_return.arg0 != FFA_MEM_FRAG_RX_32) { ++ ++ if (smccc_return.arg0 == FFA_ERROR_32) { ++ switch ((int)smccc_return.arg2) { ++ case FFA_INVALID_PARAMETERS: ++ return -ENXIO; ++ case FFA_NOT_SUPPORTED: ++ return -ENODEV; ++ default: ++ pr_warn("%s: Unknown Error code %llx\n", ++ __func__, smccc_return.arg2); ++ return -EIO; ++ } ++ } ++ ++ if (smccc_return.arg0 == FFA_MEM_OP_PAUSE_32) { ++ ++ smccc_return = arm_ffa_smccc(FFA_MEM_OP_RESUME_32, ++ smccc_return.arg1, smccc_return.arg2, 0, 0, 0, ++ 0, 0); ++ } ++ } ++ ++ *tx_offset = smccc_return.arg3; ++ ++ return 0; ++} ++ ++static int ffa_share_init_frag(phys_addr_t buffer, u32 buffer_size, ++ u32 fragment_len, u32 total_len, u64 *handle) ++{ ++ ++ struct arm_smcccv1_2_return smccc_return; ++ ++ smccc_return = ++ arm_ffa_smccc(FFA_MEM_SHARE_64, total_len, fragment_len, buffer, ++ buffer_size, 0, 0, 0); ++ ++ while (smccc_return.arg0 != FFA_SUCCESS_32) { ++ ++ if (smccc_return.arg0 == FFA_ERROR_32) { ++ switch ((int)smccc_return.arg2) { ++ case FFA_INVALID_PARAMETERS: ++ return -ENXIO; ++ case FFA_DENIED: ++ return -EIO; ++ case FFA_NO_MEMORY: ++ return -ENOMEM; ++ case FFA_ABORTED: ++ return -EAGAIN; ++ default: ++ pr_warn("%s: Unknown Error code %llx\n", ++ __func__, smccc_return.arg2); ++ return -EIO; ++ } ++ } ++ ++ if (smccc_return.arg0 == FFA_MEM_OP_PAUSE_32) { ++ ++ smccc_return = arm_ffa_smccc(FFA_MEM_OP_RESUME_32, ++ smccc_return.arg1, smccc_return.arg2, 0, 0, 0, ++ 0, 0); ++ } ++ } ++ ++ *handle = (smccc_return.arg3 << 32) | smccc_return.arg2; ++ ++ return 0; ++} ++ ++static inline u32 compute_composite_offset(u32 num_attributes) ++{ ++ u32 composite_offset = offsetof(struct ffa_mem_region, ++ endpoints[num_attributes]); ++ ++ /* ensure composite are 8 byte aligned. */ ++ if (composite_offset & 0x7) ++ return (composite_offset & (~(u32)0x7)) + 0x8; ++ ++ return composite_offset; ++} ++ ++static inline u32 compute_constituent_offset(u32 num_attributes) ++{ ++ u32 constituent_offset = offsetof(struct ffa_mem_region, ++ endpoints[num_attributes]) + ++ offsetof(struct ffa_composite_memory_region, constituents[0]); ++ ++ /* ensure constituents are 8 byte aligned. */ ++ if (constituent_offset & 0x7) ++ return (constituent_offset & (~(u32)0x7)) + 0x8; ++ ++ return constituent_offset; ++} ++ ++static inline u32 compute_region_length(u32 num_constituents, ++ u32 num_attributes) ++{ ++ /* This assumes that there is a single ffa_composite_memory_region. */ ++ return compute_constituent_offset(num_attributes) + ++ sizeof(struct ffa_mem_region_constituent)*num_constituents; ++} ++ ++static int ffa_rx_release(void) ++{ ++ struct arm_smcccv1_2_return rx_release_return; ++ ++ rx_release_return = arm_ffa_smccc(FFA_RX_RELEASE_32, ++ 0, 0, 0, 0, 0, 0, 0); ++ ++ if (rx_release_return.arg0 == FFA_ERROR_32) { ++ switch ((int)rx_release_return.arg2) { ++ case FFA_DENIED: ++ return -EAGAIN; ++ default: ++ panic("%s: Unhandled return code (%lld)\n", __func__, ++ rx_release_return.arg2); ++ } ++ } ++ ++ if (rx_release_return.arg0 == FFA_RX_RELEASE_32) { ++ /* ++ * FFA implementation returned FFA_RX_RELEASE which signals ++ * the PVM that other VMs need to be scheduled. ++ */ ++ return 1; ++ } ++ ++ return 0; ++} ++ ++static uint32_t ffa_get_num_pages_sg(struct scatterlist *sg) ++{ ++ uint32_t num_pages = 0; ++ ++ do { ++ num_pages += sg->length/PAGE_SIZE; ++ } while ((sg = sg_next(sg))); ++ ++ return num_pages; ++} ++ ++static inline struct ffa_memory_region_attribute ffa_set_region_normal( ++ enum ffa_mem_cacheability cacheability, ++ enum ffa_mem_shareability shareability) ++{ ++ struct ffa_memory_region_attribute attr = {0}; ++ ++ attr.attribute = (FFA_MEM_NORMAL << FFA_MEMTYPE_OFFSET) | ++ (cacheability << FFA_CACHEABILITY_OFFSET) | shareability; ++ ++ return attr; ++} ++ ++static inline struct ffa_memory_region_attribute ffa_set_region_device( ++ enum ffa_mem_device_type device_type) ++{ ++ struct ffa_memory_region_attribute attr = {0}; ++ ++ attr.attribute = (FFA_MEM_DEVICE << FFA_MEMTYPE_OFFSET) | ++ (device_type << FFA_DEVICE_OFFSET); ++ ++ return attr; ++} ++ ++static inline int ffa_transmit_fragment(u32 *tx_offset, phys_addr_t buffer, ++ u32 buffer_size, u32 frag_len, u32 total_len, u64 *handle) ++{ ++ int rc; ++ ++ if (*tx_offset == 0) { ++ rc = ffa_share_init_frag(buffer, buffer_size, ++ frag_len, total_len, handle); ++ ++ *tx_offset = frag_len; ++ } else ++ rc = ffa_share_next_frag(*handle, frag_len, tx_offset); ++ ++ ++ return rc; ++} ++ ++/* ++ * Share a set of pages with a list of destination endpoints. ++ * Returns a system-wide unique handle ++ */ ++static int _ffa_share_memory(u32 tag, enum mem_clear_t flags, ++ struct ffa_mem_region_attributes *attrs, ++ u32 num_attrs, struct scatterlist *sg, u32 nents, ++ ffa_mem_handle_t *handle, phys_addr_t buffer, uint32_t buffer_size) ++{ ++ struct ffa_mem_region *mem_region; ++ u32 index; ++ u32 num_constituents; ++ struct ffa_mem_region_constituent *constituents; ++ u32 total_len; ++ u32 fragment_len = sizeof(struct ffa_mem_region); ++ u32 max_fragment_size; ++ int rc = 0; ++ u32 tx_offset = 0; ++ struct ffa_composite_memory_region *composite = NULL; ++ ++ if (buffer) { ++ ++ BUG_ON(!buffer_size); ++ max_fragment_size = buffer_size * FFA_BASE_GRANULE_SIZE; ++ mem_region = phys_to_virt(buffer); ++ ++ } else { ++ ++ BUG_ON(buffer_size); ++ mem_region = (struct ffa_mem_region *)page_address(tx_buffer); ++ max_fragment_size = FFA_BASE_GRANULE_SIZE; ++ ++ } ++ ++ mem_region->flags = flags; ++ mem_region->tag = tag; ++ mem_region->sender_id = vm_id; ++ mem_region->region_attr = ffa_set_region_normal(FFA_WRITE_BACK, ++ FFA_INNER_SHAREABLE); ++ composite = ffa_get_composite(mem_region, num_attrs); ++ composite->total_page_count = ffa_get_num_pages_sg(sg); ++ ++ fragment_len = compute_constituent_offset(num_attrs); ++ ++ /* Ensure attribute description fits within the Tx buffer. */ ++ if (fragment_len > max_fragment_size) ++ return -ENXIO; ++ ++ constituents = (struct ffa_mem_region_constituent *) ++ (((void *)mem_region) + fragment_len); ++ ++ composite->constituent_count = nents; ++ total_len = compute_region_length(nents, num_attrs); ++ ++ for (index = 0; index < num_attrs; index++) { ++ mem_region->endpoints[index].receiver = attrs[index].receiver; ++ mem_region->endpoints[index].attrs = ++ attrs[index].attrs; ++ ++ mem_region->endpoints[index].composite_off = ++ compute_composite_offset(num_attrs); ++ } ++ mem_region->endpoint_count = num_attrs; ++ ++ num_constituents = 0; ++ ++ do { ++ phys_addr_t address; ++ ++ /* ++ * If current fragment size equal Tx size trigger fragment ++ * transfer. ++ */ ++ if (fragment_len == max_fragment_size) { ++ ++ /* Transmit fragment. */ ++ rc = ffa_transmit_fragment(&tx_offset, buffer, ++ buffer_size, fragment_len, total_len, handle); ++ ++ if (rc < 0) ++ return -ENXIO; ++ ++ ++ constituents = ++ (struct ffa_mem_region_constituent *)mem_region; ++ ++ num_constituents = 0; ++ fragment_len = 0; ++ } ++ ++ address = sg_phys(sg); ++ ++ /* ++ * Detect if any part of the constituent region surpasses the Tx ++ * region. ++ */ ++ if (((void *) &constituents[num_constituents]) ++ - (void *)mem_region > max_fragment_size) { ++ pr_err("%s: memory region fragment greater that the Tx buffer", ++ __func__); ++ return -EFAULT; ++ } ++#if 0 ++ pr_devel("arm_ffa mem_share pa=%#lX\n", address); ++#endif ++ constituents[num_constituents].address = address; ++ constituents[num_constituents].page_count = ++ sg->length/PAGE_SIZE; ++ num_constituents++; ++ fragment_len += sizeof(struct ffa_mem_region_constituent); ++ ++ ++ } while ((sg = sg_next(sg))); ++ ++ rc = ffa_transmit_fragment(&tx_offset, buffer, buffer_size, ++ fragment_len, total_len, handle); ++ ++ return rc; ++} ++ ++/* ++ * Share a set of pages with a list of destination endpoints. ++ * ++ * Returns a system-wide unique handle ++ */ ++static int ffa_share_memory(u32 tag, enum mem_clear_t flags, ++ struct ffa_mem_region_attributes *attrs, ++ u32 num_attrs, struct scatterlist *sg, u32 nents, ++ ffa_mem_handle_t *global_handle, bool use_tx) ++{ ++ u32 buffer_size = 0; ++ phys_addr_t buffer_pa = 0; ++ int ret; ++ struct page *buffer_page = NULL; ++ ++ if (!use_tx) { ++ /* Allocate buffer for this mem_share operation. */ ++ buffer_page = alloc_page(GFP_KERNEL); ++ if (IS_ERR_OR_NULL(buffer_page)) { ++ /* print error. Return as tx lock is not held. */ ++ pr_err("%s: unable to allocate buffer", __func__); ++ return -ENOMEM; ++ } ++ ++ buffer_pa = page_to_phys(buffer_page); ++ ++ buffer_size = 1; ++ } ++ ++ if (use_tx) ++ mutex_lock(&tx_lock); ++ ++ ret = _ffa_share_memory(tag, flags, attrs, num_attrs, sg, nents, ++ global_handle, buffer_pa, buffer_size); ++ ++ if (use_tx) ++ mutex_unlock(&tx_lock); ++ ++ return ret; ++} ++ ++static int ffa_memory_reclaim(ffa_mem_handle_t global_handle, ++ enum mem_clear_t flags) ++{ ++ ++ struct arm_smcccv1_2_return smccc_return; ++ u32 handle_high = (global_handle >> 32) & 0xffffffff; ++ u32 handle_low = global_handle & 0xffffffff; ++ ++ smccc_return = arm_ffa_smccc(FFA_MEM_RECLAIM_32, handle_low, ++ handle_high, flags, 0, 0, 0, 0); ++ ++ if (smccc_return.arg0 == FFA_ERROR_32) { ++ pr_err("%s: Error sending message %llu\n", __func__, ++ smccc_return.arg0); ++ switch ((int)smccc_return.arg2) { ++ case FFA_INVALID_PARAMETERS: ++ return -ENXIO; ++ case FFA_DENIED: ++ case FFA_NOT_SUPPORTED: ++ return -EIO; ++ case FFA_BUSY: ++ return -EAGAIN; ++ default: ++ pr_warn("%s: Unknown Error code %llx\n", __func__, ++ smccc_return.arg2); ++ return -EIO; ++ } ++ } ++ ++ return 0; ++} ++ ++/* ++ * Returns a negative value if function not supported. Otherwise returns w2, ++ * supplying optional feature parameter else 0. ++ */ ++ ++static int ffa_features(uint32_t function_id) ++{ ++ struct arm_smcccv1_2_return features_return = ++ arm_ffa_smccc(FFA_FEATURES_32, function_id, 0, 0, 0, 0, 0, 0); ++ ++ if (features_return.arg0 == FFA_ERROR_32) { ++ switch ((int)features_return.arg2) { ++ case FFA_NOT_SUPPORTED: ++ return -ENODEV; ++ default: ++ panic("%s: Unhandled return code (%lld)\n", __func__, ++ features_return.arg2); ++ } ++ } else { ++ return features_return.arg2; ++ } ++} ++ ++static ffa_sp_id_t ffa_id_get(ffa_sp_id_t *vm_id_p) ++{ ++ struct arm_smcccv1_2_return id_get_return = ++ arm_ffa_smccc(FFA_ID_GET_32, 0, 0, 0, 0, 0, 0, 0); ++ ++ if (id_get_return.arg0 == FFA_ERROR_32) { ++ pr_warn("%s: failed to obtain vm id\n", __func__); ++ return -EIO; ++ } ++ ++ *vm_id_p = id_get_return.arg2 & 0xffff; ++ ++ return 0; ++} ++ ++static int ffa_partition_info_get(uint32_t uuid0, uint32_t uuid1, ++ uint32_t uuid2, uint32_t uuid3, ++ struct ffa_partition_info **buffer) ++{ ++ int rc = 0; ++ uint32_t count; ++ struct ffa_partition_info *info = ++ (struct ffa_partition_info *) page_address(rx_buffer); ++ struct arm_smcccv1_2_return partition_info_get_return; ++ ++ mutex_lock(&rx_lock); ++ partition_info_get_return = arm_ffa_smccc(FFA_PARTITION_INFO_GET_32, ++ uuid0, uuid1, uuid2, uuid3, ++ 0, 0, 0); ++ ++ if (partition_info_get_return.arg0 == FFA_ERROR_32) { ++ switch ((int)partition_info_get_return.arg2) { ++ case FFA_INVALID_PARAMETERS: ++ rc = -ENXIO; ++ goto err; ++ case FFA_NO_MEMORY: ++ rc = -ENOMEM; ++ goto err; ++ case FFA_NOT_SUPPORTED: ++ rc = -ENODEV; ++ goto err; ++ default: ++ panic("%s: Unhandled return code (%lld)\n", __func__, ++ partition_info_get_return.arg2); ++ } ++ } ++ ++ count = partition_info_get_return.arg2; ++ ++ /* Allocate and copy the info structs. ++ * Client is responsible for freeing. ++ */ ++ *buffer = kzalloc(sizeof(struct ffa_partition_info) * count, ++ GFP_KERNEL); ++ if (*buffer == NULL) { ++ rc = -ENOMEM; ++ goto err; ++ } ++ memcpy(*buffer, info, sizeof(struct ffa_partition_info) * count); ++ ++ ffa_rx_release(); ++ ++ rc = count; ++err: ++ mutex_unlock(&rx_lock); ++ ++ return rc; ++} ++ ++static struct ffa_ops ffa_ops = { ++ .async_msg_send = ffa_msg_send, ++ .sync_msg_send = ffa_msg_send_direct_req, ++ .mem_share = ffa_share_memory, ++ .mem_reclaim = ffa_memory_reclaim, ++ .partition_info_get = ffa_partition_info_get, ++}; ++ ++struct ffa_ops *get_ffa_ops(void) ++{ ++ return &ffa_ops; ++} ++EXPORT_SYMBOL_GPL(get_ffa_ops); ++ ++static int ffa_dt_init(struct device_node *np) ++{ ++ const char *conduit; ++ ++ pr_info("FFA: obtaining conduit from DT.\n"); ++ ++ if (of_property_read_string(np, "conduit", &conduit)) { ++ pr_warn("FFA: cannot find conduit in DT\n"); ++ return -ENXIO; ++ } ++ ++ if (!strcmp("smc", conduit)) ++ arm_ffa_smccc = arm_ffa_smc; ++ else if (!strcmp("hvc", conduit)) ++ arm_ffa_smccc = arm_ffa_hvc; ++ else { ++ pr_warn("%s: unrecognized FFA conduit\n", __func__); ++ return -EIO; ++ } ++ ++ return 0; ++} ++ ++static const struct of_device_id ffa_of_match[] = { ++ {.compatible = "arm,ffa"}, ++ {}, ++}; ++ ++static int ffa_rxtx_map(uintptr_t tx_page, uintptr_t rx_page) ++{ ++ struct arm_smcccv1_2_return map_return; ++ ++ map_return = arm_ffa_smccc(FFA_RXTX_MAP_32, tx_page, ++ rx_page, 1, 0, 0, 0, 0); ++ ++ if (map_return.arg0 == FFA_ERROR_32) { ++ switch ((int)map_return.arg2) { ++ case FFA_INVALID_PARAMETERS: ++ return -ENXIO; ++ case FFA_DENIED: ++ return -EAGAIN; ++ case FFA_NO_MEMORY: ++ return -ENOMEM; ++ case FFA_NOT_SUPPORTED: ++ return -ENODEV; ++ ++ default: ++ panic("%s: Unhandled return code (%lld)\n", __func__, ++ map_return.arg2); ++ } ++ } ++ ++ return 0; ++} ++ ++static int ffa_version_check(void) ++{ ++ struct arm_smcccv1_2_return version_return; ++ u16 major = 1; ++ u16 minor = 0; ++ u32 hv_version; ++ ++ version_return = arm_ffa_smccc(FFA_VERSION_32, ((u32)major<<16)|minor, ++ 0, 0, 0, 0, 0, 0); ++ ++ if ((int)version_return.arg0 == FFA_NOT_SUPPORTED) { ++ pr_err("%s: FFA ABI is not supported at higher exception levels\n", ++ __func__); ++ return -ENODEV; ++ } ++ ++ hv_version = version_return.arg0; ++ ++ if ((hv_version>>16) == major) ++ if ((hv_version & 0xffff) >= minor) ++ return 0; ++ ++ pr_err("%s: incompatible FFA ABI at higher exception level (%x)\n", ++ __func__, hv_version); ++ return -ENODEV; ++} ++ ++static int ffa_probe(struct platform_device *pdev) ++{ ++ int ret; ++ ++ ret = ffa_dt_init(pdev->dev.of_node); ++ if (ret) { ++ pr_warn("%s: FFA driver initialization failed\n", __func__); ++ return ret; ++ } ++ ++ ret = ffa_version_check(); ++ if (ret) ++ return ret; ++ ++ /* Initialize VM ID. */ ++ ret = ffa_id_get(&vm_id); ++ if (ret) { ++ pr_warn("%s: failed to obtain own FFA endpoint ID\n", __func__); ++ return ret; ++ } ++ ++ if (ffa_features(FFA_MSG_SEND_DIRECT_REQ_32)) { ++ pr_err("%s: FFA implementation at EL2 does not support FFA_MSG_SEND_DIRECT_REQ_32\n", ++ __func__); ++ return -ENXIO; ++ } ++ ++ /* Allocate Rx buffer. */ ++ rx_buffer = alloc_page(GFP_KERNEL); ++ ++ /* ++ * Ensure buffer was correctly allocated and that the refcout was ++ * incremented. ++ */ ++ if (!rx_buffer || !try_get_page(rx_buffer)) { ++ pr_err("%s: failed to allocate FFA Rx buffer\n", __func__); ++ return -ENOMEM; ++ } ++ ++ /* Allocate Tx buffer. */ ++ tx_buffer = alloc_page(GFP_KERNEL); ++ ++ /* ++ * Ensure buffer was correctly allocated and that the refcout was ++ * incremented. ++ */ ++ if (!tx_buffer || !try_get_page(rx_buffer)) { ++ put_page(rx_buffer); ++ __free_page(rx_buffer); ++ ++ pr_err("%s: failed to allocate FFA Tx buffer\n", __func__); ++ return -ENOMEM; ++ } ++ ++ /* Register the RxTx buffers with the FFA supervisor implementation. */ ++ ret = ffa_rxtx_map(page_to_phys(tx_buffer), page_to_phys(rx_buffer)); ++ if (ret) { ++ put_page(rx_buffer); ++ put_page(tx_buffer); ++ __free_page(rx_buffer); ++ __free_page(tx_buffer); ++ ++ pr_err("%s: failed to register FFA RxTx buffers\n", __func__); ++ return ret; ++ } ++ ++ return 0; ++} ++ ++static struct platform_driver ffa_driver = { ++ .driver = { ++ .name = "ffa_protocol", ++ .of_match_table = ffa_of_match, ++ }, ++ .probe = ffa_probe, ++}; ++module_platform_driver(ffa_driver); ++ ++MODULE_AUTHOR("Arm"); ++MODULE_DESCRIPTION("Arm FFA transport driver"); ++MODULE_LICENSE("GPL v2"); +diff --git a/include/linux/arm-smcccv1_2.h b/include/linux/arm-smcccv1_2.h +new file mode 100644 +index 000000000000..a622cc352ae1 +--- /dev/null ++++ b/include/linux/arm-smcccv1_2.h +@@ -0,0 +1,51 @@ ++/* SPDX-License-Identifier: GPL-2.0-only */ ++/* ++ * Copyright (C) 2019 Arm Ltd. ++ */ ++ ++//#if defined(ARM64) ++#if CONFIG_ARM64 ++struct arm_smcccv1_2_return { ++ u64 arg0; ++ u64 arg1; ++ u64 arg2; ++ u64 arg3; ++ u64 arg4; ++ u64 arg5; ++ u64 arg6; ++ u64 arg7; ++}; ++#elif CONFIG_ARM ++struct arm_smcccv1_2_return { ++ u32 arg0; ++ u32 arg1; ++ u32 arg2; ++ u32 arg3; ++ u32 arg4; ++ u32 arg5; ++ u32 arg6; ++ u32 arg7; ++}; ++#endif ++ ++/** ++ * __arm_smcccv1_2_hvc() - make HVC calls ++ * @a0-a7: arguments passed in registers 0 to 7 ++ * @res: result values from registers 0 to 7 ++ */ ++asmlinkage ++void __arm_smcccv1_2_hvc(unsigned long a0, unsigned long a1, unsigned long a2, ++ unsigned long a3, unsigned long a4, unsigned long a5, ++ unsigned long a6, unsigned long a7, ++ struct arm_smcccv1_2_return *res); ++ ++/** ++ * __arm_smcccv1_2_smc() - make SMC calls ++ * @a0-a7: arguments passed in registers 0 to 7 ++ * @res: result values from registers 0 to 7 ++ */ ++asmlinkage ++void __arm_smcccv1_2_smc(unsigned long a0, unsigned long a1, unsigned long a2, ++ unsigned long a3, unsigned long a4, unsigned long a5, ++ unsigned long a6, unsigned long a7, ++ struct arm_smcccv1_2_return *res); +diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h +new file mode 100644 +index 000000000000..d3c80b7f9e07 +--- /dev/null ++++ b/include/linux/arm_ffa.h +@@ -0,0 +1,235 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++/* ++ * Copyright (C) 2019, 2020 Arm Ltd. ++ */ ++ ++#ifndef __LINUX_ARM_FFA_H ++#define __LINUX_ARM_FFA_H ++ ++#define FFA_ERROR_32 0x84000060 ++#define FFA_SUCCESS_32 0x84000061 ++#define FFA_INTERRUPT_32 0x84000062 ++#define FFA_VERSION_32 0x84000063 ++#define FFA_FEATURES_32 0x84000064 ++#define FFA_RX_RELEASE_32 0x84000065 ++#define FFA_RXTX_MAP_32 0x84000066 ++ ++#define FFA_PARTITION_INFO_GET_32 0x84000068 ++#define FFA_ID_GET_32 0x84000069 ++ ++#define FFA_RUN_32 0x8400006D ++#define FFA_MSG_SEND_32 0x8400006E ++#define FFA_MSG_SEND_DIRECT_REQ_32 0x8400006F ++#define FFA_MSG_SEND_DIRECT_RESP_32 0x84000070 ++#define FFA_MEM_RECLAIM_32 0x84000077 ++#define FFA_MEM_OP_PAUSE_32 0x84000078 ++#define FFA_MEM_OP_RESUME_32 0x84000079 ++ ++#define FFA_MEM_SHARE_64 0xC4000073 ++ ++#define FFA_MEM_FRAG_RX_32 0x8400007A ++#define FFA_MEM_FRAG_TX_32 0x8400007B ++ ++/* FFA error codes. */ ++#define FFA_SUCCESS (0) ++#define FFA_NOT_SUPPORTED (-1) ++#define FFA_INVALID_PARAMETERS (-2) ++#define FFA_NO_MEMORY (-3) ++#define FFA_BUSY (-4) ++#define FFA_INTERRUPTED (-5) ++#define FFA_DENIED (-6) ++#define FFA_RETRY (-7) ++#define FFA_ABORTED (-8) ++ ++#define FFA_BASE_GRANULE_SIZE 4096 ++ ++struct scatterlist; ++ ++enum ffa_mem_permission { ++ FFA_MEM_R = 0x1, ++ FFA_MEM_RW = 0x2, ++ FFA_MEM_XN = 0x4, ++ FFA_MEM_X = 0x8, ++}; ++ ++#define FFA_MEMTYPE_OFFSET 4 ++enum ffa_mem_type { ++ FFA_MEM_DEVICE = 0x1, ++ FFA_MEM_NORMAL = 0x2, ++}; ++ ++ ++#define FFA_CACHEABILITY_OFFSET 2 ++enum ffa_mem_cacheability { ++ FFA_NON_CACHEABLE = 0x1, ++ FFA_WRITE_BACK = 0x3, ++}; ++ ++enum ffa_mem_shareability { ++ FFA_NON_SHAREABLE, ++ FFA_OUTER_SHAREABLE = 0x2, ++ FFA_INNER_SHAREABLE = 0x3, ++}; ++ ++#define FFA_DEVICE_OFFSET 2 ++enum ffa_mem_device_type { ++ FFA_NGNRNE, ++ FFA_NGNRE, ++ FFA_NGRE, ++ FFA_GRE, ++}; ++ ++enum mem_clear_t { ++ FFA_KEEP_MEMORY, ++ FFA_CLEAR_MEMORY, ++}; ++ ++typedef u64 ffa_mem_handle_t; ++ ++/* The type of an FFA endpoint ID */ ++typedef u16 ffa_sp_id_t; ++ ++struct ffa_mem_region_constituent { ++ u64 address; ++ u32 page_count; ++ u32 reserved_12_15; ++}; ++ ++struct ffa_composite_memory_region { ++ ++ uint32_t total_page_count; ++ uint32_t constituent_count; ++ ++ uint64_t reserved_0; ++ ++ struct ffa_mem_region_constituent constituents[]; ++}; ++ ++struct ffa_mem_region_attributes { ++ ffa_sp_id_t receiver; ++ u8 attrs; ++ u32 composite_off; ++ u64 reserved_8_15; ++}; ++ ++/* Table 43 */ ++struct ffa_memory_region_attribute { ++ uint8_t attribute; ++}; ++ ++struct ffa_mem_region { ++ u16 sender_id; ++ struct ffa_memory_region_attribute region_attr; ++ u8 reserved_0; ++ u32 flags; ++ u64 handle; ++ u64 tag; ++ u32 reserved_1; ++ u32 endpoint_count; ++ struct ffa_mem_region_attributes endpoints[]; ++}; ++ ++static inline struct ffa_composite_memory_region * ++ffa_get_composite(struct ffa_mem_region *mem_region, u32 num_endpoints) ++{ ++ struct ffa_composite_memory_region *composite; ++ ++ composite = (struct ffa_composite_memory_region *) ++ (&mem_region->endpoints[num_endpoints]); ++ return composite; ++} ++ ++ ++struct ffa_partition_info { ++ /** The ID of the VM the information is about. */ ++ ffa_sp_id_t id; ++ /** ++ * The number of execution contexts implemented by the ++ * partition. ++ */ ++ uint16_t execution_context; ++ /** ++ * The Partition's properties, e.g. supported messaging ++ * methods ++ */ ++ uint32_t partition_properties; ++}; ++ ++ ++/** ++ * struct ffa_ops - represents the various FFA protocol operations ++ * available for an SCPI endpoint. ++ */ ++struct ffa_ops { ++ int (*async_msg_send)(ffa_sp_id_t dst_id, u32 len, u32 attributes); ++ struct arm_smcccv1_2_return ++ (*sync_msg_send)(ffa_sp_id_t dst_id, u64 w3, u64 w4, u64 w5, ++ u64 w6, u64 w7); ++ ++ /** ++ * Registers a memory region with the FFA implementation. ++ * ++ * Params: ++ * - tag: Implementation defined value. ++ * - flags: ++ * - FFA_KEEP_MEMORY: DO not clear the memory region; ++ * - FFA_CLEAR_MEMORY: Clear the memory region. ++ * - attrs[]: Array of destination VMs and permissions with which the ++ * Stage-2 mappings are set. ++ * - num_attrs: Count of elements pointed to by attrs. ++ * - sg: scatter list holding the pages to be shared. ++ * - global_handle: A system-wide unique handle referring to the shared ++ * set of physical pages being shared. ++ * - use_tx: select if memorry region description is transmitted in tx ++ * or in a dynamically allocated buffer. When using the tx buffer a ++ * global lock on the tx buffer will be held. ++ * ++ * Return: 0 in case of success, otherwise a negative value ++ * (error code). ++ */ ++ int (*mem_share)(u32 tag, enum mem_clear_t flags, ++ struct ffa_mem_region_attributes attrs[], ++ u32 num_attrs, struct scatterlist *sg, u32 nents, ++ ffa_mem_handle_t *global_handle, bool use_tx); ++ ++ /** ++ * Reclaims a memory region previously registered with the FFA ++ * implementation. ++ * Params: ++ * - global_handle: The global identifier of the memory region being ++ * reclaimed. ++ * - clear_memory: Set if the memory is meant to be cleared before ++ * being mapped in the owner's Stage-2. ++ * ++ * Return: 0 in case of success, otherwise a negative value ++ * (error code). ++ */ ++ int (*mem_reclaim)(ffa_mem_handle_t global_handle, ++ enum mem_clear_t flags); ++ /** ++ * Returns information on a sub-set of partitions within a system ++ * identified by a UUID. ++ * Params: ++ * - uuid0-3: The 128 bit UUID of the desired partition(s) represented ++ * as 4 32 bit uints in form: uuid0-uuid1-uuid2-uuid3. ++ * - ffa_partition_info**: A pointer to an array of ++ * `ffa_parition_info` structs that will be ++ * allocated and populated with the ++ * discovered partitions information. The ++ * caller is responsible for freeing the ++ * memory allocated by the FFA driver. ++ * Return: The number of discovered partitions in the system and the ++ * length of the array of ffa_partition_info structs, ++ * otherwise a negative value (error code). ++ */ ++ int (*partition_info_get)(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3, ++ struct ffa_partition_info **buffer); ++}; ++ ++#if IS_REACHABLE(CONFIG_ARM_FFA_TRANSPORT) ++struct ffa_ops *get_ffa_ops(void); ++#else ++static inline struct ffa_ops *get_ffa_ops(void) { return NULL; } ++#endif ++ ++#endif /*__LINUX_ARM_FFA_H*/ +-- +2.26.2 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0010-tee-add-support-for-session-s-client-UUID-generation.patch b/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0010-tee-add-support-for-session-s-client-UUID-generation.patch new file mode 100644 index 00000000..269940e1 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0010-tee-add-support-for-session-s-client-UUID-generation.patch @@ -0,0 +1,252 @@ +Upstream-Status: Backport [https://github.com/linaro-swg/linux/commit/e33bcbab16d1c0dd85d72bec275308369ad901f5#diff-317c0445401e56bde9d2ee0e0bb2758b0362a4099dca8e535dd20f1f649ecfc8] +Signed-off-by: Arunachalam Ganapathy + +From 69a50f4234d8fb143d499e92e3f0f67009bae586 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Vesa=20J=C3=A4=C3=A4skel=C3=A4inen?= + +Date: Wed, 22 Apr 2020 15:28:07 +0300 +Subject: [PATCH] tee: add support for session's client UUID generation +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +TEE Client API defines that from user space only information needed for +specified login operations is group identifier for group based logins. + +REE kernel is expected to formulate trustworthy client UUID and pass that +to TEE environment. REE kernel is required to verify that provided group +identifier for group based logins matches calling processes group +memberships. + +TEE specification only defines that the information passed from REE +environment to TEE environment is encoded into on UUID. + +In order to guarantee trustworthiness of client UUID user space is not +allowed to freely pass client UUID. + +UUIDv5 form is used encode variable amount of information needed for +different login types. + +Signed-off-by: Vesa Jääskeläinen +Change-Id: I414f68d7485f95277d292fcb2646cc41bd57e62a +--- + drivers/tee/Kconfig | 1 + + drivers/tee/tee_core.c | 143 ++++++++++++++++++++++++++++++++++++++++ + include/linux/tee_drv.h | 16 +++++ + 3 files changed, 160 insertions(+) + +diff --git a/drivers/tee/Kconfig b/drivers/tee/Kconfig +index 676ffcb64985..5a56317f3f4e 100644 +--- a/drivers/tee/Kconfig ++++ b/drivers/tee/Kconfig +@@ -3,6 +3,7 @@ + config TEE + tristate "Trusted Execution Environment support" + depends on HAVE_ARM_SMCCC || COMPILE_TEST ++ select CRYPTO_SHA1 + select DMA_SHARED_BUFFER + select GENERIC_ALLOCATOR + help +diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c +index 0f16d9ffd8d1..3d32a2ca48c3 100644 +--- a/drivers/tee/tee_core.c ++++ b/drivers/tee/tee_core.c +@@ -6,18 +6,33 @@ + #define pr_fmt(fmt) "%s: " fmt, __func__ + + #include ++#include + #include + #include + #include + #include + #include + #include ++#include ++#include + #include "tee_private.h" + + #define TEE_NUM_DEVICES 32 + + #define TEE_IOCTL_PARAM_SIZE(x) (sizeof(struct tee_param) * (x)) + ++#define TEE_UUID_NS_NAME_SIZE 128 ++ ++/* ++ * TEE Client UUID name space identifier (UUIDv4) ++ * ++ * Value here is random UUID that is allocated as name space identifier for ++ * forming Client UUID's for TEE environment using UUIDv5 scheme. ++ */ ++static const uuid_t tee_client_uuid_ns = UUID_INIT(0x58ac9ca0, 0x2086, 0x4683, ++ 0xa1, 0xb8, 0xec, 0x4b, ++ 0xc0, 0x8e, 0x01, 0xb6); ++ + /* + * Unprivileged devices in the lower half range and privileged devices in + * the upper half range. +@@ -111,6 +126,134 @@ static int tee_release(struct inode *inode, struct file *filp) + return 0; + } + ++/** ++ * uuid_v5() - Calculate UUIDv5 ++ * @uuid: Resulting UUID ++ * @ns: Name space ID for UUIDv5 function ++ * @name: Name for UUIDv5 function ++ * @size: Size of name ++ * ++ * UUIDv5 is specific in RFC 4122. ++ * ++ * This implements section (for SHA-1): ++ * 4.3. Algorithm for Creating a Name-Based UUID ++ */ ++static int uuid_v5(uuid_t *uuid, const uuid_t *ns, const void *name, ++ size_t size) ++{ ++ unsigned char hash[SHA1_DIGEST_SIZE]; ++ struct crypto_shash *shash = NULL; ++ struct shash_desc *desc = NULL; ++ int rc; ++ ++ shash = crypto_alloc_shash("sha1", 0, 0); ++ if (IS_ERR(shash)) { ++ rc = PTR_ERR(shash); ++ pr_err("shash(sha1) allocation failed\n"); ++ return rc; ++ } ++ ++ desc = kzalloc(sizeof(*desc) + crypto_shash_descsize(shash), ++ GFP_KERNEL); ++ if (IS_ERR(desc)) { ++ rc = PTR_ERR(desc); ++ goto out; ++ } ++ ++ desc->tfm = shash; ++ ++ rc = crypto_shash_init(desc); ++ if (rc < 0) ++ goto out2; ++ ++ rc = crypto_shash_update(desc, (const u8 *)ns, sizeof(*ns)); ++ if (rc < 0) ++ goto out2; ++ ++ rc = crypto_shash_update(desc, (const u8 *)name, size); ++ if (rc < 0) ++ goto out2; ++ ++ rc = crypto_shash_final(desc, hash); ++ if (rc < 0) ++ goto out2; ++ ++ memcpy(uuid->b, hash, UUID_SIZE); ++ ++ /* Tag for version 5 */ ++ uuid->b[6] = (hash[6] & 0x0F) | 0x50; ++ uuid->b[8] = (hash[8] & 0x3F) | 0x80; ++ ++out2: ++ kfree(desc); ++ ++out: ++ crypto_free_shash(shash); ++ return rc; ++} ++ ++int tee_session_calc_client_uuid(uuid_t *uuid, u32 connection_method, ++ const u8 connection_data[TEE_IOCTL_UUID_LEN]) ++{ ++ const char *application_id = NULL; ++ gid_t ns_grp = (gid_t)-1; ++ kgid_t grp = INVALID_GID; ++ char *name = NULL; ++ int rc; ++ ++ if (connection_method == TEE_IOCTL_LOGIN_PUBLIC) { ++ /* Nil UUID to be passed to TEE environment */ ++ uuid_copy(uuid, &uuid_null); ++ return 0; ++ } ++ ++ /* ++ * In Linux environment client UUID is based on UUIDv5. ++ * ++ * Determine client UUID with following semantics for 'name': ++ * ++ * For TEEC_LOGIN_USER: ++ * uid= ++ * ++ * For TEEC_LOGIN_GROUP: ++ * gid= ++ * ++ */ ++ ++ name = kzalloc(TEE_UUID_NS_NAME_SIZE, GFP_KERNEL); ++ if (!name) ++ return -ENOMEM; ++ ++ switch (connection_method) { ++ case TEE_IOCTL_LOGIN_USER: ++ scnprintf(name, TEE_UUID_NS_NAME_SIZE, "uid=%x", ++ current_euid().val); ++ break; ++ ++ case TEE_IOCTL_LOGIN_GROUP: ++ memcpy(&ns_grp, connection_data, sizeof(gid_t)); ++ grp = make_kgid(current_user_ns(), ns_grp); ++ if (!gid_valid(grp) || !in_egroup_p(grp)) { ++ rc = -EPERM; ++ goto out; ++ } ++ ++ scnprintf(name, TEE_UUID_NS_NAME_SIZE, "gid=%x", grp.val); ++ break; ++ ++ default: ++ rc = -EINVAL; ++ goto out; ++ } ++ ++ rc = uuid_v5(uuid, &tee_client_uuid_ns, name, strlen(name)); ++out: ++ kfree(name); ++ ++ return rc; ++} ++EXPORT_SYMBOL_GPL(tee_session_calc_client_uuid); ++ + static int tee_ioctl_version(struct tee_context *ctx, + struct tee_ioctl_version_data __user *uvers) + { +diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h +index 7a03f68fb982..545a57f61a5e 100644 +--- a/include/linux/tee_drv.h ++++ b/include/linux/tee_drv.h +@@ -166,6 +166,22 @@ int tee_device_register(struct tee_device *teedev); + */ + void tee_device_unregister(struct tee_device *teedev); + ++/** ++ * tee_session_calc_client_uuid() - Calculates client UUID for session ++ * @uuid: Resulting UUID ++ * @connection_method: Connection method for session (TEE_IOCTL_LOGIN_*) ++ * @connectuon_data: Connection data for opening session ++ * ++ * Based on connection method calculates UUIDv5 based client UUID. ++ * ++ * For group based logins verifies that calling process has specified ++ * credentials. ++ * ++ * @return < 0 on failure ++ */ ++int tee_session_calc_client_uuid(uuid_t *uuid, u32 connection_method, ++ const u8 connection_data[TEE_IOCTL_UUID_LEN]); ++ + /** + * struct tee_shm - shared memory object + * @teedev: device used to allocate the object +-- +2.26.2 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0011-tee-optee-Add-support-for-session-login-client-UUID-.patch b/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0011-tee-optee-Add-support-for-session-login-client-UUID-.patch new file mode 100644 index 00000000..65d43115 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0011-tee-optee-Add-support-for-session-login-client-UUID-.patch @@ -0,0 +1,43 @@ +Upstream-Status: Backport [https://github.com/linaro-swg/linux/commit/c5b4312bea5d5e5e3d4f0af640e2ef8a1c1bb167#diff-2d83bca4adf0468bdb51b155a5df495e0226f7971f4150cfffbf043fe3b5a279] +Signed-off-by: Arunachalam Ganapathy + +From c6c4046d8fcd34a4b8da9d844ce592951780ba8c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Vesa=20J=C3=A4=C3=A4skel=C3=A4inen?= + +Date: Wed, 22 Apr 2020 15:30:39 +0300 +Subject: [PATCH] tee: optee: Add support for session login client UUID + generation +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Adds support for client UUID generation for OP-TEE. For group based session +logins membership is verified. + +Signed-off-by: Vesa Jääskeläinen +--- + drivers/tee/optee/call.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/drivers/tee/optee/call.c b/drivers/tee/optee/call.c +index cf2367ba08d6..dbed3f480dc0 100644 +--- a/drivers/tee/optee/call.c ++++ b/drivers/tee/optee/call.c +@@ -233,9 +233,13 @@ int optee_open_session(struct tee_context *ctx, + msg_arg->params[1].attr = OPTEE_MSG_ATTR_TYPE_VALUE_INPUT | + OPTEE_MSG_ATTR_META; + memcpy(&msg_arg->params[0].u.value, arg->uuid, sizeof(arg->uuid)); +- memcpy(&msg_arg->params[1].u.value, arg->uuid, sizeof(arg->clnt_uuid)); + msg_arg->params[1].u.value.c = arg->clnt_login; + ++ rc = tee_session_calc_client_uuid((uuid_t *)&msg_arg->params[1].u.value, ++ arg->clnt_login, arg->clnt_uuid); ++ if (rc) ++ goto out; ++ + rc = optee_to_msg_param(msg_arg->params + 2, arg->num_params, param); + if (rc) + goto out; +-- +2.26.2 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0012-driver-optee-Support-for-ffa-transport.patch b/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0012-driver-optee-Support-for-ffa-transport.patch new file mode 100644 index 00000000..40d4ffeb --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0012-driver-optee-Support-for-ffa-transport.patch @@ -0,0 +1,3150 @@ +Upstream-Status: Pending [https://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux.git/commit/?h=ffa_rel_proto&id=8a0acded67268b7110c69ed5425c56d881716d78] +Signed-off-by: Arunachalam Ganapathy + +From 2e12bf893c180cb1444ca20148983d1c45431c71 Mon Sep 17 00:00:00 2001 +From: Jens Wiklander +Date: Tue, 30 Oct 2018 21:12:11 +0100 +Subject: [PATCH] driver: optee: Support for ffa transport + +FF-A transport support for optee driver. Based on ffa_rel_proto at +https://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux.git/log/?h=ffa_rel_proto + +Squashed in: + tee: remove linked list of struct tee_shm + + Removes list_shm from struct tee_context since the linked list isn't used + any longer. + + tee: remove unused tee_shm_priv_alloc() + + tee_shm_priv_alloc() isn't useful in the current state and it's also not + not used so remove it. + + tee: don't assign shm id for private shms + + Private shared memory object must not be referenced from user space. To + guarantee that don't assign an id to keep the shared memory driver + private. + + tee: remove redundant teedev in struct tee_shm + + Since the ctx element in struct tee_shm always is valid has the teedev + element become redundant so remove it. + + tee: add sec_world_id to struct tee_shm + + Adds sec_world_id to struct tee_shm which describes a shared memory + object. sec_world_id can be used by a driver to store an id assigned by + secure world. + + tee: tee_shm_op_mmap(): use TEE_SHM_USER_MAPPED + + tee_shm_op_mmap() uses the TEE_SHM_USER_MAPPED flag instead of the + TEE_SHM_REGISTER flag to tell if a shared memory object is originating + from registered user space memory. + + Set -Og flags for the OPTEE driver compilation. + + optee: simplify optee_release() + + Simplifies optee_release() with a new helper function, + optee_close_session_helper() which has been factored out from + optee_close_session(). + + A separate optee_release_supp() is added for the supplicant device. + + tee: optee: sync optee_msg.h and optee_rpc_cmd.h + + Updates to latest optee_msg.h and optee_rpc_cmd.h. There's no changes in + the ABI. Only some clarifications and a complete specification of RPC + requests where the latter is now in a separate file, optee_rpc_cmd.h. + + Most of the RPC requests are not served by the OP-TEE driver instead + they are forwarded as opaque requests to tee-supplicant. + + tee: export tee_shm_alloc() + + Export tee_shm_alloc() using EXPORT_SYMBOL_GPL(). Needed by + optee_rng_init() and other drivers complied as a module and using OP-TEE + as a service. + + optee: add spci support + + Adds support for using SPCI as transport to the OP-TEE driver. + + tee: optee: introduce SPCI specific OPTEE_MSG memref + + Introduces struct optee_msg_param_smem which carries all information + needed when OP-TEE is calling SPCI_MEM_RETRIEVE_REQ to get the shared + memory reference mapped by the hypervisor in S-EL2. Register usage is + also updated to include the information needed. + + This isn't strictly needed without a hypervisor in S-EL2 and OP-TEE + itself has the SPMC part. However, this is a configuration which + shouldn't concern normal world. + + tee: optee: Use PARTITION_INFO_GET to get SP ID. + + Instead of using a hardcoded partition ID for OPTEE, use the + SPCI_PARTITION_INFO_GET ABI to find the partition ID corresponding to + the OPTEE UUID. + + tee: optee: Update OPTEE for mem_share SPCI + + Update OPTEE to pass a scatterlist in the mem_share interface. + + tee: Adapt OPTEE to new SPCI mem_share interface + + optee: test_spci: Update optee, spci test driver [optee bits] + + Enable optee and spci test drivesr to pass a scatterlist* and a nents + parameter in mem_share. + + arm_spci: refactor mem_share implementation for EAC [optee bits] + + arm_ffa: optee: Swap spci/SPCI for ffa/FFA. [optee bits] + + arm_ffa: rename 1st member of arm_smcccv1_2_return [optee bits] + + The smcccv1_2_return.func is renamed to arg0. + + tee: add sec_world_id to struct tee_shm + + Change the type of sec_world_id member of struct tee_shm to u64 to be + able to store the 64-bit Global Handle defined in FF-A. + + optee: updated for FF-A 1.0 + + With FF-A 1.0 the ABI to secure world has changed compared to SPCI + beta1. + + The globally unique handle to identify a shared memory object is now 64 + bits wide instead of previous 32. The IDR in struct optee_ffa is + replaced with a struct rhashtable instead in order to support 64-bit + keys. + + Register usage in the FF-A function has changed compared to SPCI beta1 + so the OP-TEE ABI is updated accordingly. The global handle, aka cookie, + is now requires 2 registers. + + struct optee_msg_param_smem is updated to be able to carry a 64-bit + global handle while maintaining the same size of the struct. Due to this + the "page_count" field is dropped. + + optee: Update SMCC field name + + optee: Update FFA_VERSION from 0.9 to 1.0 + + optee/call.c: Update SPCI reference to FFA + +Signed-off-by: Jens Wiklander +Signed-off-by: Marc Bonnici +Signed-off-by: Arunachalam Ganapathy +--- + drivers/tee/Makefile | 1 + + drivers/tee/optee/Makefile | 1 + + drivers/tee/optee/call.c | 318 ++++++++++--- + drivers/tee/optee/core.c | 735 +++++++++++++++++++++++++----- + drivers/tee/optee/optee_ffa.h | 201 ++++++++ + drivers/tee/optee/optee_msg.h | 167 ++----- + drivers/tee/optee/optee_private.h | 61 ++- + drivers/tee/optee/optee_rpc_cmd.h | 333 ++++++++++++++ + drivers/tee/optee/rpc.c | 147 +++++- + drivers/tee/optee/shm_pool.c | 50 ++ + drivers/tee/optee/shm_pool.h | 1 + + drivers/tee/tee_core.c | 1 - + drivers/tee/tee_shm.c | 85 +--- + include/linux/tee_drv.h | 26 +- + 14 files changed, 1710 insertions(+), 417 deletions(-) + create mode 100644 drivers/tee/optee/optee_ffa.h + create mode 100644 drivers/tee/optee/optee_rpc_cmd.h + +diff --git a/drivers/tee/Makefile b/drivers/tee/Makefile +index 21f51fd88b07..c4fe9f0d3bf8 100644 +--- a/drivers/tee/Makefile ++++ b/drivers/tee/Makefile +@@ -4,3 +4,4 @@ tee-objs += tee_core.o + tee-objs += tee_shm.o + tee-objs += tee_shm_pool.o + obj-$(CONFIG_OPTEE) += optee/ ++ccflags-y += -Og +diff --git a/drivers/tee/optee/Makefile b/drivers/tee/optee/Makefile +index 56263ae3b1d7..57371dc91bba 100644 +--- a/drivers/tee/optee/Makefile ++++ b/drivers/tee/optee/Makefile +@@ -6,3 +6,4 @@ optee-objs += rpc.o + optee-objs += supp.o + optee-objs += shm_pool.o + optee-objs += device.o ++ccflags-y += -Og +diff --git a/drivers/tee/optee/call.c b/drivers/tee/optee/call.c +index dbed3f480dc0..ac89ab42a43f 100644 +--- a/drivers/tee/optee/call.c ++++ b/drivers/tee/optee/call.c +@@ -3,16 +3,20 @@ + * Copyright (c) 2015, Linaro Limited + */ + #include ++#include ++#include + #include + #include + #include + #include ++#include + #include + #include + #include + #include + #include "optee_private.h" + #include "optee_smc.h" ++#include "optee_ffa.h" + + struct optee_call_waiter { + struct list_head list_node; +@@ -122,13 +126,18 @@ static struct optee_session *find_session(struct optee_context_data *ctxdata, + * + * Returns return code from secure world, 0 is OK + */ +-u32 optee_do_call_with_arg(struct tee_context *ctx, phys_addr_t parg) ++int optee_do_call_with_arg(struct tee_context *ctx, struct tee_shm *arg) + { + struct optee *optee = tee_get_drvdata(ctx->teedev); +- struct optee_call_waiter w; ++ struct optee_call_waiter w = { }; + struct optee_rpc_param param = { }; + struct optee_call_ctx call_ctx = { }; +- u32 ret; ++ phys_addr_t parg = 0; ++ int rc = 0; ++ ++ rc = tee_shm_get_pa(arg, 0, &parg); ++ if (rc) ++ return rc; + + param.a0 = OPTEE_SMC_CALL_WITH_ARG; + reg_pair_from_64(¶m.a1, ¶m.a2, parg); +@@ -155,7 +164,7 @@ u32 optee_do_call_with_arg(struct tee_context *ctx, phys_addr_t parg) + param.a3 = res.a3; + optee_handle_rpc(ctx, ¶m, &call_ctx); + } else { +- ret = res.a0; ++ rc = res.a0; + break; + } + } +@@ -167,16 +176,15 @@ u32 optee_do_call_with_arg(struct tee_context *ctx, phys_addr_t parg) + */ + optee_cq_wait_final(&optee->call_queue, &w); + +- return ret; ++ return rc; + } + + static struct tee_shm *get_msg_arg(struct tee_context *ctx, size_t num_params, +- struct optee_msg_arg **msg_arg, +- phys_addr_t *msg_parg) ++ struct optee_msg_arg **msg_arg) + { +- int rc; +- struct tee_shm *shm; +- struct optee_msg_arg *ma; ++ int rc = 0; ++ struct tee_shm *shm = NULL; ++ struct optee_msg_arg *ma = NULL; + + shm = tee_shm_alloc(ctx, OPTEE_MSG_GET_ARG_SIZE(num_params), + TEE_SHM_MAPPED); +@@ -189,10 +197,6 @@ static struct tee_shm *get_msg_arg(struct tee_context *ctx, size_t num_params, + goto out; + } + +- rc = tee_shm_get_pa(shm, 0, msg_parg); +- if (rc) +- goto out; +- + memset(ma, 0, OPTEE_MSG_GET_ARG_SIZE(num_params)); + ma->num_params = num_params; + *msg_arg = ma; +@@ -209,15 +213,15 @@ int optee_open_session(struct tee_context *ctx, + struct tee_ioctl_open_session_arg *arg, + struct tee_param *param) + { ++ struct optee *optee = tee_get_drvdata(ctx->teedev); + struct optee_context_data *ctxdata = ctx->data; +- int rc; +- struct tee_shm *shm; +- struct optee_msg_arg *msg_arg; +- phys_addr_t msg_parg; ++ struct optee_msg_arg *msg_arg = NULL; + struct optee_session *sess = NULL; ++ struct tee_shm *shm = NULL; ++ int rc = 0; + + /* +2 for the meta parameters added below */ +- shm = get_msg_arg(ctx, arg->num_params + 2, &msg_arg, &msg_parg); ++ shm = get_msg_arg(ctx, arg->num_params + 2, &msg_arg); + if (IS_ERR(shm)) + return PTR_ERR(shm); + +@@ -240,7 +244,8 @@ int optee_open_session(struct tee_context *ctx, + if (rc) + goto out; + +- rc = optee_to_msg_param(msg_arg->params + 2, arg->num_params, param); ++ rc = optee->ops->to_msg_param(optee, msg_arg->params + 2, ++ arg->num_params, param); + if (rc) + goto out; + +@@ -250,7 +255,7 @@ int optee_open_session(struct tee_context *ctx, + goto out; + } + +- if (optee_do_call_with_arg(ctx, msg_parg)) { ++ if (optee->ops->do_call_with_arg(ctx, shm)) { + msg_arg->ret = TEEC_ERROR_COMMUNICATION; + msg_arg->ret_origin = TEEC_ORIGIN_COMMS; + } +@@ -265,7 +270,8 @@ int optee_open_session(struct tee_context *ctx, + kfree(sess); + } + +- if (optee_from_msg_param(param, arg->num_params, msg_arg->params + 2)) { ++ if (optee->ops->from_msg_param(optee, param, arg->num_params, ++ msg_arg->params + 2)) { + arg->ret = TEEC_ERROR_COMMUNICATION; + arg->ret_origin = TEEC_ORIGIN_COMMS; + /* Close session again to avoid leakage */ +@@ -281,12 +287,28 @@ int optee_open_session(struct tee_context *ctx, + return rc; + } + +-int optee_close_session(struct tee_context *ctx, u32 session) ++int optee_close_session_helper(struct tee_context *ctx, u32 session) ++{ ++ struct optee *optee = tee_get_drvdata(ctx->teedev); ++ struct optee_msg_arg *msg_arg = NULL; ++ struct tee_shm *shm = NULL; ++ ++ shm = get_msg_arg(ctx, 0, &msg_arg); ++ if (IS_ERR(shm)) ++ return PTR_ERR(shm); ++ ++ msg_arg->cmd = OPTEE_MSG_CMD_CLOSE_SESSION; ++ msg_arg->session = session; ++ optee->ops->do_call_with_arg(ctx, shm); ++ ++ tee_shm_free(shm); ++ ++ return 0; ++} ++ ++static int remove_session(struct tee_context *ctx, u32 session) + { + struct optee_context_data *ctxdata = ctx->data; +- struct tee_shm *shm; +- struct optee_msg_arg *msg_arg; +- phys_addr_t msg_parg; + struct optee_session *sess; + + /* Check that the session is valid and remove it from the list */ +@@ -299,27 +321,28 @@ int optee_close_session(struct tee_context *ctx, u32 session) + return -EINVAL; + kfree(sess); + +- shm = get_msg_arg(ctx, 0, &msg_arg, &msg_parg); +- if (IS_ERR(shm)) +- return PTR_ERR(shm); ++ return 0; ++} + +- msg_arg->cmd = OPTEE_MSG_CMD_CLOSE_SESSION; +- msg_arg->session = session; +- optee_do_call_with_arg(ctx, msg_parg); ++int optee_close_session(struct tee_context *ctx, u32 session) ++{ ++ int rc = remove_session(ctx, session); + +- tee_shm_free(shm); +- return 0; ++ if (rc) ++ return rc; ++ ++ return optee_close_session_helper(ctx, session); + } + + int optee_invoke_func(struct tee_context *ctx, struct tee_ioctl_invoke_arg *arg, + struct tee_param *param) + { ++ struct optee *optee = tee_get_drvdata(ctx->teedev); + struct optee_context_data *ctxdata = ctx->data; +- struct tee_shm *shm; +- struct optee_msg_arg *msg_arg; +- phys_addr_t msg_parg; +- struct optee_session *sess; +- int rc; ++ struct optee_msg_arg *msg_arg = NULL; ++ struct optee_session *sess = NULL; ++ struct tee_shm *shm = NULL; ++ int rc = 0; + + /* Check that the session is valid */ + mutex_lock(&ctxdata->mutex); +@@ -328,7 +351,7 @@ int optee_invoke_func(struct tee_context *ctx, struct tee_ioctl_invoke_arg *arg, + if (!sess) + return -EINVAL; + +- shm = get_msg_arg(ctx, arg->num_params, &msg_arg, &msg_parg); ++ shm = get_msg_arg(ctx, arg->num_params, &msg_arg); + if (IS_ERR(shm)) + return PTR_ERR(shm); + msg_arg->cmd = OPTEE_MSG_CMD_INVOKE_COMMAND; +@@ -336,16 +359,18 @@ int optee_invoke_func(struct tee_context *ctx, struct tee_ioctl_invoke_arg *arg, + msg_arg->session = arg->session; + msg_arg->cancel_id = arg->cancel_id; + +- rc = optee_to_msg_param(msg_arg->params, arg->num_params, param); ++ rc = optee->ops->to_msg_param(optee, msg_arg->params, arg->num_params, ++ param); + if (rc) + goto out; + +- if (optee_do_call_with_arg(ctx, msg_parg)) { ++ if (optee->ops->do_call_with_arg(ctx, shm)) { + msg_arg->ret = TEEC_ERROR_COMMUNICATION; + msg_arg->ret_origin = TEEC_ORIGIN_COMMS; + } + +- if (optee_from_msg_param(param, arg->num_params, msg_arg->params)) { ++ if (optee->ops->from_msg_param(optee, param, arg->num_params, ++ msg_arg->params)) { + msg_arg->ret = TEEC_ERROR_COMMUNICATION; + msg_arg->ret_origin = TEEC_ORIGIN_COMMS; + } +@@ -359,11 +384,11 @@ int optee_invoke_func(struct tee_context *ctx, struct tee_ioctl_invoke_arg *arg, + + int optee_cancel_req(struct tee_context *ctx, u32 cancel_id, u32 session) + { ++ struct optee *optee = tee_get_drvdata(ctx->teedev); + struct optee_context_data *ctxdata = ctx->data; +- struct tee_shm *shm; +- struct optee_msg_arg *msg_arg; +- phys_addr_t msg_parg; +- struct optee_session *sess; ++ struct optee_msg_arg *msg_arg = NULL; ++ struct optee_session *sess = NULL; ++ struct tee_shm *shm = NULL; + + /* Check that the session is valid */ + mutex_lock(&ctxdata->mutex); +@@ -372,14 +397,14 @@ int optee_cancel_req(struct tee_context *ctx, u32 cancel_id, u32 session) + if (!sess) + return -EINVAL; + +- shm = get_msg_arg(ctx, 0, &msg_arg, &msg_parg); ++ shm = get_msg_arg(ctx, 0, &msg_arg); + if (IS_ERR(shm)) + return PTR_ERR(shm); + + msg_arg->cmd = OPTEE_MSG_CMD_CANCEL; + msg_arg->session = session; + msg_arg->cancel_id = cancel_id; +- optee_do_call_with_arg(ctx, msg_parg); ++ optee->ops->do_call_with_arg(ctx, shm); + + tee_shm_free(shm); + return 0; +@@ -442,6 +467,16 @@ void optee_disable_shm_cache(struct optee *optee) + optee_cq_wait_final(&optee->call_queue, &w); + } + ++/** ++ * optee_ffa_disable_shm_cache() - Disables caching of some shared memory ++ * allocation in OP-TEE ++ * @optee: main service struct ++ */ ++void optee_ffa_disable_shm_cache(struct optee *optee) ++{ ++ BUG(); ++} ++ + #define PAGELIST_ENTRIES_PER_PAGE \ + ((OPTEE_MSG_NONCONTIG_PAGE_SIZE / sizeof(u64)) - 1) + +@@ -577,11 +612,11 @@ int optee_shm_register(struct tee_context *ctx, struct tee_shm *shm, + struct page **pages, size_t num_pages, + unsigned long start) + { ++ struct optee *optee = tee_get_drvdata(ctx->teedev); ++ struct optee_msg_arg *msg_arg = NULL; + struct tee_shm *shm_arg = NULL; +- struct optee_msg_arg *msg_arg; +- u64 *pages_list; +- phys_addr_t msg_parg; +- int rc; ++ u64 *pages_list = NULL; ++ int rc = 0; + + if (!num_pages) + return -EINVAL; +@@ -594,7 +629,7 @@ int optee_shm_register(struct tee_context *ctx, struct tee_shm *shm, + if (!pages_list) + return -ENOMEM; + +- shm_arg = get_msg_arg(ctx, 1, &msg_arg, &msg_parg); ++ shm_arg = get_msg_arg(ctx, 1, &msg_arg); + if (IS_ERR(shm_arg)) { + rc = PTR_ERR(shm_arg); + goto out; +@@ -615,7 +650,7 @@ int optee_shm_register(struct tee_context *ctx, struct tee_shm *shm, + msg_arg->params->u.tmem.buf_ptr = virt_to_phys(pages_list) | + (tee_shm_get_page_offset(shm) & (OPTEE_MSG_NONCONTIG_PAGE_SIZE - 1)); + +- if (optee_do_call_with_arg(ctx, msg_parg) || ++ if (optee->ops->do_call_with_arg(ctx, shm) || + msg_arg->ret != TEEC_SUCCESS) + rc = -EINVAL; + +@@ -627,12 +662,12 @@ int optee_shm_register(struct tee_context *ctx, struct tee_shm *shm, + + int optee_shm_unregister(struct tee_context *ctx, struct tee_shm *shm) + { +- struct tee_shm *shm_arg; +- struct optee_msg_arg *msg_arg; +- phys_addr_t msg_parg; ++ struct optee *optee = tee_get_drvdata(ctx->teedev); ++ struct optee_msg_arg *msg_arg = NULL; ++ struct tee_shm *shm_arg = NULL; + int rc = 0; + +- shm_arg = get_msg_arg(ctx, 1, &msg_arg, &msg_parg); ++ shm_arg = get_msg_arg(ctx, 1, &msg_arg); + if (IS_ERR(shm_arg)) + return PTR_ERR(shm_arg); + +@@ -641,7 +676,7 @@ int optee_shm_unregister(struct tee_context *ctx, struct tee_shm *shm) + msg_arg->params[0].attr = OPTEE_MSG_ATTR_TYPE_RMEM_INPUT; + msg_arg->params[0].u.rmem.shm_ref = (unsigned long)shm; + +- if (optee_do_call_with_arg(ctx, msg_parg) || ++ if (optee->ops->do_call_with_arg(ctx, shm) || + msg_arg->ret != TEEC_SUCCESS) + rc = -EINVAL; + tee_shm_free(shm_arg); +@@ -663,3 +698,166 @@ int optee_shm_unregister_supp(struct tee_context *ctx, struct tee_shm *shm) + { + return 0; + } ++ ++#ifdef CONFIG_ARM_FFA_TRANSPORT ++static int optee_ffa_yielding_call(struct tee_context *ctx, u32 w3, u32 w4, ++ u32 w5) ++{ ++ struct optee *optee = tee_get_drvdata(ctx->teedev); ++ struct arm_smcccv1_2_return ret = { }; ++ const u32 dst = optee->ffa.dst; ++ struct optee_call_waiter w; ++ u32 w6 = 0; ++ u32 w7 = 0; ++ int rc = 0; ++ ++ /* Initialize waiter */ ++ optee_cq_wait_init(&optee->call_queue, &w); ++ while (true) { ++ ret = optee->ffa.ops->sync_msg_send(dst, w3, w4, w5, w6, w7); ++ ++ if (ret.arg0) { ++ pr_err("ret.arg0 %d\n", (int)ret.arg0); ++ rc = -EIO; ++ goto done; ++ } ++ ++ switch ((int)ret.arg3) { ++ case FFA_SUCCESS: ++ break; ++ case FFA_BUSY: ++ if (w3 == OPTEE_FFA_YIELDING_CALL_RESUME) { ++ pr_err("err OPTEE_FFA_YIELDING_CALL_RESUME\n"); ++ rc = -EIO; ++ goto done; ++ } ++ ++ /* ++ * Out of threads in secure world, wait for a thread ++ * become available. ++ */ ++ optee_cq_wait_for_completion(&optee->call_queue, &w); ++ continue; ++ default: ++ pr_err("ret.arg3 0x%llx\n", (u64)ret.arg3); ++ rc = -EIO; ++ goto done; ++ } ++ ++ if (ret.arg4 == OPTEE_FFA_YIELDING_CALL_RETURN_DONE) ++ goto done; ++ ++ might_sleep(); ++ w4 = ret.arg4; ++ w5 = ret.arg5; ++ w6 = ret.arg6; ++ optee_handle_ffa_rpc(ctx, &w4, &w5, &w6); ++ w3 = OPTEE_FFA_YIELDING_CALL_RESUME; ++ w7 = ret.arg7; ++ } ++done: ++ ++ /* ++ * We're done with our thread in secure world, if there's any ++ * thread waiters wake up one. ++ */ ++ optee_cq_wait_final(&optee->call_queue, &w); ++ ++ return rc; ++} ++ ++int optee_ffa_do_call_with_arg(struct tee_context *ctx, struct tee_shm *shm) ++{ ++ if (shm->offset) ++ return -EINVAL; ++ return optee_ffa_yielding_call(ctx, OPTEE_FFA_YIELDING_CALL_WITH_ARG, ++ shm->sec_world_id, ++ shm->sec_world_id >> 32); ++} ++ ++int optee_ffa_shm_register(struct tee_context *ctx, struct tee_shm *shm, ++ struct page **pages, size_t num_pages, ++ unsigned long start) ++{ ++ struct optee *optee = tee_get_drvdata(ctx->teedev); ++ u64 global_handle = 0; ++ u32 rc = 0; ++ struct sg_table sgt; ++ struct ffa_mem_region_attributes mem_attr = { ++ .receiver = optee->ffa.dst, ++ .attrs = FFA_MEM_RW, ++ }; ++ ++ rc = check_mem_type(start, num_pages); ++ if (rc) ++ return rc; ++ ++ sg_alloc_table_from_pages(&sgt, pages, ++ num_pages, 0, ++ num_pages * 4096, GFP_KERNEL); ++ ++ rc = optee->ffa.ops->mem_share(0, 0, &mem_attr, 1, sgt.sgl, sgt.nents, ++ &global_handle, true); ++ if (rc) { ++ if (rc == FFA_NO_MEMORY) ++ return -ENOMEM; ++ return -EINVAL; ++ } ++ ++ rc = optee_shm_add_ffa_handle(optee, shm, global_handle); ++ if (rc) { ++ optee->ffa.ops->mem_reclaim(global_handle, 0); ++ return rc; ++ } ++ ++ shm->sec_world_id = global_handle; ++ ++ return 0; ++} ++ ++int optee_ffa_shm_unregister(struct tee_context *ctx, struct tee_shm *shm) ++{ ++ struct optee *optee = tee_get_drvdata(ctx->teedev); ++ u64 global_handle = shm->sec_world_id; ++ int rc = 0; ++ ++ optee_shm_rem_ffa_handle(optee, global_handle); ++ shm->sec_world_id = 0; ++ ++ rc = optee_ffa_yielding_call(ctx, ++ OPTEE_FFA_YIELDING_CALL_UNREGISTER_SHM, ++ global_handle, global_handle >> 32); ++ if (rc) ++ pr_err("OPTEE_FFA_YIELDING_CALL_UNREGISTER_SHM id 0x%llx rc %d\n", ++ global_handle, rc); ++ ++ rc = optee->ffa.ops->mem_reclaim(global_handle, 0); ++ if (rc) ++ pr_err("mem_reclain: %d", rc); ++ ++ return rc; ++} ++ ++int optee_ffa_shm_unregister_supp(struct tee_context *ctx, ++ struct tee_shm *shm) ++{ ++ struct optee *optee = tee_get_drvdata(ctx->teedev); ++ int rc = 0; ++ ++ /* ++ * We're skipping the OPTEE_FFA_YIELDING_CALL_UNREGISTER_SHM call ++ * since this is OP-TEE freeing via RPC so it has already retired ++ * this ID. ++ */ ++ ++ rc = optee->ffa.ops->mem_reclaim(shm->sec_world_id, 0); ++ if (rc) ++ pr_err("mem_reclain: %d", rc); ++ ++ optee_shm_rem_ffa_handle(optee, shm->sec_world_id); ++ ++ shm->sec_world_id = 0; ++ ++ return rc; ++} ++#endif /*CONFIG_ARM_FFA_TRANSPORT*/ +diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c +index b830e0a87fba..4178ae7f914a 100644 +--- a/drivers/tee/optee/core.c ++++ b/drivers/tee/optee/core.c +@@ -6,6 +6,8 @@ + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + + #include ++#include ++#include + #include + #include + #include +@@ -19,12 +21,157 @@ + #include + #include "optee_private.h" + #include "optee_smc.h" ++#include "optee_ffa.h" + #include "shm_pool.h" + + #define DRIVER_NAME "optee" ++#define SUPPORTED_OPTEE_PARTITIONS 1 + + #define OPTEE_SHM_NUM_PRIV_PAGES CONFIG_OPTEE_SHM_NUM_PRIV_PAGES + ++#ifdef CONFIG_ARM_FFA_TRANSPORT ++struct shm_rhash { ++ struct tee_shm *shm; ++ u64 global_id; ++ struct rhash_head linkage; ++}; ++ ++static void rh_free_fn(void *ptr, void *arg) ++{ ++ kfree(ptr); ++} ++ ++static const struct rhashtable_params shm_rhash_params = { ++ .head_offset = offsetof(struct shm_rhash, linkage), ++ .key_len = sizeof(u64), ++ .key_offset = offsetof(struct shm_rhash, global_id), ++ .automatic_shrinking = true, ++}; ++ ++struct tee_shm *optee_shm_from_ffa_handle(struct optee *optee, u64 global_id) ++{ ++ struct shm_rhash *r = NULL; ++ struct tee_shm *shm = NULL; ++ ++ mutex_lock(&optee->ffa.mutex); ++ r = rhashtable_lookup_fast(&optee->ffa.global_ids, &global_id, ++ shm_rhash_params); ++ if (r) ++ shm = r->shm; ++ mutex_unlock(&optee->ffa.mutex); ++ ++ return shm; ++} ++ ++int optee_shm_add_ffa_handle(struct optee *optee, struct tee_shm *shm, ++ u64 global_id) ++{ ++ struct shm_rhash *r = NULL; ++ int rc = 0; ++ ++ r = kmalloc(sizeof(*r), GFP_KERNEL); ++ if (!r) ++ return -ENOMEM; ++ r->shm = shm; ++ r->global_id = global_id; ++ ++ mutex_lock(&optee->ffa.mutex); ++ rc = rhashtable_lookup_insert_fast(&optee->ffa.global_ids, &r->linkage, ++ shm_rhash_params); ++ mutex_unlock(&optee->ffa.mutex); ++ ++ if (rc) ++ kfree(r); ++ ++ return rc; ++} ++ ++int optee_shm_rem_ffa_handle(struct optee *optee, u64 global_id) ++{ ++ struct shm_rhash *r = NULL; ++ int rc = -ENOENT; ++ ++ mutex_lock(&optee->ffa.mutex); ++ r = rhashtable_lookup_fast(&optee->ffa.global_ids, &global_id, ++ shm_rhash_params); ++ if (r) { ++ rc = rhashtable_remove_fast(&optee->ffa.global_ids, ++ &r->linkage, shm_rhash_params); ++ if (!rc) ++ kfree(r); ++ } ++ mutex_unlock(&optee->ffa.mutex); ++ ++ return rc; ++} ++#endif /*CONFIG_ARM_FFA_TRANSPORT*/ ++ ++static void from_msg_param_value(struct tee_param *p, u32 attr, ++ const struct optee_msg_param *mp) ++{ ++ p->attr = TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT + ++ attr - OPTEE_MSG_ATTR_TYPE_VALUE_INPUT; ++ p->u.value.a = mp->u.value.a; ++ p->u.value.b = mp->u.value.b; ++ p->u.value.c = mp->u.value.c; ++} ++ ++static int from_msg_param_tmp_mem(struct tee_param *p, u32 attr, ++ const struct optee_msg_param *mp) ++{ ++ struct tee_shm *shm = NULL; ++ phys_addr_t pa = 0; ++ int rc = 0; ++ ++ p->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT + ++ attr - OPTEE_MSG_ATTR_TYPE_TMEM_INPUT; ++ p->u.memref.size = mp->u.tmem.size; ++ shm = (struct tee_shm *)(unsigned long)mp->u.tmem.shm_ref; ++ if (!shm) { ++ p->u.memref.shm_offs = 0; ++ p->u.memref.shm = NULL; ++ return 0; ++ } ++ ++ rc = tee_shm_get_pa(shm, 0, &pa); ++ if (rc) ++ return rc; ++ ++ p->u.memref.shm_offs = mp->u.tmem.buf_ptr - pa; ++ p->u.memref.shm = shm; ++ ++ /* Check that the memref is covered by the shm object */ ++ if (p->u.memref.size) { ++ size_t o = p->u.memref.shm_offs + ++ p->u.memref.size - 1; ++ ++ rc = tee_shm_get_pa(shm, o, NULL); ++ if (rc) ++ return rc; ++ } ++ ++ return 0; ++} ++ ++static void from_msg_param_reg_mem(struct tee_param *p, u32 attr, ++ const struct optee_msg_param *mp) ++{ ++ struct tee_shm *shm = NULL; ++ ++ p->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT + ++ attr - OPTEE_MSG_ATTR_TYPE_RMEM_INPUT; ++ p->u.memref.size = mp->u.rmem.size; ++ shm = (struct tee_shm *)(unsigned long) mp->u.rmem.shm_ref; ++ ++ if (shm) { ++ p->u.memref.shm_offs = mp->u.rmem.offs; ++ p->u.memref.shm = shm; ++ } else { ++ p->u.memref.shm_offs = 0; ++ p->u.memref.shm = NULL; ++ } ++} ++ + /** + * optee_from_msg_param() - convert from OPTEE_MSG parameters to + * struct tee_param +@@ -33,13 +180,12 @@ + * @msg_params: OPTEE_MSG parameters + * Returns 0 on success or <0 on failure + */ +-int optee_from_msg_param(struct tee_param *params, size_t num_params, +- const struct optee_msg_param *msg_params) ++static int optee_from_msg_param(struct optee *optee, struct tee_param *params, ++ size_t num_params, ++ const struct optee_msg_param *msg_params) + { +- int rc; +- size_t n; +- struct tee_shm *shm; +- phys_addr_t pa; ++ size_t n = 0; ++ int rc = 0; + + for (n = 0; n < num_params; n++) { + struct tee_param *p = params + n; +@@ -54,58 +200,19 @@ int optee_from_msg_param(struct tee_param *params, size_t num_params, + case OPTEE_MSG_ATTR_TYPE_VALUE_INPUT: + case OPTEE_MSG_ATTR_TYPE_VALUE_OUTPUT: + case OPTEE_MSG_ATTR_TYPE_VALUE_INOUT: +- p->attr = TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT + +- attr - OPTEE_MSG_ATTR_TYPE_VALUE_INPUT; +- p->u.value.a = mp->u.value.a; +- p->u.value.b = mp->u.value.b; +- p->u.value.c = mp->u.value.c; ++ from_msg_param_value(p, attr, mp); + break; + case OPTEE_MSG_ATTR_TYPE_TMEM_INPUT: + case OPTEE_MSG_ATTR_TYPE_TMEM_OUTPUT: + case OPTEE_MSG_ATTR_TYPE_TMEM_INOUT: +- p->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT + +- attr - OPTEE_MSG_ATTR_TYPE_TMEM_INPUT; +- p->u.memref.size = mp->u.tmem.size; +- shm = (struct tee_shm *)(unsigned long) +- mp->u.tmem.shm_ref; +- if (!shm) { +- p->u.memref.shm_offs = 0; +- p->u.memref.shm = NULL; +- break; +- } +- rc = tee_shm_get_pa(shm, 0, &pa); ++ rc = from_msg_param_tmp_mem(p, attr, mp); + if (rc) + return rc; +- p->u.memref.shm_offs = mp->u.tmem.buf_ptr - pa; +- p->u.memref.shm = shm; +- +- /* Check that the memref is covered by the shm object */ +- if (p->u.memref.size) { +- size_t o = p->u.memref.shm_offs + +- p->u.memref.size - 1; +- +- rc = tee_shm_get_pa(shm, o, NULL); +- if (rc) +- return rc; +- } + break; + case OPTEE_MSG_ATTR_TYPE_RMEM_INPUT: + case OPTEE_MSG_ATTR_TYPE_RMEM_OUTPUT: + case OPTEE_MSG_ATTR_TYPE_RMEM_INOUT: +- p->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT + +- attr - OPTEE_MSG_ATTR_TYPE_RMEM_INPUT; +- p->u.memref.size = mp->u.rmem.size; +- shm = (struct tee_shm *)(unsigned long) +- mp->u.rmem.shm_ref; +- +- if (!shm) { +- p->u.memref.shm_offs = 0; +- p->u.memref.shm = NULL; +- break; +- } +- p->u.memref.shm_offs = mp->u.rmem.offs; +- p->u.memref.shm = shm; +- ++ from_msg_param_reg_mem(p, attr, mp); + break; + + default: +@@ -115,11 +222,21 @@ int optee_from_msg_param(struct tee_param *params, size_t num_params, + return 0; + } + ++static void to_msg_param_value(struct optee_msg_param *mp, ++ const struct tee_param *p) ++{ ++ mp->attr = OPTEE_MSG_ATTR_TYPE_VALUE_INPUT + p->attr - ++ TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT; ++ mp->u.value.a = p->u.value.a; ++ mp->u.value.b = p->u.value.b; ++ mp->u.value.c = p->u.value.c; ++} ++ + static int to_msg_param_tmp_mem(struct optee_msg_param *mp, + const struct tee_param *p) + { +- int rc; +- phys_addr_t pa; ++ phys_addr_t pa = 0; ++ int rc = 0; + + mp->attr = OPTEE_MSG_ATTR_TYPE_TMEM_INPUT + p->attr - + TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT; +@@ -162,11 +279,12 @@ static int to_msg_param_reg_mem(struct optee_msg_param *mp, + * @params: subsystem itnernal parameter representation + * Returns 0 on success or <0 on failure + */ +-int optee_to_msg_param(struct optee_msg_param *msg_params, size_t num_params, +- const struct tee_param *params) ++static int optee_to_msg_param(struct optee *optee, ++ struct optee_msg_param *msg_params, ++ size_t num_params, const struct tee_param *params) + { +- int rc; +- size_t n; ++ size_t n = 0; ++ int rc = 0; + + for (n = 0; n < num_params; n++) { + const struct tee_param *p = params + n; +@@ -180,11 +298,7 @@ int optee_to_msg_param(struct optee_msg_param *msg_params, size_t num_params, + case TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT: + case TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_OUTPUT: + case TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INOUT: +- mp->attr = OPTEE_MSG_ATTR_TYPE_VALUE_INPUT + p->attr - +- TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT; +- mp->u.value.a = p->u.value.a; +- mp->u.value.b = p->u.value.b; +- mp->u.value.c = p->u.value.c; ++ to_msg_param_value(mp, p); + break; + case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT: + case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT: +@@ -203,6 +317,137 @@ int optee_to_msg_param(struct optee_msg_param *msg_params, size_t num_params, + return 0; + } + ++#ifdef CONFIG_ARM_FFA_TRANSPORT ++static void from_msg_param_ffa_mem(struct optee *optee, struct tee_param *p, ++ u32 attr, const struct optee_msg_param *mp) ++{ ++ struct tee_shm *shm = NULL; ++ u64 offs_high = 0; ++ u64 offs_low = 0; ++ ++ p->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT + ++ attr - OPTEE_MSG_ATTR_TYPE_SMEM_INPUT; ++ p->u.memref.size = mp->u.smem.size; ++ shm = optee_shm_from_ffa_handle(optee, mp->u.smem.global_id); ++ p->u.memref.shm = shm; ++ if (shm) { ++ offs_low = mp->u.smem.offs_low; ++ offs_high = mp->u.smem.offs_high; ++ } ++ p->u.memref.shm_offs = offs_low | offs_high << 32; ++} ++ ++/** ++ * optee_ffa_from_msg_param() - convert from OPTEE_MSG parameters to ++ * struct tee_param ++ * @params: subsystem internal parameter representation ++ * @num_params: number of elements in the parameter arrays ++ * @msg_params: OPTEE_MSG parameters ++ * Returns 0 on success or <0 on failure ++ */ ++static int optee_ffa_from_msg_param(struct optee *optee, ++ struct tee_param *params, ++ size_t num_params, ++ const struct optee_msg_param *msg_params) ++{ ++ size_t n = 0; ++ ++ for (n = 0; n < num_params; n++) { ++ struct tee_param *p = params + n; ++ const struct optee_msg_param *mp = msg_params + n; ++ u32 attr = mp->attr & OPTEE_MSG_ATTR_TYPE_MASK; ++ ++ switch (attr) { ++ case OPTEE_MSG_ATTR_TYPE_NONE: ++ p->attr = TEE_IOCTL_PARAM_ATTR_TYPE_NONE; ++ memset(&p->u, 0, sizeof(p->u)); ++ break; ++ case OPTEE_MSG_ATTR_TYPE_VALUE_INPUT: ++ case OPTEE_MSG_ATTR_TYPE_VALUE_OUTPUT: ++ case OPTEE_MSG_ATTR_TYPE_VALUE_INOUT: ++ from_msg_param_value(p, attr, mp); ++ break; ++ case OPTEE_MSG_ATTR_TYPE_SMEM_INPUT: ++ case OPTEE_MSG_ATTR_TYPE_SMEM_OUTPUT: ++ case OPTEE_MSG_ATTR_TYPE_SMEM_INOUT: ++ from_msg_param_ffa_mem(optee, p, attr, mp); ++ break; ++ default: ++ return -EINVAL; ++ } ++ } ++ return 0; ++} ++ ++static int to_msg_param_ffa_mem(struct optee_msg_param *mp, ++ const struct tee_param *p) ++{ ++ struct tee_shm *shm = p->u.memref.shm; ++ ++ mp->attr = OPTEE_MSG_ATTR_TYPE_SMEM_INPUT + p->attr - ++ TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT; ++ ++ if (shm) { ++ u64 shm_offs = p->u.memref.shm_offs; ++ ++ mp->u.smem.internal_offs = shm->offset; ++ ++ mp->u.smem.offs_low = shm_offs; ++ mp->u.smem.offs_high = shm_offs >> 32; ++ /* Check that the entire offset could be stored. */ ++ if (mp->u.smem.offs_high != shm_offs >> 32) ++ return -EINVAL; ++ ++ mp->u.smem.global_id = shm->sec_world_id; ++ } else { ++ memset(&mp->u, 0, sizeof(mp->u)); ++ } ++ mp->u.smem.size = p->u.memref.size; ++ return 0; ++} ++ ++/** ++ * optee_to_msg_param() - convert from struct tee_params to OPTEE_MSG parameters ++ * @msg_params: OPTEE_MSG parameters ++ * @num_params: number of elements in the parameter arrays ++ * @params: subsystem itnernal parameter representation ++ * Returns 0 on success or <0 on failure ++ */ ++static int optee_ffa_to_msg_param(struct optee *optee, ++ struct optee_msg_param *msg_params, ++ size_t num_params, ++ const struct tee_param *params) ++{ ++ size_t n; ++ ++ for (n = 0; n < num_params; n++) { ++ const struct tee_param *p = params + n; ++ struct optee_msg_param *mp = msg_params + n; ++ ++ switch (p->attr) { ++ case TEE_IOCTL_PARAM_ATTR_TYPE_NONE: ++ mp->attr = TEE_IOCTL_PARAM_ATTR_TYPE_NONE; ++ memset(&mp->u, 0, sizeof(mp->u)); ++ break; ++ case TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT: ++ case TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_OUTPUT: ++ case TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INOUT: ++ to_msg_param_value(mp, p); ++ break; ++ case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT: ++ case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT: ++ case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT: ++ if (to_msg_param_ffa_mem(mp, p)) ++ return -EINVAL; ++ break; ++ default: ++ return -EINVAL; ++ } ++ } ++ return 0; ++} ++#endif /*CONFIG_ARM_FFA_TRANSPORT*/ ++ + static void optee_get_version(struct tee_device *teedev, + struct tee_ioctl_version_data *vers) + { +@@ -218,6 +463,17 @@ static void optee_get_version(struct tee_device *teedev, + *vers = v; + } + ++static void optee_ffa_get_version(struct tee_device *teedev, ++ struct tee_ioctl_version_data *vers) ++{ ++ struct tee_ioctl_version_data v = { ++ .impl_id = TEE_IMPL_ID_OPTEE, ++ .impl_caps = TEE_OPTEE_CAP_TZ, ++ .gen_caps = TEE_GEN_CAP_GP | TEE_GEN_CAP_REG_MEM, ++ }; ++ *vers = v; ++} ++ + static int optee_open(struct tee_context *ctx) + { + struct optee_context_data *ctxdata; +@@ -250,57 +506,41 @@ static int optee_open(struct tee_context *ctx) + return 0; + } + +-static void optee_release(struct tee_context *ctx) ++static void optee_release_helper(struct tee_context *ctx, ++ int (*close_session)(struct tee_context *ctx, ++ u32 session)) + { + struct optee_context_data *ctxdata = ctx->data; +- struct tee_device *teedev = ctx->teedev; +- struct optee *optee = tee_get_drvdata(teedev); +- struct tee_shm *shm; +- struct optee_msg_arg *arg = NULL; +- phys_addr_t parg; + struct optee_session *sess; + struct optee_session *sess_tmp; + + if (!ctxdata) + return; + +- shm = tee_shm_alloc(ctx, sizeof(struct optee_msg_arg), TEE_SHM_MAPPED); +- if (!IS_ERR(shm)) { +- arg = tee_shm_get_va(shm, 0); +- /* +- * If va2pa fails for some reason, we can't call into +- * secure world, only free the memory. Secure OS will leak +- * sessions and finally refuse more sessions, but we will +- * at least let normal world reclaim its memory. +- */ +- if (!IS_ERR(arg)) +- if (tee_shm_va2pa(shm, arg, &parg)) +- arg = NULL; /* prevent usage of parg below */ +- } +- + list_for_each_entry_safe(sess, sess_tmp, &ctxdata->sess_list, + list_node) { + list_del(&sess->list_node); +- if (!IS_ERR_OR_NULL(arg)) { +- memset(arg, 0, sizeof(*arg)); +- arg->cmd = OPTEE_MSG_CMD_CLOSE_SESSION; +- arg->session = sess->session_id; +- optee_do_call_with_arg(ctx, parg); +- } ++ close_session(ctx, sess->session_id); + kfree(sess); + } + kfree(ctxdata); ++ ctx->data = NULL; ++} + +- if (!IS_ERR(shm)) +- tee_shm_free(shm); ++static void optee_release(struct tee_context *ctx) ++{ ++ optee_release_helper(ctx, optee_close_session_helper); ++} + +- ctx->data = NULL; ++static void optee_release_supp(struct tee_context *ctx) ++{ ++ struct optee *optee = tee_get_drvdata(ctx->teedev); + +- if (teedev == optee->supp_teedev) +- optee_supp_release(&optee->supp); ++ optee_release_helper(ctx, optee_close_session_helper); ++ optee_supp_release(&optee->supp); + } + +-static const struct tee_driver_ops optee_ops = { ++static const struct tee_driver_ops optee_legacy_clnt_ops = { + .get_version = optee_get_version, + .open = optee_open, + .release = optee_release, +@@ -312,29 +552,36 @@ static const struct tee_driver_ops optee_ops = { + .shm_unregister = optee_shm_unregister, + }; + +-static const struct tee_desc optee_desc = { +- .name = DRIVER_NAME "-clnt", +- .ops = &optee_ops, ++static const struct tee_desc optee_legacy_clnt_desc = { ++ .name = DRIVER_NAME "legacy-clnt", ++ .ops = &optee_legacy_clnt_ops, + .owner = THIS_MODULE, + }; + +-static const struct tee_driver_ops optee_supp_ops = { ++static const struct tee_driver_ops optee_legacy_supp_ops = { + .get_version = optee_get_version, + .open = optee_open, +- .release = optee_release, ++ .release = optee_release_supp, + .supp_recv = optee_supp_recv, + .supp_send = optee_supp_send, + .shm_register = optee_shm_register_supp, + .shm_unregister = optee_shm_unregister_supp, + }; + +-static const struct tee_desc optee_supp_desc = { +- .name = DRIVER_NAME "-supp", +- .ops = &optee_supp_ops, ++static const struct tee_desc optee_legacy_supp_desc = { ++ .name = DRIVER_NAME "legacy-supp", ++ .ops = &optee_legacy_supp_ops, + .owner = THIS_MODULE, + .flags = TEE_DESC_PRIVILEGED, + }; + ++static const struct optee_ops optee_legacy_ops = { ++ .do_call_with_arg = optee_do_call_with_arg, ++ .to_msg_param = optee_to_msg_param, ++ .from_msg_param = optee_from_msg_param, ++}; ++ ++ + static bool optee_msg_api_uid_is_optee_api(optee_invoke_fn *invoke_fn) + { + struct arm_smccc_res res; +@@ -534,16 +781,9 @@ static void optee_smccc_hvc(unsigned long a0, unsigned long a1, + arm_smccc_hvc(a0, a1, a2, a3, a4, a5, a6, a7, res); + } + +-static optee_invoke_fn *get_invoke_func(struct device_node *np) ++static optee_invoke_fn *get_invoke_func(const char *method) + { +- const char *method; + +- pr_info("probing for conduit method from DT.\n"); +- +- if (of_property_read_string(np, "method", &method)) { +- pr_warn("missing \"method\" property\n"); +- return ERR_PTR(-ENXIO); +- } + + if (!strcmp("hvc", method)) + return optee_smccc_hvc; +@@ -554,7 +794,7 @@ static optee_invoke_fn *get_invoke_func(struct device_node *np) + return ERR_PTR(-EINVAL); + } + +-static struct optee *optee_probe(struct device_node *np) ++static struct optee *optee_probe_legacy(const char *method) + { + optee_invoke_fn *invoke_fn; + struct tee_shm_pool *pool = ERR_PTR(-EINVAL); +@@ -564,7 +804,7 @@ static struct optee *optee_probe(struct device_node *np) + u32 sec_caps; + int rc; + +- invoke_fn = get_invoke_func(np); ++ invoke_fn = get_invoke_func(method); + if (IS_ERR(invoke_fn)) + return (void *)invoke_fn; + +@@ -606,17 +846,18 @@ static struct optee *optee_probe(struct device_node *np) + goto err; + } + ++ optee->ops = &optee_legacy_ops; + optee->invoke_fn = invoke_fn; + optee->sec_caps = sec_caps; + +- teedev = tee_device_alloc(&optee_desc, NULL, pool, optee); ++ teedev = tee_device_alloc(&optee_legacy_clnt_desc, NULL, pool, optee); + if (IS_ERR(teedev)) { + rc = PTR_ERR(teedev); + goto err; + } + optee->teedev = teedev; + +- teedev = tee_device_alloc(&optee_supp_desc, NULL, pool, optee); ++ teedev = tee_device_alloc(&optee_legacy_supp_desc, NULL, pool, optee); + if (IS_ERR(teedev)) { + rc = PTR_ERR(teedev); + goto err; +@@ -662,6 +903,266 @@ static struct optee *optee_probe(struct device_node *np) + return ERR_PTR(rc); + } + ++#ifdef CONFIG_ARM_FFA_TRANSPORT ++static bool optee_ffa_api_is_compatbile(struct ffa_ops *ffa_ops, u32 dst) ++{ ++ struct arm_smcccv1_2_return ret = { }; ++ ++ ret = ffa_ops->sync_msg_send(dst, OPTEE_FFA_GET_API_VERSION, ++ 0, 0, 0, 0); ++ if (ret.arg0 != FFA_SUCCESS) { ++ pr_err("Unexpected return fid 0x%llx", ret.arg0); ++ return false; ++ } ++ if (ret.arg3 != OPTEE_FFA_VERSION_MAJOR || ++ ret.arg4 < OPTEE_FFA_VERSION_MINOR) { ++ pr_err("Incompatible OP-TEE API version %llu.%llu", ++ ret.arg3, ret.arg4); ++ return false; ++ } ++ ++ ret = ffa_ops->sync_msg_send(dst, OPTEE_FFA_GET_OS_VERSION, ++ 0, 0, 0, 0); ++ if (ret.arg0) { ++ pr_err("Unexpected error 0x%llx", ret.arg0); ++ return false; ++ } ++ if (ret.arg5) ++ pr_info("revision %llu.%llu (%08llx)", ++ ret.arg3, ret.arg4, ret.arg5); ++ else ++ pr_info("revision %llu.%llu", ret.arg3, ret.arg4); ++ ++ return true; ++} ++ ++static bool optee_ffa_exchange_caps(struct ffa_ops *ffa_ops, u32 dst, ++ u32 *sec_caps) ++{ ++ struct arm_smcccv1_2_return ret = { }; ++ ++ ret = ffa_ops->sync_msg_send(dst, OPTEE_FFA_EXCHANGE_CAPABILITIES, ++ 0, 0, 0, 0); ++ if (ret.arg0) { ++ pr_err("Unexpected error 0x%llx", ret.arg0); ++ return false; ++ } ++ ++ *sec_caps = 0; ++ ++ return true; ++} ++ ++static struct tee_shm_pool *optee_ffa_config_dyn_shm(void) ++{ ++ struct tee_shm_pool_mgr *priv_mgr; ++ struct tee_shm_pool_mgr *dmabuf_mgr; ++ void *rc; ++ ++ rc = optee_ffa_shm_pool_alloc_pages(); ++ if (IS_ERR(rc)) ++ return rc; ++ priv_mgr = rc; ++ ++ rc = optee_ffa_shm_pool_alloc_pages(); ++ if (IS_ERR(rc)) { ++ tee_shm_pool_mgr_destroy(priv_mgr); ++ return rc; ++ } ++ dmabuf_mgr = rc; ++ ++ rc = tee_shm_pool_alloc(priv_mgr, dmabuf_mgr); ++ if (IS_ERR(rc)) { ++ tee_shm_pool_mgr_destroy(priv_mgr); ++ tee_shm_pool_mgr_destroy(dmabuf_mgr); ++ } ++ ++ return rc; ++} ++ ++static const struct tee_driver_ops optee_ffa_clnt_ops = { ++ .get_version = optee_ffa_get_version, ++ .open = optee_open, ++ .release = optee_release, ++ .open_session = optee_open_session, ++ .close_session = optee_close_session, ++ .invoke_func = optee_invoke_func, ++ .cancel_req = optee_cancel_req, ++ .shm_register = optee_ffa_shm_register, ++ .shm_unregister = optee_ffa_shm_unregister, ++}; ++ ++static const struct tee_desc optee_ffa_clnt_desc = { ++ .name = DRIVER_NAME "ffa-clnt", ++ .ops = &optee_ffa_clnt_ops, ++ .owner = THIS_MODULE, ++}; ++ ++static const struct tee_driver_ops optee_ffa_supp_ops = { ++ .get_version = optee_ffa_get_version, ++ .open = optee_open, ++ .release = optee_release_supp, ++ .supp_recv = optee_supp_recv, ++ .supp_send = optee_supp_send, ++ .shm_register = optee_ffa_shm_register, /* same as for clnt ops */ ++ .shm_unregister = optee_ffa_shm_unregister_supp, ++}; ++ ++static const struct tee_desc optee_ffa_supp_desc = { ++ .name = DRIVER_NAME "ffa-supp", ++ .ops = &optee_ffa_supp_ops, ++ .owner = THIS_MODULE, ++ .flags = TEE_DESC_PRIVILEGED, ++}; ++ ++static const struct optee_ops optee_ffa_ops = { ++ .do_call_with_arg = optee_ffa_do_call_with_arg, ++ .to_msg_param = optee_ffa_to_msg_param, ++ .from_msg_param = optee_ffa_from_msg_param, ++}; ++ ++static struct optee *optee_probe_ffa(void) ++{ ++ struct tee_device *teedev = NULL; ++ struct ffa_ops *ffa_ops = NULL; ++ struct optee *optee = NULL; ++ struct ffa_partition_info *partition_info = NULL; ++ u32 ffa_dst = 0; ++ u32 sec_caps = 0; ++ int count = 0; ++ int rc = 0; ++ ++ ffa_ops = get_ffa_ops(); ++ if (!ffa_ops) { ++ pr_warn("failed \"method\" init: ffa\n"); ++ return ERR_PTR(-ENOENT); ++ } ++ /* Use OPTEE UUID to retrieve partition ID. */ ++ count = ffa_ops->partition_info_get(OPTEE_MSG_OS_OPTEE_UUID_0, ++ OPTEE_MSG_OS_OPTEE_UUID_1, ++ OPTEE_MSG_OS_OPTEE_UUID_2, ++ OPTEE_MSG_OS_OPTEE_UUID_3, ++ &partition_info); ++ ++ /* If count is negative propergate the error code. */ ++ if (count < 0) { ++ return ERR_PTR(count); ++ } ++ /* ++ * If the function returned sucessfully we must ensure to free the ++ * allocated memory before exiting. ++ */ ++ ++ /* Check only a single patition is found.*/ ++ /* TODO: Add support for dealing with multiple partitions. */ ++ if (count > SUPPORTED_OPTEE_PARTITIONS) { ++ kfree(partition_info); ++ return ERR_PTR(-EINVAL); ++ } ++ ffa_dst = partition_info[0].id; ++ kfree(partition_info); ++ ++ if (!optee_ffa_api_is_compatbile(ffa_ops, ffa_dst)) ++ return ERR_PTR(-EINVAL); ++ ++ if (!optee_ffa_exchange_caps(ffa_ops, ffa_dst, &sec_caps)) ++ return ERR_PTR(-EINVAL); ++ ++ optee = kzalloc(sizeof(*optee), GFP_KERNEL); ++ if (!optee) { ++ rc = -ENOMEM; ++ goto err; ++ } ++ optee->pool = optee_ffa_config_dyn_shm(); ++ if (IS_ERR(optee->pool)) { ++ rc = PTR_ERR(optee->pool); ++ optee->pool = NULL; ++ goto err; ++ } ++ ++ optee->ops = &optee_ffa_ops; ++ optee->ffa.ops = ffa_ops; ++ optee->ffa.dst = ffa_dst; ++ optee->sec_caps = sec_caps; ++ ++ teedev = tee_device_alloc(&optee_ffa_clnt_desc, NULL, optee->pool, ++ optee); ++ if (IS_ERR(teedev)) { ++ rc = PTR_ERR(teedev); ++ goto err; ++ } ++ optee->teedev = teedev; ++ ++ teedev = tee_device_alloc(&optee_ffa_supp_desc, NULL, optee->pool, ++ optee); ++ if (IS_ERR(teedev)) { ++ rc = PTR_ERR(teedev); ++ goto err; ++ } ++ optee->supp_teedev = teedev; ++ ++ rc = tee_device_register(optee->teedev); ++ if (rc) ++ goto err; ++ ++ rc = tee_device_register(optee->supp_teedev); ++ if (rc) ++ goto err; ++ ++ rc = rhashtable_init(&optee->ffa.global_ids, &shm_rhash_params); ++ if (rc) ++ goto err; ++ mutex_init(&optee->ffa.mutex); ++ mutex_init(&optee->call_queue.mutex); ++ INIT_LIST_HEAD(&optee->call_queue.waiters); ++ optee_wait_queue_init(&optee->wait_queue); ++ optee_supp_init(&optee->supp); ++ ++ return optee; ++err: ++ /* ++ * tee_device_unregister() is safe to call even if the ++ * devices hasn't been registered with ++ * tee_device_register() yet. ++ */ ++ tee_device_unregister(optee->supp_teedev); ++ tee_device_unregister(optee->teedev); ++ if (optee->pool) ++ tee_shm_pool_free(optee->pool); ++ kfree(optee); ++ return ERR_PTR(rc); ++} ++#endif /*CONFIG_ARM_FFA_TRANSPORT*/ ++ ++static const char *get_conduit_method(struct device_node *np) ++{ ++ const char *method = NULL; ++ ++ pr_info("probing for conduit method from DT.\n"); ++ ++ if (of_property_read_string(np, "method", &method)) { ++ pr_warn("missing \"method\" property\n"); ++ return NULL; ++ } ++ ++ return method; ++} ++ ++static struct optee *optee_probe(struct device_node *np) ++{ ++ const char *method = get_conduit_method(np); ++ ++ if (!method) ++ return ERR_PTR(-ENXIO); ++ ++#ifdef CONFIG_ARM_FFA_TRANSPORT ++ if (!strcmp(method, "ffa")) ++ return optee_probe_ffa(); ++#endif /*CONFIG_ARM_FFA_TRANSPORT*/ ++ ++ return optee_probe_legacy(method); ++} ++ + static void optee_remove(struct optee *optee) + { + /* +@@ -669,7 +1170,10 @@ static void optee_remove(struct optee *optee) + * reference counters and also avoid wild pointers in secure world + * into the old shared memory range. + */ +- optee_disable_shm_cache(optee); ++ if (optee->invoke_fn) ++ optee_disable_shm_cache(optee); ++ else ++ optee_ffa_disable_shm_cache(optee); + + /* + * The two devices has to be unregistered before we can free the +@@ -684,6 +1188,13 @@ static void optee_remove(struct optee *optee) + optee_wait_queue_exit(&optee->wait_queue); + optee_supp_uninit(&optee->supp); + mutex_destroy(&optee->call_queue.mutex); ++#ifdef CONFIG_ARM_FFA_TRANSPORT ++ if (optee->ffa.ops) { ++ mutex_destroy(&optee->ffa.mutex); ++ rhashtable_free_and_destroy(&optee->ffa.global_ids, ++ rh_free_fn, NULL); ++ } ++#endif /*CONFIG_ARM_FFA_TRANSPORT*/ + + kfree(optee); + } +diff --git a/drivers/tee/optee/optee_ffa.h b/drivers/tee/optee/optee_ffa.h +new file mode 100644 +index 000000000000..768e056ab491 +--- /dev/null ++++ b/drivers/tee/optee/optee_ffa.h +@@ -0,0 +1,201 @@ ++/* SPDX-License-Identifier: BSD-2-Clause */ ++/* ++ * Copyright (c) 2019, Linaro Limited ++ */ ++ ++/* ++ * This file is exported by OP-TEE and is in kept in sync between secure ++ * world and normal world kernel driver. We're using ARM FF-A 1.0 EAC ++ * specification. ++ */ ++ ++#ifndef __OPTEE_FFA_H ++#define __OPTEE_FFA_H ++ ++#include ++ ++/* ++ * Normal world sends requests with FFA_MSG_SEND_DIRECT_REQ and ++ * responses are returned with FFA_MSG_SEND_DIRECT_RESP for normal ++ * messages. ++ * ++ * All requests with FFA_MSG_SEND_DIRECT_REQ and FFA_MSG_SEND_DIRECT_RESP ++ * are using the AArch32 SMC calling convention with register usage as ++ * defined in FF-A specification: ++ * w0: Function ID (0x8400006F or 0x84000070) ++ * w1: Source/Destination IDs ++ * w2: Reserved (MBZ) ++ * w3-w7: Implementation defined, free to be used below ++ */ ++ ++#define OPTEE_FFA_VERSION_MAJOR 1 ++#define OPTEE_FFA_VERSION_MINOR 0 ++ ++#define OPTEE_FFA_BLOCKING_CALL(id) (id) ++#define OPTEE_FFA_YIELDING_CALL_BIT 31 ++#define OPTEE_FFA_YIELDING_CALL(id) ((id) | BIT(OPTEE_FFA_YIELDING_CALL_BIT)) ++ ++/* ++ * Returns the API version implemented, currently follows the FF-A version. ++ * Call register usage: ++ * w3: Service ID, OPTEE_FFA_GET_API_VERSION ++ * w4-w7: Not used (MBZ) ++ * ++ * Return register usage: ++ * w3: OPTEE_FFA_VERSION_MAJOR ++ * w4: OPTEE_FFA_VERSION_MINOR ++ * w5-w7: Not used (MBZ) ++ */ ++#define OPTEE_FFA_GET_API_VERSION OPTEE_FFA_BLOCKING_CALL(0) ++ ++/* ++ * Returns the revision of OP-TEE. ++ * ++ * Used by non-secure world to figure out which version of the Trusted OS ++ * is installed. Note that the returned revision is the revision of the ++ * Trusted OS, not of the API. ++ * ++ * Call register usage: ++ * w3: Service ID, OPTEE_FFA_GET_OS_VERSION ++ * w4-w7: Unused (MBZ) ++ * ++ * Return register usage: ++ * w3: CFG_OPTEE_REVISION_MAJOR ++ * w4: CFG_OPTEE_REVISION_MINOR ++ * w5: TEE_IMPL_GIT_SHA1 (or zero if not supported) ++ */ ++#define OPTEE_FFA_GET_OS_VERSION OPTEE_FFA_BLOCKING_CALL(1) ++ ++/* ++ * Exchange capabilities between normal world and secure world. ++ * ++ * Currently there are no defined capabilities. When features are added new ++ * capabilities may be added. ++ * ++ * Call register usage: ++ * w3: Service ID, OPTEE_FFA_EXCHANGE_CAPABILITIES ++ * w4-w7: Note used (MBZ) ++ * ++ * Return register usage: ++ * w3: Error code, 0 on success ++ * w4: Bit[1:0]: Number of pages of shared memory to register with ++ * OPTEE_FFA_REGISTER_RPC_SHM to support RPC ++ * Bit[31:2]: Reserved (MBZ) ++ * w5-w7: Note used (MBZ) ++ */ ++#define OPTEE_FFA_EXCHANGE_CAPABILITIES OPTEE_FFA_BLOCKING_CALL(2) ++ ++/* ++ * Call with struct optee_msg_arg as argument in the supplied shared memory ++ * with a zero internal offset and normal cached memory attributes. ++ * Register usage: ++ * w3: Service ID, OPTEE_FFA_YIELDING_CALL_WITH_ARG ++ * w4: Shared memory handle, lower bits ++ * w5: Shared memory handle, higher bits ++ * w6: Offset into shared memory pointing to a struct optee_msg_arg ++ * w7: Not used (MBZ) ++ * ++ * Call to register shared memory memory. The data is supplied in shared ++ * memory with a zero internal offset and normal cached memory attributes. ++ * The data is formatted as described in FFA 1.0 Beta1 Table 137 " ++ * Descriptor to retrieve a donated, lent or shared memory region". ++ * Register usage: ++ * w3: Service ID, OPTEE_FFA_YIELDING_CALL_REGISTER_SHM ++ * w4: Shared memory handle, lower bits ++ * w5: Shared memory handle, higher bits ++ * w6-w7: Not used (MBZ) ++ * ++ * Call unregister shared memory register usage: ++ * w3: Service ID, OPTEE_FFA_YIELDING_CALL_UNREGISTER_SHM ++ * w4: Shared memory handle, lower bits ++ * w5: Shared memory handle, higher bits ++ * w6-w7: Not used (MBZ) ++ * ++ * Resume from RPC register usage: ++ * w3: Service ID, OPTEE_FFA_YIELDING_CALL_RESUME ++ * If returning from OPTEE_FFA_YIELDING_CALL_RETURN_ALLOC_SHM: ++ * w4: Shared memory handle, lower bits ++ * w5: Shared memory handle, higher bits ++ * If the allocation failed both w4 and w5 are 0 ++ * w6: Offset into shared memory pointing the table If internal ++ * offset > 0 then one more page than requested has been allocated. ++ * else if resuming from another RPC: ++ * w4-w6: Not used (MBZ) ++ * w7: Resume info ++ * ++ * Normal return (yielding call is completed) register usage: ++ * w3: Error code, 0 on success ++ * w4: OPTEE_FFA_YIELDING_CALL_RETURN_DONE ++ * w5-w7: Not used (MBZ) ++ * ++ * Alloc SHM return (RPC from secure world) register usage: ++ * w3: Error code == 0 ++ * w4: OPTEE_FFA_YIELDING_CALL_RETURN_ALLOC_KERN_SHM or ++ * OPTEE_FFA_YIELDING_CALL_RETURN_ALLOC_SUPPL_SHM ++ * allocate kernel private or supplicant memory respectively. ++ * w5: Number of pages of shared memory ++ * w6: Not used (MBZ) ++ * w7: Resume info ++ * ++ * Free SHM return (RPC from secure world) register usage: ++ * w3: Error code == 0 ++ * w4: OPTEE_FFA_YIELDING_CALL_RETURN_FREE_KERN_SHM or ++ * OPTEE_FFA_YIELDING_CALL_RETURN_FREE_SUPPL_SHM ++ * free kernel private or supplicant memory respectively. ++ * w5 Shared memory handle to free, lower bits ++ * w6 Shared memory handle to free, higher bits ++ * The handle previously allocated with ++ * OPTEE_FFA_YIELDING_CALL_RETURN_ALLOC_KERN_SHM or ++ * OPTEE_FFA_YIELDING_CALL_RETURN_ALLOC_SUPPL_SHM. ++ * w7: Resume info ++ * ++ * RPC cmd return (RPC from secure world) register usage: ++ * w3: Error code == 0 ++ * w4: OPTEE_FFA_YIELDING_CALL_RETURN_RPC_CMD ++ * w5: Shared memory handle, lower bits ++ * w6: Shared memory handle, higher bits ++ * The handle contains aed the RPC. ++ * w7: Resume info ++ * ++ * RPC interrupt return (RPC from secure world) register usage: ++ * w3: Error code == 0 ++ * w4: OPTEE_FFA_YIELDING_CALL_RETURN_INTERRUPT ++ * w5-w6: Not used (MBZ) ++ * w7: Resume info ++ * ++ * Possible error codes in register w3: ++ * 0: Success ++ * FFA_DENIED: w4 isn't one of OPTEE_FFA_YIELDING_CALL_START ++ * OPTEE_FFA_YIELDING_CALL_REGISTER_SHM, ++ * OPTEE_FFA_YIELDING_CALL_UNREGISTER_SHM or ++ * OPTEE_FFA_YIELDING_CALL_RESUME ++ * ++ * Possible error codes for OPTEE_FFA_YIELDING_CALL_START, ++ * OPTEE_FFA_YIELDING_CALL_REGISTER_SHM and ++ * OPTEE_FFA_YIELDING_CALL_UNREGISTER_SHM ++ * FFA_BUSY: Number of OP-TEE OS threads exceeded, ++ * try again later ++ * FFA_DENIED: RPC shared memory object not found ++ * FFA_INVALID_PARAMETER: Bad shared memory handle or offset into the memory ++ * ++ * Possible error codes for OPTEE_FFA_YIELDING_CALL_RESUME ++ * FFA_INVALID_PARAMETER: Bad resume info ++ * ++ */ ++#define OPTEE_FFA_YIELDING_CALL_WITH_ARG OPTEE_FFA_YIELDING_CALL(0) ++#define OPTEE_FFA_YIELDING_CALL_REGISTER_SHM OPTEE_FFA_YIELDING_CALL(1) ++#define OPTEE_FFA_YIELDING_CALL_UNREGISTER_SHM OPTEE_FFA_YIELDING_CALL(2) ++#define OPTEE_FFA_YIELDING_CALL_RESUME OPTEE_FFA_YIELDING_CALL(3) ++ ++#define OPTEE_FFA_YIELDING_CALL_RETURN_DONE 0 ++#define OPTEE_FFA_YIELDING_CALL_RETURN_ALLOC_KERN_SHM 1 ++#define OPTEE_FFA_YIELDING_CALL_RETURN_ALLOC_SUPPL_SHM 2 ++#define OPTEE_FFA_YIELDING_CALL_RETURN_RESERVED0 3 ++#define OPTEE_FFA_YIELDING_CALL_RETURN_FREE_KERN_SHM 4 ++#define OPTEE_FFA_YIELDING_CALL_RETURN_FREE_SUPPL_SHM 5 ++#define OPTEE_FFA_YIELDING_CALL_RETURN_RESERVED1 6 ++#define OPTEE_FFA_YIELDING_CALL_RETURN_RPC_CMD 7 ++#define OPTEE_FFA_YIELDING_CALL_RETURN_INTERRUPT 8 ++ ++#endif /*__OPTEE_FFA_H*/ ++ +diff --git a/drivers/tee/optee/optee_msg.h b/drivers/tee/optee/optee_msg.h +index 795bc19ae17a..95ee82c11733 100644 +--- a/drivers/tee/optee/optee_msg.h ++++ b/drivers/tee/optee/optee_msg.h +@@ -1,6 +1,5 @@ +-/* SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) */ + /* +- * Copyright (c) 2015-2019, Linaro Limited ++ * Copyright (c) 2015-2020, Linaro Limited + */ + #ifndef _OPTEE_MSG_H + #define _OPTEE_MSG_H +@@ -11,12 +10,6 @@ + /* + * This file defines the OP-TEE message protocol used to communicate + * with an instance of OP-TEE running in secure world. +- * +- * This file is divided into three sections. +- * 1. Formatting of messages. +- * 2. Requests from normal world +- * 3. Requests from secure world, Remote Procedure Call (RPC), handled by +- * tee-supplicant. + */ + + /***************************************************************************** +@@ -30,6 +23,9 @@ + #define OPTEE_MSG_ATTR_TYPE_RMEM_INPUT 0x5 + #define OPTEE_MSG_ATTR_TYPE_RMEM_OUTPUT 0x6 + #define OPTEE_MSG_ATTR_TYPE_RMEM_INOUT 0x7 ++#define OPTEE_MSG_ATTR_TYPE_SMEM_INPUT OPTEE_MSG_ATTR_TYPE_RMEM_INPUT ++#define OPTEE_MSG_ATTR_TYPE_SMEM_OUTPUT OPTEE_MSG_ATTR_TYPE_RMEM_OUTPUT ++#define OPTEE_MSG_ATTR_TYPE_SMEM_INOUT OPTEE_MSG_ATTR_TYPE_RMEM_INOUT + #define OPTEE_MSG_ATTR_TYPE_TMEM_INPUT 0x9 + #define OPTEE_MSG_ATTR_TYPE_TMEM_OUTPUT 0xa + #define OPTEE_MSG_ATTR_TYPE_TMEM_INOUT 0xb +@@ -54,14 +50,14 @@ + * Every entry in buffer should point to a 4k page beginning (12 least + * significant bits must be equal to zero). + * +- * 12 least significant bints of optee_msg_param.u.tmem.buf_ptr should hold page +- * offset of the user buffer. ++ * 12 least significant bits of optee_msg_param.u.tmem.buf_ptr should hold ++ * page offset of user buffer. + * + * So, entries should be placed like members of this structure: + * + * struct page_data { +- * uint64_t pages_array[OPTEE_MSG_NONCONTIG_PAGE_SIZE/sizeof(uint64_t) - 1]; +- * uint64_t next_page_data; ++ * u64 pages_array[OPTEE_MSG_NONCONTIG_PAGE_SIZE/sizeof(u64) - 1]; ++ * u64 next_page_data; + * }; + * + * Structure is designed to exactly fit into the page size +@@ -129,6 +125,23 @@ struct optee_msg_param_rmem { + u64 shm_ref; + }; + ++/** ++ * struct optee_msg_param_smem - ffa memory reference parameter ++ * @offs_lower: Lower bits of offset into shared memory reference ++ * @offs_upper: Upper bits of offset into shared memory reference ++ * @internal_offs: Internal offset into the first page of shared memory ++ * reference ++ * @size: Size of the buffer ++ * @global_id: Global identifier of Shared memory ++ */ ++struct optee_msg_param_smem { ++ u32 offs_low; ++ u16 offs_high; ++ u16 internal_offs; ++ u64 size; ++ u64 global_id; ++}; ++ + /** + * struct optee_msg_param_value - opaque value parameter + * +@@ -145,12 +158,14 @@ struct optee_msg_param_value { + * @attr: attributes + * @tmem: parameter by temporary memory reference + * @rmem: parameter by registered memory reference ++ * @smem: parameter by ffa registered memory reference + * @value: parameter by opaque value + * + * @attr & OPTEE_MSG_ATTR_TYPE_MASK indicates if tmem, rmem or value is used in + * the union. OPTEE_MSG_ATTR_TYPE_VALUE_* indicates value, + * OPTEE_MSG_ATTR_TYPE_TMEM_* indicates @tmem and +- * OPTEE_MSG_ATTR_TYPE_RMEM_* indicates @rmem, ++ * OPTEE_MSG_ATTR_TYPE_RMEM_* or the alias PTEE_MSG_ATTR_TYPE_SMEM_* indicates ++ * @rmem or @smem depending on the conduit. + * OPTEE_MSG_ATTR_TYPE_NONE indicates that none of the members are used. + */ + struct optee_msg_param { +@@ -158,6 +173,7 @@ struct optee_msg_param { + union { + struct optee_msg_param_tmem tmem; + struct optee_msg_param_rmem rmem; ++ struct optee_msg_param_smem smem; + struct optee_msg_param_value value; + } u; + }; +@@ -176,17 +192,9 @@ struct optee_msg_param { + * @params: the parameters supplied to the OS Command + * + * All normal calls to Trusted OS uses this struct. If cmd requires further +- * information than what these field holds it can be passed as a parameter ++ * information than what these fields hold it can be passed as a parameter + * tagged as meta (setting the OPTEE_MSG_ATTR_META bit in corresponding +- * attrs field). All parameters tagged as meta has to come first. +- * +- * Temp memref parameters can be fragmented if supported by the Trusted OS +- * (when optee_smc.h is bearer of this protocol this is indicated with +- * OPTEE_SMC_SEC_CAP_UNREGISTERED_SHM). If a logical memref parameter is +- * fragmented then has all but the last fragment the +- * OPTEE_MSG_ATTR_FRAGMENT bit set in attrs. Even if a memref is fragmented +- * it will still be presented as a single logical memref to the Trusted +- * Application. ++ * attrs field). All parameters tagged as meta have to come first. + */ + struct optee_msg_arg { + u32 cmd; +@@ -199,7 +207,7 @@ struct optee_msg_arg { + u32 num_params; + + /* num_params tells the actual number of element in params */ +- struct optee_msg_param params[0]; ++ struct optee_msg_param params[]; + }; + + /** +@@ -290,13 +298,10 @@ struct optee_msg_arg { + * OPTEE_MSG_CMD_REGISTER_SHM registers a shared memory reference. The + * information is passed as: + * [in] param[0].attr OPTEE_MSG_ATTR_TYPE_TMEM_INPUT +- * [| OPTEE_MSG_ATTR_FRAGMENT] ++ * [| OPTEE_MSG_ATTR_NONCONTIG] + * [in] param[0].u.tmem.buf_ptr physical address (of first fragment) + * [in] param[0].u.tmem.size size (of first fragment) + * [in] param[0].u.tmem.shm_ref holds shared memory reference +- * ... +- * The shared memory can optionally be fragmented, temp memrefs can follow +- * each other with all but the last with the OPTEE_MSG_ATTR_FRAGMENT bit set. + * + * OPTEE_MSG_CMD_UNREGISTER_SHM unregisteres a previously registered shared + * memory reference. The information is passed as: +@@ -313,110 +318,4 @@ struct optee_msg_arg { + #define OPTEE_MSG_CMD_UNREGISTER_SHM 5 + #define OPTEE_MSG_FUNCID_CALL_WITH_ARG 0x0004 + +-/***************************************************************************** +- * Part 3 - Requests from secure world, RPC +- *****************************************************************************/ +- +-/* +- * All RPC is done with a struct optee_msg_arg as bearer of information, +- * struct optee_msg_arg::arg holds values defined by OPTEE_MSG_RPC_CMD_* below +- * +- * RPC communication with tee-supplicant is reversed compared to normal +- * client communication desribed above. The supplicant receives requests +- * and sends responses. +- */ +- +-/* +- * Load a TA into memory, defined in tee-supplicant +- */ +-#define OPTEE_MSG_RPC_CMD_LOAD_TA 0 +- +-/* +- * Reserved +- */ +-#define OPTEE_MSG_RPC_CMD_RPMB 1 +- +-/* +- * File system access, defined in tee-supplicant +- */ +-#define OPTEE_MSG_RPC_CMD_FS 2 +- +-/* +- * Get time +- * +- * Returns number of seconds and nano seconds since the Epoch, +- * 1970-01-01 00:00:00 +0000 (UTC). +- * +- * [out] param[0].u.value.a Number of seconds +- * [out] param[0].u.value.b Number of nano seconds. +- */ +-#define OPTEE_MSG_RPC_CMD_GET_TIME 3 +- +-/* +- * Wait queue primitive, helper for secure world to implement a wait queue. +- * +- * If secure world need to wait for a secure world mutex it issues a sleep +- * request instead of spinning in secure world. Conversely is a wakeup +- * request issued when a secure world mutex with a thread waiting thread is +- * unlocked. +- * +- * Waiting on a key +- * [in] param[0].u.value.a OPTEE_MSG_RPC_WAIT_QUEUE_SLEEP +- * [in] param[0].u.value.b wait key +- * +- * Waking up a key +- * [in] param[0].u.value.a OPTEE_MSG_RPC_WAIT_QUEUE_WAKEUP +- * [in] param[0].u.value.b wakeup key +- */ +-#define OPTEE_MSG_RPC_CMD_WAIT_QUEUE 4 +-#define OPTEE_MSG_RPC_WAIT_QUEUE_SLEEP 0 +-#define OPTEE_MSG_RPC_WAIT_QUEUE_WAKEUP 1 +- +-/* +- * Suspend execution +- * +- * [in] param[0].value .a number of milliseconds to suspend +- */ +-#define OPTEE_MSG_RPC_CMD_SUSPEND 5 +- +-/* +- * Allocate a piece of shared memory +- * +- * Shared memory can optionally be fragmented, to support that additional +- * spare param entries are allocated to make room for eventual fragments. +- * The spare param entries has .attr = OPTEE_MSG_ATTR_TYPE_NONE when +- * unused. All returned temp memrefs except the last should have the +- * OPTEE_MSG_ATTR_FRAGMENT bit set in the attr field. +- * +- * [in] param[0].u.value.a type of memory one of +- * OPTEE_MSG_RPC_SHM_TYPE_* below +- * [in] param[0].u.value.b requested size +- * [in] param[0].u.value.c required alignment +- * +- * [out] param[0].u.tmem.buf_ptr physical address (of first fragment) +- * [out] param[0].u.tmem.size size (of first fragment) +- * [out] param[0].u.tmem.shm_ref shared memory reference +- * ... +- * [out] param[n].u.tmem.buf_ptr physical address +- * [out] param[n].u.tmem.size size +- * [out] param[n].u.tmem.shm_ref shared memory reference (same value +- * as in param[n-1].u.tmem.shm_ref) +- */ +-#define OPTEE_MSG_RPC_CMD_SHM_ALLOC 6 +-/* Memory that can be shared with a non-secure user space application */ +-#define OPTEE_MSG_RPC_SHM_TYPE_APPL 0 +-/* Memory only shared with non-secure kernel */ +-#define OPTEE_MSG_RPC_SHM_TYPE_KERNEL 1 +- +-/* +- * Free shared memory previously allocated with OPTEE_MSG_RPC_CMD_SHM_ALLOC +- * +- * [in] param[0].u.value.a type of memory one of +- * OPTEE_MSG_RPC_SHM_TYPE_* above +- * [in] param[0].u.value.b value of shared memory reference +- * returned in param[0].u.tmem.shm_ref +- * above +- */ +-#define OPTEE_MSG_RPC_CMD_SHM_FREE 7 +- + #endif /* _OPTEE_MSG_H */ +diff --git a/drivers/tee/optee/optee_private.h b/drivers/tee/optee/optee_private.h +index d9c5037b4e03..d12d9b9f6d33 100644 +--- a/drivers/tee/optee/optee_private.h ++++ b/drivers/tee/optee/optee_private.h +@@ -7,6 +7,7 @@ + #define OPTEE_PRIVATE_H + + #include ++#include + #include + #include + #include +@@ -17,6 +18,7 @@ + /* Some Global Platform error codes used in this driver */ + #define TEEC_SUCCESS 0x00000000 + #define TEEC_ERROR_BAD_PARAMETERS 0xFFFF0006 ++#define TEEC_ERROR_NOT_SUPPORTED 0xFFFF000A + #define TEEC_ERROR_COMMUNICATION 0xFFFF000E + #define TEEC_ERROR_OUT_OF_MEMORY 0xFFFF000C + #define TEEC_ERROR_SHORT_BUFFER 0xFFFF0010 +@@ -65,6 +67,32 @@ struct optee_supp { + struct completion reqs_c; + }; + ++/** ++ * struct optee_ffa_data - FFA communication struct ++ * @dst FFA destination id, the id of OP-TEE in secure world ++ * @ops FFA operations ++ * @mutex Serializes access to @global_ids ++ * @global_ids FF-A shared memory global handle translation ++ */ ++struct optee_ffa { ++ u32 dst; ++ struct ffa_ops *ops; ++ struct mutex mutex; ++ struct rhashtable global_ids; ++}; ++ ++struct optee; ++struct optee_ops { ++ int (*do_call_with_arg)(struct tee_context *ctx, ++ struct tee_shm *shm_arg); ++ int (*to_msg_param)(struct optee *optee, ++ struct optee_msg_param *msg_params, ++ size_t num_params, const struct tee_param *params); ++ int (*from_msg_param)(struct optee *optee, struct tee_param *params, ++ size_t num_params, ++ const struct optee_msg_param *msg_params); ++}; ++ + /** + * struct optee - main service struct + * @supp_teedev: supplicant device +@@ -82,7 +110,11 @@ struct optee_supp { + struct optee { + struct tee_device *supp_teedev; + struct tee_device *teedev; ++ const struct optee_ops *ops; + optee_invoke_fn *invoke_fn; ++#ifdef CONFIG_ARM_FFA_TRANSPORT ++ struct optee_ffa ffa; ++#endif + struct optee_call_queue call_queue; + struct optee_wait_queue wait_queue; + struct optee_supp supp; +@@ -141,10 +173,11 @@ int optee_supp_recv(struct tee_context *ctx, u32 *func, u32 *num_params, + int optee_supp_send(struct tee_context *ctx, u32 ret, u32 num_params, + struct tee_param *param); + +-u32 optee_do_call_with_arg(struct tee_context *ctx, phys_addr_t parg); ++int optee_do_call_with_arg(struct tee_context *ctx, struct tee_shm *arg); + int optee_open_session(struct tee_context *ctx, + struct tee_ioctl_open_session_arg *arg, + struct tee_param *param); ++int optee_close_session_helper(struct tee_context *ctx, u32 session); + int optee_close_session(struct tee_context *ctx, u32 session); + int optee_invoke_func(struct tee_context *ctx, struct tee_ioctl_invoke_arg *arg, + struct tee_param *param); +@@ -163,11 +196,6 @@ int optee_shm_register_supp(struct tee_context *ctx, struct tee_shm *shm, + unsigned long start); + int optee_shm_unregister_supp(struct tee_context *ctx, struct tee_shm *shm); + +-int optee_from_msg_param(struct tee_param *params, size_t num_params, +- const struct optee_msg_param *msg_params); +-int optee_to_msg_param(struct optee_msg_param *msg_params, size_t num_params, +- const struct tee_param *params); +- + u64 *optee_allocate_pages_list(size_t num_entries); + void optee_free_pages_list(void *array, size_t num_entries); + void optee_fill_pages_list(u64 *dst, struct page **pages, int num_pages, +@@ -175,6 +203,27 @@ void optee_fill_pages_list(u64 *dst, struct page **pages, int num_pages, + + int optee_enumerate_devices(void); + ++int optee_shm_add_ffa_handle(struct optee *optee, struct tee_shm *shm, ++ u64 global_id); ++int optee_shm_rem_ffa_handle(struct optee *optee, u64 global_id); ++ ++struct tee_shm *optee_shm_from_ffa_handle(struct optee *optee, u64 global_id); ++void optee_ffa_disable_shm_cache(struct optee *optee); ++ ++int optee_ffa_shm_register(struct tee_context *ctx, struct tee_shm *shm, ++ struct page **pages, size_t num_pages, ++ unsigned long start); ++int optee_ffa_shm_unregister(struct tee_context *ctx, struct tee_shm *shm); ++int optee_ffa_shm_register_supp(struct tee_context *ctx, struct tee_shm *shm, ++ struct page **pages, size_t num_pages, ++ unsigned long start); ++int optee_ffa_shm_unregister_supp(struct tee_context *ctx, ++ struct tee_shm *shm); ++ ++int optee_ffa_do_call_with_arg(struct tee_context *ctx, struct tee_shm *arg); ++int optee_ffa_rpc_shm_register(struct tee_context *ctx, struct tee_shm *shm); ++void optee_handle_ffa_rpc(struct tee_context *ctx, u32 *w4, u32 *w5, u32 *w6); ++ + /* + * Small helpers + */ +diff --git a/drivers/tee/optee/optee_rpc_cmd.h b/drivers/tee/optee/optee_rpc_cmd.h +new file mode 100644 +index 000000000000..712aa32513d7 +--- /dev/null ++++ b/drivers/tee/optee/optee_rpc_cmd.h +@@ -0,0 +1,333 @@ ++/* SPDX-License-Identifier: BSD-2-Clause */ ++/* ++ * Copyright (c) 2016-2018, Linaro Limited ++ */ ++ ++#ifndef __OPTEE_RPC_CMD_H ++#define __OPTEE_RPC_CMD_H ++ ++/* ++ * All RPC is done with a struct optee_msg_arg as bearer of information, ++ * struct optee_msg_arg::arg holds values defined by OPTEE_RPC_CMD_* below. ++ * Only the commands handled by the kernel driver are defined here. ++ * ++ * RPC communication with tee-supplicant is reversed compared to normal ++ * client communication described above. The supplicant receives requests ++ * and sends responses. ++ */ ++ ++/* ++ * Load a TA into memory ++ * ++ * Since the size of the TA isn't known in advance the size of the TA is ++ * can be queried with a NULL buffer. ++ * ++ * [in] value[0].a-b UUID ++ * [out] memref[1] Buffer with TA ++ */ ++#define OPTEE_RPC_CMD_LOAD_TA 0 ++ ++/* ++ * Replay Protected Memory Block access ++ * ++ * [in] memref[0] Frames to device ++ * [out] memref[1] Frames from device ++ */ ++#define OPTEE_RPC_CMD_RPMB 1 ++ ++/* ++ * File system access, see definition of protocol below ++ */ ++#define OPTEE_RPC_CMD_FS 2 ++ ++/* ++ * Get time ++ * ++ * Returns number of seconds and nano seconds since the Epoch, ++ * 1970-01-01 00:00:00 +0000 (UTC). ++ * ++ * [out] value[0].a Number of seconds ++ * [out] value[0].b Number of nano seconds. ++ */ ++#define OPTEE_RPC_CMD_GET_TIME 3 ++ ++/* ++ * Wait queue primitive, helper for secure world to implement a wait queue. ++ * ++ * If secure world needs to wait for a secure world mutex it issues a sleep ++ * request instead of spinning in secure world. Conversely is a wakeup ++ * request issued when a secure world mutex with a thread waiting thread is ++ * unlocked. ++ * ++ * Waiting on a key ++ * [in] value[0].a OPTEE_RPC_WAIT_QUEUE_SLEEP ++ * [in] value[0].b Wait key ++ * ++ * Waking up a key ++ * [in] value[0].a OPTEE_RPC_WAIT_QUEUE_WAKEUP ++ * [in] value[0].b Wakeup key ++ */ ++#define OPTEE_RPC_CMD_WAIT_QUEUE 4 ++#define OPTEE_RPC_WAIT_QUEUE_SLEEP 0 ++#define OPTEE_RPC_WAIT_QUEUE_WAKEUP 1 ++ ++/* ++ * Suspend execution ++ * ++ * [in] value[0].a Number of milliseconds to suspend ++ */ ++#define OPTEE_RPC_CMD_SUSPEND 5 ++ ++/* ++ * Allocate a piece of shared memory ++ * ++ * [in] value[0].a Type of memory one of ++ * OPTEE_RPC_SHM_TYPE_* below ++ * [in] value[0].b Requested size ++ * [in] value[0].c Required alignment ++ * [out] memref[0] Buffer ++ */ ++#define OPTEE_RPC_CMD_SHM_ALLOC 6 ++/* Memory that can be shared with a non-secure user space application */ ++#define OPTEE_RPC_SHM_TYPE_APPL 0 ++/* Memory only shared with non-secure kernel */ ++#define OPTEE_RPC_SHM_TYPE_KERNEL 1 ++/* ++ * Memory shared with non-secure kernel and exported to a non-secure user ++ * space application ++ */ ++#define OPTEE_RPC_SHM_TYPE_GLOBAL 2 ++ ++/* ++ * Free shared memory previously allocated with OPTEE_RPC_CMD_SHM_ALLOC ++ * ++ * [in] value[0].a Type of memory one of ++ * OPTEE_RPC_SHM_TYPE_* above ++ * [in] value[0].b Value of shared memory reference or cookie ++ */ ++#define OPTEE_RPC_CMD_SHM_FREE 7 ++ ++/* Was OPTEE_RPC_CMD_SQL_FS, which isn't supported any longer */ ++#define OPTEE_RPC_CMD_SQL_FS_RESERVED 8 ++ ++/* ++ * Send TA profiling information to normal world ++ * ++ * [in/out] value[0].a File identifier. Must be set to 0 on ++ * first call. A value >= 1 will be ++ * returned on success. Re-use this value ++ * to append data to the same file. ++ * [in] memref[1] TA UUID ++ * [in] memref[2] Profile data ++ */ ++#define OPTEE_RPC_CMD_GPROF 9 ++ ++/* ++ * Socket command, see definition of protocol below ++ */ ++#define OPTEE_RPC_CMD_SOCKET 10 ++ ++/* ++ * Send TA function graph data to normal world ++ * ++ * [in/out] value[0].a File identifier. Must be set to 0 on ++ * first call. A value >= 1 will be ++ * returned on success. Re-use this value ++ * to append data to the same file. ++ * [in] memref[1] TA UUID ++ * [in] memref[2] function graph data ++ */ ++#define OPTEE_RPC_CMD_FTRACE 11 ++ ++/* ++ * Register timestamp buffer in the linux kernel optee driver ++ * ++ * [in] value[0].a Subcommand (register buffer, unregister buffer) ++ * OPTEE_RPC_CMD_BENCH_REG_* below ++ * [in] value[0].b Physical address of timestamp buffer ++ * [in] value[0].c Size of buffer ++ */ ++#define OPTEE_RPC_CMD_BENCH_REG_NEW 0 ++#define OPTEE_RPC_CMD_BENCH_REG_DEL 1 ++#define OPTEE_RPC_CMD_BENCH_REG 20 ++ ++/* ++ * Definition of protocol for command OPTEE_RPC_CMD_FS ++ */ ++ ++/* ++ * Open a file ++ * ++ * [in] value[0].a OPTEE_RPC_FS_OPEN ++ * [in] memref[1] A string holding the file name ++ * [out] value[2].a File descriptor of open file ++ */ ++#define OPTEE_RPC_FS_OPEN 0 ++ ++/* ++ * Create a file ++ * ++ * [in] value[0].a OPTEE_RPC_FS_CREATE ++ * [in] memref[1] A string holding the file name ++ * [out] value[2].a File descriptor of open file ++ */ ++#define OPTEE_RPC_FS_CREATE 1 ++ ++/* ++ * Close a file ++ * ++ * [in] value[0].a OPTEE_RPC_FS_CLOSE ++ * [in] value[0].b File descriptor of open file. ++ */ ++#define OPTEE_RPC_FS_CLOSE 2 ++ ++/* ++ * Read from a file ++ * ++ * [in] value[0].a OPTEE_RPC_FS_READ ++ * [in] value[0].b File descriptor of open file ++ * [in] value[0].c Offset into file ++ * [out] memref[1] Buffer to hold returned data ++ */ ++#define OPTEE_RPC_FS_READ 3 ++ ++/* ++ * Write to a file ++ * ++ * [in] value[0].a OPTEE_RPC_FS_WRITE ++ * [in] value[0].b File descriptor of open file ++ * [in] value[0].c Offset into file ++ * [in] memref[1] Buffer holding data to be written ++ */ ++#define OPTEE_RPC_FS_WRITE 4 ++ ++/* ++ * Truncate a file ++ * ++ * [in] value[0].a OPTEE_RPC_FS_TRUNCATE ++ * [in] value[0].b File descriptor of open file ++ * [in] value[0].c Length of file. ++ */ ++#define OPTEE_RPC_FS_TRUNCATE 5 ++ ++/* ++ * Remove a file ++ * ++ * [in] value[0].a OPTEE_RPC_FS_REMOVE ++ * [in] memref[1] A string holding the file name ++ */ ++#define OPTEE_RPC_FS_REMOVE 6 ++ ++/* ++ * Rename a file ++ * ++ * [in] value[0].a OPTEE_RPC_FS_RENAME ++ * [in] value[0].b True if existing target should be removed ++ * [in] memref[1] A string holding the old file name ++ * [in] memref[2] A string holding the new file name ++ */ ++#define OPTEE_RPC_FS_RENAME 7 ++ ++/* ++ * Opens a directory for file listing ++ * ++ * [in] value[0].a OPTEE_RPC_FS_OPENDIR ++ * [in] memref[1] A string holding the name of the directory ++ * [out] value[2].a Handle to open directory ++ */ ++#define OPTEE_RPC_FS_OPENDIR 8 ++ ++/* ++ * Closes a directory handle ++ * ++ * [in] value[0].a OPTEE_RPC_FS_CLOSEDIR ++ * [in] value[0].b Handle to open directory ++ */ ++#define OPTEE_RPC_FS_CLOSEDIR 9 ++ ++/* ++ * Read next file name of directory ++ * ++ * ++ * [in] value[0].a OPTEE_RPC_FS_READDIR ++ * [in] value[0].b Handle to open directory ++ * [out] memref[1] A string holding the file name ++ */ ++#define OPTEE_RPC_FS_READDIR 10 ++ ++/* End of definition of protocol for command OPTEE_RPC_CMD_FS */ ++ ++/* ++ * Definition of protocol for command OPTEE_RPC_CMD_SOCKET ++ */ ++ ++#define OPTEE_RPC_SOCKET_TIMEOUT_NONBLOCKING 0 ++#define OPTEE_RPC_SOCKET_TIMEOUT_BLOCKING 0xffffffff ++ ++/* ++ * Open socket ++ * ++ * [in] value[0].a OPTEE_RPC_SOCKET_OPEN ++ * [in] value[0].b TA instance id ++ * [in] value[1].a Server port number ++ * [in] value[1].b Protocol, TEE_ISOCKET_PROTOCOLID_* ++ * [in] value[1].c Ip version TEE_IP_VERSION_* from tee_ipsocket.h ++ * [in] memref[2] Server address ++ * [out] value[3].a Socket handle (32-bit) ++ */ ++#define OPTEE_RPC_SOCKET_OPEN 0 ++ ++/* ++ * Close socket ++ * ++ * [in] value[0].a OPTEE_RPC_SOCKET_CLOSE ++ * [in] value[0].b TA instance id ++ * [in] value[0].c Socket handle ++ */ ++#define OPTEE_RPC_SOCKET_CLOSE 1 ++ ++/* ++ * Close all sockets ++ * ++ * [in] value[0].a OPTEE_RPC_SOCKET_CLOSE_ALL ++ * [in] value[0].b TA instance id ++ */ ++#define OPTEE_RPC_SOCKET_CLOSE_ALL 2 ++ ++/* ++ * Send data on socket ++ * ++ * [in] value[0].a OPTEE_RPC_SOCKET_SEND ++ * [in] value[0].b TA instance id ++ * [in] value[0].c Socket handle ++ * [in] memref[1] Buffer to transmit ++ * [in] value[2].a Timeout ms or OPTEE_RPC_SOCKET_TIMEOUT_* ++ * [out] value[2].b Number of transmitted bytes ++ */ ++#define OPTEE_RPC_SOCKET_SEND 3 ++ ++/* ++ * Receive data on socket ++ * ++ * [in] value[0].a OPTEE_RPC_SOCKET_RECV ++ * [in] value[0].b TA instance id ++ * [in] value[0].c Socket handle ++ * [out] memref[1] Buffer to receive ++ * [in] value[2].a Timeout ms or OPTEE_RPC_SOCKET_TIMEOUT_* ++ */ ++#define OPTEE_RPC_SOCKET_RECV 4 ++ ++/* ++ * Perform IOCTL on socket ++ * ++ * [in] value[0].a OPTEE_RPC_SOCKET_IOCTL ++ * [in] value[0].b TA instance id ++ * [in] value[0].c Socket handle ++ * [in/out] memref[1] Buffer ++ * [in] value[2].a Ioctl command ++ */ ++#define OPTEE_RPC_SOCKET_IOCTL 5 ++ ++/* End of definition of protocol for command OPTEE_RPC_CMD_SOCKET */ ++ ++#endif /*__OPTEE_RPC_CMD_H*/ +diff --git a/drivers/tee/optee/rpc.c b/drivers/tee/optee/rpc.c +index b4ade54d1f28..ca5d5d01b58f 100644 +--- a/drivers/tee/optee/rpc.c ++++ b/drivers/tee/optee/rpc.c +@@ -9,8 +9,11 @@ + #include + #include + #include ++#include "optee_msg.h" + #include "optee_private.h" ++#include "optee_rpc_cmd.h" + #include "optee_smc.h" ++#include "optee_ffa.h" + + struct wq_entry { + struct list_head link; +@@ -102,10 +105,10 @@ static void handle_rpc_func_cmd_wq(struct optee *optee, + goto bad; + + switch (arg->params[0].u.value.a) { +- case OPTEE_MSG_RPC_WAIT_QUEUE_SLEEP: ++ case OPTEE_RPC_WAIT_QUEUE_SLEEP: + wq_sleep(&optee->wait_queue, arg->params[0].u.value.b); + break; +- case OPTEE_MSG_RPC_WAIT_QUEUE_WAKEUP: ++ case OPTEE_RPC_WAIT_QUEUE_WAKEUP: + wq_wakeup(&optee->wait_queue, arg->params[0].u.value.b); + break; + default: +@@ -140,10 +143,10 @@ static void handle_rpc_func_cmd_wait(struct optee_msg_arg *arg) + arg->ret = TEEC_ERROR_BAD_PARAMETERS; + } + +-static void handle_rpc_supp_cmd(struct tee_context *ctx, ++static void handle_rpc_supp_cmd(struct tee_context *ctx, struct optee *optee, + struct optee_msg_arg *arg) + { +- struct tee_param *params; ++ struct tee_param *params = NULL; + + arg->ret_origin = TEEC_ORIGIN_COMMS; + +@@ -154,32 +157,36 @@ static void handle_rpc_supp_cmd(struct tee_context *ctx, + return; + } + +- if (optee_from_msg_param(params, arg->num_params, arg->params)) { ++ if (optee->ops->from_msg_param(optee, params, arg->num_params, ++ arg->params)) { + arg->ret = TEEC_ERROR_BAD_PARAMETERS; + goto out; + } + + arg->ret = optee_supp_thrd_req(ctx, arg->cmd, arg->num_params, params); + +- if (optee_to_msg_param(arg->params, arg->num_params, params)) ++ if (optee->ops->to_msg_param(optee, arg->params, arg->num_params, ++ params)) + arg->ret = TEEC_ERROR_BAD_PARAMETERS; + out: + kfree(params); + } + ++ ++ + static struct tee_shm *cmd_alloc_suppl(struct tee_context *ctx, size_t sz) + { +- u32 ret; +- struct tee_param param; + struct optee *optee = tee_get_drvdata(ctx->teedev); +- struct tee_shm *shm; ++ struct tee_param param = { }; ++ struct tee_shm *shm = NULL; ++ u32 ret = 0; + + param.attr = TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INOUT; +- param.u.value.a = OPTEE_MSG_RPC_SHM_TYPE_APPL; ++ param.u.value.a = OPTEE_RPC_SHM_TYPE_APPL; + param.u.value.b = sz; + param.u.value.c = 0; + +- ret = optee_supp_thrd_req(ctx, OPTEE_MSG_RPC_CMD_SHM_ALLOC, 1, ¶m); ++ ret = optee_supp_thrd_req(ctx, OPTEE_RPC_CMD_SHM_ALLOC, 1, ¶m); + if (ret) + return ERR_PTR(-ENOMEM); + +@@ -216,10 +223,10 @@ static void handle_rpc_func_cmd_shm_alloc(struct tee_context *ctx, + + sz = arg->params[0].u.value.b; + switch (arg->params[0].u.value.a) { +- case OPTEE_MSG_RPC_SHM_TYPE_APPL: ++ case OPTEE_RPC_SHM_TYPE_APPL: + shm = cmd_alloc_suppl(ctx, sz); + break; +- case OPTEE_MSG_RPC_SHM_TYPE_KERNEL: ++ case OPTEE_RPC_SHM_TYPE_KERNEL: + shm = tee_shm_alloc(ctx, sz, TEE_SHM_MAPPED); + break; + default: +@@ -291,7 +298,7 @@ static void cmd_free_suppl(struct tee_context *ctx, struct tee_shm *shm) + struct tee_param param; + + param.attr = TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INOUT; +- param.u.value.a = OPTEE_MSG_RPC_SHM_TYPE_APPL; ++ param.u.value.a = OPTEE_RPC_SHM_TYPE_APPL; + param.u.value.b = tee_shm_get_id(shm); + param.u.value.c = 0; + +@@ -308,7 +315,7 @@ static void cmd_free_suppl(struct tee_context *ctx, struct tee_shm *shm) + */ + tee_shm_put(shm); + +- optee_supp_thrd_req(ctx, OPTEE_MSG_RPC_CMD_SHM_FREE, 1, ¶m); ++ optee_supp_thrd_req(ctx, OPTEE_RPC_CMD_SHM_FREE, 1, ¶m); + } + + static void handle_rpc_func_cmd_shm_free(struct tee_context *ctx, +@@ -326,10 +333,10 @@ static void handle_rpc_func_cmd_shm_free(struct tee_context *ctx, + + shm = (struct tee_shm *)(unsigned long)arg->params[0].u.value.b; + switch (arg->params[0].u.value.a) { +- case OPTEE_MSG_RPC_SHM_TYPE_APPL: ++ case OPTEE_RPC_SHM_TYPE_APPL: + cmd_free_suppl(ctx, shm); + break; +- case OPTEE_MSG_RPC_SHM_TYPE_KERNEL: ++ case OPTEE_RPC_SHM_TYPE_KERNEL: + tee_shm_free(shm); + break; + default: +@@ -357,7 +364,7 @@ static void handle_rpc_func_cmd(struct tee_context *ctx, struct optee *optee, + struct tee_shm *shm, + struct optee_call_ctx *call_ctx) + { +- struct optee_msg_arg *arg; ++ struct optee_msg_arg *arg = NULL; + + arg = tee_shm_get_va(shm, 0); + if (IS_ERR(arg)) { +@@ -366,24 +373,24 @@ static void handle_rpc_func_cmd(struct tee_context *ctx, struct optee *optee, + } + + switch (arg->cmd) { +- case OPTEE_MSG_RPC_CMD_GET_TIME: ++ case OPTEE_RPC_CMD_GET_TIME: + handle_rpc_func_cmd_get_time(arg); + break; +- case OPTEE_MSG_RPC_CMD_WAIT_QUEUE: ++ case OPTEE_RPC_CMD_WAIT_QUEUE: + handle_rpc_func_cmd_wq(optee, arg); + break; +- case OPTEE_MSG_RPC_CMD_SUSPEND: ++ case OPTEE_RPC_CMD_SUSPEND: + handle_rpc_func_cmd_wait(arg); + break; +- case OPTEE_MSG_RPC_CMD_SHM_ALLOC: ++ case OPTEE_RPC_CMD_SHM_ALLOC: + free_pages_list(call_ctx); + handle_rpc_func_cmd_shm_alloc(ctx, arg, call_ctx); + break; +- case OPTEE_MSG_RPC_CMD_SHM_FREE: ++ case OPTEE_RPC_CMD_SHM_FREE: + handle_rpc_func_cmd_shm_free(ctx, arg); + break; + default: +- handle_rpc_supp_cmd(ctx, arg); ++ handle_rpc_supp_cmd(ctx, optee, arg); + } + } + +@@ -441,3 +448,95 @@ void optee_handle_rpc(struct tee_context *ctx, struct optee_rpc_param *param, + + param->a0 = OPTEE_SMC_CALL_RETURN_FROM_RPC; + } ++ ++#ifdef CONFIG_ARM_FFA_TRANSPORT ++static void handle_ffa_rpc_func_cmd(struct tee_context *ctx, ++ struct optee *optee, ++ struct optee_msg_arg *arg) ++{ ++ switch (arg->cmd) { ++ case OPTEE_RPC_CMD_GET_TIME: ++ handle_rpc_func_cmd_get_time(arg); ++ break; ++ case OPTEE_RPC_CMD_WAIT_QUEUE: ++ handle_rpc_func_cmd_wq(optee, arg); ++ break; ++ case OPTEE_RPC_CMD_SUSPEND: ++ handle_rpc_func_cmd_wait(arg); ++ break; ++ case OPTEE_RPC_CMD_SHM_ALLOC: ++ case OPTEE_RPC_CMD_SHM_FREE: ++ pr_err("%s: RPC cmd 0x%x: not supported\n", __func__, ++ arg->cmd); ++ arg->ret = TEEC_ERROR_NOT_SUPPORTED; ++ break; ++ default: ++ handle_rpc_supp_cmd(ctx, optee, arg); ++ } ++} ++ ++void optee_handle_ffa_rpc(struct tee_context *ctx, u32 *w4, u32 *w5, u32 *w6) ++{ ++ struct optee *optee = tee_get_drvdata(ctx->teedev); ++ struct tee_shm *shm = NULL; ++ struct optee_msg_arg *rpc_arg = NULL; ++ u64 global_handle = 0; ++ u32 cmd = *w4; ++ ++ switch (cmd) { ++ case OPTEE_FFA_YIELDING_CALL_RETURN_ALLOC_KERN_SHM: ++ case OPTEE_FFA_YIELDING_CALL_RETURN_ALLOC_SUPPL_SHM: ++ if (cmd == OPTEE_FFA_YIELDING_CALL_RETURN_ALLOC_KERN_SHM) ++ shm = tee_shm_alloc(ctx, *w5 * PAGE_SIZE, ++ TEE_SHM_MAPPED); ++ else ++ shm = cmd_alloc_suppl(ctx, *w5 * PAGE_SIZE); ++ ++ if (IS_ERR_OR_NULL(shm)) ++ break; ++ ++ *w4 = shm->sec_world_id; ++ *w5 = shm->sec_world_id >> 32; ++ *w6 = shm->offset; ++ return; ++ case OPTEE_FFA_YIELDING_CALL_RETURN_FREE_KERN_SHM: ++ case OPTEE_FFA_YIELDING_CALL_RETURN_FREE_SUPPL_SHM: ++ global_handle = *w5 | ((u64)*w6 << 32); ++ shm = optee_shm_from_ffa_handle(optee, global_handle); ++ if (!shm) { ++ pr_err("Invalid global handle 0x%llx\n", global_handle); ++ break; ++ } ++ if (cmd == OPTEE_FFA_YIELDING_CALL_RETURN_FREE_KERN_SHM) ++ tee_shm_free(shm); ++ else ++ cmd_free_suppl(ctx, shm); ++ break; ++ case OPTEE_FFA_YIELDING_CALL_RETURN_RPC_CMD: ++ global_handle = *w5 | ((u64)*w6 << 32); ++ shm = optee_shm_from_ffa_handle(optee, global_handle); ++ if (!shm) { ++ pr_err("Invalid global handle 0x%llx\n", global_handle); ++ break; ++ } ++ rpc_arg = tee_shm_get_va(shm, 0); ++ if (IS_ERR(rpc_arg)) { ++ pr_err("Invalid offset 0 for global handle 0x%llx\n", ++ global_handle); ++ break; ++ } ++ handle_ffa_rpc_func_cmd(ctx, optee, rpc_arg); ++ break; ++ case OPTEE_FFA_YIELDING_CALL_RETURN_INTERRUPT: ++ /* Interrupt delivered by now */ ++ break; ++ default: ++ pr_warn("Unknown RPC func 0x%x\n", cmd); ++ break; ++ } ++ ++ *w4 = 0; ++ *w5 = 0; ++ *w6 = 0; ++} ++#endif /*CONFIG_ARM_FFA_TRANSPORT*/ +diff --git a/drivers/tee/optee/shm_pool.c b/drivers/tee/optee/shm_pool.c +index d767eebf30bd..ffc6821f6ce3 100644 +--- a/drivers/tee/optee/shm_pool.c ++++ b/drivers/tee/optee/shm_pool.c +@@ -87,3 +87,53 @@ struct tee_shm_pool_mgr *optee_shm_pool_alloc_pages(void) + + return mgr; + } ++ ++#ifdef CONFIG_ARM_FFA_TRANSPORT ++static int pool_ffa_op_alloc(struct tee_shm_pool_mgr *poolm, ++ struct tee_shm *shm, size_t size) ++{ ++ unsigned int order = get_order(size); ++ struct page *page; ++ int rc = 0; ++ ++ page = alloc_pages(GFP_KERNEL | __GFP_ZERO, order); ++ if (!page) ++ return -ENOMEM; ++ ++ shm->kaddr = page_address(page); ++ shm->paddr = page_to_phys(page); ++ shm->size = PAGE_SIZE << order; ++ ++ shm->flags |= TEE_SHM_REGISTER; ++ rc = optee_ffa_shm_register(shm->ctx, shm, &page, 1 << order, ++ (unsigned long)shm->kaddr); ++ ++ return rc; ++} ++ ++static void pool_ffa_op_free(struct tee_shm_pool_mgr *poolm, ++ struct tee_shm *shm) ++{ ++ optee_ffa_shm_unregister(shm->ctx, shm); ++ free_pages((unsigned long)shm->kaddr, get_order(shm->size)); ++ shm->kaddr = NULL; ++} ++ ++static const struct tee_shm_pool_mgr_ops pool_ffa_ops = { ++ .alloc = pool_ffa_op_alloc, ++ .free = pool_ffa_op_free, ++ .destroy_poolmgr = pool_op_destroy_poolmgr, ++}; ++ ++struct tee_shm_pool_mgr *optee_ffa_shm_pool_alloc_pages(void) ++{ ++ struct tee_shm_pool_mgr *mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); ++ ++ if (!mgr) ++ return ERR_PTR(-ENOMEM); ++ ++ mgr->ops = &pool_ffa_ops; ++ ++ return mgr; ++} ++#endif /*CONFIG_ARM_FFA_TRANSPORT*/ +diff --git a/drivers/tee/optee/shm_pool.h b/drivers/tee/optee/shm_pool.h +index 28109d991c4b..34c5fd74a3ff 100644 +--- a/drivers/tee/optee/shm_pool.h ++++ b/drivers/tee/optee/shm_pool.h +@@ -10,5 +10,6 @@ + #include + + struct tee_shm_pool_mgr *optee_shm_pool_alloc_pages(void); ++struct tee_shm_pool_mgr *optee_ffa_shm_pool_alloc_pages(void); + + #endif +diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c +index 3d32a2ca48c3..974fe7081225 100644 +--- a/drivers/tee/tee_core.c ++++ b/drivers/tee/tee_core.c +@@ -59,7 +59,6 @@ static struct tee_context *teedev_open(struct tee_device *teedev) + + kref_init(&ctx->refcount); + ctx->teedev = teedev; +- INIT_LIST_HEAD(&ctx->list_shm); + rc = teedev->desc->ops->open(ctx); + if (rc) + goto err; +diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c +index 09ddcd06c715..deb22f877881 100644 +--- a/drivers/tee/tee_shm.c ++++ b/drivers/tee/tee_shm.c +@@ -13,13 +13,13 @@ + + static void tee_shm_release(struct tee_shm *shm) + { +- struct tee_device *teedev = shm->teedev; ++ struct tee_device *teedev = shm->ctx->teedev; + +- mutex_lock(&teedev->mutex); +- idr_remove(&teedev->idr, shm->id); +- if (shm->ctx) +- list_del(&shm->link); +- mutex_unlock(&teedev->mutex); ++ if (shm->flags & TEE_SHM_DMA_BUF) { ++ mutex_lock(&teedev->mutex); ++ idr_remove(&teedev->idr, shm->id); ++ mutex_unlock(&teedev->mutex); ++ } + + if (shm->flags & TEE_SHM_POOL) { + struct tee_shm_pool_mgr *poolm; +@@ -44,8 +44,7 @@ static void tee_shm_release(struct tee_shm *shm) + kfree(shm->pages); + } + +- if (shm->ctx) +- teedev_ctx_put(shm->ctx); ++ teedev_ctx_put(shm->ctx); + + kfree(shm); + +@@ -82,7 +81,7 @@ static int tee_shm_op_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma) + size_t size = vma->vm_end - vma->vm_start; + + /* Refuse sharing shared memory provided by application */ +- if (shm->flags & TEE_SHM_REGISTER) ++ if (shm->flags & TEE_SHM_USER_MAPPED) + return -EINVAL; + + return remap_pfn_range(vma, vma->vm_start, shm->paddr >> PAGE_SHIFT, +@@ -97,20 +96,14 @@ static const struct dma_buf_ops tee_shm_dma_buf_ops = { + .mmap = tee_shm_op_mmap, + }; + +-static struct tee_shm *__tee_shm_alloc(struct tee_context *ctx, +- struct tee_device *teedev, +- size_t size, u32 flags) ++struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags) + { ++ struct tee_device *teedev = ctx->teedev; + struct tee_shm_pool_mgr *poolm = NULL; + struct tee_shm *shm; + void *ret; + int rc; + +- if (ctx && ctx->teedev != teedev) { +- dev_err(teedev->dev.parent, "ctx and teedev mismatch\n"); +- return ERR_PTR(-EINVAL); +- } +- + if (!(flags & TEE_SHM_MAPPED)) { + dev_err(teedev->dev.parent, + "only mapped allocations supported\n"); +@@ -138,7 +131,6 @@ static struct tee_shm *__tee_shm_alloc(struct tee_context *ctx, + } + + shm->flags = flags | TEE_SHM_POOL; +- shm->teedev = teedev; + shm->ctx = ctx; + if (flags & TEE_SHM_DMA_BUF) + poolm = teedev->pool->dma_buf_mgr; +@@ -151,17 +143,18 @@ static struct tee_shm *__tee_shm_alloc(struct tee_context *ctx, + goto err_kfree; + } + +- mutex_lock(&teedev->mutex); +- shm->id = idr_alloc(&teedev->idr, shm, 1, 0, GFP_KERNEL); +- mutex_unlock(&teedev->mutex); +- if (shm->id < 0) { +- ret = ERR_PTR(shm->id); +- goto err_pool_free; +- } + + if (flags & TEE_SHM_DMA_BUF) { + DEFINE_DMA_BUF_EXPORT_INFO(exp_info); + ++ mutex_lock(&teedev->mutex); ++ shm->id = idr_alloc(&teedev->idr, shm, 1, 0, GFP_KERNEL); ++ mutex_unlock(&teedev->mutex); ++ if (shm->id < 0) { ++ ret = ERR_PTR(shm->id); ++ goto err_pool_free; ++ } ++ + exp_info.ops = &tee_shm_dma_buf_ops; + exp_info.size = shm->size; + exp_info.flags = O_RDWR; +@@ -174,18 +167,16 @@ static struct tee_shm *__tee_shm_alloc(struct tee_context *ctx, + } + } + +- if (ctx) { ++ if (ctx) + teedev_ctx_get(ctx); +- mutex_lock(&teedev->mutex); +- list_add_tail(&shm->link, &ctx->list_shm); +- mutex_unlock(&teedev->mutex); +- } + + return shm; + err_rem: +- mutex_lock(&teedev->mutex); +- idr_remove(&teedev->idr, shm->id); +- mutex_unlock(&teedev->mutex); ++ if (flags & TEE_SHM_DMA_BUF) { ++ mutex_lock(&teedev->mutex); ++ idr_remove(&teedev->idr, shm->id); ++ mutex_unlock(&teedev->mutex); ++ } + err_pool_free: + poolm->ops->free(poolm, shm); + err_kfree: +@@ -194,31 +185,8 @@ static struct tee_shm *__tee_shm_alloc(struct tee_context *ctx, + tee_device_put(teedev); + return ret; + } +- +-/** +- * tee_shm_alloc() - Allocate shared memory +- * @ctx: Context that allocates the shared memory +- * @size: Requested size of shared memory +- * @flags: Flags setting properties for the requested shared memory. +- * +- * Memory allocated as global shared memory is automatically freed when the +- * TEE file pointer is closed. The @flags field uses the bits defined by +- * TEE_SHM_* in . TEE_SHM_MAPPED must currently always be +- * set. If TEE_SHM_DMA_BUF global shared memory will be allocated and +- * associated with a dma-buf handle, else driver private memory. +- */ +-struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags) +-{ +- return __tee_shm_alloc(ctx, ctx->teedev, size, flags); +-} + EXPORT_SYMBOL_GPL(tee_shm_alloc); + +-struct tee_shm *tee_shm_priv_alloc(struct tee_device *teedev, size_t size) +-{ +- return __tee_shm_alloc(NULL, teedev, size, TEE_SHM_MAPPED); +-} +-EXPORT_SYMBOL_GPL(tee_shm_priv_alloc); +- + struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr, + size_t length, u32 flags) + { +@@ -251,7 +219,6 @@ struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr, + } + + shm->flags = flags | TEE_SHM_REGISTER; +- shm->teedev = teedev; + shm->ctx = ctx; + shm->id = -1; + addr = untagged_addr(addr); +@@ -307,10 +274,6 @@ struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr, + } + } + +- mutex_lock(&teedev->mutex); +- list_add_tail(&shm->link, &ctx->list_shm); +- mutex_unlock(&teedev->mutex); +- + return shm; + err: + if (shm) { +diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h +index 545a57f61a5e..407c27c11b2b 100644 +--- a/include/linux/tee_drv.h ++++ b/include/linux/tee_drv.h +@@ -49,7 +49,6 @@ struct tee_shm_pool; + */ + struct tee_context { + struct tee_device *teedev; +- struct list_head list_shm; + void *data; + struct kref refcount; + bool releasing; +@@ -184,9 +183,7 @@ int tee_session_calc_client_uuid(uuid_t *uuid, u32 connection_method, + + /** + * struct tee_shm - shared memory object +- * @teedev: device used to allocate the object +- * @ctx: context using the object, if NULL the context is gone +- * @link link element ++ * @ctx: context using the object + * @paddr: physical address of the shared memory + * @kaddr: virtual address of the shared memory + * @size: size of shared memory +@@ -195,15 +192,17 @@ int tee_session_calc_client_uuid(uuid_t *uuid, u32 connection_method, + * @num_pages: number of locked pages + * @dmabuf: dmabuf used to for exporting to user space + * @flags: defined by TEE_SHM_* in tee_drv.h +- * @id: unique id of a shared memory object on this device ++ * @id: unique id of a shared memory object on this device, shared ++ * with user space ++ * @sec_world_id: ++ * secure world assigned id of this shared memory object, not ++ * used by all drivers + * + * This pool is only supposed to be accessed directly from the TEE + * subsystem and from drivers that implements their own shm pool manager. + */ + struct tee_shm { +- struct tee_device *teedev; + struct tee_context *ctx; +- struct list_head link; + phys_addr_t paddr; + void *kaddr; + size_t size; +@@ -213,6 +212,7 @@ struct tee_shm { + struct dma_buf *dmabuf; + u32 flags; + int id; ++ u64 sec_world_id; + }; + + /** +@@ -334,18 +334,6 @@ void *tee_get_drvdata(struct tee_device *teedev); + */ + struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags); + +-/** +- * tee_shm_priv_alloc() - Allocate shared memory privately +- * @dev: Device that allocates the shared memory +- * @size: Requested size of shared memory +- * +- * Allocates shared memory buffer that is not associated with any client +- * context. Such buffers are owned by TEE driver and used for internal calls. +- * +- * @returns a pointer to 'struct tee_shm' +- */ +-struct tee_shm *tee_shm_priv_alloc(struct tee_device *teedev, size_t size); +- + /** + * tee_shm_register() - Register shared memory buffer + * @ctx: Context that registers the shared memory +-- +2.26.2 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0013-tee-optee-fix-mem-handle-removal-in-ffa_shm_unregist.patch b/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0013-tee-optee-fix-mem-handle-removal-in-ffa_shm_unregist.patch new file mode 100644 index 00000000..ad2c9452 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0013-tee-optee-fix-mem-handle-removal-in-ffa_shm_unregist.patch @@ -0,0 +1,51 @@ +From 957e0145899813017a6a2b7f863a4a2b4e4b75aa Mon Sep 17 00:00:00 2001 +From: Arunachalam Ganapathy +Date: Tue, 5 Jan 2021 09:27:41 +0000 +Subject: [PATCH] tee: optee: fix mem handle removal in ffa_shm_unregister + +Remove ffa memory handle before calling mem_reclaim. This enables the +handle to be re-used by another thread once mem_claim for that handle +is completed. + +Signed-off-by: Arunachalam Ganapathy +Change-Id: I7294bd71f2bbc28514eaa09ae757dd216bc7df45 + +Upstream-Status: Pending [Not submitted to upstream yet] +--- + drivers/tee/optee/call.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/drivers/tee/optee/call.c b/drivers/tee/optee/call.c +index ac89ab42a43f..9c9480add0b5 100644 +--- a/drivers/tee/optee/call.c ++++ b/drivers/tee/optee/call.c +@@ -843,6 +843,10 @@ int optee_ffa_shm_unregister_supp(struct tee_context *ctx, + { + struct optee *optee = tee_get_drvdata(ctx->teedev); + int rc = 0; ++ u64 handle = shm->sec_world_id; ++ ++ optee_shm_rem_ffa_handle(optee, handle); ++ shm->sec_world_id = 0; + + /* + * We're skipping the OPTEE_FFA_YIELDING_CALL_UNREGISTER_SHM call +@@ -850,14 +854,10 @@ int optee_ffa_shm_unregister_supp(struct tee_context *ctx, + * this ID. + */ + +- rc = optee->ffa.ops->mem_reclaim(shm->sec_world_id, 0); ++ rc = optee->ffa.ops->mem_reclaim(handle, 0); + if (rc) + pr_err("mem_reclain: %d", rc); + +- optee_shm_rem_ffa_handle(optee, shm->sec_world_id); +- +- shm->sec_world_id = 0; +- + return rc; + } + #endif /*CONFIG_ARM_FFA_TRANSPORT*/ +-- +2.26.2 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0014-arm64-Add-support-for-asymmetric-AArch32-EL0-configu.patch b/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0014-arm64-Add-support-for-asymmetric-AArch32-EL0-configu.patch new file mode 100644 index 00000000..7ca9c078 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0014-arm64-Add-support-for-asymmetric-AArch32-EL0-configu.patch @@ -0,0 +1,462 @@ +Upstream-Status: Backport [http://www.linux-arm.org/git?p=linux-power.git;a=commit;h=ce7d6e205568b7949ff26f2b3c65dc4db1c15b96] +Signed-off-by: Usama Arif + +From 0316669bc2a0e1279427b7a3ed01313b70544756 Mon Sep 17 00:00:00 2001 +From: Catalin Marinas +Date: Thu, 20 Jun 2019 17:59:25 +0100 +Subject: [PATCH 1/2] arm64: Add support for asymmetric AArch32 EL0 + configurations + +There is a non-negligible chance that we may see asymmetric big.LITTLE +configurations where only the LITTLE CPUs have AArch32 support at EL0. +While Linux currently handles such configurations by not allowing +AArch32 tasks, there is a strong marketing push to investigate the +possibility of allowing compat applications. This patch is aimed to +facilitate internal testing and NOT FOR UPSTREAM. + +When the CONFIG_ASYMMETRIC_AARCH32 option is enabled (EXPERT), the type +of the ARM64_HAS_32BIT_EL0 capability becomes WEAK_LOCAL_CPU_FEATURE. +The kernel will now return true for system_supports_32bit_el0() and +32-bit tasks will be migrated to the capable CPUs during +do_notify_resume(). If the last CPU supporting 32-bit is offlined, the +kernel will SIGKILL any scheduled 32-bit tasks (the alternative is to +prevent offlining through a new .cpu_disable feature entry). + +In addition to the relaxation of the ARM64_HAS_32BIT_EL0 capability, +this patch factors out the 32-bit cpuinfo and features setting into +separate functions: __cpuinfo_store_cpu_32bit(), +init_cpu_32bit_features(). The cpuinfo of the booting CPU +(boot_cpu_data) is now updated on the first 32-bit capable CPU even if +it is a secondary one. The ID_AA64PFR0_EL0_64BIT_ONLY feature is relaxed +to FTR_NONSTRICT and FTR_HIGHER_SAFE when the asymmetric AArch32 support +is enabled. The compat_elf_hwcaps are only verified for the +AArch32-capable CPUs to still allow hotplugging AArch64-only CPUs. + +Cc: Suzuki K Poulose +Cc: Morten Rasmussen +Cc: Valentin Schneider +Cc: Qais Yousef +Signed-off-by: Catalin Marinas +Signed-off-by: Qais Yousef +--- + arch/arm64/Kconfig | 13 ++++++ + arch/arm64/include/asm/cpu.h | 2 + + arch/arm64/include/asm/cpufeature.h | 3 ++ + arch/arm64/include/asm/thread_info.h | 5 ++- + arch/arm64/kernel/cpufeature.c | 64 ++++++++++++++++++---------- + arch/arm64/kernel/cpuinfo.c | 61 +++++++++++++++++--------- + arch/arm64/kernel/process.c | 17 ++++++++ + arch/arm64/kernel/signal.c | 30 ++++++++++++- + 8 files changed, 150 insertions(+), 45 deletions(-) + +diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig +index 71d23b5d10d4..068e9e9ffc40 100644 +--- a/arch/arm64/Kconfig ++++ b/arch/arm64/Kconfig +@@ -1680,6 +1680,19 @@ config DMI + + endmenu + ++config ASYMMETRIC_AARCH32 ++ bool "Allow support for asymmetric AArch32 support" ++ depends on COMPAT && EXPERT && !KVM ++ help ++ Enable this option to allow support for asymmetric AArch32 EL0 ++ CPU configurations. Once the AArch32 EL0 support is detected ++ on a CPU, the feature is made available to user space to allow ++ the execution of 32-bit (compat) applications by migrating ++ them to the capable CPUs. Offlining such CPUs leads to 32-bit ++ applications being killed. ++ ++ If unsure say N. ++ + config SYSVIPC_COMPAT + def_bool y + depends on COMPAT && SYSVIPC +diff --git a/arch/arm64/include/asm/cpu.h b/arch/arm64/include/asm/cpu.h +index d72d995b7e25..39dbf5827070 100644 +--- a/arch/arm64/include/asm/cpu.h ++++ b/arch/arm64/include/asm/cpu.h +@@ -15,6 +15,7 @@ + struct cpuinfo_arm64 { + struct cpu cpu; + struct kobject kobj; ++ bool aarch32_valid; + u32 reg_ctr; + u32 reg_cntfrq; + u32 reg_dczid; +@@ -60,6 +61,7 @@ void cpuinfo_store_cpu(void); + void __init cpuinfo_store_boot_cpu(void); + + void __init init_cpu_features(struct cpuinfo_arm64 *info); ++void init_cpu_32bit_features(struct cpuinfo_arm64 *info); + void update_cpu_features(int cpu, struct cpuinfo_arm64 *info, + struct cpuinfo_arm64 *boot); + +diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h +index 9cde5d2e768f..d00d673d423b 100644 +--- a/arch/arm64/include/asm/cpufeature.h ++++ b/arch/arm64/include/asm/cpufeature.h +@@ -17,6 +17,7 @@ + #ifndef __ASSEMBLY__ + + #include ++#include + #include + #include + +@@ -370,6 +371,8 @@ cpucap_multi_entry_cap_matches(const struct arm64_cpu_capabilities *entry, + return false; + } + ++extern cpumask_t aarch32_el0_mask; ++ + extern DECLARE_BITMAP(cpu_hwcaps, ARM64_NCAPS); + extern struct static_key_false cpu_hwcap_keys[ARM64_NCAPS]; + extern struct static_key_false arm64_const_caps_ready; +diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h +index 8c73764b9ed2..54a4c912a7ab 100644 +--- a/arch/arm64/include/asm/thread_info.h ++++ b/arch/arm64/include/asm/thread_info.h +@@ -66,6 +66,7 @@ void arch_release_task_struct(struct task_struct *tsk); + #define TIF_FOREIGN_FPSTATE 3 /* CPU's FP state is not current's */ + #define TIF_UPROBE 4 /* uprobe breakpoint or singlestep */ + #define TIF_FSCHECK 5 /* Check FS is USER_DS on return */ ++#define TIF_SET_32BIT_AFFINITY 6 /* set thread affinity for asymmetric AArch32 */ + #define TIF_NOHZ 7 + #define TIF_SYSCALL_TRACE 8 /* syscall trace active */ + #define TIF_SYSCALL_AUDIT 9 /* syscall auditing */ +@@ -95,11 +96,13 @@ void arch_release_task_struct(struct task_struct *tsk); + #define _TIF_UPROBE (1 << TIF_UPROBE) + #define _TIF_FSCHECK (1 << TIF_FSCHECK) + #define _TIF_32BIT (1 << TIF_32BIT) ++#define _TIF_SET_32BIT_AFFINITY (1 << TIF_SET_32BIT_AFFINITY) + #define _TIF_SVE (1 << TIF_SVE) + + #define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \ + _TIF_NOTIFY_RESUME | _TIF_FOREIGN_FPSTATE | \ +- _TIF_UPROBE | _TIF_FSCHECK) ++ _TIF_UPROBE | _TIF_FSCHECK | \ ++ _TIF_SET_32BIT_AFFINITY) + + #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \ +diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c +index da92693b202c..c0d656cfe5b8 100644 +--- a/arch/arm64/kernel/cpufeature.c ++++ b/arch/arm64/kernel/cpufeature.c +@@ -8,7 +8,6 @@ + #define pr_fmt(fmt) "CPU features: " fmt + + #include +-#include + #include + #include + #include +@@ -164,7 +163,11 @@ static const struct arm64_ftr_bits ftr_id_aa64pfr0[] = { + ARM64_FTR_BITS(FTR_HIDDEN, FTR_NONSTRICT, FTR_LOWER_SAFE, ID_AA64PFR0_EL3_SHIFT, 4, 0), + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64PFR0_EL2_SHIFT, 4, 0), + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64PFR0_EL1_SHIFT, 4, ID_AA64PFR0_EL1_64BIT_ONLY), ++#ifndef CONFIG_ASYMMETRIC_AARCH32 + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64PFR0_EL0_SHIFT, 4, ID_AA64PFR0_EL0_64BIT_ONLY), ++#else ++ ARM64_FTR_BITS(FTR_HIDDEN, FTR_NONSTRICT, FTR_HIGHER_SAFE, ID_AA64PFR0_EL0_SHIFT, 4, ID_AA64PFR0_EL0_64BIT_ONLY), ++#endif + ARM64_FTR_END, + }; + +@@ -509,7 +512,7 @@ static void __init sort_ftr_regs(void) + * Any bits that are not covered by an arm64_ftr_bits entry are considered + * RES0 for the system-wide value, and must strictly match. + */ +-static void __init init_cpu_ftr_reg(u32 sys_reg, u64 new) ++static void init_cpu_ftr_reg(u32 sys_reg, u64 new) + { + u64 val = 0; + u64 strict_mask = ~0x0ULL; +@@ -590,25 +593,6 @@ void __init init_cpu_features(struct cpuinfo_arm64 *info) + init_cpu_ftr_reg(SYS_ID_AA64PFR1_EL1, info->reg_id_aa64pfr1); + init_cpu_ftr_reg(SYS_ID_AA64ZFR0_EL1, info->reg_id_aa64zfr0); + +- if (id_aa64pfr0_32bit_el0(info->reg_id_aa64pfr0)) { +- init_cpu_ftr_reg(SYS_ID_DFR0_EL1, info->reg_id_dfr0); +- init_cpu_ftr_reg(SYS_ID_ISAR0_EL1, info->reg_id_isar0); +- init_cpu_ftr_reg(SYS_ID_ISAR1_EL1, info->reg_id_isar1); +- init_cpu_ftr_reg(SYS_ID_ISAR2_EL1, info->reg_id_isar2); +- init_cpu_ftr_reg(SYS_ID_ISAR3_EL1, info->reg_id_isar3); +- init_cpu_ftr_reg(SYS_ID_ISAR4_EL1, info->reg_id_isar4); +- init_cpu_ftr_reg(SYS_ID_ISAR5_EL1, info->reg_id_isar5); +- init_cpu_ftr_reg(SYS_ID_MMFR0_EL1, info->reg_id_mmfr0); +- init_cpu_ftr_reg(SYS_ID_MMFR1_EL1, info->reg_id_mmfr1); +- init_cpu_ftr_reg(SYS_ID_MMFR2_EL1, info->reg_id_mmfr2); +- init_cpu_ftr_reg(SYS_ID_MMFR3_EL1, info->reg_id_mmfr3); +- init_cpu_ftr_reg(SYS_ID_PFR0_EL1, info->reg_id_pfr0); +- init_cpu_ftr_reg(SYS_ID_PFR1_EL1, info->reg_id_pfr1); +- init_cpu_ftr_reg(SYS_MVFR0_EL1, info->reg_mvfr0); +- init_cpu_ftr_reg(SYS_MVFR1_EL1, info->reg_mvfr1); +- init_cpu_ftr_reg(SYS_MVFR2_EL1, info->reg_mvfr2); +- } +- + if (id_aa64pfr0_sve(info->reg_id_aa64pfr0)) { + init_cpu_ftr_reg(SYS_ZCR_EL1, info->reg_zcr); + sve_init_vq_map(); +@@ -627,6 +611,26 @@ void __init init_cpu_features(struct cpuinfo_arm64 *info) + setup_boot_cpu_capabilities(); + } + ++void init_cpu_32bit_features(struct cpuinfo_arm64 *info) ++{ ++ init_cpu_ftr_reg(SYS_ID_DFR0_EL1, info->reg_id_dfr0); ++ init_cpu_ftr_reg(SYS_ID_ISAR0_EL1, info->reg_id_isar0); ++ init_cpu_ftr_reg(SYS_ID_ISAR1_EL1, info->reg_id_isar1); ++ init_cpu_ftr_reg(SYS_ID_ISAR2_EL1, info->reg_id_isar2); ++ init_cpu_ftr_reg(SYS_ID_ISAR3_EL1, info->reg_id_isar3); ++ init_cpu_ftr_reg(SYS_ID_ISAR4_EL1, info->reg_id_isar4); ++ init_cpu_ftr_reg(SYS_ID_ISAR5_EL1, info->reg_id_isar5); ++ init_cpu_ftr_reg(SYS_ID_MMFR0_EL1, info->reg_id_mmfr0); ++ init_cpu_ftr_reg(SYS_ID_MMFR1_EL1, info->reg_id_mmfr1); ++ init_cpu_ftr_reg(SYS_ID_MMFR2_EL1, info->reg_id_mmfr2); ++ init_cpu_ftr_reg(SYS_ID_MMFR3_EL1, info->reg_id_mmfr3); ++ init_cpu_ftr_reg(SYS_ID_PFR0_EL1, info->reg_id_pfr0); ++ init_cpu_ftr_reg(SYS_ID_PFR1_EL1, info->reg_id_pfr1); ++ init_cpu_ftr_reg(SYS_MVFR0_EL1, info->reg_mvfr0); ++ init_cpu_ftr_reg(SYS_MVFR1_EL1, info->reg_mvfr1); ++ init_cpu_ftr_reg(SYS_MVFR2_EL1, info->reg_mvfr2); ++} ++ + static void update_cpu_ftr_reg(struct arm64_ftr_reg *reg, u64 new) + { + const struct arm64_ftr_bits *ftrp; +@@ -1264,6 +1268,16 @@ static bool can_use_gic_priorities(const struct arm64_cpu_capabilities *entry, + } + #endif + ++#ifdef CONFIG_ASYMMETRIC_AARCH32 ++cpumask_t aarch32_el0_mask; ++ ++static void cpu_enable_aarch32_el0(struct arm64_cpu_capabilities const *cap) ++{ ++ if (has_cpuid_feature(cap, SCOPE_LOCAL_CPU)) ++ cpumask_set_cpu(smp_processor_id(), &aarch32_el0_mask); ++} ++#endif ++ + static const struct arm64_cpu_capabilities arm64_features[] = { + { + .desc = "GIC system register CPU interface", +@@ -1340,7 +1354,12 @@ static const struct arm64_cpu_capabilities arm64_features[] = { + { + .desc = "32-bit EL0 Support", + .capability = ARM64_HAS_32BIT_EL0, ++#ifndef CONFIG_ASYMMETRIC_AARCH32 + .type = ARM64_CPUCAP_SYSTEM_FEATURE, ++#else ++ .type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE, ++ .cpu_enable = cpu_enable_aarch32_el0, ++#endif + .matches = has_cpuid_feature, + .sys_reg = SYS_ID_AA64PFR0_EL1, + .sign = FTR_UNSIGNED, +@@ -1983,7 +2002,8 @@ static void verify_local_cpu_capabilities(void) + + verify_local_elf_hwcaps(arm64_elf_hwcaps); + +- if (system_supports_32bit_el0()) ++ if (system_supports_32bit_el0() && ++ this_cpu_has_cap(ARM64_HAS_32BIT_EL0)) + verify_local_elf_hwcaps(compat_elf_hwcaps); + + if (system_supports_sve()) +diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c +index 05933c065732..bda37687bb66 100644 +--- a/arch/arm64/kernel/cpuinfo.c ++++ b/arch/arm64/kernel/cpuinfo.c +@@ -351,27 +351,6 @@ static void __cpuinfo_store_cpu(struct cpuinfo_arm64 *info) + info->reg_id_aa64pfr1 = read_cpuid(ID_AA64PFR1_EL1); + info->reg_id_aa64zfr0 = read_cpuid(ID_AA64ZFR0_EL1); + +- /* Update the 32bit ID registers only if AArch32 is implemented */ +- if (id_aa64pfr0_32bit_el0(info->reg_id_aa64pfr0)) { +- info->reg_id_dfr0 = read_cpuid(ID_DFR0_EL1); +- info->reg_id_isar0 = read_cpuid(ID_ISAR0_EL1); +- info->reg_id_isar1 = read_cpuid(ID_ISAR1_EL1); +- info->reg_id_isar2 = read_cpuid(ID_ISAR2_EL1); +- info->reg_id_isar3 = read_cpuid(ID_ISAR3_EL1); +- info->reg_id_isar4 = read_cpuid(ID_ISAR4_EL1); +- info->reg_id_isar5 = read_cpuid(ID_ISAR5_EL1); +- info->reg_id_mmfr0 = read_cpuid(ID_MMFR0_EL1); +- info->reg_id_mmfr1 = read_cpuid(ID_MMFR1_EL1); +- info->reg_id_mmfr2 = read_cpuid(ID_MMFR2_EL1); +- info->reg_id_mmfr3 = read_cpuid(ID_MMFR3_EL1); +- info->reg_id_pfr0 = read_cpuid(ID_PFR0_EL1); +- info->reg_id_pfr1 = read_cpuid(ID_PFR1_EL1); +- +- info->reg_mvfr0 = read_cpuid(MVFR0_EL1); +- info->reg_mvfr1 = read_cpuid(MVFR1_EL1); +- info->reg_mvfr2 = read_cpuid(MVFR2_EL1); +- } +- + if (IS_ENABLED(CONFIG_ARM64_SVE) && + id_aa64pfr0_sve(info->reg_id_aa64pfr0)) + info->reg_zcr = read_zcr_features(); +@@ -379,10 +358,46 @@ static void __cpuinfo_store_cpu(struct cpuinfo_arm64 *info) + cpuinfo_detect_icache_policy(info); + } + ++static void __cpuinfo_store_cpu_32bit(struct cpuinfo_arm64 *info) ++{ ++ info->aarch32_valid = true; ++ ++ info->reg_id_dfr0 = read_cpuid(ID_DFR0_EL1); ++ info->reg_id_isar0 = read_cpuid(ID_ISAR0_EL1); ++ info->reg_id_isar1 = read_cpuid(ID_ISAR1_EL1); ++ info->reg_id_isar2 = read_cpuid(ID_ISAR2_EL1); ++ info->reg_id_isar3 = read_cpuid(ID_ISAR3_EL1); ++ info->reg_id_isar4 = read_cpuid(ID_ISAR4_EL1); ++ info->reg_id_isar5 = read_cpuid(ID_ISAR5_EL1); ++ info->reg_id_mmfr0 = read_cpuid(ID_MMFR0_EL1); ++ info->reg_id_mmfr1 = read_cpuid(ID_MMFR1_EL1); ++ info->reg_id_mmfr2 = read_cpuid(ID_MMFR2_EL1); ++ info->reg_id_mmfr3 = read_cpuid(ID_MMFR3_EL1); ++ info->reg_id_pfr0 = read_cpuid(ID_PFR0_EL1); ++ info->reg_id_pfr1 = read_cpuid(ID_PFR1_EL1); ++ ++ info->reg_mvfr0 = read_cpuid(MVFR0_EL1); ++ info->reg_mvfr1 = read_cpuid(MVFR1_EL1); ++ info->reg_mvfr2 = read_cpuid(MVFR2_EL1); ++} ++ + void cpuinfo_store_cpu(void) + { + struct cpuinfo_arm64 *info = this_cpu_ptr(&cpu_data); + __cpuinfo_store_cpu(info); ++ if (id_aa64pfr0_32bit_el0(info->reg_id_aa64pfr0)) ++ __cpuinfo_store_cpu_32bit(info); ++ /* ++ * With asymmetric AArch32 support, populate the boot CPU information ++ * on the first 32-bit capable secondary CPU if the primary one ++ * skipped this step. ++ */ ++ if (IS_ENABLED(CONFIG_ASYMMETRIC_AARCH32) && ++ !boot_cpu_data.aarch32_valid && ++ id_aa64pfr0_32bit_el0(info->reg_id_aa64pfr0)) { ++ __cpuinfo_store_cpu_32bit(&boot_cpu_data); ++ init_cpu_32bit_features(&boot_cpu_data); ++ } + update_cpu_features(smp_processor_id(), info, &boot_cpu_data); + } + +@@ -390,9 +405,13 @@ void __init cpuinfo_store_boot_cpu(void) + { + struct cpuinfo_arm64 *info = &per_cpu(cpu_data, 0); + __cpuinfo_store_cpu(info); ++ if (id_aa64pfr0_32bit_el0(info->reg_id_aa64pfr0)) ++ __cpuinfo_store_cpu_32bit(info); + + boot_cpu_data = *info; + init_cpu_features(&boot_cpu_data); ++ if (id_aa64pfr0_32bit_el0(boot_cpu_data.reg_id_aa64pfr0)) ++ init_cpu_32bit_features(&boot_cpu_data); + } + + device_initcall(cpuinfo_regs_init); +diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c +index cc1d8b1025b1..35f0c93699ce 100644 +--- a/arch/arm64/kernel/process.c ++++ b/arch/arm64/kernel/process.c +@@ -494,6 +494,15 @@ static void entry_task_switch(struct task_struct *next) + __this_cpu_write(__entry_task, next); + } + ++static void aarch32_thread_switch(struct task_struct *next) ++{ ++ struct thread_info *ti = task_thread_info(next); ++ ++ if (IS_ENABLED(CONFIG_ASYMMETRIC_AARCH32) && is_compat_thread(ti) && ++ !cpumask_test_cpu(smp_processor_id(), &aarch32_el0_mask)) ++ set_ti_thread_flag(ti, TIF_SET_32BIT_AFFINITY); ++} ++ + /* + * Thread switching. + */ +@@ -511,6 +520,7 @@ __notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev, + ptrauth_thread_switch(next); + ssbs_thread_switch(next); + scs_overflow_check(next); ++ aarch32_thread_switch(next); + + /* + * Complete any pending TLB or cache maintenance on this CPU in case +@@ -569,6 +579,13 @@ void arch_setup_new_exec(void) + current->mm->context.flags = is_compat_task() ? MMCF_AARCH32 : 0; + + ptrauth_thread_init_user(current); ++ ++ /* ++ * If exec'ing a 32-bit task, force the asymmetric 32-bit feature ++ * check as the task may not go through a switch_to() call. ++ */ ++ if (IS_ENABLED(CONFIG_ASYMMETRIC_AARCH32) && is_compat_task()) ++ set_thread_flag(TIF_SET_32BIT_AFFINITY); + } + + #ifdef CONFIG_ARM64_TAGGED_ADDR_ABI +diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c +index dd2cdc0d5be2..d8cdd3211d68 100644 +--- a/arch/arm64/kernel/signal.c ++++ b/arch/arm64/kernel/signal.c +@@ -8,6 +8,7 @@ + + #include + #include ++#include + #include + #include + #include +@@ -896,6 +897,29 @@ static void do_signal(struct pt_regs *regs) + restore_saved_sigmask(); + } + ++static void set_32bit_cpus_allowed(void) ++{ ++ int ret; ++ ++ /* ++ * Try to honour as best as possible whatever affinity request this ++ * task has. If it spans no compatible CPU, disregard it entirely. ++ */ ++ if (cpumask_intersects(current->cpus_ptr, &aarch32_el0_mask)) { ++ cpumask_t cpus_allowed; ++ ++ cpumask_and(&cpus_allowed, current->cpus_ptr, &aarch32_el0_mask); ++ ret = set_cpus_allowed_ptr(current, &cpus_allowed); ++ } else { ++ ret = set_cpus_allowed_ptr(current, &aarch32_el0_mask); ++ } ++ ++ if (ret) { ++ pr_warn_once("No CPUs capable of running 32-bit tasks\n"); ++ force_sig(SIGKILL); ++ } ++} ++ + asmlinkage void do_notify_resume(struct pt_regs *regs, + unsigned long thread_flags) + { +@@ -910,7 +934,11 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, + /* Check valid user FS if needed */ + addr_limit_user_check(); + +- if (thread_flags & _TIF_NEED_RESCHED) { ++ if (IS_ENABLED(CONFIG_ASYMMETRIC_AARCH32) && ++ thread_flags & _TIF_SET_32BIT_AFFINITY) { ++ clear_thread_flag(TIF_SET_32BIT_AFFINITY); ++ set_32bit_cpus_allowed(); ++ } else if (thread_flags & _TIF_NEED_RESCHED) { + /* Unmask Debug and SError for the next task */ + local_daif_restore(DAIF_PROCCTX_NOIRQ); + +-- +2.29.2 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0015-arm64-smp-Prevent-hotplugging-the-last-AArch32-able-.patch b/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0015-arm64-smp-Prevent-hotplugging-the-last-AArch32-able-.patch new file mode 100644 index 00000000..774721e0 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0015-arm64-smp-Prevent-hotplugging-the-last-AArch32-able-.patch @@ -0,0 +1,89 @@ +Upstream-Status: Backport [http://www.linux-arm.org/git?p=linux-power.git;a=commit;h=e6b567c1cc07dd1690e5d34b6a93ab9819ab2eeb] +Signed-off-by: Usama Arif + +From d6acb605de7d40c295ada9b1f4c8336e4db71ae4 Mon Sep 17 00:00:00 2001 +From: Valentin Schneider +Date: Thu, 5 Sep 2019 17:53:19 +0100 +Subject: [PATCH 2/2] arm64: smp: Prevent hotplugging the last AArch32-able CPU + +EL0 AArch32 tasks are now sigkilled when they can't run on any +compatible CPU, either because there aren't any left (hotplug) or +because they aren't allowed to run on those left (task affinity). + +However, it has been deemed valuable to prevent the loss of +functionality resulting in offlining the last AArch32-compatible CPU. + +Add arch-specific hook in _cpu_down() that allows checking whether we +can offline a cpu or not and use that hook to veto offlining the last +AArch32 CPU. + +Signed-off-by: Valentin Schneider +Signed-off-by: Qais Yousef +--- + arch/arm64/kernel/smp.c | 22 ++++++++++++++++++++++ + kernel/cpu.c | 9 +++++++++ + 2 files changed, 31 insertions(+) + +diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c +index 038ce6263d1c..c8ab4ee29f32 100644 +--- a/arch/arm64/kernel/smp.c ++++ b/arch/arm64/kernel/smp.c +@@ -85,6 +85,28 @@ static inline int op_cpu_kill(unsigned int cpu) + } + #endif + ++bool arch_allows_cpu_disable(int cpu, int tasks_frozen, ++ enum cpuhp_state target) ++{ ++ /* ++ * Don't let the last AArch32-compatible CPU go down unless the request ++ * is related to suspend (!tasks_frozen) then allow it to be offlined ++ * or we'll break suspend-to-ram functionality. ++ */ ++ if (IS_ENABLED(CONFIG_ASYMMETRIC_AARCH32) && ++ !cpumask_empty(&aarch32_el0_mask) && ++ !tasks_frozen) { ++ cpumask_t online; ++ ++ cpumask_and(&online, &aarch32_el0_mask, cpu_online_mask); ++ ++ if (cpumask_weight(&online) == 1) ++ return false; ++ } ++ ++ return true; ++} ++ + + /* + * Boot a secondary CPU, and assign it the specified idle task. +diff --git a/kernel/cpu.c b/kernel/cpu.c +index 261b5098f81c..4fae9b61f442 100644 +--- a/kernel/cpu.c ++++ b/kernel/cpu.c +@@ -134,6 +134,12 @@ static struct cpuhp_step *cpuhp_get_step(enum cpuhp_state state) + return cpuhp_hp_states + state; + } + ++bool __weak arch_allows_cpu_disable(int cpu, int tasks_frozen, ++ enum cpuhp_state target) ++{ ++ return true; ++} ++ + /** + * cpuhp_invoke_callback _ Invoke the callbacks for a given state + * @cpu: The cpu for which the callback should be invoked +@@ -985,6 +991,9 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen, + if (!cpu_present(cpu)) + return -EINVAL; + ++ if (!arch_allows_cpu_disable(cpu, tasks_frozen, target)) ++ return -EBUSY; ++ + cpus_write_lock(); + + cpuhp_tasks_frozen = tasks_frozen; +-- +2.29.2 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0016-drivers-buf-Add-userspace-ff-a-driver-buf-and-add-to.patch b/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0016-drivers-buf-Add-userspace-ff-a-driver-buf-and-add-to.patch new file mode 100644 index 00000000..f6768cbb --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0016-drivers-buf-Add-userspace-ff-a-driver-buf-and-add-to.patch @@ -0,0 +1,357 @@ +From 1d85316ed0571300c12216c9cafb634db6fe4a8a Mon Sep 17 00:00:00 2001 +From: Ben Horgan +Date: Tue, 16 Mar 2021 16:08:54 +0000 +Subject: [PATCH 1/2] drivers: buf: Add userspace ff-a driver (buf) and add to + build + +This is an earlier revision of: +https://gitlab.arm.com/linux-arm/linux-trusted-services/ + +Change-Id: Iffa92583826285d616aef8d32f3a3326ec4f1f96 +Signed-off-by: Balint Dobszay +Signed-off-by: Ben Horgan +Upstream-Status: Backport [https://git.gitlab.arm.com/linux-arm/linux-trusted-services/-/commit/4696c6f92e991072052d7ef8297db6fa4695994a] +--- + drivers/Makefile | 3 + + drivers/buf/Makefile | 3 + + drivers/buf/buf_common.h | 45 +++++++ + drivers/buf/buf_driver.c | 254 +++++++++++++++++++++++++++++++++++++++ + 4 files changed, 305 insertions(+) + create mode 100644 drivers/buf/Makefile + create mode 100644 drivers/buf/buf_common.h + create mode 100644 drivers/buf/buf_driver.c + +diff --git a/drivers/Makefile b/drivers/Makefile +index aaef17cc6512..67cb5965ab94 100644 +--- a/drivers/Makefile ++++ b/drivers/Makefile +@@ -186,3 +186,6 @@ obj-$(CONFIG_SIOX) += siox/ + obj-$(CONFIG_GNSS) += gnss/ + obj-$(CONFIG_INTERCONNECT) += interconnect/ + obj-$(CONFIG_COUNTER) += counter/ ++ ++# FF-A debugfs userspace driver ++obj-y += buf/ +diff --git a/drivers/buf/Makefile b/drivers/buf/Makefile +new file mode 100644 +index 000000000000..d42b20734770 +--- /dev/null ++++ b/drivers/buf/Makefile +@@ -0,0 +1,3 @@ ++# SPDX-License-Identifier: GPL-2.0-only ++ ++obj-y := buf_driver.o +diff --git a/drivers/buf/buf_common.h b/drivers/buf/buf_common.h +new file mode 100644 +index 000000000000..397b234bad30 +--- /dev/null ++++ b/drivers/buf/buf_common.h +@@ -0,0 +1,45 @@ ++/* SPDX-License-Identifier: GPL-2.0-only */ ++/* ++ * Copyright (c) 2020-2021, Arm Limited ++ */ ++ ++#ifndef __BUF_COMMON_H ++#define __BUF_COMMON_H ++ ++#ifdef __KERNEL__ ++#include ++#include ++#else ++#include ++#include ++#endif ++ ++struct buf_descr { ++ uint8_t *buf; ++ size_t length; ++}; ++ ++struct msg_args { ++ uint16_t dst_id; ++ uint32_t args[5]; ++}; ++ ++struct endpoint_id { ++ uint32_t uuid_0; ++ uint32_t uuid_1; ++ uint32_t uuid_2; ++ uint32_t uuid_3; ++ uint16_t id; ++}; ++ ++#define IOCTL_TYPE 0xf0 ++ ++#define GET_PART_ID _IOWR(IOCTL_TYPE, 0x00, struct endpoint_id) ++#define SEND_SYNC_MSG _IOWR(IOCTL_TYPE, 0x01, struct msg_args) ++ ++#define SHARE_INIT _IOR(IOCTL_TYPE, 0x10, unsigned long) ++#define SHARE_DEINIT _IO(IOCTL_TYPE, 0x11) ++#define SHARE_READ _IOW(IOCTL_TYPE, 0x12, struct buf_descr) ++#define SHARE_WRITE _IOW(IOCTL_TYPE, 0x13, struct buf_descr) ++ ++#endif /* __BUF_COMMON_H */ +diff --git a/drivers/buf/buf_driver.c b/drivers/buf/buf_driver.c +new file mode 100644 +index 000000000000..2403709c3757 +--- /dev/null ++++ b/drivers/buf/buf_driver.c +@@ -0,0 +1,254 @@ ++// SPDX-License-Identifier: GPL-2.0-only ++/* ++ * Thin layer to expose FF-A operations towards user space ++ * ++ * The FF-A driver operations are currently not accessible from user space. This ++ * module creates a debugfs interface to expose them. This is only a temporary ++ * workaround, not intended to be merged. ++ * ++ * Copyright (c) 2020-2021, Arm Limited ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "buf_common.h" ++ ++static struct dentry *debugfs_file = NULL; ++static struct ffa_ops *ops = NULL; ++static const ffa_sp_id_t spm_id = 0x8001; ++ ++static void *mem_region = NULL; ++static size_t mem_size = 4096; ++struct page **pages; ++static struct sg_table sgt; ++static ffa_mem_handle_t handle; ++static struct endpoint_id sp_id; ++static struct ffa_mem_region_attributes attrs[1] = { 0 }; ++ ++static int get_part_id(struct endpoint_id *sp_id) ++{ ++ int n; ++ struct ffa_partition_info *sp_infos = NULL; ++ ++ n = ops->partition_info_get(sp_id->uuid_0, sp_id->uuid_1, sp_id->uuid_2, ++ sp_id->uuid_3, &sp_infos); ++ ++ if (n >= 1) { ++ if (n > 1) { ++ pr_warn("Multiple SP with same UUID"); ++ } ++ sp_id->id = sp_infos->id; ++ kfree(sp_infos); ++ return 0; ++ } ++ else { ++ pr_err("Partition info get failed"); ++ return -1; ++ } ++} ++ ++static int send_sync_msg(struct msg_args *args) ++{ ++ struct arm_smcccv1_2_return resp; ++ ++ resp = ops->sync_msg_send(args->dst_id, args->args[0], args->args[1], ++ args->args[2], args->args[3], args->args[4]); ++ ++ if (resp.arg0) { ++ pr_err("FFA response: 0x%llx", resp.arg0); ++ return -1; ++ } ++ ++ /* TODO: sort out argument widths */ ++ args->args[0] = (uint32_t)resp.arg3; ++ args->args[1] = (uint32_t)resp.arg4; ++ args->args[2] = (uint32_t)resp.arg5; ++ args->args[3] = (uint32_t)resp.arg6; ++ args->args[4] = (uint32_t)resp.arg7; ++ ++ return 0; ++} ++ ++static int init_share(void) ++{ ++ int ret; ++ ++ mem_region = kzalloc(mem_size, GFP_KERNEL); ++ if (IS_ERR_OR_NULL(mem_region)) { ++ pr_err("Out of memory"); ++ return -ENOMEM; ++ } ++ ++ pages = kzalloc(1 * sizeof(void *), GFP_KERNEL); ++ if (IS_ERR_OR_NULL(pages)) { ++ kfree(mem_region); ++ pr_err("Out of memory"); ++ return -ENOMEM; ++ } ++ ++ pages[0] = virt_to_page(mem_region); ++ ++ sg_alloc_table_from_pages(&sgt, pages, 1, 0, 4096, GFP_KERNEL); ++ ++ attrs[0].receiver = sp_id.id; ++ attrs[0].attrs = FFA_MEM_RW; ++ ++ ret = ops->mem_share(0, 0, attrs, 1, sgt.sgl, sgt.nents, &handle, true); ++ if (ret) { ++ pr_err("Mem share failed"); ++ return ret; ++ } ++ ++ return 0; ++} ++ ++static int close_share(void) ++{ ++ int ret; ++ ++ ret = ops->mem_reclaim(handle, FFA_KEEP_MEMORY); ++ if (ret) { ++ pr_err("Mem reclaim failed"); ++ } ++ ++ kfree(mem_region); ++ ++ return ret; ++} ++ ++static int read_buf(struct buf_descr descr) ++{ ++ if (descr.length > 4096) { ++ return -ENOMEM; ++ } ++ ++ if(copy_to_user(descr.buf, mem_region, descr.length)) { ++ pr_err("Copy to user failed"); ++ return -1; ++ } ++ ++ return 0; ++} ++ ++static int write_buf(struct buf_descr descr) ++{ ++ if (descr.length > 4096) { ++ return -ENOMEM; ++ } ++ ++ if(copy_from_user(mem_region, descr.buf, descr.length)) { ++ pr_err("Copy from user failed"); ++ return -1; ++ } ++ ++ return 0; ++} ++ ++static long ioctl(struct file *fp, unsigned int cmd, unsigned long arg) ++{ ++ int ret = 0; ++ void __user *uarg = (void __user *)arg; ++ struct buf_descr descr; ++ struct msg_args args; ++ ++ switch (cmd) { ++ case GET_PART_ID: ++ if(copy_from_user(&sp_id, uarg, sizeof(struct endpoint_id))) { ++ pr_err("Copy from user failed"); ++ return -1; ++ } ++ ret = get_part_id(&sp_id); ++ if(copy_to_user(uarg, &sp_id, sizeof(struct endpoint_id))) { ++ pr_err("Copy to user failed"); ++ return -1; ++ } ++ break; ++ case SEND_SYNC_MSG: ++ if(copy_from_user(&args, uarg, sizeof(struct msg_args))) { ++ pr_err("Copy from user failed"); ++ return -1; ++ } ++ ret = send_sync_msg(&args); ++ if(copy_to_user(uarg, &args, sizeof(struct msg_args))) { ++ pr_err("Copy to user failed"); ++ return -1; ++ } ++ break; ++ case SHARE_INIT: ++ ret = init_share(); ++ if(copy_to_user(uarg, &handle, sizeof(unsigned long))) { ++ pr_err("Copy to user failed"); ++ return -1; ++ } ++ break; ++ case SHARE_DEINIT: ++ ret = close_share(); ++ break; ++ case SHARE_READ: ++ if(copy_from_user(&descr, uarg, sizeof(struct buf_descr))) { ++ pr_err("Copy from user failed"); ++ return -1; ++ } ++ ret = read_buf(descr); ++ break; ++ case SHARE_WRITE: ++ if(copy_from_user(&descr, uarg, sizeof(struct buf_descr))) { ++ pr_err("Copy from user failed"); ++ return -1; ++ } ++ ret = write_buf(descr); ++ break; ++ default: ++ pr_warn("Unknown command: %d", cmd); ++ ret = -EINVAL; ++ break; ++ } ++ ++ return ret; ++} ++ ++static const struct file_operations fops = { ++ .unlocked_ioctl = ioctl, ++}; ++ ++static int mod_init(void) ++{ ++ ops = get_ffa_ops(); ++ ++ if (IS_ERR_OR_NULL(ops)) { ++ pr_err("Cannot get FFA ops"); ++ return -1; ++ } ++ ++ debugfs_file = debugfs_create_file("buf", S_IRUSR | S_IWUSR, NULL, NULL, &fops); ++ ++ if (IS_ERR_OR_NULL(debugfs_file)) { ++ pr_err("Cannot create debugfs file"); ++ return -1; ++ } ++ ++ return 0; ++} ++ ++static void mod_exit(void) ++{ ++ debugfs_remove_recursive(debugfs_file); ++} ++ ++module_init(mod_init) ++module_exit(mod_exit) ++MODULE_LICENSE("GPL"); +-- +2.29.2 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0017-drivers-ffa-modify-FFA-ABIs-with-supported-conventio.patch b/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0017-drivers-ffa-modify-FFA-ABIs-with-supported-conventio.patch new file mode 100644 index 00000000..91a3dc47 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/0017-drivers-ffa-modify-FFA-ABIs-with-supported-conventio.patch @@ -0,0 +1,87 @@ +From e4bc772637c8aaf4dc6fa64c6d3e3df237ee5e3d Mon Sep 17 00:00:00 2001 +From: Arunachalam Ganapathy +Date: Mon, 12 Apr 2021 10:44:13 +0100 +Subject: [PATCH 2/2] drivers/ffa: modify FFA ABIs with supported convention + +SPMC (hafnium) only supports 64-bit variant of FFA_RXTX_MAP and +32-bit variant of FFA_MEM_SHARE. + +Signed-off-by: Arunachalam Ganapathy +Change-Id: I2fbddb7b9bf061b529d4e1f2e93172b1aab73492 +Upstream-Status: Inappropriate [will not be submitted as its only required for ACK 5.4] +--- + drivers/firmware/ffa/arm_ffa.c | 8 ++++---- + include/linux/arm_ffa.h | 4 +++- + 2 files changed, 7 insertions(+), 5 deletions(-) + +diff --git a/drivers/firmware/ffa/arm_ffa.c b/drivers/firmware/ffa/arm_ffa.c +index 21838f8c4632..0524deac1ce7 100644 +--- a/drivers/firmware/ffa/arm_ffa.c ++++ b/drivers/firmware/ffa/arm_ffa.c +@@ -7,7 +7,7 @@ + * residing on other Secure Partitions or Virtual Machines managed by any FFA + * compliant firmware framework. + * +- * Copyright (C) 2019, 2020 Arm Ltd. ++ * Copyright (C) 2019 - 2021 Arm Ltd. + */ + #define DEBUG + +@@ -171,7 +171,7 @@ static int ffa_share_init_frag(phys_addr_t buffer, u32 buffer_size, + struct arm_smcccv1_2_return smccc_return; + + smccc_return = +- arm_ffa_smccc(FFA_MEM_SHARE_64, total_len, fragment_len, buffer, ++ arm_ffa_smccc(FFA_MEM_SHARE_32, total_len, fragment_len, buffer, + buffer_size, 0, 0, 0); + + while (smccc_return.arg0 != FFA_SUCCESS_32) { +@@ -649,7 +649,7 @@ static int ffa_rxtx_map(uintptr_t tx_page, uintptr_t rx_page) + { + struct arm_smcccv1_2_return map_return; + +- map_return = arm_ffa_smccc(FFA_RXTX_MAP_32, tx_page, ++ map_return = arm_ffa_smccc(FFA_RXTX_MAP_64, tx_page, + rx_page, 1, 0, 0, 0, 0); + + if (map_return.arg0 == FFA_ERROR_32) { +@@ -716,7 +716,7 @@ static int ffa_probe(struct platform_device *pdev) + /* Initialize VM ID. */ + ret = ffa_id_get(&vm_id); + if (ret) { +- pr_warn("%s: failed to obtain own FFA endpoint ID\n", __func__); ++ pr_err("%s: failed to obtain own FFA endpoint ID\n", __func__); + return ret; + } + +diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h +index d3c80b7f9e07..9a8b32e2c846 100644 +--- a/include/linux/arm_ffa.h ++++ b/include/linux/arm_ffa.h +@@ -1,6 +1,6 @@ + /* SPDX-License-Identifier: GPL-2.0 */ + /* +- * Copyright (C) 2019, 2020 Arm Ltd. ++ * Copyright (C) 2019 - 2021 Arm Ltd. + */ + + #ifndef __LINUX_ARM_FFA_H +@@ -13,6 +13,7 @@ + #define FFA_FEATURES_32 0x84000064 + #define FFA_RX_RELEASE_32 0x84000065 + #define FFA_RXTX_MAP_32 0x84000066 ++#define FFA_RXTX_MAP_64 0xc4000066 + + #define FFA_PARTITION_INFO_GET_32 0x84000068 + #define FFA_ID_GET_32 0x84000069 +@@ -25,6 +26,7 @@ + #define FFA_MEM_OP_PAUSE_32 0x84000078 + #define FFA_MEM_OP_RESUME_32 0x84000079 + ++#define FFA_MEM_SHARE_32 0x84000073 + #define FFA_MEM_SHARE_64 0xC4000073 + + #define FFA_MEM_FRAG_RX_32 0x8400007A +-- +2.29.2 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/defconfig b/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/defconfig index f858f516..c8caa05a 100644 --- a/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/defconfig +++ b/meta-arm-bsp/recipes-kernel/linux/linux-arm64-ack-5.4/tc0/defconfig @@ -2,6 +2,7 @@ CONFIG_POSIX_MQUEUE=y CONFIG_AUDIT=y CONFIG_NO_HZ=y CONFIG_HIGH_RES_TIMERS=y +CONFIG_ASYMMETRIC_AARCH32=y CONFIG_PREEMPT=y CONFIG_IRQ_TIME_ACCOUNTING=y CONFIG_BSD_PROCESS_ACCT=y @@ -102,6 +103,7 @@ CONFIG_ARM_SCMI_CPUFREQ=y CONFIG_ARM_TEGRA186_CPUFREQ=y CONFIG_ARM_SCMI_PROTOCOL=y CONFIG_ARM_SCPI_PROTOCOL=y +CONFIG_ARM_FFA_TRANSPORT=y CONFIG_RASPBERRYPI_FIRMWARE=y CONFIG_INTEL_STRATIX10_SERVICE=y CONFIG_INTEL_STRATIX10_RSU=m @@ -115,7 +117,6 @@ CONFIG_ACPI_APEI_PCIEAER=y CONFIG_ACPI_APEI_MEMORY_FAILURE=y CONFIG_ACPI_APEI_EINJ=y CONFIG_VIRTUALIZATION=y -CONFIG_KVM=y CONFIG_ARM64_CRYPTO=y CONFIG_CRYPTO_SHA1_ARM64_CE=y CONFIG_CRYPTO_SHA2_ARM64_CE=y diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-5.4/perf-fixup-gcc10-01.patch b/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-5.4/perf-fixup-gcc10-01.patch new file mode 100644 index 00000000..efca58f6 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-5.4/perf-fixup-gcc10-01.patch @@ -0,0 +1,76 @@ +perf cs-etm: Move definition of 'traceid_list' global variable from header file +Upstream-Status: Backport https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/patch/tools/perf/util?id=bc79abf4afea97d5ce682aa2bd1095fb74400916 +Signed-off-by: Khasim Syed Mohammed + +From bc79abf4afea97d5ce682aa2bd1095fb74400916 Mon Sep 17 00:00:00 2001 +From: Leo Yan +Date: Tue, 5 May 2020 21:36:42 +0800 +Subject: perf cs-etm: Move definition of 'traceid_list' global variable from + header file + +commit 168200b6d6ea0cb5765943ec5da5b8149701f36a upstream. + +The variable 'traceid_list' is defined in the header file cs-etm.h, +if multiple C files include cs-etm.h the compiler might complaint for +multiple definition of 'traceid_list'. + +To fix multiple definition error, move the definition of 'traceid_list' +into cs-etm.c. + +Fixes: cd8bfd8c973e ("perf tools: Add processing of coresight metadata") +Reported-by: Thomas Backlund +Signed-off-by: Leo Yan +Reviewed-by: Mathieu Poirier +Reviewed-by: Mike Leach +Tested-by: Mike Leach +Tested-by: Thomas Backlund +Cc: Alexander Shishkin +Cc: Jiri Olsa +Cc: Mark Rutland +Cc: Namhyung Kim +Cc: Peter Zijlstra +Cc: Suzuki Poulouse +Cc: Tor Jeremiassen +Cc: linux-arm-kernel@lists.infradead.org +Link: http://lore.kernel.org/lkml/20200505133642.4756-1-leo.yan@linaro.org +Signed-off-by: Arnaldo Carvalho de Melo +Cc: Paul Barker +Signed-off-by: Greg Kroah-Hartman +--- + tools/perf/util/cs-etm.c | 3 +++ + tools/perf/util/cs-etm.h | 3 --- + 2 files changed, 3 insertions(+), 3 deletions(-) + +(limited to 'tools/perf/util') + +diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c +index 451eee24165ee..f5a9cb4088080 100644 +--- a/tools/perf/util/cs-etm.c ++++ b/tools/perf/util/cs-etm.c +@@ -94,6 +94,9 @@ struct cs_etm_queue { + struct cs_etm_traceid_queue **traceid_queues; + }; + ++/* RB tree for quick conversion between traceID and metadata pointers */ ++static struct intlist *traceid_list; ++ + static int cs_etm__update_queues(struct cs_etm_auxtrace *etm); + static int cs_etm__process_queues(struct cs_etm_auxtrace *etm); + static int cs_etm__process_timeless_queues(struct cs_etm_auxtrace *etm, +diff --git a/tools/perf/util/cs-etm.h b/tools/perf/util/cs-etm.h +index 650ecc2a63492..4ad925d6d7996 100644 +--- a/tools/perf/util/cs-etm.h ++++ b/tools/perf/util/cs-etm.h +@@ -114,9 +114,6 @@ enum cs_etm_isa { + CS_ETM_ISA_T32, + }; + +-/* RB tree for quick conversion between traceID and metadata pointers */ +-struct intlist *traceid_list; +- + struct cs_etm_queue; + + struct cs_etm_packet { +-- +cgit 1.2.3-1.el7 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-5.4/perf-fixup-gcc10-02.patch b/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-5.4/perf-fixup-gcc10-02.patch new file mode 100644 index 00000000..b512d3e1 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-5.4/perf-fixup-gcc10-02.patch @@ -0,0 +1,50 @@ +perf tests bp_account: Make global variable static +Upstream-Status: Backport https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/patch/tools/perf/tests/bp_account.c?id=73d2d6b421dfdc66b4615452a94efcece27a3c21 +Signed-off-by: Khasim Syed Mohammed + +From 73d2d6b421dfdc66b4615452a94efcece27a3c21 Mon Sep 17 00:00:00 2001 +From: Arnaldo Carvalho de Melo +Date: Mon, 2 Mar 2020 11:13:19 -0300 +Subject: perf tests bp_account: Make global variable static + +commit cff20b3151ccab690715cb6cf0f5da5cccb32adf upstream. + +To fix the build with newer gccs, that without this patch exit with: + + LD /tmp/build/perf/tests/perf-in.o + ld: /tmp/build/perf/tests/bp_account.o:/git/perf/tools/perf/tests/bp_account.c:22: multiple definition of `the_var'; /tmp/build/perf/tests/bp_signal.o:/git/perf/tools/perf/tests/bp_signal.c:38: first defined here + make[4]: *** [/git/perf/tools/build/Makefile.build:145: /tmp/build/perf/tests/perf-in.o] Error 1 + +First noticed in fedora:rawhide/32 with: + + [perfbuilder@a5ff49d6e6e4 ~]$ gcc --version + gcc (GCC) 10.0.1 20200216 (Red Hat 10.0.1-0.8) + +Reported-by: Jiri Olsa +Cc: Adrian Hunter +Cc: Namhyung Kim +Signed-off-by: Arnaldo Carvalho de Melo +Cc: Ben Hutchings +Signed-off-by: Greg Kroah-Hartman +--- + tools/perf/tests/bp_account.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +(limited to 'tools/perf/tests/bp_account.c') + +diff --git a/tools/perf/tests/bp_account.c b/tools/perf/tests/bp_account.c +index 016bba2c142db..55a9de311d7b0 100644 +--- a/tools/perf/tests/bp_account.c ++++ b/tools/perf/tests/bp_account.c +@@ -23,7 +23,7 @@ + #include "../perf-sys.h" + #include "cloexec.h" + +-volatile long the_var; ++static volatile long the_var; + + static noinline int test_function(void) + { +-- +cgit 1.2.3-1.el7 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-5.4/perf-fixup-gcc10-03.patch b/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-5.4/perf-fixup-gcc10-03.patch new file mode 100644 index 00000000..8b8a2996 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-5.4/perf-fixup-gcc10-03.patch @@ -0,0 +1,246 @@ +perf bench: Share some global variables to fix build with gcc 10 +Upstream-Status: Backport https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/tools/perf/bench?h=linux-5.4.y&id=df35e878d0a51755fb500e2e8e29c7ebb0239756 +Signed-off-by: Khasim Syed Mohammed + +From df35e878d0a51755fb500e2e8e29c7ebb0239756 Mon Sep 17 00:00:00 2001 +From: Arnaldo Carvalho de Melo +Date: Mon, 2 Mar 2020 12:09:38 -0300 +Subject: perf bench: Share some global variables to fix build with gcc 10 + +commit e4d9b04b973b2dbce7b42af95ea70d07da1c936d upstream. + +Noticed with gcc 10 (fedora rawhide) that those variables were not being +declared as static, so end up with: + + ld: /tmp/build/perf/bench/epoll-wait.o:/git/perf/tools/perf/bench/epoll-wait.c:93: multiple definition of `end'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here + ld: /tmp/build/perf/bench/epoll-wait.o:/git/perf/tools/perf/bench/epoll-wait.c:93: multiple definition of `start'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here + ld: /tmp/build/perf/bench/epoll-wait.o:/git/perf/tools/perf/bench/epoll-wait.c:93: multiple definition of `runtime'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here + ld: /tmp/build/perf/bench/epoll-ctl.o:/git/perf/tools/perf/bench/epoll-ctl.c:38: multiple definition of `end'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here + ld: /tmp/build/perf/bench/epoll-ctl.o:/git/perf/tools/perf/bench/epoll-ctl.c:38: multiple definition of `start'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here + ld: /tmp/build/perf/bench/epoll-ctl.o:/git/perf/tools/perf/bench/epoll-ctl.c:38: multiple definition of `runtime'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here + make[4]: *** [/git/perf/tools/build/Makefile.build:145: /tmp/build/perf/bench/perf-in.o] Error 1 + +Prefix those with bench__ and add them to bench/bench.h, so that we can +share those on the tools needing to access those variables from signal +handlers. + +Acked-by: Thomas Gleixner +Cc: Adrian Hunter +Cc: Davidlohr Bueso +Cc: Jiri Olsa +Cc: Namhyung Kim +Link: http://lore.kernel.org/lkml/20200303155811.GD13702@kernel.org +Signed-off-by: Arnaldo Carvalho de Melo +Cc: Ben Hutchings +Signed-off-by: Greg Kroah-Hartman +--- + tools/perf/bench/bench.h | 4 ++++ + tools/perf/bench/epoll-ctl.c | 7 +++---- + tools/perf/bench/epoll-wait.c | 11 +++++------ + tools/perf/bench/futex-hash.c | 12 ++++++------ + tools/perf/bench/futex-lock-pi.c | 11 +++++------ + 5 files changed, 23 insertions(+), 22 deletions(-) + +(limited to 'tools/perf/bench') + +diff --git a/tools/perf/bench/bench.h b/tools/perf/bench/bench.h +index fddb3ced9db62..4aa6de1aa67dc 100644 +--- a/tools/perf/bench/bench.h ++++ b/tools/perf/bench/bench.h +@@ -2,6 +2,10 @@ + #ifndef BENCH_H + #define BENCH_H + ++#include ++ ++extern struct timeval bench__start, bench__end, bench__runtime; ++ + /* + * The madvise transparent hugepage constants were added in glibc + * 2.13. For compatibility with older versions of glibc, define these +diff --git a/tools/perf/bench/epoll-ctl.c b/tools/perf/bench/epoll-ctl.c +index bb617e5688412..a7526c05df382 100644 +--- a/tools/perf/bench/epoll-ctl.c ++++ b/tools/perf/bench/epoll-ctl.c +@@ -35,7 +35,6 @@ + + static unsigned int nthreads = 0; + static unsigned int nsecs = 8; +-struct timeval start, end, runtime; + static bool done, __verbose, randomize; + + /* +@@ -94,8 +93,8 @@ static void toggle_done(int sig __maybe_unused, + { + /* inform all threads that we're done for the day */ + done = true; +- gettimeofday(&end, NULL); +- timersub(&end, &start, &runtime); ++ gettimeofday(&bench__end, NULL); ++ timersub(&bench__end, &bench__start, &bench__runtime); + } + + static void nest_epollfd(void) +@@ -361,7 +360,7 @@ int bench_epoll_ctl(int argc, const char **argv) + + threads_starting = nthreads; + +- gettimeofday(&start, NULL); ++ gettimeofday(&bench__start, NULL); + + do_threads(worker, cpu); + +diff --git a/tools/perf/bench/epoll-wait.c b/tools/perf/bench/epoll-wait.c +index 7af694437f4ea..d1c5cb526b9ff 100644 +--- a/tools/perf/bench/epoll-wait.c ++++ b/tools/perf/bench/epoll-wait.c +@@ -90,7 +90,6 @@ + + static unsigned int nthreads = 0; + static unsigned int nsecs = 8; +-struct timeval start, end, runtime; + static bool wdone, done, __verbose, randomize, nonblocking; + + /* +@@ -276,8 +275,8 @@ static void toggle_done(int sig __maybe_unused, + { + /* inform all threads that we're done for the day */ + done = true; +- gettimeofday(&end, NULL); +- timersub(&end, &start, &runtime); ++ gettimeofday(&bench__end, NULL); ++ timersub(&bench__end, &bench__start, &bench__runtime); + } + + static void print_summary(void) +@@ -287,7 +286,7 @@ static void print_summary(void) + + printf("\nAveraged %ld operations/sec (+- %.2f%%), total secs = %d\n", + avg, rel_stddev_stats(stddev, avg), +- (int) runtime.tv_sec); ++ (int)bench__runtime.tv_sec); + } + + static int do_threads(struct worker *worker, struct perf_cpu_map *cpu) +@@ -479,7 +478,7 @@ int bench_epoll_wait(int argc, const char **argv) + + threads_starting = nthreads; + +- gettimeofday(&start, NULL); ++ gettimeofday(&bench__start, NULL); + + do_threads(worker, cpu); + +@@ -519,7 +518,7 @@ int bench_epoll_wait(int argc, const char **argv) + qsort(worker, nthreads, sizeof(struct worker), cmpworker); + + for (i = 0; i < nthreads; i++) { +- unsigned long t = worker[i].ops/runtime.tv_sec; ++ unsigned long t = worker[i].ops / bench__runtime.tv_sec; + + update_stats(&throughput_stats, t); + +diff --git a/tools/perf/bench/futex-hash.c b/tools/perf/bench/futex-hash.c +index 8ba0c3330a9a2..21776862e940f 100644 +--- a/tools/perf/bench/futex-hash.c ++++ b/tools/perf/bench/futex-hash.c +@@ -37,7 +37,7 @@ static unsigned int nfutexes = 1024; + static bool fshared = false, done = false, silent = false; + static int futex_flag = 0; + +-struct timeval start, end, runtime; ++struct timeval bench__start, bench__end, bench__runtime; + static pthread_mutex_t thread_lock; + static unsigned int threads_starting; + static struct stats throughput_stats; +@@ -103,8 +103,8 @@ static void toggle_done(int sig __maybe_unused, + { + /* inform all threads that we're done for the day */ + done = true; +- gettimeofday(&end, NULL); +- timersub(&end, &start, &runtime); ++ gettimeofday(&bench__end, NULL); ++ timersub(&bench__end, &bench__start, &bench__runtime); + } + + static void print_summary(void) +@@ -114,7 +114,7 @@ static void print_summary(void) + + printf("%sAveraged %ld operations/sec (+- %.2f%%), total secs = %d\n", + !silent ? "\n" : "", avg, rel_stddev_stats(stddev, avg), +- (int) runtime.tv_sec); ++ (int)bench__runtime.tv_sec); + } + + int bench_futex_hash(int argc, const char **argv) +@@ -161,7 +161,7 @@ int bench_futex_hash(int argc, const char **argv) + + threads_starting = nthreads; + pthread_attr_init(&thread_attr); +- gettimeofday(&start, NULL); ++ gettimeofday(&bench__start, NULL); + for (i = 0; i < nthreads; i++) { + worker[i].tid = i; + worker[i].futex = calloc(nfutexes, sizeof(*worker[i].futex)); +@@ -204,7 +204,7 @@ int bench_futex_hash(int argc, const char **argv) + pthread_mutex_destroy(&thread_lock); + + for (i = 0; i < nthreads; i++) { +- unsigned long t = worker[i].ops/runtime.tv_sec; ++ unsigned long t = worker[i].ops / bench__runtime.tv_sec; + update_stats(&throughput_stats, t); + if (!silent) { + if (nfutexes == 1) +diff --git a/tools/perf/bench/futex-lock-pi.c b/tools/perf/bench/futex-lock-pi.c +index d0cae8125423f..30d97121dc4fb 100644 +--- a/tools/perf/bench/futex-lock-pi.c ++++ b/tools/perf/bench/futex-lock-pi.c +@@ -37,7 +37,6 @@ static bool silent = false, multi = false; + static bool done = false, fshared = false; + static unsigned int nthreads = 0; + static int futex_flag = 0; +-struct timeval start, end, runtime; + static pthread_mutex_t thread_lock; + static unsigned int threads_starting; + static struct stats throughput_stats; +@@ -64,7 +63,7 @@ static void print_summary(void) + + printf("%sAveraged %ld operations/sec (+- %.2f%%), total secs = %d\n", + !silent ? "\n" : "", avg, rel_stddev_stats(stddev, avg), +- (int) runtime.tv_sec); ++ (int)bench__runtime.tv_sec); + } + + static void toggle_done(int sig __maybe_unused, +@@ -73,8 +72,8 @@ static void toggle_done(int sig __maybe_unused, + { + /* inform all threads that we're done for the day */ + done = true; +- gettimeofday(&end, NULL); +- timersub(&end, &start, &runtime); ++ gettimeofday(&bench__end, NULL); ++ timersub(&bench__end, &bench__start, &bench__runtime); + } + + static void *workerfn(void *arg) +@@ -185,7 +184,7 @@ int bench_futex_lock_pi(int argc, const char **argv) + + threads_starting = nthreads; + pthread_attr_init(&thread_attr); +- gettimeofday(&start, NULL); ++ gettimeofday(&bench__start, NULL); + + create_threads(worker, thread_attr, cpu); + pthread_attr_destroy(&thread_attr); +@@ -211,7 +210,7 @@ int bench_futex_lock_pi(int argc, const char **argv) + pthread_mutex_destroy(&thread_lock); + + for (i = 0; i < nthreads; i++) { +- unsigned long t = worker[i].ops/runtime.tv_sec; ++ unsigned long t = worker[i].ops / bench__runtime.tv_sec; + + update_stats(&throughput_stats, t); + if (!silent) +-- +cgit 1.2.3-1.el7 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-5.4/perf-fixup-gcc10-04.patch b/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-5.4/perf-fixup-gcc10-04.patch new file mode 100644 index 00000000..dae1222c --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-5.4/perf-fixup-gcc10-04.patch @@ -0,0 +1,45 @@ +libtraceevent: Fix build with binutils 2.35 +Upstream-Status: Backport https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/patch/tools/lib/traceevent/plugins/Makefile?id=c2fd34d4311033120fa502aa8bd4723cdeee0103 +Signed-off-by: Khasim Syed Mohammed + +From c2fd34d4311033120fa502aa8bd4723cdeee0103 Mon Sep 17 00:00:00 2001 +From: Ben Hutchings +Date: Sat, 25 Jul 2020 02:06:23 +0100 +Subject: libtraceevent: Fix build with binutils 2.35 + +commit 39efdd94e314336f4acbac4c07e0f37bdc3bef71 upstream. + +In binutils 2.35, 'nm -D' changed to show symbol versions along with +symbol names, with the usual @@ separator. When generating +libtraceevent-dynamic-list we need just the names, so strip off the +version suffix if present. + +Signed-off-by: Ben Hutchings +Tested-by: Salvatore Bonaccorso +Reviewed-by: Steven Rostedt +Cc: linux-trace-devel@vger.kernel.org +Cc: stable@vger.kernel.org +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Greg Kroah-Hartman +--- + tools/lib/traceevent/plugins/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +(limited to 'tools/lib/traceevent/plugins/Makefile') + +diff --git a/tools/lib/traceevent/plugins/Makefile b/tools/lib/traceevent/plugins/Makefile +index f440989fa55e4..23c3535bcbd6b 100644 +--- a/tools/lib/traceevent/plugins/Makefile ++++ b/tools/lib/traceevent/plugins/Makefile +@@ -196,7 +196,7 @@ define do_generate_dynamic_list_file + xargs echo "U w W" | tr 'w ' 'W\n' | sort -u | xargs echo`;\ + if [ "$$symbol_type" = "U W" ];then \ + (echo '{'; \ +- $(NM) -u -D $1 | awk 'NF>1 {print "\t"$$2";"}' | sort -u;\ ++ $(NM) -u -D $1 | awk 'NF>1 {sub("@.*", "", $$2); print "\t"$$2";"}' | sort -u;\ + echo '};'; \ + ) > $2; \ + else \ +-- +cgit 1.2.3-1.el7 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm_5.4.bbappend b/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-n1sdp.inc similarity index 51% rename from meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm_5.4.bbappend rename to meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-n1sdp.inc index 6b13f9aa..820ce71e 100644 --- a/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm_5.4.bbappend +++ b/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-n1sdp.inc @@ -1,11 +1,6 @@ -# -# N1SDP MACHINE specific configurations -# +FILESEXTRAPATHS_prepend := "${THISDIR}/linux-linaro-arm-5.4:" -FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-5.4:" - -# Apply N1SDP specific patches -SRC_URI_append_n1sdp = " \ +SRC_URI_append = " \ file://0001-TMP-iommu-arm-smmu-v3-Ignore-IOPF-capabilities.patch \ file://0002-pci_quirk-add-acs-override-for-PCI-devices.patch \ file://0003-pcie-Add-quirk-for-the-Arm-Neoverse-N1SDP-platform.patch \ @@ -16,14 +11,21 @@ SRC_URI_append_n1sdp = " \ " # Referring to commit TAG N1SDP-2020.07.27 -SRCREV_n1sdp = "84baaae9e751c058717d9702438429257f077f03" -SRCREV_dts_n1sdp = "3209a868152f348194cc1f20fd87c759d3a97d45" +SRCREV = "84baaae9e751c058717d9702438429257f077f03" # Use intree defconfig -KBUILD_DEFCONFIG_n1sdp = "defconfig" +KBUILD_DEFCONFIG = "defconfig" # Since the intree defconfig in n1sdp kernel repository is not setting all the configs, # KCONFIG_MODE is set to "alldefconfig" to properly expand the defconfig. -KCONFIG_MODE_n1sdp = "--alldefconfig" +KCONFIG_MODE = "--alldefconfig" -COMPATIBLE_MACHINE_n1sdp = "n1sdp" +COMPATIBLE_MACHINE = "n1sdp" + +# RT kernel machine description +FILESEXTRAPATHS_prepend_pn-linux-linaro-arm-rt := "${THISDIR}:" +SRC_URI_append_pn-linux-linaro-arm-rt = " file://arm-platforms-kmeta;type=kmeta;name=arm-platforms-kmeta;destsuffix=arm-platforms-kmeta" + +# Since we use the intree defconfig and the preempt-rt turns off some configs +# do_kernel_configcheck will display warnings. So, lets disable it. +KCONF_AUDIT_LEVEL_pn-linux-linaro-arm-rt = "0" diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-rt_5.4.bb b/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-rt_5.4.bb new file mode 100644 index 00000000..4ee46be0 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm-rt_5.4.bb @@ -0,0 +1,12 @@ +# This recipe provides the kernel with PREEMPT_RT patches and is based on +# linux-linaro-arm_5.4.bb. Set PREFERRED_PROVIDER_virtual/kernel to +# linux-linaro-arm-rt to enable it as the default kernel. +require linux-linaro-arm_5.4.bb + +# +# Include preempt-rt patches +# +SRC_URI_append = " https://cdn.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patch-5.4.3-rt1.patch.gz;name=rt-patch" +SRC_URI[rt-patch.sha256sum] = "6b92ba32c7ce30919c9b66e49e5f1dce58e1f8bd92fef91e548d6f2d434a2b39" + +LINUX_KERNEL_TYPE = "preempt-rt" diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm.inc b/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm.inc index 1b8d4b2c..4859a66a 100644 --- a/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm.inc +++ b/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm.inc @@ -8,6 +8,10 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=bbea815ee2795b2f4230826c0c6b8814" inherit kernel inherit kernel-yocto +# Require linux-yocto.inc in order to have separate build dirs when building +# LINUX_KERNEL_TYPE as 'standard' and 'preempt-rt' +require recipes-kernel/linux/linux-yocto.inc + SRC_URI = "git://git.linaro.org/landing-teams/working/arm/kernel-release.git;branch=${KBRANCH} \ git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=${KMETA_BRANCH};destsuffix=kernel-meta \ file://0001-menuconfig-mconf-cfg-Allow-specification-of-ncurses-location.patch" @@ -17,3 +21,9 @@ DEPENDS += "openssl-native util-linux-native" LINUX_VERSION ?= "${PV}" S = "${WORKDIR}/git" + +# Add machine-specific settings +MACHINE_KERNEL_REQUIRE ?= "" +MACHINE_KERNEL_REQUIRE_n1sdp = "linux-linaro-arm-n1sdp.inc" + +require ${MACHINE_KERNEL_REQUIRE} diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm_5.4.bb b/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm_5.4.bb index 577af5ec..8e880ed7 100644 --- a/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm_5.4.bb +++ b/meta-arm-bsp/recipes-kernel/linux/linux-linaro-arm_5.4.bb @@ -5,6 +5,13 @@ SRCREV_meta ?= "e32057eca987b7abbe3eb47ba36f06af8711278a" KBRANCH ?= "n1sdp" KMETA_BRANCH ?= "yocto-5.4" -SRC_URI_append = " file://fix-bfd-link.patch" +# Apply following patches +SRC_URI_append = " \ + file://fix-bfd-link.patch \ + file://perf-fixup-gcc10-01.patch \ + file://perf-fixup-gcc10-02.patch \ + file://perf-fixup-gcc10-03.patch \ + file://perf-fixup-gcc10-04.patch \ + " require linux-linaro-arm.inc diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-stable_%.bbappend b/meta-arm-bsp/recipes-kernel/linux/linux-stable_%.bbappend deleted file mode 100644 index e4b2c117..00000000 --- a/meta-arm-bsp/recipes-kernel/linux/linux-stable_%.bbappend +++ /dev/null @@ -1,11 +0,0 @@ -# Add support for Arm Platforms (boards or simulators) - -require linux-arm-platforms.inc - -# -# Corstone700 KMACHINE -# -MACHINE_KERNEL_REQUIRE ?= "" -MACHINE_KERNEL_REQUIRE_corstone700 = "linux-stable-corstone700.inc" - -require ${MACHINE_KERNEL_REQUIRE} diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/0001-arm64-defconfig-drop-unused-BACKLIGHT_GENERIC-option.patch b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/0001-arm64-defconfig-drop-unused-BACKLIGHT_GENERIC-option.patch new file mode 100644 index 00000000..88a65fb3 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/0001-arm64-defconfig-drop-unused-BACKLIGHT_GENERIC-option.patch @@ -0,0 +1,41 @@ +Upstream-Status: Backport +Signed-off-by: Ross Burton + +From 717c4c8336486781630893508b3347ae18953fae Mon Sep 17 00:00:00 2001 +From: Andrey Zhizhikin +Date: Tue, 1 Dec 2020 22:29:19 +0000 +Subject: [PATCH] arm64: defconfig: drop unused BACKLIGHT_GENERIC option + +Commit 7ecdea4a0226 ("backlight: generic_bl: Remove this driver as it is +unused") removed geenric_bl driver from the tree, together with +corresponding config option. + +Remove BACKLIGHT_GENERIC config item from arm64 configuration. + +Fixes: 7ecdea4a0226 ("backlight: generic_bl: Remove this driver as it is unused") +Signed-off-by: Andrey Zhizhikin +Reviewed-by: Krzysztof Kozlowski +Acked-by: Daniel Thompson +Acked-by: Sam Ravnborg +Cc: Sam Ravnborg +Link: https://lore.kernel.org/r/20201201222922.3183-3-andrey.zhizhikin@leica-geosystems.com' +Signed-off-by: Arnd Bergmann +--- + arch/arm64/configs/defconfig | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig +index 98e15de04c5d..6493079e2c54 100644 +--- a/arch/arm64/configs/defconfig ++++ b/arch/arm64/configs/defconfig +@@ -698,7 +698,6 @@ CONFIG_DRM_PANFROST=m + CONFIG_FB=y + CONFIG_FB_MODE_HELPERS=y + CONFIG_FB_EFI=y +-CONFIG_BACKLIGHT_GENERIC=m + CONFIG_BACKLIGHT_PWM=m + CONFIG_BACKLIGHT_LP855X=m + CONFIG_LOGO=y +-- +2.25.1 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/0001-pci_quirk-add-acs-override-for-PCI-devices.patch b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/0001-pci_quirk-add-acs-override-for-PCI-devices.patch new file mode 100644 index 00000000..aa4e9e46 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/0001-pci_quirk-add-acs-override-for-PCI-devices.patch @@ -0,0 +1,161 @@ +From cfe5f638279e99cfc991cb38635cb9083c71f1e2 Mon Sep 17 00:00:00 2001 +From: Khasim Mohammed +Date: Mon, 4 Jan 2021 18:03:00 +0000 +Subject: [PATCH 1/4] pci_quirk: add acs override for PCI devices + +Upstream-Status: Inappropriate [will not be submitted as its an hack required to fix the hardware issue] + +Signed-off-by: Khasim Syed Mohammed + +Patch taken from: +https://gitlab.com/Queuecumber/linux-acs-override/raw/master/workspaces/5.4/acso.patch + +Signed-off-by: Manoj Kumar +--- + .../admin-guide/kernel-parameters.txt | 9 ++ + drivers/pci/quirks.c | 102 ++++++++++++++++++ + 2 files changed, 111 insertions(+) + +diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt +index 44fde25bb221..866a8eac8c3f 100644 +--- a/Documentation/admin-guide/kernel-parameters.txt ++++ b/Documentation/admin-guide/kernel-parameters.txt +@@ -3629,6 +3629,15 @@ + nomsi [MSI] If the PCI_MSI kernel config parameter is + enabled, this kernel boot option can be used to + disable the use of MSI interrupts system-wide. ++ pcie_acs_override = ++ [PCIE] Override missing PCIe ACS support for: ++ downstream ++ All downstream ports - full ACS capabilities ++ multfunction ++ All multifunction devices - multifunction ACS subset ++ id:nnnn:nnnn ++ Specfic device - full ACS capabilities ++ Specified as vid:did (vendor/device ID) in hex + noioapicquirk [APIC] Disable all boot interrupt quirks. + Safety option to keep boot IRQs enabled. This + should never be necessary. +diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c +index f70692ac79c5..bc758323c8f3 100644 +--- a/drivers/pci/quirks.c ++++ b/drivers/pci/quirks.c +@@ -3557,6 +3557,107 @@ static void quirk_no_bus_reset(struct pci_dev *dev) + dev->dev_flags |= PCI_DEV_FLAGS_NO_BUS_RESET; + } + ++static bool acs_on_downstream; ++static bool acs_on_multifunction; ++ ++#define NUM_ACS_IDS 16 ++struct acs_on_id { ++ unsigned short vendor; ++ unsigned short device; ++}; ++static struct acs_on_id acs_on_ids[NUM_ACS_IDS]; ++static u8 max_acs_id; ++ ++static __init int pcie_acs_override_setup(char *p) ++{ ++ if (!p) ++ return -EINVAL; ++ ++ while (*p) { ++ if (!strncmp(p, "downstream", 10)) ++ acs_on_downstream = true; ++ if (!strncmp(p, "multifunction", 13)) ++ acs_on_multifunction = true; ++ if (!strncmp(p, "id:", 3)) { ++ char opt[5]; ++ int ret; ++ long val; ++ ++ if (max_acs_id >= NUM_ACS_IDS - 1) { ++ pr_warn("Out of PCIe ACS override slots (%d)\n", ++ NUM_ACS_IDS); ++ goto next; ++ } ++ ++ p += 3; ++ snprintf(opt, 5, "%s", p); ++ ret = kstrtol(opt, 16, &val); ++ if (ret) { ++ pr_warn("PCIe ACS ID parse error %d\n", ret); ++ goto next; ++ } ++ acs_on_ids[max_acs_id].vendor = val; ++ ++ p += strcspn(p, ":"); ++ if (*p != ':') { ++ pr_warn("PCIe ACS invalid ID\n"); ++ goto next; ++ } ++ ++ p++; ++ snprintf(opt, 5, "%s", p); ++ ret = kstrtol(opt, 16, &val); ++ if (ret) { ++ pr_warn("PCIe ACS ID parse error %d\n", ret); ++ goto next; ++ } ++ acs_on_ids[max_acs_id].device = val; ++ max_acs_id++; ++ } ++next: ++ p += strcspn(p, ","); ++ if (*p == ',') ++ p++; ++ } ++ ++ if (acs_on_downstream || acs_on_multifunction || max_acs_id) ++ pr_warn("Warning: PCIe ACS overrides enabled; This may allow non-IOMMU protected peer-to-peer DMA\n"); ++ ++ return 0; ++} ++early_param("pcie_acs_override", pcie_acs_override_setup); ++ ++static int pcie_acs_overrides(struct pci_dev *dev, u16 acs_flags) ++{ ++ int i; ++ ++ /* Never override ACS for legacy devices or devices with ACS caps */ ++ if (!pci_is_pcie(dev) || ++ pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS)) ++ return -ENOTTY; ++ ++ for (i = 0; i < max_acs_id; i++) ++ if (acs_on_ids[i].vendor == dev->vendor && ++ acs_on_ids[i].device == dev->device) ++ return 1; ++ ++ switch (pci_pcie_type(dev)) { ++ case PCI_EXP_TYPE_DOWNSTREAM: ++ case PCI_EXP_TYPE_ROOT_PORT: ++ if (acs_on_downstream) ++ return 1; ++ break; ++ case PCI_EXP_TYPE_ENDPOINT: ++ case PCI_EXP_TYPE_UPSTREAM: ++ case PCI_EXP_TYPE_LEG_END: ++ case PCI_EXP_TYPE_RC_END: ++ if (acs_on_multifunction && dev->multifunction) ++ return 1; ++ } ++ ++ return -ENOTTY; ++} ++ + /* + * Some Atheros AR9xxx and QCA988x chips do not behave after a bus reset. + * The device will throw a Link Down error on AER-capable systems and +@@ -4769,6 +4870,7 @@ static const struct pci_dev_acs_enabled { + { PCI_VENDOR_ID_ZHAOXIN, 0x9083, pci_quirk_mf_endpoint_acs }, + /* Zhaoxin Root/Downstream Ports */ + { PCI_VENDOR_ID_ZHAOXIN, PCI_ANY_ID, pci_quirk_zhaoxin_pcie_ports_acs }, ++ { PCI_ANY_ID, PCI_ANY_ID, pcie_acs_overrides }, + { 0 } + }; + +-- +2.17.1 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/0002-pcie-Add-quirk-for-the-Arm-Neoverse-N1SDP-platform.patch b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/0002-pcie-Add-quirk-for-the-Arm-Neoverse-N1SDP-platform.patch new file mode 100644 index 00000000..7b35e3b6 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/0002-pcie-Add-quirk-for-the-Arm-Neoverse-N1SDP-platform.patch @@ -0,0 +1,329 @@ +From 5b9fd8da4deaabcd854c49286bf5c57c661e122f Mon Sep 17 00:00:00 2001 +From: Khasim Mohammed +Date: Mon, 4 Jan 2021 18:34:46 +0000 +Subject: [PATCH 2/4] pcie: Add quirk for the Arm Neoverse N1SDP platform + +Upstream-Status: Inappropriate [will not be submitted as its an hack required to fix the hardware issue] + +The patch is taken from : +https://git.linaro.org/landing-teams/working/arm/n1sdp-pcie-quirk.git/tree/linux + +Signed-off-by: Khasim Syed Mohammed + +The Arm N1SDP SoC suffers from some PCIe integration issues, most +prominently config space accesses to not existing BDFs being answered +with a bus abort, resulting in an SError. +To mitigate this, the firmware scans the bus before boot (catching the +SErrors) and creates a table with valid BDFs, which acts as a filter for +Linux' config space accesses. + +Add code consulting the table as an ACPI PCIe quirk, also register the +corresponding device tree based description of the host controller. +Also fix the other two minor issues on the way, namely not being fully +ECAM compliant and config space accesses being restricted to 32-bit +accesses only. + +This allows the Arm Neoverse N1SDP board to boot Linux without crashing +and to access *any* devices (there are no platform devices except UART). + +Signed-off-by: Deepak Pandey +[Sudipto: extend to cover the CCIX root port as well] +Signed-off-by: Sudipto Paul +[Andre: fix coding style issues, rewrite some parts, add DT support] +Signed-off-by: Andre Przywara +[Khasim: port the patch to linux kernel 5.10] +Signed-off-by: Khasim Syed Mohammed +--- + arch/arm64/configs/defconfig | 1 + + drivers/acpi/pci_mcfg.c | 7 + + drivers/pci/controller/Kconfig | 11 ++ + drivers/pci/controller/Makefile | 1 + + drivers/pci/controller/pcie-n1sdp.c | 198 ++++++++++++++++++++++++++++ + include/linux/pci-ecam.h | 2 + + 6 files changed, 220 insertions(+) + create mode 100644 drivers/pci/controller/pcie-n1sdp.c + +diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig +index 5cfe3cf6f2ac..a035dcd7055d 100644 +--- a/arch/arm64/configs/defconfig ++++ b/arch/arm64/configs/defconfig +@@ -205,6 +205,7 @@ CONFIG_NFC_NCI=m + CONFIG_NFC_S3FWRN5_I2C=m + CONFIG_PCI=y + CONFIG_PCIEPORTBUS=y ++CONFIG_PCI_QUIRKS=y + CONFIG_PCI_IOV=y + CONFIG_PCI_PASID=y + CONFIG_HOTPLUG_PCI=y +diff --git a/drivers/acpi/pci_mcfg.c b/drivers/acpi/pci_mcfg.c +index 95f23acd5b80..f7a7d6e87780 100644 +--- a/drivers/acpi/pci_mcfg.c ++++ b/drivers/acpi/pci_mcfg.c +@@ -143,6 +143,13 @@ static struct mcfg_fixup mcfg_quirks[] = { + XGENE_V2_ECAM_MCFG(4, 1), + XGENE_V2_ECAM_MCFG(4, 2), + ++#define N1SDP_ECAM_MCFG(rev, seg, ops) \ ++ {"ARMLTD", "ARMN1SDP", rev, seg, MCFG_BUS_ANY, ops } ++ ++ /* N1SDP SoC with v1 PCIe controller */ ++ N1SDP_ECAM_MCFG(0x20181101, 0, &pci_n1sdp_pcie_ecam_ops), ++ N1SDP_ECAM_MCFG(0x20181101, 1, &pci_n1sdp_ccix_ecam_ops), ++ + #define ALTRA_ECAM_QUIRK(rev, seg) \ + { "Ampere", "Altra ", rev, seg, MCFG_BUS_ANY, &pci_32b_read_ops } + +diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig +index 64e2f5e379aa..df10736b2d9e 100644 +--- a/drivers/pci/controller/Kconfig ++++ b/drivers/pci/controller/Kconfig +@@ -37,6 +37,17 @@ config PCI_FTPCI100 + depends on OF + default ARCH_GEMINI + ++config PCIE_HOST_N1SDP_ECAM ++ bool "ARM N1SDP PCIe Controller" ++ depends on ARM64 ++ depends on OF || (ACPI && PCI_QUIRKS) ++ select PCI_HOST_COMMON ++ default y if ARCH_VEXPRESS ++ help ++ Say Y here if you want PCIe support for the Arm N1SDP platform. ++ The controller is ECAM compliant, but needs a quirk to workaround ++ an integration issue. ++ + config PCI_TEGRA + bool "NVIDIA Tegra PCIe controller" + depends on ARCH_TEGRA || COMPILE_TEST +diff --git a/drivers/pci/controller/Makefile b/drivers/pci/controller/Makefile +index 04c6edc285c5..6e5c3dcae8d3 100644 +--- a/drivers/pci/controller/Makefile ++++ b/drivers/pci/controller/Makefile +@@ -29,6 +29,7 @@ obj-$(CONFIG_PCIE_ROCKCHIP_HOST) += pcie-rockchip-host.o + obj-$(CONFIG_PCIE_MEDIATEK) += pcie-mediatek.o + obj-$(CONFIG_PCIE_TANGO_SMP8759) += pcie-tango.o + obj-$(CONFIG_VMD) += vmd.o ++obj-$(CONFIG_PCIE_HOST_N1SDP_ECAM) += pcie-n1sdp.o + obj-$(CONFIG_PCIE_BRCMSTB) += pcie-brcmstb.o + obj-$(CONFIG_PCI_LOONGSON) += pci-loongson.o + obj-$(CONFIG_PCIE_HISI_ERR) += pcie-hisi-error.o +diff --git a/drivers/pci/controller/pcie-n1sdp.c b/drivers/pci/controller/pcie-n1sdp.c +new file mode 100644 +index 000000000000..327aee9c5564 +--- /dev/null ++++ b/drivers/pci/controller/pcie-n1sdp.c +@@ -0,0 +1,198 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Copyright (C) 2018/2019 ARM Ltd. ++ * ++ * This quirk is to mask the following issues: ++ * - PCIE SLVERR: config space accesses to invalid PCIe BDFs cause a bus ++ * error (signalled as an asynchronous SError) ++ * - MCFG BDF mapping: the root complex is mapped separately from the device ++ * config space ++ * - Non 32-bit accesses to config space are not supported. ++ * ++ * At boot time the SCP board firmware creates a discovery table with ++ * the root complex' base address and the valid BDF values, discovered while ++ * scanning the config space and catching the SErrors. ++ * Linux responds only to the EPs listed in this table, returning NULL ++ * for the rest. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/* Platform specific values as hardcoded in the firmware. */ ++#define AP_NS_SHARED_MEM_BASE 0x06000000 ++#define MAX_SEGMENTS 2 ++#define BDF_TABLE_SIZE SZ_16K ++ ++/* ++ * Shared memory layout as written by the SCP upon boot time: ++ * ---- ++ * Discover data header --> RC base address ++ * \-> BDF Count ++ * Discover data --> BDF 0...n ++ * ---- ++ */ ++struct pcie_discovery_data { ++ u32 rc_base_addr; ++ u32 nr_bdfs; ++ u32 valid_bdfs[0]; ++} *pcie_discovery_data[MAX_SEGMENTS]; ++ ++void __iomem *rc_remapped_addr[MAX_SEGMENTS]; ++ ++/* ++ * map_bus() is called before we do a config space access for a certain ++ * device. We use this to check whether this device is valid, avoiding ++ * config space accesses which would result in an SError otherwise. ++ */ ++static void __iomem *pci_n1sdp_map_bus(struct pci_bus *bus, unsigned int devfn, ++ int where) ++{ ++ struct pci_config_window *cfg = bus->sysdata; ++ unsigned int devfn_shift = cfg->ops->bus_shift - 8; ++ unsigned int busn = bus->number; ++ unsigned int segment = bus->domain_nr; ++ unsigned int bdf_addr; ++ unsigned int table_count, i; ++ ++ if (segment >= MAX_SEGMENTS || ++ busn < cfg->busr.start || busn > cfg->busr.end) ++ return NULL; ++ ++ /* The PCIe root complex has a separate config space mapping. */ ++ if (busn == 0 && devfn == 0) ++ return rc_remapped_addr[segment] + where; ++ ++ busn -= cfg->busr.start; ++ bdf_addr = (busn << cfg->ops->bus_shift) + (devfn << devfn_shift); ++ table_count = pcie_discovery_data[segment]->nr_bdfs; ++ for (i = 0; i < table_count; i++) { ++ if (bdf_addr == pcie_discovery_data[segment]->valid_bdfs[i]) ++ return pci_ecam_map_bus(bus, devfn, where); ++ } ++ ++ return NULL; ++} ++ ++static int pci_n1sdp_init(struct pci_config_window *cfg, unsigned int segment) ++{ ++ phys_addr_t table_base; ++ struct device *dev = cfg->parent; ++ struct pcie_discovery_data *shared_data; ++ size_t bdfs_size; ++ ++ if (segment >= MAX_SEGMENTS) ++ return -ENODEV; ++ ++ table_base = AP_NS_SHARED_MEM_BASE + segment * BDF_TABLE_SIZE; ++ ++ if (!request_mem_region(table_base, BDF_TABLE_SIZE, ++ "PCIe valid BDFs")) { ++ dev_err(dev, "PCIe BDF shared region request failed\n"); ++ return -ENOMEM; ++ } ++ ++ shared_data = devm_ioremap(dev, ++ table_base, BDF_TABLE_SIZE); ++ if (!shared_data) ++ return -ENOMEM; ++ ++ /* Copy the valid BDFs structure to allocated normal memory. */ ++ bdfs_size = sizeof(struct pcie_discovery_data) + ++ sizeof(u32) * shared_data->nr_bdfs; ++ pcie_discovery_data[segment] = devm_kmalloc(dev, bdfs_size, GFP_KERNEL); ++ if (!pcie_discovery_data[segment]) ++ return -ENOMEM; ++ ++ memcpy_fromio(pcie_discovery_data[segment], shared_data, bdfs_size); ++ ++ rc_remapped_addr[segment] = devm_ioremap(dev, ++ shared_data->rc_base_addr, ++ PCI_CFG_SPACE_EXP_SIZE); ++ if (!rc_remapped_addr[segment]) { ++ dev_err(dev, "Cannot remap root port base\n"); ++ return -ENOMEM; ++ } ++ ++ devm_iounmap(dev, shared_data); ++ ++ return 0; ++} ++ ++static int pci_n1sdp_pcie_init(struct pci_config_window *cfg) ++{ ++ return pci_n1sdp_init(cfg, 0); ++} ++ ++static int pci_n1sdp_ccix_init(struct pci_config_window *cfg) ++{ ++ return pci_n1sdp_init(cfg, 1); ++} ++ ++const struct pci_ecam_ops pci_n1sdp_pcie_ecam_ops = { ++ .bus_shift = 20, ++ .init = pci_n1sdp_pcie_init, ++ .pci_ops = { ++ .map_bus = pci_n1sdp_map_bus, ++ .read = pci_generic_config_read32, ++ .write = pci_generic_config_write32, ++ } ++}; ++ ++const struct pci_ecam_ops pci_n1sdp_ccix_ecam_ops = { ++ .bus_shift = 20, ++ .init = pci_n1sdp_ccix_init, ++ .pci_ops = { ++ .map_bus = pci_n1sdp_map_bus, ++ .read = pci_generic_config_read32, ++ .write = pci_generic_config_write32, ++ } ++}; ++ ++struct of_device_id n1sdp_pcie_of_match[] = { ++ { .compatible = "arm,n1sdp-pcie" }, ++ { }, ++}; ++MODULE_DEVICE_TABLE(of, n1sdp_pcie_of_match); ++ ++static int n1sdp_pcie_probe(struct platform_device *pdev) ++{ ++ const struct device_node *of_node = pdev->dev.of_node; ++ u32 segment; ++ ++ if (of_property_read_u32(of_node, "linux,pci-domain", &segment)) { ++ dev_err(&pdev->dev, "N1SDP PCI controllers require linux,pci-domain property\n"); ++ return -EINVAL; ++ } ++ ++ switch (segment) { ++ case 0: ++ n1sdp_pcie_of_match[0].data = &pci_n1sdp_pcie_ecam_ops; ++ return pci_host_common_probe(pdev); ++ case 1: ++ n1sdp_pcie_of_match[0].data = &pci_n1sdp_ccix_ecam_ops; ++ return pci_host_common_probe(pdev); ++ } ++ ++ dev_err(&pdev->dev, "Invalid segment number, must be smaller than %d\n", ++ MAX_SEGMENTS); ++ ++ return -EINVAL; ++} ++ ++static struct platform_driver n1sdp_pcie_driver = { ++ .driver = { ++ .name = KBUILD_MODNAME, ++ .of_match_table = n1sdp_pcie_of_match, ++ .suppress_bind_attrs = true, ++ }, ++ .probe = n1sdp_pcie_probe, ++}; ++builtin_platform_driver(n1sdp_pcie_driver); +diff --git a/include/linux/pci-ecam.h b/include/linux/pci-ecam.h +index 033ce74f02e8..d3959ada44af 100644 +--- a/include/linux/pci-ecam.h ++++ b/include/linux/pci-ecam.h +@@ -58,6 +58,8 @@ extern const struct pci_ecam_ops pci_thunder_ecam_ops; /* Cavium ThunderX 1.x */ + extern const struct pci_ecam_ops xgene_v1_pcie_ecam_ops; /* APM X-Gene PCIe v1 */ + extern const struct pci_ecam_ops xgene_v2_pcie_ecam_ops; /* APM X-Gene PCIe v2.x */ + extern const struct pci_ecam_ops al_pcie_ops; /* Amazon Annapurna Labs PCIe */ ++extern const struct pci_ecam_ops pci_n1sdp_pcie_ecam_ops; /* Arm N1SDP PCIe */ ++extern const struct pci_ecam_ops pci_n1sdp_ccix_ecam_ops; /* Arm N1SDP PCIe */ + #endif + + #if IS_ENABLED(CONFIG_PCI_HOST_COMMON) +-- +2.17.1 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/0003-n1sdp-update-n1sdp-pci-quirk-for-SR-IOV-support.patch b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/0003-n1sdp-update-n1sdp-pci-quirk-for-SR-IOV-support.patch new file mode 100644 index 00000000..5a53460f --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/0003-n1sdp-update-n1sdp-pci-quirk-for-SR-IOV-support.patch @@ -0,0 +1,58 @@ +From f3662513b224d9704355afc61a9dc26493bbdf13 Mon Sep 17 00:00:00 2001 +From: Khasim Mohammed +Date: Tue, 5 Jan 2021 17:57:46 +0000 +Subject: [PATCH 3/4] n1sdp: update n1sdp pci quirk for SR-IOV support + +Upstream-Status: Inappropriate [will not be submitted as its an hack required to fix the hardware issue] + +The patch is taken from: +https://git.linaro.org/landing-teams/working/arm/n1sdp-pcie-quirk.git/tree/linux + +Signed-off-by: Khasim Syed Mohammed + +VFs are not probing the vendor ID first, which is otherwise +the gate keeper for undiscovered devices. So any accesses using +a config space offset greater than 0 must be coming for an +already discovered device or from a VF that has just been created. + +Also if Linux already has a struct pci_dev* for a given BDF, +this device is safe to access. + +Skip the firmware table in these cases and allow accesses to +those devices. That enables SR-IOV support on the N1SDP board. + +Signed-off-by: Andre Przywara +--- + drivers/pci/controller/pcie-n1sdp.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/drivers/pci/controller/pcie-n1sdp.c b/drivers/pci/controller/pcie-n1sdp.c +index 327aee9c5564..45bbe506045a 100644 +--- a/drivers/pci/controller/pcie-n1sdp.c ++++ b/drivers/pci/controller/pcie-n1sdp.c +@@ -61,6 +61,7 @@ static void __iomem *pci_n1sdp_map_bus(struct pci_bus *bus, unsigned int devfn, + unsigned int segment = bus->domain_nr; + unsigned int bdf_addr; + unsigned int table_count, i; ++ struct pci_dev *dev; + + if (segment >= MAX_SEGMENTS || + busn < cfg->busr.start || busn > cfg->busr.end) +@@ -70,6 +71,14 @@ static void __iomem *pci_n1sdp_map_bus(struct pci_bus *bus, unsigned int devfn, + if (busn == 0 && devfn == 0) + return rc_remapped_addr[segment] + where; + ++ dev = pci_get_domain_bus_and_slot(segment, busn, devfn); ++ if (dev && dev->is_virtfn) ++ return pci_ecam_map_bus(bus, devfn, where); ++ ++ /* Accesses beyond the vendor ID always go to existing devices. */ ++ if (where > 0) ++ return pci_ecam_map_bus(bus, devfn, where); ++ + busn -= cfg->busr.start; + bdf_addr = (busn << cfg->ops->bus_shift) + (devfn << devfn_shift); + table_count = pcie_discovery_data[segment]->nr_bdfs; +-- +2.17.1 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/0004-n1sdp-pcie-add-quirk-support-enabling-remote-chip-PC.patch b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/0004-n1sdp-pcie-add-quirk-support-enabling-remote-chip-PC.patch new file mode 100644 index 00000000..10a59e80 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/0004-n1sdp-pcie-add-quirk-support-enabling-remote-chip-PC.patch @@ -0,0 +1,137 @@ +From 604e0130dff007f28a510291064edf20aff3ddea Mon Sep 17 00:00:00 2001 +From: Khasim Mohammed +Date: Tue, 5 Jan 2021 18:20:16 +0000 +Subject: [PATCH 4/4] n1sdp: pcie: add quirk support enabling remote chip PCIe + +Upstream-Status: Inappropriate [will not be submitted as its an hack required to fix the hardware issue] + +This patch is picked from the git repository and ported 5.10: +https://git.linaro.org/landing-teams/working/arm/n1sdp-pcie-quirk.git/patch/?id=04b7e76d0fe6481a803f58e54e008a1489d713a5 + +Signed-off-by: Khasim Syed Mohammed + +Base address mapping for remote chip Root PCIe ECAM space. + +Remote Chip PCIe topology is enumerated in Firmware and current +change takes referecne of enumerated PCIe hierarchy of Remote chip into the +kernel and include in complete PCIe topology for kernel framework. + +Signed-off-by: Sayanta Pattanayak +--- + drivers/acpi/pci_mcfg.c | 1 + + drivers/pci/controller/pcie-n1sdp.c | 36 ++++++++++++++++++++++++++--- + include/linux/pci-ecam.h | 1 + + 3 files changed, 35 insertions(+), 3 deletions(-) + +diff --git a/drivers/acpi/pci_mcfg.c b/drivers/acpi/pci_mcfg.c +index f7a7d6e87780..0523f485c930 100644 +--- a/drivers/acpi/pci_mcfg.c ++++ b/drivers/acpi/pci_mcfg.c +@@ -149,6 +149,7 @@ static struct mcfg_fixup mcfg_quirks[] = { + /* N1SDP SoC with v1 PCIe controller */ + N1SDP_ECAM_MCFG(0x20181101, 0, &pci_n1sdp_pcie_ecam_ops), + N1SDP_ECAM_MCFG(0x20181101, 1, &pci_n1sdp_ccix_ecam_ops), ++ N1SDP_ECAM_MCFG(0x20181101, 2, &pci_n1sdp_remote_pcie_ecam_ops), + + #define ALTRA_ECAM_QUIRK(rev, seg) \ + { "Ampere", "Altra ", rev, seg, MCFG_BUS_ANY, &pci_32b_read_ops } +diff --git a/drivers/pci/controller/pcie-n1sdp.c b/drivers/pci/controller/pcie-n1sdp.c +index 45bbe506045a..01f601e36343 100644 +--- a/drivers/pci/controller/pcie-n1sdp.c ++++ b/drivers/pci/controller/pcie-n1sdp.c +@@ -28,8 +28,11 @@ + + /* Platform specific values as hardcoded in the firmware. */ + #define AP_NS_SHARED_MEM_BASE 0x06000000 +-#define MAX_SEGMENTS 2 ++ ++/* Two PCIe root complexes in One Chip + One PCIe RC in Remote Chip*/ ++#define MAX_SEGMENTS 3 + #define BDF_TABLE_SIZE SZ_16K ++#define REMOTE_CHIP_ADDR_OFFSET 0x40000000000 + + /* + * Shared memory layout as written by the SCP upon boot time: +@@ -100,7 +103,10 @@ static int pci_n1sdp_init(struct pci_config_window *cfg, unsigned int segment) + if (segment >= MAX_SEGMENTS) + return -ENODEV; + +- table_base = AP_NS_SHARED_MEM_BASE + segment * BDF_TABLE_SIZE; ++ if (segment > 1) ++ table_base = AP_NS_SHARED_MEM_BASE + REMOTE_CHIP_ADDR_OFFSET; ++ else ++ table_base = AP_NS_SHARED_MEM_BASE + segment * BDF_TABLE_SIZE; + + if (!request_mem_region(table_base, BDF_TABLE_SIZE, + "PCIe valid BDFs")) { +@@ -122,9 +128,15 @@ static int pci_n1sdp_init(struct pci_config_window *cfg, unsigned int segment) + + memcpy_fromio(pcie_discovery_data[segment], shared_data, bdfs_size); + +- rc_remapped_addr[segment] = devm_ioremap(dev, ++ if (segment > 1) ++ rc_remapped_addr[segment] = devm_ioremap(dev, ++ shared_data->rc_base_addr + REMOTE_CHIP_ADDR_OFFSET, ++ PCI_CFG_SPACE_EXP_SIZE); ++ else ++ rc_remapped_addr[segment] = devm_ioremap(dev, + shared_data->rc_base_addr, + PCI_CFG_SPACE_EXP_SIZE); ++ + if (!rc_remapped_addr[segment]) { + dev_err(dev, "Cannot remap root port base\n"); + return -ENOMEM; +@@ -145,6 +157,11 @@ static int pci_n1sdp_ccix_init(struct pci_config_window *cfg) + return pci_n1sdp_init(cfg, 1); + } + ++static int pci_n1sdp_remote_pcie_init(struct pci_config_window *cfg) ++{ ++ return pci_n1sdp_init(cfg, 2); ++} ++ + const struct pci_ecam_ops pci_n1sdp_pcie_ecam_ops = { + .bus_shift = 20, + .init = pci_n1sdp_pcie_init, +@@ -165,6 +182,16 @@ const struct pci_ecam_ops pci_n1sdp_ccix_ecam_ops = { + } + }; + ++const struct pci_ecam_ops pci_n1sdp_remote_pcie_ecam_ops = { ++ .bus_shift = 20, ++ .init = pci_n1sdp_remote_pcie_init, ++ .pci_ops = { ++ .map_bus = pci_n1sdp_map_bus, ++ .read = pci_generic_config_read32, ++ .write = pci_generic_config_write32, ++ } ++}; ++ + struct of_device_id n1sdp_pcie_of_match[] = { + { .compatible = "arm,n1sdp-pcie" }, + { }, +@@ -188,6 +215,9 @@ static int n1sdp_pcie_probe(struct platform_device *pdev) + case 1: + n1sdp_pcie_of_match[0].data = &pci_n1sdp_ccix_ecam_ops; + return pci_host_common_probe(pdev); ++ case 2: ++ n1sdp_pcie_of_match[0].data = &pci_n1sdp_remote_pcie_ecam_ops; ++ return pci_host_common_probe(pdev); + } + + dev_err(&pdev->dev, "Invalid segment number, must be smaller than %d\n", +diff --git a/include/linux/pci-ecam.h b/include/linux/pci-ecam.h +index d3959ada44af..08d9684b7dc8 100644 +--- a/include/linux/pci-ecam.h ++++ b/include/linux/pci-ecam.h +@@ -60,6 +60,7 @@ extern const struct pci_ecam_ops xgene_v2_pcie_ecam_ops; /* APM X-Gene PCIe v2.x + extern const struct pci_ecam_ops al_pcie_ops; /* Amazon Annapurna Labs PCIe */ + extern const struct pci_ecam_ops pci_n1sdp_pcie_ecam_ops; /* Arm N1SDP PCIe */ + extern const struct pci_ecam_ops pci_n1sdp_ccix_ecam_ops; /* Arm N1SDP PCIe */ ++extern const struct pci_ecam_ops pci_n1sdp_remote_pcie_ecam_ops; /* Arm N1SDP PCIe */ + #endif + + #if IS_ENABLED(CONFIG_PCI_HOST_COMMON) +-- +2.17.1 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/0005-r8169-Fix-to-avoid-duplicate-sysfs-entry-creation-er.patch b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/0005-r8169-Fix-to-avoid-duplicate-sysfs-entry-creation-er.patch new file mode 100644 index 00000000..143f78bf --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/0005-r8169-Fix-to-avoid-duplicate-sysfs-entry-creation-er.patch @@ -0,0 +1,45 @@ +From 914fe7871fc2f00ec94cd4d17722158e94fa88df Mon Sep 17 00:00:00 2001 +From: Khasim Mohammed +Date: Fri, 8 Jan 2021 04:21:23 +0000 +Subject: [PATCH] r8169: Fix to avoid duplicate sysfs entry creation error +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Upstream-Status: Pending [yet to submit] + +Signed-off-by: Khasim Syed Mohammed + +Patch taken from : +https://git.linaro.org/landing-teams/working/arm/kernel-release.git/commit/?h=n1sdp&id=84baaae9e751c058717d9702438429257f077f03 + +Following error observed with r8169 driver, this patch fix the issue. + +[ 27.544136] r8169 0002:07:00.0: enabling device (0000 -> 0003) +[ 27.559734] sysfs: cannot create duplicate filename '/class/mdio_bus/r8169-700' +… +[ 27.684858] libphy: mii_bus r8169-700 failed to register +[ 27.695602] r8169: probe of 0002:07:00.0 failed with error -22 + +Change-Id: Id696abbabd794ecef5c551c5c45630963d9502a6 +Signed-off-by: Sayanta Pattanayak +--- + drivers/net/ethernet/realtek/r8169_main.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c +index 85d9c3e30c69..6d6b24978fd5 100644 +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -5088,7 +5088,7 @@ static int r8169_mdio_register(struct rtl8169_private *tp) + new_bus->priv = tp; + new_bus->parent = &pdev->dev; + new_bus->irq[0] = PHY_IGNORE_INTERRUPT; +- snprintf(new_bus->id, MII_BUS_ID_SIZE, "r8169-%x", pci_dev_id(pdev)); ++ snprintf(new_bus->id, MII_BUS_ID_SIZE, "r8169-%x-%x", pdev->bus->domain_nr, pci_dev_id(pdev)); + + new_bus->read = r8169_mdio_read_reg; + new_bus->write = r8169_mdio_write_reg; +-- +2.17.1 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/enable-realtek-R8169.cfg b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/enable-realtek-R8169.cfg new file mode 100644 index 00000000..7a574740 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/enable-realtek-R8169.cfg @@ -0,0 +1,3 @@ +# Enable Realtek Gigabit Ethernet adapter +CONFIG_REALTEK_PHY=y +CONFIG_R8169=y diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/enable-usb_conn_gpio.cfg b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/enable-usb_conn_gpio.cfg new file mode 100644 index 00000000..128c9027 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/enable-usb_conn_gpio.cfg @@ -0,0 +1,2 @@ +# PHY_TEGRA_XUSB sets this to y, but its set as m in defconfig +CONFIG_USB_CONN_GPIO=y diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/no-power-avs.patch b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/no-power-avs.patch new file mode 100644 index 00000000..a8c608c3 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.10/n1sdp/no-power-avs.patch @@ -0,0 +1,29 @@ +Remove CONFIG_POWER_AVS, this config option was removed in 785b5bb41b0a. + +Upstream-Status: Pending +Signed-off-by: Ross Burton + +diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig +index c5f25710fedc..62650dc10119 100644 +--- a/arch/arm/configs/multi_v7_defconfig ++++ b/arch/arm/configs/multi_v7_defconfig +@@ -475,7 +475,6 @@ CONFIG_GPIO_TPS6586X=y + CONFIG_GPIO_TPS65910=y + CONFIG_GPIO_TWL4030=y + CONFIG_GPIO_MXC=y +-CONFIG_POWER_AVS=y + CONFIG_ROCKCHIP_IODOMAIN=y + CONFIG_POWER_RESET_AS3722=y + CONFIG_POWER_RESET_GPIO=y +diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig +index 838301650a79..1146f2904bff 100644 +--- a/arch/arm64/configs/defconfig ++++ b/arch/arm64/configs/defconfig +@@ -523,7 +523,6 @@ CONFIG_GPIO_PCA953X_IRQ=y + CONFIG_GPIO_BD9571MWV=m + CONFIG_GPIO_MAX77620=y + CONFIG_GPIO_SL28CPLD=m +-CONFIG_POWER_AVS=y + CONFIG_QCOM_CPR=y + CONFIG_ROCKCHIP_IODOMAIN=y + CONFIG_POWER_RESET_MSM=y diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.3/0001-perf-cs-etm-Move-definition-of-traceid_list-global-v.patch b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.3/0001-perf-cs-etm-Move-definition-of-traceid_list-global-v.patch new file mode 100644 index 00000000..fb1d529a --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.3/0001-perf-cs-etm-Move-definition-of-traceid_list-global-v.patch @@ -0,0 +1,69 @@ +Upstream-Status: Backport +Signed-off-by: Ross Burton + +From 97180026ac37020c920f598fe0820e4e0bf58b22 Mon Sep 17 00:00:00 2001 +From: Leo Yan +Date: Tue, 5 May 2020 21:36:42 +0800 +Subject: [PATCH 1/4] perf cs-etm: Move definition of 'traceid_list' global + variable from header file + +The variable 'traceid_list' is defined in the header file cs-etm.h, +if multiple C files include cs-etm.h the compiler might complaint for +multiple definition of 'traceid_list'. + +To fix multiple definition error, move the definition of 'traceid_list' +into cs-etm.c. + +Fixes: cd8bfd8c973e ("perf tools: Add processing of coresight metadata") +Reported-by: Thomas Backlund +Signed-off-by: Leo Yan +Reviewed-by: Mathieu Poirier +Reviewed-by: Mike Leach +Tested-by: Mike Leach +Tested-by: Thomas Backlund +Cc: Alexander Shishkin +Cc: Jiri Olsa +Cc: Mark Rutland +Cc: Namhyung Kim +Cc: Peter Zijlstra +Cc: Suzuki Poulouse +Cc: Tor Jeremiassen +Cc: linux-arm-kernel@lists.infradead.org +Link: http://lore.kernel.org/lkml/20200505133642.4756-1-leo.yan@linaro.org +Signed-off-by: Arnaldo Carvalho de Melo +--- + tools/perf/util/cs-etm.c | 3 +++ + tools/perf/util/cs-etm.h | 3 --- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c +index 3d1c34fc4d68..458195a942ec 100644 +--- a/tools/perf/util/cs-etm.c ++++ b/tools/perf/util/cs-etm.c +@@ -90,6 +90,9 @@ struct cs_etm_queue { + struct cs_etm_traceid_queue **traceid_queues; + }; + ++/* RB tree for quick conversion between traceID and metadata pointers */ ++static struct intlist *traceid_list; ++ + static int cs_etm__update_queues(struct cs_etm_auxtrace *etm); + static int cs_etm__process_queues(struct cs_etm_auxtrace *etm); + static int cs_etm__process_timeless_queues(struct cs_etm_auxtrace *etm, +diff --git a/tools/perf/util/cs-etm.h b/tools/perf/util/cs-etm.h +index bc848fd095f4..2b7cd3a741cd 100644 +--- a/tools/perf/util/cs-etm.h ++++ b/tools/perf/util/cs-etm.h +@@ -113,9 +113,6 @@ enum cs_etm_isa { + CS_ETM_ISA_T32, + }; + +-/* RB tree for quick conversion between traceID and metadata pointers */ +-struct intlist *traceid_list; +- + struct cs_etm_queue; + + struct cs_etm_packet { +-- +2.25.1 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.3/0002-perf-tests-bp_account-Make-global-variable-static.patch b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.3/0002-perf-tests-bp_account-Make-global-variable-static.patch new file mode 100644 index 00000000..1a571830 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.3/0002-perf-tests-bp_account-Make-global-variable-static.patch @@ -0,0 +1,43 @@ +Upstream-Status: Backport +Signed-off-by: Ross Burton + +From 30a4e41456dc0d6dcfe55bbf9f5a5302a921b760 Mon Sep 17 00:00:00 2001 +From: Arnaldo Carvalho de Melo +Date: Mon, 2 Mar 2020 11:13:19 -0300 +Subject: [PATCH 2/4] perf tests bp_account: Make global variable static + +To fix the build with newer gccs, that without this patch exit with: + + LD /tmp/build/perf/tests/perf-in.o + ld: /tmp/build/perf/tests/bp_account.o:/git/perf/tools/perf/tests/bp_account.c:22: multiple definition of `the_var'; /tmp/build/perf/tests/bp_signal.o:/git/perf/tools/perf/tests/bp_signal.c:38: first defined here + make[4]: *** [/git/perf/tools/build/Makefile.build:145: /tmp/build/perf/tests/perf-in.o] Error 1 + +First noticed in fedora:rawhide/32 with: + + [perfbuilder@a5ff49d6e6e4 ~]$ gcc --version + gcc (GCC) 10.0.1 20200216 (Red Hat 10.0.1-0.8) + +Reported-by: Jiri Olsa +Cc: Adrian Hunter +Cc: Namhyung Kim +Signed-off-by: Arnaldo Carvalho de Melo +--- + tools/perf/tests/bp_account.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/perf/tests/bp_account.c b/tools/perf/tests/bp_account.c +index 153624e2d0f5..a4c8007d0046 100644 +--- a/tools/perf/tests/bp_account.c ++++ b/tools/perf/tests/bp_account.c +@@ -22,7 +22,7 @@ + #include "perf.h" + #include "cloexec.h" + +-volatile long the_var; ++static volatile long the_var; + + static noinline int test_function(void) + { +-- +2.25.1 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.3/0003-perf-bench-Share-some-global-variables-to-fix-build-.patch b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.3/0003-perf-bench-Share-some-global-variables-to-fix-build-.patch new file mode 100644 index 00000000..77a0fe92 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.3/0003-perf-bench-Share-some-global-variables-to-fix-build-.patch @@ -0,0 +1,240 @@ +Upstream-Status: Backport +Signed-off-by: Ross Burton + +From 6990e5524e8953485723fc9f203a43da26cec800 Mon Sep 17 00:00:00 2001 +From: Arnaldo Carvalho de Melo +Date: Mon, 2 Mar 2020 12:09:38 -0300 +Subject: [PATCH 3/4] perf bench: Share some global variables to fix build with + gcc 10 + +Noticed with gcc 10 (fedora rawhide) that those variables were not being +declared as static, so end up with: + + ld: /tmp/build/perf/bench/epoll-wait.o:/git/perf/tools/perf/bench/epoll-wait.c:93: multiple definition of `end'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here + ld: /tmp/build/perf/bench/epoll-wait.o:/git/perf/tools/perf/bench/epoll-wait.c:93: multiple definition of `start'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here + ld: /tmp/build/perf/bench/epoll-wait.o:/git/perf/tools/perf/bench/epoll-wait.c:93: multiple definition of `runtime'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here + ld: /tmp/build/perf/bench/epoll-ctl.o:/git/perf/tools/perf/bench/epoll-ctl.c:38: multiple definition of `end'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here + ld: /tmp/build/perf/bench/epoll-ctl.o:/git/perf/tools/perf/bench/epoll-ctl.c:38: multiple definition of `start'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here + ld: /tmp/build/perf/bench/epoll-ctl.o:/git/perf/tools/perf/bench/epoll-ctl.c:38: multiple definition of `runtime'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here + make[4]: *** [/git/perf/tools/build/Makefile.build:145: /tmp/build/perf/bench/perf-in.o] Error 1 + +Prefix those with bench__ and add them to bench/bench.h, so that we can +share those on the tools needing to access those variables from signal +handlers. + +Acked-by: Thomas Gleixner +Cc: Adrian Hunter +Cc: Davidlohr Bueso +Cc: Jiri Olsa +Cc: Namhyung Kim +Link: http://lore.kernel.org/lkml/20200303155811.GD13702@kernel.org +Signed-off-by: Arnaldo Carvalho de Melo +--- + tools/perf/bench/bench.h | 4 ++++ + tools/perf/bench/epoll-ctl.c | 7 +++---- + tools/perf/bench/epoll-wait.c | 11 +++++------ + tools/perf/bench/futex-hash.c | 12 ++++++------ + tools/perf/bench/futex-lock-pi.c | 11 +++++------ + 5 files changed, 23 insertions(+), 22 deletions(-) + +diff --git a/tools/perf/bench/bench.h b/tools/perf/bench/bench.h +index fddb3ced9db6..4aa6de1aa67d 100644 +--- a/tools/perf/bench/bench.h ++++ b/tools/perf/bench/bench.h +@@ -2,6 +2,10 @@ + #ifndef BENCH_H + #define BENCH_H + ++#include ++ ++extern struct timeval bench__start, bench__end, bench__runtime; ++ + /* + * The madvise transparent hugepage constants were added in glibc + * 2.13. For compatibility with older versions of glibc, define these +diff --git a/tools/perf/bench/epoll-ctl.c b/tools/perf/bench/epoll-ctl.c +index 2af067859966..8a383c3e0967 100644 +--- a/tools/perf/bench/epoll-ctl.c ++++ b/tools/perf/bench/epoll-ctl.c +@@ -33,7 +33,6 @@ + + static unsigned int nthreads = 0; + static unsigned int nsecs = 8; +-struct timeval start, end, runtime; + static bool done, __verbose, randomize; + + /* +@@ -92,8 +91,8 @@ static void toggle_done(int sig __maybe_unused, + { + /* inform all threads that we're done for the day */ + done = true; +- gettimeofday(&end, NULL); +- timersub(&end, &start, &runtime); ++ gettimeofday(&bench__end, NULL); ++ timersub(&bench__end, &bench__start, &bench__runtime); + } + + static void nest_epollfd(void) +@@ -359,7 +358,7 @@ int bench_epoll_ctl(int argc, const char **argv) + + threads_starting = nthreads; + +- gettimeofday(&start, NULL); ++ gettimeofday(&bench__start, NULL); + + do_threads(worker, cpu); + +diff --git a/tools/perf/bench/epoll-wait.c b/tools/perf/bench/epoll-wait.c +index fe85448abd45..235e3aa28aad 100644 +--- a/tools/perf/bench/epoll-wait.c ++++ b/tools/perf/bench/epoll-wait.c +@@ -88,7 +88,6 @@ + + static unsigned int nthreads = 0; + static unsigned int nsecs = 8; +-struct timeval start, end, runtime; + static bool wdone, done, __verbose, randomize, nonblocking; + + /* +@@ -274,8 +273,8 @@ static void toggle_done(int sig __maybe_unused, + { + /* inform all threads that we're done for the day */ + done = true; +- gettimeofday(&end, NULL); +- timersub(&end, &start, &runtime); ++ gettimeofday(&bench__end, NULL); ++ timersub(&bench__end, &bench__start, &bench__runtime); + } + + static void print_summary(void) +@@ -285,7 +284,7 @@ static void print_summary(void) + + printf("\nAveraged %ld operations/sec (+- %.2f%%), total secs = %d\n", + avg, rel_stddev_stats(stddev, avg), +- (int) runtime.tv_sec); ++ (int)bench__runtime.tv_sec); + } + + static int do_threads(struct worker *worker, struct cpu_map *cpu) +@@ -477,7 +476,7 @@ int bench_epoll_wait(int argc, const char **argv) + + threads_starting = nthreads; + +- gettimeofday(&start, NULL); ++ gettimeofday(&bench__start, NULL); + + do_threads(worker, cpu); + +@@ -517,7 +516,7 @@ int bench_epoll_wait(int argc, const char **argv) + qsort(worker, nthreads, sizeof(struct worker), cmpworker); + + for (i = 0; i < nthreads; i++) { +- unsigned long t = worker[i].ops/runtime.tv_sec; ++ unsigned long t = worker[i].ops / bench__runtime.tv_sec; + + update_stats(&throughput_stats, t); + +diff --git a/tools/perf/bench/futex-hash.c b/tools/perf/bench/futex-hash.c +index a80797763e1f..c7325c5c250a 100644 +--- a/tools/perf/bench/futex-hash.c ++++ b/tools/perf/bench/futex-hash.c +@@ -36,7 +36,7 @@ static unsigned int nfutexes = 1024; + static bool fshared = false, done = false, silent = false; + static int futex_flag = 0; + +-struct timeval start, end, runtime; ++struct timeval bench__start, bench__end, bench__runtime; + static pthread_mutex_t thread_lock; + static unsigned int threads_starting; + static struct stats throughput_stats; +@@ -102,8 +102,8 @@ static void toggle_done(int sig __maybe_unused, + { + /* inform all threads that we're done for the day */ + done = true; +- gettimeofday(&end, NULL); +- timersub(&end, &start, &runtime); ++ gettimeofday(&bench__end, NULL); ++ timersub(&bench__end, &bench__start, &bench__runtime); + } + + static void print_summary(void) +@@ -113,7 +113,7 @@ static void print_summary(void) + + printf("%sAveraged %ld operations/sec (+- %.2f%%), total secs = %d\n", + !silent ? "\n" : "", avg, rel_stddev_stats(stddev, avg), +- (int) runtime.tv_sec); ++ (int)bench__runtime.tv_sec); + } + + int bench_futex_hash(int argc, const char **argv) +@@ -160,7 +160,7 @@ int bench_futex_hash(int argc, const char **argv) + + threads_starting = nthreads; + pthread_attr_init(&thread_attr); +- gettimeofday(&start, NULL); ++ gettimeofday(&bench__start, NULL); + for (i = 0; i < nthreads; i++) { + worker[i].tid = i; + worker[i].futex = calloc(nfutexes, sizeof(*worker[i].futex)); +@@ -203,7 +203,7 @@ int bench_futex_hash(int argc, const char **argv) + pthread_mutex_destroy(&thread_lock); + + for (i = 0; i < nthreads; i++) { +- unsigned long t = worker[i].ops/runtime.tv_sec; ++ unsigned long t = worker[i].ops / bench__runtime.tv_sec; + update_stats(&throughput_stats, t); + if (!silent) { + if (nfutexes == 1) +diff --git a/tools/perf/bench/futex-lock-pi.c b/tools/perf/bench/futex-lock-pi.c +index d02330a69745..54b23fd79b10 100644 +--- a/tools/perf/bench/futex-lock-pi.c ++++ b/tools/perf/bench/futex-lock-pi.c +@@ -36,7 +36,6 @@ static bool silent = false, multi = false; + static bool done = false, fshared = false; + static unsigned int nthreads = 0; + static int futex_flag = 0; +-struct timeval start, end, runtime; + static pthread_mutex_t thread_lock; + static unsigned int threads_starting; + static struct stats throughput_stats; +@@ -63,7 +62,7 @@ static void print_summary(void) + + printf("%sAveraged %ld operations/sec (+- %.2f%%), total secs = %d\n", + !silent ? "\n" : "", avg, rel_stddev_stats(stddev, avg), +- (int) runtime.tv_sec); ++ (int)bench__runtime.tv_sec); + } + + static void toggle_done(int sig __maybe_unused, +@@ -72,8 +71,8 @@ static void toggle_done(int sig __maybe_unused, + { + /* inform all threads that we're done for the day */ + done = true; +- gettimeofday(&end, NULL); +- timersub(&end, &start, &runtime); ++ gettimeofday(&bench__end, NULL); ++ timersub(&bench__end, &bench__start, &bench__runtime); + } + + static void *workerfn(void *arg) +@@ -184,7 +183,7 @@ int bench_futex_lock_pi(int argc, const char **argv) + + threads_starting = nthreads; + pthread_attr_init(&thread_attr); +- gettimeofday(&start, NULL); ++ gettimeofday(&bench__start, NULL); + + create_threads(worker, thread_attr, cpu); + pthread_attr_destroy(&thread_attr); +@@ -210,7 +209,7 @@ int bench_futex_lock_pi(int argc, const char **argv) + pthread_mutex_destroy(&thread_lock); + + for (i = 0; i < nthreads; i++) { +- unsigned long t = worker[i].ops/runtime.tv_sec; ++ unsigned long t = worker[i].ops / bench__runtime.tv_sec; + + update_stats(&throughput_stats, t); + if (!silent) +-- +2.25.1 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.3/0004-libtraceevent-Fix-build-with-binutils-2.35.patch b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.3/0004-libtraceevent-Fix-build-with-binutils-2.35.patch new file mode 100644 index 00000000..88711175 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.3/0004-libtraceevent-Fix-build-with-binutils-2.35.patch @@ -0,0 +1,39 @@ +Upstream-Status: Backport +Signed-off-by: Ross Burton + +From 18fd100d426ea3601dfa6d86b1ee856fe5a02b73 Mon Sep 17 00:00:00 2001 +From: Ben Hutchings +Date: Sat, 25 Jul 2020 02:06:23 +0100 +Subject: [PATCH 4/4] libtraceevent: Fix build with binutils 2.35 + +In binutils 2.35, 'nm -D' changed to show symbol versions along with +symbol names, with the usual @@ separator. When generating +libtraceevent-dynamic-list we need just the names, so strip off the +version suffix if present. + +Signed-off-by: Ben Hutchings +Tested-by: Salvatore Bonaccorso +Reviewed-by: Steven Rostedt +Cc: linux-trace-devel@vger.kernel.org +Cc: stable@vger.kernel.org +Signed-off-by: Arnaldo Carvalho de Melo +--- + tools/lib/traceevent/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile +index a39cdd0d890d..983b674df7c1 100644 +--- a/tools/lib/traceevent/Makefile ++++ b/tools/lib/traceevent/Makefile +@@ -269,7 +269,7 @@ define do_generate_dynamic_list_file + xargs echo "U w W" | tr 'w ' 'W\n' | sort -u | xargs echo`;\ + if [ "$$symbol_type" = "U W" ];then \ + (echo '{'; \ +- $(NM) -u -D $1 | awk 'NF>1 {print "\t"$$2";"}' | sort -u;\ ++ $(NM) -u -D $1 | awk 'NF>1 {sub("@.*", "", $$2); print "\t"$$2";"}' | sort -u;\ + echo '};'; \ + ) > $2; \ + else \ +-- +2.25.1 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.3/0005-perf-Make-perf-able-to-build-with-latest-libbfd.patch b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.3/0005-perf-Make-perf-able-to-build-with-latest-libbfd.patch new file mode 100644 index 00000000..2d1a5e3a --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.3/0005-perf-Make-perf-able-to-build-with-latest-libbfd.patch @@ -0,0 +1,63 @@ +Upstream-Status: Backport +Signed-off-by: Ross Burton + +From 46136d414171bbfed5595774e60ac35ba60d5e3b Mon Sep 17 00:00:00 2001 +From: Changbin Du +Date: Tue, 28 Jan 2020 23:29:38 +0800 +Subject: [PATCH] perf: Make perf able to build with latest libbfd + +libbfd has changed the bfd_section_* macros to inline functions +bfd_section_ since 2019-09-18. See below two commits: + o http://www.sourceware.org/ml/gdb-cvs/2019-09/msg00064.html + o https://www.sourceware.org/ml/gdb-cvs/2019-09/msg00072.html + +This fix make perf able to build with both old and new libbfd. + +Signed-off-by: Changbin Du +Acked-by: Jiri Olsa +Cc: Peter Zijlstra +Link: http://lore.kernel.org/lkml/20200128152938.31413-1-changbin.du@gmail.com +Signed-off-by: Arnaldo Carvalho de Melo +--- + tools/perf/util/srcline.c | 16 +++++++++++++++- + 1 file changed, 15 insertions(+), 1 deletion(-) + +diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c +index 6ccf6f6d09df..5b7d6c16d33f 100644 +--- a/tools/perf/util/srcline.c ++++ b/tools/perf/util/srcline.c +@@ -193,16 +193,30 @@ static void find_address_in_section(bfd *abfd, asection *section, void *data) + bfd_vma pc, vma; + bfd_size_type size; + struct a2l_data *a2l = data; ++ flagword flags; + + if (a2l->found) + return; + +- if ((bfd_get_section_flags(abfd, section) & SEC_ALLOC) == 0) ++#ifdef bfd_get_section_flags ++ flags = bfd_get_section_flags(abfd, section); ++#else ++ flags = bfd_section_flags(section); ++#endif ++ if ((flags & SEC_ALLOC) == 0) + return; + + pc = a2l->addr; ++#ifdef bfd_get_section_vma + vma = bfd_get_section_vma(abfd, section); ++#else ++ vma = bfd_section_vma(section); ++#endif ++#ifdef bfd_get_section_size + size = bfd_get_section_size(section); ++#else ++ size = bfd_section_size(section); ++#endif + + if (pc < vma || pc >= vma + size) + return; +-- +2.25.1 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.6/0001-libtraceevent-Fix-build-with-binutils-2.35.patch b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.6/0001-libtraceevent-Fix-build-with-binutils-2.35.patch new file mode 100644 index 00000000..f44a4b49 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.6/0001-libtraceevent-Fix-build-with-binutils-2.35.patch @@ -0,0 +1,38 @@ +Upstream-Status: Backport +Signed-off-by: Ross Burton + +From c139f8e8dc8a5388f63bf2cf1c17ee114dcdb919 Mon Sep 17 00:00:00 2001 +From: Ben Hutchings +Date: Sat, 25 Jul 2020 02:06:23 +0100 +Subject: [PATCH 1/2] libtraceevent: Fix build with binutils 2.35 + +In binutils 2.35, 'nm -D' changed to show symbol versions along with +symbol names, with the usual @@ separator. When generating +libtraceevent-dynamic-list we need just the names, so strip off the +version suffix if present. + +Signed-off-by: Ben Hutchings +Tested-by: Salvatore Bonaccorso +Reviewed-by: Steven Rostedt +Cc: linux-trace-devel@vger.kernel.org +Cc: stable@vger.kernel.org +Signed-off-by: Arnaldo Carvalho de Melo +--- + tools/lib/traceevent/plugins/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/lib/traceevent/plugins/Makefile b/tools/lib/traceevent/plugins/Makefile +index 349bb81482ab..680d883efe05 100644 +--- a/tools/lib/traceevent/plugins/Makefile ++++ b/tools/lib/traceevent/plugins/Makefile +@@ -197,7 +197,7 @@ define do_generate_dynamic_list_file + xargs echo "U w W" | tr 'w ' 'W\n' | sort -u | xargs echo`;\ + if [ "$$symbol_type" = "U W" ];then \ + (echo '{'; \ +- $(NM) -u -D $1 | awk 'NF>1 {print "\t"$$2";"}' | sort -u;\ ++ $(NM) -u -D $1 | awk 'NF>1 {sub("@.*", "", $$2); print "\t"$$2";"}' | sort -u;\ + echo '};'; \ + ) > $2; \ + else \ +-- +2.25.1 diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.6/0002-perf-cs-etm-Move-definition-of-traceid_list-global-v.patch b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.6/0002-perf-cs-etm-Move-definition-of-traceid_list-global-v.patch new file mode 100644 index 00000000..0e4e362a --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.6/0002-perf-cs-etm-Move-definition-of-traceid_list-global-v.patch @@ -0,0 +1,69 @@ +Upstream-Status: Backport +Signed-off-by: Ross Burton + +From 9e752121f8d4edcde6f3fb466593eeaf6d8306b9 Mon Sep 17 00:00:00 2001 +From: Leo Yan +Date: Tue, 5 May 2020 21:36:42 +0800 +Subject: [PATCH 2/2] perf cs-etm: Move definition of 'traceid_list' global + variable from header file + +The variable 'traceid_list' is defined in the header file cs-etm.h, +if multiple C files include cs-etm.h the compiler might complaint for +multiple definition of 'traceid_list'. + +To fix multiple definition error, move the definition of 'traceid_list' +into cs-etm.c. + +Fixes: cd8bfd8c973e ("perf tools: Add processing of coresight metadata") +Reported-by: Thomas Backlund +Signed-off-by: Leo Yan +Reviewed-by: Mathieu Poirier +Reviewed-by: Mike Leach +Tested-by: Mike Leach +Tested-by: Thomas Backlund +Cc: Alexander Shishkin +Cc: Jiri Olsa +Cc: Mark Rutland +Cc: Namhyung Kim +Cc: Peter Zijlstra +Cc: Suzuki Poulouse +Cc: Tor Jeremiassen +Cc: linux-arm-kernel@lists.infradead.org +Link: http://lore.kernel.org/lkml/20200505133642.4756-1-leo.yan@linaro.org +Signed-off-by: Arnaldo Carvalho de Melo +--- + tools/perf/util/cs-etm.c | 3 +++ + tools/perf/util/cs-etm.h | 3 --- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c +index 5471045ebf5c..4d8efe96015b 100644 +--- a/tools/perf/util/cs-etm.c ++++ b/tools/perf/util/cs-etm.c +@@ -94,6 +94,9 @@ struct cs_etm_queue { + struct cs_etm_traceid_queue **traceid_queues; + }; + ++/* RB tree for quick conversion between traceID and metadata pointers */ ++static struct intlist *traceid_list; ++ + static int cs_etm__update_queues(struct cs_etm_auxtrace *etm); + static int cs_etm__process_queues(struct cs_etm_auxtrace *etm); + static int cs_etm__process_timeless_queues(struct cs_etm_auxtrace *etm, +diff --git a/tools/perf/util/cs-etm.h b/tools/perf/util/cs-etm.h +index 650ecc2a6349..4ad925d6d799 100644 +--- a/tools/perf/util/cs-etm.h ++++ b/tools/perf/util/cs-etm.h +@@ -114,9 +114,6 @@ enum cs_etm_isa { + CS_ETM_ISA_T32, + }; + +-/* RB tree for quick conversion between traceID and metadata pointers */ +-struct intlist *traceid_list; +- + struct cs_etm_queue; + + struct cs_etm_packet { +-- +2.25.1 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.7/coresight-traceid.patch b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.7/coresight-traceid.patch new file mode 100644 index 00000000..f72e59db --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.7/coresight-traceid.patch @@ -0,0 +1,71 @@ +Fix the build with coresight enabled. + +Upstream-Status: Backport +Signed-off-by: Ross Burton + +From d5d9bc542a53b3fa3b0272090b152303cf4a57d9 Mon Sep 17 00:00:00 2001 +From: Leo Yan +Date: Tue, 5 May 2020 21:36:42 +0800 +Subject: [PATCH] perf cs-etm: Move definition of 'traceid_list' global + variable from header file + +The variable 'traceid_list' is defined in the header file cs-etm.h, +if multiple C files include cs-etm.h the compiler might complaint for +multiple definition of 'traceid_list'. + +To fix multiple definition error, move the definition of 'traceid_list' +into cs-etm.c. + +Fixes: cd8bfd8c973e ("perf tools: Add processing of coresight metadata") +Reported-by: Thomas Backlund +Signed-off-by: Leo Yan +Reviewed-by: Mathieu Poirier +Reviewed-by: Mike Leach +Tested-by: Mike Leach +Tested-by: Thomas Backlund +Cc: Alexander Shishkin +Cc: Jiri Olsa +Cc: Mark Rutland +Cc: Namhyung Kim +Cc: Peter Zijlstra +Cc: Suzuki Poulouse +Cc: Tor Jeremiassen +Cc: linux-arm-kernel@lists.infradead.org +Link: http://lore.kernel.org/lkml/20200505133642.4756-1-leo.yan@linaro.org +Signed-off-by: Arnaldo Carvalho de Melo +--- + tools/perf/util/cs-etm.c | 3 +++ + tools/perf/util/cs-etm.h | 3 --- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c +index 62d2f9b9ce1b..381d9708e9bd 100644 +--- a/tools/perf/util/cs-etm.c ++++ b/tools/perf/util/cs-etm.c +@@ -94,6 +94,9 @@ struct cs_etm_queue { + struct cs_etm_traceid_queue **traceid_queues; + }; + ++/* RB tree for quick conversion between traceID and metadata pointers */ ++static struct intlist *traceid_list; ++ + static int cs_etm__update_queues(struct cs_etm_auxtrace *etm); + static int cs_etm__process_queues(struct cs_etm_auxtrace *etm); + static int cs_etm__process_timeless_queues(struct cs_etm_auxtrace *etm, +diff --git a/tools/perf/util/cs-etm.h b/tools/perf/util/cs-etm.h +index 650ecc2a6349..4ad925d6d799 100644 +--- a/tools/perf/util/cs-etm.h ++++ b/tools/perf/util/cs-etm.h +@@ -114,9 +114,6 @@ enum cs_etm_isa { + CS_ETM_ISA_T32, + }; + +-/* RB tree for quick conversion between traceID and metadata pointers */ +-struct intlist *traceid_list; +- + struct cs_etm_queue; + + struct cs_etm_packet { +-- +2.25.1 + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.7/defconfig.patch b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.7/defconfig.patch new file mode 100644 index 00000000..71b1b1ed --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.7/defconfig.patch @@ -0,0 +1,112 @@ +Change USB_CONN_GPIO to 'y' by default and regenerate the defconfig via +`make savedefconfig`. + +Upstream-Status: Inappropriate [not needed in newer kernels] +Signed-off-by: Jon Mason + +diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig +index 03d0189f7d68..a4baafe01c34 100644 +--- a/arch/arm64/configs/defconfig ++++ b/arch/arm64/configs/defconfig +@@ -165,9 +165,9 @@ CONFIG_QRTR_SMD=m + CONFIG_QRTR_TUN=m + CONFIG_BPF_JIT=y + CONFIG_CAN=m ++CONFIG_CAN_FLEXCAN=m + CONFIG_CAN_RCAR=m + CONFIG_CAN_RCAR_CANFD=m +-CONFIG_CAN_FLEXCAN=m + CONFIG_BT=m + CONFIG_BT_HIDP=m + # CONFIG_BT_HS is not set +@@ -202,20 +202,19 @@ CONFIG_PCI_HOST_THUNDER_ECAM=y + CONFIG_PCIE_ROCKCHIP_HOST=m + CONFIG_PCIE_BRCMSTB=m + CONFIG_PCI_LAYERSCAPE=y +-CONFIG_PCIE_LAYERSCAPE_GEN4=y + CONFIG_PCI_HISI=y + CONFIG_PCIE_QCOM=y + CONFIG_PCIE_ARMADA_8K=y + CONFIG_PCIE_KIRIN=y + CONFIG_PCIE_HISI_STB=y + CONFIG_PCIE_TEGRA194_HOST=m ++CONFIG_PCIE_LAYERSCAPE_GEN4=y + CONFIG_DEVTMPFS=y + CONFIG_DEVTMPFS_MOUNT=y + CONFIG_FW_LOADER_USER_HELPER=y + CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y + CONFIG_HISILICON_LPC=y + CONFIG_SIMPLE_PM_BUS=y +-CONFIG_FSL_MC_BUS=y + CONFIG_MTD=y + CONFIG_MTD_BLOCK=y + CONFIG_MTD_CFI=y +@@ -494,10 +493,10 @@ CONFIG_SENSORS_INA3221=m + CONFIG_THERMAL_GOV_POWER_ALLOCATOR=y + CONFIG_CPU_THERMAL=y + CONFIG_THERMAL_EMULATION=y +-CONFIG_QORIQ_THERMAL=m +-CONFIG_SUN8I_THERMAL=y + CONFIG_IMX_SC_THERMAL=m + CONFIG_IMX8MM_THERMAL=m ++CONFIG_QORIQ_THERMAL=m ++CONFIG_SUN8I_THERMAL=y + CONFIG_ROCKCHIP_THERMAL=m + CONFIG_RCAR_THERMAL=y + CONFIG_RCAR_GEN3_THERMAL=y +@@ -567,7 +566,6 @@ CONFIG_MEDIA_DIGITAL_TV_SUPPORT=y + CONFIG_MEDIA_SDR_SUPPORT=y + CONFIG_MEDIA_CONTROLLER=y + CONFIG_VIDEO_V4L2_SUBDEV_API=y +-CONFIG_MEDIA_PLATFORM_SUPPORT=y + # CONFIG_DVB_NET is not set + CONFIG_MEDIA_USB_SUPPORT=y + CONFIG_USB_VIDEO_CLASS=m +@@ -611,10 +609,10 @@ CONFIG_DRM_MSM=m + CONFIG_DRM_TEGRA=m + CONFIG_DRM_PANEL_LVDS=m + CONFIG_DRM_PANEL_SIMPLE=m +-CONFIG_DRM_SIMPLE_BRIDGE=m + CONFIG_DRM_PANEL_TRULY_NT35597_WQXGA=m + CONFIG_DRM_DISPLAY_CONNECTOR=m + CONFIG_DRM_SII902X=m ++CONFIG_DRM_SIMPLE_BRIDGE=m + CONFIG_DRM_THINE_THC63LVD1024=m + CONFIG_DRM_TI_SN65DSI86=m + CONFIG_DRM_I2C_ADV7511=m +@@ -662,7 +660,6 @@ CONFIG_SND_SOC_WSA881X=m + CONFIG_SND_SIMPLE_CARD=m + CONFIG_SND_AUDIO_GRAPH_CARD=m + CONFIG_I2C_HID=m +-CONFIG_USB_CONN_GPIO=m + CONFIG_USB=y + CONFIG_USB_OTG=y + CONFIG_USB_XHCI_HCD=y +@@ -797,14 +794,13 @@ CONFIG_QCOM_A53PLL=y + CONFIG_QCOM_CLK_APCS_MSM8916=y + CONFIG_QCOM_CLK_SMD_RPM=y + CONFIG_QCOM_CLK_RPMH=y +-CONFIG_IPQ_GCC_8074=y + CONFIG_IPQ_GCC_6018=y ++CONFIG_IPQ_GCC_8074=y + CONFIG_MSM_GCC_8916=y + CONFIG_MSM_GCC_8994=y + CONFIG_MSM_MMCC_8996=y + CONFIG_MSM_GCC_8998=y + CONFIG_QCS_GCC_404=y +-CONFIG_SDM_GCC_845=y + CONFIG_SDM_GPUCC_845=y + CONFIG_SDM_DISPCC_845=y + CONFIG_SM_GCC_8150=y +@@ -933,10 +929,10 @@ CONFIG_FPGA_REGION=m + CONFIG_OF_FPGA_REGION=m + CONFIG_TEE=y + CONFIG_OPTEE=y ++CONFIG_MUX_MMIO=y + CONFIG_SLIMBUS=m + CONFIG_SLIM_QCOM_CTRL=m + CONFIG_SLIM_QCOM_NGD_CTRL=m +-CONFIG_MUX_MMIO=y + CONFIG_EXT2_FS=y + CONFIG_EXT3_FS=y + CONFIG_EXT4_FS_POSIX_ACL=y diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-stable-corstone700.inc b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-corstone700.inc similarity index 92% rename from meta-arm-bsp/recipes-kernel/linux/linux-stable-corstone700.inc rename to meta-arm-bsp/recipes-kernel/linux/linux-yocto-corstone700.inc index 975a93f7..f2a9a54c 100644 --- a/meta-arm-bsp/recipes-kernel/linux/linux-stable-corstone700.inc +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-corstone700.inc @@ -1,13 +1,5 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/files/corstone700:" -# including linux-yocto.inc to use configuration fragments -require recipes-kernel/linux/linux-yocto.inc - -LINUX_VMAJOR = "5" -LINUX_VMINOR = "6" -LINUX_VPATCH = "14" -LINUX_SRCREV = "e3ac9117b18596b7363d5b7904ab03a7d782b40c" - COMPATIBLE_MACHINE = "${MACHINE}" KMACHINE = "corstone700" @@ -39,7 +31,6 @@ KERNEL_IMAGETYPE = "xipImage" KCONFIG_MODE = "--alldefconfig" -KMETA = "arm-platforms-kmeta" SRC_URI_append = " ${SRC_URI_KMETA}" KERNEL_EXTRA_FEATURES = "bsp/arm-platforms/corstone700-bsp.scc" diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto_5.3%.bbappend b/meta-arm-bsp/recipes-kernel/linux/linux-yocto_5.3%.bbappend new file mode 100644 index 00000000..f931d7d1 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto_5.3%.bbappend @@ -0,0 +1,8 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/linux-yocto-5.3:" + +SRC_URI_append = " file://0001-perf-cs-etm-Move-definition-of-traceid_list-global-v.patch \ + file://0002-perf-tests-bp_account-Make-global-variable-static.patch \ + file://0003-perf-bench-Share-some-global-variables-to-fix-build-.patch \ + file://0004-libtraceevent-Fix-build-with-binutils-2.35.patch \ + file://0005-perf-Make-perf-able-to-build-with-latest-libbfd.patch \ + " diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto_5.3.bb b/meta-arm-bsp/recipes-kernel/linux/linux-yocto_5.3.bb new file mode 100644 index 00000000..9d5e9ce8 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto_5.3.bb @@ -0,0 +1,15 @@ +KBRANCH = "v5.3/base" + +require recipes-kernel/linux/linux-yocto.inc + +SRCREV_machine = "d4f3318ed8fab6316cb7a269b8f42306632a3876" +SRCREV_meta = "8d0ed83a864cc91eef4d2abbc90f13d4ecd1c213" + +SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;name=machine;branch=${KBRANCH}; \ + git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-5.4;destsuffix=${KMETA}" + +LINUX_VERSION = "5.3.18" +LIC_FILES_CHKSUM = "file://COPYING;md5=bbea815ee2795b2f4230826c0c6b8814" + +PV = "${LINUX_VERSION}+git${SRCPV}" +KMETA = "kernel-meta" diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto_5.6%.bbappend b/meta-arm-bsp/recipes-kernel/linux/linux-yocto_5.6%.bbappend new file mode 100644 index 00000000..c4c55ad1 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto_5.6%.bbappend @@ -0,0 +1,12 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/linux-yocto-5.6:" + +SRC_URI_append = " file://0001-libtraceevent-Fix-build-with-binutils-2.35.patch \ + file://0002-perf-cs-etm-Move-definition-of-traceid_list-global-v.patch" + +# +# Corstone700 KMACHINE +# +MACHINE_KERNEL_REQUIRE ?= "" +MACHINE_KERNEL_REQUIRE_corstone700 = "linux-yocto-corstone700.inc" + +require ${MACHINE_KERNEL_REQUIRE} diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto_5.6.bb b/meta-arm-bsp/recipes-kernel/linux/linux-yocto_5.6.bb new file mode 100644 index 00000000..d17cb308 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto_5.6.bb @@ -0,0 +1,15 @@ +KBRANCH = "v5.6/base" + +require recipes-kernel/linux/linux-yocto.inc + +SRCREV_machine = "e3ac9117b18596b7363d5b7904ab03a7d782b40c" +SRCREV_meta = "b152cd93ea7046a835c869a76085aefdb6ce7421" + +SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;name=machine;branch=${KBRANCH}; \ + git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-5.6;destsuffix=${KMETA}" + +LINUX_VERSION = "5.6.14" +LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46" + +PV = "${LINUX_VERSION}+git${SRCPV}" +KMETA = "kernel-meta" diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto_5.7%.bbappend b/meta-arm-bsp/recipes-kernel/linux/linux-yocto_5.7%.bbappend new file mode 100644 index 00000000..607a50e5 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto_5.7%.bbappend @@ -0,0 +1,5 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/linux-yocto-5.7:" + +SRC_URI_append = " file://coresight-traceid.patch \ + file://defconfig.patch \ + " diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto_5.7.bb b/meta-arm-bsp/recipes-kernel/linux/linux-yocto_5.7.bb new file mode 100644 index 00000000..12eaa592 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto_5.7.bb @@ -0,0 +1,16 @@ +KBRANCH = "v5.7/base" + +require recipes-kernel/linux/linux-yocto.inc + +SRCREV_machine = "6b9830fecd4a87d7ebb4d93484fef00f46d0fa0f" +SRCREV_meta = "b9e6fd082dc5bfb51699809d7119d4b20d280c0b" + +SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;name=machine;branch=${KBRANCH}; \ + git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-5.7;destsuffix=${KMETA}" + +LINUX_VERSION = "5.7.19" +LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46" + +PV = "${LINUX_VERSION}+git${SRCPV}" +KMETA = "kernel-meta" + diff --git a/meta-arm-bsp/recipes-security/optee/files/optee-client/tc0/0001-Revert-libteec-Avoid-memcpy-when-using-TEEC_TempMemo.patch b/meta-arm-bsp/recipes-security/optee/files/optee-client/tc0/0001-Revert-libteec-Avoid-memcpy-when-using-TEEC_TempMemo.patch new file mode 100644 index 00000000..4515c1d6 --- /dev/null +++ b/meta-arm-bsp/recipes-security/optee/files/optee-client/tc0/0001-Revert-libteec-Avoid-memcpy-when-using-TEEC_TempMemo.patch @@ -0,0 +1,52 @@ +Upstream-Status: Pending [https://github.com/jenswi-linaro/optee_client/commit/7e569bdf770f635c5de1f4e659d41039a6199a0b] +Signed-off-by: Arunachalam Ganapathy + +From 7e569bdf770f635c5de1f4e659d41039a6199a0b Mon Sep 17 00:00:00 2001 +From: Jens Wiklander +Date: Wed, 11 Nov 2020 10:09:38 +0100 +Subject: [PATCH 1/2] Revert "libteec: Avoid memcpy() when using + TEEC_TempMemoryReference" + +This reverts commit dcb13e2f457fa98e9ba49dd2a364542680671e95. +--- + libteec/src/tee_client_api.c | 14 ++++---------- + 1 file changed, 4 insertions(+), 10 deletions(-) + +diff --git a/libteec/src/tee_client_api.c b/libteec/src/tee_client_api.c +index 6b81e09..b8ccdfa 100644 +--- a/libteec/src/tee_client_api.c ++++ b/libteec/src/tee_client_api.c +@@ -217,15 +217,11 @@ static TEEC_Result teec_pre_process_tmpref(TEEC_Context *ctx, + MEMREF_SHM_ID(param) = shm->id; + } + } else { +- shm->buffer = tmpref->buffer; +- res = TEEC_RegisterSharedMemory(ctx, shm); ++ res = TEEC_AllocateSharedMemory(ctx, shm); + if (res != TEEC_SUCCESS) + return res; + +- if (shm->shadow_buffer) +- memcpy(shm->shadow_buffer, tmpref->buffer, +- tmpref->size); +- ++ memcpy(shm->buffer, tmpref->buffer, tmpref->size); + MEMREF_SHM_ID(param) = shm->id; + } + +@@ -388,10 +384,8 @@ static void teec_post_process_tmpref(uint32_t param_type, + TEEC_SharedMemory *shm) + { + if (param_type != TEEC_MEMREF_TEMP_INPUT) { +- if (MEMREF_SIZE(param) <= tmpref->size && tmpref->buffer && +- shm->shadow_buffer) +- memcpy(tmpref->buffer, shm->shadow_buffer, +- MEMREF_SIZE(param)); ++ if (MEMREF_SIZE(param) <= tmpref->size && tmpref->buffer) ++ memcpy(tmpref->buffer, shm->buffer, MEMREF_SIZE(param)); + + tmpref->size = MEMREF_SIZE(param); + } +-- +2.26.2 + diff --git a/meta-arm-bsp/recipes-security/optee/files/optee-client/tc0/0002-Allocate-page-aligned-shared-memory-buffers.patch b/meta-arm-bsp/recipes-security/optee/files/optee-client/tc0/0002-Allocate-page-aligned-shared-memory-buffers.patch new file mode 100644 index 00000000..5928bfd5 --- /dev/null +++ b/meta-arm-bsp/recipes-security/optee/files/optee-client/tc0/0002-Allocate-page-aligned-shared-memory-buffers.patch @@ -0,0 +1,95 @@ +Upstream-Status: Pending [https://github.com/jenswi-linaro/optee_client/commit/7a67f8b7681ecf3abb5b09e5e320857d16f4a7e6] +Signed-off-by: Arunachalam Ganapathy + +From 7a67f8b7681ecf3abb5b09e5e320857d16f4a7e6 Mon Sep 17 00:00:00 2001 +From: Jens Wiklander +Date: Mon, 16 Nov 2020 17:34:07 +0100 +Subject: [PATCH 2/2] Allocate page aligned shared memory buffers + +Allocate page aligned shared memory buffer guarantee that each shared +memory buffer doesn't accidentally share a page of memory or they may +become aliased when mapped in secure world. This is normally not a big +problem but may make it a bit harder to track down buffer overruns in +shared memory buffers. + +In a post Arm v8.4 architecture with FF-A [1] there's trouble since it's +not permitted to share the same physical page twice. + +Signed-off-by: Jens Wiklander +--- + libteec/src/tee_client_api.c | 14 ++++++++++++-- + tee-supplicant/src/tee_supplicant.c | 12 +++++++++++- + 2 files changed, 23 insertions(+), 3 deletions(-) + +diff --git a/libteec/src/tee_client_api.c b/libteec/src/tee_client_api.c +index b8ccdfa..676d373 100644 +--- a/libteec/src/tee_client_api.c ++++ b/libteec/src/tee_client_api.c +@@ -74,6 +74,16 @@ static void teec_mutex_unlock(pthread_mutex_t *mu) + pthread_mutex_unlock(mu); + } + ++static void *teec_paged_aligned_alloc(size_t sz) ++{ ++ void *p = NULL; ++ ++ if (!posix_memalign(&p, sysconf(_SC_PAGESIZE), sz)) ++ return p; ++ ++ return NULL; ++} ++ + static int teec_open_dev(const char *devname, const char *capabilities, + uint32_t *gen_caps) + { +@@ -790,7 +800,7 @@ TEEC_Result TEEC_RegisterSharedMemory(TEEC_Context *ctx, TEEC_SharedMemory *shm) + * we're not making matters worse by trying to allocate and + * register a shadow buffer before giving up. + */ +- shm->shadow_buffer = malloc(s); ++ shm->shadow_buffer = teec_paged_aligned_alloc(s); + if (!shm->shadow_buffer) + return TEEC_ERROR_OUT_OF_MEMORY; + fd = teec_shm_register(ctx->fd, shm->shadow_buffer, s, +@@ -873,7 +883,7 @@ TEEC_Result TEEC_AllocateSharedMemory(TEEC_Context *ctx, TEEC_SharedMemory *shm) + s = 8; + + if (ctx->reg_mem) { +- shm->buffer = malloc(s); ++ shm->buffer = teec_paged_aligned_alloc(s); + if (!shm->buffer) + return TEEC_ERROR_OUT_OF_MEMORY; + +diff --git a/tee-supplicant/src/tee_supplicant.c b/tee-supplicant/src/tee_supplicant.c +index 94cf382..d590c2b 100644 +--- a/tee-supplicant/src/tee_supplicant.c ++++ b/tee-supplicant/src/tee_supplicant.c +@@ -127,6 +127,16 @@ static size_t num_waiters_dec(struct thread_arg *arg) + return ret; + } + ++static void *paged_aligned_alloc(size_t sz) ++{ ++ void *p = NULL; ++ ++ if (!posix_memalign(&p, sysconf(_SC_PAGESIZE), sz)) ++ return p; ++ ++ return NULL; ++} ++ + static int get_value(size_t num_params, struct tee_ioctl_param *params, + const uint32_t idx, struct param_value **value) + { +@@ -336,7 +346,7 @@ static struct tee_shm *register_local_shm(int fd, size_t size) + + memset(&data, 0, sizeof(data)); + +- buf = malloc(size); ++ buf = paged_aligned_alloc(size); + if (!buf) + return NULL; + +-- +2.26.2 + diff --git a/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0001-core-SPMC-update-for-FF-A-version-1.0.patch b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0001-core-SPMC-update-for-FF-A-version-1.0.patch new file mode 100644 index 00000000..d3b23193 --- /dev/null +++ b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0001-core-SPMC-update-for-FF-A-version-1.0.patch @@ -0,0 +1,50 @@ +Upstream-Status: Pending [https://github.com/jenswi-linaro/optee_os/commit/7c3b052b871420618a08402f626923fe85a139db] +Signed-off-by: Arunachalam Ganapathy + +From 7c3b052b871420618a08402f626923fe85a139db Mon Sep 17 00:00:00 2001 +From: Marc Bonnici +Date: Wed, 23 Sep 2020 13:55:22 +0100 +Subject: [PATCH 1/3] core: SPMC: update for FF-A version 1.0 + +Update expected memory attributes. As per the FF-A spec (5.11.3) a +lender of a memory region should not specify the instruction access +permission, therefore update the expected memory attribute. + +Updates the version number to 1.0 replacing the previous version number +0.9. +--- + core/arch/arm/include/optee_ffa.h | 4 ++-- + core/arch/arm/kernel/thread_spmc.c | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/core/arch/arm/include/optee_ffa.h b/core/arch/arm/include/optee_ffa.h +index 8498fbab..9daca732 100644 +--- a/core/arch/arm/include/optee_ffa.h ++++ b/core/arch/arm/include/optee_ffa.h +@@ -27,8 +27,8 @@ + * w3-w7: Implementation defined, free to be used below + */ + +-#define OPTEE_FFA_VERSION_MAJOR UINT32_C(0) +-#define OPTEE_FFA_VERSION_MINOR UINT32_C(9) ++#define OPTEE_FFA_VERSION_MAJOR UINT32_C(1) ++#define OPTEE_FFA_VERSION_MINOR UINT32_C(0) + + #define OPTEE_FFA_BLOCKING_CALL(id) UINT32_C(id) + #define OPTEE_FFA_YIELDING_CALL_BIT 31 +diff --git a/core/arch/arm/kernel/thread_spmc.c b/core/arch/arm/kernel/thread_spmc.c +index 81edf03a..16f3bbe1 100644 +--- a/core/arch/arm/kernel/thread_spmc.c ++++ b/core/arch/arm/kernel/thread_spmc.c +@@ -433,7 +433,7 @@ static int mem_share_init(void *buf, size_t blen, unsigned int *page_count, + { + struct mem_region_descr *region_descr = NULL; + struct mem_transaction_descr *descr = NULL; +- const uint8_t exp_mem_acc_perm = 0x6; /* Not executable, Read-write */ ++ const uint8_t exp_mem_acc_perm = 0x2; /* Read-write */ + /* Normal memory, Write-Back cacheable, Inner shareable */ + const uint8_t exp_mem_reg_attr = 0x2f; + unsigned int num_mem_accs = 0; +-- +2.26.2 + diff --git a/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0002-core-add-thread_smccc.patch b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0002-core-add-thread_smccc.patch new file mode 100644 index 00000000..32a420ef --- /dev/null +++ b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0002-core-add-thread_smccc.patch @@ -0,0 +1,89 @@ +Upstream-Status: Pending [https://github.com/jenswi-linaro/optee_os/commit/269e226eea2b2f26a6f844b7d25bc2b2a9b26315] +Signed-off-by: Arunachalam Ganapathy + +From 269e226eea2b2f26a6f844b7d25bc2b2a9b26315 Mon Sep 17 00:00:00 2001 +From: Jens Wiklander +Date: Tue, 4 Feb 2020 17:30:55 +0100 +Subject: [PATCH 2/3] core: add thread_smccc() + +Adds the assembly function thread_smccc() which loads the first 8 +registers with the argument and executes an SMC or HVC instruction as +appropriate. The result in the first 8 registers is then saved in the +argument struct. + +Change-Id: Ie14154fb38de5ced3cfdebdb0bf19e48caaf2279 +Signed-off-by: Jens Wiklander +--- + core/arch/arm/include/kernel/thread.h | 1 + + core/arch/arm/kernel/thread_a32.S | 16 ++++++++++++++++ + core/arch/arm/kernel/thread_a64.S | 15 +++++++++++++++ + 3 files changed, 32 insertions(+) + +diff --git a/core/arch/arm/include/kernel/thread.h b/core/arch/arm/include/kernel/thread.h +index b9c0ba4b..4f0520e9 100644 +--- a/core/arch/arm/include/kernel/thread.h ++++ b/core/arch/arm/include/kernel/thread.h +@@ -704,6 +704,7 @@ uint32_t thread_rpc_cmd(uint32_t cmd, size_t num_params, + + unsigned long thread_smc(unsigned long func_id, unsigned long a1, + unsigned long a2, unsigned long a3); ++void thread_smccc(struct thread_smc_args *arg_res); + + /** + * Allocate data for payload buffers. +diff --git a/core/arch/arm/kernel/thread_a32.S b/core/arch/arm/kernel/thread_a32.S +index 199e90a9..75d85c32 100644 +--- a/core/arch/arm/kernel/thread_a32.S ++++ b/core/arch/arm/kernel/thread_a32.S +@@ -210,6 +210,22 @@ FUNC thread_smc , : + bx lr + END_FUNC thread_smc + ++/* void thread_smccc(struct thread_smc_args *arg_res) */ ++FUNC thread_smccc , : ++ push {r4-r7} ++ push {r0, lr} ++ ldm r0, {r0-r7} ++#ifdef CFG_CORE_SEL2_SPMC ++ hvc #0 ++#else ++ smc #0 ++#endif ++ pop {r12, lr} ++ stm r12, {r0-r7} ++ pop {r4-r7} ++ bx lr ++END_FUNC thread_smccc ++ + FUNC thread_init_vbar , : + /* Set vector (VBAR) */ + write_vbar r0 +diff --git a/core/arch/arm/kernel/thread_a64.S b/core/arch/arm/kernel/thread_a64.S +index 9ce31eb2..3e0f5115 100644 +--- a/core/arch/arm/kernel/thread_a64.S ++++ b/core/arch/arm/kernel/thread_a64.S +@@ -65,6 +65,21 @@ FUNC thread_smc , : + ret + END_FUNC thread_smc + ++/* void thread_smccc(struct thread_smc_args *arg_res) */ ++FUNC thread_smccc , : ++ push x0, xzr ++ mov x8, x0 ++ load_xregs x8, 0, 0, 7 ++#ifdef CFG_CORE_SEL2_SPMC ++ hvc #0 ++#else ++ smc #0 ++#endif ++ pop x8, xzr ++ store_xregs x8, 0, 0, 7 ++ ret ++END_FUNC thread_smccc ++ + FUNC thread_init_vbar , : + msr vbar_el1, x0 + ret +-- +2.26.2 + diff --git a/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0003-core-enable-SPCI-with-SPM-Core-at-S-EL2.patch b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0003-core-enable-SPCI-with-SPM-Core-at-S-EL2.patch new file mode 100644 index 00000000..c3967dcf --- /dev/null +++ b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0003-core-enable-SPCI-with-SPM-Core-at-S-EL2.patch @@ -0,0 +1,623 @@ +Upstream-Status: Pending [https://github.com/jenswi-linaro/optee_os/commit/80f0ec4ba2af33584e99e917fa165b77028a511f] +Signed-off-by: Arunachalam Ganapathy + +From 80f0ec4ba2af33584e99e917fa165b77028a511f Mon Sep 17 00:00:00 2001 +From: Marc Bonnici +Date: Fri, 5 Jun 2020 13:47:40 +0100 +Subject: [PATCH 3/3] core: enable SPCI with SPM Core at S-EL2 + +This is a port of a pre-exisiting patch to support the case where +the SPM Core is implementation at S-EL2, that is, in a secure hypervisor. +This configuration is also know as "S-EL2 SPMC" in the FFA specification. + +Compile with CFG_CORE_SEL2_SPMC=y + +Note that this is an experimental feature, ABIs etc may have +incompatible changes. + +Sqaushed in: + core: Update cookie to uint64 in S-EL2 code + + As part of the update to FF-A 1.0 the globally + unique handle to identify a shared memory object is now 64 + bits wide instead of 32. This commit updates the + remaining usage of 32 bit values. + + core: Remove page count from S-EL2 code + + The page count field has been dropped from upstream OP-TEE to + accommodate using a 64 bit handle in the same size message param struct, + therefore update our implementation to support this. + + core: Update remaining FF-A structures to EAC + + Update relinquish data structures and ABI invocations to the FFA + EAC spec +--- + core/arch/arm/arm.mk | 7 ++ + core/arch/arm/include/kernel/thread.h | 6 + + core/arch/arm/include/mm/mobj.h | 6 + + core/arch/arm/kernel/thread_spmc.c | 164 ++++++++++++++++++++++++- + core/arch/arm/kernel/thread_spmc_a64.S | 3 +- + core/arch/arm/mm/mobj_ffa.c | 104 +++++++++++----- + core/arch/arm/plat-vexpress/conf.mk | 5 + + 7 files changed, 260 insertions(+), 35 deletions(-) + +diff --git a/core/arch/arm/arm.mk b/core/arch/arm/arm.mk +index f495f3c9..7c5e8fb0 100644 +--- a/core/arch/arm/arm.mk ++++ b/core/arch/arm/arm.mk +@@ -97,6 +97,13 @@ endif + # changes + ifeq ($(CFG_CORE_SEL1_SPMC),y) + $(call force,CFG_CORE_FFA,y) ++$(call force,CFG_CORE_SEL2_SPMC,n) ++endif ++# SPMC configuration "S-EL2 SPMC" where SPM Core is implemented at S-EL2, ++# that is, the hypervisor sandboxing OP-TEE ++ifeq ($(CFG_CORE_SEL2_SPMC),y) ++$(call force,CFG_CORE_FFA,y) ++$(call force,CFG_CORE_SEL1_SPMC,n) + endif + + # Unmaps all kernel mode code except the code needed to take exceptions +diff --git a/core/arch/arm/include/kernel/thread.h b/core/arch/arm/include/kernel/thread.h +index 4f0520e9..95f48589 100644 +--- a/core/arch/arm/include/kernel/thread.h ++++ b/core/arch/arm/include/kernel/thread.h +@@ -759,6 +759,12 @@ enum thread_shm_cache_user { + void *thread_rpc_shm_cache_alloc(enum thread_shm_cache_user user, + enum thread_shm_type shm_type, + size_t size, struct mobj **mobj); ++ ++#if defined(CFG_CORE_SEL2_SPMC) ++struct mobj_ffa *thread_spmc_populate_mobj_from_rx(uint64_t cookie); ++void thread_spmc_relinquish(uint64_t memory_region_handle); ++#endif ++ + #endif /*__ASSEMBLER__*/ + + #endif /*KERNEL_THREAD_H*/ +diff --git a/core/arch/arm/include/mm/mobj.h b/core/arch/arm/include/mm/mobj.h +index 2b9bd90c..3f820666 100644 +--- a/core/arch/arm/include/mm/mobj.h ++++ b/core/arch/arm/include/mm/mobj.h +@@ -216,6 +216,12 @@ struct mobj_ffa *mobj_ffa_sel1_spmc_new(unsigned int num_pages); + void mobj_ffa_sel1_spmc_delete(struct mobj_ffa *mobj); + TEE_Result mobj_ffa_sel1_spmc_reclaim(uint64_t cookie); + #endif ++#ifdef CFG_CORE_SEL2_SPMC ++struct mobj_ffa *mobj_ffa_sel2_spmc_new(uint64_t cookie, ++ unsigned int num_pages); ++void mobj_ffa_sel2_spmc_delete(struct mobj_ffa *mobj); ++#endif ++ + uint64_t mobj_ffa_get_cookie(struct mobj_ffa *mobj); + TEE_Result mobj_ffa_add_pages_at(struct mobj_ffa *mobj, unsigned int *idx, + paddr_t pa, unsigned int num_pages); +diff --git a/core/arch/arm/kernel/thread_spmc.c b/core/arch/arm/kernel/thread_spmc.c +index 16f3bbe1..3d7dc035 100644 +--- a/core/arch/arm/kernel/thread_spmc.c ++++ b/core/arch/arm/kernel/thread_spmc.c +@@ -7,6 +7,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -88,6 +89,18 @@ struct mem_frag_state { + + static uint16_t my_sp_id = 0x8001; + ++ ++/* Table 149: FFA_MEM_RELINQUISH. */ ++struct ffa_relinquish_descriptor { ++ uint64_t handle; ++ uint32_t flags; ++ uint32_t endpoint_count; ++ uint16_t endpoint_id_array[]; ++}; ++ ++/* Our VM ID is 0x8001, non-secure VM ID 0x0001 */ ++const uint32_t thread_spmc_target_info = 0x80010001; ++ + /* + * If @rxtx_size is 0 RX/TX buffers are not mapped or initialized. + * +@@ -101,8 +114,16 @@ static uint16_t my_sp_id = 0x8001; + * these buffers so we must always be careful when reading. while we hold + * the lock. + */ ++ ++#ifdef CFG_CORE_SEL2_SPMC ++static uint8_t rx_buf[SMALL_PAGE_SIZE] __aligned(SMALL_PAGE_SIZE); ++static uint8_t tx_buf[SMALL_PAGE_SIZE] __aligned(SMALL_PAGE_SIZE); ++#else + static void *rx_buf; + static void *tx_buf; ++#endif ++ ++ + static unsigned int rxtx_size; + static unsigned int rxtx_spinlock; + static bool tx_buf_is_mine; +@@ -127,6 +148,28 @@ static void set_args(struct thread_smc_args *args, uint32_t fid, + .a5 = w5, }; + } + ++static int __maybe_unused ++set_pages(struct constituent_address_range *regions, unsigned int num_regions, ++ unsigned int num_pages, struct mobj_ffa *mf) ++{ ++ unsigned int n = 0; ++ unsigned int idx = 0; ++ ++ for (n = 0; n < num_regions; n++) { ++ unsigned int page_count = READ_ONCE(regions[n].page_count); ++ uint64_t addr = READ_ONCE(regions[n].address); ++ ++ if (mobj_ffa_add_pages_at(mf, &idx, addr, page_count)) ++ return FFA_INVALID_PARAMETERS; ++ } ++ ++ if (idx != num_pages) ++ return FFA_INVALID_PARAMETERS; ++ ++ return 0; ++} ++ ++ + static void handle_version(struct thread_smc_args *args) + { + /* +@@ -188,6 +231,7 @@ static void handle_features(struct thread_smc_args *args) + FFA_PARAM_MBZ, FFA_PARAM_MBZ, FFA_PARAM_MBZ); + } + ++#ifdef CFG_CORE_SEL1_SPMC + static int map_buf(paddr_t pa, unsigned int sz, void **va_ret) + { + tee_mm_entry_t *mm = NULL; +@@ -293,6 +337,7 @@ out: + set_args(args, ret_fid, FFA_PARAM_MBZ, rc, + FFA_PARAM_MBZ, FFA_PARAM_MBZ, FFA_PARAM_MBZ); + } ++#endif + + static void handle_rx_release(struct thread_smc_args *args) + { +@@ -408,6 +453,7 @@ static void handle_blocking_call(struct thread_smc_args *args) + } + } + ++#if CFG_CORE_SEL1_SPMC + static int get_acc_perms(struct mem_accsess_descr *mem_acc, + unsigned int num_mem_accs, uint8_t *acc_perms, + unsigned int *region_offs) +@@ -531,7 +577,11 @@ static int add_mem_share_frag(struct mem_frag_state *s, void *buf, size_t flen) + + SLIST_REMOVE(&frag_state_head, s, mem_frag_state, link); + if (rc < 0) ++#ifdef CFG_CORE_SEL2_SPMC ++ mobj_ffa_sel2_spmc_delete(s->share.mf); ++#else + mobj_ffa_sel1_spmc_delete(s->share.mf); ++#endif + else + mobj_ffa_push_to_inactive(s->share.mf); + free(s); +@@ -559,8 +609,8 @@ static int add_mem_share(tee_mm_entry_t *mm, void *buf, size_t blen, + sizeof(struct constituent_address_range), &n) || + ADD_OVERFLOW(n, addr_range_offs, &n) || n > blen) + return FFA_INVALID_PARAMETERS; +- + share.mf = mobj_ffa_sel1_spmc_new(share.page_count); ++ + if (!share.mf) + return FFA_NO_MEMORY; + +@@ -601,6 +651,7 @@ static int add_mem_share(tee_mm_entry_t *mm, void *buf, size_t blen, + return 0; + err: + mobj_ffa_sel1_spmc_delete(share.mf); ++ + return rc; + } + +@@ -809,6 +860,7 @@ static void handle_mem_reclaim(struct thread_smc_args *args) + out: + set_args(args, ret_fid, ret_val, 0, 0, 0, 0); + } ++#endif + + /* Only called from assembly */ + void thread_spmc_msg_recv(struct thread_smc_args *args); +@@ -822,6 +874,7 @@ void thread_spmc_msg_recv(struct thread_smc_args *args) + case FFA_FEATURES: + handle_features(args); + break; ++#if CFG_CORE_SEL1_SPMC + #ifdef ARM64 + case FFA_RXTX_MAP_64: + #endif +@@ -831,6 +884,7 @@ void thread_spmc_msg_recv(struct thread_smc_args *args) + case FFA_RXTX_UNMAP: + handle_rxtx_unmap(args); + break; ++#endif + case FFA_RX_RELEASE: + handle_rx_release(args); + break; +@@ -847,6 +901,7 @@ void thread_spmc_msg_recv(struct thread_smc_args *args) + else + handle_blocking_call(args); + break; ++#if CFG_CORE_SEL1_SPMC + #ifdef ARM64 + case FFA_MEM_SHARE_64: + #endif +@@ -859,6 +914,7 @@ void thread_spmc_msg_recv(struct thread_smc_args *args) + case FFA_MEM_FRAG_TX: + handle_mem_frag_tx(args); + break; ++#endif + default: + EMSG("Unhandled FFA function ID %#"PRIx32, (uint32_t)args->a0); + set_args(args, FFA_ERROR, FFA_PARAM_MBZ, FFA_NOT_SUPPORTED, +@@ -1185,3 +1241,109 @@ void thread_rpc_free_global_payload(struct mobj *mobj __unused) + + assert(!cant_happen); + } ++ ++#ifdef CFG_CORE_SEL2_SPMC ++static void spmc_rxtx_map(void) ++{ ++ struct thread_smc_args args = { ++ .a0 = FFA_RXTX_MAP_64, ++ .a1 = (vaddr_t)tx_buf, ++ .a2 = (vaddr_t)rx_buf, ++ .a3 = 1, ++ }; ++ ++ thread_smccc(&args); ++ if (args.a0 == FFA_ERROR) { ++ EMSG("ERROR rxtx map failed with error %ld\n", args.a2); ++ panic(); ++ } ++} ++ ++static struct mem_transaction_descr *spmc_retrieve_req(uint64_t cookie) ++{ ++ struct mem_transaction_descr *retrieve_region = (void *)tx_buf; ++ ++ struct thread_smc_args args = { ++ .a0 = FFA_MEM_RETRIEVE_REQ_64, ++ .a1 = sizeof(*retrieve_region), // Total Length ++ .a2 = sizeof(*retrieve_region), // Frag Length == Total length ++ .a3 = 0, // Address, Using TX -> MBZ ++ .a4 = 0 // Using TX -> MBZ ++ }; ++ ++ /* TODO pass all the information required by the spec */ ++ memset(retrieve_region, 0, sizeof(*retrieve_region)); ++ retrieve_region->global_handle = cookie; ++ ++ thread_smccc(&args); ++ if (args.a0 == FFA_ERROR /*TODO != FFA_MEM_RETRIEVE_RESP_64 */) { ++ EMSG("Failed to fetch cookie %#"PRIx64, cookie); ++ return NULL; ++ } ++ ++ return (void *)rx_buf; ++} ++ ++void thread_spmc_relinquish(uint64_t cookie) ++{ ++ struct ffa_relinquish_descriptor *relinquish_desc = (void *)tx_buf; ++ ++ struct thread_smc_args args = { ++ .a0 = FFA_MEM_RELINQUISH, ++ }; ++ ++ memset(relinquish_desc, 0, sizeof(*relinquish_desc)); ++ relinquish_desc->handle = cookie; ++ relinquish_desc->flags = 0; ++ /* TODO: Add endpoint details. */ ++ thread_smccc(&args); ++ if (args.a0 != FFA_SUCCESS_32) ++ EMSG("Failed to relinquish cookie %#"PRIx64, cookie); ++} ++ ++struct mobj_ffa *thread_spmc_populate_mobj_from_rx(uint64_t cookie) ++{ ++ struct mem_transaction_descr *retrieve_desc; ++ struct mem_region_descr *descr; ++ struct mobj_ffa *mf; ++ uint32_t num_pages; ++ ++ ++ /* XXX Support single mem_region. */ ++ retrieve_desc = spmc_retrieve_req(cookie); ++ ++ if (!retrieve_desc) { ++ EMSG("Failed to retrieve cookie from rx buffer %#"PRIx64, cookie); ++ return NULL; ++ } ++ ++ descr = (struct mem_region_descr *) ++ ((uint8_t *)retrieve_desc + ++ retrieve_desc->mem_accsess_descr_array[0].mem_region_offs); ++ ++ num_pages = descr->total_page_count; ++ mf = mobj_ffa_sel2_spmc_new(cookie, num_pages); ++ ++ if (!mf) ++ return NULL; ++ ++ if (set_pages(descr->address_range_array, ++ descr->address_range_count, ++ num_pages, mf)) { ++ mobj_ffa_sel2_spmc_delete(mf); ++ return NULL; ++ ++ } ++ ++ return mf; ++} ++ ++static TEE_Result spmc_init(void) ++{ ++ spmc_rxtx_map(); ++ ++ return TEE_SUCCESS; ++} ++service_init(spmc_init); ++ ++#endif /*CFG_CORE_SEL2_SPMC*/ +diff --git a/core/arch/arm/kernel/thread_spmc_a64.S b/core/arch/arm/kernel/thread_spmc_a64.S +index 3d57da4d..66f9d0b4 100644 +--- a/core/arch/arm/kernel/thread_spmc_a64.S ++++ b/core/arch/arm/kernel/thread_spmc_a64.S +@@ -17,7 +17,8 @@ + + FUNC thread_ffa_msg_wait , : + mov_imm x0, FFA_MSG_WAIT /* FID */ +- mov x1, #FFA_TARGET_INFO_MBZ /* Target info MBZ */ ++ adr x1, thread_spmc_target_info ++ ldr w1, [x1] + mov x2, #FFA_PARAM_MBZ /* Param MBZ */ + mov x3, #FFA_PARAM_MBZ /* Param MBZ */ + mov x4, #FFA_PARAM_MBZ /* Param MBZ */ +diff --git a/core/arch/arm/mm/mobj_ffa.c b/core/arch/arm/mm/mobj_ffa.c +index fd5e66ea..e2c585a2 100644 +--- a/core/arch/arm/mm/mobj_ffa.c ++++ b/core/arch/arm/mm/mobj_ffa.c +@@ -19,8 +19,10 @@ struct mobj_ffa { + tee_mm_entry_t *mm; + struct refcount mapcount; + uint16_t page_offset; ++#ifdef CFG_CORE_SEL1_SPMC + bool registered_by_cookie; + bool unregistered_by_cookie; ++#endif + paddr_t pages[]; + }; + +@@ -186,6 +188,24 @@ void mobj_ffa_sel1_spmc_delete(struct mobj_ffa *mf) + } + #endif /*CFG_CORE_SEL1_SPMC*/ + ++#ifdef CFG_CORE_SEL2_SPMC ++struct mobj_ffa *mobj_ffa_sel2_spmc_new(uint64_t cookie, ++ unsigned int num_pages) ++{ ++ struct mobj_ffa *mf = NULL; ++ ++ mf = ffa_new(num_pages); ++ if (mf) ++ mf->cookie = cookie; ++ return mf; ++} ++ ++void mobj_ffa_sel2_spmc_delete(struct mobj_ffa *mf) ++{ ++ free(mf); ++} ++#endif /*CFG_CORE_SEL2_SPMC*/ ++ + TEE_Result mobj_ffa_add_pages_at(struct mobj_ffa *mf, unsigned int *idx, + paddr_t pa, unsigned int num_pages) + { +@@ -234,7 +254,9 @@ static void unmap_helper(struct mobj_ffa *mf) + } + } + +-TEE_Result mobj_ffa_unregister_by_cookie(uint64_t cookie) ++ ++#ifdef CFG_CORE_SEL1_SPMC ++TEE_Result mobj_ffa_sel1_spmc_reclaim(uint64_t cookie) + { + TEE_Result res = TEE_SUCCESS; + struct mobj_ffa *mf = NULL; +@@ -244,7 +266,7 @@ TEE_Result mobj_ffa_unregister_by_cookie(uint64_t cookie) + mf = find_in_list(&shm_head, cmp_cookie, cookie); + /* + * If the mobj is found here it's still active and cannot be +- * unregistered. ++ * reclaimed. + */ + if (mf) { + DMSG("cookie %#"PRIx64" busy refc %u", +@@ -252,24 +274,34 @@ TEE_Result mobj_ffa_unregister_by_cookie(uint64_t cookie) + res = TEE_ERROR_BUSY; + goto out; + } ++ + mf = find_in_list(&shm_inactive_head, cmp_cookie, cookie); ++ if (!mf) { ++ res = TEE_ERROR_ITEM_NOT_FOUND; ++ goto out; ++ } + /* +- * If the mobj isn't found or if it already has been unregistered. ++ * If the mobj has been registered via mobj_ffa_get_by_cookie() ++ * but not unregistered yet with mobj_ffa_unregister_by_cookie(). + */ +- if (!mf || mf->unregistered_by_cookie) { +- res = TEE_ERROR_ITEM_NOT_FOUND; ++ if (mf->registered_by_cookie && !mf->unregistered_by_cookie) { ++ DMSG("cookie %#"PRIx64" busy", cookie); ++ res = TEE_ERROR_BUSY; + goto out; + } +- mf->unregistered_by_cookie = true; +- res = TEE_SUCCESS; + ++ if (!pop_from_list(&shm_inactive_head, cmp_ptr, (vaddr_t)mf)) ++ panic(); ++ res = TEE_SUCCESS; + out: + cpu_spin_unlock_xrestore(&shm_lock, exceptions); ++ if (!res) ++ mobj_ffa_sel1_spmc_delete(mf); + return res; + } ++#endif /*CFG_CORE_SEL1_SPMC*/ + +-#ifdef CFG_CORE_SEL1_SPMC +-TEE_Result mobj_ffa_sel1_spmc_reclaim(uint64_t cookie) ++TEE_Result mobj_ffa_unregister_by_cookie(uint64_t cookie) + { + TEE_Result res = TEE_SUCCESS; + struct mobj_ffa *mf = NULL; +@@ -279,7 +311,7 @@ TEE_Result mobj_ffa_sel1_spmc_reclaim(uint64_t cookie) + mf = find_in_list(&shm_head, cmp_cookie, cookie); + /* + * If the mobj is found here it's still active and cannot be +- * reclaimed. ++ * unregistered. + */ + if (mf) { + DMSG("cookie %#"PRIx64" busy refc %u", +@@ -287,43 +319,42 @@ TEE_Result mobj_ffa_sel1_spmc_reclaim(uint64_t cookie) + res = TEE_ERROR_BUSY; + goto out; + } +- + mf = find_in_list(&shm_inactive_head, cmp_cookie, cookie); +- if (!mf) { +- res = TEE_ERROR_ITEM_NOT_FOUND; +- goto out; +- } + /* +- * If the mobj has been registered via mobj_ffa_get_by_cookie() +- * but not unregistered yet with mobj_ffa_unregister_by_cookie(). ++ * If the mobj isn't found or if it already has been unregistered. + */ +- if (mf->registered_by_cookie && !mf->unregistered_by_cookie) { +- DMSG("cookie %#"PRIx64" busy", cookie); +- res = TEE_ERROR_BUSY; ++#ifdef CFG_CORE_SEL2_SPMC ++ if (!mf) { ++#else ++ if (!mf || mf->unregistered_by_cookie) { ++#endif ++ res = TEE_ERROR_ITEM_NOT_FOUND; + goto out; + } + +- if (!pop_from_list(&shm_inactive_head, cmp_ptr, (vaddr_t)mf)) +- panic(); ++ ++#ifdef CFG_CORE_SEL2_SPMC ++ mf = pop_from_list(&shm_inactive_head, cmp_cookie, cookie); ++ mobj_ffa_sel2_spmc_delete(mf); ++ thread_spmc_relinquish(cookie); ++#else ++ mf->unregistered_by_cookie = true; ++#endif + res = TEE_SUCCESS; ++ + out: + cpu_spin_unlock_xrestore(&shm_lock, exceptions); +- if (!res) +- mobj_ffa_sel1_spmc_delete(mf); + return res; + } +-#endif /*CFG_CORE_SEL1_SPMC*/ + +-struct mobj *mobj_ffa_get_by_cookie(uint64_t cookie, unsigned int internal_offs) ++struct mobj *mobj_ffa_get_by_cookie(uint64_t cookie, ++ unsigned int internal_offs) + { + struct mobj_ffa *mf = NULL; + uint32_t exceptions = 0; +- + if (internal_offs >= SMALL_PAGE_SIZE) + return NULL; +- + exceptions = cpu_spin_lock_xsave(&shm_lock); +- + mf = find_in_list(&shm_head, cmp_cookie, cookie); + if (mf) { + if (mf->page_offset == internal_offs) { +@@ -345,9 +376,19 @@ struct mobj *mobj_ffa_get_by_cookie(uint64_t cookie, unsigned int internal_offs) + } + } else { + mf = pop_from_list(&shm_inactive_head, cmp_cookie, cookie); ++#if defined(CFG_CORE_SEL2_SPMC) ++ /* Try to retrieve it from the SPM at S-EL2 */ ++ if (mf) ++ DMSG("cookie %#"PRIx64" resurrecting", cookie); ++ if (!mf) ++ EMSG("Populating mobj from rx buffer\n"); ++ mf = thread_spmc_populate_mobj_from_rx(cookie); ++#endif + if (mf) { ++#if defined(CFG_CORE_SEL1_SPMC) + mf->unregistered_by_cookie = false; + mf->registered_by_cookie = true; ++#endif + assert(refcount_val(&mf->mobj.refc) == 0); + refcount_set(&mf->mobj.refc, 1); + refcount_set(&mf->mapcount, 0); +@@ -358,15 +399,12 @@ struct mobj *mobj_ffa_get_by_cookie(uint64_t cookie, unsigned int internal_offs) + SLIST_INSERT_HEAD(&shm_head, mf, link); + } + } +- + cpu_spin_unlock_xrestore(&shm_lock, exceptions); +- + if (!mf) { + EMSG("Failed to get cookie %#"PRIx64" internal_offs %#x", +- cookie, internal_offs); ++ cookie, internal_offs); + return NULL; + } +- + return &mf->mobj; + } + +diff --git a/core/arch/arm/plat-vexpress/conf.mk b/core/arch/arm/plat-vexpress/conf.mk +index 26b9f51e..dd6530a6 100644 +--- a/core/arch/arm/plat-vexpress/conf.mk ++++ b/core/arch/arm/plat-vexpress/conf.mk +@@ -58,8 +58,13 @@ CFG_WITH_STATS ?= y + + ifeq ($(PLATFORM_FLAVOR),fvp) + CFG_TEE_CORE_NB_CORE = 8 ++ifeq ($(CFG_CORE_SEL2_SPMC),y) ++CFG_TZDRAM_START ?= 0x06280000 ++CFG_TZDRAM_SIZE ?= 0x01D80000 ++else + CFG_TZDRAM_START ?= 0x06000000 + CFG_TZDRAM_SIZE ?= 0x02000000 ++endif + CFG_SHMEM_START ?= 0x83000000 + CFG_SHMEM_SIZE ?= 0x00200000 + # DRAM1 is defined above 4G +-- +2.26.2 + diff --git a/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0004-core-fixes-to-align-with-upstream-hafnium.patch b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0004-core-fixes-to-align-with-upstream-hafnium.patch new file mode 100644 index 00000000..a36a5101 --- /dev/null +++ b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0004-core-fixes-to-align-with-upstream-hafnium.patch @@ -0,0 +1,188 @@ +Upstream-Status: Pending [Not submitted to upstream yet] +Signed-off-by: Arunachalam Ganapathy + +From 5ca96d9ff7fa5481282fb8f59a54d3cc91a1ae36 Mon Sep 17 00:00:00 2001 +From: Olivier Deprez +Date: Thu, 1 Oct 2020 07:59:54 +0200 +Subject: [PATCH 1/5] core: fixes to align with upstream hafnium + +FF-A: fix call to thread_spmc_populate_mobj_from_rx + +FF-A: fix typos in thread_spmc.c + +FF-A: fix mem retrieve request + +FF-A. fix mem relinquish + +FF-A: call rx release from thread_spmc_populate_mobj_from_rx + +Change-Id: I38794b34bf17428d62218e30bdd0180f75498ed4 +Signed-off-by: Olivier Deprez +Signed-off-by: Arunachalam Ganapathy +--- + core/arch/arm/kernel/thread_spmc.c | 52 +++++++++++++++++++++--------- + core/arch/arm/mm/mobj_ffa.c | 3 +- + 2 files changed, 39 insertions(+), 16 deletions(-) + +diff --git a/core/arch/arm/kernel/thread_spmc.c b/core/arch/arm/kernel/thread_spmc.c +index 3d7dc035..872221d6 100644 +--- a/core/arch/arm/kernel/thread_spmc.c ++++ b/core/arch/arm/kernel/thread_spmc.c +@@ -48,7 +48,7 @@ struct mem_access_perm_descr { + }; + + /* Table 41: Endpoint memory access descriptor */ +-struct mem_accsess_descr { ++struct mem_access_descr { + struct mem_access_perm_descr mem_access_perm_descr; + uint32_t mem_region_offs; + uint64_t reserved; +@@ -64,7 +64,7 @@ struct mem_transaction_descr { + uint64_t tag; + uint32_t reserved1; + uint32_t mem_access_descr_count; +- struct mem_accsess_descr mem_accsess_descr_array[]; ++ struct mem_access_descr mem_access_descr_array[]; + }; + + struct ffa_partition_info { +@@ -453,8 +453,8 @@ static void handle_blocking_call(struct thread_smc_args *args) + } + } + +-#if CFG_CORE_SEL1_SPMC +-static int get_acc_perms(struct mem_accsess_descr *mem_acc, ++#ifdef CFG_CORE_SEL1_SPMC ++static int get_acc_perms(struct mem_access_descr *mem_acc, + unsigned int num_mem_accs, uint8_t *acc_perms, + unsigned int *region_offs) + { +@@ -495,7 +495,7 @@ static int mem_share_init(void *buf, size_t blen, unsigned int *page_count, + + /* Check that the endpoint memory access descriptor array fits */ + num_mem_accs = READ_ONCE(descr->mem_access_descr_count); +- if (MUL_OVERFLOW(sizeof(struct mem_accsess_descr), num_mem_accs, &n) || ++ if (MUL_OVERFLOW(sizeof(struct mem_access_descr), num_mem_accs, &n) || + ADD_OVERFLOW(sizeof(*descr), n, &n) || n > blen) + return FFA_INVALID_PARAMETERS; + +@@ -503,7 +503,7 @@ static int mem_share_init(void *buf, size_t blen, unsigned int *page_count, + return FFA_INVALID_PARAMETERS; + + /* Check that the access permissions matches what's expected */ +- if (get_acc_perms(descr->mem_accsess_descr_array, ++ if (get_acc_perms(descr->mem_access_descr_array, + num_mem_accs, &mem_acc_perm, ®ion_descr_offs) || + mem_acc_perm != exp_mem_acc_perm) + return FFA_INVALID_PARAMETERS; +@@ -1263,17 +1263,29 @@ static struct mem_transaction_descr *spmc_retrieve_req(uint64_t cookie) + { + struct mem_transaction_descr *retrieve_region = (void *)tx_buf; + ++ uint64_t size = sizeof(*retrieve_region) + ++ 1 * sizeof(struct mem_access_descr); + struct thread_smc_args args = { + .a0 = FFA_MEM_RETRIEVE_REQ_64, +- .a1 = sizeof(*retrieve_region), // Total Length +- .a2 = sizeof(*retrieve_region), // Frag Length == Total length ++ .a1 = size, // Total Length ++ .a2 = size, // Frag Length == Total length + .a3 = 0, // Address, Using TX -> MBZ + .a4 = 0 // Using TX -> MBZ + }; + + /* TODO pass all the information required by the spec */ +- memset(retrieve_region, 0, sizeof(*retrieve_region)); ++ memset(retrieve_region, 0, size); + retrieve_region->global_handle = cookie; ++ retrieve_region->flags = 1; ++ retrieve_region->mem_access_descr_count = 1; ++ retrieve_region->mem_access_descr_array[0].mem_region_offs = 0; ++ retrieve_region->mem_access_descr_array[0].reserved = 0; ++ retrieve_region->mem_access_descr_array[0].mem_access_perm_descr = ++ (struct mem_access_perm_descr) { ++ .endpoint_id = my_sp_id, ++ .access_perm = 0, ++ .flags = 0 ++ }; + + thread_smccc(&args); + if (args.a0 == FFA_ERROR /*TODO != FFA_MEM_RETRIEVE_RESP_64 */) { +@@ -1296,6 +1308,8 @@ void thread_spmc_relinquish(uint64_t cookie) + relinquish_desc->handle = cookie; + relinquish_desc->flags = 0; + /* TODO: Add endpoint details. */ ++ relinquish_desc->endpoint_count = 1; ++ relinquish_desc->endpoint_id_array[0] = my_sp_id; + thread_smccc(&args); + if (args.a0 != FFA_SUCCESS_32) + EMSG("Failed to relinquish cookie %#"PRIx64, cookie); +@@ -1303,11 +1317,14 @@ void thread_spmc_relinquish(uint64_t cookie) + + struct mobj_ffa *thread_spmc_populate_mobj_from_rx(uint64_t cookie) + { ++ struct mobj_ffa *ret = NULL; + struct mem_transaction_descr *retrieve_desc; + struct mem_region_descr *descr; + struct mobj_ffa *mf; + uint32_t num_pages; +- ++ struct thread_smc_args ffa_rx_release_args = { ++ .a0 = FFA_RX_RELEASE ++ }; + + /* XXX Support single mem_region. */ + retrieve_desc = spmc_retrieve_req(cookie); +@@ -1319,23 +1336,28 @@ struct mobj_ffa *thread_spmc_populate_mobj_from_rx(uint64_t cookie) + + descr = (struct mem_region_descr *) + ((uint8_t *)retrieve_desc + +- retrieve_desc->mem_accsess_descr_array[0].mem_region_offs); ++ retrieve_desc->mem_access_descr_array[0].mem_region_offs); + + num_pages = descr->total_page_count; + mf = mobj_ffa_sel2_spmc_new(cookie, num_pages); + + if (!mf) +- return NULL; ++ goto out; + + if (set_pages(descr->address_range_array, + descr->address_range_count, + num_pages, mf)) { + mobj_ffa_sel2_spmc_delete(mf); +- return NULL; +- ++ goto out; + } + +- return mf; ++ ret = mf; ++ ++out: ++ /* Release RX buffer after the mem retrieve request. */ ++ thread_smccc(&ffa_rx_release_args); ++ ++ return ret; + } + + static TEE_Result spmc_init(void) +diff --git a/core/arch/arm/mm/mobj_ffa.c b/core/arch/arm/mm/mobj_ffa.c +index e2c585a2..8e334f04 100644 +--- a/core/arch/arm/mm/mobj_ffa.c ++++ b/core/arch/arm/mm/mobj_ffa.c +@@ -380,9 +380,10 @@ struct mobj *mobj_ffa_get_by_cookie(uint64_t cookie, + /* Try to retrieve it from the SPM at S-EL2 */ + if (mf) + DMSG("cookie %#"PRIx64" resurrecting", cookie); +- if (!mf) ++ if (!mf) { + EMSG("Populating mobj from rx buffer\n"); + mf = thread_spmc_populate_mobj_from_rx(cookie); ++ } + #endif + if (mf) { + #if defined(CFG_CORE_SEL1_SPMC) +-- +2.26.2 + diff --git a/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0005-core-arm-Total-Compute-platform-support.patch b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0005-core-arm-Total-Compute-platform-support.patch new file mode 100644 index 00000000..52270ecd --- /dev/null +++ b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0005-core-arm-Total-Compute-platform-support.patch @@ -0,0 +1,187 @@ +Upstream-Status: Pending [Not submitted to upstream yet] +Signed-off-by: Arunachalam Ganapathy + +From 0c427d7f164a46862f6267b616d4ade28865b57a Mon Sep 17 00:00:00 2001 +From: Arunachalam Ganapathy +Date: Wed, 15 Jul 2020 12:51:04 +0100 +Subject: [PATCH 2/5] core: arm: Total Compute platform support + +Initial support for Total Compute platform[1] + - defines tc0 platform configuration + - enables CFG_ARM64_core by default + - defines TZCDRAM_BASE + +Link: [1] https://community.arm.com/developer/tools-software/oss-platforms/w/docs/606/total-compute + +Change-Id: Icddafbdfac40bb6ff3c367910acf632688343721 +Signed-off-by: Arunachalam Ganapathy +--- + core/arch/arm/plat-totalcompute/conf.mk | 32 +++++++++++ + core/arch/arm/plat-totalcompute/main.c | 55 +++++++++++++++++++ + .../arm/plat-totalcompute/platform_config.h | 43 +++++++++++++++ + core/arch/arm/plat-totalcompute/sub.mk | 2 + + 4 files changed, 132 insertions(+) + create mode 100644 core/arch/arm/plat-totalcompute/conf.mk + create mode 100644 core/arch/arm/plat-totalcompute/main.c + create mode 100644 core/arch/arm/plat-totalcompute/platform_config.h + create mode 100644 core/arch/arm/plat-totalcompute/sub.mk + +diff --git a/core/arch/arm/plat-totalcompute/conf.mk b/core/arch/arm/plat-totalcompute/conf.mk +new file mode 100644 +index 00000000..4fe894c7 +--- /dev/null ++++ b/core/arch/arm/plat-totalcompute/conf.mk +@@ -0,0 +1,32 @@ ++PLATFORM_FLAVOR ?= tc0 ++ ++ifeq ($(PLATFORM_FLAVOR),tc0) ++include core/arch/arm/cpu/cortex-armv8-0.mk ++platform-debugger-arm := 1 ++endif ++ ++$(call force,CFG_WITH_ARM_TRUSTED_FW,y) ++$(call force,CFG_GENERIC_BOOT,y) ++$(call force,CFG_GIC,y) ++$(call force,CFG_ARM_GICV3,y) ++$(call force,CFG_PL011,y) ++$(call force,CFG_PM_STUBS,y) ++$(call force,CFG_SECURE_TIME_SOURCE_CNTPCT,y) ++$(call force,CFG_ARM64_core,y) ++$(call force,CFG_WITH_LPAE,y) ++ ++ifeq ($(platform-debugger-arm),1) ++# ARM debugger needs this ++platform-cflags-debug-info = -gdwarf-2 ++platform-aflags-debug-info = -gdwarf-2 ++endif ++ ++ifeq ($(PLATFORM_FLAVOR),tc0) ++CFG_TEE_CORE_NB_CORE = 4 ++ ++CFG_TZDRAM_START ?= 0xff000000 ++CFG_TZDRAM_SIZE ?= 0x01000000 ++ ++CFG_SHMEM_START ?= 0xfce00000 ++CFG_SHMEM_SIZE ?= 0x00200000 ++endif +diff --git a/core/arch/arm/plat-totalcompute/main.c b/core/arch/arm/plat-totalcompute/main.c +new file mode 100644 +index 00000000..e775abfc +--- /dev/null ++++ b/core/arch/arm/plat-totalcompute/main.c +@@ -0,0 +1,55 @@ ++/* ++ * Copyright (c) 2020, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static struct gic_data gic_data __nex_bss; ++static struct pl011_data console_data __nex_bss; ++ ++register_phys_mem_pgdir(MEM_AREA_IO_SEC, CONSOLE_UART_BASE, PL011_REG_SIZE); ++register_phys_mem_pgdir(MEM_AREA_IO_SEC, GICD_BASE, GIC_DIST_REG_SIZE); ++ ++register_ddr(DRAM0_BASE, DRAM0_SIZE); ++ ++void main_init_gic(void) ++{ ++ vaddr_t gicc_base; ++ ++ gicc_base = (vaddr_t)phys_to_virt(GIC_BASE + GICC_OFFSET, ++ MEM_AREA_IO_SEC); ++ if (!gicc_base) ++ panic(); ++ ++ /* ++ * On ARMv8, GIC configuration is initialized in ARM-TF ++ * gicd base address is same as gicc_base. ++ */ ++ gic_init_base_addr(&gic_data, gicc_base, gicc_base); ++ itr_init(&gic_data.chip); ++} ++ ++void itr_core_handler(void) ++{ ++ gic_it_handle(&gic_data); ++} ++ ++void console_init(void) ++{ ++ pl011_init(&console_data, CONSOLE_UART_BASE, CONSOLE_UART_CLK_IN_HZ, ++ CONSOLE_UART_BAUDRATE); ++ register_serial_console(&console_data.chip); ++} +diff --git a/core/arch/arm/plat-totalcompute/platform_config.h b/core/arch/arm/plat-totalcompute/platform_config.h +new file mode 100644 +index 00000000..dfc58857 +--- /dev/null ++++ b/core/arch/arm/plat-totalcompute/platform_config.h +@@ -0,0 +1,43 @@ ++/* ++ * Copyright (c) 2020, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef PLATFORM_CONFIG_H ++#define PLATFORM_CONFIG_H ++ ++#include ++ ++/* Make stacks aligned to data cache line length */ ++#define STACK_ALIGNMENT 64 ++ ++#if defined(PLATFORM_FLAVOR_tc0) ++#define GIC_BASE 0x30000000 ++#define GICD_OFFSET 0x0 ++#define GICC_OFFSET 0x0 ++ ++#define UART0_BASE 0x7FF70000 ++#define UART1_BASE 0x7FF80000 ++ ++#define CONSOLE_UART_BASE UART0_BASE ++ ++#define DRAM0_BASE 0x80000000 ++#define DRAM0_SIZE 0x7d000000 ++ ++#define TZCDRAM_BASE 0xff000000 ++#define TZCDRAM_SIZE 0x01000000 ++ ++#else ++#error "Unknown platform flavor" ++#endif ++ ++#ifdef GIC_BASE ++#define GICD_BASE (GIC_BASE + GICD_OFFSET) ++#define GICC_BASE (GIC_BASE + GICC_OFFSET) ++#endif ++ ++#define CONSOLE_UART_BAUDRATE 115200 ++#define CONSOLE_UART_CLK_IN_HZ 7372800 ++ ++#endif /* PLATFORM_CONFIG_H */ +diff --git a/core/arch/arm/plat-totalcompute/sub.mk b/core/arch/arm/plat-totalcompute/sub.mk +new file mode 100644 +index 00000000..8ddc2fd4 +--- /dev/null ++++ b/core/arch/arm/plat-totalcompute/sub.mk +@@ -0,0 +1,2 @@ ++global-incdirs-y += . ++srcs-y += main.c +-- +2.26.2 + diff --git a/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0006-plat-totalcompute-Add-support-for-S-EL2-SPMC.patch b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0006-plat-totalcompute-Add-support-for-S-EL2-SPMC.patch new file mode 100644 index 00000000..3070d5f0 --- /dev/null +++ b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0006-plat-totalcompute-Add-support-for-S-EL2-SPMC.patch @@ -0,0 +1,108 @@ +Upstream-Status: Pending [Not submitted to upstream yet] +Signed-off-by: Arunachalam Ganapathy + +From 8c21a8c7ac92839f36f83ebff9a208f24302c780 Mon Sep 17 00:00:00 2001 +From: Arunachalam Ganapathy +Date: Mon, 16 Nov 2020 17:29:09 +0000 +Subject: [PATCH 3/5] plat-totalcompute: Add support for S-EL2 SPMC + +This patch adds CFG_CORE_SEL2_SPMC support. Defines CFG_TZDRAM_START +address with memory region reserved for SPMC. Adds secondary cpu boot +request handler. + +Change-Id: I3f274c7bb6b7df2706ea81aee0f2a8f8f39c1d80 +Signed-off-by: Arunachalam Ganapathy +--- + core/arch/arm/plat-totalcompute/conf.mk | 5 ++ + core/arch/arm/plat-totalcompute/sub.mk | 3 ++ + core/arch/arm/plat-totalcompute/tc0_spmc_pm.c | 50 +++++++++++++++++++ + 3 files changed, 58 insertions(+) + create mode 100644 core/arch/arm/plat-totalcompute/tc0_spmc_pm.c + +diff --git a/core/arch/arm/plat-totalcompute/conf.mk b/core/arch/arm/plat-totalcompute/conf.mk +index 4fe894c7..34095acf 100644 +--- a/core/arch/arm/plat-totalcompute/conf.mk ++++ b/core/arch/arm/plat-totalcompute/conf.mk +@@ -24,8 +24,13 @@ endif + ifeq ($(PLATFORM_FLAVOR),tc0) + CFG_TEE_CORE_NB_CORE = 4 + ++ifeq ($(CFG_CORE_SEL2_SPMC),y) ++CFG_TZDRAM_START ?= 0xfd281000 ++CFG_TZDRAM_SIZE ?= 0x01d7f000 ++else + CFG_TZDRAM_START ?= 0xff000000 + CFG_TZDRAM_SIZE ?= 0x01000000 ++endif + + CFG_SHMEM_START ?= 0xfce00000 + CFG_SHMEM_SIZE ?= 0x00200000 +diff --git a/core/arch/arm/plat-totalcompute/sub.mk b/core/arch/arm/plat-totalcompute/sub.mk +index 8ddc2fd4..ffd76ee9 100644 +--- a/core/arch/arm/plat-totalcompute/sub.mk ++++ b/core/arch/arm/plat-totalcompute/sub.mk +@@ -1,2 +1,5 @@ + global-incdirs-y += . + srcs-y += main.c ++ifeq ($(CFG_CORE_FFA),y) ++srcs-y += tc0_spmc_pm.c ++endif +diff --git a/core/arch/arm/plat-totalcompute/tc0_spmc_pm.c b/core/arch/arm/plat-totalcompute/tc0_spmc_pm.c +new file mode 100644 +index 00000000..8e59a8cc +--- /dev/null ++++ b/core/arch/arm/plat-totalcompute/tc0_spmc_pm.c +@@ -0,0 +1,50 @@ ++// SPDX-License-Identifier: BSD-2-Clause ++/* ++ * Copyright (c) 2020, Arm Limited ++ */ ++ ++#include ++#include ++#include ++#include ++ ++/* ++ * Lookup table of core and cluster affinities on the TC0. In the absence of a ++ * DT that provides the same information, this table is used to initialise ++ * OP-TEE on secondary cores. ++ */ ++static const uint64_t core_clus_aff_array[] = { ++ 0x0000, /* Cluster 0 Cpu 0 */ ++ 0x0001, /* Cluster 0 Cpu 1 */ ++ 0x0002, /* Cluster 0 Cpu 2 */ ++ 0x0003 /* Cluster 0 Cpu 3 */ ++}; ++ ++void ffa_secondary_cpu_boot_req(vaddr_t secondary_ep, uint64_t cookie) ++{ ++ unsigned long mpidr = read_mpidr(); ++ unsigned int aff_shift = 0; ++ unsigned long a1 = 0; ++ unsigned int cnt = 0; ++ int32_t ret = 0; ++ ++ if (mpidr & MPIDR_MT_MASK) ++ aff_shift = MPIDR_CLUSTER_SHIFT; ++ ++ for (cnt = 0; cnt < ARRAY_SIZE(core_clus_aff_array); cnt++) { ++ /* Clear out the affinity fields until level 2 */ ++ a1 = mpidr & ~(unsigned long)MPIDR_AARCH32_AFF_MASK; ++ ++ /* Create an mpidr from core_clus_aff_array */ ++ a1 |= core_clus_aff_array[cnt] << aff_shift; ++ ++ /* Invoke the PSCI_CPU_ON_SMC64 function */ ++ ret = thread_smc(PSCI_CPU_ON_SMC64, a1, secondary_ep, cookie); ++ ++ if (ret != PSCI_RET_SUCCESS) ++ EMSG("PSCI_CPU_ON op on mpidr 0x%lx failed %"PRId32, ++ a1, ret); ++ else ++ DMSG("PSCI_CPU_ON op on mpidr 0x%lx done", a1); ++ } ++} +-- +2.26.2 + diff --git a/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0007-plat-totalcompute-add-optee-manifest-file-and-sp-lay.patch b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0007-plat-totalcompute-add-optee-manifest-file-and-sp-lay.patch new file mode 100644 index 00000000..65354968 --- /dev/null +++ b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0007-plat-totalcompute-add-optee-manifest-file-and-sp-lay.patch @@ -0,0 +1,73 @@ +Upstream-Status: Pending [Not submitted to upstream yet] +Signed-off-by: Arunachalam Ganapathy + +From 582bf63102ec37dadff2147dcebcb62783dcf377 Mon Sep 17 00:00:00 2001 +From: Arunachalam Ganapathy +Date: Mon, 16 Nov 2020 18:03:21 +0000 +Subject: [PATCH 4/5] plat-totalcompute: add optee manifest file and sp layout + +For S-EL2 SPMC, add optee manifest file and sp layout file + +Change-Id: Ic3179987decf4e017cd4a0ad91b3beeea2bd6ca1 +Signed-off-by: Arunachalam Ganapathy +--- + .../arm/plat-totalcompute/optee_manifest.dts | 33 +++++++++++++++++++ + .../arch/arm/plat-totalcompute/sp_layout.json | 6 ++++ + 2 files changed, 39 insertions(+) + create mode 100644 core/arch/arm/plat-totalcompute/optee_manifest.dts + create mode 100644 core/arch/arm/plat-totalcompute/sp_layout.json + +diff --git a/core/arch/arm/plat-totalcompute/optee_manifest.dts b/core/arch/arm/plat-totalcompute/optee_manifest.dts +new file mode 100644 +index 00000000..4e60cbe1 +--- /dev/null ++++ b/core/arch/arm/plat-totalcompute/optee_manifest.dts +@@ -0,0 +1,33 @@ ++/* ++ * Copyright (c) 2020, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ * ++ * This file is a Partition Manifest (PM) for a minimal Secure Partition (SP) ++ * that has additional optional properties defined. ++ * ++ */ ++ ++/dts-v1/; ++ ++/ { ++ compatible = "arm,ffa-manifest-1.0"; ++ ++ /* Properties */ ++ description = "op-tee"; ++ ffa-version = <0x00010000>; /* 31:16 - Major, 15:0 - Minor */ ++ uuid = <0x486178e0 0xe7f811e3 0xbc5e0002 0xa5d5c51b>; ++ id = <1>; ++ execution-ctx-count = <4>; ++ exception-level = <2>; /* S-EL1 */ ++ execution-state = <0>; /* AARCH64 */ ++ load-address = <0xfd280000>; ++ entrypoint-offset = <0x1000>; ++ xlat-granule = <0>; /* 4KiB */ ++ boot-order = <0>; ++ messaging-method = <0>; /* Direct messaging only */ ++ run-time-model = <1>; /* Run to completion */ ++ ++ /* Boot protocol */ ++ gp-register-num = <0x0>; ++}; +diff --git a/core/arch/arm/plat-totalcompute/sp_layout.json b/core/arch/arm/plat-totalcompute/sp_layout.json +new file mode 100644 +index 00000000..05bc7851 +--- /dev/null ++++ b/core/arch/arm/plat-totalcompute/sp_layout.json +@@ -0,0 +1,6 @@ ++{ ++ "op-tee" : { ++ "image": "tee-pager_v2.bin", ++ "pm": "optee_manifest.dts" ++ } ++} +-- +2.26.2 + diff --git a/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0008-plat-totalcompute-define-tzdram-start-address-for-S-.patch b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0008-plat-totalcompute-define-tzdram-start-address-for-S-.patch new file mode 100644 index 00000000..015bdc92 --- /dev/null +++ b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0008-plat-totalcompute-define-tzdram-start-address-for-S-.patch @@ -0,0 +1,36 @@ +Upstream-Status: Pending [Not submitted to upstream yet] +Signed-off-by: Arunachalam Ganapathy + +From 1827607c6381339d051a36a84d749c3a50e3463d Mon Sep 17 00:00:00 2001 +From: Arunachalam Ganapathy +Date: Mon, 16 Nov 2020 17:38:07 +0000 +Subject: [PATCH 5/5] plat-totalcompute: define tzdram start address for S-EL1 + SPMC config + +Define TZDRAM_START for CFG_CORE_SEL1_SPMC config + +Change-Id: I71aaa92a0ecdb791802336ca31ab52e97ee52955 +Signed-off-by: Arunachalam Ganapathy +--- + core/arch/arm/plat-totalcompute/conf.mk | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/core/arch/arm/plat-totalcompute/conf.mk b/core/arch/arm/plat-totalcompute/conf.mk +index 34095acf..d330eb92 100644 +--- a/core/arch/arm/plat-totalcompute/conf.mk ++++ b/core/arch/arm/plat-totalcompute/conf.mk +@@ -24,7 +24,10 @@ endif + ifeq ($(PLATFORM_FLAVOR),tc0) + CFG_TEE_CORE_NB_CORE = 4 + +-ifeq ($(CFG_CORE_SEL2_SPMC),y) ++ifeq ($(CFG_CORE_SEL1_SPMC),y) ++CFG_TZDRAM_START ?= 0xfd000000 ++CFG_TZDRAM_SIZE ?= 0x02000000 ++else ifeq ($(CFG_CORE_SEL2_SPMC),y) + CFG_TZDRAM_START ?= 0xfd281000 + CFG_TZDRAM_SIZE ?= 0x01d7f000 + else +-- +2.26.2 + diff --git a/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0009-plat-totalcompute-add-Theodul-DSU-support.patch b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0009-plat-totalcompute-add-Theodul-DSU-support.patch new file mode 100644 index 00000000..e52a9d0c --- /dev/null +++ b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0009-plat-totalcompute-add-Theodul-DSU-support.patch @@ -0,0 +1,93 @@ +Upstream-Status: Pending [Not submitted to upstream yet] +Signed-off-by: Arunachalam Ganapathy + +From 3563e39d66404ff2415d29c4018757a85cd0ad97 Mon Sep 17 00:00:00 2001 +From: Arunachalam Ganapathy +Date: Wed, 13 Jan 2021 13:49:54 +0000 +Subject: [PATCH 1/3] plat-totalcompute: add Theodul DSU support + +- Change CPU count from 4 to 8 +- Set heap size to 128K +- In debug print, change EMSG to DMSG + +Change-Id: Ic426f5e08ac4e7ce1be37333486c75a3228e3415 +Signed-off-by: Arunachalam Ganapathy +--- + core/arch/arm/mm/mobj_ffa.c | 2 +- + core/arch/arm/plat-totalcompute/conf.mk | 4 +++- + core/arch/arm/plat-totalcompute/optee_manifest.dts | 2 +- + core/arch/arm/plat-totalcompute/tc0_spmc_pm.c | 10 +++++++++- + 4 files changed, 14 insertions(+), 4 deletions(-) + +diff --git a/core/arch/arm/mm/mobj_ffa.c b/core/arch/arm/mm/mobj_ffa.c +index 8e334f04..500404c3 100644 +--- a/core/arch/arm/mm/mobj_ffa.c ++++ b/core/arch/arm/mm/mobj_ffa.c +@@ -381,7 +381,7 @@ struct mobj *mobj_ffa_get_by_cookie(uint64_t cookie, + if (mf) + DMSG("cookie %#"PRIx64" resurrecting", cookie); + if (!mf) { +- EMSG("Populating mobj from rx buffer\n"); ++ DMSG("Populating mobj from rx: %#"PRIx64"", cookie); + mf = thread_spmc_populate_mobj_from_rx(cookie); + } + #endif +diff --git a/core/arch/arm/plat-totalcompute/conf.mk b/core/arch/arm/plat-totalcompute/conf.mk +index d330eb92..c35437aa 100644 +--- a/core/arch/arm/plat-totalcompute/conf.mk ++++ b/core/arch/arm/plat-totalcompute/conf.mk +@@ -22,7 +22,9 @@ platform-aflags-debug-info = -gdwarf-2 + endif + + ifeq ($(PLATFORM_FLAVOR),tc0) +-CFG_TEE_CORE_NB_CORE = 4 ++CFG_TEE_CORE_NB_CORE = 8 ++ ++CFG_CORE_HEAP_SIZE ?= 131072 + + ifeq ($(CFG_CORE_SEL1_SPMC),y) + CFG_TZDRAM_START ?= 0xfd000000 +diff --git a/core/arch/arm/plat-totalcompute/optee_manifest.dts b/core/arch/arm/plat-totalcompute/optee_manifest.dts +index 4e60cbe1..60cb5957 100644 +--- a/core/arch/arm/plat-totalcompute/optee_manifest.dts ++++ b/core/arch/arm/plat-totalcompute/optee_manifest.dts +@@ -18,7 +18,7 @@ + ffa-version = <0x00010000>; /* 31:16 - Major, 15:0 - Minor */ + uuid = <0x486178e0 0xe7f811e3 0xbc5e0002 0xa5d5c51b>; + id = <1>; +- execution-ctx-count = <4>; ++ execution-ctx-count = <8>; + exception-level = <2>; /* S-EL1 */ + execution-state = <0>; /* AARCH64 */ + load-address = <0xfd280000>; +diff --git a/core/arch/arm/plat-totalcompute/tc0_spmc_pm.c b/core/arch/arm/plat-totalcompute/tc0_spmc_pm.c +index 8e59a8cc..3fb32823 100644 +--- a/core/arch/arm/plat-totalcompute/tc0_spmc_pm.c ++++ b/core/arch/arm/plat-totalcompute/tc0_spmc_pm.c +@@ -17,7 +17,11 @@ static const uint64_t core_clus_aff_array[] = { + 0x0000, /* Cluster 0 Cpu 0 */ + 0x0001, /* Cluster 0 Cpu 1 */ + 0x0002, /* Cluster 0 Cpu 2 */ +- 0x0003 /* Cluster 0 Cpu 3 */ ++ 0x0003, /* Cluster 0 Cpu 3 */ ++ 0x0004, /* Cluster 0 Cpu 4 */ ++ 0x0005, /* Cluster 0 Cpu 5 */ ++ 0x0006, /* Cluster 0 Cpu 6 */ ++ 0x0007 /* Cluster 0 Cpu 7 */ + }; + + void ffa_secondary_cpu_boot_req(vaddr_t secondary_ep, uint64_t cookie) +@@ -38,6 +42,10 @@ void ffa_secondary_cpu_boot_req(vaddr_t secondary_ep, uint64_t cookie) + /* Create an mpidr from core_clus_aff_array */ + a1 |= core_clus_aff_array[cnt] << aff_shift; + ++ /* Ignore current cpu */ ++ if (a1 == mpidr) ++ continue; ++ + /* Invoke the PSCI_CPU_ON_SMC64 function */ + ret = thread_smc(PSCI_CPU_ON_SMC64, a1, secondary_ep, cookie); + +-- +2.29.2 + diff --git a/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0010-WIP-OP-TEE-SP-declare-device-regions-in-manifest.patch b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0010-WIP-OP-TEE-SP-declare-device-regions-in-manifest.patch new file mode 100644 index 00000000..fbc51618 --- /dev/null +++ b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0010-WIP-OP-TEE-SP-declare-device-regions-in-manifest.patch @@ -0,0 +1,47 @@ +Upstream-Status: Pending [Not submitted to upstream yet] +Signed-off-by: Arunachalam Ganapathy + +From fd325f731da694057a2738411faa2ccbeea71778 Mon Sep 17 00:00:00 2001 +From: Olivier Deprez +Date: Thu, 3 Dec 2020 22:29:37 +0100 +Subject: [PATCH 2/3] WIP OP-TEE SP declare device regions in manifest + +Secure Partitions must declare peripherals they access such +that the SPMC maps IO regions in SP's Stage-2 translation +regime. OP-TEE currently directly accesses the GIC Distributor +and the UART0 peripheral hence declare those device regions in +OP-TEE's manifest. + +Change-Id: I1fda46e5cf17153dfaf499042dceff325729d041 +Signed-off-by: Olivier Deprez +--- + .../arch/arm/plat-totalcompute/optee_manifest.dts | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +diff --git a/core/arch/arm/plat-totalcompute/optee_manifest.dts b/core/arch/arm/plat-totalcompute/optee_manifest.dts +index 60cb5957..cdc28d98 100644 +--- a/core/arch/arm/plat-totalcompute/optee_manifest.dts ++++ b/core/arch/arm/plat-totalcompute/optee_manifest.dts +@@ -30,4 +30,19 @@ + + /* Boot protocol */ + gp-register-num = <0x0>; ++ ++ device-regions { ++ compatible = "arm,ffa-manifest-device-regions"; ++ uart0 { ++ base-address = <0x00000000 0x7ff70000>; ++ pages-count = <1>; ++ attributes = <0x3>; /* read-write */ ++ }; ++ ++ gicd { ++ base-address = <0x00000000 0x30000000>; ++ pages-count = <16>; ++ attributes = <0x3>; /* read-write */ ++ }; ++ }; + }; +-- +2.29.2 + diff --git a/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0011-WIP-OP-TEE-SP-use-CNTVCT-in-place-of-CNTVCT.patch b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0011-WIP-OP-TEE-SP-use-CNTVCT-in-place-of-CNTVCT.patch new file mode 100644 index 00000000..323ace76 --- /dev/null +++ b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0011-WIP-OP-TEE-SP-use-CNTVCT-in-place-of-CNTVCT.patch @@ -0,0 +1,173 @@ +Upstream-Status: Pending [Not submitted to upstream yet] +Signed-off-by: Arunachalam Ganapathy + +From 85110aaf32b6d3b19fdca301f7a07a4683825802 Mon Sep 17 00:00:00 2001 +From: Olivier Deprez +Date: Thu, 3 Dec 2020 17:33:09 +0100 +Subject: [PATCH 3/3] WIP OP-TEE SP use CNTVCT in place of CNTVCT + +The SPMC forbids access to the physical counter and Secure Partitions +shall rather access the virtual counter (for which virtual offset is +set to 0). More information at [1]. + +[1] https://lists.trustedfirmware.org/pipermail/hafnium/2020-December/000092.html + +Change-Id: Ifab083921fa12154cafc31bd80ce91fa8da0db82 +Signed-off-by: Olivier Deprez +--- + core/arch/arm/include/arm64.h | 2 +- + core/arch/arm/include/kernel/delay.h | 4 ++-- + core/arch/arm/kernel/arm32_sysreg.txt | 2 +- + core/arch/arm/kernel/tee_time_arm_cntpct.c | 4 ++-- + core/kernel/tee_ta_manager.c | 4 ++-- + lib/libutee/arch/arm/arm32_user_sysreg.txt | 2 +- + lib/libutee/include/arm64_user_sysreg.h | 2 +- + lib/libutils/ext/ftrace/ftrace.c | 6 +++--- + 8 files changed, 13 insertions(+), 13 deletions(-) + +diff --git a/core/arch/arm/include/arm64.h b/core/arch/arm/include/arm64.h +index 40a6b113..46c5431f 100644 +--- a/core/arch/arm/include/arm64.h ++++ b/core/arch/arm/include/arm64.h +@@ -322,7 +322,7 @@ DEFINE_U32_REG_READ_FUNC(sctlr_el1) + + /* ARM Generic timer functions */ + DEFINE_REG_READ_FUNC_(cntfrq, uint32_t, cntfrq_el0) +-DEFINE_REG_READ_FUNC_(cntpct, uint64_t, cntpct_el0) ++DEFINE_REG_READ_FUNC_(cntvct, uint64_t, cntvct_el0) + DEFINE_REG_READ_FUNC_(cntkctl, uint32_t, cntkctl_el1) + DEFINE_REG_WRITE_FUNC_(cntkctl, uint32_t, cntkctl_el1) + DEFINE_REG_READ_FUNC_(cntps_ctl, uint32_t, cntps_ctl_el1) +diff --git a/core/arch/arm/include/kernel/delay.h b/core/arch/arm/include/kernel/delay.h +index 00510059..34629ba2 100644 +--- a/core/arch/arm/include/kernel/delay.h ++++ b/core/arch/arm/include/kernel/delay.h +@@ -44,12 +44,12 @@ static inline uint64_t arm_cnt_us2cnt(uint32_t us) + + static inline uint64_t timeout_init_us(uint32_t us) + { +- return read_cntpct() + arm_cnt_us2cnt(us); ++ return read_cntvct() + arm_cnt_us2cnt(us); + } + + static inline bool timeout_elapsed(uint64_t expire) + { +- return read_cntpct() > expire; ++ return read_cntvct() > expire; + } + + #endif +diff --git a/core/arch/arm/kernel/arm32_sysreg.txt b/core/arch/arm/kernel/arm32_sysreg.txt +index b69ebcb4..155773f8 100644 +--- a/core/arch/arm/kernel/arm32_sysreg.txt ++++ b/core/arch/arm/kernel/arm32_sysreg.txt +@@ -117,7 +117,7 @@ VBAR c12 0 c0 0 RW Vector Base Address Register + + @ B8.2 Generic Timer registers summary + CNTFRQ c14 0 c0 0 RW Counter Frequency register +-CNTPCT - 0 c14 - RO Physical Count register ++CNTVCT - 1 c14 - RO Physical Count register + CNTKCTL c14 0 c1 0 RW Timer PL1 Control register + CNTP_TVAL c14 0 c2 0 RW PL1 Physical TimerValue register + CNTP_CTL c14 0 c2 1 RW PL1 Physical Timer Control register +diff --git a/core/arch/arm/kernel/tee_time_arm_cntpct.c b/core/arch/arm/kernel/tee_time_arm_cntpct.c +index 3c41e4c2..04e673d9 100644 +--- a/core/arch/arm/kernel/tee_time_arm_cntpct.c ++++ b/core/arch/arm/kernel/tee_time_arm_cntpct.c +@@ -16,7 +16,7 @@ + + static TEE_Result arm_cntpct_get_sys_time(TEE_Time *time) + { +- uint64_t cntpct = read_cntpct(); ++ uint64_t cntpct = read_cntvct(); + uint32_t cntfrq = read_cntfrq(); + + time->seconds = cntpct / cntfrq; +@@ -49,7 +49,7 @@ REGISTER_TIME_SOURCE(arm_cntpct_time_source) + + void plat_prng_add_jitter_entropy(enum crypto_rng_src sid, unsigned int *pnum) + { +- uint64_t tsc = read_cntpct(); ++ uint64_t tsc = read_cntvct(); + int bytes = 0, n; + static uint8_t first, bits; + static uint16_t acc; +diff --git a/core/kernel/tee_ta_manager.c b/core/kernel/tee_ta_manager.c +index 46632ce7..4153fbd8 100644 +--- a/core/kernel/tee_ta_manager.c ++++ b/core/kernel/tee_ta_manager.c +@@ -923,7 +923,7 @@ static void gprof_update_session_utime(bool suspend, struct ts_session *s, + static void tee_ta_update_session_utime(bool suspend) + { + struct ts_session *s = ts_get_current_session(); +- uint64_t now = read_cntpct(); ++ uint64_t now = read_cntvct(); + + gprof_update_session_utime(suspend, s, now); + } +@@ -947,7 +947,7 @@ static void ftrace_update_times(bool suspend) + uint64_t now = 0; + uint32_t i = 0; + +- now = read_cntpct(); ++ now = read_cntvct(); + + fbuf = s->fbuf; + if (!fbuf) +diff --git a/lib/libutee/arch/arm/arm32_user_sysreg.txt b/lib/libutee/arch/arm/arm32_user_sysreg.txt +index 8baefd10..13e28f20 100644 +--- a/lib/libutee/arch/arm/arm32_user_sysreg.txt ++++ b/lib/libutee/arch/arm/arm32_user_sysreg.txt +@@ -10,4 +10,4 @@ + + @ B8.2 Generic Timer registers summary + CNTFRQ c14 0 c0 0 RW Counter Frequency register +-CNTPCT - 0 c14 - RO Physical Count register ++CNTVCT - 1 c14 - RO Physical Count register +diff --git a/lib/libutee/include/arm64_user_sysreg.h b/lib/libutee/include/arm64_user_sysreg.h +index db4ee188..722a08c9 100644 +--- a/lib/libutee/include/arm64_user_sysreg.h ++++ b/lib/libutee/include/arm64_user_sysreg.h +@@ -31,7 +31,7 @@ static inline __noprof void write_##reg(type val) \ + + /* ARM Generic timer functions */ + DEFINE_REG_READ_FUNC_(cntfrq, uint32_t, cntfrq_el0) +-DEFINE_REG_READ_FUNC_(cntpct, uint64_t, cntpct_el0) ++DEFINE_REG_READ_FUNC_(cntvct, uint64_t, cntvct_el0) + DEFINE_REG_READ_FUNC_(tpidr_el0, uint64_t, tpidr_el0) + DEFINE_REG_WRITE_FUNC_(tpidr_el0, uint64_t, tpidr_el0) + +diff --git a/lib/libutils/ext/ftrace/ftrace.c b/lib/libutils/ext/ftrace/ftrace.c +index 101aa594..637cbd19 100644 +--- a/lib/libutils/ext/ftrace/ftrace.c ++++ b/lib/libutils/ext/ftrace/ftrace.c +@@ -165,7 +165,7 @@ void __noprof ftrace_enter(unsigned long pc, unsigned long *lr) + + if (fbuf->ret_idx < FTRACE_RETFUNC_DEPTH) { + fbuf->ret_stack[fbuf->ret_idx] = *lr; +- fbuf->begin_time[fbuf->ret_idx] = read_cntpct(); ++ fbuf->begin_time[fbuf->ret_idx] = read_cntvct(); + fbuf->ret_idx++; + } else { + /* +@@ -269,7 +269,7 @@ unsigned long __noprof ftrace_return(void) + dur_loc = curr_buf - (fbuf->ret_idx + + (2 * sizeof(unsigned long)) + 11); + ftrace_duration(dur_loc, fbuf->begin_time[fbuf->ret_idx], +- read_cntpct()); ++ read_cntvct()); + } else { + bool full = false; + +@@ -297,7 +297,7 @@ unsigned long __noprof ftrace_return(void) + dur_loc = curr_buf - fbuf->ret_idx - 6; + ftrace_duration(dur_loc, + fbuf->begin_time[fbuf->ret_idx], +- read_cntpct()); ++ read_cntvct()); + } + } + +-- +2.29.2 + diff --git a/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0012-core-Add-FFA_SECONDARY_EP_REGISTER-support.patch b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0012-core-Add-FFA_SECONDARY_EP_REGISTER-support.patch new file mode 100644 index 00000000..47a31bf2 --- /dev/null +++ b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0012-core-Add-FFA_SECONDARY_EP_REGISTER-support.patch @@ -0,0 +1,155 @@ +From 5d903d035e376e3b4c411e4f8947f6508ef577d9 Mon Sep 17 00:00:00 2001 +From: Arunachalam Ganapathy +Date: Mon, 12 Apr 2021 15:42:29 +0100 +Subject: [PATCH 1/2] core: Add FFA_SECONDARY_EP_REGISTER support + +Signed-off-by: Olivier Deprez +Signed-off-by: Arunachalam Ganapathy +Change-Id: I806b07b815278512abaecc7c77b29a0d395e3d35 +Upstream-Status: Pending [Not submitted to upstream yet] +--- + core/arch/arm/include/ffa.h | 3 +- + core/arch/arm/include/kernel/boot.h | 3 +- + core/arch/arm/kernel/entry_a64.S | 3 +- + core/arch/arm/plat-totalcompute/tc0_spmc_pm.c | 55 ++++--------------- + 4 files changed, 17 insertions(+), 47 deletions(-) + +diff --git a/core/arch/arm/include/ffa.h b/core/arch/arm/include/ffa.h +index 6c78dacc..f5480c00 100644 +--- a/core/arch/arm/include/ffa.h ++++ b/core/arch/arm/include/ffa.h +@@ -1,7 +1,7 @@ + /* SPDX-License-Identifier: BSD-3-Clause */ + /* + * Copyright (c) 2020, Linaro Limited +- * Copyright (c) 2018-2019, Arm Limited. All rights reserved. ++ * Copyright (c) 2018-2021, Arm Limited. All rights reserved. + */ + + #ifndef __FFA_H +@@ -68,6 +68,7 @@ + #define FFA_MEM_RECLAIM U(0x84000077) + #define FFA_MEM_FRAG_RX U(0x8400007A) + #define FFA_MEM_FRAG_TX U(0x8400007B) ++#define FFA_SECONDARY_EP_REGISTER_64 U(0xC4000084) + + /* Special value for traffic targeted to the Hypervisor or SPM */ + #define FFA_TARGET_INFO_MBZ U(0x0) +diff --git a/core/arch/arm/include/kernel/boot.h b/core/arch/arm/include/kernel/boot.h +index 278d514f..30eb1596 100644 +--- a/core/arch/arm/include/kernel/boot.h ++++ b/core/arch/arm/include/kernel/boot.h +@@ -1,6 +1,7 @@ + /* SPDX-License-Identifier: BSD-2-Clause */ + /* + * Copyright (c) 2015-2020, Linaro Limited ++ * Copyright (c) 2021, Arm Limited. All rights reserved. + */ + #ifndef __KERNEL_BOOT_H + #define __KERNEL_BOOT_H +@@ -86,6 +87,6 @@ void *get_external_dt(void); + + unsigned long get_aslr_seed(void *fdt); + +-void ffa_secondary_cpu_boot_req(vaddr_t secondary_ep, uint64_t cookie); ++void ffa_secondary_cpu_ep_register(vaddr_t secondary_ep); + + #endif /* __KERNEL_BOOT_H */ +diff --git a/core/arch/arm/kernel/entry_a64.S b/core/arch/arm/kernel/entry_a64.S +index 9ae6b32e..7d7b8aaf 100644 +--- a/core/arch/arm/kernel/entry_a64.S ++++ b/core/arch/arm/kernel/entry_a64.S +@@ -1,6 +1,7 @@ + /* SPDX-License-Identifier: BSD-2-Clause */ + /* + * Copyright (c) 2015, Linaro Limited ++ * Copyright (c) 2021, Arm Limited. All rights reserved. + */ + + #include +@@ -239,7 +240,7 @@ clear_nex_bss: + */ + ldr x1, boot_mmu_config + CORE_MMU_CONFIG_LOAD_OFFSET + sub x0, x0, x1 +- bl ffa_secondary_cpu_boot_req ++ bl ffa_secondary_cpu_ep_register + b thread_ffa_msg_wait + #else + /* +diff --git a/core/arch/arm/plat-totalcompute/tc0_spmc_pm.c b/core/arch/arm/plat-totalcompute/tc0_spmc_pm.c +index 3fb32823..f31324b9 100644 +--- a/core/arch/arm/plat-totalcompute/tc0_spmc_pm.c ++++ b/core/arch/arm/plat-totalcompute/tc0_spmc_pm.c +@@ -1,6 +1,6 @@ + // SPDX-License-Identifier: BSD-2-Clause + /* +- * Copyright (c) 2020, Arm Limited ++ * Copyright (c) 2020 - 2021, Arm Limited + */ + + #include +@@ -8,51 +8,18 @@ + #include + #include + +-/* +- * Lookup table of core and cluster affinities on the TC0. In the absence of a +- * DT that provides the same information, this table is used to initialise +- * OP-TEE on secondary cores. +- */ +-static const uint64_t core_clus_aff_array[] = { +- 0x0000, /* Cluster 0 Cpu 0 */ +- 0x0001, /* Cluster 0 Cpu 1 */ +- 0x0002, /* Cluster 0 Cpu 2 */ +- 0x0003, /* Cluster 0 Cpu 3 */ +- 0x0004, /* Cluster 0 Cpu 4 */ +- 0x0005, /* Cluster 0 Cpu 5 */ +- 0x0006, /* Cluster 0 Cpu 6 */ +- 0x0007 /* Cluster 0 Cpu 7 */ +-}; +- +-void ffa_secondary_cpu_boot_req(vaddr_t secondary_ep, uint64_t cookie) ++void ffa_secondary_cpu_ep_register(vaddr_t secondary_ep) + { +- unsigned long mpidr = read_mpidr(); +- unsigned int aff_shift = 0; +- unsigned long a1 = 0; +- unsigned int cnt = 0; +- int32_t ret = 0; +- +- if (mpidr & MPIDR_MT_MASK) +- aff_shift = MPIDR_CLUSTER_SHIFT; ++ unsigned int ret = 0; + +- for (cnt = 0; cnt < ARRAY_SIZE(core_clus_aff_array); cnt++) { +- /* Clear out the affinity fields until level 2 */ +- a1 = mpidr & ~(unsigned long)MPIDR_AARCH32_AFF_MASK; ++ /* Invoke FFA_SECONDARY_EP_REGISTER_64 to the SPMC */ ++ ret = thread_smc(FFA_SECONDARY_EP_REGISTER_64, secondary_ep, 0, 0); + +- /* Create an mpidr from core_clus_aff_array */ +- a1 |= core_clus_aff_array[cnt] << aff_shift; +- +- /* Ignore current cpu */ +- if (a1 == mpidr) +- continue; +- +- /* Invoke the PSCI_CPU_ON_SMC64 function */ +- ret = thread_smc(PSCI_CPU_ON_SMC64, a1, secondary_ep, cookie); +- +- if (ret != PSCI_RET_SUCCESS) +- EMSG("PSCI_CPU_ON op on mpidr 0x%lx failed %"PRId32, +- a1, ret); +- else +- DMSG("PSCI_CPU_ON op on mpidr 0x%lx done", a1); ++ if (ret != FFA_SUCCESS_32) { ++ EMSG("FFA_SECONDARY_EP_REGISTER_64 ret %"PRId32, ret); ++ } else { ++ DMSG("FFA_SECONDARY_EP_REGISTER_64 done"); + } ++ ++ return; + } +-- +2.29.2 + diff --git a/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0013-core-arm-modify-FFA-ABIs-with-supported-convention.patch b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0013-core-arm-modify-FFA-ABIs-with-supported-convention.patch new file mode 100644 index 00000000..bf8f3586 --- /dev/null +++ b/meta-arm-bsp/recipes-security/optee/files/optee-os/tc0/0013-core-arm-modify-FFA-ABIs-with-supported-convention.patch @@ -0,0 +1,79 @@ +From 6b7edfa39991079fc735a2afcba23454ae0205ed Mon Sep 17 00:00:00 2001 +From: Arunachalam Ganapathy +Date: Mon, 12 Apr 2021 15:29:13 +0100 +Subject: [PATCH 2/2] core: arm: modify FFA ABIs with supported convention + +Use FFA_MEM_RETRIEVE_REQ_32 as SPMC at SEL2 (hafnium) only supports 32-bit variant +Fix warnings in thread_spmc.c + +Change-Id: Ia3d206d24f7f12dca9332b40f45934e132a37f99 +Signed-off-by: Arunachalam Ganapathy +Upstream-Status: Pending [Not submitted to upstream yet] +--- + core/arch/arm/kernel/thread_spmc.c | 13 ++++++++----- + 1 file changed, 8 insertions(+), 5 deletions(-) + +diff --git a/core/arch/arm/kernel/thread_spmc.c b/core/arch/arm/kernel/thread_spmc.c +index 872221d6..f8a05412 100644 +--- a/core/arch/arm/kernel/thread_spmc.c ++++ b/core/arch/arm/kernel/thread_spmc.c +@@ -1,7 +1,7 @@ + // SPDX-License-Identifier: BSD-2-Clause + /* + * Copyright (c) 2020, Linaro Limited. +- * Copyright (c) 2019, Arm Limited. All rights reserved. ++ * Copyright (c) 2019 - 2021, Arm Limited. All rights reserved. + */ + + #include +@@ -128,8 +128,10 @@ static unsigned int rxtx_size; + static unsigned int rxtx_spinlock; + static bool tx_buf_is_mine; + ++#ifdef CFG_CORE_SEL1_SPMC + static SLIST_HEAD(mem_frag_state_head, mem_frag_state) frag_state_head = + SLIST_HEAD_INITIALIZER(&frag_state_head); ++#endif + + static uint32_t swap_src_dst(uint32_t src_dst) + { +@@ -387,7 +389,8 @@ static void handle_partition_info_get(struct thread_smc_args *args) + + cpu_spin_lock(&rxtx_spinlock); + if (rxtx_size && tx_buf_is_mine) { +- struct ffa_partition_info *fpi = tx_buf; ++ struct ffa_partition_info *fpi = ++ (struct ffa_partition_info *)tx_buf; + + fpi->id = my_sp_id; + fpi->execution_context = CFG_TEE_CORE_NB_CORE; +@@ -874,7 +877,7 @@ void thread_spmc_msg_recv(struct thread_smc_args *args) + case FFA_FEATURES: + handle_features(args); + break; +-#if CFG_CORE_SEL1_SPMC ++#ifdef CFG_CORE_SEL1_SPMC + #ifdef ARM64 + case FFA_RXTX_MAP_64: + #endif +@@ -901,7 +904,7 @@ void thread_spmc_msg_recv(struct thread_smc_args *args) + else + handle_blocking_call(args); + break; +-#if CFG_CORE_SEL1_SPMC ++#ifdef CFG_CORE_SEL1_SPMC + #ifdef ARM64 + case FFA_MEM_SHARE_64: + #endif +@@ -1266,7 +1269,7 @@ static struct mem_transaction_descr *spmc_retrieve_req(uint64_t cookie) + uint64_t size = sizeof(*retrieve_region) + + 1 * sizeof(struct mem_access_descr); + struct thread_smc_args args = { +- .a0 = FFA_MEM_RETRIEVE_REQ_64, ++ .a0 = FFA_MEM_RETRIEVE_REQ_32, + .a1 = size, // Total Length + .a2 = size, // Frag Length == Total length + .a3 = 0, // Address, Using TX -> MBZ +-- +2.29.2 + diff --git a/meta-arm-bsp/recipes-security/optee/optee-client-tc0.inc b/meta-arm-bsp/recipes-security/optee/optee-client-tc0.inc new file mode 100644 index 00000000..ad9c4758 --- /dev/null +++ b/meta-arm-bsp/recipes-security/optee/optee-client-tc0.inc @@ -0,0 +1,12 @@ +# TC0 specific configuration + +# Intermediate SHA with 3.11 baseline version +SRCREV = "3f44b870299514ad8c6b7dee776eb2994d9c1cd4" +PV = "3.11.0+git${SRCPV}" + +FILESEXTRAPATHS_prepend_tc0 := "${THISDIR}/files/optee-client/tc0:" + +SRC_URI_append = " \ + file://0001-Revert-libteec-Avoid-memcpy-when-using-TEEC_TempMemo.patch \ + file://0002-Allocate-page-aligned-shared-memory-buffers.patch \ + " diff --git a/meta-arm-bsp/recipes-security/optee/optee-client_3.11.0.bbappend b/meta-arm-bsp/recipes-security/optee/optee-client_3.11.0.bbappend new file mode 100644 index 00000000..fa4fd690 --- /dev/null +++ b/meta-arm-bsp/recipes-security/optee/optee-client_3.11.0.bbappend @@ -0,0 +1,6 @@ +# Machine specific configurations + +MACHINE_OPTEE_CLIENT_REQUIRE ?= "" +MACHINE_OPTEE_CLIENT_REQUIRE_tc0 = "optee-client-tc0.inc" + +require ${MACHINE_OPTEE_CLIENT_REQUIRE} diff --git a/meta-arm-bsp/recipes-security/optee/optee-os-tc0.inc b/meta-arm-bsp/recipes-security/optee/optee-os-tc0.inc new file mode 100644 index 00000000..10556f2f --- /dev/null +++ b/meta-arm-bsp/recipes-security/optee/optee-os-tc0.inc @@ -0,0 +1,56 @@ +# TC0 specific configuration + +# Intermediate SHA with 3.11 baseline version +SRCREV = "3284d935bc7e7bf7abfb5b19394a387d975d6dd4" +PV = "3.11.0+git${SRCPV}" + +# This is incorporated into the SRCREV above +SRC_URI_remove = " \ + file://0001-libutils-provide-empty-__getauxval-implementation.patch \ + file://0002-link.mk-implement-support-for-libnames-after-libgcc-.patch \ + file://0003-ta_dev_kit.mk-make-sure-that-libutils-is-linked-seco.patch \ + " + +FILESEXTRAPATHS_prepend_tc0 := "${THISDIR}/files/optee-os/tc0:" + +SRC_URI_append = " \ + file://0001-core-SPMC-update-for-FF-A-version-1.0.patch \ + file://0002-core-add-thread_smccc.patch \ + file://0003-core-enable-SPCI-with-SPM-Core-at-S-EL2.patch \ + file://0004-core-fixes-to-align-with-upstream-hafnium.patch \ + file://0005-core-arm-Total-Compute-platform-support.patch \ + file://0006-plat-totalcompute-Add-support-for-S-EL2-SPMC.patch \ + file://0007-plat-totalcompute-add-optee-manifest-file-and-sp-lay.patch \ + file://0008-plat-totalcompute-define-tzdram-start-address-for-S-.patch \ + file://0009-plat-totalcompute-add-Theodul-DSU-support.patch \ + file://0010-WIP-OP-TEE-SP-declare-device-regions-in-manifest.patch \ + file://0011-WIP-OP-TEE-SP-use-CNTVCT-in-place-of-CNTVCT.patch \ + file://0012-core-Add-FFA_SECONDARY_EP_REGISTER-support.patch \ + file://0013-core-arm-modify-FFA-ABIs-with-supported-convention.patch \ + " + +COMPATIBLE_MACHINE = "tc0" + +OPTEEMACHINE = "totalcompute-tc0" + +# Enable optee memory layout and boot logs +EXTRA_OEMAKE += " CFG_TEE_CORE_LOG_LEVEL=3" + +# default disable latency benchmarks (over all OP-TEE layers) +EXTRA_OEMAKE += " CFG_TEE_BENCHMARK=n" + +# Enable stats +EXTRA_OEMAKE += " CFG_WITH_STATS=y" + +EXTRA_OEMAKE += " CFG_CORE_SEL2_SPMC=y" + +# Copy optee manifest file and sp_layout +# This function will be modified or removed once upstream optee-os adds support +# for SEL2 SPMC config +do_install_append() { + install -d ${D}${nonarch_base_libdir}/firmware/ + install -m 644 ${S}/core/arch/arm/plat-totalcompute/sp_layout.json \ + ${D}${nonarch_base_libdir}/firmware/ + install -m 644 ${S}/core/arch/arm/plat-totalcompute/optee_manifest.dts \ + ${D}${nonarch_base_libdir}/firmware/ +} diff --git a/meta-arm-bsp/recipes-security/optee/optee-os_3.11.0.bbappend b/meta-arm-bsp/recipes-security/optee/optee-os_3.11.0.bbappend new file mode 100644 index 00000000..7b96a4d9 --- /dev/null +++ b/meta-arm-bsp/recipes-security/optee/optee-os_3.11.0.bbappend @@ -0,0 +1,6 @@ +# Machine specific configurations + +MACHINE_OPTEE_OS_REQUIRE ?= "" +MACHINE_OPTEE_OS_REQUIRE_tc0 = "optee-os-tc0.inc" + +require ${MACHINE_OPTEE_OS_REQUIRE} diff --git a/meta-arm-bsp/recipes-security/optee/optee-test-tc0.inc b/meta-arm-bsp/recipes-security/optee/optee-test-tc0.inc new file mode 100644 index 00000000..cca5076f --- /dev/null +++ b/meta-arm-bsp/recipes-security/optee/optee-test-tc0.inc @@ -0,0 +1,14 @@ +# TC0 specific configuration + +# Intermediate SHA with 3.11 baseline version +SRCREV = "b35df64954ef96e09c0d5573014f4d1432dbc92f" +PV = "3.11.0+git${SRCPV}" + +# This is incorporated into the SRCREV above +SRC_URI_remove = " \ + file://0001-host-xtest-Adjust-order-of-including-compiler.h.patch \ + file://0002-make-remove-Wno-unsafe-loop-for-clang.patch \ + file://0003-make-remove-Wmissing-noreturn-for-clang.patch \ +" + +COMPATIBLE_MACHINE = "tc0" diff --git a/meta-arm-bsp/recipes-security/optee/optee-test_3.11.0.bbappend b/meta-arm-bsp/recipes-security/optee/optee-test_3.11.0.bbappend new file mode 100644 index 00000000..4fd1cdee --- /dev/null +++ b/meta-arm-bsp/recipes-security/optee/optee-test_3.11.0.bbappend @@ -0,0 +1,6 @@ +# Machine specific configurations + +MACHINE_OPTEE_TEST_REQUIRE ?= "" +MACHINE_OPTEE_TEST_REQUIRE_tc0 = "optee-test-tc0.inc" + +require ${MACHINE_OPTEE_TEST_REQUIRE} diff --git a/meta-arm-bsp/wic/n1sdp-efidisk.wks b/meta-arm-bsp/wic/n1sdp-efidisk.wks index d1ebfb82..b131dd84 100644 --- a/meta-arm-bsp/wic/n1sdp-efidisk.wks +++ b/meta-arm-bsp/wic/n1sdp-efidisk.wks @@ -6,6 +6,4 @@ part /boot --source bootimg-efi --sourceparams="loader=grub-efi" --ondisk sda -- part / --source rootfs --ondisk sda --fstype=ext4 --label root --align 1024 --uuid=6a60524d-061d-454a-bfd1-38989910eccd -part swap --ondisk sda --size 44 --label swap1 --fstype=swap - bootloader --ptable gpt --configfile="n1sdp-grub.cfg" --timeout=5 diff --git a/meta-arm-toolchain/conf/layer.conf b/meta-arm-toolchain/conf/layer.conf index d0ca75ad..1a0499d3 100644 --- a/meta-arm-toolchain/conf/layer.conf +++ b/meta-arm-toolchain/conf/layer.conf @@ -6,7 +6,7 @@ BBFILES += "\ BBFILE_COLLECTIONS += "arm-toolchain" BBFILE_PATTERN_arm-toolchain := "^${LAYERDIR}/" -BBFILE_PRIORITY_arm-toolchain = "30" +BBFILE_PRIORITY_arm-toolchain = "5" # Additional license directories. LICENSE_PATH += "${LAYERDIR}/custom-licenses" diff --git a/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/external-arm-toolchain.bb b/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/external-arm-toolchain.bb index b44fd2f4..c506c419 100644 --- a/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/external-arm-toolchain.bb +++ b/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/external-arm-toolchain.bb @@ -115,6 +115,8 @@ do_install() { rm -rf ${D}${bindir}/gdbserver sed -i -e 's#/arm/tools/gnu/bash/4.2/rhe6-x86_64##' ${D}${bindir}/tzselect sed -i -e 's#/arm/tools/gnu/bash/4.2/rhe6-x86_64##' ${D}${bindir}/ldd + sed -i -e 's#/usr/bin/bash#/bin/sh#' ${D}${bindir}/tzselect + sed -i -e 's#/usr/bin/bash#/bin/sh#' ${D}${bindir}/ldd sed -i -e 's#/bin/bash#/bin/sh#' ${D}${bindir}/tzselect sed -i -e 's#/bin/bash#/bin/sh#' ${D}${bindir}/ldd diff --git a/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-aarch64-none-elf_9.2-2019.12.bb b/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-aarch64-none-elf_9.2-2019.12.bb index 221c07aa..5df37278 100644 --- a/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-aarch64-none-elf_9.2-2019.12.bb +++ b/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-aarch64-none-elf_9.2-2019.12.bb @@ -19,3 +19,6 @@ SRC_URI[gnu-a-x86_64.sha256sum] = "36d2cbe7c2984f2c20f562ac2f3ba524c59151adfa8ee SRC_URI[gnu-a-aarch64.sha256sum] = "041ca53bdd434b1a48f32161e957da1b84543c373d1881e2fd84a1579f87f243" 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/gnu-a/downloads" +UPSTREAM_CHECK_REGEX = "gcc-arm-(?P.+)-${HOST_ARCH}-${BINNAME}\.tar\.\w+" diff --git a/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-arm-none-eabi_9-2019-q4-major.bb b/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-arm-none-eabi_9-2019-q4-major.bb index ede9ae99..a9f80797 100644 --- a/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-arm-none-eabi_9-2019-q4-major.bb +++ b/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-arm-none-eabi_9-2019-q4-major.bb @@ -15,3 +15,6 @@ PROVIDES = "virtual/arm-none-eabi-gcc" SRC_URI = "https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/${BPN}-${PV}-${HOST_ARCH}-linux.tar.bz2;name=gnu-rm-${HOST_ARCH}" SRC_URI[gnu-rm-x86_64.sha256sum] = "bcd840f839d5bf49279638e9f67890b2ef3a7c9c7a9b25271e83ec4ff41d177a" SRC_URI[gnu-rm-aarch64.sha256sum] = "1f5b9309006737950b2218250e6bb392e2d68d4f1a764fe66be96e2a78888d83" + +UPSTREAM_CHECK_URI = "https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads" +UPSTREAM_CHECK_REGEX = "${BPN}-(?P.+)-${HOST_ARCH}-linux\.tar\.\w+" diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2.inc b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2.inc new file mode 100644 index 00000000..2a822930 --- /dev/null +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2.inc @@ -0,0 +1,121 @@ +require recipes-devtools/gcc/gcc-common.inc + +# Third digit in PV should be incremented after a minor release + +PV = "arm-10.2" +CVE_VERSION = "10.2" + +# BINV should be incremented to a revision after a minor gcc release + +BINV = "10.2.1" + +MMYY = "20.11" +RELEASE = "20${MMYY}" +PR = "r${RELEASE}" + +FILESEXTRAPATHS =. "${FILE_DIRNAME}/gcc-arm-10.2:${FILE_DIRNAME}/gcc-arm-10.2/backport:" + +DEPENDS =+ "mpfr gmp libmpc zlib flex-native" +NATIVEDEPS = "mpfr-native gmp-native libmpc-native zlib-native flex-native" + +LICENSE = "GPL-3.0-with-GCC-exception & GPLv3" + +LIC_FILES_CHKSUM = "\ + file://COPYING;md5=59530bdf33659b29e73d4adb9f9f6552 \ + file://COPYING3;md5=d32239bcb673463ab874e80d47fae504 \ + file://COPYING3.LIB;md5=6a6a8e020838b23406c81b19c1d46df6 \ + file://COPYING.LIB;md5=2d5025d4aa3495befef8f17206a5b0a1 \ + file://COPYING.RUNTIME;md5=fe60d87048567d4fe8c8a0ed2448bcc8 \ +" + +BASEURI ?= "https://developer.arm.com/-/media/Files/downloads/gnu-a/10.2-2020.11/srcrel/gcc-arm-src-snapshot-10.2-2020.11.tar.xz" +SRC_URI = "\ + ${BASEURI} \ + file://0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch \ + file://0002-gcc-poison-system-directories.patch \ + file://0003-gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch \ + file://0004-64-bit-multilib-hack.patch \ + file://0005-optional-libstdc.patch \ + file://0006-COLLECT_GCC_OPTIONS.patch \ + file://0007-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch \ + file://0008-fortran-cross-compile-hack.patch \ + file://0009-cpp-honor-sysroot.patch \ + file://0010-MIPS64-Default-to-N64-ABI.patch \ + file://0011-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch \ + file://0012-gcc-Fix-argument-list-too-long-error.patch \ + file://0013-Disable-sdt.patch \ + file://0014-libtool.patch \ + file://0015-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch \ + file://0016-Use-the-multilib-config-files-from-B-instead-of-usin.patch \ + file://0017-Avoid-using-libdir-from-.la-which-usually-points-to-.patch \ + file://0018-export-CPP.patch \ + file://0019-Ensure-target-gcc-headers-can-be-included.patch \ + file://0020-Don-t-search-host-directory-during-relink-if-inst_pr.patch \ + file://0021-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch \ + file://0022-aarch64-Add-support-for-musl-ldso.patch \ + file://0023-libcc1-fix-libcc1-s-install-path-and-rpath.patch \ + file://0024-handle-sysroot-support-for-nativesdk-gcc.patch \ + file://0025-Search-target-sysroot-gcc-version-specific-dirs-with.patch \ + file://0026-Fix-various-_FOR_BUILD-and-related-variables.patch \ + file://0027-nios2-Define-MUSL_DYNAMIC_LINKER.patch \ + file://0028-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch \ + file://0029-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch \ + file://0030-sync-gcc-stddef.h-with-musl.patch \ + file://0031-fix-segmentation-fault-in-precompiled-header-generat.patch \ + file://0032-Fix-for-testsuite-failure.patch \ + file://0033-Re-introduce-spe-commandline-options.patch \ + file://0034-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch \ + file://0035-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch \ + file://0036-mingw32-Enable-operation_not_supported.patch \ + file://0037-libatomic-Do-not-enforce-march-on-aarch64.patch \ + file://0001-lib-Remove-i-86-march-overrides.patch \ +" +SRC_URI[md5sum] = "ce6ebec573e3e52cdb770c8f822aad17" + +S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/gcc-arm-src-snapshot-10.2-2020.11" +# For dev release snapshotting +#S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/gcc-${RELEASE}" +#B = "${WORKDIR}/gcc-${PV}/build.${HOST_SYS}.${TARGET_SYS}" + +# Language Overrides +FORTRAN = "" +JAVA = "" + +SSP ?= "--disable-libssp" +SSP_mingw32 = "--enable-libssp" + +EXTRA_OECONF_BASE = "\ + ${SSP} \ + --enable-libitm \ + --enable-lto \ + --disable-bootstrap \ + --with-system-zlib \ + ${@'--with-linker-hash-style=${LINKER_HASH_STYLE}' if '${LINKER_HASH_STYLE}' else ''} \ + --enable-linker-build-id \ + --with-ppl=no \ + --with-cloog=no \ + --enable-checking=release \ + --enable-cheaders=c_global \ + --without-isl \ +" + +EXTRA_OECONF_INITIAL = "\ + --disable-libgomp \ + --disable-libitm \ + --disable-libquadmath \ + --with-system-zlib \ + --disable-lto \ + --disable-plugin \ + --enable-linker-build-id \ + --enable-decimal-float=no \ + --without-isl \ + --disable-libssp \ +" + +EXTRA_OECONF_append_aarchilp32 = " --with-abi=ilp32" + +EXTRA_OECONF_PATHS = "\ + --with-gxx-include-dir=/not/exist{target_includedir}/c++/${BINV} \ + --with-sysroot=/not/exist \ + --with-build-sysroot=${STAGING_DIR_TARGET} \ +" diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch similarity index 79% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch index 4ad79e44..82ae9f8d 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch @@ -1,7 +1,7 @@ -From d7b284a9bede9d5059ad7e95a867254bf913c638 Mon Sep 17 00:00:00 2001 +From f2a5dc3bc7e5727d6bf77e1c6e8a31a6f000883d Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 29 Mar 2013 08:37:11 +0400 -Subject: [PATCH 01/40] gcc-4.3.1: ARCH_FLAGS_FOR_TARGET +Subject: [PATCH] gcc-4.3.1: ARCH_FLAGS_FOR_TARGET Signed-off-by: Khem Raj @@ -12,10 +12,10 @@ Upstream-Status: Inappropriate [embedded specific] 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure -index 0601395512f..8c5b1e9d561 100755 +index 4cc938ebb7d..226a64939d1 100755 --- a/configure +++ b/configure -@@ -7507,7 +7507,7 @@ fi +@@ -7722,7 +7722,7 @@ fi # for target_alias and gcc doesn't manage it consistently. target_configargs="--cache-file=./config.cache ${target_configargs}" @@ -25,10 +25,10 @@ index 0601395512f..8c5b1e9d561 100755 *" newlib "*) case " $target_configargs " in diff --git a/configure.ac b/configure.ac -index c3433336523..69c31c65ad7 100644 +index c78d9cbea62..f024f4bac9b 100644 --- a/configure.ac +++ b/configure.ac -@@ -3096,7 +3096,7 @@ fi +@@ -3227,7 +3227,7 @@ fi # for target_alias and gcc doesn't manage it consistently. target_configargs="--cache-file=./config.cache ${target_configargs}" @@ -37,6 +37,3 @@ index c3433336523..69c31c65ad7 100644 case " $target_configdirs " in *" newlib "*) case " $target_configargs " in --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0001-lib-Remove-i-86-march-overrides.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0001-lib-Remove-i-86-march-overrides.patch new file mode 100644 index 00000000..3f04e121 --- /dev/null +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0001-lib-Remove-i-86-march-overrides.patch @@ -0,0 +1,113 @@ +From 3776789cde95916f95deef48acf9532b0ebf91ae Mon Sep 17 00:00:00 2001 +From: Nathan Rossi +Date: Tue, 15 Dec 2020 11:43:36 +1000 +Subject: [PATCH] lib*: Remove i*86 march overrides + +OE does not pass the '--with-arch' option to gccs configure, as such +some gcc-runtime libraries try to override the value of '-march' and +'-mtune' which OE already provides. This causes conflicts with other +i*86 instruction/architecture flags (e.g. -msse* and -mfpmath=*). +Additionally this caused the following libraries to be built with less +optimized tune configurations. + +Upstream suggests that this should be detecting or otherwise checking if +the target supports the desired functionality before overriding. + + https://gcc.gnu.org/legacy-ml/gcc-patches/2016-04/msg01344.html + +libatomic also overrides the '-march' specifically for IFUNC objects. +OE already supplies the correct march flag, so remove setting. + +Upstream-Status: Inappropriate [OE Specific] +Signed-off-by: Nathan Rossi +--- + libatomic/Makefile.am | 1 - + libatomic/Makefile.in | 1 - + libatomic/configure.tgt | 9 --------- + libgomp/configure.tgt | 8 -------- + libitm/configure.tgt | 9 --------- + 5 files changed, 28 deletions(-) + +diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am +index ac1ca64587..5aa16e0699 100644 +--- a/libatomic/Makefile.am ++++ b/libatomic/Makefile.am +@@ -133,7 +133,6 @@ libatomic_la_LIBADD += $(foreach s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS)) + libatomic_la_LIBADD += $(addsuffix _8_2_.lo,$(SIZEOBJS)) + endif + if ARCH_I386 +-IFUNC_OPTIONS = -march=i586 + libatomic_la_LIBADD += $(addsuffix _8_1_.lo,$(SIZEOBJS)) + endif + if ARCH_X86_64 +diff --git a/libatomic/Makefile.in b/libatomic/Makefile.in +index 97df2d7ff0..82c511d420 100644 +--- a/libatomic/Makefile.in ++++ b/libatomic/Makefile.in +@@ -432,7 +432,6 @@ libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix \ + _$(s)_.lo,$(SIZEOBJS))) $(am__append_1) $(am__append_2) \ + $(am__append_3) $(am__append_4) + @ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=armv7-a+fp -DHAVE_KERNEL64 +-@ARCH_I386_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=i586 + @ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -mcx16 + libatomic_convenience_la_SOURCES = $(libatomic_la_SOURCES) + libatomic_convenience_la_LIBADD = $(libatomic_la_LIBADD) +diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt +index 5dd0926d20..3cc41773c3 100644 +--- a/libatomic/configure.tgt ++++ b/libatomic/configure.tgt +@@ -82,15 +82,6 @@ case "${target_cpu}" in + ;; + + i[3456]86) +- case " ${CC} ${CFLAGS} " in +- *" -m64 "*|*" -mx32 "*) +- ;; +- *) +- if test -z "$with_arch"; then +- XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}" +- XCFLAGS="${XCFLAGS} -fomit-frame-pointer" +- fi +- esac + ARCH=x86 + # ??? Detect when -march=i686 is already enabled. + try_ifunc=yes +diff --git a/libgomp/configure.tgt b/libgomp/configure.tgt +index 4790a31e39..46c4c958e6 100644 +--- a/libgomp/configure.tgt ++++ b/libgomp/configure.tgt +@@ -72,14 +72,6 @@ if test x$enable_linux_futex = xyes; then + # Note that bare i386 is not included here. We need cmpxchg. + i[456]86-*-linux*) + config_path="linux/x86 linux posix" +- case " ${CC} ${CFLAGS} " in +- *" -m64 "*|*" -mx32 "*) +- ;; +- *) +- if test -z "$with_arch"; then +- XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}" +- fi +- esac + ;; + + # Similar jiggery-pokery for x86_64 multilibs, except here we +diff --git a/libitm/configure.tgt b/libitm/configure.tgt +index 04109160e9..3d78ea609d 100644 +--- a/libitm/configure.tgt ++++ b/libitm/configure.tgt +@@ -59,15 +59,6 @@ case "${target_cpu}" in + arm*) ARCH=arm ;; + + i[3456]86) +- case " ${CC} ${CFLAGS} " in +- *" -m64 "*|*" -mx32 "*) +- ;; +- *) +- if test -z "$with_arch"; then +- XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}" +- XCFLAGS="${XCFLAGS} -fomit-frame-pointer" +- fi +- esac + XCFLAGS="${XCFLAGS} -mrtm" + ARCH=x86 + ;; diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0002-gcc-poison-system-directories.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0002-gcc-poison-system-directories.patch similarity index 81% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0002-gcc-poison-system-directories.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0002-gcc-poison-system-directories.patch index e7ff1246..30a84860 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0002-gcc-poison-system-directories.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0002-gcc-poison-system-directories.patch @@ -1,7 +1,7 @@ -From 95ec476dd7726cc9c1bfd6fb23ba3aea8bbf61a4 Mon Sep 17 00:00:00 2001 +From 74cc21f474402cf3578e37e1d7a1a22bbd070f6a Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 29 Mar 2013 08:59:00 +0400 -Subject: [PATCH 02/40] gcc: poison-system-directories +Subject: [PATCH] gcc: poison-system-directories Add /sw/include and /opt/include based on the original zecke-no-host-includes.patch patch. The original patch checked for @@ -26,10 +26,10 @@ Upstream-Status: Pending 7 files changed, 68 insertions(+) diff --git a/gcc/common.opt b/gcc/common.opt -index b52ef0b38c8..0de3f0924cd 100644 +index 65a82410abc..415f38fa1f4 100644 --- a/gcc/common.opt +++ b/gcc/common.opt -@@ -679,6 +679,10 @@ Wreturn-local-addr +@@ -682,6 +682,10 @@ Wreturn-local-addr Common Var(warn_return_local_addr) Init(1) Warning Warn about returning a pointer/reference to a local or temporary variable. @@ -41,10 +41,10 @@ index b52ef0b38c8..0de3f0924cd 100644 Common Var(warn_shadow) Warning Warn when one variable shadows another. Same as -Wshadow=global. diff --git a/gcc/config.in b/gcc/config.in -index 5bccb408016..1c784a8276b 100644 +index 809e7b26823..5adeaeed36b 100644 --- a/gcc/config.in +++ b/gcc/config.in -@@ -194,6 +194,12 @@ +@@ -224,6 +224,12 @@ #endif @@ -58,10 +58,10 @@ index 5bccb408016..1c784a8276b 100644 optimizer and back end) to be checked for dynamic type safety at runtime. This is quite expensive. */ diff --git a/gcc/configure b/gcc/configure -index 6121e163259..3901722400c 100755 +index cd3d9516fce..8de766a942c 100755 --- a/gcc/configure +++ b/gcc/configure -@@ -953,6 +953,7 @@ with_system_zlib +@@ -1010,6 +1010,7 @@ with_system_zlib enable_maintainer_mode enable_link_mutex enable_version_specific_runtime_libs @@ -69,7 +69,7 @@ index 6121e163259..3901722400c 100755 enable_plugin enable_host_shared enable_libquadmath_support -@@ -1696,6 +1697,8 @@ Optional Features: +@@ -1766,6 +1767,8 @@ Optional Features: --enable-version-specific-runtime-libs specify that runtime libraries should be installed in a compiler-specific directory @@ -78,7 +78,7 @@ index 6121e163259..3901722400c 100755 --enable-plugin enable plugin support --enable-host-shared build host code as shared libraries --disable-libquadmath-support -@@ -29701,6 +29704,19 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then : +@@ -30235,6 +30238,19 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then : fi @@ -99,10 +99,10 @@ index 6121e163259..3901722400c 100755 diff --git a/gcc/configure.ac b/gcc/configure.ac -index b066cc609e1..1b1362f70fe 100644 +index 0de3b4bf97b..8bfd6feb780 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac -@@ -6327,6 +6327,16 @@ AC_ARG_ENABLE(version-specific-runtime-libs, +@@ -6595,6 +6595,16 @@ AC_ARG_ENABLE(version-specific-runtime-libs, [specify that runtime libraries should be installed in a compiler-specific directory])]) @@ -120,18 +120,18 @@ index b066cc609e1..1b1362f70fe 100644 AC_SUBST(subdirs) AC_SUBST(srcdir) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi -index e5c4e8125aa..fb228631a42 100644 +index f98161391a0..f12d8d12150 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi -@@ -304,6 +304,7 @@ Objective-C and Objective-C++ Dialects}. - -Wpacked -Wpacked-bitfield-compat -Wpacked-not-aligned -Wpadded @gol +@@ -348,6 +348,7 @@ Objective-C and Objective-C++ Dialects}. + -Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded @gol -Wparentheses -Wno-pedantic-ms-format @gol - -Wplacement-new -Wplacement-new=@var{n} @gol + -Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast @gol +-Wno-poison-system-directories @gol - -Wpointer-arith -Wpointer-compare -Wno-pointer-to-int-cast @gol - -Wno-pragmas -Wredundant-decls -Wrestrict -Wno-return-local-addr @gol - -Wreturn-type -Wsequence-point -Wshadow -Wno-shadow-ivar @gol -@@ -5743,6 +5744,14 @@ made up of data only and thus requires no special treatment. But, for + -Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls @gol + -Wrestrict -Wno-return-local-addr -Wreturn-type @gol + -Wno-scalar-storage-order -Wsequence-point @gol +@@ -6924,6 +6925,14 @@ made up of data only and thus requires no special treatment. But, for most targets, it is made up of code and thus requires the stack to be made executable in order for the program to work properly. @@ -147,20 +147,20 @@ index e5c4e8125aa..fb228631a42 100644 @opindex Wfloat-equal @opindex Wno-float-equal diff --git a/gcc/gcc.c b/gcc/gcc.c -index a716f708259..02b3cd39fc2 100644 +index 9f790db0daf..b2200c5185a 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c -@@ -1037,6 +1037,8 @@ proper position among the other output files. */ +@@ -1041,6 +1041,8 @@ proper position among the other output files. */ "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \ "%X %{o*} %{e*} %{N} %{n} %{r}\ - %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}} \ + %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \ + %{Wno-poison-system-directories:--no-poison-system-directories} \ + %{Werror=poison-system-directories:--error-poison-system-directories} \ - %{static|no-pie|static-pie:} %{L*} %(mfwrap) %(link_libgcc) " \ - VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o " CHKP_SPEC " \ + %{static|no-pie|static-pie:} %@{L*} %(mfwrap) %(link_libgcc) " \ + VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o "" \ %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\ diff --git a/gcc/incpath.c b/gcc/incpath.c -index b11c6a57939..9a457e02dd3 100644 +index 8a2bda00f80..9098ab044ab 100644 --- a/gcc/incpath.c +++ b/gcc/incpath.c @@ -26,6 +26,7 @@ @@ -198,6 +198,3 @@ index b11c6a57939..9a457e02dd3 100644 } /* Use given -I paths for #include "..." but not #include <...>, and --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0003-gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0003-gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch similarity index 92% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0003-gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0003-gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch index e62deb2e..27237feb 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0003-gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0003-gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch @@ -1,7 +1,7 @@ -From 6640d7e39b13d1ef26d249153ab15d510fda3566 Mon Sep 17 00:00:00 2001 +From 6e3395c0bc933bdc3242d1dead4896d0aa4e11a8 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 29 Mar 2013 09:08:31 +0400 -Subject: [PATCH 03/40] gcc-4.3.3: SYSROOT_CFLAGS_FOR_TARGET +Subject: [PATCH] gcc-4.3.3: SYSROOT_CFLAGS_FOR_TARGET Before committing, I noticed that PR/32161 was marked as a dup of PR/32009, but my previous patch did not fix it. @@ -26,10 +26,10 @@ Upstream-Status: Pending 1 file changed, 32 insertions(+) diff --git a/configure b/configure -index 8c5b1e9d561..2d1fc6b94d9 100755 +index 226a64939d1..b31dc137fc9 100755 --- a/configure +++ b/configure -@@ -6768,6 +6768,38 @@ fi +@@ -6971,6 +6971,38 @@ fi @@ -68,6 +68,3 @@ index 8c5b1e9d561..2d1fc6b94d9 100755 # Handle --with-headers=XXX. If the value is not "yes", the contents of # the named directory are copied to $(tooldir)/sys-include. if test x"${with_headers}" != x && test x"${with_headers}" != xno ; then --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0004-64-bit-multilib-hack.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0004-64-bit-multilib-hack.patch similarity index 60% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0004-64-bit-multilib-hack.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0004-64-bit-multilib-hack.patch index 371d8775..7c751bef 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0004-64-bit-multilib-hack.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0004-64-bit-multilib-hack.patch @@ -1,7 +1,7 @@ -From 1e649d81ca662c4cdf73882ebb8a11f0f19f5baf Mon Sep 17 00:00:00 2001 +From 85a7c5aeb82ed61e6ef6d8e061b9da9e6a4a652c Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 29 Mar 2013 09:10:06 +0400 -Subject: [PATCH 04/40] 64-bit multilib hack. +Subject: [PATCH] 64-bit multilib hack. GCC has internal multilib handling code but it assumes a very specific rigid directory layout. The build system implementation of multilib layout is very generic and allows @@ -19,20 +19,42 @@ and be able to patch these entries with a complete set of correct paths but this don't have such code at this point. This is something the target gcc recipe should do and override these platform defaults in its build config. +Do same for riscv64 and aarch64 + RP 15/8/11 +Upstream-Status: Inappropriate[OE-Specific] + Signed-off-by: Khem Raj Signed-off-by: Elvis Dowson - -Upstream-Status: Pending +Signed-off-by: Mark Hatle --- - gcc/config/i386/t-linux64 | 6 ++---- - gcc/config/mips/t-linux64 | 10 +++------- - gcc/config/rs6000/t-linux64 | 5 ++--- - 3 files changed, 7 insertions(+), 14 deletions(-) + gcc/config/aarch64/t-aarch64-linux | 8 ++++---- + gcc/config/i386/t-linux64 | 6 ++---- + gcc/config/mips/t-linux64 | 10 +++------- + gcc/config/riscv/t-linux | 6 ++++-- + gcc/config/rs6000/t-linux64 | 5 ++--- + 5 files changed, 15 insertions(+), 20 deletions(-) +diff --git a/gcc/config/aarch64/t-aarch64-linux b/gcc/config/aarch64/t-aarch64-linux +index 83e59e33b85..b1356be1fb4 100644 +--- a/gcc/config/aarch64/t-aarch64-linux ++++ b/gcc/config/aarch64/t-aarch64-linux +@@ -21,8 +21,8 @@ + LIB1ASMSRC = aarch64/lib1funcs.asm + LIB1ASMFUNCS = _aarch64_sync_cache_range + +-AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be) +-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu) +-MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu) ++#AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be) ++#MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu) ++#MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu) + +-MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32) ++#MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32) diff --git a/gcc/config/i386/t-linux64 b/gcc/config/i386/t-linux64 -index 8ea0faff369..266c6008004 100644 +index 1171e218578..5e057b7e5db 100644 --- a/gcc/config/i386/t-linux64 +++ b/gcc/config/i386/t-linux64 @@ -32,7 +32,5 @@ @@ -46,7 +68,7 @@ index 8ea0faff369..266c6008004 100644 +MULTILIB_DIRNAMES = . . +MULTILIB_OSDIRNAMES = ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) diff --git a/gcc/config/mips/t-linux64 b/gcc/config/mips/t-linux64 -index c017b7d04c5..126892cf40b 100644 +index ceb58d3b5f3..43fe2bf28ab 100644 --- a/gcc/config/mips/t-linux64 +++ b/gcc/config/mips/t-linux64 @@ -17,10 +17,6 @@ @@ -63,8 +85,20 @@ index c017b7d04c5..126892cf40b 100644 +MULTILIB_DIRNAMES = . . . +MULTILIB_OSDIRNAMES = ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) + +diff --git a/gcc/config/riscv/t-linux b/gcc/config/riscv/t-linux +index 216d2776a18..e4d817621fc 100644 +--- a/gcc/config/riscv/t-linux ++++ b/gcc/config/riscv/t-linux +@@ -1,3 +1,5 @@ + # Only XLEN and ABI affect Linux multilib dir names, e.g. /lib32/ilp32d/ +-MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES))) +-MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES)) ++#MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES))) ++MULTILIB_DIRNAMES := . . ++#MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES)) ++MULTILIB_OSDIRNAMES := ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) diff --git a/gcc/config/rs6000/t-linux64 b/gcc/config/rs6000/t-linux64 -index 0faa2a02df4..13fd8ca971e 100644 +index 264a7e27524..dc9d440f66b 100644 --- a/gcc/config/rs6000/t-linux64 +++ b/gcc/config/rs6000/t-linux64 @@ -26,10 +26,9 @@ @@ -80,6 +114,3 @@ index 0faa2a02df4..13fd8ca971e 100644 rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c $(COMPILE) $< --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0005-optional-libstdc.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0005-optional-libstdc.patch similarity index 79% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0005-optional-libstdc.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0005-optional-libstdc.patch index f9cf6c20..4020c9e3 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0005-optional-libstdc.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0005-optional-libstdc.patch @@ -1,7 +1,7 @@ -From b486380dcc4758e856ab6d847eb358d05bd79d64 Mon Sep 17 00:00:00 2001 +From 6ddfb0bfcd1eea71acd37ab06f7a4510b9f1d12b Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 29 Mar 2013 09:12:56 +0400 -Subject: [PATCH 05/40] optional libstdc +Subject: [PATCH] optional libstdc gcc-runtime builds libstdc++ separately from gcc-cross-*. Its configure tests using g++ will not run correctly since by default the linker will try to link against libstdc++ @@ -25,10 +25,10 @@ Upstream-Status: Inappropriate [embedded specific] 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt -index f591b39be5a..2955fcea867 100644 +index c49da99d395..35f712e2c84 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt -@@ -1901,6 +1901,10 @@ nostdinc++ +@@ -2025,6 +2025,10 @@ nostdinc++ C++ ObjC++ Do not search standard system include directories for C++. @@ -40,7 +40,7 @@ index f591b39be5a..2955fcea867 100644 C ObjC C++ ObjC++ Joined Separate ; Documented in common.opt diff --git a/gcc/cp/g++spec.c b/gcc/cp/g++spec.c -index 443a1746da3..e9b51be62ef 100644 +index 0ab63bcd211..7b081e9e4f0 100644 --- a/gcc/cp/g++spec.c +++ b/gcc/cp/g++spec.c @@ -137,6 +137,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, @@ -52,10 +52,10 @@ index 443a1746da3..e9b51be62ef 100644 library = -1; break; diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi -index fb228631a42..310ba8109ed 100644 +index f12d8d12150..cf6cb428e7d 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi -@@ -212,6 +212,9 @@ in the following sections. +@@ -230,6 +230,9 @@ in the following sections. -fno-weak -nostdinc++ @gol -fvisibility-inlines-hidden @gol -fvisibility-ms-compat @gol @@ -63,20 +63,20 @@ index fb228631a42..310ba8109ed 100644 +-fvtv-counts -fvtv-debug @gol +-nostdlib++ @gol -fext-numeric-literals @gol - -Wabi=@var{n} -Wabi-tag -Wconversion-null -Wctor-dtor-privacy @gol - -Wdelete-non-virtual-dtor -Wliteral-suffix -Wmultiple-inheritance @gol -@@ -510,7 +513,7 @@ Objective-C and Objective-C++ Dialects}. - -s -static -static-pie -static-libgcc -static-libstdc++ @gol + -Wabi-tag -Wcatch-value -Wcatch-value=@var{n} @gol + -Wno-class-conversion -Wclass-memaccess @gol +@@ -599,7 +602,7 @@ Objective-C and Objective-C++ Dialects}. + -pie -pthread -r -rdynamic @gol + -s -static -static-pie -static-libgcc -static-libstdc++ @gol -static-libasan -static-libtsan -static-liblsan -static-libubsan @gol - -static-libmpx -static-libmpxwrappers @gol --shared -shared-libgcc -symbolic @gol +-shared -shared-libgcc -symbolic -nostdlib++ @gol -T @var{script} -Wl,@var{option} -Xlinker @var{option} @gol -u @var{symbol} -z @var{keyword}} -@@ -12359,6 +12362,33 @@ library subroutines. - constructors are called; @pxref{Collect2,,@code{collect2}, gccint, - GNU Compiler Collection (GCC) Internals}.) +@@ -14407,6 +14410,33 @@ Specify that the program entry point is @var{entry}. The argument is + interpreted by the linker; the GNU linker accepts either a symbol name + or an address. +@item -nostdlib++ +@opindex nostdlib++ @@ -109,17 +109,14 @@ index fb228631a42..310ba8109ed 100644 @opindex pie Produce a dynamically linked position independent executable on targets diff --git a/gcc/gcc.c b/gcc/gcc.c -index 02b3cd39fc2..8cd27a5dad5 100644 +index b2200c5185a..f8be58ce0a6 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c -@@ -1047,6 +1047,7 @@ proper position among the other output files. */ +@@ -1051,6 +1051,7 @@ proper position among the other output files. */ %(mflib) " STACK_SPLIT_SPEC "\ %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} " SANITIZER_SPEC " \ - %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\ + %{!nostdlib:%{!r:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}}\ + %{!nostdlib++:}\ - %{!nostdlib:%{!nostartfiles:%E}} %{T*} \n%(post_link) }}}}}}" + %{!nostdlib:%{!r:%{!nostartfiles:%E}}} %{T*} \n%(post_link) }}}}}}" #endif --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0007-COLLECT_GCC_OPTIONS.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0006-COLLECT_GCC_OPTIONS.patch similarity index 80% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0007-COLLECT_GCC_OPTIONS.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0006-COLLECT_GCC_OPTIONS.patch index 8c7e72e1..9fbbe807 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0007-COLLECT_GCC_OPTIONS.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0006-COLLECT_GCC_OPTIONS.patch @@ -1,7 +1,7 @@ -From 209e46f45382088caab54425b92b5dfc43ebb4fc Mon Sep 17 00:00:00 2001 +From a6c90d3a9c5010b4aa7cc30467cf81ca7e0f430e Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 29 Mar 2013 09:16:28 +0400 -Subject: [PATCH 07/40] COLLECT_GCC_OPTIONS +Subject: [PATCH] COLLECT_GCC_OPTIONS This patch adds --sysroot into COLLECT_GCC_OPTIONS which is used to invoke collect2. @@ -14,10 +14,10 @@ Upstream-Status: Pending 1 file changed, 9 insertions(+) diff --git a/gcc/gcc.c b/gcc/gcc.c -index 8cd27a5dad5..d355d65583a 100644 +index f8be58ce0a6..48b0f9dde81 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c -@@ -4677,6 +4677,15 @@ set_collect_gcc_options (void) +@@ -4806,6 +4806,15 @@ set_collect_gcc_options (void) sizeof ("COLLECT_GCC_OPTIONS=") - 1); first_time = TRUE; @@ -33,6 +33,3 @@ index 8cd27a5dad5..d355d65583a 100644 for (i = 0; (int) i < n_switches; i++) { const char *const *args; --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0008-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0007-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch similarity index 85% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0008-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0007-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch index f9632afe..a764bdd0 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0008-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0007-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch @@ -1,8 +1,7 @@ -From 3bcbdf5ade54a72820ad7798119d0bbad4baf6ec Mon Sep 17 00:00:00 2001 +From 5670d4489f119d2da661734895ac0be99b606d1b Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 29 Mar 2013 09:17:25 +0400 -Subject: [PATCH 08/40] Use the defaults.h in ${B} instead of ${S}, and t-oe in - ${B} +Subject: [PATCH] Use the defaults.h in ${B} instead of ${S}, and t-oe in ${B} Use the defaults.h in ${B} instead of ${S}, and t-oe in ${B}, so that the source can be shared between gcc-cross-initial, @@ -27,10 +26,10 @@ Signed-off-by: Hongxu Jia 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gcc/Makefile.in b/gcc/Makefile.in -index 20bee0494b1..1367136bfac 100644 +index 543b477ff18..a67d2cc18d6 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in -@@ -538,7 +538,7 @@ TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@ +@@ -540,7 +540,7 @@ TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@ TARGET_SYSTEM_ROOT_DEFINE = @TARGET_SYSTEM_ROOT_DEFINE@ xmake_file=@xmake_file@ @@ -40,10 +39,10 @@ index 20bee0494b1..1367136bfac 100644 TM_MULTILIB_CONFIG=@TM_MULTILIB_CONFIG@ TM_MULTILIB_EXCEPTIONS_CONFIG=@TM_MULTILIB_EXCEPTIONS_CONFIG@ diff --git a/gcc/configure b/gcc/configure -index 0c9b8ac5f55..134c2c2f156 100755 +index 8de766a942c..b26e8fc7fee 100755 --- a/gcc/configure +++ b/gcc/configure -@@ -12158,8 +12158,8 @@ for f in $tm_file; do +@@ -12705,8 +12705,8 @@ for f in $tm_file; do tm_include_list="${tm_include_list} $f" ;; defaults.h ) @@ -55,10 +54,10 @@ index 0c9b8ac5f55..134c2c2f156 100755 * ) tm_file_list="${tm_file_list} \$(srcdir)/config/$f" diff --git a/gcc/configure.ac b/gcc/configure.ac -index 53840363115..0c3c82e4ff7 100644 +index 8bfd6feb780..26fa46802c7 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac -@@ -1922,8 +1922,8 @@ for f in $tm_file; do +@@ -2138,8 +2138,8 @@ for f in $tm_file; do tm_include_list="${tm_include_list} $f" ;; defaults.h ) @@ -70,7 +69,7 @@ index 53840363115..0c3c82e4ff7 100644 * ) tm_file_list="${tm_file_list} \$(srcdir)/config/$f" diff --git a/gcc/mkconfig.sh b/gcc/mkconfig.sh -index 0f75c863c0b..68d8d6613cf 100644 +index d2c677a4a42..d03852481cb 100644 --- a/gcc/mkconfig.sh +++ b/gcc/mkconfig.sh @@ -77,7 +77,7 @@ if [ -n "$HEADERS" ]; then @@ -91,6 +90,3 @@ index 0f75c863c0b..68d8d6613cf 100644 fi # Add multiple inclusion protection guard, part two. --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0011-fortran-cross-compile-hack.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0008-fortran-cross-compile-hack.patch similarity index 81% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0011-fortran-cross-compile-hack.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0008-fortran-cross-compile-hack.patch index fe0fb7d5..714db3be 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0011-fortran-cross-compile-hack.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0008-fortran-cross-compile-hack.patch @@ -1,7 +1,7 @@ -From 71cba188d47b6ae9d9b87261eb4bc9eb68ae355d Mon Sep 17 00:00:00 2001 +From f05062625e7a4751be723595a2f7a4b7fbeff311 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 29 Mar 2013 09:20:01 +0400 -Subject: [PATCH 11/39] fortran cross-compile hack. +Subject: [PATCH] fortran cross-compile hack. * Fortran would have searched for arm-angstrom-gnueabi-gfortran but would have used used gfortan. For gcc_4.2.2.bb we want to use the gfortran compiler from our cross @@ -16,10 +16,10 @@ Upstream-Status: Inappropriate [embedded specific] 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libgfortran/configure b/libgfortran/configure -index 91fce8fecd0..6747f86eb98 100755 +index b4cf854ddb3..e8e0ac3b1cf 100755 --- a/libgfortran/configure +++ b/libgfortran/configure -@@ -12883,7 +12883,7 @@ esac +@@ -13090,7 +13090,7 @@ esac # We need gfortran to compile parts of the library #AC_PROG_FC(gfortran) @@ -29,10 +29,10 @@ index 91fce8fecd0..6747f86eb98 100755 ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5' ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5' diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac -index bf6d3634dda..9dbe43cc616 100644 +index 711dc60ff78..3c9bbfbf47d 100644 --- a/libgfortran/configure.ac +++ b/libgfortran/configure.ac -@@ -250,7 +250,7 @@ AC_SUBST(enable_static) +@@ -258,7 +258,7 @@ AC_SUBST(enable_static) # We need gfortran to compile parts of the library #AC_PROG_FC(gfortran) @@ -41,6 +41,3 @@ index bf6d3634dda..9dbe43cc616 100644 AC_PROG_FC(gfortran) # extra LD Flags which are required for targets --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0010-cpp-honor-sysroot.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0009-cpp-honor-sysroot.patch similarity index 75% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0010-cpp-honor-sysroot.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0009-cpp-honor-sysroot.patch index 037eacf4..8ad6853d 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0010-cpp-honor-sysroot.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0009-cpp-honor-sysroot.patch @@ -1,7 +1,7 @@ -From 2ae7af4eb70eff6aeda1fe96333ff50cfaa9d906 Mon Sep 17 00:00:00 2001 +From 1d76de7f1f5c99f1fa1a4b14aedad3d702e4e136 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 29 Mar 2013 09:22:00 +0400 -Subject: [PATCH 10/40] cpp: honor sysroot. +Subject: [PATCH] cpp: honor sysroot. Currently, if the gcc toolchain is relocated and installed from sstate, then you try and compile preprocessed source (.i or .ii files), the compiler will try and access the builtin sysroot location @@ -26,21 +26,21 @@ Upstream-Status: Pending 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/cp/lang-specs.h b/gcc/cp/lang-specs.h -index f0802b8915c..f324d299849 100644 +index 0ad4a33b93e..16c744f4f90 100644 --- a/gcc/cp/lang-specs.h +++ b/gcc/cp/lang-specs.h -@@ -64,5 +64,5 @@ along with GCC; see the file COPYING3. If not see +@@ -66,5 +66,5 @@ along with GCC; see the file COPYING3. If not see {".ii", "@c++-cpp-output", 0, 0, 0}, {"@c++-cpp-output", - "%{!M:%{!MM:%{!E:\ -- cc1plus -fpreprocessed %i %(cc1_options) %2\ -+ cc1plus -fpreprocessed %i %I %(cc1_options) %2\ - %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, + "%{!E:%{!M:%{!MM:" +- " cc1plus -fpreprocessed %i %(cc1_options) %2" ++ " cc1plus -fpreprocessed %i %I %(cc1_options) %2" + " %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, diff --git a/gcc/gcc.c b/gcc/gcc.c -index d355d65583a..570cdc00034 100644 +index 48b0f9dde81..c87f603955f 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c -@@ -1343,7 +1343,7 @@ static const struct compiler default_compilers[] = +@@ -1348,7 +1348,7 @@ static const struct compiler default_compilers[] = %W{o*:--output-pch=%*}}%V}}}}}}}", 0, 0, 0}, {".i", "@cpp-output", 0, 0, 0}, {"@cpp-output", @@ -49,6 +49,3 @@ index d355d65583a..570cdc00034 100644 {".s", "@assembler", 0, 0, 0}, {"@assembler", "%{!M:%{!MM:%{!E:%{!S:as %(asm_debug) %(asm_options) %i %A }}}}", 0, 0, 0}, --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0011-MIPS64-Default-to-N64-ABI.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0010-MIPS64-Default-to-N64-ABI.patch similarity index 85% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0011-MIPS64-Default-to-N64-ABI.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0010-MIPS64-Default-to-N64-ABI.patch index c863cff9..625e2d87 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0011-MIPS64-Default-to-N64-ABI.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0010-MIPS64-Default-to-N64-ABI.patch @@ -1,7 +1,7 @@ -From 1e1ea0eb55a594ac4cd7b838f74dec7405aae02b Mon Sep 17 00:00:00 2001 +From 4fad4433c96bc9d0d9d124f9674fb3389f6f426e Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 29 Mar 2013 09:23:08 +0400 -Subject: [PATCH 11/40] MIPS64: Default to N64 ABI +Subject: [PATCH] MIPS64: Default to N64 ABI MIPS64 defaults to n32 ABI, this patch makes it so that it defaults to N64 ABI @@ -14,10 +14,10 @@ Upstream-Status: Inappropriate [OE config specific] 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gcc/config.gcc b/gcc/config.gcc -index 7af8e028104..fc7c91246ed 100644 +index cf1a87e2efd..37c4221a39f 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc -@@ -2143,29 +2143,29 @@ mips*-*-linux*) # Linux MIPS, either endian. +@@ -2511,29 +2511,29 @@ mips*-*-linux*) # Linux MIPS, either endian. default_mips_arch=mips32 ;; mips64el-st-linux-gnu) @@ -52,6 +52,3 @@ index 7af8e028104..fc7c91246ed 100644 enable_mips_multilibs="yes" ;; esac --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0012-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0011-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch similarity index 87% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0012-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0011-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch index d3be10f2..e3579763 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0012-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0011-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch @@ -1,7 +1,7 @@ -From 6f8649936df3677109b8396f563c716ae8b237fe Mon Sep 17 00:00:00 2001 +From 8fc016a53c22c19feccbfa13ebdf19090dc67058 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 29 Mar 2013 09:24:50 +0400 -Subject: [PATCH 12/40] Define GLIBC_DYNAMIC_LINKER and UCLIBC_DYNAMIC_LINKER +Subject: [PATCH] Define GLIBC_DYNAMIC_LINKER and UCLIBC_DYNAMIC_LINKER relative to SYSTEMLIBS_DIR This patch defines GLIBC_DYNAMIC_LINKER and UCLIBC_DYNAMIC_LINKER @@ -24,14 +24,14 @@ Upstream-Status: Inappropriate [OE configuration] gcc/config/linux.h | 8 ++++---- gcc/config/mips/linux.h | 12 ++++++------ gcc/config/riscv/linux.h | 2 +- - gcc/config/rs6000/linux64.h | 16 ++++++---------- + gcc/config/rs6000/linux64.h | 15 +++++---------- gcc/config/sh/linux.h | 2 +- gcc/config/sparc/linux.h | 2 +- gcc/config/sparc/linux64.h | 4 ++-- - 12 files changed, 30 insertions(+), 34 deletions(-) + 12 files changed, 29 insertions(+), 34 deletions(-) diff --git a/gcc/config/alpha/linux-elf.h b/gcc/config/alpha/linux-elf.h -index 36b74dc1993..02373578af8 100644 +index e25fcac3c59..01aca0c6542 100644 --- a/gcc/config/alpha/linux-elf.h +++ b/gcc/config/alpha/linux-elf.h @@ -23,8 +23,8 @@ along with GCC; see the file COPYING3. If not see @@ -46,10 +46,10 @@ index 36b74dc1993..02373578af8 100644 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}" #elif DEFAULT_LIBC == LIBC_GLIBC diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h -index 8585fde3d41..b3af68cac57 100644 +index 5bdcfa0c5d3..0c0332f317f 100644 --- a/gcc/config/arm/linux-eabi.h +++ b/gcc/config/arm/linux-eabi.h -@@ -62,8 +62,8 @@ +@@ -65,8 +65,8 @@ GLIBC_DYNAMIC_LINKER_DEFAULT and TARGET_DEFAULT_FLOAT_ABI. */ #undef GLIBC_DYNAMIC_LINKER @@ -61,7 +61,7 @@ index 8585fde3d41..b3af68cac57 100644 #define GLIBC_DYNAMIC_LINKER \ diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h -index cfcd9cb1a5c..a798e987ecb 100644 +index 0ec3aa53189..abfa9566d74 100644 --- a/gcc/config/arm/linux-elf.h +++ b/gcc/config/arm/linux-elf.h @@ -60,7 +60,7 @@ @@ -74,7 +74,7 @@ index cfcd9cb1a5c..a798e987ecb 100644 #define LINUX_TARGET_LINK_SPEC "%{h*} \ %{static:-Bstatic} \ diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h -index 69f97f15b0d..71bc31d9231 100644 +index 9f823f125ed..e0390b7d5e3 100644 --- a/gcc/config/i386/linux.h +++ b/gcc/config/i386/linux.h @@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. If not see @@ -87,7 +87,7 @@ index 69f97f15b0d..71bc31d9231 100644 #undef MUSL_DYNAMIC_LINKER #define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1" diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h -index f2d913e30ac..8725f33d8a5 100644 +index 6cb68d1ccfa..7de09ec857c 100644 --- a/gcc/config/i386/linux64.h +++ b/gcc/config/i386/linux64.h @@ -27,9 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see @@ -104,10 +104,10 @@ index f2d913e30ac..8725f33d8a5 100644 #undef MUSL_DYNAMIC_LINKER32 #define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1" diff --git a/gcc/config/linux.h b/gcc/config/linux.h -index 2ea4ff92c1d..487b0c0923b 100644 +index 95654bcdb5a..0c1a8118a26 100644 --- a/gcc/config/linux.h +++ b/gcc/config/linux.h -@@ -81,10 +81,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +@@ -94,10 +94,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see GLIBC_DYNAMIC_LINKER must be defined for each target using them, or GLIBC_DYNAMIC_LINKER32 and GLIBC_DYNAMIC_LINKER64 for targets supporting both 32-bit and 64-bit compilation. */ @@ -123,7 +123,7 @@ index 2ea4ff92c1d..487b0c0923b 100644 #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker" #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64" diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h -index 2dfd0c18b90..12057c51b5e 100644 +index 54446e58e5f..4786ee304c1 100644 --- a/gcc/config/mips/linux.h +++ b/gcc/config/mips/linux.h @@ -22,20 +22,20 @@ along with GCC; see the file COPYING3. If not see @@ -154,7 +154,7 @@ index 2dfd0c18b90..12057c51b5e 100644 #undef MUSL_DYNAMIC_LINKER32 #define MUSL_DYNAMIC_LINKER32 \ diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h -index aa8a28d5d31..ebf9551c955 100644 +index 4afef7c228c..01997330741 100644 --- a/gcc/config/riscv/linux.h +++ b/gcc/config/riscv/linux.h @@ -22,7 +22,7 @@ along with GCC; see the file COPYING3. If not see @@ -167,10 +167,10 @@ index aa8a28d5d31..ebf9551c955 100644 #define MUSL_ABI_SUFFIX \ "%{mabi=ilp32:-sf}" \ diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h -index 44eab40a234..54aa8d957e7 100644 +index 34776c8421e..967c1c43c63 100644 --- a/gcc/config/rs6000/linux64.h +++ b/gcc/config/rs6000/linux64.h -@@ -413,16 +413,11 @@ extern int dot_symbols; +@@ -419,24 +419,19 @@ extern int dot_symbols; #undef LINK_OS_DEFAULT_SPEC #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)" @@ -189,21 +189,19 @@ index 44eab40a234..54aa8d957e7 100644 +#define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv2:" SYSTEMLIBS_DIR "ld64.so.2;:" SYSTEMLIBS_DIR "ld64.so.1}" #endif + #undef MUSL_DYNAMIC_LINKER32 #define MUSL_DYNAMIC_LINKER32 \ -@@ -430,8 +425,9 @@ extern int dot_symbols; +- "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" ++ SYSTEMLIBS_DIR "ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" + #undef MUSL_DYNAMIC_LINKER64 #define MUSL_DYNAMIC_LINKER64 \ - "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" +- "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" ++ SYSTEMLIBS_DIR "ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" --#define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0" --#define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0" -+#define UCLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-uClibc.so.0" -+#define UCLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld64-uClibc.so.0" -+ - #if DEFAULT_LIBC == LIBC_UCLIBC - #define CHOOSE_DYNAMIC_LINKER(G, U, M) \ - "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}" + #undef DEFAULT_ASM_ENDIAN + #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN) diff --git a/gcc/config/sh/linux.h b/gcc/config/sh/linux.h -index 6d2ccd012ba..ec78a89ce15 100644 +index c1d0441d488..81373eb8336 100644 --- a/gcc/config/sh/linux.h +++ b/gcc/config/sh/linux.h @@ -64,7 +64,7 @@ along with GCC; see the file COPYING3. If not see @@ -216,10 +214,10 @@ index 6d2ccd012ba..ec78a89ce15 100644 #undef SUBTARGET_LINK_EMUL_SUFFIX #define SUBTARGET_LINK_EMUL_SUFFIX "%{mfdpic:_fd;:_linux}" diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h -index 9fb03af0fe9..401fddbbb22 100644 +index 81201e67a2f..8b6fc577594 100644 --- a/gcc/config/sparc/linux.h +++ b/gcc/config/sparc/linux.h -@@ -83,7 +83,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); +@@ -84,7 +84,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); When the -shared link option is used a final link is not being done. */ @@ -229,7 +227,7 @@ index 9fb03af0fe9..401fddbbb22 100644 #undef LINK_SPEC #define LINK_SPEC "-m elf32_sparc %{shared:-shared} \ diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h -index c1fe42165b7..26a79bfa2e3 100644 +index a1a0efd8f28..85d1084afc2 100644 --- a/gcc/config/sparc/linux64.h +++ b/gcc/config/sparc/linux64.h @@ -84,8 +84,8 @@ along with GCC; see the file COPYING3. If not see @@ -243,6 +241,3 @@ index c1fe42165b7..26a79bfa2e3 100644 #ifdef SPARC_BI_ARCH --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0015-gcc-Fix-argument-list-too-long-error.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0012-gcc-Fix-argument-list-too-long-error.patch similarity index 69% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0015-gcc-Fix-argument-list-too-long-error.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0012-gcc-Fix-argument-list-too-long-error.patch index 4bff8428..88e1715b 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0015-gcc-Fix-argument-list-too-long-error.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0012-gcc-Fix-argument-list-too-long-error.patch @@ -1,7 +1,7 @@ -From 2e75a14cd60227e036790184f0eb400abc3c870b Mon Sep 17 00:00:00 2001 +From a22d1264049d29b90663cf5667049ae6f9b7a5ce Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 29 Mar 2013 09:26:37 +0400 -Subject: [PATCH 15/39] gcc: Fix argument list too long error. +Subject: [PATCH] gcc: Fix argument list too long error. There would be an "Argument list too long" error when the build directory is longer than 200, this is caused by: @@ -17,24 +17,25 @@ $(sort list) doesn't need this. Signed-off-by: Robert Yang Signed-off-by: Khem Raj +RP: gcc then added *.h and *.def additions to this list, breaking the original +fix. Add the sort to the original gcc code, leaving the tr+sort to fix the original +issue but include the new files too as reported by Zhuang + Upstream-Status: Pending --- gcc/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/Makefile.in b/gcc/Makefile.in -index 1367136bfac..71a8275c39f 100644 +index a67d2cc18d6..480c9366418 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in -@@ -3538,7 +3538,7 @@ install-plugin: installdirs lang.install-plugin s-header-vars install-gengtype +@@ -3606,7 +3606,7 @@ install-plugin: installdirs lang.install-plugin s-header-vars install-gengtype # We keep the directory structure for files in config or c-family and .def # files. All other files are flattened to a single directory. $(mkinstalldirs) $(DESTDIR)$(plugin_includedir) - headers=`echo $(PLUGIN_HEADERS) $$(cd $(srcdir); echo *.h *.def) | tr ' ' '\012' | sort -u`; \ -+ headers="$(sort $(PLUGIN_HEADERS) $$(cd $(srcdir); echo *.h *.def))"; \ ++ headers=`echo $(sort $(PLUGIN_HEADERS)) $$(cd $(srcdir); echo *.h *.def) | tr ' ' '\012' | sort -u`; \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`; \ for file in $$headers; do \ if [ -f $$file ] ; then \ --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0016-Disable-sdt.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0013-Disable-sdt.patch similarity index 88% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0016-Disable-sdt.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0013-Disable-sdt.patch index 81975462..207cdb57 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0016-Disable-sdt.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0013-Disable-sdt.patch @@ -1,7 +1,7 @@ -From 423d87ac47d21e399d759d7ff3b638f0c721a7df Mon Sep 17 00:00:00 2001 +From fa47586935a18ecfc2ad5586802e326e21741b7b Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 29 Mar 2013 09:28:10 +0400 -Subject: [PATCH 16/39] Disable sdt. +Subject: [PATCH] Disable sdt. We don't list dtrace in DEPENDS so we shouldn't be depending on this header. It may or may not exist from preivous builds though. To be determinstic, disable @@ -25,10 +25,10 @@ Upstream-Status: Inappropriate [hack] 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/gcc/configure b/gcc/configure -index a575839c1b2..872338f29b6 100755 +index b26e8fc7fee..6080f86145e 100755 --- a/gcc/configure +++ b/gcc/configure -@@ -29296,12 +29296,12 @@ fi +@@ -29789,12 +29789,12 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking sys/sdt.h in the target C library" >&5 $as_echo_n "checking sys/sdt.h in the target C library... " >&6; } have_sys_sdt_h=no @@ -48,10 +48,10 @@ index a575839c1b2..872338f29b6 100755 $as_echo "$have_sys_sdt_h" >&6; } diff --git a/gcc/configure.ac b/gcc/configure.ac -index 676116a6d96..55046e68926 100644 +index 26fa46802c7..42be5252778 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac -@@ -5957,15 +5957,15 @@ fi +@@ -6190,15 +6190,15 @@ fi AC_SUBST([enable_default_ssp]) # Test for on the target. @@ -77,10 +77,10 @@ index 676116a6d96..55046e68926 100644 # Check if TFmode long double should be used by default or not. # Some glibc targets used DFmode long double, but with glibc 2.4 diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure -index c9dbaa139d5..c64a77d152b 100755 +index 9f9c5a2419a..71ed13b815b 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure -@@ -21786,11 +21786,11 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +@@ -22615,11 +22615,11 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu @@ -96,10 +96,10 @@ index c9dbaa139d5..c64a77d152b 100755 $as_echo "$glibcxx_cv_sys_sdt_h" >&6; } diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac -index 0ef96270c9c..afe55a1b215 100644 +index 699e55fd829..5c7a7bda439 100644 --- a/libstdc++-v3/configure.ac +++ b/libstdc++-v3/configure.ac -@@ -230,7 +230,7 @@ GLIBCXX_CHECK_SC_NPROCESSORS_ONLN +@@ -241,7 +241,7 @@ GLIBCXX_CHECK_SC_NPROCESSORS_ONLN GLIBCXX_CHECK_SC_NPROC_ONLN GLIBCXX_CHECK_PTHREADS_NUM_PROCESSORS_NP GLIBCXX_CHECK_SYSCTL_HW_NCPU @@ -108,6 +108,3 @@ index 0ef96270c9c..afe55a1b215 100644 # Check for available headers. AC_CHECK_HEADERS([endian.h execinfo.h float.h fp.h ieeefp.h inttypes.h \ --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0015-libtool.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0014-libtool.patch similarity index 87% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0015-libtool.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0014-libtool.patch index 750f8a24..f4e70c3b 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0015-libtool.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0014-libtool.patch @@ -1,7 +1,7 @@ -From 80f2b01b3f917cea08294328c8bbc51dadece4af Mon Sep 17 00:00:00 2001 +From 6ecd478881468934444ff85611fd43f7033b1e81 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 29 Mar 2013 09:29:11 +0400 -Subject: [PATCH 15/40] libtool +Subject: [PATCH] libtool libstdc++ from gcc-runtime gets created with -rpath=/usr/lib/../lib for qemux86-64 when running on am x86_64 build host. @@ -23,7 +23,7 @@ Upstream-Status: Pending 1 file changed, 4 insertions(+) diff --git a/ltmain.sh b/ltmain.sh -index 9503ec85d70..0121fba707f 100644 +index 70990740b6c..ee938056bef 100644 --- a/ltmain.sh +++ b/ltmain.sh @@ -6359,6 +6359,10 @@ func_mode_link () @@ -37,6 +37,3 @@ index 9503ec85d70..0121fba707f 100644 oldlibs= if test -z "$rpath"; then --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0018-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0015-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch similarity index 86% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0018-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0015-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch index 643cc671..bc2674ab 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0018-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0015-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch @@ -1,7 +1,7 @@ -From 7dbba844a59bdf6e7d724f8bfa7927246cb7af8f Mon Sep 17 00:00:00 2001 +From de4427fa49c07dc651ee6ceaf5c5078700ca3b08 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 29 Mar 2013 09:30:32 +0400 -Subject: [PATCH 18/39] gcc: armv4: pass fix-v4bx to linker to support EABI. +Subject: [PATCH] gcc: armv4: pass fix-v4bx to linker to support EABI. The LINK_SPEC for linux gets overwritten by linux-eabi.h which means the value of TARGET_FIX_V4BX_SPEC gets lost and as a result @@ -19,12 +19,12 @@ Upstream-Status: Pending 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h -index b3af68cac57..330b6e13c5f 100644 +index 0c0332f317f..7b3769e8459 100644 --- a/gcc/config/arm/linux-eabi.h +++ b/gcc/config/arm/linux-eabi.h -@@ -88,10 +88,14 @@ +@@ -91,10 +91,14 @@ #define MUSL_DYNAMIC_LINKER \ - "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}.so.1" + "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1" +/* For armv4 we pass --fix-v4bx to linker to support EABI */ +#undef TARGET_FIX_V4BX_SPEC @@ -38,6 +38,3 @@ index b3af68cac57..330b6e13c5f 100644 LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC, \ LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC) --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0019-Use-the-multilib-config-files-from-B-instead-of-usin.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0016-Use-the-multilib-config-files-from-B-instead-of-usin.patch similarity index 81% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0019-Use-the-multilib-config-files-from-B-instead-of-usin.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0016-Use-the-multilib-config-files-from-B-instead-of-usin.patch index 08491865..1dc4bb85 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0019-Use-the-multilib-config-files-from-B-instead-of-usin.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0016-Use-the-multilib-config-files-from-B-instead-of-usin.patch @@ -1,8 +1,8 @@ -From 117140acd3c383f620ff75894276001c7405dcce Mon Sep 17 00:00:00 2001 +From 6b363c2c1c089ee900efa6013aefba1003840a37 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 29 Mar 2013 09:33:04 +0400 -Subject: [PATCH 19/39] Use the multilib config files from ${B} instead of - using the ones from ${S} +Subject: [PATCH] Use the multilib config files from ${B} instead of using the + ones from ${S} Use the multilib config files from ${B} instead of using the ones from ${S} so that the source can be shared between gcc-cross-initial, @@ -18,10 +18,10 @@ Upstream-Status: Inappropriate [configuration] 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/gcc/configure b/gcc/configure -index 872338f29b6..cfcadc93a01 100755 +index 6080f86145e..825a9652329 100755 --- a/gcc/configure +++ b/gcc/configure -@@ -12138,10 +12138,20 @@ done +@@ -12685,10 +12685,20 @@ done tmake_file_= for f in ${tmake_file} do @@ -44,9 +44,9 @@ index 872338f29b6..cfcadc93a01 100755 + ;; + esac done - tmake_file="${tmake_file_}" + tmake_file="${tmake_file_}${omp_device_property_tmake_file}" -@@ -12152,6 +12162,10 @@ tm_file_list="options.h" +@@ -12699,6 +12709,10 @@ tm_file_list="options.h" tm_include_list="options.h insn-constants.h" for f in $tm_file; do case $f in @@ -58,10 +58,10 @@ index 872338f29b6..cfcadc93a01 100755 f=`echo $f | sed 's/^..//'` tm_file_list="${tm_file_list} $f" diff --git a/gcc/configure.ac b/gcc/configure.ac -index 55046e68926..44b90478f55 100644 +index 42be5252778..6099eb3251f 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac -@@ -1902,10 +1902,20 @@ done +@@ -2118,10 +2118,20 @@ done tmake_file_= for f in ${tmake_file} do @@ -84,9 +84,9 @@ index 55046e68926..44b90478f55 100644 + ;; + esac done - tmake_file="${tmake_file_}" + tmake_file="${tmake_file_}${omp_device_property_tmake_file}" -@@ -1916,6 +1926,10 @@ tm_file_list="options.h" +@@ -2132,6 +2142,10 @@ tm_file_list="options.h" tm_include_list="options.h insn-constants.h" for f in $tm_file; do case $f in @@ -97,6 +97,3 @@ index 55046e68926..44b90478f55 100644 ./* ) f=`echo $f | sed 's/^..//'` tm_file_list="${tm_file_list} $f" --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0018-Avoid-using-libdir-from-.la-which-usually-points-to-.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0017-Avoid-using-libdir-from-.la-which-usually-points-to-.patch similarity index 76% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0018-Avoid-using-libdir-from-.la-which-usually-points-to-.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0017-Avoid-using-libdir-from-.la-which-usually-points-to-.patch index 20e77d6e..05f12847 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0018-Avoid-using-libdir-from-.la-which-usually-points-to-.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0017-Avoid-using-libdir-from-.la-which-usually-points-to-.patch @@ -1,8 +1,8 @@ -From 27cca95dcfeead8c52d292c4824ee96f178d6183 Mon Sep 17 00:00:00 2001 +From 08752c2f1d21553301bee5757c453c6a36cbe03c Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 20 Feb 2015 09:39:38 +0000 -Subject: [PATCH 18/40] Avoid using libdir from .la which usually points to a - host path +Subject: [PATCH] Avoid using libdir from .la which usually points to a host + path Upstream-Status: Inappropriate [embedded specific] @@ -13,7 +13,7 @@ Signed-off-by: Khem Raj 1 file changed, 3 insertions(+) diff --git a/ltmain.sh b/ltmain.sh -index 0121fba707f..52bdbdb5f9c 100644 +index ee938056bef..9ebc7e3d1e0 100644 --- a/ltmain.sh +++ b/ltmain.sh @@ -5628,6 +5628,9 @@ func_mode_link () @@ -26,6 +26,3 @@ index 0121fba707f..52bdbdb5f9c 100644 dir="$libdir" absdir="$libdir" fi --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0019-export-CPP.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0018-export-CPP.patch similarity index 93% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0019-export-CPP.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0018-export-CPP.patch index 140c67a4..886a1221 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0019-export-CPP.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0018-export-CPP.patch @@ -1,7 +1,7 @@ -From a2936382da81aefa9b69c1fc625f6c706b7ea1d8 Mon Sep 17 00:00:00 2001 +From 5c3d66378c7ff60ca11a875aa4aa6f8a8529d43a Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 20 Feb 2015 09:40:59 +0000 -Subject: [PATCH 19/40] export CPP +Subject: [PATCH] export CPP The OE environment sets and exports CPP as being the target gcc. When building gcc-cross-canadian for a mingw targetted sdk, the following can be found @@ -37,7 +37,7 @@ Signed-off-by: Khem Raj 1 file changed, 1 insertion(+) diff --git a/Makefile.in b/Makefile.in -index 38774f542a6..b426d4f9350 100644 +index 36e369df6e7..c717903bb13 100644 --- a/Makefile.in +++ b/Makefile.in @@ -149,6 +149,7 @@ BUILD_EXPORTS = \ @@ -48,6 +48,3 @@ index 38774f542a6..b426d4f9350 100644 CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \ CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ CXX="$(CXX_FOR_BUILD)"; export CXX; \ --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0023-Ensure-target-gcc-headers-can-be-included.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0019-Ensure-target-gcc-headers-can-be-included.patch similarity index 80% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0023-Ensure-target-gcc-headers-can-be-included.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0019-Ensure-target-gcc-headers-can-be-included.patch index 73db3e69..2797b2c2 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0023-Ensure-target-gcc-headers-can-be-included.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0019-Ensure-target-gcc-headers-can-be-included.patch @@ -1,7 +1,7 @@ -From 73766424a2f71b1810fb8afdd863028855d87e5a Mon Sep 17 00:00:00 2001 +From 378b752c5d9a3dba4e58cdadf8b4b4f34ea99a76 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 20 Feb 2015 10:25:11 +0000 -Subject: [PATCH 23/39] Ensure target gcc headers can be included +Subject: [PATCH] Ensure target gcc headers can be included There are a few headers installed as part of the OpenEmbedded gcc-runtime target (omp.h, ssp/*.h). Being installed from a recipe @@ -18,23 +18,21 @@ Signed-off-by: Khem Raj --- gcc/Makefile.in | 2 ++ gcc/cppdefault.c | 4 ++++ - gcc/defaults.h | 9 +++++++++ - gcc/gcc.c | 7 ------- - 4 files changed, 15 insertions(+), 7 deletions(-) + 2 files changed, 6 insertions(+) diff --git a/gcc/Makefile.in b/gcc/Makefile.in -index 71a8275c39f..5ae693fb06c 100644 +index 480c9366418..011c7ac2db6 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in -@@ -614,6 +614,7 @@ libexecdir = @libexecdir@ +@@ -618,6 +618,7 @@ libexecdir = @libexecdir@ # Directory in which the compiler finds libraries etc. libsubdir = $(libdir)/gcc/$(real_target_noncanonical)/$(version)$(accel_dir_suffix) -+libsubdir_target = gcc/$(target_noncanonical)/$(version) ++libsubdir_target = $(target_noncanonical)/$(version) # Directory in which the compiler finds executables libexecsubdir = $(libexecdir)/gcc/$(real_target_noncanonical)/$(version)$(accel_dir_suffix) # Directory in which all plugin resources are installed -@@ -2870,6 +2871,7 @@ CFLAGS-intl.o += -DLOCALEDIR=\"$(localedir)\" +@@ -2946,6 +2947,7 @@ CFLAGS-intl.o += -DLOCALEDIR=\"$(localedir)\" PREPROCESSOR_DEFINES = \ -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \ @@ -43,7 +41,7 @@ index 71a8275c39f..5ae693fb06c 100644 -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \ -DGPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT=$(gcc_gxx_include_dir_add_sysroot) \ diff --git a/gcc/cppdefault.c b/gcc/cppdefault.c -index b36a979d5ba..e2e187dedaf 100644 +index af38cc494ea..2f43b88a0c3 100644 --- a/gcc/cppdefault.c +++ b/gcc/cppdefault.c @@ -59,6 +59,10 @@ const struct default_include cpp_include_defaults[] @@ -57,6 +55,3 @@ index b36a979d5ba..e2e187dedaf 100644 #ifdef LOCAL_INCLUDE_DIR /* /usr/local/include comes before the fixincluded header files. */ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0025-Don-t-search-host-directory-during-relink-if-inst_pr.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0020-Don-t-search-host-directory-during-relink-if-inst_pr.patch similarity index 80% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0025-Don-t-search-host-directory-during-relink-if-inst_pr.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0020-Don-t-search-host-directory-during-relink-if-inst_pr.patch index d8b35bbb..c3baf8b4 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0025-Don-t-search-host-directory-during-relink-if-inst_pr.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0020-Don-t-search-host-directory-during-relink-if-inst_pr.patch @@ -1,8 +1,8 @@ -From fd96c9b35c592f1bdd32bc5ae669157473e44063 Mon Sep 17 00:00:00 2001 +From 870e805d705d99d9b9d7dbd09727f9c1d2ad9c1d Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Tue, 3 Mar 2015 08:21:19 +0000 -Subject: [PATCH 25/39] Don't search host directory during "relink" if - $inst_prefix is provided +Subject: [PATCH] Don't search host directory during "relink" if $inst_prefix + is provided http://lists.gnu.org/archive/html/libtool-patches/2011-01/msg00026.html @@ -14,7 +14,7 @@ Signed-off-by: Khem Raj 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ltmain.sh b/ltmain.sh -index 52bdbdb5f9c..82bcec39f05 100644 +index 9ebc7e3d1e0..7ea79fa8be6 100644 --- a/ltmain.sh +++ b/ltmain.sh @@ -6004,12 +6004,13 @@ func_mode_link () @@ -33,6 +33,3 @@ index 52bdbdb5f9c..82bcec39f05 100644 ;; esac fi --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0026-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0021-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch similarity index 81% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0026-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0021-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch index d3ab5aa9..abee4866 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0026-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0021-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch @@ -1,18 +1,18 @@ -From c2e400afe8c514357859fca88af4d3e1fcbfe2ff Mon Sep 17 00:00:00 2001 +From aba42de763a619355471efd1573561b0cbf51162 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Tue, 28 Apr 2015 23:15:27 -0700 -Subject: [PATCH 26/39] Use SYSTEMLIBS_DIR replacement instead of hardcoding +Subject: [PATCH] Use SYSTEMLIBS_DIR replacement instead of hardcoding base_libdir +Upstream-Status: Pending + Signed-off-by: Khem Raj --- -Upstream-Status: Pending - gcc/config/aarch64/aarch64-linux.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h -index bf1327e98cc..64436183bc8 100644 +index e587e2e9ad6..ddc62895693 100644 --- a/gcc/config/aarch64/aarch64-linux.h +++ b/gcc/config/aarch64/aarch64-linux.h @@ -21,7 +21,7 @@ @@ -24,6 +24,3 @@ index bf1327e98cc..64436183bc8 100644 #undef MUSL_DYNAMIC_LINKER #define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1" --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0025-aarch64-Add-support-for-musl-ldso.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0022-aarch64-Add-support-for-musl-ldso.patch similarity index 83% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0025-aarch64-Add-support-for-musl-ldso.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0022-aarch64-Add-support-for-musl-ldso.patch index 03f9725b..c55b66d4 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0025-aarch64-Add-support-for-musl-ldso.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0022-aarch64-Add-support-for-musl-ldso.patch @@ -1,7 +1,7 @@ -From b142e77e44e1acece6da54ccdc24c4da89cf4b99 Mon Sep 17 00:00:00 2001 +From d63820a78d92f302410358293546f01c7ad17bd8 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Tue, 28 Apr 2015 23:18:39 -0700 -Subject: [PATCH 25/40] aarch64: Add support for musl ldso +Subject: [PATCH] aarch64: Add support for musl ldso Upstream-Status: Pending @@ -11,7 +11,7 @@ Signed-off-by: Khem Raj 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h -index 64436183bc8..ba156676026 100644 +index ddc62895693..b301825313a 100644 --- a/gcc/config/aarch64/aarch64-linux.h +++ b/gcc/config/aarch64/aarch64-linux.h @@ -24,7 +24,7 @@ @@ -23,6 +23,3 @@ index 64436183bc8..ba156676026 100644 #undef ASAN_CC1_SPEC #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}" --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0028-libcc1-fix-libcc1-s-install-path-and-rpath.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0023-libcc1-fix-libcc1-s-install-path-and-rpath.patch similarity index 87% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0028-libcc1-fix-libcc1-s-install-path-and-rpath.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0023-libcc1-fix-libcc1-s-install-path-and-rpath.patch index 2673f4e3..80c4d229 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0028-libcc1-fix-libcc1-s-install-path-and-rpath.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0023-libcc1-fix-libcc1-s-install-path-and-rpath.patch @@ -1,7 +1,7 @@ -From a8a8a02788ff98f253ce0b33adcb0e661d24b1e3 Mon Sep 17 00:00:00 2001 +From 3474e16ad4ea8cf4e0e330568e3bc9039e723dce Mon Sep 17 00:00:00 2001 From: Robert Yang Date: Sun, 5 Jul 2015 20:25:18 -0700 -Subject: [PATCH 28/39] libcc1: fix libcc1's install path and rpath +Subject: [PATCH] libcc1: fix libcc1's install path and rpath * Install libcc1.so and libcc1plugin.so into $(libexecdir)/gcc/$(target_noncanonical)/$(gcc_version), as what we @@ -20,7 +20,7 @@ Signed-off-by: Robert Yang 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libcc1/Makefile.am b/libcc1/Makefile.am -index 6ecb66b4365..634cce3c2a9 100644 +index c005b0dad4a..ec31d35b7b9 100644 --- a/libcc1/Makefile.am +++ b/libcc1/Makefile.am @@ -37,8 +37,8 @@ libiberty = $(if $(wildcard $(libiberty_noasan)),$(Wc)$(libiberty_noasan), \ @@ -35,10 +35,10 @@ index 6ecb66b4365..634cce3c2a9 100644 if ENABLE_PLUGIN plugin_LTLIBRARIES = libcc1plugin.la libcp1plugin.la diff --git a/libcc1/Makefile.in b/libcc1/Makefile.in -index 47be10025ad..8d5481d87bd 100644 +index 7104b649026..2103c477468 100644 --- a/libcc1/Makefile.in +++ b/libcc1/Makefile.in -@@ -303,8 +303,8 @@ libiberty = $(if $(wildcard $(libiberty_noasan)),$(Wc)$(libiberty_noasan), \ +@@ -393,8 +393,8 @@ libiberty = $(if $(wildcard $(libiberty_noasan)),$(Wc)$(libiberty_noasan), \ $(Wc)$(libiberty_normal))) libiberty_dep = $(patsubst $(Wc)%,%,$(libiberty)) @@ -49,6 +49,3 @@ index 47be10025ad..8d5481d87bd 100644 @ENABLE_PLUGIN_TRUE@plugin_LTLIBRARIES = libcc1plugin.la libcp1plugin.la @ENABLE_PLUGIN_TRUE@cc1lib_LTLIBRARIES = libcc1.la shared_source = callbacks.cc callbacks.hh connection.cc connection.hh \ --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0027-handle-sysroot-support-for-nativesdk-gcc.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0024-handle-sysroot-support-for-nativesdk-gcc.patch similarity index 58% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0027-handle-sysroot-support-for-nativesdk-gcc.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0024-handle-sysroot-support-for-nativesdk-gcc.patch index 4b955de8..dc3e6da6 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0027-handle-sysroot-support-for-nativesdk-gcc.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0024-handle-sysroot-support-for-nativesdk-gcc.patch @@ -1,7 +1,7 @@ -From c033c1df11b692213d03db91d6cc145b4adedfac Mon Sep 17 00:00:00 2001 +From 702daf2e9cb97337e0e594fcd435b1b61a917d14 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Mon, 7 Dec 2015 23:39:54 +0000 -Subject: [PATCH 27/40] handle sysroot support for nativesdk-gcc +Subject: [PATCH] handle sysroot support for nativesdk-gcc Being able to build a nativesdk gcc is useful, particularly in cases where the host compiler may be of an incompatible version (or a 32 @@ -24,14 +24,39 @@ Upstream-Status: Inappropriate RP 2015/7/28 Signed-off-by: Khem Raj ---- - gcc/cppdefault.c | 50 +++++++++++++++++++++++++++++++++++------------- - gcc/cppdefault.h | 3 ++- - gcc/gcc.c | 20 +++++++++++++------ - 3 files changed, 53 insertions(+), 20 deletions(-) +Added PREFIXVAR and EXEC_PREFIXVAR to support runtime relocation. Without +these as part of the gccrelocprefix the system can't do runtime relocation +if the executable is moved. (These paths were missed in the original +implementation.) + +Signed-off-by: Mark Hatle +--- + gcc/c-family/c-opts.c | 4 +-- + gcc/cppdefault.c | 63 ++++++++++++++++++++++++++----------------- + gcc/cppdefault.h | 13 ++++----- + gcc/gcc.c | 20 +++++++++----- + gcc/incpath.c | 12 ++++----- + gcc/prefix.c | 6 +++-- + 6 files changed, 70 insertions(+), 48 deletions(-) + +diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c +index 58ba0948e79..806bbcfb7a5 100644 +--- a/gcc/c-family/c-opts.c ++++ b/gcc/c-family/c-opts.c +@@ -1409,8 +1409,8 @@ add_prefixed_path (const char *suffix, incpath_kind chain) + size_t prefix_len, suffix_len; + + suffix_len = strlen (suffix); +- prefix = iprefix ? iprefix : cpp_GCC_INCLUDE_DIR; +- prefix_len = iprefix ? strlen (iprefix) : cpp_GCC_INCLUDE_DIR_len; ++ prefix = iprefix ? iprefix : GCC_INCLUDE_DIRVAR; ++ prefix_len = iprefix ? strlen (iprefix) : strlen(GCC_INCLUDE_DIRVAR) - 7; + + path = (char *) xmalloc (prefix_len + suffix_len + 1); + memcpy (path, prefix, prefix_len); diff --git a/gcc/cppdefault.c b/gcc/cppdefault.c -index e2e187dedaf..2faba2b1d63 100644 +index 2f43b88a0c3..6b6be04686c 100644 --- a/gcc/cppdefault.c +++ b/gcc/cppdefault.c @@ -35,6 +35,30 @@ @@ -39,7 +64,7 @@ index e2e187dedaf..2faba2b1d63 100644 #endif +static char GPLUSPLUS_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GPLUSPLUS_INCLUDE_DIR; -+static char GCC_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GCC_INCLUDE_DIR; ++char GCC_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GCC_INCLUDE_DIR; +static char GPLUSPLUS_TOOL_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GPLUSPLUS_TOOL_INCLUDE_DIR; +static char GPLUSPLUS_BACKWARD_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GPLUSPLUS_BACKWARD_INCLUDE_DIR; +static char STANDARD_STARTFILE_PREFIX_2VAR[4096] __attribute__ ((section (".gccrelocprefix"))) = STANDARD_STARTFILE_PREFIX_2 GCC_INCLUDE_SUBDIR_TARGET; @@ -113,7 +138,7 @@ index e2e187dedaf..2faba2b1d63 100644 /* A multilib suffix needs adding if different multilibs use different headers. */ #ifdef SYSROOT_HEADERS_SUFFIX_SPEC -@@ -85,16 +109,16 @@ const struct default_include cpp_include_defaults[] +@@ -85,33 +109,24 @@ const struct default_include cpp_include_defaults[] #endif #ifdef CROSS_INCLUDE_DIR /* One place the target system's headers might be. */ @@ -134,8 +159,27 @@ index e2e187dedaf..2faba2b1d63 100644 #endif { 0, 0, 0, 0, 0, 0 } }; + #endif /* no INCLUDE_DEFAULTS */ + +-#ifdef GCC_INCLUDE_DIR +-const char cpp_GCC_INCLUDE_DIR[] = GCC_INCLUDE_DIR; +-const size_t cpp_GCC_INCLUDE_DIR_len = sizeof GCC_INCLUDE_DIR - 8; +-#else +-const char cpp_GCC_INCLUDE_DIR[] = ""; +-const size_t cpp_GCC_INCLUDE_DIR_len = 0; +-#endif +- + /* The configured prefix. */ +-const char cpp_PREFIX[] = PREFIX; +-const size_t cpp_PREFIX_len = sizeof PREFIX - 1; +-const char cpp_EXEC_PREFIX[] = STANDARD_EXEC_PREFIX; ++char PREFIXVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = PREFIX; ++char EXEC_PREFIXVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = STANDARD_EXEC_PREFIX; + + /* This value is set by cpp_relocated at runtime */ + const char *gcc_exec_prefix; diff --git a/gcc/cppdefault.h b/gcc/cppdefault.h -index 4a0186d1cf2..29e5d9da0dc 100644 +index a681264f75e..5e10a2fa140 100644 --- a/gcc/cppdefault.h +++ b/gcc/cppdefault.h @@ -33,7 +33,8 @@ @@ -148,11 +192,32 @@ index 4a0186d1cf2..29e5d9da0dc 100644 const char *const component; /* The component containing the directory (see update_path in prefix.c) */ const char cplusplus; /* Only look here if we're compiling C++. */ +@@ -50,17 +51,13 @@ struct default_include + }; + + extern const struct default_include cpp_include_defaults[]; +-extern const char cpp_GCC_INCLUDE_DIR[]; +-extern const size_t cpp_GCC_INCLUDE_DIR_len; ++extern char GCC_INCLUDE_DIRVAR[] __attribute__ ((section (".gccrelocprefix"))); + + /* The configure-time prefix, i.e., the value supplied as the argument + to --prefix=. */ +-extern const char cpp_PREFIX[]; ++extern char PREFIXVAR[] __attribute__ ((section (".gccrelocprefix"))); + /* The length of the configure-time prefix. */ +-extern const size_t cpp_PREFIX_len; +-/* The configure-time execution prefix. This is typically the lib/gcc +- subdirectory of cpp_PREFIX. */ +-extern const char cpp_EXEC_PREFIX[]; ++extern char EXEC_PREFIXVAR[] __attribute__ ((section (".gccrelocprefix"))); + /* The run-time execution prefix. This is typically the lib/gcc + subdirectory of the actual installation. */ + extern const char *gcc_exec_prefix; diff --git a/gcc/gcc.c b/gcc/gcc.c -index 3fb64d453f1..cd0c7fbe961 100644 +index c87f603955f..535d5c3bb65 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c -@@ -248,6 +248,8 @@ FILE *report_times_to_file = NULL; +@@ -252,6 +252,8 @@ FILE *report_times_to_file = NULL; #endif static const char *target_system_root = DEFAULT_TARGET_SYSTEM_ROOT; @@ -161,7 +226,7 @@ index 3fb64d453f1..cd0c7fbe961 100644 /* Nonzero means pass the updated target_system_root to the compiler. */ static int target_system_root_changed; -@@ -519,6 +521,7 @@ or with constant text in a single argument. +@@ -526,6 +528,7 @@ or with constant text in a single argument. %G process LIBGCC_SPEC as a spec. %R Output the concatenation of target_system_root and target_sysroot_suffix. @@ -169,7 +234,7 @@ index 3fb64d453f1..cd0c7fbe961 100644 %S process STARTFILE_SPEC as a spec. A capital S is actually used here. %E process ENDFILE_SPEC as a spec. A capital E is actually used here. %C process CPP_SPEC as a spec. -@@ -1487,10 +1490,10 @@ static const char *gcc_libexec_prefix; +@@ -1499,10 +1502,10 @@ static const char *gcc_libexec_prefix; gcc_exec_prefix is set because, in that case, we know where the compiler has been installed, and use paths relative to that location instead. */ @@ -184,7 +249,7 @@ index 3fb64d453f1..cd0c7fbe961 100644 /* For native compilers, these are well-known paths containing components that may be provided by the system. For cross -@@ -1498,9 +1501,9 @@ static const char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX; +@@ -1510,9 +1513,9 @@ static const char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX; static const char *md_exec_prefix = MD_EXEC_PREFIX; static const char *md_startfile_prefix = MD_STARTFILE_PREFIX; static const char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1; @@ -196,7 +261,7 @@ index 3fb64d453f1..cd0c7fbe961 100644 = STANDARD_STARTFILE_PREFIX_2; /* A relative path to be used in finding the location of tools -@@ -5849,6 +5852,11 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) +@@ -5952,6 +5955,11 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) } break; @@ -208,6 +273,77 @@ index 3fb64d453f1..cd0c7fbe961 100644 case 'S': value = do_spec_1 (startfile_spec, 0, NULL); if (value != 0) +diff --git a/gcc/incpath.c b/gcc/incpath.c +index 9098ab044ab..bfad4ebe382 100644 +--- a/gcc/incpath.c ++++ b/gcc/incpath.c +@@ -131,7 +131,7 @@ add_standard_paths (const char *sysroot, const char *iprefix, + int relocated = cpp_relocated (); + size_t len; + +- if (iprefix && (len = cpp_GCC_INCLUDE_DIR_len) != 0) ++ if (iprefix && (len = strlen(GCC_INCLUDE_DIRVAR) - 7) != 0) + { + /* Look for directories that start with the standard prefix. + "Translate" them, i.e. replace /usr/local/lib/gcc... with +@@ -145,7 +145,7 @@ add_standard_paths (const char *sysroot, const char *iprefix, + now. */ + if (sysroot && p->add_sysroot) + continue; +- if (!filename_ncmp (p->fname, cpp_GCC_INCLUDE_DIR, len)) ++ if (!filename_ncmp (p->fname, GCC_INCLUDE_DIRVAR, len)) + { + char *str = concat (iprefix, p->fname + len, NULL); + if (p->multilib == 1 && imultilib) +@@ -185,7 +185,7 @@ add_standard_paths (const char *sysroot, const char *iprefix, + free (sysroot_no_trailing_dir_separator); + } + else if (!p->add_sysroot && relocated +- && !filename_ncmp (p->fname, cpp_PREFIX, cpp_PREFIX_len)) ++ && !filename_ncmp (p->fname, PREFIXVAR, strlen(PREFIXVAR))) + { + static const char *relocated_prefix; + char *ostr; +@@ -202,12 +202,12 @@ add_standard_paths (const char *sysroot, const char *iprefix, + dummy = concat (gcc_exec_prefix, "dummy", NULL); + relocated_prefix + = make_relative_prefix (dummy, +- cpp_EXEC_PREFIX, +- cpp_PREFIX); ++ EXEC_PREFIXVAR, ++ PREFIXVAR); + free (dummy); + } + ostr = concat (relocated_prefix, +- p->fname + cpp_PREFIX_len, ++ p->fname + strlen(PREFIXVAR), + NULL); + str = update_path (ostr, p->component); + free (ostr); +diff --git a/gcc/prefix.c b/gcc/prefix.c +index 1a403e535bd..c26d07bde12 100644 +--- a/gcc/prefix.c ++++ b/gcc/prefix.c +@@ -72,7 +72,9 @@ License along with GCC; see the file COPYING3. If not see + #include "prefix.h" + #include "common/common-target.h" + +-static const char *std_prefix = PREFIX; ++char PREFIXVAR1[4096] __attribute__ ((section (".gccrelocprefix"))) = PREFIX; ++ ++static const char *std_prefix = PREFIXVAR1; + + static const char *get_key_value (char *); + static char *translate_name (char *); +@@ -212,7 +214,7 @@ translate_name (char *name) + prefix = getenv (key); + + if (prefix == 0) +- prefix = PREFIX; ++ prefix = PREFIXVAR1; + + /* We used to strip trailing DIR_SEPARATORs here, but that can + sometimes yield a result with no separator when one was coded -- -2.21.0 +2.29.2 diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0030-Search-target-sysroot-gcc-version-specific-dirs-with.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0025-Search-target-sysroot-gcc-version-specific-dirs-with.patch similarity index 90% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0030-Search-target-sysroot-gcc-version-specific-dirs-with.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0025-Search-target-sysroot-gcc-version-specific-dirs-with.patch index 33566dff..abf1f849 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0030-Search-target-sysroot-gcc-version-specific-dirs-with.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0025-Search-target-sysroot-gcc-version-specific-dirs-with.patch @@ -1,7 +1,7 @@ -From f5cc8cd0c44092dc487106ade27e011c1f584ada Mon Sep 17 00:00:00 2001 +From 9c0c73ee48dbee2aad57f4dcdad1b7b74e77b944 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Mon, 7 Dec 2015 23:41:45 +0000 -Subject: [PATCH 30/39] Search target sysroot gcc version specific dirs with +Subject: [PATCH] Search target sysroot gcc version specific dirs with multilib. We install the gcc libraries (such as crtbegin.p) into @@ -51,10 +51,10 @@ Signed-off-by: Khem Raj 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/gcc/gcc.c b/gcc/gcc.c -index cd0c7fbe961..f6f3aa077c8 100644 +index 535d5c3bb65..04647ae812d 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c -@@ -2527,7 +2527,7 @@ for_each_path (const struct path_prefix *paths, +@@ -2616,7 +2616,7 @@ for_each_path (const struct path_prefix *paths, if (path == NULL) { len = paths->max_len + extra_space + 1; @@ -63,7 +63,7 @@ index cd0c7fbe961..f6f3aa077c8 100644 path = XNEWVEC (char, len); } -@@ -2539,6 +2539,33 @@ for_each_path (const struct path_prefix *paths, +@@ -2628,6 +2628,33 @@ for_each_path (const struct path_prefix *paths, /* Look first in MACHINE/VERSION subdirectory. */ if (!skip_multi_dir) { @@ -97,6 +97,3 @@ index cd0c7fbe961..f6f3aa077c8 100644 memcpy (path + len, multi_suffix, suffix_len + 1); ret = callback (path, callback_info); if (ret) --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0029-Fix-various-_FOR_BUILD-and-related-variables.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0026-Fix-various-_FOR_BUILD-and-related-variables.patch similarity index 86% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0029-Fix-various-_FOR_BUILD-and-related-variables.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0026-Fix-various-_FOR_BUILD-and-related-variables.patch index 0c8bdb17..97bf2f3a 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0029-Fix-various-_FOR_BUILD-and-related-variables.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0026-Fix-various-_FOR_BUILD-and-related-variables.patch @@ -1,7 +1,7 @@ -From 1377c738e31a1e1599cfab189485a9459f803e79 Mon Sep 17 00:00:00 2001 +From 3a003af8804dda90fdf4862eca5f66cb12faaf02 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Mon, 7 Dec 2015 23:42:45 +0000 -Subject: [PATCH 29/40] Fix various _FOR_BUILD and related variables +Subject: [PATCH] Fix various _FOR_BUILD and related variables When doing a FOR_BUILD thing, you have to override CFLAGS with CFLAGS_FOR_BUILD. And if you use C++, you also have to override @@ -26,7 +26,7 @@ Signed-off-by: Khem Raj 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Makefile.in b/Makefile.in -index b426d4f9350..a2af9905cce 100644 +index c717903bb13..5abc649868d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -152,6 +152,7 @@ BUILD_EXPORTS = \ @@ -37,44 +37,6 @@ index b426d4f9350..a2af9905cce 100644 CXX="$(CXX_FOR_BUILD)"; export CXX; \ CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \ GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \ -@@ -169,6 +170,9 @@ BUILD_EXPORTS = \ - # built for the build system to override those in BASE_FLAGS_TO_PASS. - EXTRA_BUILD_FLAGS = \ - CFLAGS="$(CFLAGS_FOR_BUILD)" \ -+ CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \ -+ CPP="$(CC_FOR_BUILD) -E" \ -+ CPPFLAGS="$(CPPFLAGS_FOR_BUILD)" \ - LDFLAGS="$(LDFLAGS_FOR_BUILD)" - - # This is the list of directories to built for the host system. -@@ -186,6 +190,7 @@ HOST_SUBDIR = @host_subdir@ - HOST_EXPORTS = \ - $(BASE_EXPORTS) \ - CC="$(CC)"; export CC; \ -+ CPP="$(CC) -E"; export CPP; \ - ADA_CFLAGS="$(ADA_CFLAGS)"; export ADA_CFLAGS; \ - CFLAGS="$(CFLAGS)"; export CFLAGS; \ - CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ -@@ -743,6 +748,7 @@ BASE_FLAGS_TO_PASS = \ - "CC_FOR_BUILD=$(CC_FOR_BUILD)" \ - "CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \ - "CXX_FOR_BUILD=$(CXX_FOR_BUILD)" \ -+ "CXXFLAGS_FOR_BUILD=$(CXXFLAGS_FOR_BUILD)" \ - "EXPECT=$(EXPECT)" \ - "FLEX=$(FLEX)" \ - "INSTALL=$(INSTALL)" \ -diff --git a/Makefile.tpl b/Makefile.tpl -index 1f23b79b4b2..6c5652e811d 100644 ---- a/Makefile.tpl -+++ b/Makefile.tpl -@@ -154,6 +154,7 @@ BUILD_EXPORTS = \ - CC="$(CC_FOR_BUILD)"; export CC; \ - CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \ - CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ -+ CPPFLAGS="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS; \ - CXX="$(CXX_FOR_BUILD)"; export CXX; \ - CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \ - GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \ @@ -171,6 +172,9 @@ BUILD_EXPORTS = \ # built for the build system to override those in BASE_FLAGS_TO_PASS. EXTRA_BUILD_FLAGS = \ @@ -93,11 +55,49 @@ index 1f23b79b4b2..6c5652e811d 100644 ADA_CFLAGS="$(ADA_CFLAGS)"; export ADA_CFLAGS; \ CFLAGS="$(CFLAGS)"; export CFLAGS; \ CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ +@@ -776,6 +781,7 @@ BASE_FLAGS_TO_PASS = \ + "CC_FOR_BUILD=$(CC_FOR_BUILD)" \ + "CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \ + "CXX_FOR_BUILD=$(CXX_FOR_BUILD)" \ ++ "CXXFLAGS_FOR_BUILD=$(CXXFLAGS_FOR_BUILD)" \ + "EXPECT=$(EXPECT)" \ + "FLEX=$(FLEX)" \ + "INSTALL=$(INSTALL)" \ +diff --git a/Makefile.tpl b/Makefile.tpl +index efed1511750..778beb705b4 100644 +--- a/Makefile.tpl ++++ b/Makefile.tpl +@@ -154,6 +154,7 @@ BUILD_EXPORTS = \ + CC="$(CC_FOR_BUILD)"; export CC; \ + CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \ + CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ ++ CPPFLAGS="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS; \ + CXX="$(CXX_FOR_BUILD)"; export CXX; \ + CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \ + GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \ +@@ -173,6 +174,9 @@ BUILD_EXPORTS = \ + # built for the build system to override those in BASE_FLAGS_TO_PASS. + EXTRA_BUILD_FLAGS = \ + CFLAGS="$(CFLAGS_FOR_BUILD)" \ ++ CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \ ++ CPP="$(CC_FOR_BUILD) -E" \ ++ CPPFLAGS="$(CPPFLAGS_FOR_BUILD)" \ + LDFLAGS="$(LDFLAGS_FOR_BUILD)" + + # This is the list of directories to built for the host system. +@@ -190,6 +194,7 @@ HOST_SUBDIR = @host_subdir@ + HOST_EXPORTS = \ + $(BASE_EXPORTS) \ + CC="$(CC)"; export CC; \ ++ CPP="$(CC) -E"; export CPP; \ + ADA_CFLAGS="$(ADA_CFLAGS)"; export ADA_CFLAGS; \ + CFLAGS="$(CFLAGS)"; export CFLAGS; \ + CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ diff --git a/gcc/Makefile.in b/gcc/Makefile.in -index 5ae693fb06c..02ee0aa72f4 100644 +index 011c7ac2db6..2f1165f7b5e 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in -@@ -801,7 +801,7 @@ BUILD_LDFLAGS=@BUILD_LDFLAGS@ +@@ -805,7 +805,7 @@ BUILD_LDFLAGS=@BUILD_LDFLAGS@ BUILD_NO_PIE_FLAG = @BUILD_NO_PIE_FLAG@ BUILD_LDFLAGS += $(BUILD_NO_PIE_FLAG) BUILD_CPPFLAGS= -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \ @@ -107,10 +107,10 @@ index 5ae693fb06c..02ee0aa72f4 100644 # Actual name to use when installing a native compiler. GCC_INSTALL_NAME := $(shell echo gcc|sed '$(program_transform_name)') diff --git a/gcc/configure b/gcc/configure -index 3d9dcbdc93d..aa127a4f6a4 100755 +index 825a9652329..ff46cf58960 100755 --- a/gcc/configure +++ b/gcc/configure -@@ -11797,7 +11797,7 @@ else +@@ -12314,7 +12314,7 @@ else CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \ CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \ LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \ @@ -118,12 +118,12 @@ index 3d9dcbdc93d..aa127a4f6a4 100755 + GMPINC="" CPPFLAGS="${CPPFLAGS_FOR_BUILD} -DGENERATOR_FILE" \ ${realsrcdir}/configure \ --enable-languages=${enable_languages-all} \ - --target=$target_alias --host=$build_alias --build=$build_alias + ${enable_obsolete+--enable-obsolete="$enable_obsolete"} \ diff --git a/gcc/configure.ac b/gcc/configure.ac -index e09c840b605..18bf53c7e0a 100644 +index 6099eb3251f..b3c345b61dc 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac -@@ -1708,7 +1708,7 @@ else +@@ -1898,7 +1898,7 @@ else CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \ CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \ LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \ @@ -131,7 +131,4 @@ index e09c840b605..18bf53c7e0a 100644 + GMPINC="" CPPFLAGS="${CPPFLAGS_FOR_BUILD} -DGENERATOR_FILE" \ ${realsrcdir}/configure \ --enable-languages=${enable_languages-all} \ - --target=$target_alias --host=$build_alias --build=$build_alias --- -2.21.0 - + ${enable_obsolete+--enable-obsolete="$enable_obsolete"} \ diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0030-nios2-Define-MUSL_DYNAMIC_LINKER.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0027-nios2-Define-MUSL_DYNAMIC_LINKER.patch similarity index 79% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0030-nios2-Define-MUSL_DYNAMIC_LINKER.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0027-nios2-Define-MUSL_DYNAMIC_LINKER.patch index 04e126c5..3cd75b71 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0030-nios2-Define-MUSL_DYNAMIC_LINKER.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0027-nios2-Define-MUSL_DYNAMIC_LINKER.patch @@ -1,7 +1,7 @@ -From 75da3cc9ca2d3de8c2062f23bf4f72415741ef83 Mon Sep 17 00:00:00 2001 +From 4e53d0ae70af85af0e112a48a3e4dfe4c39f4a8d Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Tue, 2 Feb 2016 10:26:10 -0800 -Subject: [PATCH 30/40] nios2: Define MUSL_DYNAMIC_LINKER +Subject: [PATCH] nios2: Define MUSL_DYNAMIC_LINKER Upstream-Status: Pending @@ -12,7 +12,7 @@ Signed-off-by: Khem Raj 1 file changed, 1 insertion(+) diff --git a/gcc/config/nios2/linux.h b/gcc/config/nios2/linux.h -index 4729105626d..36181eb7b85 100644 +index 4bdcdcca1f0..e7943a9d640 100644 --- a/gcc/config/nios2/linux.h +++ b/gcc/config/nios2/linux.h @@ -30,6 +30,7 @@ @@ -23,6 +23,3 @@ index 4729105626d..36181eb7b85 100644 #undef LINK_SPEC #define LINK_SPEC LINK_SPEC_ENDIAN \ --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0031-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0028-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch similarity index 86% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0031-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0028-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch index 002cf2be..2a6769a8 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0031-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0028-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch @@ -1,7 +1,7 @@ -From f715aeef294b85fa593ef69e6d0114cc7b15312b Mon Sep 17 00:00:00 2001 +From 5db0404eb770ac477fd99d444226bcf021067584 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Tue, 27 Jun 2017 18:10:54 -0700 -Subject: [PATCH 31/40] Add ssp_nonshared to link commandline for musl targets +Subject: [PATCH] Add ssp_nonshared to link commandline for musl targets when -fstack-protector options are enabled we need to link with ssp_shared on musl since it does not provide @@ -23,10 +23,10 @@ Signed-off-by: Khem Raj 3 files changed, 27 insertions(+) diff --git a/gcc/config/linux.h b/gcc/config/linux.h -index 487b0c0923b..4769d089538 100644 +index 0c1a8118a26..bdc2a2d0659 100644 --- a/gcc/config/linux.h +++ b/gcc/config/linux.h -@@ -182,6 +182,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +@@ -195,6 +195,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \ { 0, 0, 0, 0, 0, 0 } \ } @@ -41,10 +41,10 @@ index 487b0c0923b..4769d089538 100644 #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */ diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h -index 01b40c762f6..e7c5e92215c 100644 +index b7026fcbee7..dd54d6c393e 100644 --- a/gcc/config/rs6000/linux.h +++ b/gcc/config/rs6000/linux.h -@@ -92,6 +92,16 @@ +@@ -94,6 +94,16 @@ " -m elf32ppclinux") #endif @@ -62,10 +62,10 @@ index 01b40c762f6..e7c5e92215c 100644 #define LINK_OS_LINUX_SPEC LINK_OS_LINUX_EMUL " %{!shared: %{!static: \ %{!static-pie: \ diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h -index 54aa8d957e7..619e113e2b8 100644 +index 967c1c43c63..dc5e4d97975 100644 --- a/gcc/config/rs6000/linux64.h +++ b/gcc/config/rs6000/linux64.h -@@ -466,6 +466,16 @@ extern int dot_symbols; +@@ -452,6 +452,16 @@ extern int dot_symbols; " -m elf64ppc") #endif @@ -82,6 +82,3 @@ index 54aa8d957e7..619e113e2b8 100644 #define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " %{!shared: %{!static: \ %{!static-pie: \ %{rdynamic:-export-dynamic} \ --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0035-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0029-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch similarity index 80% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0035-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0029-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch index 5e416e01..767cba03 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0035-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0029-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch @@ -1,7 +1,7 @@ -From 775c7fafcbfebed2d4bd8a6a011f18f70f3b59d3 Mon Sep 17 00:00:00 2001 +From fbc926dbf6a47fa623b9c94cd9b09a0e90448fdc Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Wed, 4 May 2016 21:11:34 -0700 -Subject: [PATCH 35/39] Link libgcc using LDFLAGS, not just SHLIB_LDFLAGS +Subject: [PATCH] Link libgcc using LDFLAGS, not just SHLIB_LDFLAGS Upstream-Status: Pending @@ -12,7 +12,7 @@ Signed-off-by: Khem Raj 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libgcc/config/t-slibgcc b/libgcc/config/t-slibgcc -index 7e60b621a2d..ea22ede3361 100644 +index c997553447c..330352c2c81 100644 --- a/libgcc/config/t-slibgcc +++ b/libgcc/config/t-slibgcc @@ -32,7 +32,7 @@ SHLIB_INSTALL_SOLINK = $(LN_S) $(SHLIB_SONAME) \ @@ -24,6 +24,3 @@ index 7e60b621a2d..ea22ede3361 100644 -o $(SHLIB_DIR)/$(SHLIB_SONAME).tmp @multilib_flags@ \ $(SHLIB_OBJS) $(SHLIB_LC) && \ rm -f $(SHLIB_DIR)/$(SHLIB_SOLINK) && \ --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0037-sync-gcc-stddef.h-with-musl.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0030-sync-gcc-stddef.h-with-musl.patch similarity index 77% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0037-sync-gcc-stddef.h-with-musl.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0030-sync-gcc-stddef.h-with-musl.patch index f8a7f41a..4f18907a 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0037-sync-gcc-stddef.h-with-musl.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0030-sync-gcc-stddef.h-with-musl.patch @@ -1,23 +1,23 @@ -From 602abaab15ffb60bf1797187a71b485042c56360 Mon Sep 17 00:00:00 2001 +From 24dc04dc8d69e3bf61322615b3ef18e02ccd311e Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 3 Feb 2017 12:56:00 -0800 -Subject: [PATCH 37/39] sync gcc stddef.h with musl +Subject: [PATCH] sync gcc stddef.h with musl musl defines ptrdiff_t size_t and wchar_t so dont define them here if musl is definining them -Signed-off-by: Khem Raj ---- Upstream-Status: Pending +Signed-off-by: Khem Raj +--- gcc/ginclude/stddef.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gcc/ginclude/stddef.h b/gcc/ginclude/stddef.h -index 31b96a7e5e1..438a3ce7c56 100644 +index 9d67eac4947..6cb5edbedb4 100644 --- a/gcc/ginclude/stddef.h +++ b/gcc/ginclude/stddef.h -@@ -134,6 +134,7 @@ _TYPE_wchar_t; +@@ -128,6 +128,7 @@ _TYPE_wchar_t; #ifndef ___int_ptrdiff_t_h #ifndef _GCC_PTRDIFF_T #ifndef _PTRDIFF_T_DECLARED /* DragonFly */ @@ -25,7 +25,7 @@ index 31b96a7e5e1..438a3ce7c56 100644 #define _PTRDIFF_T #define _T_PTRDIFF_ #define _T_PTRDIFF -@@ -143,10 +144,12 @@ _TYPE_wchar_t; +@@ -137,10 +138,12 @@ _TYPE_wchar_t; #define ___int_ptrdiff_t_h #define _GCC_PTRDIFF_T #define _PTRDIFF_T_DECLARED @@ -38,7 +38,7 @@ index 31b96a7e5e1..438a3ce7c56 100644 #endif /* _PTRDIFF_T_DECLARED */ #endif /* _GCC_PTRDIFF_T */ #endif /* ___int_ptrdiff_t_h */ -@@ -184,6 +187,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; +@@ -178,6 +181,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; #ifndef _GCC_SIZE_T #ifndef _SIZET_ #ifndef __size_t @@ -46,15 +46,15 @@ index 31b96a7e5e1..438a3ce7c56 100644 #define __size_t__ /* BeOS */ #define __SIZE_T__ /* Cray Unicos/Mk */ #define _SIZE_T -@@ -200,6 +204,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; +@@ -194,6 +198,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; #define ___int_size_t_h #define _GCC_SIZE_T #define _SIZET_ +#define __DEFINED_size_t /* musl */ - #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \ + #if defined (__FreeBSD__) \ || defined(__DragonFly__) \ - || defined(__FreeBSD_kernel__) -@@ -235,6 +240,7 @@ typedef long ssize_t; + || defined(__FreeBSD_kernel__) \ +@@ -228,6 +233,7 @@ typedef long ssize_t; #endif /* _SIZE_T */ #endif /* __SIZE_T__ */ #endif /* __size_t__ */ @@ -62,7 +62,7 @@ index 31b96a7e5e1..438a3ce7c56 100644 #undef __need_size_t #endif /* _STDDEF_H or __need_size_t. */ -@@ -264,6 +270,7 @@ typedef long ssize_t; +@@ -257,6 +263,7 @@ typedef long ssize_t; #ifndef ___int_wchar_t_h #ifndef __INT_WCHAR_T_H #ifndef _GCC_WCHAR_T @@ -70,7 +70,7 @@ index 31b96a7e5e1..438a3ce7c56 100644 #define __wchar_t__ /* BeOS */ #define __WCHAR_T__ /* Cray Unicos/Mk */ #define _WCHAR_T -@@ -279,6 +286,7 @@ typedef long ssize_t; +@@ -272,6 +279,7 @@ typedef long ssize_t; #define __INT_WCHAR_T_H #define _GCC_WCHAR_T #define _WCHAR_T_DECLARED @@ -78,7 +78,7 @@ index 31b96a7e5e1..438a3ce7c56 100644 /* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_ instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other -@@ -344,6 +352,7 @@ typedef __WCHAR_TYPE__ wchar_t; +@@ -337,6 +345,7 @@ typedef __WCHAR_TYPE__ wchar_t; #endif #endif /* __WCHAR_T__ */ #endif /* __wchar_t__ */ @@ -86,6 +86,3 @@ index 31b96a7e5e1..438a3ce7c56 100644 #undef __need_wchar_t #endif /* _STDDEF_H or __need_wchar_t. */ --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0036-fix-segmentation-fault-in-precompiled-header-generat.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0031-fix-segmentation-fault-in-precompiled-header-generat.patch similarity index 86% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0036-fix-segmentation-fault-in-precompiled-header-generat.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0031-fix-segmentation-fault-in-precompiled-header-generat.patch index c4ce5db5..702279af 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0036-fix-segmentation-fault-in-precompiled-header-generat.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0031-fix-segmentation-fault-in-precompiled-header-generat.patch @@ -1,7 +1,7 @@ -From a9bb29a4e9b478f9b126e483467ce9031c33fe4f Mon Sep 17 00:00:00 2001 +From 27b8ba5555ada2dab076988529bfb84d00a4b901 Mon Sep 17 00:00:00 2001 From: Juro Bystricky Date: Mon, 19 Mar 2018 22:31:20 -0700 -Subject: [PATCH 36/40] fix segmentation fault in precompiled header generation +Subject: [PATCH] fix segmentation fault in precompiled header generation Prevent a segmentation fault which occurs when using incorrect structure trying to access name of some named operators, such as @@ -19,10 +19,10 @@ Signed-off-by: Khem Raj 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/libcpp/lex.c b/libcpp/lex.c -index 37c365a3560..63480048db6 100644 +index 56ac3a1dd73..73a951148b3 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c -@@ -3279,11 +3279,27 @@ cpp_spell_token (cpp_reader *pfile, const cpp_token *token, +@@ -3311,11 +3311,27 @@ cpp_spell_token (cpp_reader *pfile, const cpp_token *token, spell_ident: case SPELL_IDENT: if (forstring) @@ -55,6 +55,3 @@ index 37c365a3560..63480048db6 100644 else buffer = _cpp_spell_ident_ucns (buffer, token->val.node.node); break; --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0039-Fix-for-testsuite-failure.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0032-Fix-for-testsuite-failure.patch similarity index 98% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0039-Fix-for-testsuite-failure.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0032-Fix-for-testsuite-failure.patch index f3516309..0a0767b4 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0039-Fix-for-testsuite-failure.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0032-Fix-for-testsuite-failure.patch @@ -1,7 +1,7 @@ -From d151a62c252749643c850a08d1335321e5b75d42 Mon Sep 17 00:00:00 2001 +From 2512aacf023c679d86d8f40caff4f6ff412b32ff Mon Sep 17 00:00:00 2001 From: RAGHUNATH LOLUR Date: Wed, 6 Dec 2017 22:52:26 -0800 -Subject: [PATCH 39/39] Fix for testsuite failure +Subject: [PATCH] Fix for testsuite failure 2017-11-16 Raghunath Lolur @@ -139,7 +139,7 @@ index ea896b7ebfd..bf15569b826 100644 #include "funcspec-56.inc" diff --git a/gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c b/gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c -index 3fbdc881dda..6b4d9d1252a 100644 +index 8561a3c26d6..6377f814645 100644 --- a/gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c +++ b/gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c @@ -1,5 +1,5 @@ @@ -220,7 +220,7 @@ index 96006b3e338..4287e4538bf 100644 /* This test uses __builtin_trap () instead of e.g. abort, because due to -mpreferred-stack-boundary=3 it should not call diff --git a/gcc/testsuite/gcc.target/i386/pr62120.c b/gcc/testsuite/gcc.target/i386/pr62120.c -index bfb8c4703eb..ed04cf181f3 100644 +index 28d85d37712..c93266bd4bc 100644 --- a/gcc/testsuite/gcc.target/i386/pr62120.c +++ b/gcc/testsuite/gcc.target/i386/pr62120.c @@ -1,5 +1,5 @@ @@ -253,6 +253,3 @@ index 6cda1534311..26e37f5b8ba 100644 #define vector(elcount, type) \ __attribute__((vector_size((elcount)*sizeof(type)))) type --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0040-Re-introduce-spe-commandline-options.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0033-Re-introduce-spe-commandline-options.patch similarity index 81% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0040-Re-introduce-spe-commandline-options.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0033-Re-introduce-spe-commandline-options.patch index 8afa0102..ba7c2b8f 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0040-Re-introduce-spe-commandline-options.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0033-Re-introduce-spe-commandline-options.patch @@ -1,7 +1,7 @@ -From 8fb8f773e117ee70be00bb0da5f343fe110da5c4 Mon Sep 17 00:00:00 2001 +From 3fc06241ce37e2e4b3ed21ace28d347eb511448d Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Wed, 6 Jun 2018 12:10:22 -0700 -Subject: [PATCH 40/40] Re-introduce spe commandline options +Subject: [PATCH] Re-introduce spe commandline options This should ensure that we keep accepting spe options @@ -14,10 +14,10 @@ Signed-off-by: Khem Raj 1 file changed, 12 insertions(+) diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt -index ace8a477550..d6a8f825d88 100644 +index f95b8279270..0e52d51409d 100644 --- a/gcc/config/rs6000/rs6000.opt +++ b/gcc/config/rs6000/rs6000.opt -@@ -365,6 +365,18 @@ mdebug= +@@ -344,6 +344,18 @@ mdebug= Target RejectNegative Joined -mdebug= Enable debug output. @@ -36,6 +36,3 @@ index ace8a477550..d6a8f825d88 100644 mabi=altivec Target RejectNegative Var(rs6000_altivec_abi) Save Use the AltiVec ABI extensions. --- -2.17.1 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0034-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0034-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch similarity index 77% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0034-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0034-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch index 92224cc5..4ce9dc6d 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0034-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0034-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch @@ -1,7 +1,8 @@ -From 46ca51dd413330bb8425b06283e7667bfb507c3d Mon Sep 17 00:00:00 2001 +From b42ff59c3fe2967d37815c8db72a47b9b7f585b4 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Sat, 24 Oct 2015 20:09:53 +0000 -Subject: [PATCH 34/40] libgcc_s: Use alias for __cpu_indicator_init instead of symver +Subject: [PATCH] libgcc_s: Use alias for __cpu_indicator_init instead of + symver Adapter from @@ -25,23 +26,23 @@ gcc/Changelog: 2015-05-11 Szabolcs Nagy - * config/i386/i386.c (ix86_expand_builtin): Make __builtin_cpu_init + * config/i386/i386-expand.c (ix86_expand_builtin): Make __builtin_cpu_init call __cpu_indicator_init_local instead of __cpu_indicator_init. Upstream-Status: Pending Signed-off-by: Khem Raj --- - gcc/config/i386/i386.c | 4 ++-- - libgcc/config/i386/cpuinfo.c | 6 +++--- - libgcc/config/i386/t-linux | 2 +- + gcc/config/i386/i386-expand.c | 4 ++-- + libgcc/config/i386/cpuinfo.c | 6 +++--- + libgcc/config/i386/t-linux | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) -diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c -index a88a29b51e6..6f3f5187970 100644 ---- a/gcc/config/i386/i386.c -+++ b/gcc/config/i386/i386.c -@@ -36555,10 +36555,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget, +diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c +index 48f00c5fcfc..468f5f71fac 100644 +--- a/gcc/config/i386/i386-expand.c ++++ b/gcc/config/i386/i386-expand.c +@@ -10941,10 +10941,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget, { case IX86_BUILTIN_CPU_INIT: { @@ -55,10 +56,10 @@ index a88a29b51e6..6f3f5187970 100644 return expand_expr (call_expr, target, mode, EXPAND_NORMAL); } diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c -index d1853d5515b..864150c9249 100644 +index 00322c58622..f42bbb8af98 100644 --- a/libgcc/config/i386/cpuinfo.c +++ b/libgcc/config/i386/cpuinfo.c -@@ -485,7 +485,7 @@ __cpu_indicator_init (void) +@@ -508,7 +508,7 @@ __cpu_indicator_init (void) return 0; } @@ -80,6 +81,3 @@ index 8506a635790..564296f788e 100644 -HOST_LIBGCC2_CFLAGS += -mlong-double-80 -DUSE_ELF_SYMVER $(CET_FLAGS) +HOST_LIBGCC2_CFLAGS += -mlong-double-80 $(CET_FLAGS) CRTSTUFF_T_CFLAGS += $(CET_FLAGS) --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0035-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0035-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch new file mode 100644 index 00000000..dd1bf6de --- /dev/null +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0035-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch @@ -0,0 +1,182 @@ +From 0395060a7dcf98c5f5a65103f6aaa71d6b862259 Mon Sep 17 00:00:00 2001 +From: Richard Purdie +Date: Tue, 10 Mar 2020 08:26:53 -0700 +Subject: [PATCH] gentypes/genmodes: Do not use __LINE__ for maintaining + reproducibility + +Inserting line numbers into generated code means its not always reproducible wth +differing versions of host gcc. Void the issue by not adding these. + +Upstream-Status: Inappropriate [OE Reproducibility specific] + +Signed-off-by: Richard Purdie +Signed-off-by: Khem Raj +--- + gcc/gengtype.c | 6 +++--- + gcc/genmodes.c | 32 ++++++++++++++++---------------- + 2 files changed, 19 insertions(+), 19 deletions(-) + +diff --git a/gcc/gengtype.c b/gcc/gengtype.c +index 981577481af..d5700fff401 100644 +--- a/gcc/gengtype.c ++++ b/gcc/gengtype.c +@@ -991,7 +991,7 @@ create_field_at (pair_p next, type_p type, const char *name, options_p opt, + /* Create a fake field with the given type and name. NEXT is the next + field in the chain. */ + #define create_field(next,type,name) \ +- create_field_all (next,type,name, 0, this_file, __LINE__) ++ create_field_all (next,type,name, 0, this_file, 0) + + /* Like create_field, but the field is only valid when condition COND + is true. */ +@@ -1024,7 +1024,7 @@ create_optional_field_ (pair_p next, type_p type, const char *name, + } + + #define create_optional_field(next,type,name,cond) \ +- create_optional_field_(next,type,name,cond,__LINE__) ++ create_optional_field_(next,type,name,cond,0) + + /* Reverse a linked list of 'struct pair's in place. */ + pair_p +@@ -5187,7 +5187,7 @@ main (int argc, char **argv) + /* These types are set up with #define or else outside of where + we can see them. We should initialize them before calling + read_input_list. */ +-#define POS_HERE(Call) do { pos.file = this_file; pos.line = __LINE__; \ ++#define POS_HERE(Call) do { pos.file = this_file; pos.line = 0; \ + Call;} while (0) + POS_HERE (do_scalar_typedef ("CUMULATIVE_ARGS", &pos)); + POS_HERE (do_scalar_typedef ("REAL_VALUE_TYPE", &pos)); +diff --git a/gcc/genmodes.c b/gcc/genmodes.c +index bd78310ea24..dbd02c51a4c 100644 +--- a/gcc/genmodes.c ++++ b/gcc/genmodes.c +@@ -430,7 +430,7 @@ complete_all_modes (void) + } + + /* For each mode in class CLASS, construct a corresponding complex mode. */ +-#define COMPLEX_MODES(C) make_complex_modes (MODE_##C, __FILE__, __LINE__) ++#define COMPLEX_MODES(C) make_complex_modes (MODE_##C, __FILE__, 0) + static void + make_complex_modes (enum mode_class cl, + const char *file, unsigned int line) +@@ -489,7 +489,7 @@ make_complex_modes (enum mode_class cl, + having as many components as necessary. ORDER is the sorting order + of the mode, with smaller numbers indicating a higher priority. */ + #define VECTOR_MODES_WITH_PREFIX(PREFIX, C, W, ORDER) \ +- make_vector_modes (MODE_##C, #PREFIX, W, ORDER, __FILE__, __LINE__) ++ make_vector_modes (MODE_##C, #PREFIX, W, ORDER, __FILE__, 0) + #define VECTOR_MODES(C, W) VECTOR_MODES_WITH_PREFIX (V, C, W, 0) + static void ATTRIBUTE_UNUSED + make_vector_modes (enum mode_class cl, const char *prefix, unsigned int width, +@@ -541,7 +541,7 @@ make_vector_modes (enum mode_class cl, const char *prefix, unsigned int width, + /* Create a vector of booleans called NAME with COUNT elements and + BYTESIZE bytes in total. */ + #define VECTOR_BOOL_MODE(NAME, COUNT, BYTESIZE) \ +- make_vector_bool_mode (#NAME, COUNT, BYTESIZE, __FILE__, __LINE__) ++ make_vector_bool_mode (#NAME, COUNT, BYTESIZE, __FILE__, 0) + static void ATTRIBUTE_UNUSED + make_vector_bool_mode (const char *name, unsigned int count, + unsigned int bytesize, const char *file, +@@ -563,7 +563,7 @@ make_vector_bool_mode (const char *name, unsigned int count, + /* Input. */ + + #define _SPECIAL_MODE(C, N) \ +- make_special_mode (MODE_##C, #N, __FILE__, __LINE__) ++ make_special_mode (MODE_##C, #N, __FILE__, 0) + #define RANDOM_MODE(N) _SPECIAL_MODE (RANDOM, N) + #define CC_MODE(N) _SPECIAL_MODE (CC, N) + +@@ -576,7 +576,7 @@ make_special_mode (enum mode_class cl, const char *name, + + #define INT_MODE(N, Y) FRACTIONAL_INT_MODE (N, -1U, Y) + #define FRACTIONAL_INT_MODE(N, B, Y) \ +- make_int_mode (#N, B, Y, __FILE__, __LINE__) ++ make_int_mode (#N, B, Y, __FILE__, 0) + + static void + make_int_mode (const char *name, +@@ -589,16 +589,16 @@ make_int_mode (const char *name, + } + + #define FRACT_MODE(N, Y, F) \ +- make_fixed_point_mode (MODE_FRACT, #N, Y, 0, F, __FILE__, __LINE__) ++ make_fixed_point_mode (MODE_FRACT, #N, Y, 0, F, __FILE__, 0) + + #define UFRACT_MODE(N, Y, F) \ +- make_fixed_point_mode (MODE_UFRACT, #N, Y, 0, F, __FILE__, __LINE__) ++ make_fixed_point_mode (MODE_UFRACT, #N, Y, 0, F, __FILE__, 0) + + #define ACCUM_MODE(N, Y, I, F) \ +- make_fixed_point_mode (MODE_ACCUM, #N, Y, I, F, __FILE__, __LINE__) ++ make_fixed_point_mode (MODE_ACCUM, #N, Y, I, F, __FILE__, 0) + + #define UACCUM_MODE(N, Y, I, F) \ +- make_fixed_point_mode (MODE_UACCUM, #N, Y, I, F, __FILE__, __LINE__) ++ make_fixed_point_mode (MODE_UACCUM, #N, Y, I, F, __FILE__, 0) + + /* Create a fixed-point mode by setting CL, NAME, BYTESIZE, IBIT, FBIT, + FILE, and LINE. */ +@@ -619,7 +619,7 @@ make_fixed_point_mode (enum mode_class cl, + + #define FLOAT_MODE(N, Y, F) FRACTIONAL_FLOAT_MODE (N, -1U, Y, F) + #define FRACTIONAL_FLOAT_MODE(N, B, Y, F) \ +- make_float_mode (#N, B, Y, #F, __FILE__, __LINE__) ++ make_float_mode (#N, B, Y, #F, __FILE__, 0) + + static void + make_float_mode (const char *name, +@@ -636,7 +636,7 @@ make_float_mode (const char *name, + #define DECIMAL_FLOAT_MODE(N, Y, F) \ + FRACTIONAL_DECIMAL_FLOAT_MODE (N, -1U, Y, F) + #define FRACTIONAL_DECIMAL_FLOAT_MODE(N, B, Y, F) \ +- make_decimal_float_mode (#N, B, Y, #F, __FILE__, __LINE__) ++ make_decimal_float_mode (#N, B, Y, #F, __FILE__, 0) + + static void + make_decimal_float_mode (const char *name, +@@ -651,7 +651,7 @@ make_decimal_float_mode (const char *name, + } + + #define RESET_FLOAT_FORMAT(N, F) \ +- reset_float_format (#N, #F, __FILE__, __LINE__) ++ reset_float_format (#N, #F, __FILE__, 0) + static void ATTRIBUTE_UNUSED + reset_float_format (const char *name, const char *format, + const char *file, unsigned int line) +@@ -672,7 +672,7 @@ reset_float_format (const char *name, const char *format, + + /* __intN support. */ + #define INT_N(M,PREC) \ +- make_int_n (#M, PREC, __FILE__, __LINE__) ++ make_int_n (#M, PREC, __FILE__, 0) + static void ATTRIBUTE_UNUSED + make_int_n (const char *m, int bitsize, + const char *file, unsigned int line) +@@ -701,7 +701,7 @@ make_int_n (const char *m, int bitsize, + /* Partial integer modes are specified by relation to a full integer + mode. */ + #define PARTIAL_INT_MODE(M,PREC,NAME) \ +- make_partial_integer_mode (#M, #NAME, PREC, __FILE__, __LINE__) ++ make_partial_integer_mode (#M, #NAME, PREC, __FILE__, 0) + static void ATTRIBUTE_UNUSED + make_partial_integer_mode (const char *base, const char *name, + unsigned int precision, +@@ -728,7 +728,7 @@ make_partial_integer_mode (const char *base, const char *name, + /* A single vector mode can be specified by naming its component + mode and the number of components. */ + #define VECTOR_MODE(C, M, N) \ +- make_vector_mode (MODE_##C, #M, N, __FILE__, __LINE__); ++ make_vector_mode (MODE_##C, #M, N, __FILE__, 0); + static void ATTRIBUTE_UNUSED + make_vector_mode (enum mode_class bclass, + const char *base, +@@ -771,7 +771,7 @@ make_vector_mode (enum mode_class bclass, + + /* Adjustability. */ + #define _ADD_ADJUST(A, M, X, C1, C2) \ +- new_adjust (#M, &adj_##A, #A, #X, MODE_##C1, MODE_##C2, __FILE__, __LINE__) ++ new_adjust (#M, &adj_##A, #A, #X, MODE_##C1, MODE_##C2, __FILE__, 0) + + #define ADJUST_NUNITS(M, X) _ADD_ADJUST (nunits, M, X, RANDOM, RANDOM) + #define ADJUST_BYTESIZE(M, X) _ADD_ADJUST (bytesize, M, X, RANDOM, RANDOM) diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0036-mingw32-Enable-operation_not_supported.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0036-mingw32-Enable-operation_not_supported.patch new file mode 100644 index 00000000..de82a3a5 --- /dev/null +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0036-mingw32-Enable-operation_not_supported.patch @@ -0,0 +1,26 @@ +From 6f87a095f0e696bec07a50df789c9db8bdbca43d Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Tue, 12 May 2020 10:39:09 -0700 +Subject: [PATCH] mingw32: Enable operation_not_supported + +Fixes nativesdk build errors on mingw32 gcc-runtime + +Upstream-Status: Pending +Signed-off-by: Khem Raj +--- + libstdc++-v3/config/os/mingw32/error_constants.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libstdc++-v3/config/os/mingw32/error_constants.h b/libstdc++-v3/config/os/mingw32/error_constants.h +index 68ac72a78fb..71cd5815b81 100644 +--- a/libstdc++-v3/config/os/mingw32/error_constants.h ++++ b/libstdc++-v3/config/os/mingw32/error_constants.h +@@ -107,7 +107,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + #ifdef _GLIBCXX_HAVE_EPERM + operation_not_permitted = EPERM, + #endif +-// operation_not_supported = EOPNOTSUPP, ++ operation_not_supported = EOPNOTSUPP, + #ifdef _GLIBCXX_HAVE_EWOULDBLOCK + operation_would_block = EWOULDBLOCK, + #endif diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0037-libatomic-Do-not-enforce-march-on-aarch64.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0037-libatomic-Do-not-enforce-march-on-aarch64.patch new file mode 100644 index 00000000..3946acea --- /dev/null +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-10.2/0037-libatomic-Do-not-enforce-march-on-aarch64.patch @@ -0,0 +1,42 @@ +From 38d262bfe7c0c894c364dc6e4dc7971e78a73974 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 13 May 2020 15:10:38 -0700 +Subject: [PATCH] libatomic: Do not enforce march on aarch64 + +OE passes the right options via gcc compiler cmdline via TUNE_CCARGS +this can conflict between -mcpu settings and -march setting here, since +-mcpu will translate into an appropriate -march, lets depend on that +instead of setting it explicitly + +Upstream-Status: Inappropriate [OE-Specific] + +Signed-off-by: Khem Raj +--- + libatomic/Makefile.am | 1 - + libatomic/Makefile.in | 1 - + 2 files changed, 2 deletions(-) + +diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am +index 133fbbca77e..ac1ca645876 100644 +--- a/libatomic/Makefile.am ++++ b/libatomic/Makefile.am +@@ -125,7 +125,6 @@ libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix _$(s)_.lo,$(SIZEOBJS))) + ## On a target-specific basis, include alternates to be selected by IFUNC. + if HAVE_IFUNC + if ARCH_AARCH64_LINUX +-IFUNC_OPTIONS = -march=armv8-a+lse + libatomic_la_LIBADD += $(foreach s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS))) + endif + if ARCH_ARM_LINUX +diff --git a/libatomic/Makefile.in b/libatomic/Makefile.in +index a51807e95c9..97df2d7ff03 100644 +--- a/libatomic/Makefile.in ++++ b/libatomic/Makefile.in +@@ -431,7 +431,6 @@ M_SRC = $(firstword $(filter %/$(M_FILE), $(all_c_files))) + libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix \ + _$(s)_.lo,$(SIZEOBJS))) $(am__append_1) $(am__append_2) \ + $(am__append_3) $(am__append_4) +-@ARCH_AARCH64_LINUX_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=armv8-a+lse + @ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=armv7-a+fp -DHAVE_KERNEL64 + @ARCH_I386_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=i586 + @ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -mcx16 diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2.inc b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2.inc deleted file mode 100644 index 65fbeffb..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2.inc +++ /dev/null @@ -1,115 +0,0 @@ -require recipes-devtools/gcc/gcc-common.inc - -BASEPV = "8.2" -PV = "arm-${BASEPV}" -CVE_VERSION = "${BASEPV}" - -MMYY = "19.01" -RELEASE = "20${MMYY}" -PR = "r${RELEASE}" -BINV = "${BASEPV}.1" - -FILESEXTRAPATHS =. "${FILE_DIRNAME}/gcc-${BASEPV}:${FILE_DIRNAME}/gcc-${BASEPV}/backport:" - -DEPENDS =+ "mpfr gmp libmpc zlib flex-native" -NATIVEDEPS = "mpfr-native gmp-native libmpc-native zlib-native flex-native" - -LICENSE = "GPL-3.0-with-GCC-exception & GPLv3" - -LIC_FILES_CHKSUM = "\ - file://COPYING;md5=59530bdf33659b29e73d4adb9f9f6552 \ - file://COPYING3;md5=d32239bcb673463ab874e80d47fae504 \ - file://COPYING3.LIB;md5=6a6a8e020838b23406c81b19c1d46df6 \ - file://COPYING.LIB;md5=2d5025d4aa3495befef8f17206a5b0a1 \ - file://COPYING.RUNTIME;md5=fe60d87048567d4fe8c8a0ed2448bcc8 \ -" - -#BASEURI ?= "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.bz2" -SRCREV = "1a721bce9532193e63acdcdb56fc16e8ac70b20a" -BASEURI ?= "git://git.linaro.org/toolchain/gcc.git;protocol=https;branch=linaro-local/ARM/arm-8-branch" - -SRC_URI = "\ - ${BASEURI} \ - file://0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch \ - file://0003-gcc-poison-system-directories.patch \ - file://0005-gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch \ - file://0006-64-bit-multilib-hack.patch \ - file://0007-optional-libstdc.patch \ - file://0008-gcc-disable-MASK_RELAX_PIC_CALLS-bit.patch \ - file://0009-COLLECT_GCC_OPTIONS.patch \ - file://0010-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch \ - file://0011-fortran-cross-compile-hack.patch \ - file://0012-cpp-honor-sysroot.patch \ - file://0013-MIPS64-Default-to-N64-ABI.patch \ - file://0014-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch \ - file://0015-gcc-Fix-argument-list-too-long-error.patch \ - file://0016-Disable-sdt.patch \ - file://0017-libtool.patch \ - file://0018-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch \ - file://0019-Use-the-multilib-config-files-from-B-instead-of-usin.patch \ - file://0020-Avoid-using-libdir-from-.la-which-usually-points-to-.patch \ - file://0021-export-CPP.patch \ - file://0022-Disable-the-MULTILIB_OSDIRNAMES-and-other-multilib-o.patch \ - file://0023-Ensure-target-gcc-headers-can-be-included.patch \ - file://0024-gcc-4.8-won-t-build-with-disable-dependency-tracking.patch \ - file://0025-Don-t-search-host-directory-during-relink-if-inst_pr.patch \ - file://0026-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch \ - file://0027-aarch64-Add-support-for-musl-ldso.patch \ - file://0028-libcc1-fix-libcc1-s-install-path-and-rpath.patch \ - file://0029-handle-sysroot-support-for-nativesdk-gcc.patch \ - file://0030-Search-target-sysroot-gcc-version-specific-dirs-with.patch \ - file://0031-Fix-various-_FOR_BUILD-and-related-variables.patch \ - file://0032-nios2-Define-MUSL_DYNAMIC_LINKER.patch \ - file://0033-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch \ - file://0034-libgcc-Add-knob-to-use-ldbl-128-on-ppc.patch \ - file://0035-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch \ - file://0036-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch \ - file://0037-sync-gcc-stddef.h-with-musl.patch \ - file://0038-fix-segmentation-fault-in-precompiled-header-generat.patch \ - file://0039-Fix-for-testsuite-failure.patch \ - file://0040-Re-introduce-spe-commandline-options.patch \ - file://0041-ARC-fix-spec-gen.patch \ - file://0042-powerpc-powerpc64-Add-support-for-musl-ldso.patch \ - file://0043-riscv-Disable-multilib-for-OE.patch \ - ${BACKPORTS} \ -" -BACKPORTS = "\ -" - -S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/git" -#S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/gcc-${PV}" -#S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/git" -#S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/gcc-${RELEASE}" -B = "${WORKDIR}/gcc-${PV}/build.${HOST_SYS}.${TARGET_SYS}" - -# Language Overrides -FORTRAN = "" -JAVA = "" - -LTO = "--enable-lto" -SSP ?= "--disable-libssp" -SSP_mingw32 = "--enable-libssp" - -EXTRA_OECONF_BASE = "\ - ${LTO} \ - ${SSP} \ - --enable-libitm \ - --disable-bootstrap \ - --disable-libmudflap \ - --with-system-zlib \ - ${@'--with-linker-hash-style=${LINKER_HASH_STYLE}' if '${LINKER_HASH_STYLE}' else ''} \ - --enable-linker-build-id \ - --with-ppl=no \ - --with-cloog=no \ - --enable-checking=release \ - --enable-cheaders=c_global \ - --without-isl \ -" - -EXTRA_OECONF_append_aarchilp32 = " --with-abi=ilp32" - -EXTRA_OECONF_PATHS = "\ - --with-gxx-include-dir=/not/exist{target_includedir}/c++/${BINV} \ - --with-sysroot=/not/exist \ - --with-build-sysroot=${STAGING_DIR_TARGET} \ -" diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch deleted file mode 100644 index 423fe28e..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch +++ /dev/null @@ -1,42 +0,0 @@ -From b752fb2b6d6f6da68da5386b96abf0d74cd4bbe6 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 29 Mar 2013 08:37:11 +0400 -Subject: [PATCH 01/39] gcc-4.3.1: ARCH_FLAGS_FOR_TARGET - -Signed-off-by: Khem Raj - -Upstream-Status: Inappropriate [embedded specific] ---- - configure | 2 +- - configure.ac | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/configure b/configure -index 69c99e99cca..517fb70192e 100755 ---- a/configure -+++ b/configure -@@ -7511,7 +7511,7 @@ fi - # for target_alias and gcc doesn't manage it consistently. - target_configargs="--cache-file=./config.cache ${target_configargs}" - --FLAGS_FOR_TARGET= -+FLAGS_FOR_TARGET="$ARCH_FLAGS_FOR_TARGET" - case " $target_configdirs " in - *" newlib "*) - case " $target_configargs " in -diff --git a/configure.ac b/configure.ac -index a1edc369a27..f8c254f1fac 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -3100,7 +3100,7 @@ fi - # for target_alias and gcc doesn't manage it consistently. - target_configargs="--cache-file=./config.cache ${target_configargs}" - --FLAGS_FOR_TARGET= -+FLAGS_FOR_TARGET="$ARCH_FLAGS_FOR_TARGET" - case " $target_configdirs " in - *" newlib "*) - case " $target_configargs " in --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0003-gcc-poison-system-directories.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0003-gcc-poison-system-directories.patch deleted file mode 100644 index 05138976..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0003-gcc-poison-system-directories.patch +++ /dev/null @@ -1,194 +0,0 @@ -From 48c670d2678e0323d88eb72205e039f393cabe05 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 29 Mar 2013 08:59:00 +0400 -Subject: [PATCH 03/39] gcc: poison-system-directories - -Signed-off-by: Khem Raj - -Upstream-Status: Inappropriate [distribution: codesourcery] ---- - gcc/common.opt | 4 ++++ - gcc/config.in | 6 ++++++ - gcc/configure | 16 ++++++++++++++++ - gcc/configure.ac | 10 ++++++++++ - gcc/doc/invoke.texi | 9 +++++++++ - gcc/gcc.c | 2 ++ - gcc/incpath.c | 19 +++++++++++++++++++ - 7 files changed, 66 insertions(+) - -diff --git a/gcc/common.opt b/gcc/common.opt -index d6ef85928f3..7b29efe3882 100644 ---- a/gcc/common.opt -+++ b/gcc/common.opt -@@ -679,6 +679,10 @@ Wreturn-local-addr - Common Var(warn_return_local_addr) Init(1) Warning - Warn about returning a pointer/reference to a local or temporary variable. - -+Wpoison-system-directories -+Common Var(flag_poison_system_directories) Init(1) Warning -+Warn for -I and -L options using system directories if cross compiling -+ - Wshadow - Common Var(warn_shadow) Warning - Warn when one variable shadows another. Same as -Wshadow=global. -diff --git a/gcc/config.in b/gcc/config.in -index 5bccb408016..1c784a8276b 100644 ---- a/gcc/config.in -+++ b/gcc/config.in -@@ -194,6 +194,12 @@ - #endif - - -+/* Define to warn for use of native system header directories */ -+#ifndef USED_FOR_TARGET -+#undef ENABLE_POISON_SYSTEM_DIRECTORIES -+#endif -+ -+ - /* Define if you want all operations on RTL (the basic data structure of the - optimizer and back end) to be checked for dynamic type safety at runtime. - This is quite expensive. */ -diff --git a/gcc/configure b/gcc/configure -index 5c345ce0fd7..cafd05fd150 100755 ---- a/gcc/configure -+++ b/gcc/configure -@@ -953,6 +953,7 @@ with_system_zlib - enable_maintainer_mode - enable_link_mutex - enable_version_specific_runtime_libs -+enable_poison_system_directories - enable_plugin - enable_host_shared - enable_libquadmath_support -@@ -1696,6 +1697,8 @@ Optional Features: - --enable-version-specific-runtime-libs - specify that runtime libraries should be installed - in a compiler-specific directory -+ --enable-poison-system-directories -+ warn for use of native system header directories - --enable-plugin enable plugin support - --enable-host-shared build host code as shared libraries - --disable-libquadmath-support -@@ -29715,6 +29718,19 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then : - fi - - -+# Check whether --enable-poison-system-directories was given. -+if test "${enable_poison_system_directories+set}" = set; then : -+ enableval=$enable_poison_system_directories; -+else -+ enable_poison_system_directories=no -+fi -+ -+if test "x${enable_poison_system_directories}" = "xyes"; then -+ -+$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h -+ -+fi -+ - # Substitute configuration variables - - -diff --git a/gcc/configure.ac b/gcc/configure.ac -index 65dbf1f2f80..dd5b38195ce 100644 ---- a/gcc/configure.ac -+++ b/gcc/configure.ac -@@ -6341,6 +6341,16 @@ AC_ARG_ENABLE(version-specific-runtime-libs, - [specify that runtime libraries should be - installed in a compiler-specific directory])]) - -+AC_ARG_ENABLE([poison-system-directories], -+ AS_HELP_STRING([--enable-poison-system-directories], -+ [warn for use of native system header directories]),, -+ [enable_poison_system_directories=no]) -+if test "x${enable_poison_system_directories}" = "xyes"; then -+ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES], -+ [1], -+ [Define to warn for use of native system header directories]) -+fi -+ - # Substitute configuration variables - AC_SUBST(subdirs) - AC_SUBST(srcdir) -diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi -index 255149fcfb8..cb71b60fe3c 100644 ---- a/gcc/doc/invoke.texi -+++ b/gcc/doc/invoke.texi -@@ -303,6 +303,7 @@ Objective-C and Objective-C++ Dialects}. - -Wpacked -Wpacked-bitfield-compat -Wpacked-not-aligned -Wpadded @gol - -Wparentheses -Wno-pedantic-ms-format @gol - -Wplacement-new -Wplacement-new=@var{n} @gol -+-Wno-poison-system-directories @gol - -Wpointer-arith -Wpointer-compare -Wno-pointer-to-int-cast @gol - -Wno-pragmas -Wredundant-decls -Wrestrict -Wno-return-local-addr @gol - -Wreturn-type -Wsequence-point -Wshadow -Wno-shadow-ivar @gol -@@ -5712,6 +5713,14 @@ made up of data only and thus requires no special treatment. But, for - most targets, it is made up of code and thus requires the stack to be - made executable in order for the program to work properly. - -+@item -Wno-poison-system-directories -+@opindex Wno-poison-system-directories -+Do not warn for @option{-I} or @option{-L} options using system -+directories such as @file{/usr/include} when cross compiling. This -+option is intended for use in chroot environments when such -+directories contain the correct headers and libraries for the target -+system rather than the host. -+ - @item -Wfloat-equal - @opindex Wfloat-equal - @opindex Wno-float-equal -diff --git a/gcc/gcc.c b/gcc/gcc.c -index a716f708259..02b3cd39fc2 100644 ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -1037,6 +1037,8 @@ proper position among the other output files. */ - "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \ - "%X %{o*} %{e*} %{N} %{n} %{r}\ - %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}} \ -+ %{Wno-poison-system-directories:--no-poison-system-directories} \ -+ %{Werror=poison-system-directories:--error-poison-system-directories} \ - %{static|no-pie|static-pie:} %{L*} %(mfwrap) %(link_libgcc) " \ - VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o " CHKP_SPEC " \ - %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\ -diff --git a/gcc/incpath.c b/gcc/incpath.c -index b11c6a57939..e3b7a21966f 100644 ---- a/gcc/incpath.c -+++ b/gcc/incpath.c -@@ -26,6 +26,7 @@ - #include "intl.h" - #include "incpath.h" - #include "cppdefault.h" -+#include "diagnostic-core.h" - - /* Microsoft Windows does not natively support inodes. - VMS has non-numeric inodes. */ -@@ -393,6 +394,26 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose) - } - fprintf (stderr, _("End of search list.\n")); - } -+ -+#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES -+ if (flag_poison_system_directories) -+ { -+ struct cpp_dir *p; -+ -+ for (p = heads[INC_QUOTE]; p; p = p->next) -+ { -+ if ((!strncmp (p->name, "/usr/include", 12)) -+ || (!strncmp (p->name, "/usr/local/include", 18)) -+ || (!strncmp (p->name, "/usr/X11R6/include", 18)) -+ || (!strncmp (p->name, "/sw/include", 11)) -+ || (!strncmp (p->name, "/opt/include", 12))) -+ warning (OPT_Wpoison_system_directories, -+ "include location \"%s\" is unsafe for " -+ "cross-compilation", -+ p->name); -+ } -+ } -+#endif - } - - /* Use given -I paths for #include "..." but not #include <...>, and --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0005-gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0005-gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch deleted file mode 100644 index 8b1b9769..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0005-gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch +++ /dev/null @@ -1,73 +0,0 @@ -From ae3fe6e5e50937de6e4223ca90810187372a8cf5 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 29 Mar 2013 09:08:31 +0400 -Subject: [PATCH 05/39] gcc-4.3.3: SYSROOT_CFLAGS_FOR_TARGET - -Before committing, I noticed that PR/32161 was marked as a dup of PR/32009, but my previous patch did not fix it. - -This alternative patch is better because it lets you just use CFLAGS_FOR_TARGET to set the compilation flags for libgcc. Since bootstrapped target libraries are never compiled with the native compiler, it makes little sense to use different flags for stage1 and later stages. And it also makes little sense to use a different variable than CFLAGS_FOR_TARGET. - -Other changes I had to do include: - -- moving the creation of default CFLAGS_FOR_TARGET from Makefile.am to configure.ac, because otherwise the BOOT_CFLAGS are substituted into CFLAGS_FOR_TARGET (which is "-O2 -g $(CFLAGS)") via $(CFLAGS). It is also cleaner this way though. - -- passing the right CFLAGS to configure scripts as exported environment variables - -I also stopped passing LIBCFLAGS to configure scripts since they are unused in the whole src tree. And I updated the documentation as H-P reminded me to do. - -Bootstrapped/regtested i686-pc-linux-gnu, will commit to 4.4 shortly. Ok for 4.3? - -Signed-off-by: Paolo Bonzini -Signed-off-by: Khem Raj - -Upstream-Status: Pending ---- - configure | 32 ++++++++++++++++++++++++++++++++ - 1 file changed, 32 insertions(+) - -diff --git a/configure b/configure -index 517fb70192e..acd2b97df40 100755 ---- a/configure -+++ b/configure -@@ -6772,6 +6772,38 @@ fi - - - -+# During gcc bootstrap, if we use some random cc for stage1 then CFLAGS -+# might be empty or "-g". We don't require a C++ compiler, so CXXFLAGS -+# might also be empty (or "-g", if a non-GCC C++ compiler is in the path). -+# We want to ensure that TARGET libraries (which we know are built with -+# gcc) are built with "-O2 -g", so include those options when setting -+# CFLAGS_FOR_TARGET and CXXFLAGS_FOR_TARGET. -+if test "x$CFLAGS_FOR_TARGET" = x; then -+ CFLAGS_FOR_TARGET=$CFLAGS -+ case " $CFLAGS " in -+ *" -O2 "*) ;; -+ *) CFLAGS_FOR_TARGET="-O2 $CFLAGS" ;; -+ esac -+ case " $CFLAGS " in -+ *" -g "* | *" -g3 "*) ;; -+ *) CFLAGS_FOR_TARGET="-g $CFLAGS" ;; -+ esac -+fi -+ -+ -+if test "x$CXXFLAGS_FOR_TARGET" = x; then -+ CXXFLAGS_FOR_TARGET=$CXXFLAGS -+ case " $CXXFLAGS " in -+ *" -O2 "*) ;; -+ *) CXXFLAGS_FOR_TARGET="-O2 $CXXFLAGS" ;; -+ esac -+ case " $CXXFLAGS " in -+ *" -g "* | *" -g3 "*) ;; -+ *) CXXFLAGS_FOR_TARGET="-g $CXXFLAGS" ;; -+ esac -+fi -+ -+ - # Handle --with-headers=XXX. If the value is not "yes", the contents of - # the named directory are copied to $(tooldir)/sys-include. - if test x"${with_headers}" != x && test x"${with_headers}" != xno ; then --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0006-64-bit-multilib-hack.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0006-64-bit-multilib-hack.patch deleted file mode 100644 index 0dce95c8..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0006-64-bit-multilib-hack.patch +++ /dev/null @@ -1,85 +0,0 @@ -From 89af3b7399313b337f06c19cc2d787aa16d27711 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 29 Mar 2013 09:10:06 +0400 -Subject: [PATCH 06/39] 64-bit multilib hack. - -GCC has internal multilib handling code but it assumes a very specific rigid directory -layout. The build system implementation of multilib layout is very generic and allows -complete customisation of the library directories. - -This patch is a partial solution to allow any custom directories to be passed into gcc -and handled correctly. It forces gcc to use the base_libdir (which is the current -directory, "."). We need to do this for each multilib that is configured as we don't -know which compiler options may be being passed into the compiler. Since we have a compiler -per mulitlib at this point that isn't an issue. - -The one problem is the target compiler is only going to work for the default multlilib at -this point. Ideally we'd figure out which multilibs were being enabled with which paths -and be able to patch these entries with a complete set of correct paths but this we -don't have such code at this point. This is something the target gcc recipe should do -and override these platform defaults in its build config. - -RP 15/8/11 - -Signed-off-by: Khem Raj -Signed-off-by: Elvis Dowson - -Upstream-Status: Pending ---- - gcc/config/i386/t-linux64 | 6 ++---- - gcc/config/mips/t-linux64 | 10 +++------- - gcc/config/rs6000/t-linux64 | 5 ++--- - 3 files changed, 7 insertions(+), 14 deletions(-) - -diff --git a/gcc/config/i386/t-linux64 b/gcc/config/i386/t-linux64 -index 8ea0faff369..266c6008004 100644 ---- a/gcc/config/i386/t-linux64 -+++ b/gcc/config/i386/t-linux64 -@@ -32,7 +32,5 @@ - # - comma=, - MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG)) --MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS))) --MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu) --MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu) --MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32) -+MULTILIB_DIRNAMES = . . -+MULTILIB_OSDIRNAMES = ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) -diff --git a/gcc/config/mips/t-linux64 b/gcc/config/mips/t-linux64 -index c017b7d04c5..126892cf40b 100644 ---- a/gcc/config/mips/t-linux64 -+++ b/gcc/config/mips/t-linux64 -@@ -17,10 +17,6 @@ - # . - - MULTILIB_OPTIONS = mabi=n32/mabi=32/mabi=64 --MULTILIB_DIRNAMES = n32 32 64 --MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el) --MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft) --MULTILIB_OSDIRNAMES = \ -- ../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \ -- ../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \ -- ../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT)) -+MULTILIB_DIRNAMES = . . . -+MULTILIB_OSDIRNAMES = ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) -+ -diff --git a/gcc/config/rs6000/t-linux64 b/gcc/config/rs6000/t-linux64 -index 0faa2a02df4..13fd8ca971e 100644 ---- a/gcc/config/rs6000/t-linux64 -+++ b/gcc/config/rs6000/t-linux64 -@@ -26,10 +26,9 @@ - # MULTILIB_OSDIRNAMES according to what is found on the target. - - MULTILIB_OPTIONS := m64/m32 --MULTILIB_DIRNAMES := 64 32 -+MULTILIB_DIRNAMES := . . - MULTILIB_EXTRA_OPTS := --MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu) --MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu) -+MULTILIB_OSDIRNAMES := ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) - - rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c - $(COMPILE) $< --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0007-optional-libstdc.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0007-optional-libstdc.patch deleted file mode 100644 index 721ea03f..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0007-optional-libstdc.patch +++ /dev/null @@ -1,125 +0,0 @@ -From fb7df63e9548c29b70601d642a1850fc455f8565 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 29 Mar 2013 09:12:56 +0400 -Subject: [PATCH 07/39] optional libstdc - -gcc-runtime builds libstdc++ separately from gcc-cross-*. Its configure tests using g++ -will not run correctly since by default the linker will try to link against libstdc++ -which shouldn't exist yet. We need an option to disable -lstdc++ -option whilst leaving -lc, -lgcc and other automatic library dependencies added by gcc -driver. This patch adds such an option which only disables the -lstdc++. - -A "standard" gcc build uses xgcc and hence avoids this. We should ask upstream how to -do this officially, the likely answer is don't build libstdc++ separately. - -RP 29/6/10 - -Signed-off-by: Khem Raj - -Upstream-Status: Inappropriate [embedded specific] ---- - gcc/c-family/c.opt | 4 ++++ - gcc/cp/g++spec.c | 1 + - gcc/doc/invoke.texi | 32 +++++++++++++++++++++++++++++++- - gcc/gcc.c | 1 + - 4 files changed, 37 insertions(+), 1 deletion(-) - -diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt -index 5013501b232..6312f2c8f90 100644 ---- a/gcc/c-family/c.opt -+++ b/gcc/c-family/c.opt -@@ -1900,6 +1900,10 @@ nostdinc++ - C++ ObjC++ - Do not search standard system include directories for C++. - -+nostdlib++ -+Driver -+Do not link standard C++ runtime library -+ - o - C ObjC C++ ObjC++ Joined Separate - ; Documented in common.opt -diff --git a/gcc/cp/g++spec.c b/gcc/cp/g++spec.c -index 443a1746da3..e9b51be62ef 100644 ---- a/gcc/cp/g++spec.c -+++ b/gcc/cp/g++spec.c -@@ -137,6 +137,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, - switch (decoded_options[i].opt_index) - { - case OPT_nostdlib: -+ case OPT_nostdlib__: - case OPT_nodefaultlibs: - library = -1; - break; -diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi -index cb71b60fe3c..b0d481e3a30 100644 ---- a/gcc/doc/invoke.texi -+++ b/gcc/doc/invoke.texi -@@ -211,6 +211,9 @@ in the following sections. - -fno-weak -nostdinc++ @gol - -fvisibility-inlines-hidden @gol - -fvisibility-ms-compat @gol -+-fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} @gol -+-fvtv-counts -fvtv-debug @gol -+-nostdlib++ @gol - -fext-numeric-literals @gol - -Wabi=@var{n} -Wabi-tag -Wconversion-null -Wctor-dtor-privacy @gol - -Wdelete-non-virtual-dtor -Wliteral-suffix -Wmultiple-inheritance @gol -@@ -509,7 +512,7 @@ Objective-C and Objective-C++ Dialects}. - -s -static -static-pie -static-libgcc -static-libstdc++ @gol - -static-libasan -static-libtsan -static-liblsan -static-libubsan @gol - -static-libmpx -static-libmpxwrappers @gol ---shared -shared-libgcc -symbolic @gol -+-shared -shared-libgcc -symbolic -nostdlib++ @gol - -T @var{script} -Wl,@var{option} -Xlinker @var{option} @gol - -u @var{symbol} -z @var{keyword}} - -@@ -12331,6 +12334,33 @@ library subroutines. - constructors are called; @pxref{Collect2,,@code{collect2}, gccint, - GNU Compiler Collection (GCC) Internals}.) - -+@item -nostdlib++ -+@opindex nostdlib++ -+Do not use the standard system C++ runtime libraries when linking. -+Only the libraries you specify will be passed to the linker. -+ -+@cindex @option{-lgcc}, use with @option{-nostdlib} -+@cindex @option{-nostdlib} and unresolved references -+@cindex unresolved references and @option{-nostdlib} -+@cindex @option{-lgcc}, use with @option{-nodefaultlibs} -+@cindex @option{-nodefaultlibs} and unresolved references -+@cindex unresolved references and @option{-nodefaultlibs} -+One of the standard libraries bypassed by @option{-nostdlib} and -+@option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines -+which GCC uses to overcome shortcomings of particular machines, or special -+needs for some languages. -+(@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler -+Collection (GCC) Internals}, -+for more discussion of @file{libgcc.a}.) -+In most cases, you need @file{libgcc.a} even when you want to avoid -+other standard libraries. In other words, when you specify @option{-nostdlib} -+or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well. -+This ensures that you have no unresolved references to internal GCC -+library subroutines. -+(An example of such an internal subroutine is @code{__main}, used to ensure C++ -+constructors are called; @pxref{Collect2,,@code{collect2}, gccint, -+GNU Compiler Collection (GCC) Internals}.) -+ - @item -pie - @opindex pie - Produce a dynamically linked position independent executable on targets -diff --git a/gcc/gcc.c b/gcc/gcc.c -index 02b3cd39fc2..8cd27a5dad5 100644 ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -1047,6 +1047,7 @@ proper position among the other output files. */ - %(mflib) " STACK_SPLIT_SPEC "\ - %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} " SANITIZER_SPEC " \ - %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\ -+ %{!nostdlib++:}\ - %{!nostdlib:%{!nostartfiles:%E}} %{T*} \n%(post_link) }}}}}}" - #endif - --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0008-gcc-disable-MASK_RELAX_PIC_CALLS-bit.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0008-gcc-disable-MASK_RELAX_PIC_CALLS-bit.patch deleted file mode 100644 index a76b7f73..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0008-gcc-disable-MASK_RELAX_PIC_CALLS-bit.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 11eb97efccb90b830c84ed077a25b1a15ad3335b Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 29 Mar 2013 09:14:20 +0400 -Subject: [PATCH 08/39] gcc: disable MASK_RELAX_PIC_CALLS bit - -The new feature added after 4.3.3 -"http://www.pubbs.net/200909/gcc/94048-patch-add-support-for-rmipsjalr.html" -will cause cc1plus eat up all the system memory when build webkit-gtk. -The function mips_get_pic_call_symbol keeps on recursively calling itself. -Disable this feature to walk aside the bug. - -Signed-off-by: Dongxiao Xu -Signed-off-by: Khem Raj - -Upstream-Status: Inappropriate [configuration] ---- - gcc/configure | 7 ------- - gcc/configure.ac | 7 ------- - 2 files changed, 14 deletions(-) - -diff --git a/gcc/configure b/gcc/configure -index cafd05fd150..19ba051d673 100755 ---- a/gcc/configure -+++ b/gcc/configure -@@ -27553,13 +27553,6 @@ $as_echo_n "checking assembler and linker for explicit JALR relocation... " >&6; - rm -f conftest.* - fi - fi -- if test $gcc_cv_as_ld_jalr_reloc = yes; then -- if test x$target_cpu_default = x; then -- target_cpu_default=MASK_RELAX_PIC_CALLS -- else -- target_cpu_default="($target_cpu_default)|MASK_RELAX_PIC_CALLS" -- fi -- fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_ld_jalr_reloc" >&5 - $as_echo "$gcc_cv_as_ld_jalr_reloc" >&6; } - -diff --git a/gcc/configure.ac b/gcc/configure.ac -index dd5b38195ce..066dfe19bb6 100644 ---- a/gcc/configure.ac -+++ b/gcc/configure.ac -@@ -4798,13 +4798,6 @@ x: - rm -f conftest.* - fi - fi -- if test $gcc_cv_as_ld_jalr_reloc = yes; then -- if test x$target_cpu_default = x; then -- target_cpu_default=MASK_RELAX_PIC_CALLS -- else -- target_cpu_default="($target_cpu_default)|MASK_RELAX_PIC_CALLS" -- fi -- fi - AC_MSG_RESULT($gcc_cv_as_ld_jalr_reloc) - - AC_CACHE_CHECK([linker for .eh_frame personality relaxation], --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0009-COLLECT_GCC_OPTIONS.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0009-COLLECT_GCC_OPTIONS.patch deleted file mode 100644 index 3abece0d..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0009-COLLECT_GCC_OPTIONS.patch +++ /dev/null @@ -1,38 +0,0 @@ -From e19d25847f08eeb5ef26a031fa5eff732bfd0d43 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 29 Mar 2013 09:16:28 +0400 -Subject: [PATCH 09/39] COLLECT_GCC_OPTIONS - -This patch adds --sysroot into COLLECT_GCC_OPTIONS which is used to -invoke collect2. - -Signed-off-by: Khem Raj - -Upstream-Status: Pending ---- - gcc/gcc.c | 9 +++++++++ - 1 file changed, 9 insertions(+) - -diff --git a/gcc/gcc.c b/gcc/gcc.c -index 8cd27a5dad5..d355d65583a 100644 ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -4677,6 +4677,15 @@ set_collect_gcc_options (void) - sizeof ("COLLECT_GCC_OPTIONS=") - 1); - - first_time = TRUE; -+#ifdef HAVE_LD_SYSROOT -+ if (target_system_root_changed && target_system_root) -+ { -+ obstack_grow (&collect_obstack, "'--sysroot=", sizeof("'--sysroot=")-1); -+ obstack_grow (&collect_obstack, target_system_root,strlen(target_system_root)); -+ obstack_grow (&collect_obstack, "'", 1); -+ first_time = FALSE; -+ } -+#endif - for (i = 0; (int) i < n_switches; i++) - { - const char *const *args; --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0010-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0010-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch deleted file mode 100644 index 5785b589..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0010-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch +++ /dev/null @@ -1,96 +0,0 @@ -From 265cb883c310f3bb7e49fd13b81362476fbeb6c1 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 29 Mar 2013 09:17:25 +0400 -Subject: [PATCH 10/39] Use the defaults.h in ${B} instead of ${S}, and t-oe in - ${B} - -Use the defaults.h in ${B} instead of ${S}, and t-oe in ${B}, so that -the source can be shared between gcc-cross-initial, -gcc-cross-intermediate, gcc-cross, gcc-runtime, and also the sdk build. - -Signed-off-by: Khem Raj - -Upstream-Status: Pending - -While compiling gcc-crosssdk-initial-x86_64 on some host, there is -occasionally failure that test the existance of default.h doesn't -work, the reason is tm_include_list='** defaults.h' rather than -tm_include_list='** ./defaults.h' - -So we add the test condition for this situation. -Signed-off-by: Hongxu Jia ---- - gcc/Makefile.in | 2 +- - gcc/configure | 4 ++-- - gcc/configure.ac | 4 ++-- - gcc/mkconfig.sh | 4 ++-- - 4 files changed, 7 insertions(+), 7 deletions(-) - -diff --git a/gcc/Makefile.in b/gcc/Makefile.in -index 20bee0494b1..1367136bfac 100644 ---- a/gcc/Makefile.in -+++ b/gcc/Makefile.in -@@ -538,7 +538,7 @@ TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@ - TARGET_SYSTEM_ROOT_DEFINE = @TARGET_SYSTEM_ROOT_DEFINE@ - - xmake_file=@xmake_file@ --tmake_file=@tmake_file@ -+tmake_file=@tmake_file@ ./t-oe - TM_ENDIAN_CONFIG=@TM_ENDIAN_CONFIG@ - TM_MULTILIB_CONFIG=@TM_MULTILIB_CONFIG@ - TM_MULTILIB_EXCEPTIONS_CONFIG=@TM_MULTILIB_EXCEPTIONS_CONFIG@ -diff --git a/gcc/configure b/gcc/configure -index 19ba051d673..a575839c1b2 100755 ---- a/gcc/configure -+++ b/gcc/configure -@@ -12158,8 +12158,8 @@ for f in $tm_file; do - tm_include_list="${tm_include_list} $f" - ;; - defaults.h ) -- tm_file_list="${tm_file_list} \$(srcdir)/$f" -- tm_include_list="${tm_include_list} $f" -+ tm_file_list="${tm_file_list} ./$f" -+ tm_include_list="${tm_include_list} ./$f" - ;; - * ) - tm_file_list="${tm_file_list} \$(srcdir)/config/$f" -diff --git a/gcc/configure.ac b/gcc/configure.ac -index 066dfe19bb6..676116a6d96 100644 ---- a/gcc/configure.ac -+++ b/gcc/configure.ac -@@ -1922,8 +1922,8 @@ for f in $tm_file; do - tm_include_list="${tm_include_list} $f" - ;; - defaults.h ) -- tm_file_list="${tm_file_list} \$(srcdir)/$f" -- tm_include_list="${tm_include_list} $f" -+ tm_file_list="${tm_file_list} ./$f" -+ tm_include_list="${tm_include_list} ./$f" - ;; - * ) - tm_file_list="${tm_file_list} \$(srcdir)/config/$f" -diff --git a/gcc/mkconfig.sh b/gcc/mkconfig.sh -index 0f75c863c0b..68d8d6613cf 100644 ---- a/gcc/mkconfig.sh -+++ b/gcc/mkconfig.sh -@@ -77,7 +77,7 @@ if [ -n "$HEADERS" ]; then - if [ $# -ge 1 ]; then - echo '#ifdef IN_GCC' >> ${output}T - for file in "$@"; do -- if test x"$file" = x"defaults.h"; then -+ if test x"$file" = x"./defaults.h" -o x"$file" = x"defaults.h"; then - postpone_defaults_h="yes" - else - echo "# include \"$file\"" >> ${output}T -@@ -106,7 +106,7 @@ esac - - # If we postponed including defaults.h, add the #include now. - if test x"$postpone_defaults_h" = x"yes"; then -- echo "# include \"defaults.h\"" >> ${output}T -+ echo "# include \"./defaults.h\"" >> ${output}T - fi - - # Add multiple inclusion protection guard, part two. --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0012-cpp-honor-sysroot.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0012-cpp-honor-sysroot.patch deleted file mode 100644 index 961f96f1..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0012-cpp-honor-sysroot.patch +++ /dev/null @@ -1,54 +0,0 @@ -From b3e8e7e8ae106e3207e9edc3d23dcce1464b755f Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 29 Mar 2013 09:22:00 +0400 -Subject: [PATCH 12/39] cpp: honor sysroot. - -Currently, if the gcc toolchain is relocated and installed from sstate, then you try and compile -preprocessed source (.i or .ii files), the compiler will try and access the builtin sysroot location -rather than the --sysroot option specified on the commandline. If access to that directory is -permission denied (unreadable), gcc will error. - -This happens when ccache is in use due to the fact it uses preprocessed source files. - -The fix below adds %I to the cpp-output spec macro so the default substitutions for -iprefix, --isystem, -isysroot happen and the correct sysroot is used. - -[YOCTO #2074] - -RP 2012/04/13 - -Signed-off-by: Khem Raj - -Upstream-Status: Pending ---- - gcc/cp/lang-specs.h | 2 +- - gcc/gcc.c | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/gcc/cp/lang-specs.h b/gcc/cp/lang-specs.h -index f0802b8915c..f324d299849 100644 ---- a/gcc/cp/lang-specs.h -+++ b/gcc/cp/lang-specs.h -@@ -64,5 +64,5 @@ along with GCC; see the file COPYING3. If not see - {".ii", "@c++-cpp-output", 0, 0, 0}, - {"@c++-cpp-output", - "%{!M:%{!MM:%{!E:\ -- cc1plus -fpreprocessed %i %(cc1_options) %2\ -+ cc1plus -fpreprocessed %i %I %(cc1_options) %2\ - %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, -diff --git a/gcc/gcc.c b/gcc/gcc.c -index d355d65583a..570cdc00034 100644 ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -1343,7 +1343,7 @@ static const struct compiler default_compilers[] = - %W{o*:--output-pch=%*}}%V}}}}}}}", 0, 0, 0}, - {".i", "@cpp-output", 0, 0, 0}, - {"@cpp-output", -- "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, -+ "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %I %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, - {".s", "@assembler", 0, 0, 0}, - {"@assembler", - "%{!M:%{!MM:%{!E:%{!S:as %(asm_debug) %(asm_options) %i %A }}}}", 0, 0, 0}, --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0013-MIPS64-Default-to-N64-ABI.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0013-MIPS64-Default-to-N64-ABI.patch deleted file mode 100644 index 8ef8806b..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0013-MIPS64-Default-to-N64-ABI.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 0f3629978cd7c98614e87d4fd190b89864221631 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 29 Mar 2013 09:23:08 +0400 -Subject: [PATCH 13/39] MIPS64: Default to N64 ABI - -MIPS64 defaults to n32 ABI, this patch makes it -so that it defaults to N64 ABI - -Signed-off-by: Khem Raj - -Upstream-Status: Inappropriate [OE config specific] ---- - gcc/config.gcc | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -diff --git a/gcc/config.gcc b/gcc/config.gcc -index 8741dd1e3b2..2ffcb39d85f 100644 ---- a/gcc/config.gcc -+++ b/gcc/config.gcc -@@ -2137,29 +2137,29 @@ mips*-*-linux*) # Linux MIPS, either endian. - default_mips_arch=mips32 - ;; - mips64el-st-linux-gnu) -- default_mips_abi=n32 -+ default_mips_abi=64 - tm_file="${tm_file} mips/st.h" - tmake_file="${tmake_file} mips/t-st" - enable_mips_multilibs="yes" - ;; - mips64octeon*-*-linux*) -- default_mips_abi=n32 -+ default_mips_abi=64 - tm_defines="${tm_defines} MIPS_CPU_STRING_DEFAULT=\\\"octeon\\\"" - target_cpu_default=MASK_SOFT_FLOAT_ABI - enable_mips_multilibs="yes" - ;; - mipsisa64r6*-*-linux*) -- default_mips_abi=n32 -+ default_mips_abi=64 - default_mips_arch=mips64r6 - enable_mips_multilibs="yes" - ;; - mipsisa64r2*-*-linux*) -- default_mips_abi=n32 -+ default_mips_abi=64 - default_mips_arch=mips64r2 - enable_mips_multilibs="yes" - ;; - mips64*-*-linux* | mipsisa64*-*-linux*) -- default_mips_abi=n32 -+ default_mips_abi=64 - enable_mips_multilibs="yes" - ;; - esac --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0014-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0014-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch deleted file mode 100644 index 043bb9dd..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0014-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch +++ /dev/null @@ -1,248 +0,0 @@ -From 53f1c382b1366c5621c8edead9c766950c290fd9 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 29 Mar 2013 09:24:50 +0400 -Subject: [PATCH 14/39] Define GLIBC_DYNAMIC_LINKER and UCLIBC_DYNAMIC_LINKER - relative to SYSTEMLIBS_DIR - -This patch defines GLIBC_DYNAMIC_LINKER and UCLIBC_DYNAMIC_LINKER -relative to SYSTEMLIBS_DIR which can be set in generated headers -This breaks the assumption of hardcoded multilib in gcc -Change is only for the supported architectures in OE including -SH, sparc, alpha for possible future support (if any) - -Removes the do_headerfix task in metadata - -Signed-off-by: Khem Raj - -Upstream-Status: Inappropriate [OE configuration] ---- - gcc/config/alpha/linux-elf.h | 4 ++-- - gcc/config/arm/linux-eabi.h | 4 ++-- - gcc/config/arm/linux-elf.h | 2 +- - gcc/config/i386/linux.h | 2 +- - gcc/config/i386/linux64.h | 6 +++--- - gcc/config/linux.h | 8 ++++---- - gcc/config/mips/linux.h | 12 ++++++------ - gcc/config/riscv/linux.h | 2 +- - gcc/config/rs6000/linux64.h | 16 ++++++---------- - gcc/config/sh/linux.h | 2 +- - gcc/config/sparc/linux.h | 2 +- - gcc/config/sparc/linux64.h | 4 ++-- - 12 files changed, 30 insertions(+), 34 deletions(-) - -diff --git a/gcc/config/alpha/linux-elf.h b/gcc/config/alpha/linux-elf.h -index 36b74dc1993..02373578af8 100644 ---- a/gcc/config/alpha/linux-elf.h -+++ b/gcc/config/alpha/linux-elf.h -@@ -23,8 +23,8 @@ along with GCC; see the file COPYING3. If not see - #define EXTRA_SPECS \ - { "elf_dynamic_linker", ELF_DYNAMIC_LINKER }, - --#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" --#define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0" -+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2" -+#define UCLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-uClibc.so.0" - #if DEFAULT_LIBC == LIBC_UCLIBC - #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}" - #elif DEFAULT_LIBC == LIBC_GLIBC -diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h -index 8585fde3d41..b3af68cac57 100644 ---- a/gcc/config/arm/linux-eabi.h -+++ b/gcc/config/arm/linux-eabi.h -@@ -62,8 +62,8 @@ - GLIBC_DYNAMIC_LINKER_DEFAULT and TARGET_DEFAULT_FLOAT_ABI. */ - - #undef GLIBC_DYNAMIC_LINKER --#define GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "/lib/ld-linux.so.3" --#define GLIBC_DYNAMIC_LINKER_HARD_FLOAT "/lib/ld-linux-armhf.so.3" -+#define GLIBC_DYNAMIC_LINKER_SOFT_FLOAT SYSTEMLIBS_DIR "ld-linux.so.3" -+#define GLIBC_DYNAMIC_LINKER_HARD_FLOAT SYSTEMLIBS_DIR "ld-linux-armhf.so.3" - #define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_SOFT_FLOAT - - #define GLIBC_DYNAMIC_LINKER \ -diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h -index cfcd9cb1a5c..a798e987ecb 100644 ---- a/gcc/config/arm/linux-elf.h -+++ b/gcc/config/arm/linux-elf.h -@@ -60,7 +60,7 @@ - - #define LIBGCC_SPEC "%{mfloat-abi=soft*:-lfloat} -lgcc" - --#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" -+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2" - - #define LINUX_TARGET_LINK_SPEC "%{h*} \ - %{static:-Bstatic} \ -diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h -index 69f97f15b0d..71bc31d9231 100644 ---- a/gcc/config/i386/linux.h -+++ b/gcc/config/i386/linux.h -@@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. If not see - . */ - - #define GNU_USER_LINK_EMULATION "elf_i386" --#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" -+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2" - - #undef MUSL_DYNAMIC_LINKER - #define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1" -diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h -index f2d913e30ac..8725f33d8a5 100644 ---- a/gcc/config/i386/linux64.h -+++ b/gcc/config/i386/linux64.h -@@ -27,9 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see - #define GNU_USER_LINK_EMULATION64 "elf_x86_64" - #define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64" - --#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2" --#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2" --#define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2" -+#define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-linux.so.2" -+#define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-linux-x86-64.so.2" -+#define GLIBC_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ld-linux-x32.so.2" - - #undef MUSL_DYNAMIC_LINKER32 - #define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1" -diff --git a/gcc/config/linux.h b/gcc/config/linux.h -index 2ea4ff92c1d..487b0c0923b 100644 ---- a/gcc/config/linux.h -+++ b/gcc/config/linux.h -@@ -81,10 +81,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see - GLIBC_DYNAMIC_LINKER must be defined for each target using them, or - GLIBC_DYNAMIC_LINKER32 and GLIBC_DYNAMIC_LINKER64 for targets - supporting both 32-bit and 64-bit compilation. */ --#define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0" --#define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0" --#define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0" --#define UCLIBC_DYNAMIC_LINKERX32 "/lib/ldx32-uClibc.so.0" -+#define UCLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-uClibc.so.0" -+#define UCLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-uClibc.so.0" -+#define UCLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld64-uClibc.so.0" -+#define UCLIBC_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ldx32-uClibc.so.0" - #define BIONIC_DYNAMIC_LINKER "/system/bin/linker" - #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker" - #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64" -diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h -index 2dfd0c18b90..12057c51b5e 100644 ---- a/gcc/config/mips/linux.h -+++ b/gcc/config/mips/linux.h -@@ -22,20 +22,20 @@ along with GCC; see the file COPYING3. If not see - #define GNU_USER_LINK_EMULATIONN32 "elf32%{EB:b}%{EL:l}tsmipn32" - - #define GLIBC_DYNAMIC_LINKER32 \ -- "%{mnan=2008:/lib/ld-linux-mipsn8.so.1;:/lib/ld.so.1}" -+ "%{mnan=2008:" SYSTEMLIBS_DIR "ld-linux-mipsn8.so.1;:" SYSTEMLIBS_DIR "ld.so.1}" - #define GLIBC_DYNAMIC_LINKER64 \ -- "%{mnan=2008:/lib64/ld-linux-mipsn8.so.1;:/lib64/ld.so.1}" -+ "%{mnan=2008:" SYSTEMLIBS_DIR "ld-linux-mipsn8.so.1;:" SYSTEMLIBS_DIR "ld.so.1}" - #define GLIBC_DYNAMIC_LINKERN32 \ -- "%{mnan=2008:/lib32/ld-linux-mipsn8.so.1;:/lib32/ld.so.1}" -+ "%{mnan=2008:" SYSTEMLIBS_DIR "ld-linux-mipsn8.so.1;:" SYSTEMLIBS_DIR "ld.so.1}" - - #undef UCLIBC_DYNAMIC_LINKER32 - #define UCLIBC_DYNAMIC_LINKER32 \ -- "%{mnan=2008:/lib/ld-uClibc-mipsn8.so.0;:/lib/ld-uClibc.so.0}" -+ "%{mnan=2008:" SYSTEMLIBS_DIR "ld-uClibc-mipsn8.so.0;:" SYSTEMLIBS_DIR "ld-uClibc.so.0}" - #undef UCLIBC_DYNAMIC_LINKER64 - #define UCLIBC_DYNAMIC_LINKER64 \ -- "%{mnan=2008:/lib/ld64-uClibc-mipsn8.so.0;:/lib/ld64-uClibc.so.0}" -+ "%{mnan=2008:" SYSTEMLIBS_DIR "ld64-uClibc-mipsn8.so.0;:" SYSTEMLIBS_DIR "ld64-uClibc.so.0}" - #define UCLIBC_DYNAMIC_LINKERN32 \ -- "%{mnan=2008:/lib32/ld-uClibc-mipsn8.so.0;:/lib32/ld-uClibc.so.0}" -+ "%{mnan=2008:" SYSTEMLIBS_DIR "ld-uClibc-mipsn8.so.0;:" SYSTEMLIBS_DIR "ld-uClibc.so.0}" - - #undef MUSL_DYNAMIC_LINKER32 - #define MUSL_DYNAMIC_LINKER32 \ -diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h -index aa8a28d5d..ebf9551c9 100644 ---- a/gcc/config/riscv/linux.h -+++ b/gcc/config/riscv/linux.h -@@ -22,7 +22,7 @@ along with GCC; see the file COPYING3. - GNU_USER_TARGET_OS_CPP_BUILTINS(); \ - } while (0) - --#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-riscv" XLEN_SPEC "-" ABI_SPEC ".so.1" -+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux-riscv" XLEN_SPEC "-" ABI_SPEC ".so.1" - - #define MUSL_ABI_SUFFIX \ - "%{mabi=ilp32:-sf}" \ -diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h -index 90fe6566255..55695dadd91 100644 ---- a/gcc/config/rs6000/linux64.h -+++ b/gcc/config/rs6000/linux64.h -@@ -420,16 +420,11 @@ extern int dot_symbols; - #undef LINK_OS_DEFAULT_SPEC - #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)" - --#define GLIBC_DYNAMIC_LINKER32 "%(dynamic_linker_prefix)/lib/ld.so.1" -- -+#define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld.so.1" - #ifdef LINUX64_DEFAULT_ABI_ELFv2 --#define GLIBC_DYNAMIC_LINKER64 \ --"%{mabi=elfv1:%(dynamic_linker_prefix)/lib64/ld64.so.1;" \ --":%(dynamic_linker_prefix)/lib64/ld64.so.2}" -+#define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv1:" SYSTEMLIBS_DIR "ld64.so.1;:" SYSTEMLIBS_DIR "ld64.so.2}" - #else --#define GLIBC_DYNAMIC_LINKER64 \ --"%{mabi=elfv2:%(dynamic_linker_prefix)/lib64/ld64.so.2;" \ --":%(dynamic_linker_prefix)/lib64/ld64.so.1}" -+#define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv2:" SYSTEMLIBS_DIR "ld64.so.2;:" SYSTEMLIBS_DIR "ld64.so.1}" - #endif - - #define MUSL_DYNAMIC_LINKER32 \ -@@ -437,8 +432,9 @@ extern int dot_symbols; - #define MUSL_DYNAMIC_LINKER64 \ - "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" - --#define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0" --#define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0" -+#define UCLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-uClibc.so.0" -+#define UCLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld64-uClibc.so.0" -+ - #if DEFAULT_LIBC == LIBC_UCLIBC - #define CHOOSE_DYNAMIC_LINKER(G, U, M) \ - "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}" -diff --git a/gcc/config/sh/linux.h b/gcc/config/sh/linux.h -index 6d2ccd012ba..ec78a89ce15 100644 ---- a/gcc/config/sh/linux.h -+++ b/gcc/config/sh/linux.h -@@ -64,7 +64,7 @@ along with GCC; see the file COPYING3. If not see - "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E MUSL_DYNAMIC_LINKER_FP \ - "%{mfdpic:-fdpic}.so.1" - --#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" -+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2" - - #undef SUBTARGET_LINK_EMUL_SUFFIX - #define SUBTARGET_LINK_EMUL_SUFFIX "%{mfdpic:_fd;:_linux}" -diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h -index 9fb03af0fe9..401fddbbb22 100644 ---- a/gcc/config/sparc/linux.h -+++ b/gcc/config/sparc/linux.h -@@ -83,7 +83,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); - When the -shared link option is used a final link is not being - done. */ - --#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" -+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2" - - #undef LINK_SPEC - #define LINK_SPEC "-m elf32_sparc %{shared:-shared} \ -diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h -index c1fe42165b7..26a79bfa2e3 100644 ---- a/gcc/config/sparc/linux64.h -+++ b/gcc/config/sparc/linux64.h -@@ -84,8 +84,8 @@ along with GCC; see the file COPYING3. If not see - When the -shared link option is used a final link is not being - done. */ - --#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2" --#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux.so.2" -+#define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-linux.so.2" -+#define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-linux.so.2" - - #ifdef SPARC_BI_ARCH - --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0017-libtool.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0017-libtool.patch deleted file mode 100644 index 0caa1ce1..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0017-libtool.patch +++ /dev/null @@ -1,42 +0,0 @@ -From c8b11e96b11910b2d4df6ae8104466e3303d933f Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 29 Mar 2013 09:29:11 +0400 -Subject: [PATCH 17/39] libtool - -libstdc++ from gcc-runtime gets created with -rpath=/usr/lib/../lib for qemux86-64 -when running on am x86_64 build host. - -This patch stops this speading to libdir in the libstdc++.la file within libtool. -Arguably, it shouldn't be passing this into libtool in the first place but -for now this resolves the nastiest problems this causes. - -func_normal_abspath would resolve an empty path to `pwd` so we need -to filter the zero case. - -RP 2012/8/24 - -Signed-off-by: Khem Raj - -Upstream-Status: Pending ---- - ltmain.sh | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/ltmain.sh b/ltmain.sh -index 9503ec85d70..0121fba707f 100644 ---- a/ltmain.sh -+++ b/ltmain.sh -@@ -6359,6 +6359,10 @@ func_mode_link () - func_warning "ignoring multiple \`-rpath's for a libtool library" - - install_libdir="$1" -+ if test -n "$install_libdir"; then -+ func_normal_abspath "$install_libdir" -+ install_libdir=$func_normal_abspath_result -+ fi - - oldlibs= - if test -z "$rpath"; then --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0020-Avoid-using-libdir-from-.la-which-usually-points-to-.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0020-Avoid-using-libdir-from-.la-which-usually-points-to-.patch deleted file mode 100644 index 911fe852..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0020-Avoid-using-libdir-from-.la-which-usually-points-to-.patch +++ /dev/null @@ -1,31 +0,0 @@ -From a7266111a5ba2d146c979e86ff84f6b807ca5fdc Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 20 Feb 2015 09:39:38 +0000 -Subject: [PATCH 20/39] Avoid using libdir from .la which usually points to a - host path - -Upstream-Status: Inappropriate [embedded specific] - -Signed-off-by: Jonathan Liu -Signed-off-by: Khem Raj ---- - ltmain.sh | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/ltmain.sh b/ltmain.sh -index 0121fba707f..52bdbdb5f9c 100644 ---- a/ltmain.sh -+++ b/ltmain.sh -@@ -5628,6 +5628,9 @@ func_mode_link () - absdir="$abs_ladir" - libdir="$abs_ladir" - else -+ # Instead of using libdir from .la which usually points to a host path, -+ # use the path the .la is contained in. -+ libdir="$abs_ladir" - dir="$libdir" - absdir="$libdir" - fi --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0021-export-CPP.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0021-export-CPP.patch deleted file mode 100644 index 2e6b4110..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0021-export-CPP.patch +++ /dev/null @@ -1,53 +0,0 @@ -From c8599fc3b5781b319707c9c0f1b0a1ef7cddb027 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 20 Feb 2015 09:40:59 +0000 -Subject: [PATCH 21/39] export CPP - -The OE environment sets and exports CPP as being the target gcc. When -building gcc-cross-canadian for a mingw targetted sdk, the following can be found -in build.x86_64-pokysdk-mingw32.i586-poky-linux/build-x86_64-linux/libiberty/config.log: - -configure:3641: checking for _FILE_OFFSET_BITS value needed for large files -configure:3666: gcc -c -isystem/media/build1/poky/build/tmp/sysroots/x86_64-linux/usr/include -O2 -pipe conftest.c >&5 -configure:3666: $? = 0 -configure:3698: result: no -configure:3786: checking how to run the C preprocessor -configure:3856: result: x86_64-pokysdk-mingw32-gcc -E --sysroot=/media/build1/poky/build/tmp/sysroots/x86_64-nativesdk-mingw32-pokysdk-mingw32 -configure:3876: x86_64-pokysdk-mingw32-gcc -E --sysroot=/media/build1/poky/build/tmp/sysroots/x86_64-nativesdk-mingw32-pokysdk-mingw32 conftest.c -configure:3876: $? = 0 - -Note this is a *build* target (in build-x86_64-linux) so it should be -using the host "gcc", not x86_64-pokysdk-mingw32-gcc. Since the mingw32 -headers are very different, using the wrong cpp is a real problem. It is leaking -into configure through the CPP variable. Ultimately this leads to build -failures related to not being able to include a process.h file for pem-unix.c. - -The fix is to ensure we export a sane CPP value into the build -environment when using build targets. We could define a CPP_FOR_BUILD value which may be -the version which needs to be upstreamed but for now, this fix is good enough to -avoid the problem. - -RP 22/08/2013 - -Upstream-Status: Pending - -Signed-off-by: Khem Raj ---- - Makefile.in | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/Makefile.in b/Makefile.in -index 2bf83b72265..1af45580086 100644 ---- a/Makefile.in -+++ b/Makefile.in -@@ -149,6 +149,7 @@ BUILD_EXPORTS = \ - AR="$(AR_FOR_BUILD)"; export AR; \ - AS="$(AS_FOR_BUILD)"; export AS; \ - CC="$(CC_FOR_BUILD)"; export CC; \ -+ CPP="$(CC_FOR_BUILD) -E"; export CPP; \ - CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \ - CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ - CXX="$(CXX_FOR_BUILD)"; export CXX; \ --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0022-Disable-the-MULTILIB_OSDIRNAMES-and-other-multilib-o.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0022-Disable-the-MULTILIB_OSDIRNAMES-and-other-multilib-o.patch deleted file mode 100644 index 17c581f1..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0022-Disable-the-MULTILIB_OSDIRNAMES-and-other-multilib-o.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 5e2ee46c720b6ce03a18da70dd4e0917c258ab0b Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 20 Feb 2015 10:21:55 +0000 -Subject: [PATCH 22/39] Disable the MULTILIB_OSDIRNAMES and other multilib - options. - -Hard coding the MULTILIB_OSDIRNAMES with ../lib64 is causing problems on -systems where the libdir is NOT set to /lib64. This is allowed by the -ABI, as -long as the dynamic loader is present in /lib. - -We simply want to use the default rules in gcc to find and configure the -normal libdir. - -Upstream-Status: Inappropriate[OE-Specific] - -Signed-off-by: Mark Hatle -Signed-off-by: Khem Raj ---- - gcc/config/aarch64/t-aarch64-linux | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/gcc/config/aarch64/t-aarch64-linux b/gcc/config/aarch64/t-aarch64-linux -index b9897785a89..7d06f0d0edb 100644 ---- a/gcc/config/aarch64/t-aarch64-linux -+++ b/gcc/config/aarch64/t-aarch64-linux -@@ -21,8 +21,8 @@ - LIB1ASMSRC = aarch64/lib1funcs.asm - LIB1ASMFUNCS = _aarch64_sync_cache_range - --AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be) --MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu) --MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu) -+#AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be) -+#MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu) -+#MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu) - --MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32) -+#MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32) --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0024-gcc-4.8-won-t-build-with-disable-dependency-tracking.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0024-gcc-4.8-won-t-build-with-disable-dependency-tracking.patch deleted file mode 100644 index 67b47f4e..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0024-gcc-4.8-won-t-build-with-disable-dependency-tracking.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 57beef69396f6c187014b8e61cdc966218479d07 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 20 Feb 2015 11:17:19 +0000 -Subject: [PATCH 24/39] gcc 4.8+ won't build with --disable-dependency-tracking - -since the *.Ppo files don't get created unless --enable-dependency-tracking is true. - -This patch ensures we only use those compiler options when its enabled. - -Upstream-Status: Submitted - -(Problem was already reported upstream, attached this patch there -http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55930) - -RP -2012/09/22 - -Signed-off-by: Khem Raj ---- - libatomic/Makefile.am | 3 ++- - libatomic/Makefile.in | 3 ++- - 2 files changed, 4 insertions(+), 2 deletions(-) - -diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am -index 803b292cce5..b47842eb590 100644 ---- a/libatomic/Makefile.am -+++ b/libatomic/Makefile.am -@@ -101,7 +101,8 @@ PAT_S = $(word 3,$(PAT_SPLIT)) - IFUNC_DEF = -DIFUNC_ALT=$(PAT_S) - IFUNC_OPT = $(word $(PAT_S),$(IFUNC_OPTIONS)) - --M_DEPS = -MT $@ -MD -MP -MF $(DEPDIR)/$(@F).Ppo -+@AMDEP_TRUE@M_DEPS = -MT $@ -MD -MP -MF $(DEPDIR)/$(@F).Ppo -+@AMDEP_FALSE@M_DEPS = - M_SIZE = -DN=$(PAT_N) - M_IFUNC = $(if $(PAT_S),$(IFUNC_DEF) $(IFUNC_OPT)) - M_FILE = $(PAT_BASE)_n.c -diff --git a/libatomic/Makefile.in b/libatomic/Makefile.in -index c8f38be5835..4fab7cec3ea 100644 ---- a/libatomic/Makefile.in -+++ b/libatomic/Makefile.in -@@ -335,7 +335,8 @@ PAT_N = $(word 2,$(PAT_SPLIT)) - PAT_S = $(word 3,$(PAT_SPLIT)) - IFUNC_DEF = -DIFUNC_ALT=$(PAT_S) - IFUNC_OPT = $(word $(PAT_S),$(IFUNC_OPTIONS)) --M_DEPS = -MT $@ -MD -MP -MF $(DEPDIR)/$(@F).Ppo -+@AMDEP_TRUE@M_DEPS = -MT $@ -MD -MP -MF $(DEPDIR)/$(@F).Ppo -+@AMDEP_FALSE@M_DEPS = - M_SIZE = -DN=$(PAT_N) - M_IFUNC = $(if $(PAT_S),$(IFUNC_DEF) $(IFUNC_OPT)) - M_FILE = $(PAT_BASE)_n.c --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0027-aarch64-Add-support-for-musl-ldso.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0027-aarch64-Add-support-for-musl-ldso.patch deleted file mode 100644 index 9e5ce8a6..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0027-aarch64-Add-support-for-musl-ldso.patch +++ /dev/null @@ -1,28 +0,0 @@ -From a2cc175769fd8255750eaecae64e3d1f9c38d48f Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Tue, 28 Apr 2015 23:18:39 -0700 -Subject: [PATCH 27/39] aarch64: Add support for musl ldso - -Signed-off-by: Khem Raj ---- -Upstream-Status: Pending - - gcc/config/aarch64/aarch64-linux.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h -index 64436183bc8..ba156676026 100644 ---- a/gcc/config/aarch64/aarch64-linux.h -+++ b/gcc/config/aarch64/aarch64-linux.h -@@ -24,7 +24,7 @@ - #define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1" - - #undef MUSL_DYNAMIC_LINKER --#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1" -+#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1" - - #undef ASAN_CC1_SPEC - #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}" --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0029-handle-sysroot-support-for-nativesdk-gcc.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0029-handle-sysroot-support-for-nativesdk-gcc.patch deleted file mode 100644 index 727bb0da..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0029-handle-sysroot-support-for-nativesdk-gcc.patch +++ /dev/null @@ -1,213 +0,0 @@ -From 3bb74495e45e0e798daae5556497e688b8fc4eef Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Mon, 7 Dec 2015 23:39:54 +0000 -Subject: [PATCH 29/39] handle sysroot support for nativesdk-gcc - -Being able to build a nativesdk gcc is useful, particularly in cases -where the host compiler may be of an incompatible version (or a 32 -bit compiler is needed). - -Sadly, building nativesdk-gcc is not straight forward. We install -nativesdk-gcc into a relocatable location and this means that its -library locations can change. "Normal" sysroot support doesn't help -in this case since the values of paths like "libdir" change, not just -base root directory of the system. - -In order to handle this we do two things: - -a) Add %r into spec file markup which can be used for injected paths - such as SYSTEMLIBS_DIR (see gcc_multilib_setup()). -b) Add other paths which need relocation into a .gccrelocprefix section - which the relocation code will notice and adjust automatically. - -Upstream-Status: Inappropriate -RP 2015/7/28 - -Signed-off-by: Khem Raj ---- - gcc/cppdefault.c | 50 +++++++++++++++++++++++++++++++++++------------- - gcc/cppdefault.h | 3 ++- - gcc/gcc.c | 20 +++++++++++++------ - 3 files changed, 53 insertions(+), 20 deletions(-) - -diff --git a/gcc/cppdefault.c b/gcc/cppdefault.c -index e2e187dedaf..2faba2b1d63 100644 ---- a/gcc/cppdefault.c -+++ b/gcc/cppdefault.c -@@ -35,6 +35,30 @@ - # undef CROSS_INCLUDE_DIR - #endif - -+static char GPLUSPLUS_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GPLUSPLUS_INCLUDE_DIR; -+static char GCC_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GCC_INCLUDE_DIR; -+static char GPLUSPLUS_TOOL_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GPLUSPLUS_TOOL_INCLUDE_DIR; -+static char GPLUSPLUS_BACKWARD_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GPLUSPLUS_BACKWARD_INCLUDE_DIR; -+static char STANDARD_STARTFILE_PREFIX_2VAR[4096] __attribute__ ((section (".gccrelocprefix"))) = STANDARD_STARTFILE_PREFIX_2 GCC_INCLUDE_SUBDIR_TARGET; -+#ifdef LOCAL_INCLUDE_DIR -+static char LOCAL_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = LOCAL_INCLUDE_DIR; -+#endif -+#ifdef PREFIX_INCLUDE_DIR -+static char PREFIX_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = PREFIX_INCLUDE_DIR; -+#endif -+#ifdef FIXED_INCLUDE_DIR -+static char FIXED_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = FIXED_INCLUDE_DIR; -+#endif -+#ifdef CROSS_INCLUDE_DIR -+static char CROSS_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = CROSS_INCLUDE_DIR; -+#endif -+#ifdef TOOL_INCLUDE_DIR -+static char TOOL_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = TOOL_INCLUDE_DIR; -+#endif -+#ifdef NATIVE_SYSTEM_HEADER_DIR -+static char NATIVE_SYSTEM_HEADER_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = NATIVE_SYSTEM_HEADER_DIR; -+#endif -+ - const struct default_include cpp_include_defaults[] - #ifdef INCLUDE_DEFAULTS - = INCLUDE_DEFAULTS; -@@ -42,38 +66,38 @@ const struct default_include cpp_include_defaults[] - = { - #ifdef GPLUSPLUS_INCLUDE_DIR - /* Pick up GNU C++ generic include files. */ -- { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, -+ { GPLUSPLUS_INCLUDE_DIRVAR, "G++", 1, 1, - GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, - #endif - #ifdef GPLUSPLUS_TOOL_INCLUDE_DIR - /* Pick up GNU C++ target-dependent include files. */ -- { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, -+ { GPLUSPLUS_TOOL_INCLUDE_DIRVAR, "G++", 1, 1, - GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, - #endif - #ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR - /* Pick up GNU C++ backward and deprecated include files. */ -- { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, -+ { GPLUSPLUS_BACKWARD_INCLUDE_DIRVAR, "G++", 1, 1, - GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, - #endif - #ifdef GCC_INCLUDE_DIR - /* This is the dir for gcc's private headers. */ -- { GCC_INCLUDE_DIR, "GCC", 0, 0, 0, 0 }, -+ { GCC_INCLUDE_DIRVAR, "GCC", 0, 0, 0, 0 }, - #endif - #ifdef GCC_INCLUDE_SUBDIR_TARGET - /* This is the dir for gcc's private headers under the specified sysroot. */ -- { STANDARD_STARTFILE_PREFIX_2 GCC_INCLUDE_SUBDIR_TARGET, "GCC", 0, 0, 1, 0 }, -+ { STANDARD_STARTFILE_PREFIX_2VAR, "GCC", 0, 0, 1, 0 }, - #endif - #ifdef LOCAL_INCLUDE_DIR - /* /usr/local/include comes before the fixincluded header files. */ -- { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, -- { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 }, -+ { LOCAL_INCLUDE_DIRVAR, 0, 0, 1, 1, 2 }, -+ { LOCAL_INCLUDE_DIRVAR, 0, 0, 1, 1, 0 }, - #endif - #ifdef PREFIX_INCLUDE_DIR -- { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0 }, -+ { PREFIX_INCLUDE_DIRVAR, 0, 0, 1, 0, 0 }, - #endif - #ifdef FIXED_INCLUDE_DIR - /* This is the dir for fixincludes. */ -- { FIXED_INCLUDE_DIR, "GCC", 0, 0, 0, -+ { FIXED_INCLUDE_DIRVAR, "GCC", 0, 0, 0, - /* A multilib suffix needs adding if different multilibs use - different headers. */ - #ifdef SYSROOT_HEADERS_SUFFIX_SPEC -@@ -85,16 +109,16 @@ const struct default_include cpp_include_defaults[] - #endif - #ifdef CROSS_INCLUDE_DIR - /* One place the target system's headers might be. */ -- { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0 }, -+ { CROSS_INCLUDE_DIRVAR, "GCC", 0, 0, 0, 0 }, - #endif - #ifdef TOOL_INCLUDE_DIR - /* Another place the target system's headers might be. */ -- { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0 }, -+ { TOOL_INCLUDE_DIRVAR, "BINUTILS", 0, 1, 0, 0 }, - #endif - #ifdef NATIVE_SYSTEM_HEADER_DIR - /* /usr/include comes dead last. */ -- { NATIVE_SYSTEM_HEADER_DIR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 2 }, -- { NATIVE_SYSTEM_HEADER_DIR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 0 }, -+ { NATIVE_SYSTEM_HEADER_DIRVAR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 2 }, -+ { NATIVE_SYSTEM_HEADER_DIRVAR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 0 }, - #endif - { 0, 0, 0, 0, 0, 0 } - }; -diff --git a/gcc/cppdefault.h b/gcc/cppdefault.h -index 4a0186d1cf2..29e5d9da0dc 100644 ---- a/gcc/cppdefault.h -+++ b/gcc/cppdefault.h -@@ -33,7 +33,8 @@ - - struct default_include - { -- const char *const fname; /* The name of the directory. */ -+ const char *fname; /* The name of the directory. */ -+ - const char *const component; /* The component containing the directory - (see update_path in prefix.c) */ - const char cplusplus; /* Only look here if we're compiling C++. */ -diff --git a/gcc/gcc.c b/gcc/gcc.c -index 3fb64d453f1..cd0c7fbe961 100644 ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -248,6 +248,8 @@ FILE *report_times_to_file = NULL; - #endif - static const char *target_system_root = DEFAULT_TARGET_SYSTEM_ROOT; - -+static char target_relocatable_prefix[4096] __attribute__ ((section (".gccrelocprefix"))) = SYSTEMLIBS_DIR; -+ - /* Nonzero means pass the updated target_system_root to the compiler. */ - - static int target_system_root_changed; -@@ -519,6 +521,7 @@ or with constant text in a single argument. - %G process LIBGCC_SPEC as a spec. - %R Output the concatenation of target_system_root and - target_sysroot_suffix. -+ %r Output the base path target_relocatable_prefix - %S process STARTFILE_SPEC as a spec. A capital S is actually used here. - %E process ENDFILE_SPEC as a spec. A capital E is actually used here. - %C process CPP_SPEC as a spec. -@@ -1487,10 +1490,10 @@ static const char *gcc_libexec_prefix; - gcc_exec_prefix is set because, in that case, we know where the - compiler has been installed, and use paths relative to that - location instead. */ --static const char *const standard_exec_prefix = STANDARD_EXEC_PREFIX; --static const char *const standard_libexec_prefix = STANDARD_LIBEXEC_PREFIX; --static const char *const standard_bindir_prefix = STANDARD_BINDIR_PREFIX; --static const char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX; -+static char standard_exec_prefix[4096] __attribute__ ((section (".gccrelocprefix"))) = STANDARD_EXEC_PREFIX; -+static char standard_libexec_prefix[4096] __attribute__ ((section (".gccrelocprefix"))) = STANDARD_LIBEXEC_PREFIX; -+static char standard_bindir_prefix[4096] __attribute__ ((section (".gccrelocprefix"))) = STANDARD_BINDIR_PREFIX; -+static char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX; - - /* For native compilers, these are well-known paths containing - components that may be provided by the system. For cross -@@ -1498,9 +1501,9 @@ static const char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX; - static const char *md_exec_prefix = MD_EXEC_PREFIX; - static const char *md_startfile_prefix = MD_STARTFILE_PREFIX; - static const char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1; --static const char *const standard_startfile_prefix_1 -+static char standard_startfile_prefix_1[4096] __attribute__ ((section (".gccrelocprefix"))) - = STANDARD_STARTFILE_PREFIX_1; --static const char *const standard_startfile_prefix_2 -+static char standard_startfile_prefix_2[4096] __attribute__ ((section (".gccrelocprefix"))) - = STANDARD_STARTFILE_PREFIX_2; - - /* A relative path to be used in finding the location of tools -@@ -5849,6 +5852,11 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) - } - break; - -+ case 'r': -+ obstack_grow (&obstack, target_relocatable_prefix, -+ strlen (target_relocatable_prefix)); -+ break; -+ - case 'S': - value = do_spec_1 (startfile_spec, 0, NULL); - if (value != 0) --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0031-Fix-various-_FOR_BUILD-and-related-variables.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0031-Fix-various-_FOR_BUILD-and-related-variables.patch deleted file mode 100644 index dabc0059..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0031-Fix-various-_FOR_BUILD-and-related-variables.patch +++ /dev/null @@ -1,137 +0,0 @@ -From 93b4e1d3a0f8417118d1c48fcd1ce51996e1420b Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Mon, 7 Dec 2015 23:42:45 +0000 -Subject: [PATCH 31/39] Fix various _FOR_BUILD and related variables - -When doing a FOR_BUILD thing, you have to override CFLAGS with -CFLAGS_FOR_BUILD. And if you use C++, you also have to override -CXXFLAGS with CXXFLAGS_FOR_BUILD. -Without this, when building for mingw, you end up trying to use -the mingw headers for a host build. - -The same goes for other variables as well, such as CPPFLAGS, -CPP, and GMPINC. - -Upstream-Status: Pending - -Signed-off-by: Peter Seebach -Signed-off-by: Mark Hatle -Signed-off-by: Khem Raj ---- - Makefile.in | 6 ++++++ - Makefile.tpl | 5 +++++ - gcc/Makefile.in | 2 +- - gcc/configure | 2 +- - gcc/configure.ac | 2 +- - 5 files changed, 14 insertions(+), 3 deletions(-) - -diff --git a/Makefile.in b/Makefile.in -index 1af45580086..8966453c32c 100644 ---- a/Makefile.in -+++ b/Makefile.in -@@ -152,6 +152,7 @@ BUILD_EXPORTS = \ - CPP="$(CC_FOR_BUILD) -E"; export CPP; \ - CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \ - CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ -+ CPPFLAGS="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS; \ - CXX="$(CXX_FOR_BUILD)"; export CXX; \ - CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \ - GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \ -@@ -169,6 +170,9 @@ BUILD_EXPORTS = \ - # built for the build system to override those in BASE_FLAGS_TO_PASS. - EXTRA_BUILD_FLAGS = \ - CFLAGS="$(CFLAGS_FOR_BUILD)" \ -+ CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \ -+ CPP="$(CC_FOR_BUILD) -E" \ -+ CPPFLAGS="$(CPPFLAGS_FOR_BUILD)" \ - LDFLAGS="$(LDFLAGS_FOR_BUILD)" - - # This is the list of directories to built for the host system. -@@ -186,6 +190,7 @@ HOST_SUBDIR = @host_subdir@ - HOST_EXPORTS = \ - $(BASE_EXPORTS) \ - CC="$(CC)"; export CC; \ -+ CPP="$(CC) -E"; export CPP; \ - ADA_CFLAGS="$(ADA_CFLAGS)"; export ADA_CFLAGS; \ - CFLAGS="$(CFLAGS)"; export CFLAGS; \ - CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ -@@ -753,6 +758,7 @@ BASE_FLAGS_TO_PASS = \ - "CC_FOR_BUILD=$(CC_FOR_BUILD)" \ - "CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \ - "CXX_FOR_BUILD=$(CXX_FOR_BUILD)" \ -+ "CXXFLAGS_FOR_BUILD=$(CXXFLAGS_FOR_BUILD)" \ - "EXPECT=$(EXPECT)" \ - "FLEX=$(FLEX)" \ - "INSTALL=$(INSTALL)" \ -diff --git a/Makefile.tpl b/Makefile.tpl -index abd2bc2fb89..5822b260404 100644 ---- a/Makefile.tpl -+++ b/Makefile.tpl -@@ -154,6 +154,7 @@ BUILD_EXPORTS = \ - CC="$(CC_FOR_BUILD)"; export CC; \ - CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \ - CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ -+ CPPFLAGS="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS; \ - CXX="$(CXX_FOR_BUILD)"; export CXX; \ - CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \ - GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \ -@@ -171,6 +172,9 @@ BUILD_EXPORTS = \ - # built for the build system to override those in BASE_FLAGS_TO_PASS. - EXTRA_BUILD_FLAGS = \ - CFLAGS="$(CFLAGS_FOR_BUILD)" \ -+ CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \ -+ CPP="$(CC_FOR_BUILD) -E" \ -+ CPPFLAGS="$(CPPFLAGS_FOR_BUILD)" \ - LDFLAGS="$(LDFLAGS_FOR_BUILD)" - - # This is the list of directories to built for the host system. -@@ -188,6 +192,7 @@ HOST_SUBDIR = @host_subdir@ - HOST_EXPORTS = \ - $(BASE_EXPORTS) \ - CC="$(CC)"; export CC; \ -+ CPP="$(CC) -E"; export CPP; \ - ADA_CFLAGS="$(ADA_CFLAGS)"; export ADA_CFLAGS; \ - CFLAGS="$(CFLAGS)"; export CFLAGS; \ - CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ -diff --git a/gcc/Makefile.in b/gcc/Makefile.in -index 5ae693fb06c..02ee0aa72f4 100644 ---- a/gcc/Makefile.in -+++ b/gcc/Makefile.in -@@ -801,7 +801,7 @@ BUILD_LDFLAGS=@BUILD_LDFLAGS@ - BUILD_NO_PIE_FLAG = @BUILD_NO_PIE_FLAG@ - BUILD_LDFLAGS += $(BUILD_NO_PIE_FLAG) - BUILD_CPPFLAGS= -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \ -- -I$(srcdir)/../include @INCINTL@ $(CPPINC) $(CPPFLAGS) -+ -I$(srcdir)/../include @INCINTL@ $(CPPINC) $(CPPFLAGS_FOR_BUILD) - - # Actual name to use when installing a native compiler. - GCC_INSTALL_NAME := $(shell echo gcc|sed '$(program_transform_name)') -diff --git a/gcc/configure b/gcc/configure -index cfcadc93a01..2f6b4f72ef3 100755 ---- a/gcc/configure -+++ b/gcc/configure -@@ -11797,7 +11797,7 @@ else - CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \ - CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \ - LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \ -- GMPINC="" CPPFLAGS="${CPPFLAGS} -DGENERATOR_FILE" \ -+ GMPINC="" CPPFLAGS="${CPPFLAGS_FOR_BUILD} -DGENERATOR_FILE" \ - ${realsrcdir}/configure \ - --enable-languages=${enable_languages-all} \ - --target=$target_alias --host=$build_alias --build=$build_alias -diff --git a/gcc/configure.ac b/gcc/configure.ac -index 44b90478f55..9f8a51fc9bd 100644 ---- a/gcc/configure.ac -+++ b/gcc/configure.ac -@@ -1708,7 +1708,7 @@ else - CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \ - CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \ - LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \ -- GMPINC="" CPPFLAGS="${CPPFLAGS} -DGENERATOR_FILE" \ -+ GMPINC="" CPPFLAGS="${CPPFLAGS_FOR_BUILD} -DGENERATOR_FILE" \ - ${realsrcdir}/configure \ - --enable-languages=${enable_languages-all} \ - --target=$target_alias --host=$build_alias --build=$build_alias --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0032-nios2-Define-MUSL_DYNAMIC_LINKER.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0032-nios2-Define-MUSL_DYNAMIC_LINKER.patch deleted file mode 100644 index 6dd9d542..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0032-nios2-Define-MUSL_DYNAMIC_LINKER.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 99f3e3b427996ac579d95e68440a0bd7af7ef0fc Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Tue, 2 Feb 2016 10:26:10 -0800 -Subject: [PATCH 32/39] nios2: Define MUSL_DYNAMIC_LINKER - -Signed-off-by: Marek Vasut -Signed-off-by: Khem Raj ---- -Upstream-Status: Pending - - gcc/config/nios2/linux.h | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/gcc/config/nios2/linux.h b/gcc/config/nios2/linux.h -index 4729105626d..36181eb7b85 100644 ---- a/gcc/config/nios2/linux.h -+++ b/gcc/config/nios2/linux.h -@@ -30,6 +30,7 @@ - #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" - - #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-nios2.so.1" -+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-nios2.so.1" - - #undef LINK_SPEC - #define LINK_SPEC LINK_SPEC_ENDIAN \ --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0033-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0033-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch deleted file mode 100644 index 05a6b0a1..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0033-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch +++ /dev/null @@ -1,87 +0,0 @@ -From 84b55ab2f68710a583d4ec810ea8b3b68576f8aa Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Tue, 27 Jun 2017 18:10:54 -0700 -Subject: [PATCH 33/39] Add ssp_nonshared to link commandline for musl targets - -when -fstack-protector options are enabled we need to -link with ssp_shared on musl since it does not provide -the __stack_chk_fail_local() so essentially it provides -libssp but not libssp_nonshared something like -TARGET_LIBC_PROVIDES_SSP_BUT_NOT_SSP_NONSHARED - where-as for glibc the needed symbols -are already present in libc_nonshared library therefore -we do not need any library helper on glibc based systems -but musl needs the libssp_noshared from gcc - -Upstream-Status: Pending - -Signed-off-by: Khem Raj ---- - gcc/config/linux.h | 7 +++++++ - gcc/config/rs6000/linux.h | 10 ++++++++++ - gcc/config/rs6000/linux64.h | 10 ++++++++++ - 3 files changed, 27 insertions(+) - -diff --git a/gcc/config/linux.h b/gcc/config/linux.h -index 487b0c0923b..4769d089538 100644 ---- a/gcc/config/linux.h -+++ b/gcc/config/linux.h -@@ -182,6 +182,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see - { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \ - { 0, 0, 0, 0, 0, 0 } \ - } -+#ifdef TARGET_LIBC_PROVIDES_SSP -+#undef LINK_SSP_SPEC -+#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ -+ "|fstack-protector-strong|fstack-protector-explicit" \ -+ ":-lssp_nonshared}" -+#endif -+ - #endif - - #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */ -diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h -index 01b40c762f6..e7c5e92215c 100644 ---- a/gcc/config/rs6000/linux.h -+++ b/gcc/config/rs6000/linux.h -@@ -92,6 +92,16 @@ - " -m elf32ppclinux") - #endif - -+/* link libssp_nonshared.a with musl */ -+#if DEFAULT_LIBC == LIBC_MUSL -+#ifdef TARGET_LIBC_PROVIDES_SSP -+#undef LINK_SSP_SPEC -+#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ -+ "|fstack-protector-strong|fstack-protector-explicit" \ -+ ":-lssp_nonshared}" -+#endif -+#endif -+ - #undef LINK_OS_LINUX_SPEC - #define LINK_OS_LINUX_SPEC LINK_OS_LINUX_EMUL " %{!shared: %{!static: \ - %{!static-pie: \ -diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h -index 55695dadd91..60f1ee24985 100644 ---- a/gcc/config/rs6000/linux64.h -+++ b/gcc/config/rs6000/linux64.h -@@ -473,6 +473,16 @@ extern int dot_symbols; - " -m elf64ppc") - #endif - -+/* link libssp_nonshared.a with musl */ -+#if DEFAULT_LIBC == LIBC_MUSL -+#ifdef TARGET_LIBC_PROVIDES_SSP -+#undef LINK_SSP_SPEC -+#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ -+ "|fstack-protector-strong|fstack-protector-explicit" \ -+ ":-lssp_nonshared}" -+#endif -+#endif -+ - #define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " %{!shared: %{!static: \ - %{!static-pie: \ - %{rdynamic:-export-dynamic} \ --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0034-libgcc-Add-knob-to-use-ldbl-128-on-ppc.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0034-libgcc-Add-knob-to-use-ldbl-128-on-ppc.patch deleted file mode 100644 index 391cda71..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0034-libgcc-Add-knob-to-use-ldbl-128-on-ppc.patch +++ /dev/null @@ -1,465 +0,0 @@ -From faf35e26740461fe1a1da5433d5a0169a663e3b5 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 29 Apr 2016 20:03:28 +0000 -Subject: [PATCH 34/39] libgcc: Add knob to use ldbl-128 on ppc - -musl does not support ldbl 128 so we can not assume -that linux as a whole supports ldbl-128 bits, instead -act upon configure option passed to gcc and assume no -on musl and yes otherwise if no option is passed since -default behaviour is to assume ldbl128 it does not -change the defaults - -Signed-off-by: Khem Raj ---- -Upstream-Status: Pending - - libgcc/Makefile.in | 1 + - libgcc/config/rs6000/t-linux | 5 ++++- - libgcc/configure | 18 ++++++++++++++++++ - libgcc/configure.ac | 12 ++++++++++++ - 4 files changed, 35 insertions(+), 1 deletion(-) - mode change 100644 => 100755 libgcc/configure - -diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in -index dd8cee99fd3..b5f478af382 100644 ---- a/libgcc/Makefile.in -+++ b/libgcc/Makefile.in -@@ -48,6 +48,7 @@ unwind_header = @unwind_header@ - md_unwind_header = @md_unwind_header@ - sfp_machine_header = @sfp_machine_header@ - thread_header = @thread_header@ -+with_ldbl128 = @with_ldbl128@ - - host_noncanonical = @host_noncanonical@ - real_host_noncanonical = @real_host_noncanonical@ -diff --git a/libgcc/config/rs6000/t-linux b/libgcc/config/rs6000/t-linux -index 4f6d4c4a4d2..c50dd94a2da 100644 ---- a/libgcc/config/rs6000/t-linux -+++ b/libgcc/config/rs6000/t-linux -@@ -1,3 +1,9 @@ - SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-glibc.ver - --HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-minimal-toc -+ifeq ($(with_ldbl128),yes) -+HOST_LIBGCC2_CFLAGS += -mlong-double-128 -+else -+# We do not want to build ibm-ldouble.c. -+LIB2ADD := $(filter-out %ibm-ldouble.c, $(LIB2ADD)) -+endif -+HOST_LIBGCC2_CFLAGS += -mno-minimal-toc -diff --git a/libgcc/config/rs6000/fixtfdi.c b/libgcc/config/rs6000/fixtfdi.c ---- a/libgcc/config/rs6000/fixtfdi.c 1969-12-31 19:00:00.000000000 -0500 -+++ b/libgcc/config/rs6000/fixtfdi.c 2018-12-12 17:54:50.110755540 -0500 -@@ -0,0 +1,42 @@ -+/* Software floating-point emulation. -+ Convert a to 64bit signed integer -+ Copyright (C) 1997-2016 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ Contributed by Richard Henderson (rth@cygnus.com) and -+ Jakub Jelinek (jj@ultra.linux.cz). -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ In addition to the permissions in the GNU Lesser General Public -+ License, the Free Software Foundation gives you unlimited -+ permission to link the compiled version of this file into -+ combinations with other programs, and to distribute those -+ combinations without any restriction coming from the use of this -+ file. (The Lesser General Public License restrictions do apply in -+ other respects; for example, they cover modification of the file, -+ and distribution when not linked into a combine executable.) -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ . */ -+ -+#ifdef _ARCH_PPC64 -+#include "soft-fp.h" -+#include "quad-float128.h" -+ -+DItype -+__fixtfdi (TFtype a) -+{ -+ if (a < 0) -+ return - __fixunstfdi (-a); -+ return __fixunstfdi (a); -+} -+#endif -diff --git a/libgcc/config/rs6000/fixunstfdi.c b/libgcc/config/rs6000/fixunstfdi.c ---- a/libgcc/config/rs6000/fixunstfdi.c 1969-12-31 19:00:00.000000000 -0500 -+++ b/libgcc/config/rs6000/fixunstfdi.c 2018-12-12 17:56:06.141654537 -0500 -@@ -0,0 +1,58 @@ -+/* Software floating-point emulation. -+ Convert a to 64bit unsigned integer -+ Copyright (C) 1997-2016 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ Contributed by Richard Henderson (rth@cygnus.com) and -+ Jakub Jelinek (jj@ultra.linux.cz). -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ In addition to the permissions in the GNU Lesser General Public -+ License, the Free Software Foundation gives you unlimited -+ permission to link the compiled version of this file into -+ combinations with other programs, and to distribute those -+ combinations without any restriction coming from the use of this -+ file. (The Lesser General Public License restrictions do apply in -+ other respects; for example, they cover modification of the file, -+ and distribution when not linked into a combine executable.) -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ . */ -+ -+#ifdef _ARCH_PPC64 -+#include "soft-fp.h" -+#include "quad-float128.h" -+ -+DItype -+__fixunstfdi (TFtype a) -+{ -+ if (a < 0) -+ return 0; -+ -+ /* Compute high word of result, as a flonum. */ -+ const TFtype b = (a / (((UDItype) 1) << (sizeof (SItype) * 8))); -+ /* Convert that to fixed (but not to DItype!), -+ and shift it into the high word. */ -+ UDItype v = (USItype) b; -+ v <<= (sizeof (SItype) * 8); -+ /* Remove high part from the TFtype, leaving the low part as flonum. */ -+ a -= (TFtype) v; -+ /* Convert that to fixed (but not to DItype!) and add it in. -+ Sometimes A comes out negative. This is significant, since -+ A has more bits than a long int does. */ -+ if (a < 0) -+ v -= (USItype) (-a); -+ else -+ v += (USItype) a; -+ return v; -+} -+#endif -diff --git a/libgcc/config/rs6000/floatditf.c b/libgcc/config/rs6000/floatditf.c ---- a/libgcc/config/rs6000/floatditf.c 1969-12-31 19:00:00.000000000 -0500 -+++ b/libgcc/config/rs6000/floatditf.c 2018-12-12 17:57:55.852953553 -0500 -@@ -0,0 +1,47 @@ -+/* Software floating-point emulation. -+ Convert a 64bit signed integer to IEEE quad -+ Copyright (C) 1997-2016 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ Contributed by Richard Henderson (rth@cygnus.com) and -+ Jakub Jelinek (jj@ultra.linux.cz). -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ In addition to the permissions in the GNU Lesser General Public -+ License, the Free Software Foundation gives you unlimited -+ permission to link the compiled version of this file into -+ combinations with other programs, and to distribute those -+ combinations without any restriction coming from the use of this -+ file. (The Lesser General Public License restrictions do apply in -+ other respects; for example, they cover modification of the file, -+ and distribution when not linked into a combine executable.) -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ . */ -+ -+#ifdef _ARCH_PPC64 -+#include "soft-fp.h" -+#include "double.h" -+#include "quad-float128.h" -+ -+TFtype -+__floatditf (DItype u) -+{ -+ DFtype dh, dl; -+ -+ dh = (SItype) (u >> (sizeof (SItype) * 8)); -+ dh *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1)); -+ dl = (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1)); -+ -+ return (TFtype) dh + (TFtype) dl; -+} -+#endif -diff --git a/libgcc/config/rs6000/floatunditf.c b/libgcc/config/rs6000/floatunditf.c ---- a/libgcc/config/rs6000/floatunditf.c 1969-12-31 19:00:00.000000000 -0500 -+++ b/libgcc/config/rs6000/floatunditf.c 2018-12-12 17:57:15.262473574 -0500 -@@ -0,0 +1,47 @@ -+/* Software floating-point emulation. -+ Convert a 64bit unsigned integer to IEEE quad -+ Copyright (C) 1997-2016 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ Contributed by Richard Henderson (rth@cygnus.com) and -+ Jakub Jelinek (jj@ultra.linux.cz). -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ In addition to the permissions in the GNU Lesser General Public -+ License, the Free Software Foundation gives you unlimited -+ permission to link the compiled version of this file into -+ combinations with other programs, and to distribute those -+ combinations without any restriction coming from the use of this -+ file. (The Lesser General Public License restrictions do apply in -+ other respects; for example, they cover modification of the file, -+ and distribution when not linked into a combine executable.) -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ . */ -+ -+#ifdef _ARCH_PPC64 -+#include "soft-fp.h" -+#include "double.h" -+#include "quad-float128.h" -+ -+TFtype -+__floatunditf (UDItype u) -+{ -+ DFtype dh, dl; -+ -+ dh = (USItype) (u >> (sizeof (SItype) * 8)); -+ dh *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1)); -+ dl = (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1)); -+ -+ return (TFtype) dh + (TFtype) dl; -+} -+#endif -diff --git a/libgcc/config/rs6000/ppc64-fp.c b/libgcc/config/rs6000/ppc64-fp.c ---- a/libgcc/config/rs6000/ppc64-fp.c 2018-12-12 17:53:49.540038500 -0500 -+++ b/libgcc/config/rs6000/ppc64-fp.c 2018-12-12 17:49:51.897235314 -0500 -@@ -25,34 +25,21 @@ - . */ - - #if defined(__powerpc64__) || defined (__64BIT__) || defined(__ppc64__) --#define TMODES - #include "fp-bit.h" - --extern DItype __fixtfdi (TFtype); - extern DItype __fixdfdi (DFtype); - extern DItype __fixsfdi (SFtype); - extern USItype __fixunsdfsi (DFtype); - extern USItype __fixunssfsi (SFtype); --extern TFtype __floatditf (DItype); --extern TFtype __floatunditf (UDItype); - extern DFtype __floatdidf (DItype); - extern DFtype __floatundidf (UDItype); - extern SFtype __floatdisf (DItype); - extern SFtype __floatundisf (UDItype); --extern DItype __fixunstfdi (TFtype); - - static DItype local_fixunssfdi (SFtype); - static DItype local_fixunsdfdi (DFtype); - - DItype --__fixtfdi (TFtype a) --{ -- if (a < 0) -- return - __fixunstfdi (-a); -- return __fixunstfdi (a); --} -- --DItype - __fixdfdi (DFtype a) - { - if (a < 0) -@@ -86,30 +73,6 @@ - return (SItype) a; - } - --TFtype --__floatditf (DItype u) --{ -- DFtype dh, dl; -- -- dh = (SItype) (u >> (sizeof (SItype) * 8)); -- dh *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1)); -- dl = (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1)); -- -- return (TFtype) dh + (TFtype) dl; --} -- --TFtype --__floatunditf (UDItype u) --{ -- DFtype dh, dl; -- -- dh = (USItype) (u >> (sizeof (SItype) * 8)); -- dh *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1)); -- dl = (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1)); -- -- return (TFtype) dh + (TFtype) dl; --} -- - DFtype - __floatdidf (DItype u) - { -@@ -183,30 +146,6 @@ - return (SFtype) f; - } - --DItype --__fixunstfdi (TFtype a) --{ -- if (a < 0) -- return 0; -- -- /* Compute high word of result, as a flonum. */ -- const TFtype b = (a / (((UDItype) 1) << (sizeof (SItype) * 8))); -- /* Convert that to fixed (but not to DItype!), -- and shift it into the high word. */ -- UDItype v = (USItype) b; -- v <<= (sizeof (SItype) * 8); -- /* Remove high part from the TFtype, leaving the low part as flonum. */ -- a -= (TFtype) v; -- /* Convert that to fixed (but not to DItype!) and add it in. -- Sometimes A comes out negative. This is significant, since -- A has more bits than a long int does. */ -- if (a < 0) -- v -= (USItype) (-a); -- else -- v += (USItype) a; -- return v; --} -- - /* This version is needed to prevent recursion; fixunsdfdi in libgcc - calls fixdfdi, which in turn calls calls fixunsdfdi. */ - -diff --git a/libgcc/config/rs6000/quad-float128.h b/libgcc/config/rs6000/quad-float128.h ---- a/libgcc/config/rs6000/quad-float128.h 2018-12-12 17:53:49.540038500 -0500 -+++ b/libgcc/config/rs6000/quad-float128.h 2018-12-12 17:30:19.423468244 -0500 -@@ -104,6 +104,11 @@ - extern UTItype_ppc __fixunskfti (TFtype); - extern TFtype __floattikf (TItype_ppc); - extern TFtype __floatuntikf (UTItype_ppc); -+ -+extern DItype_ppc __fixtfdi (TFtype); -+extern DItype_ppc __fixunstfdi (TFtype); -+extern TFtype __floatditf (DItype_ppc); -+extern TFtype __floatunditf (UDItype_ppc); - #endif - - /* Functions using the ISA 3.0 hardware support. If the code is compiled with -diff --git a/libgcc/config/rs6000/t-float128 b/libgcc/config/rs6000/t-float128 ---- a/libgcc/config/rs6000/t-float128 2018-12-12 17:53:49.540038500 -0500 -+++ b/libgcc/config/rs6000/t-float128 2018-12-12 17:45:12.233937136 -0500 -@@ -24,6 +24,7 @@ - - # New functions for software emulation - fp128_ppc_funcs = floattikf floatuntikf fixkfti fixunskfti \ -+ floatditf floatunditf fixtfdi fixunstfdi \ - extendkftf2-sw trunctfkf2-sw \ - sfp-exceptions _mulkc3 _divkc3 _powikf2 - - -diff --git a/libgcc/configure b/libgcc/configure -old mode 100644 -new mode 100755 -index b2f3f870844..ed806587c17 ---- a/libgcc/configure -+++ b/libgcc/configure -@@ -619,6 +619,7 @@ build_vendor - build_cpu - build - with_aix_soname -+with_ldbl128 - enable_vtable_verify - enable_shared - libgcc_topdir -@@ -668,6 +669,7 @@ with_cross_host - with_ld - enable_shared - enable_vtable_verify -+with_long_double_128 - with_aix_soname - enable_version_specific_runtime_libs - with_slibdir -@@ -1329,6 +1331,7 @@ Optional Packages: - --with-target-subdir=SUBDIR Configuring in a subdirectory for target - --with-cross-host=HOST Configuring with a cross compiler - --with-ld arrange to use the specified ld (full pathname) -+ --with-long-double-128 use 128-bit long double by default - --with-aix-soname=aix|svr4|both - shared library versioning (aka "SONAME") variant to - provide on AIX -@@ -2213,6 +2216,21 @@ fi - - - -+# Check whether --with-long-double-128 was given. -+if test "${with_long_double_128+set}" = set; then : -+ withval=$with_long_double_128; with_ldbl128="$with_long_double_128" -+else -+ case "${host}" in -+ power*-*-musl*) -+ with_ldbl128="no";; -+ *) with_ldbl128="yes";; -+ esac -+ -+fi -+ -+ -+ -+ - # Check whether --with-aix-soname was given. - if test "${with_aix_soname+set}" = set; then : - withval=$with_aix_soname; case "${host}:${enable_shared}" in -diff --git a/libgcc/configure.ac b/libgcc/configure.ac -index b59aa746afc..42220a263c5 100644 ---- a/libgcc/configure.ac -+++ b/libgcc/configure.ac -@@ -78,6 +78,18 @@ AC_ARG_ENABLE(vtable-verify, - [enable_vtable_verify=no]) - AC_SUBST(enable_vtable_verify) - -+AC_ARG_WITH(long-double-128, -+[AS_HELP_STRING([--with-long-double-128], -+ [use 128-bit long double by default])], -+ with_ldbl128="$with_long_double_128", -+[case "${host}" in -+ power*-*-musl*) -+ with_ldbl128="no";; -+ *) with_ldbl128="yes";; -+ esac -+]) -+AC_SUBST(with_ldbl128) -+ - AC_ARG_WITH(aix-soname, - [AS_HELP_STRING([--with-aix-soname=aix|svr4|both], - [shared library versioning (aka "SONAME") variant to provide on AIX])], --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0036-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0036-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch deleted file mode 100644 index 8def33a1..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0036-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch +++ /dev/null @@ -1,86 +0,0 @@ -From b7faeed60261d7b75f2db3823926de1650ef64bc Mon Sep 17 00:00:00 2001 -From: Szabolcs Nagy -Date: Sat, 24 Oct 2015 20:09:53 +0000 -Subject: [PATCH 36/39] libgcc_s: Use alias for __cpu_indicator_init instead of - symver - -Adapter from - -https://gcc.gnu.org/ml/gcc-patches/2015-05/msg00899.html - -This fix was debated but hasnt been applied gcc upstream since -they expect musl to support '@' in symbol versioning which is -a sun/gnu versioning extention. This patch however avoids the -need for the '@' symbols at all - -libgcc/Changelog: - -2015-05-11 Szabolcs Nagy - - * config/i386/cpuinfo.c (__cpu_indicator_init_local): Add. - (__cpu_indicator_init@GCC_4.8.0, __cpu_model@GCC_4.8.0): Remove. - - * config/i386/t-linux (HOST_LIBGCC2_CFLAGS): Remove -DUSE_ELF_SYMVER. - -gcc/Changelog: - -2015-05-11 Szabolcs Nagy - - * config/i386/i386.c (ix86_expand_builtin): Make __builtin_cpu_init - call __cpu_indicator_init_local instead of __cpu_indicator_init. - -Signed-off-by: Khem Raj ---- -Upstream-Status: Pending - - gcc/config/i386/i386.c | 4 ++-- - libgcc/config/i386/cpuinfo.c | 6 +++--- - libgcc/config/i386/t-linux | 2 +- - 3 files changed, 6 insertions(+), 6 deletions(-) - -diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c -index 6a2141e48db..455fccbdd50 100644 ---- a/gcc/config/i386/i386.c -+++ b/gcc/config/i386/i386.c -@@ -36490,10 +36490,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget, - { - case IX86_BUILTIN_CPU_INIT: - { -- /* Make it call __cpu_indicator_init in libgcc. */ -+ /* Make it call __cpu_indicator_init_local in libgcc.a. */ - tree call_expr, fndecl, type; - type = build_function_type_list (integer_type_node, NULL_TREE); -- fndecl = build_fn_decl ("__cpu_indicator_init", type); -+ fndecl = build_fn_decl ("__cpu_indicator_init_local", type); - call_expr = build_call_expr (fndecl, 0); - return expand_expr (call_expr, target, mode, EXPAND_NORMAL); - } -diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c -index 86953db2743..e0476272810 100644 ---- a/libgcc/config/i386/cpuinfo.c -+++ b/libgcc/config/i386/cpuinfo.c -@@ -482,7 +482,7 @@ __cpu_indicator_init (void) - return 0; - } - --#if defined SHARED && defined USE_ELF_SYMVER --__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0"); --__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0"); -+#ifndef SHARED -+int __cpu_indicator_init_local (void) -+ __attribute__ ((weak, alias ("__cpu_indicator_init"))); - #endif -diff --git a/libgcc/config/i386/t-linux b/libgcc/config/i386/t-linux -index 8506a635790..564296f788e 100644 ---- a/libgcc/config/i386/t-linux -+++ b/libgcc/config/i386/t-linux -@@ -3,5 +3,5 @@ - # t-slibgcc-elf-ver and t-linux - SHLIB_MAPFILES = libgcc-std.ver $(srcdir)/config/i386/libgcc-glibc.ver - --HOST_LIBGCC2_CFLAGS += -mlong-double-80 -DUSE_ELF_SYMVER $(CET_FLAGS) -+HOST_LIBGCC2_CFLAGS += -mlong-double-80 $(CET_FLAGS) - CRTSTUFF_T_CFLAGS += $(CET_FLAGS) --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0038-fix-segmentation-fault-in-precompiled-header-generat.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0038-fix-segmentation-fault-in-precompiled-header-generat.patch deleted file mode 100644 index 224d2ae6..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0038-fix-segmentation-fault-in-precompiled-header-generat.patch +++ /dev/null @@ -1,60 +0,0 @@ -From 00694849632dee23741925c6104df134f6bff747 Mon Sep 17 00:00:00 2001 -From: Juro Bystricky -Date: Mon, 19 Mar 2018 22:31:20 -0700 -Subject: [PATCH 38/39] fix segmentation fault in precompiled header generation - -Prevent a segmentation fault which occurs when using incorrect -structure trying to access name of some named operators, such as -CPP_NOT, CPP_AND etc. "token->val.node.spelling" cannot be used in -those cases, as is may not be initialized at all. - -[YOCTO #11738] - -Upstream-Status: Pending - -Signed-off-by: Juro Bystricky -Signed-off-by: Khem Raj ---- - libcpp/lex.c | 26 +++++++++++++++++++++----- - 1 file changed, 21 insertions(+), 5 deletions(-) - -diff --git a/libcpp/lex.c b/libcpp/lex.c -index 37c365a3560..63480048db6 100644 ---- a/libcpp/lex.c -+++ b/libcpp/lex.c -@@ -3279,11 +3279,27 @@ cpp_spell_token (cpp_reader *pfile, const cpp_token *token, - spell_ident: - case SPELL_IDENT: - if (forstring) -- { -- memcpy (buffer, NODE_NAME (token->val.node.spelling), -- NODE_LEN (token->val.node.spelling)); -- buffer += NODE_LEN (token->val.node.spelling); -- } -+ { -+ if (token->type == CPP_NAME) -+ { -+ memcpy (buffer, NODE_NAME (token->val.node.spelling), -+ NODE_LEN (token->val.node.spelling)); -+ buffer += NODE_LEN (token->val.node.spelling); -+ break; -+ } -+ /* NAMED_OP, cannot use node.spelling */ -+ if (token->flags & NAMED_OP) -+ { -+ const char *str = cpp_named_operator2name (token->type); -+ if (str) -+ { -+ size_t len = strlen(str); -+ memcpy(buffer, str, len); -+ buffer += len; -+ } -+ break; -+ } -+ } - else - buffer = _cpp_spell_ident_ucns (buffer, token->val.node.node); - break; --- -2.17.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0041-ARC-fix-spec-gen.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0041-ARC-fix-spec-gen.patch deleted file mode 100644 index cbd5e41a..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0041-ARC-fix-spec-gen.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 892142379c6b99fe8c3ebdfe0b79e2a435228c1d Mon Sep 17 00:00:00 2001 -From: claziss -Date: Mon, 17 Sep 2018 08:52:10 +0000 -Subject: [PATCH] [ARC] Update LINK_EH_SPEC linker spec. - -With no trailing space in LINK_EH_SPEC linker spec gets generated as: ------------------------->8--------------------- -%{!r:--build-id} --eh-frame-hdr%{h*} ... ------------------------->8--------------------- - -or even worse if hash style is added: ------------------------->8--------------------- -%{!r:--build-id} --eh-frame-hdr--hash-style=sysv %{h*} ... ------------------------->8--------------------- - -Now if that spec is really used by LD then it fails inevitably -saying that it doesn't know option "--eh-frame-hdr--hash-style=sysv". - -2018-09-17 Alexey Brodkin - - * config/arc/linux.h (LINK_EH_SPEC): Add missing space. - -git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@264361 138bc75d-0d04-0410-961f-82ee72b054a4 - -Signed-off-by: Alexey Brodkin - -Upstream-Status: Backport[https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=892142379c6b] ---- - gcc/config/arc/linux.h | 2 +- - 1 files changed, 1 insertions(+), 1 deletion(-) - -diff --git a/gcc/config/arc/linux.h b/gcc/config/arc/linux.h -index 96d548eae341..62ebe4de0fc7 100644 ---- a/gcc/config/arc/linux.h -+++ b/gcc/config/arc/linux.h -@@ -98,7 +98,7 @@ along with GCC; see the file COPYING3. If not see - Signalize that because we have fde-glibc, we don't need all C shared libs - linked against -lgcc_s. */ - #undef LINK_EH_SPEC --#define LINK_EH_SPEC "--eh-frame-hdr" -+#define LINK_EH_SPEC "--eh-frame-hdr " - #endif - - #undef SUBTARGET_CPP_SPEC diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0042-powerpc-powerpc64-Add-support-for-musl-ldso.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0042-powerpc-powerpc64-Add-support-for-musl-ldso.patch deleted file mode 100644 index b0c735bb..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0042-powerpc-powerpc64-Add-support-for-musl-ldso.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 3f5f5da776be86b408a15f38c9782f2185f97073 Mon Sep 17 00:00:00 2001 -From: Serhey Popovych -Date: Tue, 11 Dec 2018 02:30:50 -0500 -Subject: [PATCH] powerpc/powerpc64: Add support for musl ldso - -Signed-off-by: Serhey Popovych ---- -Upstream-Status: Inappropriate [OE-Specific] - - gcc/config/rs6000/linux64.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h -index 619e113..ee8b44f 100644 ---- a/gcc/config/rs6000/linux64.h -+++ b/gcc/config/rs6000/linux64.h -@@ -421,9 +421,9 @@ extern int dot_symbols; - #endif - - #define MUSL_DYNAMIC_LINKER32 \ -- "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" -+ SYSTEMLIBS_DIR "ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" - #define MUSL_DYNAMIC_LINKER64 \ -- "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" -+ SYSTEMLIBS_DIR "ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" - - #define UCLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-uClibc.so.0" - #define UCLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld64-uClibc.so.0" --- -2.7.4 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0043-riscv-Disable-multilib-for-OE.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0043-riscv-Disable-multilib-for-OE.patch deleted file mode 100644 index dc28d1bf..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.2/0043-riscv-Disable-multilib-for-OE.patch +++ /dev/null @@ -1,27 +0,0 @@ -From ca0a6e035eef0cdbd0ef3a222c75d4b9f873c512 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 28 Dec 2018 09:59:53 -0800 -Subject: [PATCH 39/39] riscv: Disable multilib for OE - -Upstream-Status: Inappropriate [OE-Specific] - -Signed-off-by: Khem Raj ---- - gcc/config/riscv/t-linux | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/gcc/config/riscv/t-linux b/gcc/config/riscv/t-linux -index 216d2776a18..e4d817621fc 100644 ---- a/gcc/config/riscv/t-linux -+++ b/gcc/config/riscv/t-linux -@@ -1,3 +1,5 @@ - # Only XLEN and ABI affect Linux multilib dir names, e.g. /lib32/ilp32d/ --MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES))) --MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES)) -+#MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES))) -+MULTILIB_DIRNAMES := . . -+#MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES)) -+MULTILIB_OSDIRNAMES := ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) --- -2.20.1 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3.inc b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3.inc deleted file mode 100644 index 3fb87bb5..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3.inc +++ /dev/null @@ -1,114 +0,0 @@ -require recipes-devtools/gcc/gcc-common.inc - -BASEPV = "8.3" -PV = "arm-${BASEPV}" -CVE_VERSION = "${BASEPV}" - -MMYY = "19.03" -RELEASE = "20${MMYY}" -PR = "r${RELEASE}" -BINV = "${BASEPV}.0" - -FILESEXTRAPATHS =. "${FILE_DIRNAME}/gcc-${BASEPV}:${FILE_DIRNAME}/gcc-${BASEPV}/backport:" - -DEPENDS =+ "mpfr gmp libmpc zlib flex-native" -NATIVEDEPS = "mpfr-native gmp-native libmpc-native zlib-native flex-native" - -LICENSE = "GPL-3.0-with-GCC-exception & GPLv3" - -LIC_FILES_CHKSUM = "\ - file://COPYING;md5=59530bdf33659b29e73d4adb9f9f6552 \ - file://COPYING3;md5=d32239bcb673463ab874e80d47fae504 \ - file://COPYING3.LIB;md5=6a6a8e020838b23406c81b19c1d46df6 \ - file://COPYING.LIB;md5=2d5025d4aa3495befef8f17206a5b0a1 \ - file://COPYING.RUNTIME;md5=fe60d87048567d4fe8c8a0ed2448bcc8 \ -" - -#BASEURI ?= "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.bz2" -SRCREV = "47335befa47297ab810945cece69c466417a95c1" -BASEURI ?= "git://git.linaro.org/toolchain/gcc.git;protocol=https;branch=linaro-local/ARM/arm-8-branch" - -SRC_URI = "\ - ${BASEURI} \ - file://0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch \ - file://0002-gcc-poison-system-directories.patch \ - file://0003-gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch \ - file://0004-64-bit-multilib-hack.patch \ - file://0005-optional-libstdc.patch \ - file://0006-gcc-disable-MASK_RELAX_PIC_CALLS-bit.patch \ - file://0007-COLLECT_GCC_OPTIONS.patch \ - file://0008-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch \ - file://0009-fortran-cross-compile-hack.patch \ - file://0010-cpp-honor-sysroot.patch \ - file://0011-MIPS64-Default-to-N64-ABI.patch \ - file://0012-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch \ - file://0013-gcc-Fix-argument-list-too-long-error.patch \ - file://0014-Disable-sdt.patch \ - file://0015-libtool.patch \ - file://0016-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch \ - file://0017-Use-the-multilib-config-files-from-B-instead-of-usin.patch \ - file://0018-Avoid-using-libdir-from-.la-which-usually-points-to-.patch \ - file://0019-export-CPP.patch \ - file://0020-Disable-the-MULTILIB_OSDIRNAMES-and-other-multilib-o.patch \ - file://0021-Ensure-target-gcc-headers-can-be-included.patch \ - file://0022-gcc-4.8-won-t-build-with-disable-dependency-tracking.patch \ - file://0023-Don-t-search-host-directory-during-relink-if-inst_pr.patch \ - file://0024-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch \ - file://0025-aarch64-Add-support-for-musl-ldso.patch \ - file://0026-libcc1-fix-libcc1-s-install-path-and-rpath.patch \ - file://0027-handle-sysroot-support-for-nativesdk-gcc.patch \ - file://0028-Search-target-sysroot-gcc-version-specific-dirs-with.patch \ - file://0029-Fix-various-_FOR_BUILD-and-related-variables.patch \ - file://0030-nios2-Define-MUSL_DYNAMIC_LINKER.patch \ - file://0031-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch \ - file://0032-libgcc-Add-knob-to-use-ldbl-128-on-ppc.patch \ - file://0033-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch \ - file://0034-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch \ - file://0035-sync-gcc-stddef.h-with-musl.patch \ - file://0036-fix-segmentation-fault-in-precompiled-header-generat.patch \ - file://0037-Fix-for-testsuite-failure.patch \ - file://0038-Re-introduce-spe-commandline-options.patch \ - file://0039-riscv-Disable-multilib-for-OE.patch \ - file://0040-powerpc-powerpc64-Add-support-for-musl-ldso.patch \ - ${BACKPORTS} \ -" -BACKPORTS = "\ -" - -S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/git" -#S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/gcc-${PV}" -#S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/git" -#S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/gcc-${RELEASE}" -B = "${WORKDIR}/gcc-${PV}/build.${HOST_SYS}.${TARGET_SYS}" - -# Language Overrides -FORTRAN = "" -JAVA = "" - -LTO = "--enable-lto" -SSP ?= "--disable-libssp" -SSP_mingw32 = "--enable-libssp" - -EXTRA_OECONF_BASE = "\ - ${LTO} \ - ${SSP} \ - --enable-libitm \ - --disable-bootstrap \ - --disable-libmudflap \ - --with-system-zlib \ - ${@'--with-linker-hash-style=${LINKER_HASH_STYLE}' if '${LINKER_HASH_STYLE}' else ''} \ - --enable-linker-build-id \ - --with-ppl=no \ - --with-cloog=no \ - --enable-checking=release \ - --enable-cheaders=c_global \ - --without-isl \ -" - -EXTRA_OECONF_append_aarchilp32 = " --with-abi=ilp32" - -EXTRA_OECONF_PATHS = "\ - --with-gxx-include-dir=/not/exist{target_includedir}/c++/${BINV} \ - --with-sysroot=/not/exist \ - --with-build-sysroot=${STAGING_DIR_TARGET} \ -" diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0006-gcc-disable-MASK_RELAX_PIC_CALLS-bit.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0006-gcc-disable-MASK_RELAX_PIC_CALLS-bit.patch deleted file mode 100644 index 0cea228c..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0006-gcc-disable-MASK_RELAX_PIC_CALLS-bit.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 1dba090a11c40b0926f9707a543d658c95e1f156 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 29 Mar 2013 09:14:20 +0400 -Subject: [PATCH 06/40] gcc: disable MASK_RELAX_PIC_CALLS bit - -The new feature added after 4.3.3 -"http://www.pubbs.net/200909/gcc/94048-patch-add-support-for-rmipsjalr.html" -will cause cc1plus eat up all the system memory when build webkit-gtk. -The function mips_get_pic_call_symbol keeps on recursively calling itself. -Disable this feature to walk aside the bug. - -Signed-off-by: Dongxiao Xu -Signed-off-by: Khem Raj - -Upstream-Status: Inappropriate [configuration] ---- - gcc/configure | 7 ------- - gcc/configure.ac | 7 ------- - 2 files changed, 14 deletions(-) - -diff --git a/gcc/configure b/gcc/configure -index 3901722400c..0c9b8ac5f55 100755 ---- a/gcc/configure -+++ b/gcc/configure -@@ -27553,13 +27553,6 @@ $as_echo_n "checking assembler and linker for explicit JALR relocation... " >&6; - rm -f conftest.* - fi - fi -- if test $gcc_cv_as_ld_jalr_reloc = yes; then -- if test x$target_cpu_default = x; then -- target_cpu_default=MASK_RELAX_PIC_CALLS -- else -- target_cpu_default="($target_cpu_default)|MASK_RELAX_PIC_CALLS" -- fi -- fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_ld_jalr_reloc" >&5 - $as_echo "$gcc_cv_as_ld_jalr_reloc" >&6; } - -diff --git a/gcc/configure.ac b/gcc/configure.ac -index 1b1362f70fe..53840363115 100644 ---- a/gcc/configure.ac -+++ b/gcc/configure.ac -@@ -4798,13 +4798,6 @@ x: - rm -f conftest.* - fi - fi -- if test $gcc_cv_as_ld_jalr_reloc = yes; then -- if test x$target_cpu_default = x; then -- target_cpu_default=MASK_RELAX_PIC_CALLS -- else -- target_cpu_default="($target_cpu_default)|MASK_RELAX_PIC_CALLS" -- fi -- fi - AC_MSG_RESULT($gcc_cv_as_ld_jalr_reloc) - - AC_CACHE_CHECK([linker for .eh_frame personality relaxation], --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0009-fortran-cross-compile-hack.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0009-fortran-cross-compile-hack.patch deleted file mode 100644 index 50d895bf..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0009-fortran-cross-compile-hack.patch +++ /dev/null @@ -1,46 +0,0 @@ -From e654573352d28f160f379ee77e4067cf108714d0 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 29 Mar 2013 09:20:01 +0400 -Subject: [PATCH 09/40] fortran cross-compile hack. - -* Fortran would have searched for arm-angstrom-gnueabi-gfortran but would have used -used gfortan. For gcc_4.2.2.bb we want to use the gfortran compiler from our cross -directory. - -Signed-off-by: Khem Raj - -Upstream-Status: Inappropriate [embedded specific] ---- - libgfortran/configure | 2 +- - libgfortran/configure.ac | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/libgfortran/configure b/libgfortran/configure -index 91fce8fecd0..6747f86eb98 100755 ---- a/libgfortran/configure -+++ b/libgfortran/configure -@@ -12883,7 +12883,7 @@ esac - - # We need gfortran to compile parts of the library - #AC_PROG_FC(gfortran) --FC="$GFORTRAN" -+#FC="$GFORTRAN" - ac_ext=${ac_fc_srcext-f} - ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5' - ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5' -diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac -index bf6d3634dda..9dbe43cc616 100644 ---- a/libgfortran/configure.ac -+++ b/libgfortran/configure.ac -@@ -250,7 +250,7 @@ AC_SUBST(enable_static) - - # We need gfortran to compile parts of the library - #AC_PROG_FC(gfortran) --FC="$GFORTRAN" -+#FC="$GFORTRAN" - AC_PROG_FC(gfortran) - - # extra LD Flags which are required for targets --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0013-gcc-Fix-argument-list-too-long-error.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0013-gcc-Fix-argument-list-too-long-error.patch deleted file mode 100644 index e9d2cac2..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0013-gcc-Fix-argument-list-too-long-error.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 9e815965fbaa90134be0e777cfc2fbcfab16b674 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 29 Mar 2013 09:26:37 +0400 -Subject: [PATCH 13/40] gcc: Fix argument list too long error. - -There would be an "Argument list too long" error when the -build directory is longer than 200, this is caused by: - -headers=`echo $(PLUGIN_HEADERS) | tr ' ' '\012' | sort -u` - -The PLUGIN_HEADERS is too long before sort, so the "echo" can't handle -it, use the $(sort list) of GNU make which can handle the too long list -would fix the problem, the header would be short enough after sorted. -The "tr ' ' '\012'" was used for translating the space to "\n", the -$(sort list) doesn't need this. - -Signed-off-by: Robert Yang -Signed-off-by: Khem Raj - -Upstream-Status: Pending ---- - gcc/Makefile.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/gcc/Makefile.in b/gcc/Makefile.in -index 1367136bfac..71a8275c39f 100644 ---- a/gcc/Makefile.in -+++ b/gcc/Makefile.in -@@ -3538,7 +3538,7 @@ install-plugin: installdirs lang.install-plugin s-header-vars install-gengtype - # We keep the directory structure for files in config or c-family and .def - # files. All other files are flattened to a single directory. - $(mkinstalldirs) $(DESTDIR)$(plugin_includedir) -- headers=`echo $(PLUGIN_HEADERS) $$(cd $(srcdir); echo *.h *.def) | tr ' ' '\012' | sort -u`; \ -+ headers="$(sort $(PLUGIN_HEADERS) $$(cd $(srcdir); echo *.h *.def))"; \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`; \ - for file in $$headers; do \ - if [ -f $$file ] ; then \ --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0014-Disable-sdt.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0014-Disable-sdt.patch deleted file mode 100644 index 2bc44515..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0014-Disable-sdt.patch +++ /dev/null @@ -1,113 +0,0 @@ -From 00c7a7fdd4b4aad9e57d8b541de17ad209b6cd06 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 29 Mar 2013 09:28:10 +0400 -Subject: [PATCH 14/40] Disable sdt. - -We don't list dtrace in DEPENDS so we shouldn't be depending on this header. -It may or may not exist from preivous builds though. To be determinstic, disable -sdt.h usage always. This avoids build failures if the header is removed after configure -but before libgcc is compiled for example. - -RP 2012/8/7 - -Signed-off-by: Khem Raj - -Disable sdt for libstdc++-v3. - -Signed-off-by: Robert Yang - -Upstream-Status: Inappropriate [hack] ---- - gcc/configure | 12 ++++++------ - gcc/configure.ac | 18 +++++++++--------- - libstdc++-v3/configure | 6 +++--- - libstdc++-v3/configure.ac | 2 +- - 4 files changed, 19 insertions(+), 19 deletions(-) - -diff --git a/gcc/configure b/gcc/configure -index 134c2c2f156..5111ec0aabb 100755 ---- a/gcc/configure -+++ b/gcc/configure -@@ -29282,12 +29282,12 @@ fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking sys/sdt.h in the target C library" >&5 - $as_echo_n "checking sys/sdt.h in the target C library... " >&6; } - have_sys_sdt_h=no --if test -f $target_header_dir/sys/sdt.h; then -- have_sys_sdt_h=yes -- --$as_echo "#define HAVE_SYS_SDT_H 1" >>confdefs.h -- --fi -+#if test -f $target_header_dir/sys/sdt.h; then -+# have_sys_sdt_h=yes -+# -+#$as_echo "#define HAVE_SYS_SDT_H 1" >>confdefs.h -+# -+#fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_sys_sdt_h" >&5 - $as_echo "$have_sys_sdt_h" >&6; } - -diff --git a/gcc/configure.ac b/gcc/configure.ac -index 0c3c82e4ff7..3e09af916fd 100644 ---- a/gcc/configure.ac -+++ b/gcc/configure.ac -@@ -5943,15 +5943,15 @@ fi - AC_SUBST([enable_default_ssp]) - - # Test for on the target. --GCC_TARGET_TEMPLATE([HAVE_SYS_SDT_H]) --AC_MSG_CHECKING(sys/sdt.h in the target C library) --have_sys_sdt_h=no --if test -f $target_header_dir/sys/sdt.h; then -- have_sys_sdt_h=yes -- AC_DEFINE(HAVE_SYS_SDT_H, 1, -- [Define if your target C library provides sys/sdt.h]) --fi --AC_MSG_RESULT($have_sys_sdt_h) -+#GCC_TARGET_TEMPLATE([HAVE_SYS_SDT_H]) -+#AC_MSG_CHECKING(sys/sdt.h in the target C library) -+#have_sys_sdt_h=no -+#if test -f $target_header_dir/sys/sdt.h; then -+# have_sys_sdt_h=yes -+# AC_DEFINE(HAVE_SYS_SDT_H, 1, -+# [Define if your target C library provides sys/sdt.h]) -+#fi -+#AC_MSG_RESULT($have_sys_sdt_h) - - # Check if TFmode long double should be used by default or not. - # Some glibc targets used DFmode long double, but with glibc 2.4 -diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure -index 5535bfa2b5a..13d793f5059 100755 ---- a/libstdc++-v3/configure -+++ b/libstdc++-v3/configure -@@ -21786,11 +21786,11 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' - ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' - ac_compiler_gnu=$ac_cv_c_compiler_gnu - -- if test $glibcxx_cv_sys_sdt_h = yes; then -+# if test $glibcxx_cv_sys_sdt_h = yes; then - --$as_echo "#define HAVE_SYS_SDT_H 1" >>confdefs.h -+#$as_echo "#define HAVE_SYS_SDT_H 1" >>confdefs.h - -- fi -+# fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_sys_sdt_h" >&5 - $as_echo "$glibcxx_cv_sys_sdt_h" >&6; } - -diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac -index 0ef96270c9c..afe55a1b215 100644 ---- a/libstdc++-v3/configure.ac -+++ b/libstdc++-v3/configure.ac -@@ -230,7 +230,7 @@ GLIBCXX_CHECK_SC_NPROCESSORS_ONLN - GLIBCXX_CHECK_SC_NPROC_ONLN - GLIBCXX_CHECK_PTHREADS_NUM_PROCESSORS_NP - GLIBCXX_CHECK_SYSCTL_HW_NCPU --GLIBCXX_CHECK_SDT_H -+#GLIBCXX_CHECK_SDT_H - - # Check for available headers. - AC_CHECK_HEADERS([endian.h execinfo.h float.h fp.h ieeefp.h inttypes.h \ --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0016-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0016-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch deleted file mode 100644 index 9b1b4d4d..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0016-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch +++ /dev/null @@ -1,43 +0,0 @@ -From a66ec1e382bf869749588f072a4a7c09039f2b3a Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 29 Mar 2013 09:30:32 +0400 -Subject: [PATCH 16/40] gcc: armv4: pass fix-v4bx to linker to support EABI. - -The LINK_SPEC for linux gets overwritten by linux-eabi.h which -means the value of TARGET_FIX_V4BX_SPEC gets lost and as a result -the option is not passed to linker when chosing march=armv4 -This patch redefines this in linux-eabi.h and reinserts it -for eabi defaulting toolchains. - -We might want to send it upstream. - -Signed-off-by: Khem Raj - -Upstream-Status: Pending ---- - gcc/config/arm/linux-eabi.h | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h -index b3af68cac57..330b6e13c5f 100644 ---- a/gcc/config/arm/linux-eabi.h -+++ b/gcc/config/arm/linux-eabi.h -@@ -88,10 +88,14 @@ - #define MUSL_DYNAMIC_LINKER \ - "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}.so.1" - -+/* For armv4 we pass --fix-v4bx to linker to support EABI */ -+#undef TARGET_FIX_V4BX_SPEC -+#define TARGET_FIX_V4BX_SPEC "%{mcpu=arm8|mcpu=arm810|mcpu=strongarm*|march=armv4: --fix-v4bx}" -+ - /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to - use the GNU/Linux version, not the generic BPABI version. */ - #undef LINK_SPEC --#define LINK_SPEC EABI_LINK_SPEC \ -+#define LINK_SPEC TARGET_FIX_V4BX_SPEC EABI_LINK_SPEC \ - LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC, \ - LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC) - --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0017-Use-the-multilib-config-files-from-B-instead-of-usin.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0017-Use-the-multilib-config-files-from-B-instead-of-usin.patch deleted file mode 100644 index 382fecdb..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0017-Use-the-multilib-config-files-from-B-instead-of-usin.patch +++ /dev/null @@ -1,102 +0,0 @@ -From 624db734f656ad8cdf8b3cf3fc8e860b70c6c251 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 29 Mar 2013 09:33:04 +0400 -Subject: [PATCH 17/40] Use the multilib config files from ${B} instead of - using the ones from ${S} - -Use the multilib config files from ${B} instead of using the ones from ${S} -so that the source can be shared between gcc-cross-initial, -gcc-cross-intermediate, gcc-cross, gcc-runtime, and also the sdk build. - -Signed-off-by: Khem Raj -Signed-off-by: Constantin Musca - -Upstream-Status: Inappropriate [configuration] ---- - gcc/configure | 22 ++++++++++++++++++---- - gcc/configure.ac | 22 ++++++++++++++++++---- - 2 files changed, 36 insertions(+), 8 deletions(-) - -diff --git a/gcc/configure b/gcc/configure -index 5111ec0aabb..3d9dcbdc93d 100755 ---- a/gcc/configure -+++ b/gcc/configure -@@ -12138,10 +12138,20 @@ done - tmake_file_= - for f in ${tmake_file} - do -- if test -f ${srcdir}/config/$f -- then -- tmake_file_="${tmake_file_} \$(srcdir)/config/$f" -- fi -+ case $f in -+ */t-linux64 ) -+ if test -f ./config/$f -+ then -+ tmake_file_="${tmake_file_} ./config/$f" -+ fi -+ ;; -+ * ) -+ if test -f ${srcdir}/config/$f -+ then -+ tmake_file_="${tmake_file_} \$(srcdir)/config/$f" -+ fi -+ ;; -+ esac - done - tmake_file="${tmake_file_}" - -@@ -12152,6 +12162,10 @@ tm_file_list="options.h" - tm_include_list="options.h insn-constants.h" - for f in $tm_file; do - case $f in -+ */linux64.h ) -+ tm_file_list="${tm_file_list} ./config/$f" -+ tm_include_list="${tm_include_list} ./config/$f" -+ ;; - ./* ) - f=`echo $f | sed 's/^..//'` - tm_file_list="${tm_file_list} $f" -diff --git a/gcc/configure.ac b/gcc/configure.ac -index 3e09af916fd..e09c840b605 100644 ---- a/gcc/configure.ac -+++ b/gcc/configure.ac -@@ -1902,10 +1902,20 @@ done - tmake_file_= - for f in ${tmake_file} - do -- if test -f ${srcdir}/config/$f -- then -- tmake_file_="${tmake_file_} \$(srcdir)/config/$f" -- fi -+ case $f in -+ */t-linux64 ) -+ if test -f ./config/$f -+ then -+ tmake_file_="${tmake_file_} ./config/$f" -+ fi -+ ;; -+ * ) -+ if test -f ${srcdir}/config/$f -+ then -+ tmake_file_="${tmake_file_} \$(srcdir)/config/$f" -+ fi -+ ;; -+ esac - done - tmake_file="${tmake_file_}" - -@@ -1916,6 +1926,10 @@ tm_file_list="options.h" - tm_include_list="options.h insn-constants.h" - for f in $tm_file; do - case $f in -+ */linux64.h ) -+ tm_file_list="${tm_file_list} ./config/$f" -+ tm_include_list="${tm_include_list} ./config/$f" -+ ;; - ./* ) - f=`echo $f | sed 's/^..//'` - tm_file_list="${tm_file_list} $f" --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0020-Disable-the-MULTILIB_OSDIRNAMES-and-other-multilib-o.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0020-Disable-the-MULTILIB_OSDIRNAMES-and-other-multilib-o.patch deleted file mode 100644 index b22557ea..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0020-Disable-the-MULTILIB_OSDIRNAMES-and-other-multilib-o.patch +++ /dev/null @@ -1,42 +0,0 @@ -From d4326ab74a362b0fc83ed866f82c359389a36adc Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 20 Feb 2015 10:21:55 +0000 -Subject: [PATCH 20/40] Disable the MULTILIB_OSDIRNAMES and other multilib - options. - -Hard coding the MULTILIB_OSDIRNAMES with ../lib64 is causing problems on -systems where the libdir is NOT set to /lib64. This is allowed by the -ABI, as -long as the dynamic loader is present in /lib. - -We simply want to use the default rules in gcc to find and configure the -normal libdir. - -Upstream-Status: Inappropriate[OE-Specific] - -Signed-off-by: Mark Hatle -Signed-off-by: Khem Raj ---- - gcc/config/aarch64/t-aarch64-linux | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/gcc/config/aarch64/t-aarch64-linux b/gcc/config/aarch64/t-aarch64-linux -index b9897785a89..7d06f0d0edb 100644 ---- a/gcc/config/aarch64/t-aarch64-linux -+++ b/gcc/config/aarch64/t-aarch64-linux -@@ -21,8 +21,8 @@ - LIB1ASMSRC = aarch64/lib1funcs.asm - LIB1ASMFUNCS = _aarch64_sync_cache_range - --AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be) --MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu) --MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu) -+#AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be) -+#MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu) -+#MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu) - --MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32) -+#MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32) --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0021-Ensure-target-gcc-headers-can-be-included.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0021-Ensure-target-gcc-headers-can-be-included.patch deleted file mode 100644 index 60d72699..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0021-Ensure-target-gcc-headers-can-be-included.patch +++ /dev/null @@ -1,98 +0,0 @@ -From 476eda9054df443d094273c8b61fce63d940adfc Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 20 Feb 2015 10:25:11 +0000 -Subject: [PATCH 21/40] Ensure target gcc headers can be included - -There are a few headers installed as part of the OpenEmbedded -gcc-runtime target (omp.h, ssp/*.h). Being installed from a recipe -built for the target architecture, these are within the target -sysroot and not cross/nativesdk; thus they weren't able to be -found by gcc with the existing search paths. Add support for -picking up these headers under the sysroot supplied on the gcc -command line in order to resolve this. - -Upstream-Status: Pending - -Signed-off-by: Paul Eggleton -Signed-off-by: Khem Raj ---- - gcc/Makefile.in | 2 ++ - gcc/cppdefault.c | 4 ++++ - gcc/defaults.h | 9 +++++++++ - gcc/gcc.c | 7 ------- - 4 files changed, 15 insertions(+), 7 deletions(-) - -diff --git a/gcc/Makefile.in b/gcc/Makefile.in -index 71a8275c39f..5ae693fb06c 100644 ---- a/gcc/Makefile.in -+++ b/gcc/Makefile.in -@@ -614,6 +614,7 @@ libexecdir = @libexecdir@ - - # Directory in which the compiler finds libraries etc. - libsubdir = $(libdir)/gcc/$(real_target_noncanonical)/$(version)$(accel_dir_suffix) -+libsubdir_target = gcc/$(target_noncanonical)/$(version) - # Directory in which the compiler finds executables - libexecsubdir = $(libexecdir)/gcc/$(real_target_noncanonical)/$(version)$(accel_dir_suffix) - # Directory in which all plugin resources are installed -@@ -2870,6 +2871,7 @@ CFLAGS-intl.o += -DLOCALEDIR=\"$(localedir)\" - - PREPROCESSOR_DEFINES = \ - -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \ -+ -DGCC_INCLUDE_SUBDIR_TARGET=\"$(libsubdir_target)/include\" \ - -DFIXED_INCLUDE_DIR=\"$(libsubdir)/include-fixed\" \ - -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \ - -DGPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT=$(gcc_gxx_include_dir_add_sysroot) \ -diff --git a/gcc/cppdefault.c b/gcc/cppdefault.c -index b36a979d5ba..e2e187dedaf 100644 ---- a/gcc/cppdefault.c -+++ b/gcc/cppdefault.c -@@ -59,6 +59,10 @@ const struct default_include cpp_include_defaults[] - /* This is the dir for gcc's private headers. */ - { GCC_INCLUDE_DIR, "GCC", 0, 0, 0, 0 }, - #endif -+#ifdef GCC_INCLUDE_SUBDIR_TARGET -+ /* This is the dir for gcc's private headers under the specified sysroot. */ -+ { STANDARD_STARTFILE_PREFIX_2 GCC_INCLUDE_SUBDIR_TARGET, "GCC", 0, 0, 1, 0 }, -+#endif - #ifdef LOCAL_INCLUDE_DIR - /* /usr/local/include comes before the fixincluded header files. */ - { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, -diff --git a/gcc/defaults.h b/gcc/defaults.h -index 9035b333be8..5982bbda61d 100644 ---- a/gcc/defaults.h -+++ b/gcc/defaults.h -@@ -1455,4 +1455,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see - #define DWARF_GNAT_ENCODINGS_DEFAULT DWARF_GNAT_ENCODINGS_GDB - #endif - -+/* Default prefixes to attach to command names. */ -+ -+#ifndef STANDARD_STARTFILE_PREFIX_1 -+#define STANDARD_STARTFILE_PREFIX_1 "/lib/" -+#endif -+#ifndef STANDARD_STARTFILE_PREFIX_2 -+#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/" -+#endif -+ - #endif /* ! GCC_DEFAULTS_H */ -diff --git a/gcc/gcc.c b/gcc/gcc.c -index 570cdc00034..3fb64d453f1 100644 ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -1464,13 +1464,6 @@ static const char *gcc_libexec_prefix; - - /* Default prefixes to attach to command names. */ - --#ifndef STANDARD_STARTFILE_PREFIX_1 --#define STANDARD_STARTFILE_PREFIX_1 "/lib/" --#endif --#ifndef STANDARD_STARTFILE_PREFIX_2 --#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/" --#endif -- - #ifdef CROSS_DIRECTORY_STRUCTURE /* Don't use these prefixes for a cross compiler. */ - #undef MD_EXEC_PREFIX - #undef MD_STARTFILE_PREFIX --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0022-gcc-4.8-won-t-build-with-disable-dependency-tracking.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0022-gcc-4.8-won-t-build-with-disable-dependency-tracking.patch deleted file mode 100644 index 6f0d3f11..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0022-gcc-4.8-won-t-build-with-disable-dependency-tracking.patch +++ /dev/null @@ -1,54 +0,0 @@ -From bc192f0a07ad819dee93446c5ef6895d9550d92d Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 20 Feb 2015 11:17:19 +0000 -Subject: [PATCH 22/40] gcc 4.8+ won't build with --disable-dependency-tracking - -since the *.Ppo files don't get created unless --enable-dependency-tracking is true. - -This patch ensures we only use those compiler options when its enabled. - -Upstream-Status: Submitted - -(Problem was already reported upstream, attached this patch there -http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55930) - -RP -2012/09/22 - -Signed-off-by: Khem Raj ---- - libatomic/Makefile.am | 3 ++- - libatomic/Makefile.in | 3 ++- - 2 files changed, 4 insertions(+), 2 deletions(-) - -diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am -index 803b292cce5..b47842eb590 100644 ---- a/libatomic/Makefile.am -+++ b/libatomic/Makefile.am -@@ -101,7 +101,8 @@ PAT_S = $(word 3,$(PAT_SPLIT)) - IFUNC_DEF = -DIFUNC_ALT=$(PAT_S) - IFUNC_OPT = $(word $(PAT_S),$(IFUNC_OPTIONS)) - --M_DEPS = -MT $@ -MD -MP -MF $(DEPDIR)/$(@F).Ppo -+@AMDEP_TRUE@M_DEPS = -MT $@ -MD -MP -MF $(DEPDIR)/$(@F).Ppo -+@AMDEP_FALSE@M_DEPS = - M_SIZE = -DN=$(PAT_N) - M_IFUNC = $(if $(PAT_S),$(IFUNC_DEF) $(IFUNC_OPT)) - M_FILE = $(PAT_BASE)_n.c -diff --git a/libatomic/Makefile.in b/libatomic/Makefile.in -index c8f38be5835..4fab7cec3ea 100644 ---- a/libatomic/Makefile.in -+++ b/libatomic/Makefile.in -@@ -335,7 +335,8 @@ PAT_N = $(word 2,$(PAT_SPLIT)) - PAT_S = $(word 3,$(PAT_SPLIT)) - IFUNC_DEF = -DIFUNC_ALT=$(PAT_S) - IFUNC_OPT = $(word $(PAT_S),$(IFUNC_OPTIONS)) --M_DEPS = -MT $@ -MD -MP -MF $(DEPDIR)/$(@F).Ppo -+@AMDEP_TRUE@M_DEPS = -MT $@ -MD -MP -MF $(DEPDIR)/$(@F).Ppo -+@AMDEP_FALSE@M_DEPS = - M_SIZE = -DN=$(PAT_N) - M_IFUNC = $(if $(PAT_S),$(IFUNC_DEF) $(IFUNC_OPT)) - M_FILE = $(PAT_BASE)_n.c --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0023-Don-t-search-host-directory-during-relink-if-inst_pr.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0023-Don-t-search-host-directory-during-relink-if-inst_pr.patch deleted file mode 100644 index fe3f3436..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0023-Don-t-search-host-directory-during-relink-if-inst_pr.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 0409d2dd7322ecbed731cbe29b034fea43c5dddc Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Tue, 3 Mar 2015 08:21:19 +0000 -Subject: [PATCH 23/40] Don't search host directory during "relink" if - $inst_prefix is provided - -http://lists.gnu.org/archive/html/libtool-patches/2011-01/msg00026.html - -Upstream-Status: Submitted - -Signed-off-by: Khem Raj ---- - ltmain.sh | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -diff --git a/ltmain.sh b/ltmain.sh -index 52bdbdb5f9c..82bcec39f05 100644 ---- a/ltmain.sh -+++ b/ltmain.sh -@@ -6004,12 +6004,13 @@ func_mode_link () - fi - else - # We cannot seem to hardcode it, guess we'll fake it. -+ # Default if $libdir is not relative to the prefix: - add_dir="-L$libdir" -- # Try looking first in the location we're being installed to. -+ - if test -n "$inst_prefix_dir"; then - case $libdir in - [\\/]*) -- add_dir="$add_dir -L$inst_prefix_dir$libdir" -+ add_dir="-L$inst_prefix_dir$libdir" - ;; - esac - fi --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0024-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0024-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch deleted file mode 100644 index c388a0ad..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0024-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 56e2e1fc2a27c4a5cc9b471d5d0af90bcb871bfa Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Tue, 28 Apr 2015 23:15:27 -0700 -Subject: [PATCH 24/40] Use SYSTEMLIBS_DIR replacement instead of hardcoding base_libdir - -Upstream-Status: Pending - -Signed-off-by: Khem Raj ---- - gcc/config/aarch64/aarch64-linux.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h -index bf1327e98cc..64436183bc8 100644 ---- a/gcc/config/aarch64/aarch64-linux.h -+++ b/gcc/config/aarch64/aarch64-linux.h -@@ -21,7 +21,7 @@ - #ifndef GCC_AARCH64_LINUX_H - #define GCC_AARCH64_LINUX_H - --#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1" -+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1" - - #undef MUSL_DYNAMIC_LINKER - #define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1" --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0026-libcc1-fix-libcc1-s-install-path-and-rpath.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0026-libcc1-fix-libcc1-s-install-path-and-rpath.patch deleted file mode 100644 index 85917389..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0026-libcc1-fix-libcc1-s-install-path-and-rpath.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 3d4e53fc7cd71ce1181af8a5e9655398857af741 Mon Sep 17 00:00:00 2001 -From: Robert Yang -Date: Sun, 5 Jul 2015 20:25:18 -0700 -Subject: [PATCH 26/40] libcc1: fix libcc1's install path and rpath - -* Install libcc1.so and libcc1plugin.so into - $(libexecdir)/gcc/$(target_noncanonical)/$(gcc_version), as what we - had done to lto-plugin. -* Fix bad RPATH iussue: - gcc-5.2.0: package gcc-plugins contains bad RPATH /patht/to/tmp/sysroots/qemux86-64/usr/lib64/../lib64 in file - /path/to/gcc/5.2.0-r0/packages-split/gcc-plugins/usr/lib64/gcc/x86_64-poky-linux/5.2.0/plugin/libcc1plugin.so.0.0.0 - [rpaths] - -Upstream-Status: Inappropriate [OE configuration] - -Signed-off-by: Robert Yang ---- - libcc1/Makefile.am | 4 ++-- - libcc1/Makefile.in | 4 ++-- - 2 files changed, 4 insertions(+), 4 deletions(-) - -diff --git a/libcc1/Makefile.am b/libcc1/Makefile.am -index 6ecb66b4365..634cce3c2a9 100644 ---- a/libcc1/Makefile.am -+++ b/libcc1/Makefile.am -@@ -37,8 +37,8 @@ libiberty = $(if $(wildcard $(libiberty_noasan)),$(Wc)$(libiberty_noasan), \ - $(Wc)$(libiberty_normal))) - libiberty_dep = $(patsubst $(Wc)%,%,$(libiberty)) - --plugindir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/plugin --cc1libdir = $(libdir)/$(libsuffix) -+cc1libdir = $(libexecdir)/gcc/$(target_noncanonical)/$(gcc_version) -+plugindir = $(cc1libdir) - - if ENABLE_PLUGIN - plugin_LTLIBRARIES = libcc1plugin.la libcp1plugin.la -diff --git a/libcc1/Makefile.in b/libcc1/Makefile.in -index 47be10025ad..8d5481d87bd 100644 ---- a/libcc1/Makefile.in -+++ b/libcc1/Makefile.in -@@ -303,8 +303,8 @@ libiberty = $(if $(wildcard $(libiberty_noasan)),$(Wc)$(libiberty_noasan), \ - $(Wc)$(libiberty_normal))) - - libiberty_dep = $(patsubst $(Wc)%,%,$(libiberty)) --plugindir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/plugin --cc1libdir = $(libdir)/$(libsuffix) -+cc1libdir = $(libexecdir)/gcc/$(target_noncanonical)/$(gcc_version) -+plugindir = $(cc1libdir) - @ENABLE_PLUGIN_TRUE@plugin_LTLIBRARIES = libcc1plugin.la libcp1plugin.la - @ENABLE_PLUGIN_TRUE@cc1lib_LTLIBRARIES = libcc1.la - shared_source = callbacks.cc callbacks.hh connection.cc connection.hh \ --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0028-Search-target-sysroot-gcc-version-specific-dirs-with.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0028-Search-target-sysroot-gcc-version-specific-dirs-with.patch deleted file mode 100644 index 1b25d780..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0028-Search-target-sysroot-gcc-version-specific-dirs-with.patch +++ /dev/null @@ -1,102 +0,0 @@ -From 62240d4c725ea0b43abfb901ddad90e83e29a25c Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Mon, 7 Dec 2015 23:41:45 +0000 -Subject: [PATCH 28/40] Search target sysroot gcc version specific dirs with - multilib. - -We install the gcc libraries (such as crtbegin.p) into -//5.2.0/ -which is a default search path for GCC (aka multi_suffix in the -code below). is 'machine' in gcc's terminology. We use -these directories so that multiple gcc versions could in theory -co-exist on target. - -We only want to build one gcc-cross-canadian per arch and have this work -for all multilibs. can be handled by mapping the multilib - to the one used by gcc-cross-canadian, e.g. -mips64-polkmllib32-linux -is symlinked to by mips64-poky-linux. - -The default gcc search path in the target sysroot for a "lib64" mutlilib -is: - -/lib32/mips64-poky-linux/5.2.0/ -/lib32/../lib64/ -/usr/lib32/mips64-poky-linux/5.2.0/ -/usr/lib32/../lib64/ -/lib32/ -/usr/lib32/ - -which means that the lib32 crtbegin.o will be found and the lib64 ones -will not which leads to compiler failures. - -This patch injects a multilib version of that path first so the lib64 -binaries can be found first. With this change the search path becomes: - -/lib32/../lib64/mips64-poky-linux/5.2.0/ -/lib32/mips64-poky-linux/5.2.0/ -/lib32/../lib64/ -/usr/lib32/../lib64/mips64-poky-linux/5.2.0/ -/usr/lib32/mips64-poky-linux/5.2.0/ -/usr/lib32/../lib64/ -/lib32/ -/usr/lib32/ - -Upstream-Status: Pending -RP 2015/7/31 - -Signed-off-by: Khem Raj ---- - gcc/gcc.c | 29 ++++++++++++++++++++++++++++- - 1 file changed, 28 insertions(+), 1 deletion(-) - -diff --git a/gcc/gcc.c b/gcc/gcc.c -index cd0c7fbe961..f6f3aa077c8 100644 ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -2527,7 +2527,7 @@ for_each_path (const struct path_prefix *paths, - if (path == NULL) - { - len = paths->max_len + extra_space + 1; -- len += MAX (MAX (suffix_len, multi_os_dir_len), multiarch_len); -+ len += MAX ((suffix_len + multi_os_dir_len), multiarch_len); - path = XNEWVEC (char, len); - } - -@@ -2539,6 +2539,33 @@ for_each_path (const struct path_prefix *paths, - /* Look first in MACHINE/VERSION subdirectory. */ - if (!skip_multi_dir) - { -+ if (!(pl->os_multilib ? skip_multi_os_dir : skip_multi_dir)) -+ { -+ const char *this_multi; -+ size_t this_multi_len; -+ -+ if (pl->os_multilib) -+ { -+ this_multi = multi_os_dir; -+ this_multi_len = multi_os_dir_len; -+ } -+ else -+ { -+ this_multi = multi_dir; -+ this_multi_len = multi_dir_len; -+ } -+ -+ /* Look in multilib MACHINE/VERSION subdirectory first */ -+ if (this_multi_len) -+ { -+ memcpy (path + len, this_multi, this_multi_len + 1); -+ memcpy (path + len + this_multi_len, multi_suffix, suffix_len + 1); -+ ret = callback (path, callback_info); -+ if (ret) -+ break; -+ } -+ } -+ - memcpy (path + len, multi_suffix, suffix_len + 1); - ret = callback (path, callback_info); - if (ret) --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0032-libgcc-Add-knob-to-use-ldbl-128-on-ppc.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0032-libgcc-Add-knob-to-use-ldbl-128-on-ppc.patch deleted file mode 100644 index 025caba3..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0032-libgcc-Add-knob-to-use-ldbl-128-on-ppc.patch +++ /dev/null @@ -1,125 +0,0 @@ -From 6dfbca78b8d253aecf9cbb5e68e04b8dd3d6a543 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 29 Apr 2016 20:03:28 +0000 -Subject: [PATCH 32/40] libgcc: Add knob to use ldbl-128 on ppc - -musl does not support ldbl 128 so we can not assume -that linux as a whole supports ldbl-128 bits, instead -act upon configure option passed to gcc and assume no -on musl and yes otherwise if no option is passed since -default behaviour is to assume ldbl128 it does not -change the defaults - -Upstream-Status: Pending - -Signed-off-by: Khem Raj ---- - libgcc/Makefile.in | 1 + - libgcc/config/rs6000/t-linux | 5 ++++- - libgcc/configure | 18 ++++++++++++++++++ - libgcc/configure.ac | 12 ++++++++++++ - 4 files changed, 35 insertions(+), 1 deletion(-) - mode change 100644 => 100755 libgcc/configure - -diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in -index dd8cee99fd3..b5f478af382 100644 ---- a/libgcc/Makefile.in -+++ b/libgcc/Makefile.in -@@ -48,6 +48,7 @@ unwind_header = @unwind_header@ - md_unwind_header = @md_unwind_header@ - sfp_machine_header = @sfp_machine_header@ - thread_header = @thread_header@ -+with_ldbl128 = @with_ldbl128@ - - host_noncanonical = @host_noncanonical@ - real_host_noncanonical = @real_host_noncanonical@ -diff --git a/libgcc/config/rs6000/t-linux b/libgcc/config/rs6000/t-linux -index 4f6d4c4a4d2..c50dd94a2da 100644 ---- a/libgcc/config/rs6000/t-linux -+++ b/libgcc/config/rs6000/t-linux -@@ -1,3 +1,6 @@ - SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-glibc.ver - --HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-minimal-toc -+ifeq ($(with_ldbl128),yes) -+HOST_LIBGCC2_CFLAGS += -mlong-double-128 -+endif -+HOST_LIBGCC2_CFLAGS += -mno-minimal-toc -diff --git a/libgcc/configure b/libgcc/configure -old mode 100644 -new mode 100755 -index b2f3f870844..ed806587c17 ---- a/libgcc/configure -+++ b/libgcc/configure -@@ -619,6 +619,7 @@ build_vendor - build_cpu - build - with_aix_soname -+with_ldbl128 - enable_vtable_verify - enable_shared - libgcc_topdir -@@ -668,6 +669,7 @@ with_cross_host - with_ld - enable_shared - enable_vtable_verify -+with_long_double_128 - with_aix_soname - enable_version_specific_runtime_libs - with_slibdir -@@ -1329,6 +1331,7 @@ Optional Packages: - --with-target-subdir=SUBDIR Configuring in a subdirectory for target - --with-cross-host=HOST Configuring with a cross compiler - --with-ld arrange to use the specified ld (full pathname) -+ --with-long-double-128 use 128-bit long double by default - --with-aix-soname=aix|svr4|both - shared library versioning (aka "SONAME") variant to - provide on AIX -@@ -2213,6 +2216,21 @@ fi - - - -+# Check whether --with-long-double-128 was given. -+if test "${with_long_double_128+set}" = set; then : -+ withval=$with_long_double_128; with_ldbl128="$with_long_double_128" -+else -+ case "${host}" in -+ power*-*-musl*) -+ with_ldbl128="no";; -+ *) with_ldbl128="yes";; -+ esac -+ -+fi -+ -+ -+ -+ - # Check whether --with-aix-soname was given. - if test "${with_aix_soname+set}" = set; then : - withval=$with_aix_soname; case "${host}:${enable_shared}" in -diff --git a/libgcc/configure.ac b/libgcc/configure.ac -index b59aa746afc..42220a263c5 100644 ---- a/libgcc/configure.ac -+++ b/libgcc/configure.ac -@@ -78,6 +78,18 @@ AC_ARG_ENABLE(vtable-verify, - [enable_vtable_verify=no]) - AC_SUBST(enable_vtable_verify) - -+AC_ARG_WITH(long-double-128, -+[AS_HELP_STRING([--with-long-double-128], -+ [use 128-bit long double by default])], -+ with_ldbl128="$with_long_double_128", -+[case "${host}" in -+ power*-*-musl*) -+ with_ldbl128="no";; -+ *) with_ldbl128="yes";; -+ esac -+]) -+AC_SUBST(with_ldbl128) -+ - AC_ARG_WITH(aix-soname, - [AS_HELP_STRING([--with-aix-soname=aix|svr4|both], - [shared library versioning (aka "SONAME") variant to provide on AIX])], --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0033-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0033-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch deleted file mode 100644 index 343f7aad..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0033-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 7e55147e8e609ace6f9eecd86a956636687671f0 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Wed, 4 May 2016 21:11:34 -0700 -Subject: [PATCH 33/40] Link libgcc using LDFLAGS, not just SHLIB_LDFLAGS - -Upstream-Status: Pending - -Signed-off-by: Christopher Larson -Signed-off-by: Khem Raj ---- - libgcc/config/t-slibgcc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/libgcc/config/t-slibgcc b/libgcc/config/t-slibgcc -index 7e60b621a2d..ea22ede3361 100644 ---- a/libgcc/config/t-slibgcc -+++ b/libgcc/config/t-slibgcc -@@ -32,7 +32,7 @@ SHLIB_INSTALL_SOLINK = $(LN_S) $(SHLIB_SONAME) \ - $(DESTDIR)$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK) - - SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \ -- $(SHLIB_LDFLAGS) \ -+ $(LDFLAGS) $(SHLIB_LDFLAGS) \ - -o $(SHLIB_DIR)/$(SHLIB_SONAME).tmp @multilib_flags@ \ - $(SHLIB_OBJS) $(SHLIB_LC) && \ - rm -f $(SHLIB_DIR)/$(SHLIB_SOLINK) && \ --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0035-sync-gcc-stddef.h-with-musl.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0035-sync-gcc-stddef.h-with-musl.patch deleted file mode 100644 index 6ecd6e97..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0035-sync-gcc-stddef.h-with-musl.patch +++ /dev/null @@ -1,91 +0,0 @@ -From 38d401fb6ab555d09f4a9a677721dde0743876e1 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 3 Feb 2017 12:56:00 -0800 -Subject: [PATCH 35/40] sync gcc stddef.h with musl - -musl defines ptrdiff_t size_t and wchar_t -so dont define them here if musl is definining them - -Upstream-Status: Pending - -Signed-off-by: Khem Raj ---- - gcc/ginclude/stddef.h | 9 +++++++++ - 1 file changed, 9 insertions(+) - -diff --git a/gcc/ginclude/stddef.h b/gcc/ginclude/stddef.h -index 31b96a7e5e1..438a3ce7c56 100644 ---- a/gcc/ginclude/stddef.h -+++ b/gcc/ginclude/stddef.h -@@ -134,6 +134,7 @@ _TYPE_wchar_t; - #ifndef ___int_ptrdiff_t_h - #ifndef _GCC_PTRDIFF_T - #ifndef _PTRDIFF_T_DECLARED /* DragonFly */ -+#ifndef __DEFINED_ptrdiff_t /* musl */ - #define _PTRDIFF_T - #define _T_PTRDIFF_ - #define _T_PTRDIFF -@@ -143,10 +144,12 @@ _TYPE_wchar_t; - #define ___int_ptrdiff_t_h - #define _GCC_PTRDIFF_T - #define _PTRDIFF_T_DECLARED -+#define __DEFINED_ptrdiff_t /* musl */ - #ifndef __PTRDIFF_TYPE__ - #define __PTRDIFF_TYPE__ long int - #endif - typedef __PTRDIFF_TYPE__ ptrdiff_t; -+#endif /* __DEFINED_ptrdiff_t */ - #endif /* _PTRDIFF_T_DECLARED */ - #endif /* _GCC_PTRDIFF_T */ - #endif /* ___int_ptrdiff_t_h */ -@@ -184,6 +187,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; - #ifndef _GCC_SIZE_T - #ifndef _SIZET_ - #ifndef __size_t -+#ifndef __DEFINED_size_t /* musl */ - #define __size_t__ /* BeOS */ - #define __SIZE_T__ /* Cray Unicos/Mk */ - #define _SIZE_T -@@ -200,6 +204,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; - #define ___int_size_t_h - #define _GCC_SIZE_T - #define _SIZET_ -+#define __DEFINED_size_t /* musl */ - #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \ - || defined(__DragonFly__) \ - || defined(__FreeBSD_kernel__) -@@ -235,6 +240,7 @@ typedef long ssize_t; - #endif /* _SIZE_T */ - #endif /* __SIZE_T__ */ - #endif /* __size_t__ */ -+#endif /* __DEFINED_size_t */ - #undef __need_size_t - #endif /* _STDDEF_H or __need_size_t. */ - -@@ -264,6 +270,7 @@ typedef long ssize_t; - #ifndef ___int_wchar_t_h - #ifndef __INT_WCHAR_T_H - #ifndef _GCC_WCHAR_T -+#ifndef __DEFINED_wchar_t /* musl */ - #define __wchar_t__ /* BeOS */ - #define __WCHAR_T__ /* Cray Unicos/Mk */ - #define _WCHAR_T -@@ -279,6 +286,7 @@ typedef long ssize_t; - #define __INT_WCHAR_T_H - #define _GCC_WCHAR_T - #define _WCHAR_T_DECLARED -+#define __DEFINED_wchar_t /* musl */ - - /* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_ - instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other -@@ -344,6 +352,7 @@ typedef __WCHAR_TYPE__ wchar_t; - #endif - #endif /* __WCHAR_T__ */ - #endif /* __wchar_t__ */ -+#endif /* __DEFINED_wchar_t musl */ - #undef __need_wchar_t - #endif /* _STDDEF_H or __need_wchar_t. */ - --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0037-Fix-for-testsuite-failure.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0037-Fix-for-testsuite-failure.patch deleted file mode 100644 index 70999dd4..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0037-Fix-for-testsuite-failure.patch +++ /dev/null @@ -1,258 +0,0 @@ -From 1e5c1ef34d92b4157e1a24ca743d45f3a7375a5e Mon Sep 17 00:00:00 2001 -From: RAGHUNATH LOLUR -Date: Wed, 6 Dec 2017 22:52:26 -0800 -Subject: [PATCH 37/40] Fix for testsuite failure - -2017-11-16 Raghunath Lolur - - * gcc.dg/pr56275.c: If SSE is disabled, ensure that - "-mfpmath" is not set to use SSE. Set "-mfpmath=387". - * gcc.dg/pr68306.c: Likewise - * gcc.dg/pr68306-2.c: Likewise - * gcc.dg/pr68306-3.c: Likewise - * gcc.dg/pr69634.c: Likewise - * gcc.target/i386/amd64-abi-1.c: Likewise - * gcc.target/i386/funcspec-6.c: Likewise - * gcc.target/i386/interrupt-387-err-1.c: Likewise - * gcc.target/i386/isa-14.c: Likewise - * gcc.target/i386/pr44948-2b.c: Likewise - * gcc.target/i386/pr53425-1.c: Likewise - * gcc.target/i386/pr53425-2.c: Likewise - * gcc.target/i386/pr55247.c: Likewise - * gcc.target/i386/pr59644.c: Likewise - * gcc.target/i386/pr62120.c: Likewise - * gcc.target/i386/pr70467-1.c: Likewise - * gcc.target/i386/warn-vect-op-1.c: Likewise - -If -Wall, -Werror are used during compilation various test cases fail -to compile. - -If SSE is disabled, be sure to -mfpmath=387 to resolve this. - -This patch removes the changes to Changelog from the original patch. -This will help us avoid conflicts. - -Upstream-Status: Pending - -Signed-off-by: Mark Hatle ---- - gcc/testsuite/gcc.dg/pr56275.c | 2 +- - gcc/testsuite/gcc.dg/pr68306-2.c | 2 +- - gcc/testsuite/gcc.dg/pr68306-3.c | 2 +- - gcc/testsuite/gcc.dg/pr68306.c | 2 +- - gcc/testsuite/gcc.dg/pr69634.c | 2 +- - gcc/testsuite/gcc.target/i386/amd64-abi-1.c | 2 +- - gcc/testsuite/gcc.target/i386/funcspec-6.c | 1 + - gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c | 2 +- - gcc/testsuite/gcc.target/i386/isa-14.c | 2 +- - gcc/testsuite/gcc.target/i386/pr44948-2b.c | 2 +- - gcc/testsuite/gcc.target/i386/pr53425-1.c | 2 +- - gcc/testsuite/gcc.target/i386/pr53425-2.c | 2 +- - gcc/testsuite/gcc.target/i386/pr55247.c | 2 +- - gcc/testsuite/gcc.target/i386/pr59644.c | 2 +- - gcc/testsuite/gcc.target/i386/pr62120.c | 2 +- - gcc/testsuite/gcc.target/i386/pr70467-1.c | 2 +- - gcc/testsuite/gcc.target/i386/warn-vect-op-1.c | 2 +- - 17 files changed, 17 insertions(+), 16 deletions(-) - -diff --git a/gcc/testsuite/gcc.dg/pr56275.c b/gcc/testsuite/gcc.dg/pr56275.c -index b901bb2b199..a4f6c95e1a1 100644 ---- a/gcc/testsuite/gcc.dg/pr56275.c -+++ b/gcc/testsuite/gcc.dg/pr56275.c -@@ -1,6 +1,6 @@ - /* { dg-do compile } */ - /* { dg-options "-O2" } */ --/* { dg-additional-options "-mno-sse" { target { i?86-*-* x86_64-*-* } } } */ -+/* { dg-additional-options "-mno-sse -mfpmath=387" { target { i?86-*-* x86_64-*-* } } } */ - - typedef long long v2tw __attribute__ ((vector_size (2 * sizeof (long long)))); - -diff --git a/gcc/testsuite/gcc.dg/pr68306-2.c b/gcc/testsuite/gcc.dg/pr68306-2.c -index 4672ebe7987..2a368c484b6 100644 ---- a/gcc/testsuite/gcc.dg/pr68306-2.c -+++ b/gcc/testsuite/gcc.dg/pr68306-2.c -@@ -1,6 +1,6 @@ - /* { dg-do compile } */ - /* { dg-options "-O3" } */ --/* { dg-additional-options "-mno-sse -mno-mmx" { target i?86-*-* x86_64-*-* } } */ -+/* { dg-additional-options "-mno-sse -mno-mmx -mfpmath=387" { target i?86-*-* x86_64-*-* } } */ - - struct { - int tz_minuteswest; -diff --git a/gcc/testsuite/gcc.dg/pr68306-3.c b/gcc/testsuite/gcc.dg/pr68306-3.c -index f5a8c102cf8..df3390c64c2 100644 ---- a/gcc/testsuite/gcc.dg/pr68306-3.c -+++ b/gcc/testsuite/gcc.dg/pr68306-3.c -@@ -1,6 +1,6 @@ - /* { dg-do compile } */ - /* { dg-options "-O3" } */ --/* { dg-additional-options "-mno-sse -mno-mmx" { target i?86-*-* x86_64-*-* } } */ -+/* { dg-additional-options "-mno-sse -mno-mmx -mfpmath=387" { target i?86-*-* x86_64-*-* } } */ - /* { dg-additional-options "-mno-altivec -mno-vsx" { target powerpc*-*-* } } */ - - extern void fn2(); -diff --git a/gcc/testsuite/gcc.dg/pr68306.c b/gcc/testsuite/gcc.dg/pr68306.c -index 54e5b40f221..0813389e2c1 100644 ---- a/gcc/testsuite/gcc.dg/pr68306.c -+++ b/gcc/testsuite/gcc.dg/pr68306.c -@@ -1,6 +1,6 @@ - /* { dg-do compile } */ - /* { dg-options "-O3" } */ --/* { dg-additional-options "-mno-sse -mno-mmx" { target i?86-*-* x86_64-*-* } } */ -+/* { dg-additional-options "-mno-sse -mno-mmx -mfpmath=387" { target i?86-*-* x86_64-*-* } } */ - - enum powerpc_pmc_type { PPC_PMC_IBM }; - struct { -diff --git a/gcc/testsuite/gcc.dg/pr69634.c b/gcc/testsuite/gcc.dg/pr69634.c -index 60a56149463..bcc23f9ccd6 100644 ---- a/gcc/testsuite/gcc.dg/pr69634.c -+++ b/gcc/testsuite/gcc.dg/pr69634.c -@@ -1,6 +1,6 @@ - /* { dg-do compile } */ - /* { dg-options "-O2 -fno-dce -fschedule-insns -fno-tree-vrp -fcompare-debug -Wno-psabi" } */ --/* { dg-additional-options "-mno-sse" { target i?86-*-* x86_64-*-* } } */ -+/* { dg-additional-options "-mno-sse -mfpmath=387" { target i?86-*-* x86_64-*-* } } */ - /* { dg-require-effective-target scheduling } */ - - typedef unsigned short u16; -diff --git a/gcc/testsuite/gcc.target/i386/amd64-abi-1.c b/gcc/testsuite/gcc.target/i386/amd64-abi-1.c -index 69fde57bf06..7f1f1c03edf 100644 ---- a/gcc/testsuite/gcc.target/i386/amd64-abi-1.c -+++ b/gcc/testsuite/gcc.target/i386/amd64-abi-1.c -@@ -1,5 +1,5 @@ - /* { dg-do compile { target { ! ia32 } } } */ --/* { dg-options "-mno-sse" } */ -+/* { dg-options "-mno-sse -mfpmath=387" } */ - /* { dg-additional-options "-mabi=sysv" { target *-*-mingw* } } */ - - double foo(void) { return 0; } /* { dg-error "SSE disabled" } */ -diff --git a/gcc/testsuite/gcc.target/i386/funcspec-6.c b/gcc/testsuite/gcc.target/i386/funcspec-6.c -index ea896b7ebfd..bf15569b826 100644 ---- a/gcc/testsuite/gcc.target/i386/funcspec-6.c -+++ b/gcc/testsuite/gcc.target/i386/funcspec-6.c -@@ -1,6 +1,7 @@ - /* Test whether all of the 64-bit function specific options are accepted - without error. */ - /* { dg-do compile { target { ! ia32 } } } */ -+/* { dg-additional-options "-mfpmath=387" } */ - - #include "funcspec-56.inc" - -diff --git a/gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c b/gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c -index 3fbdc881dda..6b4d9d1252a 100644 ---- a/gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c -+++ b/gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O2 -mgeneral-regs-only -mno-cld -mno-iamcu -m80387" } */ -+/* { dg-options "-O2 -mgeneral-regs-only -mno-cld -mno-iamcu -m80387 -mfpmath=387" } */ - - typedef unsigned int uword_t __attribute__ ((mode (__word__))); - -diff --git a/gcc/testsuite/gcc.target/i386/isa-14.c b/gcc/testsuite/gcc.target/i386/isa-14.c -index 5d49e6e77fe..1de2db92bdd 100644 ---- a/gcc/testsuite/gcc.target/i386/isa-14.c -+++ b/gcc/testsuite/gcc.target/i386/isa-14.c -@@ -1,5 +1,5 @@ - /* { dg-do run } */ --/* { dg-options "-march=x86-64 -msse4a -mfma4 -mno-sse" } */ -+/* { dg-options "-march=x86-64 -msse4a -mfma4 -mno-sse -mfpmath=387" } */ - - extern void abort (void); - -diff --git a/gcc/testsuite/gcc.target/i386/pr44948-2b.c b/gcc/testsuite/gcc.target/i386/pr44948-2b.c -index fa1769b62fb..f79fb12726f 100644 ---- a/gcc/testsuite/gcc.target/i386/pr44948-2b.c -+++ b/gcc/testsuite/gcc.target/i386/pr44948-2b.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-O -mno-sse -Wno-psabi -mtune=generic" } */ -+/* { dg-options "-O -mno-sse -Wno-psabi -mtune=generic -mfpmath=387" } */ - - struct A - { -diff --git a/gcc/testsuite/gcc.target/i386/pr53425-1.c b/gcc/testsuite/gcc.target/i386/pr53425-1.c -index 2e89ff7d81d..6339bf6b736 100644 ---- a/gcc/testsuite/gcc.target/i386/pr53425-1.c -+++ b/gcc/testsuite/gcc.target/i386/pr53425-1.c -@@ -1,6 +1,6 @@ - /* PR target/53425 */ - /* { dg-do compile { target { ! ia32 } } } */ --/* { dg-options "-O2 -mno-sse" } */ -+/* { dg-options "-O2 -mno-sse -mfpmath=387" } */ - /* { dg-skip-if "no SSE vector" { x86_64-*-mingw* } } */ - - typedef double __v2df __attribute__ ((__vector_size__ (16))); -diff --git a/gcc/testsuite/gcc.target/i386/pr53425-2.c b/gcc/testsuite/gcc.target/i386/pr53425-2.c -index 61f6283dbe9..2c5a55f0ac3 100644 ---- a/gcc/testsuite/gcc.target/i386/pr53425-2.c -+++ b/gcc/testsuite/gcc.target/i386/pr53425-2.c -@@ -1,6 +1,6 @@ - /* PR target/53425 */ - /* { dg-do compile { target { ! ia32 } } } */ --/* { dg-options "-O2 -mno-sse" } */ -+/* { dg-options "-O2 -mno-sse -mfpmath=387" } */ - /* { dg-skip-if "no SSE vector" { x86_64-*-mingw* } } */ - - typedef float __v2sf __attribute__ ((__vector_size__ (8))); -diff --git a/gcc/testsuite/gcc.target/i386/pr55247.c b/gcc/testsuite/gcc.target/i386/pr55247.c -index 23366d0909d..9810e3abb76 100644 ---- a/gcc/testsuite/gcc.target/i386/pr55247.c -+++ b/gcc/testsuite/gcc.target/i386/pr55247.c -@@ -1,6 +1,6 @@ - /* { dg-do compile { target { ! ia32 } } } */ - /* { dg-require-effective-target maybe_x32 } */ --/* { dg-options "-O2 -mno-sse -mno-mmx -mx32 -maddress-mode=long" } */ -+/* { dg-options "-O2 -mno-sse -mno-mmx -mx32 -maddress-mode=long -mfpmath=387" } */ - - typedef unsigned int uint32_t; - typedef uint32_t Elf32_Word; -diff --git a/gcc/testsuite/gcc.target/i386/pr59644.c b/gcc/testsuite/gcc.target/i386/pr59644.c -index 96006b3e338..4287e4538bf 100644 ---- a/gcc/testsuite/gcc.target/i386/pr59644.c -+++ b/gcc/testsuite/gcc.target/i386/pr59644.c -@@ -1,6 +1,6 @@ - /* PR target/59644 */ - /* { dg-do run { target lp64 } } */ --/* { dg-options "-O2 -ffreestanding -mno-sse -mpreferred-stack-boundary=3 -maccumulate-outgoing-args -mno-red-zone" } */ -+/* { dg-options "-O2 -ffreestanding -mno-sse -mpreferred-stack-boundary=3 -maccumulate-outgoing-args -mno-red-zone -mfpmath=387" } */ - - /* This test uses __builtin_trap () instead of e.g. abort, - because due to -mpreferred-stack-boundary=3 it should not call -diff --git a/gcc/testsuite/gcc.target/i386/pr62120.c b/gcc/testsuite/gcc.target/i386/pr62120.c -index bfb8c4703eb..ed04cf181f3 100644 ---- a/gcc/testsuite/gcc.target/i386/pr62120.c -+++ b/gcc/testsuite/gcc.target/i386/pr62120.c -@@ -1,5 +1,5 @@ - /* { dg-do compile } */ --/* { dg-options "-mno-sse" } */ -+/* { dg-options "-mno-sse -mfpmath=387" } */ - - void foo () - { -diff --git a/gcc/testsuite/gcc.target/i386/pr70467-1.c b/gcc/testsuite/gcc.target/i386/pr70467-1.c -index 4e112c88d07..bcfb396a68d 100644 ---- a/gcc/testsuite/gcc.target/i386/pr70467-1.c -+++ b/gcc/testsuite/gcc.target/i386/pr70467-1.c -@@ -1,6 +1,6 @@ - /* PR rtl-optimization/70467 */ - /* { dg-do compile } */ --/* { dg-options "-O2 -mno-sse" } */ -+/* { dg-options "-O2 -mno-sse -mfpmath=387" } */ - - void foo (unsigned long long *); - -diff --git a/gcc/testsuite/gcc.target/i386/warn-vect-op-1.c b/gcc/testsuite/gcc.target/i386/warn-vect-op-1.c -index 6cda1534311..26e37f5b8ba 100644 ---- a/gcc/testsuite/gcc.target/i386/warn-vect-op-1.c -+++ b/gcc/testsuite/gcc.target/i386/warn-vect-op-1.c -@@ -1,5 +1,5 @@ - /* { dg-do compile { target { ! ia32 } } } */ --/* { dg-options "-mno-sse -Wvector-operation-performance" } */ -+/* { dg-options "-mno-sse -Wvector-operation-performance -mfpmath=387" } */ - #define vector(elcount, type) \ - __attribute__((vector_size((elcount)*sizeof(type)))) type - --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0038-Re-introduce-spe-commandline-options.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0038-Re-introduce-spe-commandline-options.patch deleted file mode 100644 index 8de8892b..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0038-Re-introduce-spe-commandline-options.patch +++ /dev/null @@ -1,41 +0,0 @@ -From f0bea96434ac478c3cff8c29dd97cccfac5b35e3 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Wed, 6 Jun 2018 12:10:22 -0700 -Subject: [PATCH 38/40] Re-introduce spe commandline options - -This should ensure that we keep accepting -spe options - -Upstream-Status: Inappropriate [SPE port is removed from rs600 port] - -Signed-off-by: Khem Raj ---- - gcc/config/rs6000/rs6000.opt | 12 ++++++++++++ - 1 file changed, 12 insertions(+) - -diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt -index ace8a477550..d6a8f825d88 100644 ---- a/gcc/config/rs6000/rs6000.opt -+++ b/gcc/config/rs6000/rs6000.opt -@@ -365,6 +365,18 @@ mdebug= - Target RejectNegative Joined - -mdebug= Enable debug output. - -+mspe -+Target Var(rs6000_spe) Save -+Generate SPE SIMD instructions on E500. -+ -+mabi=spe -+Target RejectNegative Var(rs6000_spe_abi) Save -+Use the SPE ABI extensions. -+ -+mabi=no-spe -+Target RejectNegative Var(rs6000_spe_abi, 0) -+Do not use the SPE ABI extensions. -+ - mabi=altivec - Target RejectNegative Var(rs6000_altivec_abi) Save - Use the AltiVec ABI extensions. --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0039-riscv-Disable-multilib-for-OE.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0039-riscv-Disable-multilib-for-OE.patch deleted file mode 100644 index f7b222e8..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0039-riscv-Disable-multilib-for-OE.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 24f74444c00c6c9bf076fb002614ebf6dec31f1a Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 28 Dec 2018 09:59:53 -0800 -Subject: [PATCH 39/40] riscv: Disable multilib for OE - -Upstream-Status: Inappropriate [OE-Specific] - -Signed-off-by: Khem Raj ---- - gcc/config/riscv/t-linux | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/gcc/config/riscv/t-linux b/gcc/config/riscv/t-linux -index 216d2776a18..e4d817621fc 100644 ---- a/gcc/config/riscv/t-linux -+++ b/gcc/config/riscv/t-linux -@@ -1,3 +1,5 @@ - # Only XLEN and ABI affect Linux multilib dir names, e.g. /lib32/ilp32d/ --MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES))) --MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES)) -+#MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES))) -+MULTILIB_DIRNAMES := . . -+#MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES)) -+MULTILIB_OSDIRNAMES := ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0040-powerpc-powerpc64-Add-support-for-musl-ldso.patch b/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0040-powerpc-powerpc64-Add-support-for-musl-ldso.patch deleted file mode 100644 index 9fba1637..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0040-powerpc-powerpc64-Add-support-for-musl-ldso.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 4bd0a3866f302725cb4eddcaddaeece64900c42f Mon Sep 17 00:00:00 2001 -From: Serhey Popovych -Date: Tue, 11 Dec 2018 02:30:50 -0500 -Subject: [PATCH 40/40] powerpc/powerpc64: Add support for musl ldso - -Upstream-Status: Inappropriate [OE-Specific] - -Signed-off-by: Serhey Popovych ---- - gcc/config/rs6000/linux64.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h -index 619e113e2b8..ee8b44f9374 100644 ---- a/gcc/config/rs6000/linux64.h -+++ b/gcc/config/rs6000/linux64.h -@@ -421,9 +421,9 @@ extern int dot_symbols; - #endif - - #define MUSL_DYNAMIC_LINKER32 \ -- "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" -+ SYSTEMLIBS_DIR "ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" - #define MUSL_DYNAMIC_LINKER64 \ -- "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" -+ SYSTEMLIBS_DIR "ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" - - #define UCLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-uClibc.so.0" - #define UCLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld64-uClibc.so.0" --- -2.21.0 - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-cross-canadian_arm-8.2.bb b/meta-arm-toolchain/recipes-devtools/gcc/gcc-cross-canadian_arm-10.2.bb similarity index 100% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-cross-canadian_arm-8.2.bb rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-cross-canadian_arm-10.2.bb diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-cross-canadian_arm-8.3.bb b/meta-arm-toolchain/recipes-devtools/gcc/gcc-cross-canadian_arm-8.3.bb deleted file mode 100644 index 8987a4c1..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-cross-canadian_arm-8.3.bb +++ /dev/null @@ -1,5 +0,0 @@ -require recipes-devtools/gcc/gcc-${PV}.inc -require recipes-devtools/gcc/gcc-cross-canadian.inc - - - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-cross_arm-8.2.bb b/meta-arm-toolchain/recipes-devtools/gcc/gcc-cross_arm-10.2.bb similarity index 100% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-cross_arm-8.2.bb rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-cross_arm-10.2.bb diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-cross_arm-8.3.bb b/meta-arm-toolchain/recipes-devtools/gcc/gcc-cross_arm-8.3.bb deleted file mode 100644 index 0a8aa75b..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-cross_arm-8.3.bb +++ /dev/null @@ -1,3 +0,0 @@ -require recipes-devtools/gcc/gcc-${PV}.inc -require recipes-devtools/gcc/gcc-cross.inc - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-crosssdk_arm-8.2.bb b/meta-arm-toolchain/recipes-devtools/gcc/gcc-crosssdk_arm-10.2.bb similarity index 100% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-crosssdk_arm-8.2.bb rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-crosssdk_arm-10.2.bb diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-crosssdk_arm-8.3.bb b/meta-arm-toolchain/recipes-devtools/gcc/gcc-crosssdk_arm-8.3.bb deleted file mode 100644 index 0a9f98a1..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-crosssdk_arm-8.3.bb +++ /dev/null @@ -1,2 +0,0 @@ -require recipes-devtools/gcc/gcc-cross_${PV}.bb -require recipes-devtools/gcc/gcc-crosssdk.inc diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-runtime_arm-8.2.bb b/meta-arm-toolchain/recipes-devtools/gcc/gcc-runtime_arm-10.2.bb similarity index 50% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-runtime_arm-8.2.bb rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-runtime_arm-10.2.bb index 8f41c112..b755f555 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-runtime_arm-8.2.bb +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-runtime_arm-10.2.bb @@ -1,7 +1,2 @@ require recipes-devtools/gcc/gcc-${PV}.inc require recipes-devtools/gcc/gcc-runtime.inc - -FILES_libgomp-dev += "\ - ${libdir}/gcc/${TARGET_SYS}/${BINV}/include/openacc.h \ -" - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-runtime_arm-8.3.bb b/meta-arm-toolchain/recipes-devtools/gcc/gcc-runtime_arm-8.3.bb deleted file mode 100644 index 8f41c112..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-runtime_arm-8.3.bb +++ /dev/null @@ -1,7 +0,0 @@ -require recipes-devtools/gcc/gcc-${PV}.inc -require recipes-devtools/gcc/gcc-runtime.inc - -FILES_libgomp-dev += "\ - ${libdir}/gcc/${TARGET_SYS}/${BINV}/include/openacc.h \ -" - diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-sanitizers_arm-10.2.bb b/meta-arm-toolchain/recipes-devtools/gcc/gcc-sanitizers_arm-10.2.bb new file mode 100644 index 00000000..9c41e926 --- /dev/null +++ b/meta-arm-toolchain/recipes-devtools/gcc/gcc-sanitizers_arm-10.2.bb @@ -0,0 +1,7 @@ +require recipes-devtools/gcc/gcc-${PV}.inc +require recipes-devtools/gcc/gcc-sanitizers.inc + +# Building with thumb enabled on armv4t armv5t fails with +# sanitizer_linux.s:5749: Error: lo register required -- `ldr ip,[sp],#8' +ARM_INSTRUCTION_SET_armv4 = "arm" +ARM_INSTRUCTION_SET_armv5 = "arm" diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-sanitizers_arm-8.2.bb b/meta-arm-toolchain/recipes-devtools/gcc/gcc-sanitizers_arm-8.2.bb deleted file mode 100644 index 03769bfd..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-sanitizers_arm-8.2.bb +++ /dev/null @@ -1,2 +0,0 @@ -require recipes-devtools/gcc/gcc-${PV}.inc -require recipes-devtools/gcc/gcc-sanitizers.inc diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-sanitizers_arm-8.3.bb b/meta-arm-toolchain/recipes-devtools/gcc/gcc-sanitizers_arm-8.3.bb deleted file mode 100644 index 03769bfd..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-sanitizers_arm-8.3.bb +++ /dev/null @@ -1,2 +0,0 @@ -require recipes-devtools/gcc/gcc-${PV}.inc -require recipes-devtools/gcc/gcc-sanitizers.inc diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-source_arm-8.2.bb b/meta-arm-toolchain/recipes-devtools/gcc/gcc-source_arm-10.2.bb similarity index 100% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc-source_arm-8.2.bb rename to meta-arm-toolchain/recipes-devtools/gcc/gcc-source_arm-10.2.bb diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc-source_arm-8.3.bb b/meta-arm-toolchain/recipes-devtools/gcc/gcc-source_arm-8.3.bb deleted file mode 100644 index b890fa33..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc-source_arm-8.3.bb +++ /dev/null @@ -1,4 +0,0 @@ -require recipes-devtools/gcc/gcc-${PV}.inc -require recipes-devtools/gcc/gcc-source.inc - -EXCLUDE_FROM_WORLD = "1" diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc_arm-8.2.bb b/meta-arm-toolchain/recipes-devtools/gcc/gcc_arm-10.2.bb similarity index 100% rename from meta-arm-toolchain/recipes-devtools/gcc/gcc_arm-8.2.bb rename to meta-arm-toolchain/recipes-devtools/gcc/gcc_arm-10.2.bb diff --git a/meta-arm-toolchain/recipes-devtools/gcc/gcc_arm-8.3.bb b/meta-arm-toolchain/recipes-devtools/gcc/gcc_arm-8.3.bb deleted file mode 100644 index 51a08772..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/gcc_arm-8.3.bb +++ /dev/null @@ -1,15 +0,0 @@ -require recipes-devtools/gcc/gcc-${PV}.inc -require recipes-devtools/gcc/gcc-target.inc -require recipes-devtools/gcc/gcc-arm-common.inc - -# Building with thumb enabled on armv4t armv5t fails with -# | gcc-4.8.1-r0/gcc-4.8.1/gcc/cp/decl.c:7438:(.text.unlikely+0x2fa): relocation truncated to fit: R_ARM_THM_CALL against symbol `fancy_abort(char const*, int, char const*)' defined in .glue_7 section in linker stubs -# | gcc-4.8.1-r0/gcc-4.8.1/gcc/cp/decl.c:7442:(.text.unlikely+0x318): additional relocation overflows omitted from the output -ARM_INSTRUCTION_SET_armv4 = "arm" -ARM_INSTRUCTION_SET_armv5 = "arm" - -ARMFPARCHEXT_armv6 = "${@'+fp' if d.getVar('TARGET_FPU') == 'hard' else ''}" -ARMFPARCHEXT_armv7a = "${@'+fp' if d.getVar('TARGET_FPU') == 'hard' else ''}" -ARMFPARCHEXT_armv7ve = "${@'+fp' if d.getVar('TARGET_FPU') == 'hard' else ''}" - -BBCLASSEXTEND = "nativesdk" diff --git a/meta-arm-toolchain/recipes-devtools/gcc/libgcc-initial_arm-8.3.bb b/meta-arm-toolchain/recipes-devtools/gcc/libgcc-initial_arm-10.2.bb similarity index 52% rename from meta-arm-toolchain/recipes-devtools/gcc/libgcc-initial_arm-8.3.bb rename to meta-arm-toolchain/recipes-devtools/gcc/libgcc-initial_arm-10.2.bb index 3e07c719..32f3dc09 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/libgcc-initial_arm-8.3.bb +++ b/meta-arm-toolchain/recipes-devtools/gcc/libgcc-initial_arm-10.2.bb @@ -1,2 +1,5 @@ require recipes-devtools/gcc/gcc-${PV}.inc require recipes-devtools/gcc/libgcc-initial.inc + +# Building with thumb enabled on armv6t fails +ARM_INSTRUCTION_SET_armv6 = "arm" diff --git a/meta-arm-toolchain/recipes-devtools/gcc/libgcc-initial_arm-8.2.bb b/meta-arm-toolchain/recipes-devtools/gcc/libgcc-initial_arm-8.2.bb deleted file mode 100644 index 3e07c719..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/libgcc-initial_arm-8.2.bb +++ /dev/null @@ -1,2 +0,0 @@ -require recipes-devtools/gcc/gcc-${PV}.inc -require recipes-devtools/gcc/libgcc-initial.inc diff --git a/meta-arm-toolchain/recipes-devtools/gcc/libgcc_arm-8.3.bb b/meta-arm-toolchain/recipes-devtools/gcc/libgcc_arm-10.2.bb similarity index 50% rename from meta-arm-toolchain/recipes-devtools/gcc/libgcc_arm-8.3.bb rename to meta-arm-toolchain/recipes-devtools/gcc/libgcc_arm-10.2.bb index 340300cd..572bab18 100644 --- a/meta-arm-toolchain/recipes-devtools/gcc/libgcc_arm-8.3.bb +++ b/meta-arm-toolchain/recipes-devtools/gcc/libgcc_arm-10.2.bb @@ -1,2 +1,5 @@ require recipes-devtools/gcc/gcc-${PV}.inc require recipes-devtools/gcc/libgcc.inc + +# Building with thumb enabled on armv6t fails +ARM_INSTRUCTION_SET_armv6 = "arm" diff --git a/meta-arm-toolchain/recipes-devtools/gcc/libgcc_arm-8.2.bb b/meta-arm-toolchain/recipes-devtools/gcc/libgcc_arm-8.2.bb deleted file mode 100644 index 340300cd..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/libgcc_arm-8.2.bb +++ /dev/null @@ -1,2 +0,0 @@ -require recipes-devtools/gcc/gcc-${PV}.inc -require recipes-devtools/gcc/libgcc.inc diff --git a/meta-arm-toolchain/recipes-devtools/gcc/libgfortran_arm-8.2.bb b/meta-arm-toolchain/recipes-devtools/gcc/libgfortran_arm-10.2.bb similarity index 100% rename from meta-arm-toolchain/recipes-devtools/gcc/libgfortran_arm-8.2.bb rename to meta-arm-toolchain/recipes-devtools/gcc/libgfortran_arm-10.2.bb diff --git a/meta-arm-toolchain/recipes-devtools/gcc/libgfortran_arm-8.3.bb b/meta-arm-toolchain/recipes-devtools/gcc/libgfortran_arm-8.3.bb deleted file mode 100644 index 4e5688e9..00000000 --- a/meta-arm-toolchain/recipes-devtools/gcc/libgfortran_arm-8.3.bb +++ /dev/null @@ -1,3 +0,0 @@ -require recipes-devtools/gcc/gcc-${PV}.inc -require recipes-devtools/gcc/libgfortran.inc - diff --git a/meta-arm/conf/machine/microbit-v1.conf b/meta-arm/conf/machine/microbit-v1.conf new file mode 100644 index 00000000..c4cc4d50 --- /dev/null +++ b/meta-arm/conf/machine/microbit-v1.conf @@ -0,0 +1,20 @@ +#@TYPE: Machine +#@NAME: microbit_v1 +#@DESCRIPTION: Machine for BBC Microbit v1, Zephyr BOARD qemu_cortex_m0 + +require conf/machine/include/qemu.inc +require conf/machine/include/tune-cortex-m0.inc + +MACHINEOVERRIDES =. "nordic:" + +# For runqemu +QB_SYSTEM_NAME = "qemu-system-arm" +QB_MACHINE = "-machine microbit" +QB_CPU = "-cpu cortex-m0" +QB_OPT_APPEND = "-nographic -vga none" +QB_RNG = "" + +# Zephyr RTOS settings +ZEPHYR_BOARD = "qemu_cortex_m0" +ZEPHYR_INHERIT_CLASSES += "zephyr-qemuboot" +ARCH_qemu-cortex-m0 = "arm" diff --git a/meta-arm/conf/machine/qemuarm64-secureboot.conf b/meta-arm/conf/machine/qemuarm64-secureboot.conf index f2c15e61..fe19ed27 100644 --- a/meta-arm/conf/machine/qemuarm64-secureboot.conf +++ b/meta-arm/conf/machine/qemuarm64-secureboot.conf @@ -6,10 +6,6 @@ KMACHINE = "qemuarm64" UBOOT_MACHINE = "qemu_arm64_defconfig" -# The 5.4 kernel panics when booting, so use the development kernel until the -# default kernel is upgraded (5.5. supposedly works) -PREFERRED_PROVIDER_virtual/kernel = "linux-yocto-dev" - QB_MACHINE = "-machine virt,secure=on" QB_OPT_APPEND += "-no-acpi" QB_MEM = "-m 1024" @@ -23,4 +19,3 @@ IMAGE_FSTYPES += "wic wic.qcow2" WKS_FILE ?= "qemuarm64.wks" WKS_FILE_DEPENDS = "trusted-firmware-a" IMAGE_BOOT_FILES = "${KERNEL_IMAGETYPE}" - diff --git a/meta-arm/recipes-bsp/hafnium/hafnium_2.4.bb b/meta-arm/recipes-bsp/hafnium/hafnium_2.4.bb new file mode 100644 index 00000000..3a525990 --- /dev/null +++ b/meta-arm/recipes-bsp/hafnium/hafnium_2.4.bb @@ -0,0 +1,74 @@ +SUMMARY = "Hafnium" +DESCRIPTION = "A reference Secure Partition Manager (SPM) for systems that implement the Armv8.4-A Secure-EL2 extension" +LICENSE = "BSD-3-Clause & GPLv2" +LIC_FILES_CHKSUM = "file://LICENSE;md5=782b40c14bad5294672c500501edc103" + +PACKAGE_ARCH = "${MACHINE_ARCH}" + +inherit deploy python3native + +SRC_URI = "gitsm://git.trustedfirmware.org/hafnium/hafnium.git;protocol=https" +SRCREV = "410a3acaf669c12d41fb4c57fcaf3ecee6fdba61" +S = "${WORKDIR}/git" + +COMPATIBLE_MACHINE ?= "invalid" + +# Default build 'reference' +HAFNIUM_PROJECT ?= "reference" + +# Platform must be set for each machine +HAFNIUM_PLATFORM ?= "invalid" + +# hafnium build directory +# Append _clang as the build rule in hafnium adds this to the platform name. +HAFNIUM_BUILD_DIR_PLAT = "out/${HAFNIUM_PROJECT}/${HAFNIUM_PLATFORM}_clang" + +# do_deploy will install everything listed in this variable. It is set by +# default to hafnium +HAFNIUM_INSTALL_TARGET ?= "hafnium" + +DEPENDS = "bison-native bc-native" + +# set project to build +EXTRA_OEMAKE += "PROJECT=${HAFNIUM_PROJECT}" + +do_compile_prepend() { + # Hafnium expects 'python'. Create symlink python to python3 + real=$(which ${PYTHON}) + ln -snf $real $(dirname $real)/python +} + +do_install() { + install -d -m 755 ${D}/firmware + for bldfile in ${HAFNIUM_INSTALL_TARGET}; do + processed="0" + if [ -f ${S}/${HAFNIUM_BUILD_DIR_PLAT}/$bldfile.bin ]; then + echo "Install $bldfile.bin" + install -m 0755 ${S}/${HAFNIUM_BUILD_DIR_PLAT}/$bldfile.bin \ + ${D}/firmware/$bldfile-${HAFNIUM_PLATFORM}.bin + ln -sf $bldfile-${HAFNIUM_PLATFORM}.bin ${D}/firmware/$bldfile.bin + processed="1" + fi + if [ -f ${S}/${HAFNIUM_BUILD_DIR_PLAT}/$bldfile.elf ]; then + echo "Install $bldfile.elf" + install -m 0755 ${S}/${HAFNIUM_BUILD_DIR_PLAT}/$bldfile.elf \ + ${D}/firmware/$bldfile-${HAFNIUM_PLATFORM}.elf + ln -sf $bldfile-${HAFNIUM_PLATFORM}.elf ${D}/firmware/$bldfile.elf + processed="1" + fi + if [ "$processed" = "0" ]; then + bberror "Unsupported HAFNIUM_INSTALL_TARGET target $bldfile" + exit 1 + fi + done +} + +FILES_${PN} = "/firmware" +SYSROOT_DIRS += "/firmware" +# skip QA tests: {'ldflags'} +INSANE_SKIP_${PN} = "ldflags" + +do_deploy() { + cp -rf ${D}/firmware/* ${DEPLOYDIR}/ +} +addtask deploy after do_install diff --git a/meta-arm/recipes-bsp/scp-firmware/scp-firmware_2.6.0.bb b/meta-arm/recipes-bsp/scp-firmware/scp-firmware_2.6.0.bb index f9510e49..123f442e 100644 --- a/meta-arm/recipes-bsp/scp-firmware/scp-firmware_2.6.0.bb +++ b/meta-arm/recipes-bsp/scp-firmware/scp-firmware_2.6.0.bb @@ -17,11 +17,11 @@ SCP_PLATFORM ?= "invalid" SCP_COMPILER ?= "arm-none-eabi" SCP_LOG_LEVEL ?= "WARN" -DEPENDS += "virtual/arm-none-eabi-gcc-native" +INHIBIT_DEFAULT_DEPS = "1" +DEPENDS = "virtual/arm-none-eabi-gcc-native" SCP_BUILD_STR = "${@bb.utils.contains('SCP_BUILD_RELEASE', '1', 'release', 'debug', d)}" -inherit python3native inherit deploy B = "${WORKDIR}/build" diff --git a/meta-arm/recipes-bsp/scp-firmware/scp-firmware_2.7.0.bb b/meta-arm/recipes-bsp/scp-firmware/scp-firmware_2.7.0.bb new file mode 100644 index 00000000..3a71b2ea --- /dev/null +++ b/meta-arm/recipes-bsp/scp-firmware/scp-firmware_2.7.0.bb @@ -0,0 +1,75 @@ +SUMMARY = "SCP and MCP Firmware" +DESCRIPTION = "Firmware for SCP and MCP software reference implementation" +HOMEPAGE = "https://github.com/ARM-software/SCP-firmware" + +LICENSE = "BSD-3-Clause & Apache-2.0" +LIC_FILES_CHKSUM = "file://license.md;beginline=5;md5=9db9e3d2fb8d9300a6c3d15101b19731 \ + file://cmsis/LICENSE.txt;md5=e3fc50a88d0a364313df4b21ef20c29e" + +SRC_URI = "gitsm://github.com/ARM-software/SCP-firmware.git;protocol=https" +SRCREV = "2c4f3af270024b85e1b38fd963050c58f6e9b865" + +PROVIDES += "virtual/control-processor-firmware" + +SCP_BUILD_RELEASE ?= "1" +SCP_PLATFORM ?= "invalid" +SCP_COMPILER ?= "arm-none-eabi" +SCP_LOG_LEVEL ?= "WARN" + +INHIBIT_DEFAULT_DEPS = "1" +DEPENDS = "virtual/arm-none-eabi-gcc-native" + +SCP_BUILD_STR = "${@bb.utils.contains('SCP_BUILD_RELEASE', '1', 'release', 'debug', d)}" + +inherit deploy + +B = "${WORKDIR}/build" +S = "${WORKDIR}/git" + +# Allow platform specific copying of only scp or both scp & mcp, default to both +FW_TARGETS ?= "scp mcp" +FW_INSTALL ?= "ramfw romfw" + +PACKAGE_ARCH = "${MACHINE_ARCH}" +COMPATIBLE_MACHINE ?= "invalid" + +LDFLAGS[unexport] = "1" + +# No configure +do_configure[noexec] = "1" + +EXTRA_OEMAKE = "V=1 \ + BUILD_PATH='${B}' \ + PRODUCT='${SCP_PLATFORM}' \ + MODE='${SCP_BUILD_STR}' \ + LOG_LEVEL='${SCP_LOG_LEVEL}' \ + CC='${SCP_COMPILER}-gcc' \ + AR='${SCP_COMPILER}-ar' \ + SIZE='${SCP_COMPILER}-size' \ + OBJCOPY='${SCP_COMPILER}-objcopy' \ + " + +do_compile() { + oe_runmake -C "${S}" +} +do_compile[cleandirs] += "${B}" + +do_install() { + install -d ${D}/firmware + for FW in ${FW_TARGETS}; do + for TYPE in ${FW_INSTALL}; do + install -D "${B}/product/${SCP_PLATFORM}/${FW}_${TYPE}/${SCP_BUILD_STR}/bin/${FW}_${TYPE}.bin" "${D}/firmware/" + done + done +} + +FILES_${PN} = "/firmware" +SYSROOT_DIRS += "/firmware" +# Skip QA check for relocations in .text of elf binaries +INSANE_SKIP_${PN} = "textrel" + +do_deploy() { + # Copy the images to deploy directory + cp -rf ${D}/firmware/* ${DEPLOYDIR}/ +} +addtask deploy after do_install diff --git a/meta-arm/recipes-bsp/trusted-firmware-a/files/0001-fdts-a5ds-Fix-for-the-system-timer-issue.patch b/meta-arm/recipes-bsp/trusted-firmware-a/files/0001-fdts-a5ds-Fix-for-the-system-timer-issue.patch new file mode 100644 index 00000000..212eacd9 --- /dev/null +++ b/meta-arm/recipes-bsp/trusted-firmware-a/files/0001-fdts-a5ds-Fix-for-the-system-timer-issue.patch @@ -0,0 +1,34 @@ +Upstream-Status: Backport [e3c152d1156af8a4b6453376454ecdceaf81704c] +Signed-off-by: Abdellatif El Khlifi + +From e3c152d1156af8a4b6453376454ecdceaf81704c Mon Sep 17 00:00:00 2001 +From: lakshmi Kailasanathan +Date: Fri, 17 Apr 2020 12:52:19 +0100 +Subject: [PATCH] fdts: a5ds: Fix for the system timer issue. + +A5DS FPGA system timer clock frequency is 7.5Mhz. +The dt is file updated inline with the hardware +clock frequency. + +Change-Id: I3f6c2e0d4a7b293175a42cf398a8730448504af9 +Signed-off-by: lakshmi Kailasanathan +--- + fdts/a5ds.dts | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/fdts/a5ds.dts b/fdts/a5ds.dts +index 7334c4559..c6f5be6fa 100644 +--- a/fdts/a5ds.dts ++++ b/fdts/a5ds.dts +@@ -128,7 +128,7 @@ + #size-cells = <1>; + ranges; + reg = <0x1a040000 0x1000>; +- clock-frequency = <50000000>; ++ clock-frequency = <7500000>; + + frame@1a050000 { + frame-number = <0>; +-- +2.17.1 + diff --git a/meta-arm/recipes-bsp/trusted-firmware-a/files/0002-pmf.h-made-PMF_STOTE_ENABLE-pass-Wtautological.patch b/meta-arm/recipes-bsp/trusted-firmware-a/files/0002-pmf.h-made-PMF_STOTE_ENABLE-pass-Wtautological.patch new file mode 100644 index 00000000..42e0f5b1 --- /dev/null +++ b/meta-arm/recipes-bsp/trusted-firmware-a/files/0002-pmf.h-made-PMF_STOTE_ENABLE-pass-Wtautological.patch @@ -0,0 +1,31 @@ +From c9209fa0f474d41bc5ecf2b988ab404123038c1b Mon Sep 17 00:00:00 2001 +From: Brett Warren +Date: Tue, 3 Nov 2020 13:34:26 +0000 +Subject: [PATCH] pmf.h: made PMF_STOTE_ENABLE pass -Wtautological + +When compiling with clang, PMF_STORE_ENABLE triggers +-Wtautological-constant-compare. To mitigate, the definition +is modified cosmetically to not trigger this error. + +Upstream-Status: Pending +Signed-off-by: Brett Warren +--- + include/lib/pmf/pmf.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/lib/pmf/pmf.h b/include/lib/pmf/pmf.h +index df7c9ff31..baa2dfd60 100644 +--- a/include/lib/pmf/pmf.h ++++ b/include/lib/pmf/pmf.h +@@ -25,7 +25,7 @@ + /* + * Flags passed to PMF_REGISTER_SERVICE + */ +-#define PMF_STORE_ENABLE (1 << 0) ++#define PMF_STORE_ENABLE 1 + #define PMF_DUMP_ENABLE (1 << 1) + + /* +-- +2.17.1 + diff --git a/meta-arm/recipes-bsp/trusted-firmware-a/files/0003-xlat-tables-v2-remove-tautological-assert.patch b/meta-arm/recipes-bsp/trusted-firmware-a/files/0003-xlat-tables-v2-remove-tautological-assert.patch new file mode 100644 index 00000000..c24b1cfc --- /dev/null +++ b/meta-arm/recipes-bsp/trusted-firmware-a/files/0003-xlat-tables-v2-remove-tautological-assert.patch @@ -0,0 +1,31 @@ +From a0b72074ee4cfdf0ff3b807b01a962898761def4 Mon Sep 17 00:00:00 2001 +From: Brett Warren +Date: Fri, 27 Nov 2020 10:29:48 +0000 +Subject: [PATCH] xlat_tables_v2: remove tautological assert + +When compiling with clang for aarch32, an assert triggered +-Wtautological error. This assertion is removed, as +this means there is no way for it to resolve as false anyway. + +Upstream-Status: Pending +Signed-off-by: Brett Warren +--- + lib/xlat_tables_v2/aarch32/xlat_tables_arch.c | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/lib/xlat_tables_v2/aarch32/xlat_tables_arch.c b/lib/xlat_tables_v2/aarch32/xlat_tables_arch.c +index b69c6702b..52a75b37a 100644 +--- a/lib/xlat_tables_v2/aarch32/xlat_tables_arch.c ++++ b/lib/xlat_tables_v2/aarch32/xlat_tables_arch.c +@@ -203,8 +203,6 @@ void setup_mmu_cfg(uint64_t *params, unsigned int flags, + + assert(virtual_addr_space_size >= + xlat_get_min_virt_addr_space_size()); +- assert(virtual_addr_space_size <= +- MAX_VIRT_ADDR_SPACE_SIZE); + assert(IS_POWER_OF_TWO(virtual_addr_space_size)); + + /* +-- +2.17.1 + diff --git a/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a-2.2/0001-make-link-compiler-rt-builtins-when-32-bit-2-2.patch b/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a-2.2/0001-make-link-compiler-rt-builtins-when-32-bit-2-2.patch new file mode 100644 index 00000000..16bfcf19 --- /dev/null +++ b/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a-2.2/0001-make-link-compiler-rt-builtins-when-32-bit-2-2.patch @@ -0,0 +1,54 @@ +From f2855c0957ded1af279724c1a82c3e381cc036f9 Mon Sep 17 00:00:00 2001 +From: Brett Warren +Date: Fri, 27 Nov 2020 10:12:07 +0000 +Subject: [PATCH 3/3] make: link compiler-rt builtins when 32-bit + +Compiler-rt builtins weren't previously linked when using +GNU ld to link for aarch32; this is now explicitly linked +in. + +For use with TFA 2.2 + +Upstream-Status: Pending +Signed-off-by: Brett Warren +--- + Makefile | 9 +++++++++ + make_helpers/build_macros.mk | 2 +- + 2 files changed, 10 insertions(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index 721246d51..5bf8e9a11 100644 +--- a/Makefile ++++ b/Makefile +@@ -204,6 +204,15 @@ LD = $(LINKER) + AS = $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH)) + CPP = $(CC) -E + PP = $(CC) -E ++ ++ifeq (${ARCH},aarch32) ++RUNTIME_LIB = $(shell $(CC) --sysroot=$(RUNTIME_SYSROOT) \ ++ $(shell sed 's/none/linux/' <<< '$(target32-directive)') \ ++ -mfloat-abi=$(TARGET_FPU) \ ++ -rtlib=compiler-rt \ ++ -print-libgcc-file-name 2> /dev/null) ++endif ++ + else + TF_CFLAGS_aarch32 = $(march32-directive) + TF_CFLAGS_aarch64 = $(march64-directive) +diff --git a/make_helpers/build_macros.mk b/make_helpers/build_macros.mk +index b89d87ea6..1ff345336 100644 +--- a/make_helpers/build_macros.mk ++++ b/make_helpers/build_macros.mk +@@ -436,7 +436,7 @@ ifneq ($(findstring armlink,$(notdir $(LD))),) + else + $$(Q)$$(LD) -o $$@ $$(TF_LDFLAGS) $$(LDFLAGS) -Map=$(MAPFILE) \ + --script $(LINKERFILE) $(BUILD_DIR)/build_message.o \ +- $(OBJS) $(LDPATHS) $(LIBWRAPPER) $(LDLIBS) $(BL_LIBS) ++ $(OBJS) $(LDPATHS) $(LIBWRAPPER) $(LDLIBS) $(BL_LIBS) $(RUNTIME_LIB) + endif + ifeq ($(DISABLE_BIN_GENERATION),1) + @${ECHO_BLANK_LINE} +-- +2.17.1 + diff --git a/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a-2.3/0001-make-link-compiler-rt-builtins-when-32-bit-2-3.patch b/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a-2.3/0001-make-link-compiler-rt-builtins-when-32-bit-2-3.patch new file mode 100644 index 00000000..1c018650 --- /dev/null +++ b/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a-2.3/0001-make-link-compiler-rt-builtins-when-32-bit-2-3.patch @@ -0,0 +1,52 @@ +From 39d139a56c54856a718218e30114f732188832ea Mon Sep 17 00:00:00 2001 +From: Brett Warren +Date: Fri, 27 Nov 2020 14:41:43 +0000 +Subject: [PATCH] make: link compiler-rt builtins when 32-bit + +Compiler-rt builtins weren't previously linked when using +GNU ld to link for aarch32; this is now explicitly linked +in. + +For use with TFA 2.3 + +Upstream-Status: Pending +Signed-off-by: Brett Warren +--- + Makefile | 7 +++++++ + make_helpers/build_macros.mk | 2 +- + 2 files changed, 8 insertions(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index f01a9ae3e..493b80b14 100644 +--- a/Makefile ++++ b/Makefile +@@ -243,6 +243,13 @@ endif + AS = $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH)) + CPP = $(CC) -E + PP = $(CC) -E ++ifeq (${ARCH},aarch32) ++RUNTIME_LIB = $(shell $(CC) --sysroot=$(RUNTIME_SYSROOT) \ ++ $(shell sed 's/none/linux/' <<< '$(target32-directive)') \ ++ -mfloat-abi=$(TARGET_FPU) \ ++ -rtlib=compiler-rt \ ++ -print-libgcc-file-name 2> /dev/null) ++endif + else ifneq ($(findstring gcc,$(notdir $(CC))),) + TF_CFLAGS_aarch32 = $(march32-directive) + TF_CFLAGS_aarch64 = $(march64-directive) +diff --git a/make_helpers/build_macros.mk b/make_helpers/build_macros.mk +index 1c3d14d05..2a1abd4fe 100644 +--- a/make_helpers/build_macros.mk ++++ b/make_helpers/build_macros.mk +@@ -482,7 +482,7 @@ ifneq ($(findstring armlink,$(notdir $(LD))),) + else ifneq ($(findstring gcc,$(notdir $(LD))),) + $$(Q)$$(LD) -o $$@ $$(TF_LDFLAGS) $$(LDFLAGS) -Wl,-Map=$(MAPFILE) \ + -Wl,-T$(LINKERFILE) $(BUILD_DIR)/build_message.o \ +- $(OBJS) $(LDPATHS) $(LIBWRAPPER) $(LDLIBS) $(BL_LIBS) ++ $(OBJS) $(LDPATHS) $(LIBWRAPPER) $(LDLIBS) $(BL_LIBS) $(RUNTIME_LIB) + else + $$(Q)$$(LD) -o $$@ $$(TF_LDFLAGS) $$(LDFLAGS) $(BL_LDFLAGS) -Map=$(MAPFILE) \ + --script $(LINKERFILE) $(BUILD_DIR)/build_message.o \ +-- +2.17.1 + diff --git a/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc b/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc index 98085d0a..69d5ca8b 100644 --- a/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc +++ b/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc @@ -1,5 +1,5 @@ DESCRIPTION = "Trusted Firmware-A" -LICENSE = "BSD & Apache-2.0" +LICENSE = "BSD-3-Clause" PROVIDES = "virtual/trusted-firmware-a" @@ -7,6 +7,9 @@ PACKAGE_ARCH = "${MACHINE_ARCH}" inherit deploy +SRC_URI = "git://git.trustedfirmware.org/TF-A/trusted-firmware-a.git;protocol=https;name=tfa" +UPSTREAM_CHECK_GITTAGREGEX = "^v(?P\d+(\.\d+)+)$" + COMPATIBLE_MACHINE ?= "invalid" COMPATIBLE_MACHINE_qemuarm64 ?= "qemuarm64" @@ -19,14 +22,24 @@ TFA_PLATFORM_aarch64_qemuall ?= "qemu" TFA_BOARD ?= "" # Some platforms use SPD (Secure Payload Dispatcher) services -# Few options are "opteed", "tlkd", "trusty", "tspd"... +# Few options are "opteed", "tlkd", "trusty", "tspd", "spmd"... # Leave empty to not use SPD TFA_SPD ?= "" TFA_SPD_aarch64_qemuall ?= "opteed" +# Variable used when TFA_SPD=spmd +TFA_SPMD_SPM_AT_SEL2 ?= "1" + +# SP layout file location. Used when TFA_SPD=spmd and TFA_SPMD_SPM_AT_SEL2=1 +TFA_SP_LAYOUT_FILE ?= "" + +# SPMC manifest file location. Used when TFA_SPD=spmd and TFA_SPMD_SPM_AT_SEL2=1 +TFA_ARM_SPMC_MANIFEST_DTS ?= "" + # Build for debug (set TFA_DEBUG to 1 to activate) TFA_DEBUG ?= "0" +S = "${WORKDIR}/git" B = "${WORKDIR}/build" # mbed TLS support (set TFA_MBEDTLS to 1 to activate) @@ -39,11 +52,17 @@ SRC_URI_MBEDTLS ??= "" LIC_FILES_CHKSUM_MBEDTLS ??= "" # add MBEDTLS to our sources if activated SRC_URI_append = " ${@bb.utils.contains('TFA_MBEDTLS', '1', '${SRC_URI_MBEDTLS}', '', d)}" -# add mbed TLS chksum -LIC_FILES_CHKSUM += "${@bb.utils.contains('TFA_MBEDTLS', '1', '${LIC_FILES_CHKSUM_MBEDTLS}', '', d)}" +# Update license variables +LICENSE_append = "${@bb.utils.contains('TFA_MBEDTLS', '1', ' & Apache-2.0', '', d)}" +LIC_FILES_CHKSUM_append = "${@bb.utils.contains('TFA_MBEDTLS', '1', ' ${LIC_FILES_CHKSUM_MBEDTLS}', '', d)}" # add mbed TLS to version SRCREV_FORMAT_append = "${@bb.utils.contains('TFA_MBEDTLS', '1', '_mbedtls', '', d)}" +SRC_URI_append = " \ + file://0002-pmf.h-made-PMF_STOTE_ENABLE-pass-Wtautological.patch \ + file://0003-xlat-tables-v2-remove-tautological-assert.patch \ + " + # U-boot support (set TFA_UBOOT to 1 to activate) # When U-Boot support is activated BL33 is activated with u-boot.bin file TFA_UBOOT ?= "0" @@ -73,10 +92,14 @@ LD[unexport] = "1" # No configure do_configure[noexec] = "1" +# Baremetal, just need a compiler +DEPENDS_remove = "virtual/${TARGET_PREFIX}compilerlibs virtual/libc" + # We need dtc for dtbs compilation # We need openssl for fiptool -DEPENDS_append = " dtc-native openssl-native" +DEPENDS = "dtc-native openssl-native" DEPENDS_append_aarch64_qemuall ?= " optee-os" +DEPENDS_append_toolchain-clang = " compiler-rt" # CC and LD introduce arguments which conflict with those otherwise provided by # this recipe. The heads of these variables excluding those arguments @@ -100,6 +123,9 @@ EXTRA_OEMAKE += "${@'TARGET_BOARD=${TFA_BOARD}' if d.getVar('TFA_BOARD') else '' # Handle TFA_SPD parameter EXTRA_OEMAKE += "${@'SPD=${TFA_SPD}' if d.getVar('TFA_SPD') else ''}" +# If TFA_SPD is spmd, set SPMD_SPM_AT_SEL2 +EXTRA_OEMAKE += "${@'SPMD_SPM_AT_SEL2=${TFA_SPMD_SPM_AT_SEL2}' if d.getVar('TFA_SPD', True) == 'spmd' else ''}" + # Handle TFA_DEBUG parameter EXTRA_OEMAKE += "${@bb.utils.contains('TFA_DEBUG', '1', 'DEBUG=${TFA_DEBUG}', '', d)}" @@ -111,6 +137,25 @@ DEPENDS += " ${@bb.utils.contains('TFA_UBOOT', '1', 'u-boot', '', d)}" do_compile[depends] += " ${@bb.utils.contains('TFA_UBOOT', '1', 'u-boot:do_deploy', '', d)}" EXTRA_OEMAKE += "${@bb.utils.contains('TFA_UBOOT', '1', 'BL33=${DEPLOY_DIR_IMAGE}/u-boot.bin', '',d)}" +# Hafnium support +SEL2_SPMC = "${@'${TFA_SPMD_SPM_AT_SEL2}' if d.getVar('TFA_SPD', True) == 'spmd' else ''}" + +DEPENDS += " ${@bb.utils.contains('SEL2_SPMC', '1', 'hafnium', '', d)}" + +EXTRA_OEMAKE += "${@bb.utils.contains('SEL2_SPMC', '1', 'CTX_INCLUDE_EL2_REGS=1 ARM_ARCH_MINOR=4 BL32=${RECIPE_SYSROOT}/firmware/hafnium.bin', '', d)}" + +# Add SP layout file and spmc manifest for hafnium +EXTRA_OEMAKE += "${@bb.utils.contains('SEL2_SPMC', '1', 'SP_LAYOUT_FILE=${TFA_SP_LAYOUT_FILE}' if d.getVar('TFA_SP_LAYOUT_FILE') else '', '', d)}" + +EXTRA_OEMAKE += "${@bb.utils.contains('SEL2_SPMC', '1', 'ARM_SPMC_MANIFEST_DTS=${TFA_ARM_SPMC_MANIFEST_DTS}' if d.getVar('TFA_ARM_SPMC_MANIFEST_DTS') else '', '', d)}" + +# Tell the tools where the native OpenSSL is located +EXTRA_OEMAKE += "OPENSSL_DIR=${STAGING_DIR_NATIVE}/${prefix_native}" + +# Runtime variables +EXTRA_OEMAKE += "RUNTIME_SYSROOT=${STAGING_DIR_HOST}" +EXTRA_OEMAKE += "TARGET_FPU=${TARGET_FPU}" + EXTRA_OEMAKE_append_aarch64_qemuall = " \ BL32=${STAGING_DIR_TARGET}${nonarch_base_libdir}/firmware/tee-header_v2.bin \ BL32_EXTRA1=${STAGING_DIR_TARGET}${nonarch_base_libdir}/firmware/tee-pager_v2.bin \ @@ -131,6 +176,7 @@ do_compile() { # These changes are needed to have the native tools compiling and executing properly sed -i '/^LDLIBS/ s,$, \$\{BUILD_LDFLAGS},' ${S}/tools/fiptool/Makefile sed -i '/^INCLUDE_PATHS/ s,$, \$\{BUILD_CFLAGS},' ${S}/tools/fiptool/Makefile + # This can be removed when only TF-A 2.4 onwards is supported sed -i 's^OPENSSL_DIR.*=.*$^OPENSSL_DIR = ${STAGING_DIR_NATIVE}/${prefix_native}^' ${S}/tools/*/Makefile # Currently there are races if you build all the targets at once in parallel @@ -205,3 +251,8 @@ do_deploy() { cp -rf ${D}/firmware/* ${DEPLOYDIR}/ } addtask deploy after do_install + +CVE_PRODUCT = "arm:arm-trusted-firmware \ + arm:trusted_firmware-a \ + arm:arm_trusted_firmware \ + arm_trusted_firmware_project:arm_trusted_firmware" diff --git a/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_1.5.bb b/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_1.5.bb index 744ba8ca..56d3507e 100644 --- a/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_1.5.bb +++ b/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_1.5.bb @@ -4,17 +4,13 @@ require trusted-firmware-a.inc -SRC_URI = "git://git.trustedfirmware.org/TF-A/trusted-firmware-a.git;protocol=https;name=tfa" - # Use TF-A for version SRCREV_FORMAT = "tfa" # TF-A v1.5 SRCREV_tfa = "ed8112606c54d85781fc8429160883d6310ece32" -S = "${WORKDIR}/git" - -LIC_FILES_CHKSUM = "file://license.rst;md5=e927e02bca647e14efd87e9e914b2443" +LIC_FILES_CHKSUM += "file://license.rst;md5=e927e02bca647e14efd87e9e914b2443" # # mbed TLS source @@ -26,7 +22,7 @@ SRC_URI_MBEDTLS = "git://github.com/ARMmbed/mbedtls.git;name=mbedtls;protocol=ht # mbed TLS v2.16.2 SRCREV_mbedtls = "d81c11b8ab61fd5b2da8133aa73c5fe33a0633eb" -LIC_FILES_CHKSUM_MBEDTLS += " \ +LIC_FILES_CHKSUM_MBEDTLS = " \ file://mbedtls/apache-2.0.txt;md5=3b83ef96387f14655fc854ddc3c6bd57 \ file://mbedtls/LICENSE;md5=302d50a6369f5f22efdb674db908167a \ " diff --git a/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.1.bb b/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.1.bb deleted file mode 100644 index 1f36dbcd..00000000 --- a/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.1.bb +++ /dev/null @@ -1,32 +0,0 @@ -# -# Trusted firmware-A 2.1 -# - -require trusted-firmware-a.inc - -SRC_URI = "git://git.trustedfirmware.org/TF-A/trusted-firmware-a.git;protocol=https;name=tfa" - -# Use TF-A for version -SRCREV_FORMAT = "tfa" - -# TF-A v2.1 -SRCREV_tfa = "e1286bdb968ee74fc52f96cf303a4218e1ae2950" - -S = "${WORKDIR}/git" - -LIC_FILES_CHKSUM = "file://license.rst;md5=c709b197e22b81ede21109dbffd5f363" - -# -# mbed TLS source -# Those are used in trusted-firmware-a.inc if TFA_MBEDTLS is set to 1 -# - -SRC_URI_MBEDTLS = "git://github.com/ARMmbed/mbedtls.git;name=mbedtls;protocol=https;destsuffix=git/mbedtls;branch=mbedtls-2.16" - -# mbed TLS v2.16.2 -SRCREV_mbedtls = "d81c11b8ab61fd5b2da8133aa73c5fe33a0633eb" - -LIC_FILES_CHKSUM_MBEDTLS += " \ - file://mbedtls/apache-2.0.txt;md5=3b83ef96387f14655fc854ddc3c6bd57 \ - file://mbedtls/LICENSE;md5=302d50a6369f5f22efdb674db908167a \ - " diff --git a/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.2.bb b/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.2.bb index cd575395..f4deebb1 100644 --- a/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.2.bb +++ b/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.2.bb @@ -4,17 +4,13 @@ require trusted-firmware-a.inc -SRC_URI = "git://git.trustedfirmware.org/TF-A/trusted-firmware-a.git;protocol=https;name=tfa" - # Use TF-A for version SRCREV_FORMAT = "tfa" # TF-A v2.2 SRCREV_tfa = "7192b956bde11652a835eee0724dca0e403fee90" -S = "${WORKDIR}/git" - -LIC_FILES_CHKSUM = "file://docs/license.rst;md5=189505435dbcdcc8caa63c46fe93fa89" +LIC_FILES_CHKSUM += "file://docs/license.rst;md5=189505435dbcdcc8caa63c46fe93fa89" # # mbed TLS source @@ -23,10 +19,15 @@ LIC_FILES_CHKSUM = "file://docs/license.rst;md5=189505435dbcdcc8caa63c46fe93fa89 SRC_URI_MBEDTLS = "git://github.com/ARMmbed/mbedtls.git;name=mbedtls;protocol=https;destsuffix=git/mbedtls;branch=mbedtls-2.16" +FILESEXTRAPATHS_prepend := "${THISDIR}/${BP}:" +SRC_URI += " \ + file://0001-make-link-compiler-rt-builtins-when-32-bit-2-2.patch \ + " + # mbed TLS v2.16.2 SRCREV_mbedtls = "d81c11b8ab61fd5b2da8133aa73c5fe33a0633eb" -LIC_FILES_CHKSUM_MBEDTLS += " \ +LIC_FILES_CHKSUM_MBEDTLS = " \ file://mbedtls/apache-2.0.txt;md5=3b83ef96387f14655fc854ddc3c6bd57 \ file://mbedtls/LICENSE;md5=302d50a6369f5f22efdb674db908167a \ " diff --git a/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.3.bb b/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.3.bb index 37619f20..ffe660ba 100644 --- a/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.3.bb +++ b/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.3.bb @@ -4,17 +4,15 @@ require trusted-firmware-a.inc -SRC_URI = "git://git.trustedfirmware.org/TF-A/trusted-firmware-a.git;protocol=https;name=tfa" - # Use TF-A for version SRCREV_FORMAT = "tfa" # TF-A v2.3 SRCREV_tfa = "ecd27ad85f1eba29f6bf92c39dc002c85b07dad5" -S = "${WORKDIR}/git" +LIC_FILES_CHKSUM += "file://docs/license.rst;md5=189505435dbcdcc8caa63c46fe93fa89" -LIC_FILES_CHKSUM = "file://docs/license.rst;md5=189505435dbcdcc8caa63c46fe93fa89" +SRC_URI += "file://0001-fdts-a5ds-Fix-for-the-system-timer-issue.patch" # # mbed TLS source @@ -23,10 +21,15 @@ LIC_FILES_CHKSUM = "file://docs/license.rst;md5=189505435dbcdcc8caa63c46fe93fa89 SRC_URI_MBEDTLS = "git://github.com/ARMmbed/mbedtls.git;name=mbedtls;protocol=https;destsuffix=git/mbedtls;tag=v2.24.0" +FILESEXTRAPATHS_prepend := "${THISDIR}/${BP}:" +SRC_URI += " \ + file://0001-make-link-compiler-rt-builtins-when-32-bit-2-3.patch \ + " + # mbed TLS v2.18.1 SRCREV_mbedtls = "v2.24.0" -LIC_FILES_CHKSUM_MBEDTLS += " \ +LIC_FILES_CHKSUM_MBEDTLS = " \ file://mbedtls/apache-2.0.txt;md5=3b83ef96387f14655fc854ddc3c6bd57 \ file://mbedtls/LICENSE;md5=302d50a6369f5f22efdb674db908167a \ " diff --git a/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.4.bb b/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.4.bb new file mode 100644 index 00000000..f23132af --- /dev/null +++ b/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.4.bb @@ -0,0 +1,15 @@ +require trusted-firmware-a.inc + +# Use TF-A for version +SRCREV_FORMAT = "tfa" + +# TF-A v2.4 +SRCREV_tfa = "e2c509a39c6cc4dda8734e6509cdbe6e3603cdfc" + +LIC_FILES_CHKSUM += "file://docs/license.rst;md5=189505435dbcdcc8caa63c46fe93fa89" + +# mbed TLS v2.24.0 +SRC_URI_MBEDTLS = "git://github.com/ARMmbed/mbedtls.git;name=mbedtls;protocol=https;destsuffix=git/mbedtls;branch=master" +SRCREV_mbedtls = "523f0554b6cdc7ace5d360885c3f5bbcc73ec0e8" + +LIC_FILES_CHKSUM_MBEDTLS = "file://mbedtls/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" diff --git a/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_git.bb b/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_git.bb deleted file mode 100644 index c443ecd6..00000000 --- a/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_git.bb +++ /dev/null @@ -1,31 +0,0 @@ -# Trusted firmware-A points a commit rather a tag -# -# This is only a base receipt and should be bbextended with suitable SRCREV_tfa -# and SRCREV_MBEDTLS and target TFA_* variables - -# Never select this if another version is available -DEFAULT_PREFERENCE = "-1" - -require trusted-firmware-a.inc - -SRC_URI = "git://git.trustedfirmware.org/TF-A/trusted-firmware-a.git;protocol=https;name=tfa" - -# Use TF-A for version -SRCREV_FORMAT = "tfa" - -S = "${WORKDIR}/git" - -LIC_FILES_CHKSUM = "file://docs/license.rst;md5=189505435dbcdcc8caa63c46fe93fa89" - -# -# mbed TLS source -# Those are used in trusted-firmware-a.inc if TFA_MBEDTLS is set to 1 -# - -SRC_URI_MBEDTLS = "git://github.com/ARMmbed/mbedtls.git;name=mbedtls;protocol=https;destsuffix=git/mbedtls" - -LIC_FILES_CHKSUM_MBEDTLS += " \ - file://mbedtls/apache-2.0.txt;md5=3b83ef96387f14655fc854ddc3c6bd57 \ - file://mbedtls/LICENSE;md5=302d50a6369f5f22efdb674db908167a \ - " - diff --git a/meta-arm/recipes-bsp/trusted-firmware-m/files/objcopy.patch b/meta-arm/recipes-bsp/trusted-firmware-m/files/objcopy.patch new file mode 100644 index 00000000..5734c13a --- /dev/null +++ b/meta-arm/recipes-bsp/trusted-firmware-m/files/objcopy.patch @@ -0,0 +1,20 @@ +The BFD target elf32-little has no specified machine, which trips the +architecture sanity test. Use elf32-littlearm to set the machine +correctly. + +Upstream-Status: Backport +Signed-off-by: Ross Burton + +diff --git a/cmake/Common/CompilerGNUARMCommon.cmake b/cmake/Common/CompilerGNUARMCommon.cmake +index 32e805bb..2d3ea8e4 100644 +--- a/cmake/Common/CompilerGNUARMCommon.cmake ++++ b/cmake/Common/CompilerGNUARMCommon.cmake +@@ -196,7 +196,7 @@ function(compiler_generate_hex_output TARGET) + endfunction() + + function(compiler_generate_elf_output TARGET) +- add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_GNUARM_OBJCOPY} ARGS -O elf32-little $ $/${TARGET}.elf) ++ add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_GNUARM_OBJCOPY} ARGS -O elf32-littlearm $ $/${TARGET}.elf) + endfunction() + + # Function for creating a new target that preprocesses a .c file diff --git a/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.0.bb b/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.1.bb similarity index 64% rename from meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.0.bb rename to meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.1.bb index 80df2f10..17c3f4bf 100644 --- a/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.0.bb +++ b/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.1.bb @@ -10,23 +10,27 @@ PROVIDES = "virtual/trusted-firmware-m" LICENSE = "BSD-3-Clause & Apachev2" -LIC_FILES_CHKSUM ?= "file://license.rst;md5=07f368487da347f3c7bd0fc3085f3afa" -LIC_FILES_CHKSUM += "file://../mbed-crypto/LICENSE;md5=302d50a6369f5f22efdb674db908167a" -LIC_FILES_CHKSUM += "file://../CMSIS_5/LICENSE.txt;md5=c4082b6c254c9fb71136710391d9728b" +LIC_FILES_CHKSUM = "file://license.rst;md5=07f368487da347f3c7bd0fc3085f3afa \ + file://../tf-m-tests/license.rst;md5=02d06ffb8d9f099ff4961c0cb0183a18 \ + file://../mbed-crypto/LICENSE;md5=302d50a6369f5f22efdb674db908167a \ + file://../mcuboot/LICENSE;md5=b6ee33f1d12a5e6ee3de1e82fb51eeb8" -SRC_URI = "git://git.trustedfirmware.org/trusted-firmware-m.git;protocol=https;branch=master;name=tfm;destsuffix=${S}" -SRC_URI += "git://github.com/ARMmbed/mbed-crypto.git;protocol=https;branch=development;name=mbed-crypto;destsuffix=${S}/../mbed-crypto" -SRC_URI += "https://github.com/ARM-software/CMSIS_5/releases/download/5.5.0/ARM.CMSIS.5.5.0.pack;name=cmsis;subdir=${S}/../CMSIS_5;downloadfilename=ARM.CMSIS.5.5.0.zip" +SRC_URI = "git://git.trustedfirmware.org/TF-M/trusted-firmware-m.git;protocol=https;branch=master;name=tfm;destsuffix=${S} \ + git://git.trustedfirmware.org/TF-M/tf-m-tests.git;protocol=https;branch=master;name=tfm-tests;destsuffix=${S}/../tf-m-tests \ + git://github.com/ARMmbed/mbed-crypto.git;protocol=https;branch=development;name=mbed-crypto;destsuffix=${S}/../mbed-crypto \ + git://github.com/JuulLabs-OSS/mcuboot.git;protocol=https;name=mcuboot;destsuffix=${S}/../mcuboot \ + file://objcopy.patch" -SRC_URI[cmsis.md5sum] = "73b6cf6b4ab06ac099478e6cf983c08e" -SRC_URI[cmsis.sha256sum] = "fc6e46c77de29ed05ef3bfd4846a2da49b024bc8854c876ac053aaa8d348ac52" - -SRCREV_FORMAT = "tfm_mbed-crypto_cmsis" -# TF-Mv1.0 -SRCREV_tfm = "0768982ea41b5e7d207445f19ee23e5d67d9c89b" +# TF-Mv1.1 +SRCREV_tfm = "a6b336c1509fd5f5522450e3cec0fcd6c060f9c8" # mbedcrypto-3.0.1 SRCREV_mbed-crypto = "1146b4e06011b69a6437e6b728f2af043a06ec19" -SRCREV_cmsis = "5.5.0" +# TF-Mv1.1 +SRCREV_tfm-tests = "5a571808e7841f15cc966661a64dd6adb3b40f6c" +# v1.6.0 +SRCREV_mcuboot = "50d24a57516f558dac72bef634723b60c5cfb46b" + +UPSTREAM_CHECK_GITTAGREGEX = "^TF-Mv(?P\d+(\.\d+)+)$" # Note to future readers of this recipe: until the CMakeLists don't abuse # installation (see do_install) there is no point in trying to inherit @@ -35,23 +39,30 @@ SRCREV_cmsis = "5.5.0" inherit python3native deploy -TFM_DEPENDS ?= "" -DEPENDS += "${TFM_DEPENDS}" -DEPENDS += "cmake-native" -DEPENDS += "python3-cryptography-native python3-pyasn1-native" -DEPENDS += "python3-cbor-native" +# Baremetal and we bring a compiler below +INHIBIT_DEFAULT_DEPS = "1" + +PACKAGE_ARCH = "${MACHINE_ARCH}" + +DEPENDS += "cmake-native \ + python3-cryptography-native \ + python3-pyasn1-native \ + python3-cbor-native" S = "${WORKDIR}/git/tfm" B = "${WORKDIR}/build" -COMPATIBLE_MACHINE ?= "invalid" - # Build for debug (set TFA_DEBUG to 1 to activate) TFM_DEBUG ?= "0" # Set target config TFM_CONFIG ?= "ConfigDefault.cmake" -# Platform must be set for each machine -TFM_PLATFORM ?= "invalid" + +# Platform must be set, ideally in the machine configuration. +TFM_PLATFORM ?= "" +python() { + if not d.getVar("TFM_PLATFORM"): + raise bb.parse.SkipRecipe("TFM_PLATFORM needs to be set") +} # Uncomment, or copy these lines to your local.conf to use the Arm Clang compiler # from meta-arm-toolchain. @@ -75,16 +86,15 @@ EXTRA_OECMAKE += "-DCOMPILER=${TFM_COMPILER}" EXTRA_OECMAKE += "${@bb.utils.contains('TFM_DEBUG', '1', '-DCMAKE_BUILD_TYPE=Debug', '', d)}" EXTRA_OECMAKE += "-DPROJ_CONFIG=${S}/configs/${TFM_CONFIG}" +# Verbose builds +EXTRA_OECMAKE += "-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON" + # Let the Makefile handle setting up the CFLAGS and LDFLAGS as it is a standalone application CFLAGS[unexport] = "1" LDFLAGS[unexport] = "1" AS[unexport] = "1" LD[unexport] = "1" -# This is needed because CMSIS_5 source package originally has .pack extension not .zip -# and bitbake checks this dependency based on file extension -do_unpack[depends] += "unzip-native:do_populate_sysroot" - do_configure[prefuncs] += "do_check_config" do_check_config() { if [ ! -f "${S}/configs/${TFM_CONFIG}" ]; then @@ -94,7 +104,7 @@ do_check_config() { do_configure[cleandirs] = "${B}" do_configure() { - cmake -G"Unix Makefiles" --build ${S} ${EXTRA_OECMAKE} + cmake -G"Unix Makefiles" ${S} ${EXTRA_OECMAKE} } # Invoke install here as there's no point in splitting compile from install: the @@ -102,7 +112,7 @@ do_configure() { # rebuild. It also overrides the install prefix to be in the build tree, so you # can't use the usual install prefix variables. do_compile() { - oe_runmake install + cmake --build ./ -- install } do_install() { diff --git a/meta-arm/recipes-bsp/uefi/edk2-firmware_git.bb b/meta-arm/recipes-bsp/uefi/edk2-firmware.inc similarity index 69% rename from meta-arm/recipes-bsp/uefi/edk2-firmware_git.bb rename to meta-arm/recipes-bsp/uefi/edk2-firmware.inc index 39a041f1..1160c3a4 100644 --- a/meta-arm/recipes-bsp/uefi/edk2-firmware_git.bb +++ b/meta-arm/recipes-bsp/uefi/edk2-firmware.inc @@ -11,22 +11,28 @@ LIC_FILES_CHKSUM = "file://License.txt;md5=2b415520383f7964e96700ae12b4570a" # EDK2 Platforms LIC_FILES_CHKSUM += "file://edk2-platforms/License.txt;md5=2b415520383f7964e96700ae12b4570a" -SRC_URI = "\ - gitsm://github.com/tianocore/edk2.git;name=edk2;destsuffix=edk2;nobranch=1 \ - git://github.com/tianocore/edk2-platforms.git;name=edk2-platforms;destsuffix=edk2/edk2-platforms;nobranch=1 \ -" -SRCREV_edk2 ?= "6ff7c838d09224dd4e4c9b5b93152d8db1b19740" -SRCREV_edk2-platforms ?= "ed4cc8059ec551032f0d8b8c172e9ec19214a638" -SRCREV_FORMAT = "edk2_edk2-platforms" +# These can be overridden as needed +EDK2_SRC_URI = "gitsm://github.com/tianocore/edk2.git" +EDK2_PLATFORMS_SRC_URI = "git://github.com/tianocore/edk2-platforms.git" -EDK2_BUILD_RELEASE ?= "0" -EDK2_PLATFORM ?= "invalid" -EDK2_PLATFORM_DSC ?= "" -EDK2_BIN_NAME ?= "" -EDK2_ARCH ?= "" +SRC_URI = "\ + ${EDK2_SRC_URI};name=edk2;destsuffix=edk2;nobranch=1 \ + ${EDK2_PLATFORMS_SRC_URI};name=edk2-platforms;destsuffix=edk2/edk2-platforms;nobranch=1 \ +" + +SRCREV_FORMAT = "edk2_edk2-platforms" +UPSTREAM_CHECK_GITTAGREGEX = "^edk2-stable(?P\d+)$" + +EDK2_BUILD_RELEASE ?= "1" +EDK2_PLATFORM ?= "ArmVirtQemu-AARCH64" +EDK2_PLATFORM_DSC ?= "ArmVirtPkg/ArmVirtQemu.dsc" +EDK2_BIN_NAME ?= "QEMU_EFI.fd" +EDK2_ARCH ?= "AARCH64" EDK2_BUILD_MODE = "${@bb.utils.contains('EDK2_BUILD_RELEASE', '1', 'RELEASE', 'DEBUG', d)}" +# Baremetal, no need for a C library +DEPENDS_remove = "virtual/${TARGET_PREFIX}compilerlibs virtual/libc" DEPENDS += "util-linux-native iasl-native" inherit deploy @@ -35,7 +41,7 @@ S = "${WORKDIR}/edk2" B = "${WORKDIR}/build" PACKAGE_ARCH = "${MACHINE_ARCH}" -COMPATIBLE_MACHINE ?= "invalid" +COMPATIBLE_MACHINE ?= "qemuarm64" LDFLAGS[unexport] = "1" @@ -51,7 +57,8 @@ export CONF_PATH = "${S}/Conf" export BTOOLS_PATH = "${EDK_TOOLS_PATH}/BinWrappers/PosixLike" -GCC_VER ?= "GCC5" +EDK_COMPILER ?= "GCC5" +EDK_COMPILER_toolchain-clang = "CLANG38" do_compile() { sed -i -e 's:-I \.\.:-I \.\. ${BUILD_CFLAGS} :' ${EDK_TOOLS_PATH}/Source/C/Makefiles/header.makefile @@ -69,13 +76,13 @@ do_compile() { "${S}/BaseTools/BinWrappers/PosixLike/build" \ -a "${EDK2_ARCH}" \ -b ${EDK2_BUILD_MODE} \ - -t ${GCC_VER} \ - -p "${S}/edk2-platforms/Platform/ARM/${EDK2_PLATFORM_DSC}" + -t ${EDK_COMPILER} \ + -p ${EDK2_PLATFORM_DSC} } do_install() { install -d ${D}/firmware - install ${B}/Build/${EDK2_PLATFORM}/${EDK2_BUILD_MODE}_${GCC_VER}/FV/${EDK2_BIN_NAME} ${D}/firmware/uefi.bin + install ${B}/Build/${EDK2_PLATFORM}/${EDK2_BUILD_MODE}_${EDK_COMPILER}/FV/${EDK2_BIN_NAME} ${D}/firmware/uefi.bin } FILES_${PN} = "/firmware" diff --git a/meta-arm/recipes-bsp/uefi/edk2-firmware_201911.bb b/meta-arm/recipes-bsp/uefi/edk2-firmware_201911.bb new file mode 100644 index 00000000..1ff24ff5 --- /dev/null +++ b/meta-arm/recipes-bsp/uefi/edk2-firmware_201911.bb @@ -0,0 +1,5 @@ +SRCREV_edk2 ?= "bd85bf54c268204c7a698a96f3ccd96cd77952cd" +SRCREV_edk2-platforms ?= "46df7b29afeb846ee664e48949f9c8161abf1f2f" + +require edk2-firmware.inc + diff --git a/meta-arm/recipes-bsp/uefi/edk2-firmware_202011.bb b/meta-arm/recipes-bsp/uefi/edk2-firmware_202011.bb new file mode 100644 index 00000000..94310e3d --- /dev/null +++ b/meta-arm/recipes-bsp/uefi/edk2-firmware_202011.bb @@ -0,0 +1,4 @@ +SRCREV_edk2 ?= "872f953262d68a11da7bc2fb3ded16df234b8700" +SRCREV_edk2-platforms ?= "3f71a8fb114ae9ce87281eb30ab0e678f6806b05" + +require edk2-firmware.inc diff --git a/meta-arm/recipes-devtools/opencsd/opencsd_0.14.2.bb b/meta-arm/recipes-devtools/opencsd/opencsd_0.14.2.bb deleted file mode 100644 index f321c7d7..00000000 --- a/meta-arm/recipes-devtools/opencsd/opencsd_0.14.2.bb +++ /dev/null @@ -1,31 +0,0 @@ -SUMMARY = "OpenCSD - An open source CoreSight(tm) Trace Decode library" -HOMEPAGE = "https://github.com/Linaro/OpenCSD" -LICENSE = "BSD-3-Clause" -LIC_FILES_CHKSUM = "file://LICENSE;md5=ad8cb685eb324d2fa2530b985a43f3e5" - -SRC_URI = "git://github.com/Linaro/OpenCSD;protocol=http;branch=master" -SRCREV = "afdea70b2cafa20837703c387d33cd6776c6d16a" - -S = "${WORKDIR}/git" - -COMPATIBLE_HOST = "(x86_64.*|aarch64.*)-linux" - -EXTRA_OEMAKE = "ARCH='${TARGET_ARCH}' \ - CROSS_COMPILE='${TARGET_SYS}-' \ - CC='${CC}' \ - CXX='${CXX}' \ - LIB='${AR}' \ - LINKER='${CXX}' \ - LINUX64=1 \ - DEBUG=1 \ - " - -do_compile() { - oe_runmake -C ${S}/decoder/build/linux ${EXTRA_OEMAKE} -} - -do_install() { - oe_runmake -C ${S}/decoder/build/linux PREFIX=${D}/usr install -} - -BBCLASSEXTEND = "native" diff --git a/meta-arm/recipes-devtools/opencsd/opencsd_1.0.0.bb b/meta-arm/recipes-devtools/opencsd/opencsd_1.0.0.bb new file mode 100644 index 00000000..cb75ce1a --- /dev/null +++ b/meta-arm/recipes-devtools/opencsd/opencsd_1.0.0.bb @@ -0,0 +1,38 @@ +SUMMARY = "OpenCSD - An open source CoreSight(tm) Trace Decode library" +HOMEPAGE = "https://github.com/Linaro/OpenCSD" +LICENSE = "BSD-3-Clause" +LIC_FILES_CHKSUM = "file://LICENSE;md5=ad8cb685eb324d2fa2530b985a43f3e5" + +SRC_URI = "git://github.com/Linaro/OpenCSD;protocol=https" +SRCREV = "01d44a34f8fc057f4b041c01f8d9502d77fe612f" + +S = "${WORKDIR}/git" + +COMPATIBLE_HOST = "(i.86|x86_64|arm|aarch64).*-linux" + +EXTRA_OEMAKE = "ARCH='${TARGET_ARCH}' \ + CROSS_COMPILE='${TARGET_SYS}-' \ + CC='${CC}' \ + CXX='${CXX}' \ + LIB='${AR}' \ + LINKER='${CXX}' \ + LINUX64=1 \ + DEBUG=1 \ + PREFIX=${D}/usr \ + INSTALL_BIN_DIR=${D}${bindir} \ + INSTALL_INCLUDE_DIR=${D}${includedir} \ + INSTALL_LIB_DIR=${D}${libdir} \ + INSTALL_MAN_DIR=${D}${mandir}/man1 \ + " + +do_compile() { + oe_runmake -C ${S}/decoder/build/linux +} + +do_install() { + # Remove mkdir when upgrading (https://github.com/Linaro/OpenCSD/pull/36) + mkdir --parents ${D}${mandir}/man1 + oe_runmake -C ${S}/decoder/build/linux install install_man +} + +BBCLASSEXTEND = "native" diff --git a/meta-arm/recipes-devtools/python/python3-cbor_1.0.0.bb b/meta-arm/recipes-devtools/python/python3-cbor_1.0.0.bb index 7c529f30..1df062bc 100644 --- a/meta-arm/recipes-devtools/python/python3-cbor_1.0.0.bb +++ b/meta-arm/recipes-devtools/python/python3-cbor_1.0.0.bb @@ -2,7 +2,9 @@ DESCRIPTION = "An implementation of RFC 7049 - Concise Binary Object Representat HOMEPAGE = "https://github.com/brianolson/cbor_py" LICENSE = "Apache-2.0" -LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" +# Use a line from setup.py until LICENSE is distributed +# (https://github.com/brianolson/cbor_py/issues/20) +LIC_FILES_CHKSUM = "file://setup.py;beginline=88;endline=88;md5=267392b618a88b03e5987f69d9b98699" SRC_URI[md5sum] = "22b03b59784fd78cb6c27aa498af0db6" SRC_URI[sha256sum] = "13225a262ddf5615cbd9fd55a76a0d53069d18b07d2e9f19c39e6acb8609bbb6" diff --git a/meta-arm/recipes-kernel/linux/linux-arm64-ack/0001-perf-cs-etm-Move-definition-of-traceid_list-global-v.patch b/meta-arm/recipes-kernel/linux/linux-arm64-ack/0001-perf-cs-etm-Move-definition-of-traceid_list-global-v.patch new file mode 100644 index 00000000..94ab4357 --- /dev/null +++ b/meta-arm/recipes-kernel/linux/linux-arm64-ack/0001-perf-cs-etm-Move-definition-of-traceid_list-global-v.patch @@ -0,0 +1,69 @@ +Upstream-Status: Backport +Signed-off-by: Ross Burton + +From 28c69b683210b5d5321ceb71e44a77bc31a32c8a Mon Sep 17 00:00:00 2001 +From: Leo Yan +Date: Tue, 5 May 2020 21:36:42 +0800 +Subject: [PATCH 1/4] perf cs-etm: Move definition of 'traceid_list' global + variable from header file + +The variable 'traceid_list' is defined in the header file cs-etm.h, +if multiple C files include cs-etm.h the compiler might complaint for +multiple definition of 'traceid_list'. + +To fix multiple definition error, move the definition of 'traceid_list' +into cs-etm.c. + +Fixes: cd8bfd8c973e ("perf tools: Add processing of coresight metadata") +Reported-by: Thomas Backlund +Signed-off-by: Leo Yan +Reviewed-by: Mathieu Poirier +Reviewed-by: Mike Leach +Tested-by: Mike Leach +Tested-by: Thomas Backlund +Cc: Alexander Shishkin +Cc: Jiri Olsa +Cc: Mark Rutland +Cc: Namhyung Kim +Cc: Peter Zijlstra +Cc: Suzuki Poulouse +Cc: Tor Jeremiassen +Cc: linux-arm-kernel@lists.infradead.org +Link: http://lore.kernel.org/lkml/20200505133642.4756-1-leo.yan@linaro.org +Signed-off-by: Arnaldo Carvalho de Melo +--- + tools/perf/util/cs-etm.c | 3 +++ + tools/perf/util/cs-etm.h | 3 --- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c +index f5f855fff412..50de6a1ed0ce 100644 +--- a/tools/perf/util/cs-etm.c ++++ b/tools/perf/util/cs-etm.c +@@ -94,6 +94,9 @@ struct cs_etm_queue { + struct cs_etm_traceid_queue **traceid_queues; + }; + ++/* RB tree for quick conversion between traceID and metadata pointers */ ++static struct intlist *traceid_list; ++ + static int cs_etm__update_queues(struct cs_etm_auxtrace *etm); + static int cs_etm__process_queues(struct cs_etm_auxtrace *etm); + static int cs_etm__process_timeless_queues(struct cs_etm_auxtrace *etm, +diff --git a/tools/perf/util/cs-etm.h b/tools/perf/util/cs-etm.h +index 650ecc2a6349..4ad925d6d799 100644 +--- a/tools/perf/util/cs-etm.h ++++ b/tools/perf/util/cs-etm.h +@@ -114,9 +114,6 @@ enum cs_etm_isa { + CS_ETM_ISA_T32, + }; + +-/* RB tree for quick conversion between traceID and metadata pointers */ +-struct intlist *traceid_list; +- + struct cs_etm_queue; + + struct cs_etm_packet { +-- +2.25.1 + diff --git a/meta-arm/recipes-kernel/linux/linux-arm64-ack/0002-perf-tests-bp_account-Make-global-variable-static.patch b/meta-arm/recipes-kernel/linux/linux-arm64-ack/0002-perf-tests-bp_account-Make-global-variable-static.patch new file mode 100644 index 00000000..142d4b7c --- /dev/null +++ b/meta-arm/recipes-kernel/linux/linux-arm64-ack/0002-perf-tests-bp_account-Make-global-variable-static.patch @@ -0,0 +1,43 @@ +Upstream-Status: Backport +Signed-off-by: Ross Burton + +From b28dc646b4c5cd3844bd591af841494dd1de0a9f Mon Sep 17 00:00:00 2001 +From: Arnaldo Carvalho de Melo +Date: Mon, 2 Mar 2020 11:13:19 -0300 +Subject: [PATCH 2/4] perf tests bp_account: Make global variable static + +To fix the build with newer gccs, that without this patch exit with: + + LD /tmp/build/perf/tests/perf-in.o + ld: /tmp/build/perf/tests/bp_account.o:/git/perf/tools/perf/tests/bp_account.c:22: multiple definition of `the_var'; /tmp/build/perf/tests/bp_signal.o:/git/perf/tools/perf/tests/bp_signal.c:38: first defined here + make[4]: *** [/git/perf/tools/build/Makefile.build:145: /tmp/build/perf/tests/perf-in.o] Error 1 + +First noticed in fedora:rawhide/32 with: + + [perfbuilder@a5ff49d6e6e4 ~]$ gcc --version + gcc (GCC) 10.0.1 20200216 (Red Hat 10.0.1-0.8) + +Reported-by: Jiri Olsa +Cc: Adrian Hunter +Cc: Namhyung Kim +Signed-off-by: Arnaldo Carvalho de Melo +--- + tools/perf/tests/bp_account.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/perf/tests/bp_account.c b/tools/perf/tests/bp_account.c +index 016bba2c142d..55a9de311d7b 100644 +--- a/tools/perf/tests/bp_account.c ++++ b/tools/perf/tests/bp_account.c +@@ -23,7 +23,7 @@ + #include "../perf-sys.h" + #include "cloexec.h" + +-volatile long the_var; ++static volatile long the_var; + + static noinline int test_function(void) + { +-- +2.25.1 + diff --git a/meta-arm/recipes-kernel/linux/linux-arm64-ack/0003-perf-bench-Share-some-global-variables-to-fix-build-.patch b/meta-arm/recipes-kernel/linux/linux-arm64-ack/0003-perf-bench-Share-some-global-variables-to-fix-build-.patch new file mode 100644 index 00000000..965cc384 --- /dev/null +++ b/meta-arm/recipes-kernel/linux/linux-arm64-ack/0003-perf-bench-Share-some-global-variables-to-fix-build-.patch @@ -0,0 +1,240 @@ +Upstream-Status: Backport +Signed-off-by: Ross Burton + +From e6ae6031755b6781af42af28f11186bb18e94842 Mon Sep 17 00:00:00 2001 +From: Arnaldo Carvalho de Melo +Date: Mon, 2 Mar 2020 12:09:38 -0300 +Subject: [PATCH 3/4] perf bench: Share some global variables to fix build with + gcc 10 + +Noticed with gcc 10 (fedora rawhide) that those variables were not being +declared as static, so end up with: + + ld: /tmp/build/perf/bench/epoll-wait.o:/git/perf/tools/perf/bench/epoll-wait.c:93: multiple definition of `end'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here + ld: /tmp/build/perf/bench/epoll-wait.o:/git/perf/tools/perf/bench/epoll-wait.c:93: multiple definition of `start'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here + ld: /tmp/build/perf/bench/epoll-wait.o:/git/perf/tools/perf/bench/epoll-wait.c:93: multiple definition of `runtime'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here + ld: /tmp/build/perf/bench/epoll-ctl.o:/git/perf/tools/perf/bench/epoll-ctl.c:38: multiple definition of `end'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here + ld: /tmp/build/perf/bench/epoll-ctl.o:/git/perf/tools/perf/bench/epoll-ctl.c:38: multiple definition of `start'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here + ld: /tmp/build/perf/bench/epoll-ctl.o:/git/perf/tools/perf/bench/epoll-ctl.c:38: multiple definition of `runtime'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here + make[4]: *** [/git/perf/tools/build/Makefile.build:145: /tmp/build/perf/bench/perf-in.o] Error 1 + +Prefix those with bench__ and add them to bench/bench.h, so that we can +share those on the tools needing to access those variables from signal +handlers. + +Acked-by: Thomas Gleixner +Cc: Adrian Hunter +Cc: Davidlohr Bueso +Cc: Jiri Olsa +Cc: Namhyung Kim +Link: http://lore.kernel.org/lkml/20200303155811.GD13702@kernel.org +Signed-off-by: Arnaldo Carvalho de Melo +--- + tools/perf/bench/bench.h | 4 ++++ + tools/perf/bench/epoll-ctl.c | 7 +++---- + tools/perf/bench/epoll-wait.c | 11 +++++------ + tools/perf/bench/futex-hash.c | 12 ++++++------ + tools/perf/bench/futex-lock-pi.c | 11 +++++------ + 5 files changed, 23 insertions(+), 22 deletions(-) + +diff --git a/tools/perf/bench/bench.h b/tools/perf/bench/bench.h +index fddb3ced9db6..4aa6de1aa67d 100644 +--- a/tools/perf/bench/bench.h ++++ b/tools/perf/bench/bench.h +@@ -2,6 +2,10 @@ + #ifndef BENCH_H + #define BENCH_H + ++#include ++ ++extern struct timeval bench__start, bench__end, bench__runtime; ++ + /* + * The madvise transparent hugepage constants were added in glibc + * 2.13. For compatibility with older versions of glibc, define these +diff --git a/tools/perf/bench/epoll-ctl.c b/tools/perf/bench/epoll-ctl.c +index bb617e568841..a7526c05df38 100644 +--- a/tools/perf/bench/epoll-ctl.c ++++ b/tools/perf/bench/epoll-ctl.c +@@ -35,7 +35,6 @@ + + static unsigned int nthreads = 0; + static unsigned int nsecs = 8; +-struct timeval start, end, runtime; + static bool done, __verbose, randomize; + + /* +@@ -94,8 +93,8 @@ static void toggle_done(int sig __maybe_unused, + { + /* inform all threads that we're done for the day */ + done = true; +- gettimeofday(&end, NULL); +- timersub(&end, &start, &runtime); ++ gettimeofday(&bench__end, NULL); ++ timersub(&bench__end, &bench__start, &bench__runtime); + } + + static void nest_epollfd(void) +@@ -361,7 +360,7 @@ int bench_epoll_ctl(int argc, const char **argv) + + threads_starting = nthreads; + +- gettimeofday(&start, NULL); ++ gettimeofday(&bench__start, NULL); + + do_threads(worker, cpu); + +diff --git a/tools/perf/bench/epoll-wait.c b/tools/perf/bench/epoll-wait.c +index 7af694437f4e..d1c5cb526b9f 100644 +--- a/tools/perf/bench/epoll-wait.c ++++ b/tools/perf/bench/epoll-wait.c +@@ -90,7 +90,6 @@ + + static unsigned int nthreads = 0; + static unsigned int nsecs = 8; +-struct timeval start, end, runtime; + static bool wdone, done, __verbose, randomize, nonblocking; + + /* +@@ -276,8 +275,8 @@ static void toggle_done(int sig __maybe_unused, + { + /* inform all threads that we're done for the day */ + done = true; +- gettimeofday(&end, NULL); +- timersub(&end, &start, &runtime); ++ gettimeofday(&bench__end, NULL); ++ timersub(&bench__end, &bench__start, &bench__runtime); + } + + static void print_summary(void) +@@ -287,7 +286,7 @@ static void print_summary(void) + + printf("\nAveraged %ld operations/sec (+- %.2f%%), total secs = %d\n", + avg, rel_stddev_stats(stddev, avg), +- (int) runtime.tv_sec); ++ (int)bench__runtime.tv_sec); + } + + static int do_threads(struct worker *worker, struct perf_cpu_map *cpu) +@@ -479,7 +478,7 @@ int bench_epoll_wait(int argc, const char **argv) + + threads_starting = nthreads; + +- gettimeofday(&start, NULL); ++ gettimeofday(&bench__start, NULL); + + do_threads(worker, cpu); + +@@ -519,7 +518,7 @@ int bench_epoll_wait(int argc, const char **argv) + qsort(worker, nthreads, sizeof(struct worker), cmpworker); + + for (i = 0; i < nthreads; i++) { +- unsigned long t = worker[i].ops/runtime.tv_sec; ++ unsigned long t = worker[i].ops / bench__runtime.tv_sec; + + update_stats(&throughput_stats, t); + +diff --git a/tools/perf/bench/futex-hash.c b/tools/perf/bench/futex-hash.c +index 8ba0c3330a9a..21776862e940 100644 +--- a/tools/perf/bench/futex-hash.c ++++ b/tools/perf/bench/futex-hash.c +@@ -37,7 +37,7 @@ static unsigned int nfutexes = 1024; + static bool fshared = false, done = false, silent = false; + static int futex_flag = 0; + +-struct timeval start, end, runtime; ++struct timeval bench__start, bench__end, bench__runtime; + static pthread_mutex_t thread_lock; + static unsigned int threads_starting; + static struct stats throughput_stats; +@@ -103,8 +103,8 @@ static void toggle_done(int sig __maybe_unused, + { + /* inform all threads that we're done for the day */ + done = true; +- gettimeofday(&end, NULL); +- timersub(&end, &start, &runtime); ++ gettimeofday(&bench__end, NULL); ++ timersub(&bench__end, &bench__start, &bench__runtime); + } + + static void print_summary(void) +@@ -114,7 +114,7 @@ static void print_summary(void) + + printf("%sAveraged %ld operations/sec (+- %.2f%%), total secs = %d\n", + !silent ? "\n" : "", avg, rel_stddev_stats(stddev, avg), +- (int) runtime.tv_sec); ++ (int)bench__runtime.tv_sec); + } + + int bench_futex_hash(int argc, const char **argv) +@@ -161,7 +161,7 @@ int bench_futex_hash(int argc, const char **argv) + + threads_starting = nthreads; + pthread_attr_init(&thread_attr); +- gettimeofday(&start, NULL); ++ gettimeofday(&bench__start, NULL); + for (i = 0; i < nthreads; i++) { + worker[i].tid = i; + worker[i].futex = calloc(nfutexes, sizeof(*worker[i].futex)); +@@ -204,7 +204,7 @@ int bench_futex_hash(int argc, const char **argv) + pthread_mutex_destroy(&thread_lock); + + for (i = 0; i < nthreads; i++) { +- unsigned long t = worker[i].ops/runtime.tv_sec; ++ unsigned long t = worker[i].ops / bench__runtime.tv_sec; + update_stats(&throughput_stats, t); + if (!silent) { + if (nfutexes == 1) +diff --git a/tools/perf/bench/futex-lock-pi.c b/tools/perf/bench/futex-lock-pi.c +index d0cae8125423..30d97121dc4f 100644 +--- a/tools/perf/bench/futex-lock-pi.c ++++ b/tools/perf/bench/futex-lock-pi.c +@@ -37,7 +37,6 @@ static bool silent = false, multi = false; + static bool done = false, fshared = false; + static unsigned int nthreads = 0; + static int futex_flag = 0; +-struct timeval start, end, runtime; + static pthread_mutex_t thread_lock; + static unsigned int threads_starting; + static struct stats throughput_stats; +@@ -64,7 +63,7 @@ static void print_summary(void) + + printf("%sAveraged %ld operations/sec (+- %.2f%%), total secs = %d\n", + !silent ? "\n" : "", avg, rel_stddev_stats(stddev, avg), +- (int) runtime.tv_sec); ++ (int)bench__runtime.tv_sec); + } + + static void toggle_done(int sig __maybe_unused, +@@ -73,8 +72,8 @@ static void toggle_done(int sig __maybe_unused, + { + /* inform all threads that we're done for the day */ + done = true; +- gettimeofday(&end, NULL); +- timersub(&end, &start, &runtime); ++ gettimeofday(&bench__end, NULL); ++ timersub(&bench__end, &bench__start, &bench__runtime); + } + + static void *workerfn(void *arg) +@@ -185,7 +184,7 @@ int bench_futex_lock_pi(int argc, const char **argv) + + threads_starting = nthreads; + pthread_attr_init(&thread_attr); +- gettimeofday(&start, NULL); ++ gettimeofday(&bench__start, NULL); + + create_threads(worker, thread_attr, cpu); + pthread_attr_destroy(&thread_attr); +@@ -211,7 +210,7 @@ int bench_futex_lock_pi(int argc, const char **argv) + pthread_mutex_destroy(&thread_lock); + + for (i = 0; i < nthreads; i++) { +- unsigned long t = worker[i].ops/runtime.tv_sec; ++ unsigned long t = worker[i].ops / bench__runtime.tv_sec; + + update_stats(&throughput_stats, t); + if (!silent) +-- +2.25.1 + diff --git a/meta-arm/recipes-kernel/linux/linux-arm64-ack/0004-libtraceevent-Fix-build-with-binutils-2.35.patch b/meta-arm/recipes-kernel/linux/linux-arm64-ack/0004-libtraceevent-Fix-build-with-binutils-2.35.patch new file mode 100644 index 00000000..5e181577 --- /dev/null +++ b/meta-arm/recipes-kernel/linux/linux-arm64-ack/0004-libtraceevent-Fix-build-with-binutils-2.35.patch @@ -0,0 +1,39 @@ +Upstream-Status: Backport +Signed-off-by: Ross Burton + +From c2c2c58915def6cda401d1782048d23b2b02ed85 Mon Sep 17 00:00:00 2001 +From: Ben Hutchings +Date: Sat, 25 Jul 2020 02:06:23 +0100 +Subject: [PATCH 4/4] libtraceevent: Fix build with binutils 2.35 + +In binutils 2.35, 'nm -D' changed to show symbol versions along with +symbol names, with the usual @@ separator. When generating +libtraceevent-dynamic-list we need just the names, so strip off the +version suffix if present. + +Signed-off-by: Ben Hutchings +Tested-by: Salvatore Bonaccorso +Reviewed-by: Steven Rostedt +Cc: linux-trace-devel@vger.kernel.org +Cc: stable@vger.kernel.org +Signed-off-by: Arnaldo Carvalho de Melo +--- + tools/lib/traceevent/plugins/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/lib/traceevent/plugins/Makefile b/tools/lib/traceevent/plugins/Makefile +index f440989fa55e..23c3535bcbd6 100644 +--- a/tools/lib/traceevent/plugins/Makefile ++++ b/tools/lib/traceevent/plugins/Makefile +@@ -196,7 +196,7 @@ define do_generate_dynamic_list_file + xargs echo "U w W" | tr 'w ' 'W\n' | sort -u | xargs echo`;\ + if [ "$$symbol_type" = "U W" ];then \ + (echo '{'; \ +- $(NM) -u -D $1 | awk 'NF>1 {print "\t"$$2";"}' | sort -u;\ ++ $(NM) -u -D $1 | awk 'NF>1 {sub("@.*", "", $$2); print "\t"$$2";"}' | sort -u;\ + echo '};'; \ + ) > $2; \ + else \ +-- +2.25.1 + diff --git a/meta-arm/recipes-kernel/linux/linux-arm64-ack_4.19.bb b/meta-arm/recipes-kernel/linux/linux-arm64-ack_4.19.bb deleted file mode 100644 index 989b0556..00000000 --- a/meta-arm/recipes-kernel/linux/linux-arm64-ack_4.19.bb +++ /dev/null @@ -1,12 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# Copyright (c) 2020 Arm Limited -# -require linux-arm64-ack.inc - -SRC_URI = " \ - git://android.googlesource.com/kernel/common.git;protocol=https;branch=android-4.19-q-release \ - " - -# ASB-2020-06-05_4.19-q-release tag commit -SRCREV = "ebd43352dd92e56f14a4985a3c99de767fc8f9cf" diff --git a/meta-arm/recipes-kernel/linux/linux-arm64-ack_5.4.bb b/meta-arm/recipes-kernel/linux/linux-arm64-ack_5.4.bb index 99b9b9fe..aab2fd1c 100644 --- a/meta-arm/recipes-kernel/linux/linux-arm64-ack_5.4.bb +++ b/meta-arm/recipes-kernel/linux/linux-arm64-ack_5.4.bb @@ -6,7 +6,11 @@ require linux-arm64-ack.inc SRC_URI = " \ git://android.googlesource.com/kernel/common.git;protocol=https;branch=android11-5.4-lts \ + file://0001-perf-cs-etm-Move-definition-of-traceid_list-global-v.patch \ + file://0002-perf-tests-bp_account-Make-global-variable-static.patch \ + file://0003-perf-bench-Share-some-global-variables-to-fix-build-.patch \ + file://0004-libtraceevent-Fix-build-with-binutils-2.35.patch \ " -# ASB-2020-06-05_5.4-stable tag commit -SRCREV = "2068976fd7b172b64020006efde1ee57af6bbf99" +# ASB-2020-07-05_5.4-stable tag commit +SRCREV = "056684c0d252f75c13be4abb7408f692eedab653" diff --git a/meta-arm/recipes-security/optee/optee-client.inc b/meta-arm/recipes-security/optee/optee-client.inc index d82392cc..f697386c 100644 --- a/meta-arm/recipes-security/optee/optee-client.inc +++ b/meta-arm/recipes-security/optee/optee-client.inc @@ -2,12 +2,10 @@ SUMMARY = "OP-TEE Client API" DESCRIPTION = "Open Portable Trusted Execution Environment - Normal World Client side of the TEE" HOMEPAGE = "https://www.op-tee.org/" -LICENSE = "BSD" -LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=69663ab153298557a59c67a60a743e5b" +LICENSE = "BSD-2-Clause" +LIC_FILES_CHKSUM = "file://LICENSE;md5=69663ab153298557a59c67a60a743e5b" -require optee.inc - -inherit python3native systemd update-rc.d +inherit systemd update-rc.d cmake SRC_URI = " \ git://github.com/OP-TEE/optee_client.git \ @@ -15,32 +13,15 @@ SRC_URI = " \ file://tee-supplicant.sh \ " +UPSTREAM_CHECK_GITTAGREGEX = "^(?P\d+(\.\d+)+)$" + S = "${WORKDIR}/git" -B = "${WORKDIR}/build" -EXTRA_OEMAKE = "O=${B}" - -do_compile() { - cd ${S} - oe_runmake -} -do_compile[cleandirs] = "${B}" - -do_install() { - cd ${S} - oe_runmake install - - install -D -p -m0755 ${B}/export/usr/sbin/tee-supplicant ${D}${sbindir}/tee-supplicant - - install -D -p -m0644 ${B}/export/usr/lib/libteec.so.1.0 ${D}${libdir}/libteec.so.1.0 - ln -sf libteec.so.1.0 ${D}${libdir}/libteec.so - ln -sf libteec.so.1.0 ${D}${libdir}/libteec.so.1 - - install -d ${D}${includedir} - install -p -m0644 ${B}/export/usr/include/*.h ${D}${includedir} +EXTRA_OECMAKE = "-DBUILD_SHARED_LIBS=ON" +EXTRA_OECMAKE_append_toolchain-clang = " -DCFG_WERROR=0" +do_install_append() { install -D -p -m0644 ${WORKDIR}/tee-supplicant.service ${D}${systemd_system_unitdir}/tee-supplicant.service - install -D -p -m0755 ${WORKDIR}/tee-supplicant.sh ${D}${sysconfdir}/init.d/tee-supplicant sed -i -e s:@sysconfdir@:${sysconfdir}:g \ @@ -52,8 +33,5 @@ do_install() { SYSTEMD_SERVICE_${PN} = "tee-supplicant.service" INITSCRIPT_PACKAGES = "${PN}" - INITSCRIPT_NAME_${PN} = "tee-supplicant" INITSCRIPT_PARAMS_${PN} = "start 10 1 2 3 4 5 . stop 90 0 6 ." - - diff --git a/meta-arm/recipes-security/optee/optee-client_3.8.0.bb b/meta-arm/recipes-security/optee/optee-client_3.8.0.bb deleted file mode 100644 index b1587bb0..00000000 --- a/meta-arm/recipes-security/optee/optee-client_3.8.0.bb +++ /dev/null @@ -1,3 +0,0 @@ -require optee-client.inc - -SRCREV = "be4fa2e36f717f03ca46e574aa66f697a897d090" diff --git a/meta-arm/recipes-security/optee/optee-examples.inc b/meta-arm/recipes-security/optee/optee-examples.inc index 7d128587..851043b5 100644 --- a/meta-arm/recipes-security/optee/optee-examples.inc +++ b/meta-arm/recipes-security/optee/optee-examples.inc @@ -2,8 +2,8 @@ SUMMARY = "OP-TEE examples" DESCRIPTION = "Open Portable Trusted Execution Environment - Sample Applications" HOMEPAGE = "https://github.com/linaro-swg/optee_examples" -LICENSE = "GPLv2" -LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=cd95ab417e23b94f381dafc453d70c30" +LICENSE = "BSD-2-Clause" +LIC_FILES_CHKSUM = "file://LICENSE;md5=cd95ab417e23b94f381dafc453d70c30" DEPENDS = "optee-client optee-os python3-pycryptodomex-native" @@ -15,29 +15,17 @@ SRC_URI = "git://github.com/linaro-swg/optee_examples.git \ file://0001-make-Pass-ldflags-during-link.patch \ " -OPTEE_COMPILER = "${@d.getVar('TOOLCHAIN') or 'gcc'}" - -EXTRA_OEMAKE = " TA_DEV_KIT_DIR=${TA_DEV_KIT_DIR} \ - OPTEE_CLIENT_EXPORT=${OPTEE_CLIENT_EXPORT} \ - TEEC_EXPORT=${TEEC_EXPORT} \ - HOST_CROSS_COMPILE=${TARGET_PREFIX} \ - LIBGCC_LOCATE_CFLAGS=--sysroot=${STAGING_DIR_HOST} \ - COMPILER=${OPTEE_COMPILER} \ - TA_CROSS_COMPILE=${TARGET_PREFIX} \ - V=1 \ +EXTRA_OEMAKE += "TA_DEV_KIT_DIR=${TA_DEV_KIT_DIR} \ + HOST_CROSS_COMPILE=${HOST_PREFIX} \ + TA_CROSS_COMPILE=${HOST_PREFIX} \ OUTPUT_DIR=${B} \ " S = "${WORKDIR}/git" B = "${WORKDIR}/build" -OPTEE_CLIENT_EXPORT = "${STAGING_DIR_HOST}${prefix}" -TEEC_EXPORT = "${STAGING_DIR_HOST}${prefix}" -TA_DEV_KIT_DIR = "${STAGING_INCDIR}/optee/export-user_ta" - do_compile() { - cd ${S} - oe_runmake + oe_runmake -C ${S} } do_compile[cleandirs] = "${B}" @@ -52,4 +40,3 @@ FILES_${PN} += "${nonarch_base_libdir}/optee_armtz/" # Imports machine specific configs from staging to build PACKAGE_ARCH = "${MACHINE_ARCH}" - diff --git a/meta-arm/recipes-security/optee/optee-examples_3.8.0.bb b/meta-arm/recipes-security/optee/optee-examples_3.8.0.bb deleted file mode 100644 index bd9b3178..00000000 --- a/meta-arm/recipes-security/optee/optee-examples_3.8.0.bb +++ /dev/null @@ -1,3 +0,0 @@ -require optee-examples.inc - -SRCREV = "559b2141c16bf0f57ccd72f60e4deb84fc2a05b0" diff --git a/meta-arm/recipes-security/optee/optee-os.inc b/meta-arm/recipes-security/optee/optee-os.inc index 3094b35a..f8697cfe 100644 --- a/meta-arm/recipes-security/optee/optee-os.inc +++ b/meta-arm/recipes-security/optee/optee-os.inc @@ -2,12 +2,14 @@ SUMMARY = "OP-TEE Trusted OS" DESCRIPTION = "Open Portable Trusted Execution Environment - Trusted side of the TEE" HOMEPAGE = "https://www.op-tee.org/" -LICENSE = "BSD" -LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=c1f21c4f72f372ef38a5a4aee55ec173" +LICENSE = "BSD-2-Clause" +LIC_FILES_CHKSUM = "file://LICENSE;md5=c1f21c4f72f372ef38a5a4aee55ec173" inherit deploy python3native require optee.inc +CVE_PRODUCT = "linaro:op-tee op-tee:op-tee_os" + DEPENDS = "python3-pycryptodome-native python3-pycryptodomex-native python3-pyelftools-native" DEPENDS_append_toolchain-clang = " compiler-rt" @@ -17,25 +19,13 @@ SRC_URI = "git://github.com/OP-TEE/optee_os.git" S = "${WORKDIR}/git" B = "${WORKDIR}/build" -OPTEEMACHINE ?= "${MACHINE}" -OPTEEMACHINE_aarch64_qemuall ?= "vexpress-qemu_armv8a" -OPTEE_ARCH = "null" -OPTEE_ARCH_armv7a = "arm32" -OPTEE_ARCH_aarch64 = "arm64" -OPTEE_CORE = "${@d.getVar('OPTEE_ARCH').upper()}" -OPTEE_COMPILER = "${@d.getVar('TOOLCHAIN') or 'gcc'}" - - -EXTRA_OEMAKE = " \ +EXTRA_OEMAKE += " \ PLATFORM=${OPTEEMACHINE} \ CFG_${OPTEE_CORE}_core=y \ CROSS_COMPILE_core=${HOST_PREFIX} \ CROSS_COMPILE_ta_${OPTEE_ARCH}=${HOST_PREFIX} \ NOWERROR=1 \ - V=1 \ ta-targets=ta_${OPTEE_ARCH} \ - LIBGCC_LOCATE_CFLAGS=--sysroot=${STAGING_DIR_HOST} \ - COMPILER=${OPTEE_COMPILER} \ O=${B} \ " @@ -48,8 +38,7 @@ LD[unexport] = "1" do_configure[noexec] = "1" do_compile() { - cd ${S} - oe_runmake all CFG_TEE_TA_LOG_LEVEL=0 + oe_runmake -C ${S} all CFG_TEE_TA_LOG_LEVEL=0 } do_compile[cleandirs] = "${B}" diff --git a/meta-arm/recipes-security/optee/optee-os/0001-libutils-provide-empty-__getauxval-implementation.patch b/meta-arm/recipes-security/optee/optee-os/0001-libutils-provide-empty-__getauxval-implementation.patch new file mode 100644 index 00000000..0120f5c2 --- /dev/null +++ b/meta-arm/recipes-security/optee/optee-os/0001-libutils-provide-empty-__getauxval-implementation.patch @@ -0,0 +1,62 @@ +Upstream-Status: Backport +Signed-off-by: Ross Burton + +From 36e784f621bf5d5be9183beba35f39426277c110 Mon Sep 17 00:00:00 2001 +From: Volodymyr Babchuk +Date: Tue, 13 Oct 2020 22:45:39 +0300 +Subject: [PATCH 1/3] libutils: provide empty __getauxval() implementation + +Never version of libgcc are built with LSE implementation in mind. To +determine if LSE is available on platform it calls __getauxval(), so in +some cases we can get undefined reference to __getauxval() error. + +Prominent case is libgcc_eh.a library, which is used by C++ TAs. Exception +handler depends on atomic operations, so it tries to call +init_have_lse_atomics() first. This function in turn calls __getauxval(), +which causes linking error. + +In the future we can make __getauxval() to return actual platform +capabilities. + +Signed-off-by: Volodymyr Babchuk +Reviewed-by: Jens Wiklander +Reviewed-by: Jerome Forissier +--- + lib/libutils/ext/arch/arm/auxval.c | 12 ++++++++++++ + lib/libutils/ext/arch/arm/sub.mk | 1 + + 2 files changed, 13 insertions(+) + create mode 100644 lib/libutils/ext/arch/arm/auxval.c + +diff --git a/lib/libutils/ext/arch/arm/auxval.c b/lib/libutils/ext/arch/arm/auxval.c +new file mode 100644 +index 00000000..98bca850 +--- /dev/null ++++ b/lib/libutils/ext/arch/arm/auxval.c +@@ -0,0 +1,12 @@ ++// SPDX-License-Identifier: BSD-2-Clause ++/* ++ * Copyright (c) 2020, EPAM Systems ++ */ ++ ++#include ++ ++unsigned long int __getauxval (unsigned long int type); ++unsigned long int __getauxval (unsigned long int type __unused) ++{ ++ return 0; ++} +diff --git a/lib/libutils/ext/arch/arm/sub.mk b/lib/libutils/ext/arch/arm/sub.mk +index dc5eed67..2e779066 100644 +--- a/lib/libutils/ext/arch/arm/sub.mk ++++ b/lib/libutils/ext/arch/arm/sub.mk +@@ -3,6 +3,7 @@ srcs-$(CFG_ARM32_$(sm)) += aeabi_unwind.c + endif + srcs-$(CFG_ARM32_$(sm)) += atomic_a32.S + srcs-$(CFG_ARM64_$(sm)) += atomic_a64.S ++srcs-y += auxval.c + ifneq ($(sm),ldelf) # TA, core + srcs-$(CFG_ARM32_$(sm)) += mcount_a32.S + srcs-$(CFG_ARM64_$(sm)) += mcount_a64.S +-- +2.25.1 + diff --git a/meta-arm/recipes-security/optee/optee-os/0001-mk-compile.mk-fix-cc-option-macro.patch b/meta-arm/recipes-security/optee/optee-os/0001-mk-compile.mk-fix-cc-option-macro.patch deleted file mode 100644 index 52d8f9be..00000000 --- a/meta-arm/recipes-security/optee/optee-os/0001-mk-compile.mk-fix-cc-option-macro.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 1ec374238f537eb0e3024d0db45f1fe3b5d471cc Mon Sep 17 00:00:00 2001 -From: Jerome Forissier -Date: Wed, 20 May 2020 10:50:00 +0200 -Subject: [PATCH 1/6] mk/compile.mk: fix cc-option macro - -There are (at least) three issues with the cc-option macro: - -1. When COMPILER=clang: when presented with a supported but unused - option, Clang emits a warning to stderr (and returns a success code - of 0). Therefore it is incorrect to check stderr to determine if an - option is supported or not; we should rely on the return status - instead. -2. When COMPILER=clang, the compile command $(CC$(sm)) contains an - equal sign (e.g., clang --target=arm-linux-gnueabihf). This is not - expected in the cc-option macro, currently only flags are allowed to - potentially contain an equal sign. This messes with the caching of - the test result. -3. The macro should not cache the return value when an option is not - supported. For instance, if we have: - A := $(call cc-option,--not-supported,a) - B := $(call cc-option,--not-supported,b) - ...we expect A to be "a" and B to be "b". The current implementation - returns "a" in both cases. - -This commit fixes the above problems. - -Fixes: 989ac108b0ef ("mk/compile.mk: add cc-option macro") -Signed-off-by: Jerome Forissier -Upstream-Status: Accepted [https://github.com/OP-TEE/optee_os/pull/3891] -Signed-off-by: Joshua Watt ---- - mk/compile.mk | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -diff --git a/mk/compile.mk b/mk/compile.mk -index ddeb408f..9868ddd1 100644 ---- a/mk/compile.mk -+++ b/mk/compile.mk -@@ -17,12 +17,12 @@ objs := - # Disable all builtin rules - .SUFFIXES: - --__cc-option = $(if $(shell $(CC$(sm)) $(1) -c -x c /dev/null -o /dev/null 2>&1 >/dev/null),$(2),$(1)) --_cc-opt-cached-var-name = cached-cc-option$(subst =,~,$(strip $(1)))$(subst $(empty) $(empty),,$(CC$(sm))) -+_cc-option-supported = $(if $(shell $(CC$(sm)) $(1) -c -x c /dev/null -o /dev/null 2>/dev/null >/dev/null || echo "Not supported"),,1) -+_cc-opt-cached-var-name = $(subst =,~,$(strip cached-cc-option-$(1)-$(subst $(empty) $(empty),,$(CC$(sm))))) - define _cc-option --$(eval _cached := $(call _cc-opt-cached-var-name,$1)) --$(eval $(_cached) := $(if $(filter $(origin $(_cached)),undefined),$(call __cc-option,$(1),$(2)),$($(_cached)))) --$($(_cached)) -+$(eval _var_name := $(call _cc-opt-cached-var-name,$1)) -+$(eval $(_var_name) := $(if $(filter $(origin $(_var_name)),undefined),$(call _cc-option-supported,$(1)),$($(_var_name)))) -+$(if $($(_var_name)),$(1),$(2)) - endef - cc-option = $(strip $(call _cc-option,$(1),$(2))) - --- -2.17.1 - diff --git a/meta-arm/recipes-security/optee/optee-os/0002-Allow-use-of-cc-option-in-core-arch-arm-arm.mk.patch b/meta-arm/recipes-security/optee/optee-os/0002-Allow-use-of-cc-option-in-core-arch-arm-arm.mk.patch deleted file mode 100644 index 83cc52c6..00000000 --- a/meta-arm/recipes-security/optee/optee-os/0002-Allow-use-of-cc-option-in-core-arch-arm-arm.mk.patch +++ /dev/null @@ -1,158 +0,0 @@ -From b45199897c1f956ca9da0f4e8d857a49787f5ff8 Mon Sep 17 00:00:00 2001 -From: Jerome Forissier -Date: Tue, 26 May 2020 15:21:00 +0200 -Subject: [PATCH 2/6] Allow use of cc-option in core/arch/arm/arm.mk - -It can be useful to call the cc-option macro when setting flags in -core/arch/arm/arm.mk. Unfortunately cc-option is defined in -mk/compile.mk which is too late to be useful (core/arch/arm/arm.mk is -included by core/core.mk before mk/compile.mk). - -This commit addresses the issue by moving the definition of cc-option -to its own file, mk/cc-option.mk, which is then included by -core/arch/arm/arm.mk. There is a dependency on the compiler definitions -(mk/gcc.mk or mk/clang.mk) and on $(arch-bit-$(sm)) so -core/arch/arm/arm.mk is modified accordingly. - -Moving cc-option out of mk/compile.mk means that all non-core -submodules would lose the definition unless they include -mk/cc-option.mk; the TA dev kit is modified so that TAs can call -cc-option from within their sub.mk files. As for other submodules, they -are internal and do not use cc-options as of now so they are not -modified. - -Signed-off-by: Jerome Forissier -Upstream-Status: Accepted [https://github.com/OP-TEE/optee_os/pull/3891] -Signed-off-by: Joshua Watt ---- - core/arch/arm/arm.mk | 14 ++++++++++++-- - core/core.mk | 4 ---- - mk/cc-option.mk | 9 +++++++++ - mk/compile.mk | 9 --------- - ta/mk/ta_dev_kit.mk | 4 +++- - ta/ta.mk | 1 + - 6 files changed, 25 insertions(+), 16 deletions(-) - create mode 100644 mk/cc-option.mk - -diff --git a/core/arch/arm/arm.mk b/core/arch/arm/arm.mk -index a18eda3b..ad036c91 100644 ---- a/core/arch/arm/arm.mk -+++ b/core/arch/arm/arm.mk -@@ -1,3 +1,15 @@ -+# Setup compiler for this sub module -+# Note this file is included only from core.mk (with $(sm) == core) -+ifeq ($(CFG_ARM64_core),y) -+arch-bits-core := 64 -+else -+arch-bits-core := 32 -+endif -+COMPILER_core ?= $(COMPILER) -+include mk/$(COMPILER_core).mk -+ -+include mk/cc-option.mk -+ - CFG_LTC_OPTEE_THREAD ?= y - # Size of emulated TrustZone protected SRAM, 448 kB. - # Only applicable when paging is enabled. -@@ -148,14 +160,12 @@ core-platform-cflags += -fpie - endif - - ifeq ($(CFG_ARM64_core),y) --arch-bits-core := 64 - core-platform-cppflags += $(arm64-platform-cppflags) - core-platform-cflags += $(arm64-platform-cflags) - core-platform-cflags += $(arm64-platform-cflags-generic) - core-platform-cflags += $(arm64-platform-cflags-no-hard-float) - core-platform-aflags += $(arm64-platform-aflags) - else --arch-bits-core := 32 - core-platform-cppflags += $(arm32-platform-cppflags) - core-platform-cflags += $(arm32-platform-cflags) - core-platform-cflags += $(arm32-platform-cflags-no-hard-float) -diff --git a/core/core.mk b/core/core.mk -index 016f1489..1a330457 100644 ---- a/core/core.mk -+++ b/core/core.mk -@@ -16,10 +16,6 @@ PLATFORM_FLAVOR_$(PLATFORM_FLAVOR) := y - $(eval $(call cfg-depends-all,CFG_PAGED_USER_TA,CFG_WITH_PAGER CFG_WITH_USER_TA)) - include core/crypto.mk - --# Setup compiler for this sub module --COMPILER_$(sm) ?= $(COMPILER) --include mk/$(COMPILER_$(sm)).mk -- - cppflags$(sm) += -D__KERNEL__ - - cppflags$(sm) += -Icore/include -diff --git a/mk/cc-option.mk b/mk/cc-option.mk -new file mode 100644 -index 00000000..72f9a6f3 ---- /dev/null -+++ b/mk/cc-option.mk -@@ -0,0 +1,9 @@ -+_cc-option-supported = $(if $(shell $(CC$(sm)) $(1) -c -x c /dev/null -o /dev/null 2>/dev/null >/dev/null || echo "Not supported"),,1) -+_cc-opt-cached-var-name = $(subst =,~,$(strip cached-cc-option-$(1)-$(subst $(empty) $(empty),,$(CC$(sm))))) -+define _cc-option -+$(eval _var_name := $(call _cc-opt-cached-var-name,$1)) -+$(eval $(_var_name) := $(if $(filter $(origin $(_var_name)),undefined),$(call _cc-option-supported,$(1)),$($(_var_name)))) -+$(if $($(_var_name)),$(1),$(2)) -+endef -+cc-option = $(strip $(call _cc-option,$(1),$(2))) -+ -diff --git a/mk/compile.mk b/mk/compile.mk -index 9868ddd1..d2705025 100644 ---- a/mk/compile.mk -+++ b/mk/compile.mk -@@ -17,15 +17,6 @@ objs := - # Disable all builtin rules - .SUFFIXES: - --_cc-option-supported = $(if $(shell $(CC$(sm)) $(1) -c -x c /dev/null -o /dev/null 2>/dev/null >/dev/null || echo "Not supported"),,1) --_cc-opt-cached-var-name = $(subst =,~,$(strip cached-cc-option-$(1)-$(subst $(empty) $(empty),,$(CC$(sm))))) --define _cc-option --$(eval _var_name := $(call _cc-opt-cached-var-name,$1)) --$(eval $(_var_name) := $(if $(filter $(origin $(_var_name)),undefined),$(call _cc-option-supported,$(1)),$($(_var_name)))) --$(if $($(_var_name)),$(1),$(2)) --endef --cc-option = $(strip $(call _cc-option,$(1),$(2))) -- - comp-cflags$(sm) = -std=gnu99 - comp-aflags$(sm) = - comp-cppflags$(sm) = -diff --git a/ta/mk/ta_dev_kit.mk b/ta/mk/ta_dev_kit.mk -index 90c6a455..596a6961 100644 ---- a/ta/mk/ta_dev_kit.mk -+++ b/ta/mk/ta_dev_kit.mk -@@ -93,6 +93,9 @@ clean: - @$(cmd-echo-silent) ' CLEAN $(O)' - ${q}if [ -d "$(O)" ]; then $(RMDIR) $(O); fi - -+include $(ta-dev-kit-dir$(sm))/mk/$(COMPILER_$(sm)).mk -+include $(ta-dev-kit-dir$(sm))/mk/cc-option.mk -+ - subdirs = . - include $(ta-dev-kit-dir$(sm))/mk/subdir.mk - -@@ -107,7 +110,6 @@ endif - endif - - SCRIPTS_DIR := $(ta-dev-kit-dir)/scripts --include $(ta-dev-kit-dir$(sm))/mk/$(COMPILER_$(sm)).mk - include $(ta-dev-kit-dir$(sm))/mk/compile.mk - - ifneq ($(user-ta-uuid),) -diff --git a/ta/ta.mk b/ta/ta.mk -index b961663a..75b7cfd9 100644 ---- a/ta/ta.mk -+++ b/ta/ta.mk -@@ -157,6 +157,7 @@ $(foreach f, $(libfiles), \ - - # Copy .mk files - ta-mkfiles = mk/compile.mk mk/subdir.mk mk/gcc.mk mk/clang.mk mk/cleandirs.mk \ -+ mk/cc-option.mk \ - ta/arch/$(ARCH)/link.mk ta/arch/$(ARCH)/link_shlib.mk \ - ta/mk/ta_dev_kit.mk - --- -2.17.1 - diff --git a/meta-arm/recipes-security/optee/optee-os/0002-link.mk-implement-support-for-libnames-after-libgcc-.patch b/meta-arm/recipes-security/optee/optee-os/0002-link.mk-implement-support-for-libnames-after-libgcc-.patch new file mode 100644 index 00000000..11296c8c --- /dev/null +++ b/meta-arm/recipes-security/optee/optee-os/0002-link.mk-implement-support-for-libnames-after-libgcc-.patch @@ -0,0 +1,55 @@ +Upstream-Status: Backport +Signed-off-by: Ross Burton + +From 73196b58ea6978ffa5e581738030f51c5789ef73 Mon Sep 17 00:00:00 2001 +From: Volodymyr Babchuk +Date: Tue, 13 Oct 2020 22:54:13 +0300 +Subject: [PATCH 2/3] link.mk: implement support for libnames-after-libgcc + variable + +Newer versions of libgcc depend on external __getauxval() symbol, which is +now provided by libutils. But libgcc is linked after libutils, so linker +can't resolve that symbol. We can't include libgcc into linking group with +libtutils, because libgcc provides symbols that conflict with libutil's +ones, like __aeabi_idiv with friends for instance. + +So, to resolve libgcc dependency on libutils we need to link with libutils +second time. To make things more generic, we will introduce +$(libnames-after-libgcc) variable for libraries that should be linked after +libgcc. + +Signed-off-by: Volodymyr Babchuk +Reviewed-by: Jens Wiklander +Reviewed-by: Jerome Forissier +--- + ta/arch/arm/link.mk | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/ta/arch/arm/link.mk b/ta/arch/arm/link.mk +index 445c285d..3025acb1 100644 +--- a/ta/arch/arm/link.mk ++++ b/ta/arch/arm/link.mk +@@ -55,8 +55,11 @@ link-ldflags += --eh-frame-hdr + link-ldadd += $(libstdc++$(sm)) $(libgcc_eh$(sm)) + endif + link-ldadd += --end-group +-ldargs-$(user-ta-uuid).elf := $(link-ldflags) $(objs) $(link-ldadd) $(libgcc$(sm)) + ++link-ldadd-after-libgcc += $(addprefix -l,$(libnames-after-libgcc)) ++ ++ldargs-$(user-ta-uuid).elf := $(link-ldflags) $(objs) $(link-ldadd) \ ++ $(libgcc$(sm)) $(link-ldadd-after-libgcc) + + link-script-cppflags-$(sm) := \ + $(filter-out $(CPPFLAGS_REMOVE) $(cppflags-remove), \ +@@ -76,6 +79,7 @@ $(link-script-pp$(sm)): $(link-script$(sm)) $(conf-file) $(link-script-pp-makefi + $(link-script-cppflags-$(sm)) $$< -o $$@ + + $(link-out-dir$(sm))/$(user-ta-uuid).elf: $(objs) $(libdeps) \ ++ $(libdeps-after-libgcc) \ + $(link-script-pp$(sm)) \ + $(dynlistdep) \ + $(additional-link-deps) +-- +2.25.1 + diff --git a/meta-arm/recipes-security/optee/optee-os/0003-arm64-Disable-outline-atomics-when-compiling.patch b/meta-arm/recipes-security/optee/optee-os/0003-arm64-Disable-outline-atomics-when-compiling.patch deleted file mode 100644 index 71a7e917..00000000 --- a/meta-arm/recipes-security/optee/optee-os/0003-arm64-Disable-outline-atomics-when-compiling.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 821cf4e6bd2764ebab8d413eeb1c3dbf673aeb78 Mon Sep 17 00:00:00 2001 -From: Joshua Watt -Date: Mon, 18 May 2020 20:00:00 -0500 -Subject: [PATCH 3/6] arm64: Disable outline-atomics when compiling - -Disables the automatic detection of LSE (Large System Extension) -instructions when compiling AArch64 code. GCC 10 implements this -detection in libgcc using __getauxval(), which OP-TEE does not -implement. -This requires that the proper -mcpu is passed to GCC so that the code -can be correctly compiled to use either LSE or load-store-exclusive. - -Fixes linker errors like the following when compiling with GCC 10: - - aarch64-linux-ld.bfd: libgcc.a(lse-init.o): - in function `init_have_lse_atomics': - lse-init.c:44: undefined reference to `__getauxval' - core/arch/arm/kernel/link.mk:38: - recipe for target 'build/core/all_objs.o' failed - -Signed-off-by: Joshua Watt -[jf: s/optee doesn't/OP-TEE does not/, replace ?= by := for immediate - evaluation] -Reviewed-by: Jerome Forissier -Upstream-Status: Accepted [https://github.com/OP-TEE/optee_os/pull/3891] -Signed-off-by: Joshua Watt ---- - core/arch/arm/arm.mk | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/core/arch/arm/arm.mk b/core/arch/arm/arm.mk -index ad036c91..d8dd5206 100644 ---- a/core/arch/arm/arm.mk -+++ b/core/arch/arm/arm.mk -@@ -127,7 +127,7 @@ arm32-platform-aflags-no-hard-float ?= - - arm64-platform-cflags-no-hard-float ?= -mgeneral-regs-only - arm64-platform-cflags-hard-float ?= --arm64-platform-cflags-generic ?= -mstrict-align -+arm64-platform-cflags-generic := -mstrict-align $(call cc-option,-mno-outline-atomics,) - - ifeq ($(DEBUG),1) - # For backwards compatibility --- -2.17.1 - diff --git a/meta-arm/recipes-security/optee/optee-os/0003-ta_dev_kit.mk-make-sure-that-libutils-is-linked-seco.patch b/meta-arm/recipes-security/optee/optee-os/0003-ta_dev_kit.mk-make-sure-that-libutils-is-linked-seco.patch new file mode 100644 index 00000000..88ba5f85 --- /dev/null +++ b/meta-arm/recipes-security/optee/optee-os/0003-ta_dev_kit.mk-make-sure-that-libutils-is-linked-seco.patch @@ -0,0 +1,44 @@ +Upstream-Status: Backport +Signed-off-by: Ross Burton + +From f50962e3f56f0932662b2ffa10afe53339a335dd Mon Sep 17 00:00:00 2001 +From: Volodymyr Babchuk +Date: Fri, 16 Oct 2020 16:36:08 +0300 +Subject: [PATCH 3/3] ta_dev_kit.mk: make sure that libutils is linked second + time + +libgcc depends on __getauxval symbol from libuils. As, generally libutils +is linked before libgcc, we will get "unresolved symbol" error. To resolve +this dependency we need to link libutils second time - after libgcc. + +Signed-off-by: Volodymyr Babchuk +Reviewed-by: Jens Wiklander +Reviewed-by: Jerome Forissier +--- + ta/mk/ta_dev_kit.mk | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/ta/mk/ta_dev_kit.mk b/ta/mk/ta_dev_kit.mk +index e28be677..d0e66317 100644 +--- a/ta/mk/ta_dev_kit.mk ++++ b/ta/mk/ta_dev_kit.mk +@@ -78,6 +78,16 @@ endif + libnames += dl + libdeps += $(ta-dev-kit-dir$(sm))/lib/libdl.a + ++# libutils provides __getauxval symbol which is needed by libgcc 10.x. We can't ++# link libutils after libgcc, because libgcc will replace some symbols provided ++# by libutils, which will cause further linking issues. ++# ++# But if we place libutils before libgcc, linker will not be able to resolve ++# __getauxval. So we need to link with libutils twice: before and after libgcc. ++# Hence it included both in $(libnames) and in $(libnames-after-libgcc) ++libnames-after-libgcc += utils ++libdeps-after-libgcc += $(ta-dev-kit-dir$(sm))/lib/libutils.a ++ + # Pass config variable (CFG_) from conf.mk on the command line + cppflags$(sm) += $(strip \ + $(foreach var, $(filter CFG_%,$(.VARIABLES)), \ +-- +2.25.1 + diff --git a/meta-arm/recipes-security/optee/optee-os/0004-Cleanup-unused-comp-cflags-sm-from-libgcc-lookup-com.patch b/meta-arm/recipes-security/optee/optee-os/0004-Cleanup-unused-comp-cflags-sm-from-libgcc-lookup-com.patch deleted file mode 100644 index 95fd5491..00000000 --- a/meta-arm/recipes-security/optee/optee-os/0004-Cleanup-unused-comp-cflags-sm-from-libgcc-lookup-com.patch +++ /dev/null @@ -1,59 +0,0 @@ -From a5dbec871f2acf01b5701a646584ad55d0ac1db7 Mon Sep 17 00:00:00 2001 -From: Jerome Forissier -Date: Tue, 26 May 2020 11:35:32 +0200 -Subject: [PATCH 4/6] Cleanup unused comp-cflags$(sm) from libgcc lookup - commands - -The compiler is not expected to need any flag from $(comp-cflags$(sm)) -to locate the compiler runtime libraries, and in fact this variable is -always undefined at the point it is used. Indeed, comp-cflags$(sm) is -set in mk/compile.mk, i.e., after mk/gcc.mk (or mk/clang.mk) has -been included. - -Therefore, remove the useless flags. - -Signed-off-by: Jerome Forissier -Upstream-Status: Accepted [https://github.com/OP-TEE/optee_os/pull/3891] -Signed-off-by: Joshua Watt ---- - mk/clang.mk | 10 +++++++++- - mk/gcc.mk | 2 +- - 2 files changed, 10 insertions(+), 2 deletions(-) - -diff --git a/mk/clang.mk b/mk/clang.mk -index 28367e73..34034a9c 100644 ---- a/mk/clang.mk -+++ b/mk/clang.mk -@@ -45,7 +45,15 @@ nostdinc$(sm) := -nostdinc -isystem $(shell $(CC$(sm)) \ - comp-cflags-warns-clang := -Wno-language-extension-token \ - -Wno-gnu-zero-variadic-macro-arguments - --libgcc$(sm) := -+# Note, use the compiler runtime library (libclang_rt.builtins.*.a) instead of -+# libgcc for clang -+libgcc$(sm) := $(shell $(CC$(sm)) $(CFLAGS$(arch-bits-$(sm))) \ -+ -rtlib=compiler-rt -print-libgcc-file-name 2> /dev/null) -+ -+# Core ASLR relies on the executable being ready to run from its preferred load -+# address, because some symbols are used before the MMU is enabled and the -+# relocations are applied. -+ldflag-apply-dynamic-relocs := --apply-dynamic-relocs - - # Define these to something to discover accidental use - CC := false -diff --git a/mk/gcc.mk b/mk/gcc.mk -index 1f2c5990..c53a23b1 100644 ---- a/mk/gcc.mk -+++ b/mk/gcc.mk -@@ -12,7 +12,7 @@ nostdinc$(sm) := -nostdinc -isystem $(shell $(CC$(sm)) \ - -print-file-name=include 2> /dev/null) - - # Get location of libgcc from gcc --libgcc$(sm) := $(shell $(CC$(sm)) $(CFLAGS$(arch-bits-$(sm))) $(comp-cflags$(sm)) \ -+libgcc$(sm) := $(shell $(CC$(sm)) $(CFLAGS$(arch-bits-$(sm))) \ - -print-libgcc-file-name 2> /dev/null) - - # Define these to something to discover accidental use --- -2.17.1 - diff --git a/meta-arm/recipes-security/optee/optee-os/0005-Fixup-Allow-use-of-cc-option-in-core-arch-arm-arm.mk.patch b/meta-arm/recipes-security/optee/optee-os/0005-Fixup-Allow-use-of-cc-option-in-core-arch-arm-arm.mk.patch deleted file mode 100644 index 7c68cfd3..00000000 --- a/meta-arm/recipes-security/optee/optee-os/0005-Fixup-Allow-use-of-cc-option-in-core-arch-arm-arm.mk.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 2fd7b1f22d2e03dac423adace92ab2214305b4ac Mon Sep 17 00:00:00 2001 -From: Jerome Forissier -Date: Tue, 26 May 2020 18:16:16 +0200 -Subject: [PATCH 5/6] [Fixup] Allow use of cc-option in core/arch/arm/arm.mk - -Fix a build error, let's see if Shippable is happy with this, I -still do not understand why these lines are needed. - -Signed-off-by: Jerome Forissier -Upstream-Status: Accepted [https://github.com/OP-TEE/optee_os/pull/3891] -Signed-off-by: Joshua Watt ---- - core/core.mk | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/core/core.mk b/core/core.mk -index 1a330457..d6af1d51 100644 ---- a/core/core.mk -+++ b/core/core.mk -@@ -16,6 +16,10 @@ PLATFORM_FLAVOR_$(PLATFORM_FLAVOR) := y - $(eval $(call cfg-depends-all,CFG_PAGED_USER_TA,CFG_WITH_PAGER CFG_WITH_USER_TA)) - include core/crypto.mk - -+# Setup compiler for this sub module -+COMPILER_$(sm) ?= $(COMPILER) -+include mk/$(COMPILER_$(sm)).mk -+ - cppflags$(sm) += -D__KERNEL__ - - cppflags$(sm) += -Icore/include --- -2.17.1 - diff --git a/meta-arm/recipes-security/optee/optee-os/0006-allow-setting-sysroot-for-libgcc-lookup.patch b/meta-arm/recipes-security/optee/optee-os/0006-allow-setting-sysroot-for-libgcc-lookup.patch index 86e84287..17005396 100644 --- a/meta-arm/recipes-security/optee/optee-os/0006-allow-setting-sysroot-for-libgcc-lookup.patch +++ b/meta-arm/recipes-security/optee/optee-os/0006-allow-setting-sysroot-for-libgcc-lookup.patch @@ -1,22 +1,34 @@ -From 017994c477e2d082395460de83a7828d4e7d4b70 Mon Sep 17 00:00:00 2001 -From: Joshua Watt +From 0bab935695ebcf0c533b49896ab18ff33d4a47d1 Mon Sep 17 00:00:00 2001 +From: Ross Burton Date: Tue, 26 May 2020 14:38:02 -0500 Subject: [PATCH] allow setting sysroot for libgcc lookup +Explicitly pass the new variable LIBGCC_LOCATE_CFLAGS variable when searching +for the compiler libraries as there's no easy way to reliably pass --sysroot +otherwise. + +Upstream-Status: Pending [https://github.com/OP-TEE/optee_os/issues/4188] +Signed-off-by: Ross Burton --- - mk/gcc.mk | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + mk/gcc.mk | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mk/gcc.mk b/mk/gcc.mk -index adc77a24..e238b9f3 100644 +index adc77a24..81bfa78a 100644 --- a/mk/gcc.mk +++ b/mk/gcc.mk -@@ -13,7 +13,7 @@ nostdinc$(sm) := -nostdinc -isystem $(shell $(CC$(sm)) \ +@@ -13,11 +13,11 @@ nostdinc$(sm) := -nostdinc -isystem $(shell $(CC$(sm)) \ -print-file-name=include 2> /dev/null) # Get location of libgcc from gcc -libgcc$(sm) := $(shell $(CC$(sm)) $(CFLAGS$(arch-bits-$(sm))) \ +libgcc$(sm) := $(shell $(CC$(sm)) $(LIBGCC_LOCATE_CFLAGS) $(CFLAGS$(arch-bits-$(sm))) \ -print-libgcc-file-name 2> /dev/null) - libstdc++$(sm) := $(shell $(CXX$(sm)) $(CXXFLAGS$(arch-bits-$(sm))) $(comp-cxxflags$(sm)) \ +-libstdc++$(sm) := $(shell $(CXX$(sm)) $(CXXFLAGS$(arch-bits-$(sm))) $(comp-cxxflags$(sm)) \ ++libstdc++$(sm) := $(shell $(CXX$(sm)) $(LIBGCC_LOCATE_CFLAGS) $(CXXFLAGS$(arch-bits-$(sm))) $(comp-cxxflags$(sm)) \ -print-file-name=libstdc++.a 2> /dev/null) +-libgcc_eh$(sm) := $(shell $(CXX$(sm)) $(CXXFLAGS$(arch-bits-$(sm))) $(comp-cxxflags$(sm)) \ ++libgcc_eh$(sm) := $(shell $(CXX$(sm)) $(LIBGCC_LOCATE_CFLAGS) $(CXXFLAGS$(arch-bits-$(sm))) $(comp-cxxflags$(sm)) \ + -print-file-name=libgcc_eh.a 2> /dev/null) + + # Define these to something to discover accidental use diff --git a/meta-arm/recipes-security/optee/optee-os/allow-setting-sysroot-for-libgcc-lookup-for-3.8.0.patch b/meta-arm/recipes-security/optee/optee-os/allow-setting-sysroot-for-libgcc-lookup-for-3.8.0.patch deleted file mode 100644 index d911d80a..00000000 --- a/meta-arm/recipes-security/optee/optee-os/allow-setting-sysroot-for-libgcc-lookup-for-3.8.0.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 030cd84cf0df1c27355ec02e0226317684897a97 Mon Sep 17 00:00:00 2001 -From: Joshua Watt -Date: Tue, 26 May 2020 14:38:02 -0500 -Subject: [PATCH 6/6] allow setting sysroot for libgcc lookup - ---- - mk/gcc.mk | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/mk/gcc.mk b/mk/gcc.mk -index c53a23b1..330b200a 100644 ---- a/mk/gcc.mk -+++ b/mk/gcc.mk -@@ -12,7 +12,7 @@ nostdinc$(sm) := -nostdinc -isystem $(shell $(CC$(sm)) \ - -print-file-name=include 2> /dev/null) - - # Get location of libgcc from gcc --libgcc$(sm) := $(shell $(CC$(sm)) $(CFLAGS$(arch-bits-$(sm))) \ -+libgcc$(sm) := $(shell $(CC$(sm)) $(LIBGCC_LOCATE_CFLAGS) $(CFLAGS$(arch-bits-$(sm))) \ - -print-libgcc-file-name 2> /dev/null) - - # Define these to something to discover accidental use --- -2.17.1 - diff --git a/meta-arm/recipes-security/optee/optee-os/missing-mkdir.patch b/meta-arm/recipes-security/optee/optee-os/missing-mkdir.patch deleted file mode 100644 index db1b47f8..00000000 --- a/meta-arm/recipes-security/optee/optee-os/missing-mkdir.patch +++ /dev/null @@ -1,31 +0,0 @@ -Upstream-Status: Backport [https://github.com/OP-TEE/optee_os/pull/4000] -Signed-off-by: Ross Burton - -From 79384a244d1972cdb02114f5cde6fcaf2e014c9b Mon Sep 17 00:00:00 2001 -From: Jerome Forissier -Date: Tue, 28 Jul 2020 17:28:43 +0200 -Subject: [PATCH] build: fix race when generating conf.mk - -This patch fixes the following error triggered by a heavily parallel build: - - echo sm := ta_arm64 > .../export-ta_arm64/mk/conf.mk.tmp - /bin/bash: .../export-ta_arm64/mk/conf.mk.tmp: No such file or directory - -Fixes: https://github.com/OP-TEE/optee_os/issues/3999 -Signed-off-by: Jerome Forissier ---- - ta/ta.mk | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/ta/ta.mk b/ta/ta.mk -index 59ed87f71d..ad97edaf08 100644 ---- a/ta/ta.mk -+++ b/ta/ta.mk -@@ -190,6 +190,7 @@ define mk-file-export - .PHONY: $(conf-mk-file-export) - $(conf-mk-file-export): - @$$(cmd-echo-silent) ' CHK ' $$@ -+ $(q)mkdir -p $$(dir $$@) - $(q)echo sm := $$(sm-$(conf-mk-file-export)) > $$@.tmp - $(q)echo sm-$$(sm-$(conf-mk-file-export)) := y >> $$@.tmp - $(q)($$(foreach v, $$(ta-mk-file-export-vars-$$(sm-$(conf-mk-file-export))), \ diff --git a/meta-arm/recipes-security/optee/optee-os_3.11.0.bb b/meta-arm/recipes-security/optee/optee-os_3.11.0.bb index a8f2a11b..13b3dc65 100644 --- a/meta-arm/recipes-security/optee/optee-os_3.11.0.bb +++ b/meta-arm/recipes-security/optee/optee-os_3.11.0.bb @@ -5,5 +5,7 @@ SRCREV = "c4def2a8262a03244d9a88461699b9b8e43c6b55" SRC_URI_append = " \ file://0006-allow-setting-sysroot-for-libgcc-lookup.patch \ file://0007-allow-setting-sysroot-for-clang.patch \ + file://0001-libutils-provide-empty-__getauxval-implementation.patch \ + file://0002-link.mk-implement-support-for-libnames-after-libgcc-.patch \ + file://0003-ta_dev_kit.mk-make-sure-that-libutils-is-linked-seco.patch \ " - diff --git a/meta-arm/recipes-security/optee/optee-os_3.8.0.bb b/meta-arm/recipes-security/optee/optee-os_3.8.0.bb deleted file mode 100644 index 7e0fad59..00000000 --- a/meta-arm/recipes-security/optee/optee-os_3.8.0.bb +++ /dev/null @@ -1,13 +0,0 @@ -require optee-os.inc - -SRCREV = "023e33656e2c9557ce50ad63a98b2e2c9b51c118" - -SRC_URI_append = " \ - file://0001-mk-compile.mk-fix-cc-option-macro.patch \ - file://0002-Allow-use-of-cc-option-in-core-arch-arm-arm.mk.patch \ - file://0003-arm64-Disable-outline-atomics-when-compiling.patch \ - file://0004-Cleanup-unused-comp-cflags-sm-from-libgcc-lookup-com.patch \ - file://0005-Fixup-Allow-use-of-cc-option-in-core-arch-arm-arm.mk.patch \ - file://allow-setting-sysroot-for-libgcc-lookup-for-3.8.0.patch\ - file://missing-mkdir.patch \ -" diff --git a/meta-arm/recipes-security/optee/optee-test.inc b/meta-arm/recipes-security/optee/optee-test.inc index 95ed3110..969d5e23 100644 --- a/meta-arm/recipes-security/optee/optee-test.inc +++ b/meta-arm/recipes-security/optee/optee-test.inc @@ -8,6 +8,11 @@ LIC_FILES_CHKSUM = "file://${S}/LICENSE.md;md5=daa2bcccc666345ab8940aab1315a4fa" inherit python3native require optee.inc +# Linking fails on musl due to C++/threads +# https://github.com/OP-TEE/optee_test/issues/458#issuecomment-720540834 +# When upgraded we should be able to remove this limitation +COMPATIBLE_HOST_libc-musl = 'null' + DEPENDS = "optee-client optee-os python3-pycryptodomex-native" SRC_URI = "git://github.com/OP-TEE/optee_test.git \ @@ -19,19 +24,9 @@ SRC_URI = "git://github.com/OP-TEE/optee_test.git \ S = "${WORKDIR}/git" B = "${WORKDIR}/build" -OPTEE_CLIENT_EXPORT = "${STAGING_DIR_HOST}${prefix}" -TEEC_EXPORT = "${STAGING_DIR_HOST}${prefix}" -TA_DEV_KIT_DIR = "${STAGING_INCDIR}/optee/export-user_ta" -OPTEE_COMPILER = "${@d.getVar('TOOLCHAIN') or 'gcc'}" - -EXTRA_OEMAKE = " TA_DEV_KIT_DIR=${TA_DEV_KIT_DIR} \ - OPTEE_CLIENT_EXPORT=${OPTEE_CLIENT_EXPORT} \ - TEEC_EXPORT=${TEEC_EXPORT} \ - LIBGCC_LOCATE_CFLAGS=--sysroot=${STAGING_DIR_HOST} \ - COMPILER=${OPTEE_COMPILER} \ - CROSS_COMPILE_HOST=${TARGET_PREFIX} \ - CROSS_COMPILE_TA=${TARGET_PREFIX} \ - V=1 \ +EXTRA_OEMAKE += "TA_DEV_KIT_DIR=${TA_DEV_KIT_DIR} \ + CROSS_COMPILE_HOST=${HOST_PREFIX} \ + CROSS_COMPILE_TA=${HOST_PREFIX} \ O=${B} \ " diff --git a/meta-arm/recipes-security/optee/optee-test/0001-host-xtest-Adjust-order-of-including-compiler.h.patch b/meta-arm/recipes-security/optee/optee-test/0001-host-xtest-Adjust-order-of-including-compiler.h.patch index 3066b664..3c500d7a 100644 --- a/meta-arm/recipes-security/optee/optee-test/0001-host-xtest-Adjust-order-of-including-compiler.h.patch +++ b/meta-arm/recipes-security/optee/optee-test/0001-host-xtest-Adjust-order-of-including-compiler.h.patch @@ -12,7 +12,7 @@ recipe-sysroot/usr/include/bits/stat.h:17:19: error: expected identifier or '(' ^ including compiler.h afer sys/stat.h fixes the problem. -Upstream-Status: Pending +Upstream-Status: Pending [https://github.com/OP-TEE/optee_test/issues/453] Signed-off-by: Khem Raj --- host/xtest/install_ta.c | 2 +- diff --git a/meta-arm/recipes-security/optee/optee-test/0002-make-remove-Wno-unsafe-loop-for-clang.patch b/meta-arm/recipes-security/optee/optee-test/0002-make-remove-Wno-unsafe-loop-for-clang.patch index ef09c563..17dd7d87 100644 --- a/meta-arm/recipes-security/optee/optee-test/0002-make-remove-Wno-unsafe-loop-for-clang.patch +++ b/meta-arm/recipes-security/optee/optee-test/0002-make-remove-Wno-unsafe-loop-for-clang.patch @@ -6,7 +6,7 @@ Subject: [PATCH] make: remove -Wmissing-noreturn for clang When compiling when clang, -Wmissing-noreturn causes an error because of non-compliant code. This option is removed to workaround this. -Upstream-Status: Pending +Upstream-Status: Pending [https://github.com/OP-TEE/optee_test/issues/452] Changed-Id: 71cb511904547d790d1ea98f93bf8e5a6afcb36d Signed-off-by: Brett Warren --- diff --git a/meta-arm/recipes-security/optee/optee-test/0003-make-remove-Wmissing-noreturn-for-clang.patch b/meta-arm/recipes-security/optee/optee-test/0003-make-remove-Wmissing-noreturn-for-clang.patch index b265e810..bbc303f3 100644 --- a/meta-arm/recipes-security/optee/optee-test/0003-make-remove-Wmissing-noreturn-for-clang.patch +++ b/meta-arm/recipes-security/optee/optee-test/0003-make-remove-Wmissing-noreturn-for-clang.patch @@ -7,7 +7,7 @@ When compiling with clang, the -Wno-unsafe-loop-optimizations option throws an error because clang doesn't recognise it. This option is removed to workaround this. -Upstream-Status: Pending +Upstream-Status: Pending [https://github.com/OP-TEE/optee_test/issues/452] Change-Id: 5fe0892c73208aaffac8c9995cb3275936fb1ba6 Signed-off-by: Brett Warren --- diff --git a/meta-arm/recipes-security/optee/optee-test_3.8.0.bb b/meta-arm/recipes-security/optee/optee-test_3.8.0.bb deleted file mode 100644 index 8ea33485..00000000 --- a/meta-arm/recipes-security/optee/optee-test_3.8.0.bb +++ /dev/null @@ -1,3 +0,0 @@ -require optee-test.inc - -SRCREV = "30481e381cb4285706e7516853495a7699c93b2c" diff --git a/meta-arm/recipes-security/optee/optee.inc b/meta-arm/recipes-security/optee/optee.inc index 4bf87fed..6f6f26d4 100644 --- a/meta-arm/recipes-security/optee/optee.inc +++ b/meta-arm/recipes-security/optee/optee.inc @@ -1,3 +1,26 @@ +UPSTREAM_CHECK_GITTAGREGEX = "^(?P\d+(\.\d+)+)$" + COMPATIBLE_MACHINE ?= "invalid" COMPATIBLE_MACHINE_qemuarm64 ?= "qemuarm64" # Please add supported machines below or set it in .bbappend or .conf + +OPTEEMACHINE ?= "${MACHINE}" +OPTEEMACHINE_aarch64_qemuall ?= "vexpress-qemu_armv8a" + +OPTEE_ARCH = "null" +OPTEE_ARCH_armv7a = "arm32" +OPTEE_ARCH_aarch64 = "arm64" +OPTEE_CORE = "${@d.getVar('OPTEE_ARCH').upper()}" + +OPTEE_COMPILER = "${@d.getVar('TOOLCHAIN') or 'gcc'}" + +# Set here but not passed to EXTRA_OEMAKE by default as that breaks +# the optee-os build +TA_DEV_KIT_DIR = "${STAGING_INCDIR}/optee/export-user_ta" + +EXTRA_OEMAKE += "V=1 \ + LIBGCC_LOCATE_CFLAGS=--sysroot=${STAGING_DIR_HOST} \ + COMPILER=${OPTEE_COMPILER} \ + OPTEE_CLIENT_EXPORT=${STAGING_DIR_HOST}${prefix} \ + TEEC_EXPORT=${STAGING_DIR_HOST}${prefix} \ + " diff --git a/meta-arm/recipes-security/trusted-services/crypto-sp_git.bb b/meta-arm/recipes-security/trusted-services/crypto-sp_git.bb new file mode 100644 index 00000000..f9ed9292 --- /dev/null +++ b/meta-arm/recipes-security/trusted-services/crypto-sp_git.bb @@ -0,0 +1,14 @@ +SUMMARY = "crypto-sp secure partition" + +require sp.inc + +TS_DEPLOYMENT = "${S}/deployments/crypto/shim/" + +do_install () { + install -d -m 755 ${D}/firmware + install -m 0644 "${B}/crypto-sp.bin" "${D}/firmware/crypto-sp.bin" + install -m 0644 "${S}/deployments/crypto/shim/crypto.dts" \ + "${D}/firmware/crypto.dts" +} + +FILES_${PN} = "/firmware/crypto-sp.bin /firmware/crypto.dts" diff --git a/meta-arm/recipes-security/trusted-services/files/0001-Add-a-new-environment-to-run-TS-with-a-shim-layer-in.patch b/meta-arm/recipes-security/trusted-services/files/0001-Add-a-new-environment-to-run-TS-with-a-shim-layer-in.patch new file mode 100644 index 00000000..053f69d1 --- /dev/null +++ b/meta-arm/recipes-security/trusted-services/files/0001-Add-a-new-environment-to-run-TS-with-a-shim-layer-in.patch @@ -0,0 +1,13960 @@ +From 69831e0a5668c7659257b6d812c177adf0801129 Mon Sep 17 00:00:00 2001 +From: Davidson K +Date: Mon, 8 Mar 2021 19:07:00 +0530 +Subject: [PATCH 01/13] Add a new environment to run TS with a shim layer in + S-EL1 + +To run the trusted services with Hafnium as the Hypervisor executing +at S-EL2, a shim layer that executes at S-EL1 is implemented. The +main purpose of the shim layer is to forward the synchronous exceptions +between Hafnium and Trusted Service. + +The following files in this commit were forked from tf-a-tests, keeping +the original license header intact: + tag name: v2.4 + tagged commit: 272065470e4d1939e59609a932a64955ec965921 + +From 'tftf/framework' of tf-a-tests to + 'environments/shim/framework': + aarch64/asm_debug.S (modified content) + debug.c + +From 'include' of tf-a-tests to + 'environments/shim/include': + common/aarch64/asm_macros.S (modified content) + common/aarch64/assert_macros.S (modified content) + common/asm_macros_common.S (modified content) + common/debug.h + drivers/arm/pl011.h + drivers/console.h + lib/aarch64/arch.h + lib/aarch64/arch_features.h + lib/aarch64/arch_helpers.h + lib/cassert.h + lib/libc/aarch64/endian_.h + lib/libc/aarch64/limits_.h + lib/libc/aarch64/setjmp_.h + lib/libc/aarch64/stddef_.h + lib/libc/aarch64/stdio_.h + lib/libc/cdefs.h + lib/libc/endian.h + lib/libc/errno.h + lib/libc/limits.h + lib/libc/setjmp.h + lib/libc/stdarg.h + lib/libc/assert.h + lib/libc/stdbool.h + lib/libc/stddef.h + lib/libc/stdint.h (modified content) + lib/libc/stdio.h (modified content) + lib/libc/stdlib.h (modified content) + lib/libc/string.h + lib/libc/time.h + lib/libc/uuid.h + lib/mmio.h + lib/spinlock.h + lib/status.h + lib/tftf_lib.h + lib/utils_def.h + lib/xlat_tables/aarch64/xlat_tables_aarch64.h + lib/xlat_tables/xlat_mmu_helpers.h + lib/xlat_tables/xlat_tables_arch.h + lib/xlat_tables/xlat_tables_defs.h + lib/xlat_tables/xlat_tables_v2.h + lib/xlat_tables/xlat_tables_v2_helpers.h + runtime_services/ffa_helpers.h + runtime_services/ffa_svc.h + runtime_services/smccc.h + +From 'plat/arm/tc0/include' of tf-a-tests to + 'environments/shim/include': + platform_def.h (modified content) + +From 'tftf/framework/include' of tf-a-tests to + 'environments/shim/include': + tftf.h (modified content) + +From 'lib/aarch64' of tf-a-tests to + 'environments/shim/lib/aarch64': + cache_helpers.S (modified content) + misc_helpers.S (modified content) + +From 'lib/libc' of tf-a-tests to + 'environments/shim/lib/libc': + assert.c + memcmp.c + memcpy.c + memmove.c + memset.c + printf.c + putchar.c + rand.c + snprintf.c (modified content) + strcmp.c + strlen.c + +From 'lib/locks' of tf-a-tests to + 'environments/shim/lib/locks': + aarch64/spinlock.S (modified content) + +From 'lib/smc' of tf-a-tests to + 'environments/shim/lib/smc': + aarch64/asm_smc.S (modified content) + aarch64/hvc.c + +From 'lib/utils' of tf-a-tests to + 'environments/shim/lib/utils': + mp_printf.c + +From 'lib/xlat_tables_v2' of tf-a-tests to + 'environments/shim/lib/xlat_tables_v2': + aarch64/enable_mmu.S (modified content) + aarch64/xlat_tables_arch.c + xlat_tables_context.c + xlat_tables_core.c + xlat_tables_private.h + xlat_tables_utils.c + +From 'drivers/arm/pl011/aarch64' of tf-a-tests to + 'environments/shim/pl011/aarch64/': + pl011_console.S (modified content) + +From 'plat/arm/tc0/aarch64' of tf-a-tests to + 'environments/shim/plat': + plat_helpers.S + +From 'spm/common' of tf-a-tests to + 'environments/shim/spm/common': + aarch64/sp_arch_helpers.S (modified content) + sp_helpers.c + sp_helpers.h + +The following files in this commit were forked from optee_os, keeping +the original license header intact: + branch name: psa-development + tagged commit: ac7f4110cee21afd7124791b41a4ca28cac119f5 + +From 'lib/libc/' of optee_os to + 'environments/shim/lib/libc': + bget_malloc.c + +From 'lib/libutils/ext/include' of optee_os to + 'environments/shim/include/common': + asm.S + +From 'lib/libutils/ext/include' of optee_os to + 'environments/shim/include/lib/libc': + compiler.h (modified content) + util.h + +From 'lib/libutils/isoc/include' of optee_os to + 'environments/shim/include/lib/libc': + inttypes.h + malloc.h (modified content) + +Upstream-Status: Pending [Not submitted to upstream yet] +Change-Id: Id1c8ffb9464eb29a97a354eedc23603115980791 +Signed-off-by: Ben Horgan +Signed-off-by: Davidson K +Signed-off-by: Olivier Deprez +Signed-off-by: Ruari Phipps +--- + environments/shim/.gitignore | 9 + + environments/shim/aarch64/sp_entrypoint.S | 31 + + .../shim/aarch64/spm_shim_entrypoint.S | 86 ++ + .../shim/aarch64/spm_shim_exceptions.S | 127 ++ + environments/shim/component.cmake | 97 ++ + .../shim/default_toolchain_file.cmake | 20 + + environments/shim/env.cmake | 23 + + .../shim/framework/aarch64/asm_debug.S | 120 ++ + environments/shim/framework/debug.c | 24 + + .../shim/include/common/aarch64/asm_macros.S | 218 +++ + .../include/common/aarch64/assert_macros.S | 31 + + environments/shim/include/common/asm.S | 46 + + .../shim/include/common/asm_macros_common.S | 72 + + environments/shim/include/common/debug.h | 89 ++ + environments/shim/include/common/trace.h | 15 + + environments/shim/include/drivers/arm/pl011.h | 87 ++ + environments/shim/include/drivers/console.h | 56 + + environments/shim/include/lib/aarch64/arch.h | 955 +++++++++++++ + .../shim/include/lib/aarch64/arch_features.h | 95 ++ + .../shim/include/lib/aarch64/arch_helpers.h | 526 +++++++ + environments/shim/include/lib/cassert.h | 18 + + .../shim/include/lib/libc/aarch64/endian_.h | 128 ++ + .../shim/include/lib/libc/aarch64/limits_.h | 26 + + .../shim/include/lib/libc/aarch64/setjmp_.h | 30 + + .../shim/include/lib/libc/aarch64/stddef_.h | 15 + + .../shim/include/lib/libc/aarch64/stdio_.h | 15 + + environments/shim/include/lib/libc/assert.h | 28 + + environments/shim/include/lib/libc/cdefs.h | 33 + + environments/shim/include/lib/libc/compiler.h | 32 + + environments/shim/include/lib/libc/endian.h | 191 +++ + environments/shim/include/lib/libc/errno.h | 169 +++ + environments/shim/include/lib/libc/inttypes.h | 54 + + environments/shim/include/lib/libc/limits.h | 19 + + environments/shim/include/lib/libc/malloc.h | 131 ++ + environments/shim/include/lib/libc/setjmp.h | 20 + + environments/shim/include/lib/libc/stdarg.h | 20 + + environments/shim/include/lib/libc/stdbool.h | 17 + + environments/shim/include/lib/libc/stddef.h | 27 + + environments/shim/include/lib/libc/stdint.h | 148 ++ + environments/shim/include/lib/libc/stdio.h | 33 + + environments/shim/include/lib/libc/stdlib.h | 34 + + environments/shim/include/lib/libc/string.h | 30 + + environments/shim/include/lib/libc/time.h | 18 + + environments/shim/include/lib/libc/util.h | 165 +++ + environments/shim/include/lib/libc/uuid.h | 56 + + environments/shim/include/lib/mmio.h | 42 + + environments/shim/include/lib/spinlock.h | 18 + + environments/shim/include/lib/status.h | 28 + + environments/shim/include/lib/tftf_lib.h | 236 ++++ + environments/shim/include/lib/utils_def.h | 165 +++ + .../xlat_tables/aarch64/xlat_tables_aarch64.h | 96 ++ + .../lib/xlat_tables/xlat_mmu_helpers.h | 91 ++ + .../lib/xlat_tables/xlat_tables_arch.h | 31 + + .../lib/xlat_tables/xlat_tables_defs.h | 182 +++ + .../include/lib/xlat_tables/xlat_tables_v2.h | 367 +++++ + .../lib/xlat_tables/xlat_tables_v2_helpers.h | 163 +++ + environments/shim/include/platform_def.h | 150 ++ + .../include/runtime_services/ffa_helpers.h | 399 ++++++ + .../shim/include/runtime_services/ffa_svc.h | 140 ++ + .../shim/include/runtime_services/smccc.h | 80 ++ + environments/shim/include/shim_sp.h | 47 + + environments/shim/include/tftf.h | 174 +++ + environments/shim/lib/aarch64/cache_helpers.S | 210 +++ + environments/shim/lib/aarch64/misc_helpers.S | 226 +++ + environments/shim/lib/libc/assert.c | 17 + + environments/shim/lib/libc/bget_malloc.c | 951 +++++++++++++ + environments/shim/lib/libc/memcmp.c | 24 + + environments/shim/lib/libc/memcpy.c | 18 + + environments/shim/lib/libc/memmove.c | 31 + + environments/shim/lib/libc/memset.c | 17 + + environments/shim/lib/libc/printf.c | 251 ++++ + environments/shim/lib/libc/putchar.c | 20 + + environments/shim/lib/libc/rand.c | 65 + + environments/shim/lib/libc/snprintf.c | 250 ++++ + environments/shim/lib/libc/strcmp.c | 52 + + environments/shim/lib/libc/strlen.c | 17 + + environments/shim/lib/libc/strstr.c | 25 + + .../shim/lib/locks/aarch64/spinlock.S | 34 + + environments/shim/lib/smc/aarch64/asm_smc.S | 76 + + environments/shim/lib/smc/aarch64/hvc.c | 30 + + environments/shim/lib/utils/mp_printf.c | 24 + + .../lib/xlat_tables_v2/aarch64/enable_mmu.S | 98 ++ + .../xlat_tables_v2/aarch64/xlat_tables_arch.c | 295 ++++ + .../lib/xlat_tables_v2/xlat_tables_context.c | 181 +++ + .../lib/xlat_tables_v2/xlat_tables_core.c | 1226 +++++++++++++++++ + .../lib/xlat_tables_v2/xlat_tables_private.h | 108 ++ + .../lib/xlat_tables_v2/xlat_tables_utils.c | 573 ++++++++ + .../shim/pl011/aarch64/pl011_console.S | 246 ++++ + environments/shim/plat/plat_helpers.S | 90 ++ + environments/shim/shim_main.c | 119 ++ + environments/shim/sp.ld.S | 120 ++ + .../shim/spm/common/aarch64/sp_arch_helpers.S | 42 + + environments/shim/spm/common/sp_debug.c | 68 + + environments/shim/spm/common/sp_debug.h | 13 + + environments/shim/spm/common/sp_helpers.c | 97 ++ + environments/shim/spm/common/sp_helpers.h | 76 + + external/bget/bget.cmake | 52 + + external/bget/bget.patch | 675 +++++++++ + 98 files changed, 13010 insertions(+) + create mode 100644 environments/shim/.gitignore + create mode 100644 environments/shim/aarch64/sp_entrypoint.S + create mode 100644 environments/shim/aarch64/spm_shim_entrypoint.S + create mode 100644 environments/shim/aarch64/spm_shim_exceptions.S + create mode 100644 environments/shim/component.cmake + create mode 100644 environments/shim/default_toolchain_file.cmake + create mode 100644 environments/shim/env.cmake + create mode 100644 environments/shim/framework/aarch64/asm_debug.S + create mode 100644 environments/shim/framework/debug.c + create mode 100644 environments/shim/include/common/aarch64/asm_macros.S + create mode 100644 environments/shim/include/common/aarch64/assert_macros.S + create mode 100644 environments/shim/include/common/asm.S + create mode 100644 environments/shim/include/common/asm_macros_common.S + create mode 100644 environments/shim/include/common/debug.h + create mode 100644 environments/shim/include/common/trace.h + create mode 100644 environments/shim/include/drivers/arm/pl011.h + create mode 100644 environments/shim/include/drivers/console.h + create mode 100644 environments/shim/include/lib/aarch64/arch.h + create mode 100644 environments/shim/include/lib/aarch64/arch_features.h + create mode 100644 environments/shim/include/lib/aarch64/arch_helpers.h + create mode 100644 environments/shim/include/lib/cassert.h + create mode 100644 environments/shim/include/lib/libc/aarch64/endian_.h + create mode 100644 environments/shim/include/lib/libc/aarch64/limits_.h + create mode 100644 environments/shim/include/lib/libc/aarch64/setjmp_.h + create mode 100644 environments/shim/include/lib/libc/aarch64/stddef_.h + create mode 100644 environments/shim/include/lib/libc/aarch64/stdio_.h + create mode 100644 environments/shim/include/lib/libc/assert.h + create mode 100644 environments/shim/include/lib/libc/cdefs.h + create mode 100644 environments/shim/include/lib/libc/compiler.h + create mode 100644 environments/shim/include/lib/libc/endian.h + create mode 100644 environments/shim/include/lib/libc/errno.h + create mode 100644 environments/shim/include/lib/libc/inttypes.h + create mode 100644 environments/shim/include/lib/libc/limits.h + create mode 100644 environments/shim/include/lib/libc/malloc.h + create mode 100644 environments/shim/include/lib/libc/setjmp.h + create mode 100644 environments/shim/include/lib/libc/stdarg.h + create mode 100644 environments/shim/include/lib/libc/stdbool.h + create mode 100644 environments/shim/include/lib/libc/stddef.h + create mode 100644 environments/shim/include/lib/libc/stdint.h + create mode 100644 environments/shim/include/lib/libc/stdio.h + create mode 100644 environments/shim/include/lib/libc/stdlib.h + create mode 100644 environments/shim/include/lib/libc/string.h + create mode 100644 environments/shim/include/lib/libc/time.h + create mode 100644 environments/shim/include/lib/libc/util.h + create mode 100644 environments/shim/include/lib/libc/uuid.h + create mode 100644 environments/shim/include/lib/mmio.h + create mode 100644 environments/shim/include/lib/spinlock.h + create mode 100644 environments/shim/include/lib/status.h + create mode 100644 environments/shim/include/lib/tftf_lib.h + create mode 100644 environments/shim/include/lib/utils_def.h + create mode 100644 environments/shim/include/lib/xlat_tables/aarch64/xlat_tables_aarch64.h + create mode 100644 environments/shim/include/lib/xlat_tables/xlat_mmu_helpers.h + create mode 100644 environments/shim/include/lib/xlat_tables/xlat_tables_arch.h + create mode 100644 environments/shim/include/lib/xlat_tables/xlat_tables_defs.h + create mode 100644 environments/shim/include/lib/xlat_tables/xlat_tables_v2.h + create mode 100644 environments/shim/include/lib/xlat_tables/xlat_tables_v2_helpers.h + create mode 100644 environments/shim/include/platform_def.h + create mode 100644 environments/shim/include/runtime_services/ffa_helpers.h + create mode 100644 environments/shim/include/runtime_services/ffa_svc.h + create mode 100644 environments/shim/include/runtime_services/smccc.h + create mode 100644 environments/shim/include/shim_sp.h + create mode 100644 environments/shim/include/tftf.h + create mode 100644 environments/shim/lib/aarch64/cache_helpers.S + create mode 100644 environments/shim/lib/aarch64/misc_helpers.S + create mode 100644 environments/shim/lib/libc/assert.c + create mode 100644 environments/shim/lib/libc/bget_malloc.c + create mode 100644 environments/shim/lib/libc/memcmp.c + create mode 100644 environments/shim/lib/libc/memcpy.c + create mode 100644 environments/shim/lib/libc/memmove.c + create mode 100644 environments/shim/lib/libc/memset.c + create mode 100644 environments/shim/lib/libc/printf.c + create mode 100644 environments/shim/lib/libc/putchar.c + create mode 100644 environments/shim/lib/libc/rand.c + create mode 100644 environments/shim/lib/libc/snprintf.c + create mode 100644 environments/shim/lib/libc/strcmp.c + create mode 100644 environments/shim/lib/libc/strlen.c + create mode 100644 environments/shim/lib/libc/strstr.c + create mode 100644 environments/shim/lib/locks/aarch64/spinlock.S + create mode 100644 environments/shim/lib/smc/aarch64/asm_smc.S + create mode 100644 environments/shim/lib/smc/aarch64/hvc.c + create mode 100644 environments/shim/lib/utils/mp_printf.c + create mode 100644 environments/shim/lib/xlat_tables_v2/aarch64/enable_mmu.S + create mode 100644 environments/shim/lib/xlat_tables_v2/aarch64/xlat_tables_arch.c + create mode 100644 environments/shim/lib/xlat_tables_v2/xlat_tables_context.c + create mode 100644 environments/shim/lib/xlat_tables_v2/xlat_tables_core.c + create mode 100644 environments/shim/lib/xlat_tables_v2/xlat_tables_private.h + create mode 100644 environments/shim/lib/xlat_tables_v2/xlat_tables_utils.c + create mode 100644 environments/shim/pl011/aarch64/pl011_console.S + create mode 100644 environments/shim/plat/plat_helpers.S + create mode 100644 environments/shim/shim_main.c + create mode 100644 environments/shim/sp.ld.S + create mode 100644 environments/shim/spm/common/aarch64/sp_arch_helpers.S + create mode 100644 environments/shim/spm/common/sp_debug.c + create mode 100644 environments/shim/spm/common/sp_debug.h + create mode 100644 environments/shim/spm/common/sp_helpers.c + create mode 100644 environments/shim/spm/common/sp_helpers.h + create mode 100644 external/bget/bget.cmake + create mode 100644 external/bget/bget.patch + +diff --git a/environments/shim/.gitignore b/environments/shim/.gitignore +new file mode 100644 +index 0000000..ca5ed3a +--- /dev/null ++++ b/environments/shim/.gitignore +@@ -0,0 +1,9 @@ ++# ++# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. ++# ++# SPDX-License-Identifier: BSD-3-Clause ++# ++ ++# Ignore bget files. These are downloaded from the net ++include/lib/libc/bget.h ++lib/libc/bget.c +diff --git a/environments/shim/aarch64/sp_entrypoint.S b/environments/shim/aarch64/sp_entrypoint.S +new file mode 100644 +index 0000000..8ef330b +--- /dev/null ++++ b/environments/shim/aarch64/sp_entrypoint.S +@@ -0,0 +1,31 @@ ++/* ++ * Copyright (c) 2018-2021, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#define __ASSEMBLY__ ++#include ++#include ++#include ++ ++ .globl sp_entrypoint ++ ++.section .bss.stacks ++ .balign CACHE_WRITEBACK_GRANULE ++ .fill SP_STACKS_SIZE ++stacks_end: ++ ++func sp_entrypoint ++ ++ /* Setup the stack pointer. */ ++ adr x0, stacks_end ++ mov sp, x0 ++ /* Mask FIQs */ ++ msr daifset, #DAIF_FIQ_BIT ++ isb ++ ++ /* And jump to the C entrypoint. */ ++ b sp_main ++ ++endfunc sp_entrypoint +diff --git a/environments/shim/aarch64/spm_shim_entrypoint.S b/environments/shim/aarch64/spm_shim_entrypoint.S +new file mode 100644 +index 0000000..53222be +--- /dev/null ++++ b/environments/shim/aarch64/spm_shim_entrypoint.S +@@ -0,0 +1,86 @@ ++/* ++ * Copyright (c) 2021, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#define __ASSEMBLY__ ++#include ++#include ++#include ++ ++ .globl shim_entrypoint ++ ++.section .bss.shim_stacks ++ .balign CACHE_WRITEBACK_GRANULE ++ .fill SP_STACKS_SIZE ++shim_stacks_end: ++ ++func shim_entrypoint ++ ++ /* Setup the stack pointer. */ ++ adr x0, shim_stacks_end ++ mov sp, x0 ++ ++ /* Setup vector base address */ ++ adr x0, spm_shim_exceptions_ptr ++ msr vbar_el1, x0 ++ isb ++ ++ /* Enable I-Cache */ ++ /* Enable setting DAIF from S-EL0 */ ++ mrs x0, sctlr_el1 ++ orr x0, x0, #SCTLR_I_BIT ++ orr x0, x0, #SCTLR_UMA_BIT ++ msr sctlr_el1, x0 ++ isb ++ ++ /* Relocate symbols */ ++#shim_pie_fixup: ++# ldr x0, =shim_pie_fixup ++# and x0, x0, #~(0x1000 - 1) ++# mov x1, #SP_IMAGE_SIZE ++# add x1, x1, x0 ++# bl fixup_gdt_reloc ++ ++ /* Clear S-EL1 shim BSS */ ++ adrp x0, __SHIM_BSS_START__ ++ adrp x2, __SHIM_BSS_END__ ++ sub x2, x2, x0 ++ mov x1, xzr ++ bl memset ++ ++ /* Clear S-EL0 partition BSS */ ++ adrp x0, __BSS_START__ ++ adrp x2, __BSS_END__ ++ sub x2, x2, x0 ++ mov x1, xzr ++ bl memset ++ ++ /* And jump to the C entrypoint. */ ++ bl shim_main ++ ++ cbz x0, 1f ++ ++0: mov x0, #0x60 ++ movk x0, #0x8400, lsl #16 ++ mov x1, xzr ++ mov x2, xzr ++ mov x3, xzr ++ smc #0 ++ b 0b ++ ++ /* Exception return to S-EL0 TS application code */ ++1: adrp x0, sp_entrypoint ++ msr elr_el1, x0 ++ ++ /* AArch64 EL0t */ ++ mov x0, xzr ++ msr spsr_el1, x0 ++ ++ /* TODO: clear GP/SIMD registers */ ++ /* TODO: tune EL0 system registers */ ++ ++ eret ++ ++endfunc shim_entrypoint +diff --git a/environments/shim/aarch64/spm_shim_exceptions.S b/environments/shim/aarch64/spm_shim_exceptions.S +new file mode 100644 +index 0000000..7eca49b +--- /dev/null ++++ b/environments/shim/aarch64/spm_shim_exceptions.S +@@ -0,0 +1,127 @@ ++/* ++ * Copyright (c) 2021, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#define __ASSEMBLY__ ++#include ++#include ++ ++/* ----------------------------------------------------------------------------- ++ * Very simple stackless exception handlers used by the spm shim layer. ++ * ----------------------------------------------------------------------------- ++ */ ++ .globl spm_shim_exceptions_ptr ++ ++vector_base spm_shim_exceptions_ptr ++ ++ /* ----------------------------------------------------- ++ * Current EL with SP0 : 0x0 - 0x200 ++ * ----------------------------------------------------- ++ */ ++vector_entry SynchronousExceptionSP0 ++ b . ++end_vector_entry SynchronousExceptionSP0 ++ ++vector_entry IrqSP0 ++ b . ++end_vector_entry IrqSP0 ++ ++vector_entry FiqSP0 ++ b . ++end_vector_entry FiqSP0 ++ ++vector_entry SErrorSP0 ++ b . ++end_vector_entry SErrorSP0 ++ ++ /* ----------------------------------------------------- ++ * Current EL with SPx: 0x200 - 0x400 ++ * ----------------------------------------------------- ++ */ ++vector_entry SynchronousExceptionSPx ++ b . ++end_vector_entry SynchronousExceptionSPx ++ ++vector_entry IrqSPx ++ b . ++end_vector_entry IrqSPx ++ ++vector_entry FiqSPx ++ b . ++end_vector_entry FiqSPx ++ ++vector_entry SErrorSPx ++ b . ++end_vector_entry SErrorSPx ++ ++ /* ----------------------------------------------------- ++ * Lower EL using AArch64 : 0x400 - 0x600. No exceptions ++ * are handled since secure_partition does not implement ++ * a lower EL ++ * ----------------------------------------------------- ++ */ ++vector_entry SynchronousExceptionA64 ++ msr tpidr_el1, x30 ++ mrs x30, esr_el1 ++ ubfx x30, x30, #ESR_EC_SHIFT, #ESR_EC_LENGTH ++ ++ cmp x30, #EC_AARCH64_SVC ++ b.eq do_smc ++ ++ cmp x30, #EC_AARCH32_SVC ++ b.eq do_smc ++ ++ cmp x30, #EC_AARCH64_SYS ++ b.eq handle_sys_trap ++ ++ /* Fail in all the other cases */ ++ b panic ++ ++ /* --------------------------------------------- ++ * Tell SPM that we are done initialising ++ * --------------------------------------------- ++ */ ++do_smc: ++ mrs x30, tpidr_el1 ++ smc #0 ++ eret ++ ++ /* AArch64 system instructions trap are handled as a panic for now */ ++handle_sys_trap: ++panic: ++ b panic ++end_vector_entry SynchronousExceptionA64 ++ ++vector_entry IrqA64 ++ b . ++end_vector_entry IrqA64 ++ ++vector_entry FiqA64 ++ b . ++end_vector_entry FiqA64 ++ ++vector_entry SErrorA64 ++ b . ++end_vector_entry SErrorA64 ++ ++ /* ----------------------------------------------------- ++ * Lower EL using AArch32 : 0x600 - 0x800 ++ * ----------------------------------------------------- ++ */ ++vector_entry SynchronousExceptionA32 ++ b . ++end_vector_entry SynchronousExceptionA32 ++ ++vector_entry IrqA32 ++ b . ++end_vector_entry IrqA32 ++ ++vector_entry FiqA32 ++ b . ++end_vector_entry FiqA32 ++ ++vector_entry SErrorA32 ++ b . ++end_vector_entry SErrorA32 +diff --git a/environments/shim/component.cmake b/environments/shim/component.cmake +new file mode 100644 +index 0000000..faa445d +--- /dev/null ++++ b/environments/shim/component.cmake +@@ -0,0 +1,97 @@ ++#------------------------------------------------------------------------------- ++# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. ++# ++# SPDX-License-Identifier: BSD-3-Clause ++# ++#------------------------------------------------------------------------------- ++ ++if (NOT DEFINED TGT) ++ message(FATAL_ERROR "mandatory parameter TGT is not defined.") ++endif() ++ ++include(${TS_ROOT}/external/bget/bget.cmake) ++ ++target_sources(${TGT} PRIVATE ++ "${CMAKE_CURRENT_LIST_DIR}/aarch64/spm_shim_entrypoint.S" ++ "${CMAKE_CURRENT_LIST_DIR}/aarch64/spm_shim_exceptions.S" ++ "${CMAKE_CURRENT_LIST_DIR}/aarch64/sp_entrypoint.S" ++ "${CMAKE_CURRENT_LIST_DIR}/framework/aarch64/asm_debug.S" ++ "${CMAKE_CURRENT_LIST_DIR}/framework/debug.c" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/aarch64/cache_helpers.S" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/aarch64/misc_helpers.S" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/libc/assert.c" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/libc/bget_malloc.c" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/libc/memcmp.c" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/libc/memcpy.c" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/libc/memmove.c" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/libc/memset.c" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/libc/printf.c" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/libc/putchar.c" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/libc/rand.c" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/libc/snprintf.c" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/libc/strcmp.c" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/libc/strlen.c" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/libc/strstr.c" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/locks/aarch64/spinlock.S" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/smc/aarch64/asm_smc.S" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/smc/aarch64/hvc.c" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/utils/mp_printf.c" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/xlat_tables_v2/aarch64/enable_mmu.S" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/xlat_tables_v2/aarch64/xlat_tables_arch.c" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/xlat_tables_v2/xlat_tables_context.c" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/xlat_tables_v2/xlat_tables_core.c" ++ "${CMAKE_CURRENT_LIST_DIR}/lib/xlat_tables_v2/xlat_tables_utils.c" ++ "${CMAKE_CURRENT_LIST_DIR}/pl011/aarch64/pl011_console.S" ++ "${CMAKE_CURRENT_LIST_DIR}/plat/plat_helpers.S" ++ "${CMAKE_CURRENT_LIST_DIR}/spm/common/aarch64/sp_arch_helpers.S" ++ "${CMAKE_CURRENT_LIST_DIR}/spm/common/sp_debug.c" ++ "${CMAKE_CURRENT_LIST_DIR}/spm/common/sp_helpers.c" ++ "${CMAKE_CURRENT_LIST_DIR}/shim_main.c" ++ ) ++ ++set(SHIM_HEADER_FILES ++ ${CMAKE_CURRENT_LIST_DIR} ++ ${CMAKE_CURRENT_LIST_DIR}/include ++ ${CMAKE_CURRENT_LIST_DIR}/include/common ++ ${CMAKE_CURRENT_LIST_DIR}/include/common/aarch64 ++ ${CMAKE_CURRENT_LIST_DIR}/include/drivers ++ ${CMAKE_CURRENT_LIST_DIR}/include/lib ++ ${CMAKE_CURRENT_LIST_DIR}/include/lib/aarch64 ++ ${CMAKE_CURRENT_LIST_DIR}/include/lib/libc ++ ${CMAKE_CURRENT_LIST_DIR}/include/lib/libc/aarch64 ++ ${CMAKE_CURRENT_LIST_DIR}/include/lib/xlat_tables ++ ${CMAKE_CURRENT_LIST_DIR}/include/lib/xlat_tables/aarch64 ++ ${CMAKE_CURRENT_LIST_DIR}/include/runtime_services ++ ${CMAKE_CURRENT_LIST_DIR}/spm/common ++ ${CMAKE_CURRENT_LIST_DIR}/lib/xlat_tables_v2 ++) ++ ++target_include_directories(${TGT} PRIVATE ${SHIM_HEADER_FILES}) ++ ++if(TARGET secure-storage) ++ set(SHIM_DEFINES ++ SECURE_STORAGE=1 ++ __ASSEMBLY__=1 ++ ) ++ set(LD_OUTPUT ++ ${CMAKE_BINARY_DIR}/secure-storage.ld ++ ) ++elseif(TARGET crypto-sp) ++ set(SHIM_DEFINES ++ CRYPTO=1 ++ __ASSEMBLY__=1 ++ ) ++ set(LD_OUTPUT ++ ${CMAKE_BINARY_DIR}/crypto-sp.ld ++ ) ++endif() ++ ++compiler_preprocess_file( ++ SRC ${CMAKE_CURRENT_LIST_DIR}/sp.ld.S ++ DST ${LD_OUTPUT} ++ DEFINES ${SHIM_DEFINES} ++ INCLUDES ${SHIM_HEADER_FILES} ++) ++ ++add_custom_target(${TGT}-pplscript DEPENDS ${LD_OUTPUT}) ++add_dependencies(${TGT} ${TGT}-pplscript) +diff --git a/environments/shim/default_toolchain_file.cmake b/environments/shim/default_toolchain_file.cmake +new file mode 100644 +index 0000000..be0d686 +--- /dev/null ++++ b/environments/shim/default_toolchain_file.cmake +@@ -0,0 +1,20 @@ ++#------------------------------------------------------------------------------- ++# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. ++# ++# SPDX-License-Identifier: BSD-3-Clause ++# ++#------------------------------------------------------------------------------- ++ ++#GNUARM v8 and v9 compilers use a different triplet. ++if(NOT DEFINED ENV{CROSS_COMPILE}) ++ set(CROSS_COMPILE "aarch64-none-linux-gnu-;aarch64-linux-gnu-" CACHE STRING "List of GCC prefix triplets to use.") ++endif() ++ ++set(CMAKE_CROSSCOMPILING True) ++set(CMAKE_SYSTEM_NAME Generic) ++set(CMAKE_SYSTEM_PROCESSOR arm) ++set(CMAKE_POSITION_INDEPENDENT_CODE True) ++ ++set(CMAKE_C_FLAGS_INIT "-nostdinc -I$ENV{TS_ROOT}/environments/shim/include/lib/libc -I$ENV{TS_ROOT}/environments/shim/include/lib/libc/aarch64") ++ ++include($ENV{TS_ROOT}/tools/cmake/compiler/GCC.cmake REQUIRED) +diff --git a/environments/shim/env.cmake b/environments/shim/env.cmake +new file mode 100644 +index 0000000..1bdab88 +--- /dev/null ++++ b/environments/shim/env.cmake +@@ -0,0 +1,23 @@ ++#------------------------------------------------------------------------------- ++# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. ++# ++# SPDX-License-Identifier: BSD-3-Clause ++# ++#------------------------------------------------------------------------------- ++ ++#------------------------------------------------------------------------------- ++# Environment file for deployments to Hafnium. This is a cross-compiled ++# enviroment where built executables run within secure partitions ++# with hafnium acting as the secure partition manager. ++#------------------------------------------------------------------------------- ++set(TS_ENV "shim" CACHE STRING "Environment identifier") ++ ++# Default to using the base toolcahin file for the enviroment ++set(TS_BASE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/default_toolchain_file.cmake" CACHE STRING "Base toolchainfile") ++ ++# Replicate in environment variable for access from child cmake contexts ++set(ENV{TS_BASE_TOOLCHAIN_FILE} "${TS_BASE_TOOLCHAIN_FILE}") ++ ++# Set toolchain files to use ++set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/default_toolchain_file.cmake" CACHE STRING "Toolchain file") ++set(TS_EXTERNAL_LIB_TOOLCHAIN_FILE "${CMAKE_TOOLCHAIN_FILE}" CACHE STRING "External lib Toolchain file") +diff --git a/environments/shim/framework/aarch64/asm_debug.S b/environments/shim/framework/aarch64/asm_debug.S +new file mode 100644 +index 0000000..bada3f5 +--- /dev/null ++++ b/environments/shim/framework/aarch64/asm_debug.S +@@ -0,0 +1,120 @@ ++/* ++ * Copyright (c) 2018-2021, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#define __ASSEMBLY__ ++#include ++#include ++ ++#if ENABLE_ASSERTIONS ++ ++ .globl asm_assert ++ ++/* Since the max decimal input number is 65536 */ ++#define MAX_DEC_DIVISOR 10000 ++/* The offset to add to get ascii for numerals '0 - 9' */ ++#define ASCII_OFFSET_NUM 0x30 ++ ++.section .rodata.assert_str, "aS" ++assert_msg1: ++ .asciz "ASSERT: File " ++assert_msg2: ++ .asciz " Line " ++ ++ /* ++ * This macro is intended to be used to print the ++ * line number in decimal. Used by asm_assert macro. ++ * The max number expected is 65536. ++ * In: x4 = the decimal to print. ++ * Clobber: x30, x0, x1, x2, x5, x6 ++ */ ++ .macro asm_print_line_dec ++ mov x6, #10 /* Divide by 10 after every loop iteration */ ++ mov x5, #MAX_DEC_DIVISOR ++dec_print_loop: ++ udiv x0, x4, x5 /* Get the quotient */ ++ msub x4, x0, x5, x4 /* Find the remainder */ ++ add x0, x0, #ASCII_OFFSET_NUM /* Convert to ascii */ ++ bl plat_crash_console_putc ++ udiv x5, x5, x6 /* Reduce divisor */ ++ cbnz x5, dec_print_loop ++ .endm ++ ++/* --------------------------------------------------------------------------- ++ * Assertion support in assembly. ++ * The below function helps to support assertions in assembly where we do not ++ * have a C runtime stack. Arguments to the function are : ++ * x0 - File name ++ * x1 - Line no ++ * Clobber list : x30, x0, x1, x2, x3, x4, x5, x6. ++ * --------------------------------------------------------------------------- ++ */ ++func asm_assert ++ mov x5, x0 ++ mov x6, x1 ++ /* Ensure the console is initialized */ ++ bl plat_crash_console_init ++ /* Check if the console is initialized */ ++ cbz x0, _assert_loop ++ /* The console is initialized */ ++ adr x4, assert_msg1 ++ bl asm_print_str ++ mov x4, x5 ++ bl asm_print_str ++ adr x4, assert_msg2 ++ bl asm_print_str ++ /* Check if line number higher than max permitted */ ++ tst x6, #~0xffff ++ b.ne _assert_loop ++ mov x4, x6 ++ asm_print_line_dec ++ bl plat_crash_console_flush ++_assert_loop: ++ wfi ++ b _assert_loop ++endfunc asm_assert ++ ++/* ++ * This function prints a string from address in x4. ++ * In: x4 = pointer to string. ++ * Clobber: x30, x0, x1, x2, x3 ++ */ ++func asm_print_str ++ mov x3, x30 ++1: ++ ldrb w0, [x4], #0x1 ++ cbz x0, 2f ++ bl plat_crash_console_putc ++ b 1b ++2: ++ ret x3 ++endfunc asm_print_str ++ ++/* ++ * This function prints a hexadecimal number in x4. ++ * In: x4 = the hexadecimal to print. ++ * Clobber: x30, x0 - x3, x5 ++ */ ++func asm_print_hex ++ mov x3, x30 ++ mov x5, #64 /* No of bits to convert to ascii */ ++1: ++ sub x5, x5, #4 ++ lsrv x0, x4, x5 ++ and x0, x0, #0xf ++ cmp x0, #0xA ++ b.lo 2f ++ /* Add by 0x27 in addition to ASCII_OFFSET_NUM ++ * to get ascii for characters 'a - f'. ++ */ ++ add x0, x0, #0x27 ++2: ++ add x0, x0, #ASCII_OFFSET_NUM ++ bl plat_crash_console_putc ++ cbnz x5, 1b ++ ret x3 ++endfunc asm_print_hex ++ ++#endif /* ENABLE_ASSERTIONS */ +diff --git a/environments/shim/framework/debug.c b/environments/shim/framework/debug.c +new file mode 100644 +index 0000000..66fc03b +--- /dev/null ++++ b/environments/shim/framework/debug.c +@@ -0,0 +1,24 @@ ++/* ++ * Copyright (c) 2018, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include ++#include ++ ++void __attribute__((__noreturn__)) do_panic(const char *file, int line) ++{ ++ printf("PANIC in file: %s line: %d\n", file, line); ++ ++ console_flush(); ++ ++ while (1) ++ continue; ++} ++ ++void __attribute__((__noreturn__)) do_bug_unreachable(const char *file, int line) ++{ ++ mp_printf("BUG: Unreachable code!\n"); ++ do_panic(file, line); ++} +diff --git a/environments/shim/include/common/aarch64/asm_macros.S b/environments/shim/include/common/aarch64/asm_macros.S +new file mode 100644 +index 0000000..3921d80 +--- /dev/null ++++ b/environments/shim/include/common/aarch64/asm_macros.S +@@ -0,0 +1,218 @@ ++/* ++ * Copyright (c) 2018-2021, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#define __ASSEMBLY__ ++#ifndef __ASM_MACROS_S__ ++#define __ASM_MACROS_S__ ++ ++#include ++#include ++ ++#define TLB_INVALIDATE(_type) \ ++ tlbi _type ++ ++ .macro func_prologue ++ stp x29, x30, [sp, #-0x10]! ++ mov x29,sp ++ .endm ++ ++ .macro func_epilogue ++ ldp x29, x30, [sp], #0x10 ++ .endm ++ ++ ++ .macro dcache_line_size reg, tmp ++ mrs \tmp, ctr_el0 ++ ubfx \tmp, \tmp, #16, #4 ++ mov \reg, #4 ++ lsl \reg, \reg, \tmp ++ .endm ++ ++ ++ .macro icache_line_size reg, tmp ++ mrs \tmp, ctr_el0 ++ and \tmp, \tmp, #0xf ++ mov \reg, #4 ++ lsl \reg, \reg, \tmp ++ .endm ++ ++ /* ++ * Declare the exception vector table, enforcing it is aligned on a ++ * 2KB boundary, as required by the ARMv8 architecture. ++ * Use zero bytes as the fill value to be stored in the padding bytes ++ * so that it inserts illegal AArch64 instructions. This increases ++ * security, robustness and potentially facilitates debugging. ++ */ ++ .macro vector_base label ++ .section .vectors, "ax" ++ .align 11, 0 ++ \label: ++ .endm ++ ++ /* ++ * Create an entry in the exception vector table, enforcing it is ++ * aligned on a 128-byte boundary, as required by the ARMv8 ++ * architecture. Use zero bytes as the fill value to be stored in the ++ * padding bytes so that it inserts illegal AArch64 instructions. ++ * This increases security, robustness and potentially facilitates ++ * debugging. ++ */ ++ .macro vector_entry label ++ .section .vectors, "ax" ++ .cfi_sections .debug_frame ++ .align 7, 0 ++ .type \label, %function ++ .cfi_startproc ++ \label: ++ .endm ++ ++ /* ++ * Add the bytes until fill the full exception vector, whose size is always ++ * 32 instructions. If there are more than 32 instructions in the ++ * exception vector then an error is emitted. ++ */ ++ .macro end_vector_entry label ++ .cfi_endproc ++ .fill \label + (32 * 4) - . ++ .endm ++ ++ /* ++ * This macro calculates the base address of an MP stack using the ++ * platform_get_core_pos() index, the name of the stack storage and ++ * the size of each stack ++ * Out: X0 = physical address of stack base ++ * Clobber: X30, X1, X2 ++ */ ++ .macro get_mp_stack _name, _size ++ bl platform_get_core_pos ++ ldr x2, =(\_name + \_size) ++ mov x1, #\_size ++ madd x0, x0, x1, x2 ++ .endm ++ ++ /* ++ * This macro calculates the base address of a UP stack using the ++ * name of the stack storage and the size of the stack ++ * Out: X0 = physical address of stack base ++ */ ++ .macro get_up_stack _name, _size ++ ldr x0, =(\_name + \_size) ++ .endm ++ ++ /* ++ * Helper macro to generate the best mov/movk combinations according ++ * the value to be moved. The 16 bits from '_shift' are tested and ++ * if not zero, they are moved into '_reg' without affecting ++ * other bits. ++ */ ++ .macro _mov_imm16 _reg, _val, _shift ++ .if (\_val >> \_shift) & 0xffff ++ .if (\_val & (1 << \_shift - 1)) ++ movk \_reg, (\_val >> \_shift) & 0xffff, LSL \_shift ++ .else ++ mov \_reg, \_val & (0xffff << \_shift) ++ .endif ++ .endif ++ .endm ++ ++ /* ++ * Helper macro to load arbitrary values into 32 or 64-bit registers ++ * which generates the best mov/movk combinations. Many base addresses ++ * are 64KB aligned the macro will eliminate updating bits 15:0 in ++ * that case ++ */ ++ .macro mov_imm _reg, _val ++ .if (\_val) == 0 ++ mov \_reg, #0 ++ .else ++ _mov_imm16 \_reg, (\_val), 0 ++ _mov_imm16 \_reg, (\_val), 16 ++ _mov_imm16 \_reg, (\_val), 32 ++ _mov_imm16 \_reg, (\_val), 48 ++ .endif ++ .endm ++ ++ .macro asm_read_sysreg_el1_or_el2 sysreg ++ mrs x0, CurrentEL ++ cmp x0, #(MODE_EL1 << MODE_EL_SHIFT) ++ b.eq 1f ++ cmp x0, #(MODE_EL2 << MODE_EL_SHIFT) ++ b.eq 2f ++ b dead ++1: ++ mrs x0, \sysreg\()_el1 ++ b 3f ++2: ++ mrs x0, \sysreg\()_el2 ++3: ++ .endm ++ ++ .macro asm_write_sysreg_el1_or_el2 sysreg scratch_reg ++ mrs \scratch_reg, CurrentEL ++ cmp \scratch_reg, #(MODE_EL1 << MODE_EL_SHIFT) ++ b.eq 1f ++ cmp \scratch_reg, #(MODE_EL2 << MODE_EL_SHIFT) ++ b.eq 2f ++ b dead ++1: ++ msr \sysreg\()_el1, x0 ++ b 3f ++2: ++ msr \sysreg\()_el2, x0 ++3: ++ .endm ++ ++ .macro asm_read_sctlr_el1_or_el2 ++ asm_read_sysreg_el1_or_el2 sctlr ++ .endm ++ ++ .macro asm_write_sctlr_el1_or_el2 scratch_reg ++ asm_write_sysreg_el1_or_el2 sctlr \scratch_reg ++ .endm ++ ++ .macro asm_write_vbar_el1_or_el2 scratch_reg ++ asm_write_sysreg_el1_or_el2 vbar \scratch_reg ++ .endm ++ ++/* ++ * Depending on the current exception level, jump to 'label_el1' or 'label_el2'. ++ * If the current exception level is neither EL1 nor EL2, jump to 'label_error' ++ * instead. ++ * The caller needs to provide the macro with a scratch 64-bit register to use. ++ * Its contents prior to calling this function will be lost. ++ */ ++ .macro JUMP_EL1_OR_EL2 scratch_reg, label_el1, label_el2, label_error ++ mrs \scratch_reg, CurrentEL ++ cmp \scratch_reg, #(MODE_EL1 << MODE_EL_SHIFT) ++ b.eq \label_el1 ++ cmp \scratch_reg, #(MODE_EL2 << MODE_EL_SHIFT) ++ b.eq \label_el2 ++ b \label_error ++ .endm ++ ++ /* ++ * Helper macro to read system register value into x0 ++ */ ++ .macro read reg:req ++#if ENABLE_BTI ++ bti j ++#endif ++ mrs x0, \reg ++ ret ++ .endm ++ ++ /* ++ * Helper macro to write value from x1 to system register ++ */ ++ .macro write reg:req ++#if ENABLE_BTI ++ bti j ++#endif ++ msr \reg, x1 ++ ret ++ .endm ++ ++#endif /* __ASM_MACROS_S__ */ +diff --git a/environments/shim/include/common/aarch64/assert_macros.S b/environments/shim/include/common/aarch64/assert_macros.S +new file mode 100644 +index 0000000..af1949d +--- /dev/null ++++ b/environments/shim/include/common/aarch64/assert_macros.S +@@ -0,0 +1,31 @@ ++/* ++ * Copyright (c) 2018-2021, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#define __ASSEMBLY__ ++#ifndef __ASSERT_MACROS_S__ ++#define __ASSERT_MACROS_S__ ++ ++ /* ++ * Assembler macro to enable asm_assert. Use this macro wherever ++ * assert is required in assembly. Please note that the macro makes ++ * use of label '300' to provide the logic and the caller ++ * should make sure that this label is not used to branch prior ++ * to calling this macro. ++ */ ++#define ASM_ASSERT(_cc) \ ++.ifndef .L_assert_filename ;\ ++ .pushsection .rodata.str1.1, "aS" ;\ ++ .L_assert_filename: ;\ ++ .string __FILE__ ;\ ++ .popsection ;\ ++.endif ;\ ++ b._cc 300f ;\ ++ adr x0, .L_assert_filename ;\ ++ mov x1, __LINE__ ;\ ++ b asm_assert ;\ ++300: ++ ++#endif /* __ASSERT_MACROS_S__ */ +diff --git a/environments/shim/include/common/asm.S b/environments/shim/include/common/asm.S +new file mode 100644 +index 0000000..d3cecc3 +--- /dev/null ++++ b/environments/shim/include/common/asm.S +@@ -0,0 +1,46 @@ ++/* SPDX-License-Identifier: BSD-2-Clause */ ++/* ++ * Copyright (c) 2014, STMicroelectronics International N.V. ++ */ ++ ++ .macro FUNC name colon section=default ++ .ifc \section\(),default ++ .section .text.\name ++ .else ++ .section \section , "ax" , %progbits ++ .endif ++ .global \name ++ .type \name , %function ++ .balign 4 ++ \name \colon ++ .endm ++ ++ .macro DATA name colon ++ .global \name ++ .type \name , %object ++ \name \colon ++ .endm ++ ++ .macro LOCAL_FUNC name colon section=default ++ .ifc \section\(),default ++ .section .text.\name ++ .else ++ .section \section , "ax" , %progbits ++ .endif ++ .type \name , %function ++ .balign 4 ++ \name \colon ++ .endm ++ ++ .macro LOCAL_DATA name colon ++ .type \name , %object ++ \name \colon ++ .endm ++ ++ .macro END_DATA name ++ .size \name , .-\name ++ .endm ++ ++ .macro END_FUNC name ++ .size \name , .-\name ++ .endm +diff --git a/environments/shim/include/common/asm_macros_common.S b/environments/shim/include/common/asm_macros_common.S +new file mode 100644 +index 0000000..0047897 +--- /dev/null ++++ b/environments/shim/include/common/asm_macros_common.S +@@ -0,0 +1,72 @@ ++/* ++ * Copyright (c) 2018-2021, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#define __ASSEMBLY__ ++#ifndef __ASM_MACROS_COMMON_S__ ++#define __ASM_MACROS_COMMON_S__ ++ ++#include ++ ++#if ENABLE_BTI && !ARM_ARCH_AT_LEAST(8, 5) ++#error Branch Target Identification requires ARM_ARCH_MINOR >= 5 ++#endif ++ ++ /* ++ * This macro is used to create a function label and place the ++ * code into a separate text section based on the function name ++ * to enable elimination of unused code during linking. It also adds ++ * basic debug information to enable call stack printing most of the ++ * time. ++ */ ++ .macro func _name ++ /* ++ * Add Call Frame Information entry in the .debug_frame section for ++ * debugger consumption. This enables callstack printing in debuggers. ++ * This does not use any space in the final loaded binary, only in the ++ * ELF file. ++ * Note that a function manipulating the CFA pointer location (i.e. the ++ * x29 frame pointer on AArch64) should declare it using the ++ * appropriate .cfi* directives, or be prepared to have a degraded ++ * debugging experience. ++ */ ++ .cfi_sections .debug_frame ++ .section .text.\_name, "ax" ++ .type \_name, %function ++ .func \_name ++ /* ++ * .cfi_startproc and .cfi_endproc are needed to output entries in ++ * .debug_frame ++ */ ++ .cfi_startproc ++ \_name: ++ .endm ++ ++ /* ++ * This macro is used to mark the end of a function. ++ */ ++ .macro endfunc _name ++ .endfunc ++ .cfi_endproc ++ .size \_name, . - \_name ++ .endm ++ ++ /* ++ * This macro declares an array of 1 or more stacks, properly ++ * aligned and in the requested section ++ */ ++#define STACK_ALIGN 6 ++ ++ .macro declare_stack _name, _section, _size, _count ++ .if ((\_size & ((1 << STACK_ALIGN) - 1)) <> 0) ++ .error "Stack size not correctly aligned" ++ .endif ++ .section \_section, "aw", %nobits ++ .align STACK_ALIGN ++ \_name: ++ .space ((\_count) * (\_size)), 0 ++ .endm ++ ++#endif /* __ASM_MACROS_COMMON_S__ */ +diff --git a/environments/shim/include/common/debug.h b/environments/shim/include/common/debug.h +new file mode 100644 +index 0000000..4b30175 +--- /dev/null ++++ b/environments/shim/include/common/debug.h +@@ -0,0 +1,89 @@ ++/* ++ * Copyright (c) 2014-2018, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef __DEBUG_H__ ++#define __DEBUG_H__ ++ ++#include ++ ++#ifdef IMAGE_CACTUS_MM ++/* Remove dependency on spinlocks for Cactus-MM */ ++#define mp_printf printf ++#else ++/* ++ * Print a formatted string on the UART. ++ * ++ * Does the same thing as the standard libc's printf() function but in a MP-safe ++ * manner, i.e. it can be called from several CPUs simultaneously without ++ * getting interleaved messages. ++ */ ++__attribute__((format(printf, 1, 2))) ++void mp_printf(const char *fmt, ...); ++#endif /* IMAGE_CACTUS_MM */ ++ ++/* ++ * The log output macros print output to the console. These macros produce ++ * compiled log output only if the LOG_LEVEL defined in the makefile (or the ++ * make command line) is greater or equal than the level required for that ++ * type of log output. ++ * The format expected is similar to printf(). For example: ++ * INFO("Info %s.\n", "message") -> INFO: Info message. ++ * WARN("Warning %s.\n", "message") -> WARNING: Warning message. ++ */ ++#define LOG_LEVEL_NONE 0 ++#define LOG_LEVEL_ERROR 10 ++#define LOG_LEVEL_NOTICE 20 ++#define LOG_LEVEL_WARNING 30 ++#define LOG_LEVEL_INFO 40 ++#define LOG_LEVEL_VERBOSE 50 ++ ++#if LOG_LEVEL >= LOG_LEVEL_NOTICE ++# define NOTICE(...) mp_printf("NOTICE: " __VA_ARGS__) ++#else ++# define NOTICE(...) ++#endif ++ ++#if LOG_LEVEL >= LOG_LEVEL_ERROR ++# define ERROR(...) mp_printf("ERROR: " __VA_ARGS__) ++#else ++# define ERROR(...) ++#endif ++ ++#if LOG_LEVEL >= LOG_LEVEL_WARNING ++# define WARN(...) mp_printf("WARNING: " __VA_ARGS__) ++#else ++# define WARN(...) ++#endif ++ ++#if LOG_LEVEL >= LOG_LEVEL_INFO ++# define INFO(...) mp_printf("INFO: " __VA_ARGS__) ++#else ++# define INFO(...) ++#endif ++ ++#if LOG_LEVEL >= LOG_LEVEL_VERBOSE ++# define VERBOSE(...) mp_printf("VERBOSE: " __VA_ARGS__) ++#else ++# define VERBOSE(...) ++#endif ++ ++#if ENABLE_BACKTRACE ++void backtrace(const char *cookie); ++#else ++#define backtrace(x) ++#endif ++ ++/* ++ * For the moment this panic function is very basic: report an error and ++ * spin. This can be expanded in the future to provide more information. ++ */ ++void __attribute__((__noreturn__)) do_panic(const char *file, int line); ++#define panic() do_panic(__FILE__, __LINE__) ++ ++void __attribute__((__noreturn__)) do_bug_unreachable(const char *file, int line); ++#define bug_unreachable() do_bug_unreachable(__FILE__, __LINE__) ++ ++#endif /* __DEBUG_H__ */ +diff --git a/environments/shim/include/common/trace.h b/environments/shim/include/common/trace.h +new file mode 100644 +index 0000000..aece27e +--- /dev/null ++++ b/environments/shim/include/common/trace.h +@@ -0,0 +1,15 @@ ++/* ++ * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef __TRACE_H__ ++#define __TRACE_H__ ++ ++#include ++ ++#define EMSG(...) mp_printf("ERROR: " __VA_ARGS__) ++#define DMSG(...) mp_printf("NOTICE: " __VA_ARGS__) ++ ++#endif /* __DEBUG_H__ */ +diff --git a/environments/shim/include/drivers/arm/pl011.h b/environments/shim/include/drivers/arm/pl011.h +new file mode 100644 +index 0000000..3e19ee8 +--- /dev/null ++++ b/environments/shim/include/drivers/arm/pl011.h +@@ -0,0 +1,87 @@ ++/* ++ * Copyright (c) 2018, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef __PL011_H__ ++#define __PL011_H__ ++ ++/* PL011 Registers */ ++#define UARTDR 0x000 ++#define UARTRSR 0x004 ++#define UARTECR 0x004 ++#define UARTFR 0x018 ++#define UARTILPR 0x020 ++#define UARTIBRD 0x024 ++#define UARTFBRD 0x028 ++#define UARTLCR_H 0x02C ++#define UARTCR 0x030 ++#define UARTIFLS 0x034 ++#define UARTIMSC 0x038 ++#define UARTRIS 0x03C ++#define UARTMIS 0x040 ++#define UARTICR 0x044 ++#define UARTDMACR 0x048 ++ ++/* Data status bits */ ++#define UART_DATA_ERROR_MASK 0x0F00 ++ ++/* Status reg bits */ ++#define UART_STATUS_ERROR_MASK 0x0F ++ ++/* Flag reg bits */ ++#define PL011_UARTFR_RI (1 << 8) /* Ring indicator */ ++#define PL011_UARTFR_TXFE (1 << 7) /* Transmit FIFO empty */ ++#define PL011_UARTFR_RXFF (1 << 6) /* Receive FIFO full */ ++#define PL011_UARTFR_TXFF (1 << 5) /* Transmit FIFO full */ ++#define PL011_UARTFR_RXFE (1 << 4) /* Receive FIFO empty */ ++#define PL011_UARTFR_BUSY (1 << 3) /* UART busy */ ++#define PL011_UARTFR_DCD (1 << 2) /* Data carrier detect */ ++#define PL011_UARTFR_DSR (1 << 1) /* Data set ready */ ++#define PL011_UARTFR_CTS (1 << 0) /* Clear to send */ ++ ++#define PL011_UARTFR_TXFF_BIT 5 /* Transmit FIFO full bit in UARTFR register */ ++#define PL011_UARTFR_RXFE_BIT 4 /* Receive FIFO empty bit in UARTFR register */ ++#define PL011_UARTFR_BUSY_BIT 3 /* UART busy bit in UARTFR register */ ++ ++/* Control reg bits */ ++#define PL011_UARTCR_CTSEN (1 << 15) /* CTS hardware flow control enable */ ++#define PL011_UARTCR_RTSEN (1 << 14) /* RTS hardware flow control enable */ ++#define PL011_UARTCR_RTS (1 << 11) /* Request to send */ ++#define PL011_UARTCR_DTR (1 << 10) /* Data transmit ready. */ ++#define PL011_UARTCR_RXE (1 << 9) /* Receive enable */ ++#define PL011_UARTCR_TXE (1 << 8) /* Transmit enable */ ++#define PL011_UARTCR_LBE (1 << 7) /* Loopback enable */ ++#define PL011_UARTCR_UARTEN (1 << 0) /* UART Enable */ ++ ++#if !defined(PL011_LINE_CONTROL) ++/* FIFO Enabled / No Parity / 8 Data bit / One Stop Bit */ ++#define PL011_LINE_CONTROL (PL011_UARTLCR_H_FEN | PL011_UARTLCR_H_WLEN_8) ++#endif ++ ++/* Line Control Register Bits */ ++#define PL011_UARTLCR_H_SPS (1 << 7) /* Stick parity select */ ++#define PL011_UARTLCR_H_WLEN_8 (3 << 5) ++#define PL011_UARTLCR_H_WLEN_7 (2 << 5) ++#define PL011_UARTLCR_H_WLEN_6 (1 << 5) ++#define PL011_UARTLCR_H_WLEN_5 (0 << 5) ++#define PL011_UARTLCR_H_FEN (1 << 4) /* FIFOs Enable */ ++#define PL011_UARTLCR_H_STP2 (1 << 3) /* Two stop bits select */ ++#define PL011_UARTLCR_H_EPS (1 << 2) /* Even parity select */ ++#define PL011_UARTLCR_H_PEN (1 << 1) /* Parity Enable */ ++#define PL011_UARTLCR_H_BRK (1 << 0) /* Send break */ ++ ++/* Constants */ ++#define PL011_BAUDRATE 115200 ++ ++#ifndef __ASSEMBLER__ ++#include ++ ++/* Functions */ ++ ++int console_pl011_putc(int); ++ ++#endif /* __ASSEMBLER__ */ ++ ++#endif /* __PL011_H__ */ +diff --git a/environments/shim/include/drivers/console.h b/environments/shim/include/drivers/console.h +new file mode 100644 +index 0000000..4c22a99 +--- /dev/null ++++ b/environments/shim/include/drivers/console.h +@@ -0,0 +1,56 @@ ++/* ++ * Copyright (c) 2018-2019, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef __CONSOLE_H__ ++#define __CONSOLE_H__ ++ ++/* Returned by getc callbacks when receive FIFO is empty. */ ++#define ERROR_NO_PENDING_CHAR -1 ++/* Returned by console_xxx() if the registered console doesn't implement xxx. */ ++#define ERROR_NO_VALID_CONSOLE (-128) ++ ++#ifndef __ASSEMBLY__ ++ ++#include ++ ++/* ++ * Function to initialize the console without a C Runtime to print debug ++ * information. It saves the console base to the data section. Returns 1 on ++ * success, 0 on error. ++ */ ++int console_init(uintptr_t base_addr, ++ unsigned int uart_clk, unsigned int baud_rate); ++ ++/* ++ * Function to output a character over the console. It returns the character ++ * printed on success or an error code. ++ */ ++int console_putc(int c); ++ ++/* ++ * Function to get a character from the console. It returns the character ++ * grabbed on success or an error code on error. This function is blocking, it ++ * waits until there is an available character to return. Returns a character or ++ * error code. ++ */ ++int console_getc(void); ++ ++/* ++ * Function to get a character from the console. It returns the character ++ * grabbed on success or an error code on error. This function is non-blocking, ++ * it returns immediately. ++ */ ++int console_try_getc(void); ++ ++/* ++ * Function to force a write of all buffered data that hasn't been output. It ++ * returns 0 upon successful completion, otherwise it returns an error code. ++ */ ++int console_flush(void); ++ ++#endif /* __ASSEMBLY__ */ ++ ++#endif /* __CONSOLE_H__ */ +diff --git a/environments/shim/include/lib/aarch64/arch.h b/environments/shim/include/lib/aarch64/arch.h +new file mode 100644 +index 0000000..2d2a892 +--- /dev/null ++++ b/environments/shim/include/lib/aarch64/arch.h +@@ -0,0 +1,955 @@ ++/* ++ * Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef ARCH_H ++#define ARCH_H ++ ++#include ++ ++/******************************************************************************* ++ * MIDR bit definitions ++ ******************************************************************************/ ++#define MIDR_IMPL_MASK U(0xff) ++#define MIDR_IMPL_SHIFT U(0x18) ++#define MIDR_VAR_SHIFT U(20) ++#define MIDR_VAR_BITS U(4) ++#define MIDR_VAR_MASK U(0xf) ++#define MIDR_REV_SHIFT U(0) ++#define MIDR_REV_BITS U(4) ++#define MIDR_REV_MASK U(0xf) ++#define MIDR_PN_MASK U(0xfff) ++#define MIDR_PN_SHIFT U(0x4) ++ ++/******************************************************************************* ++ * MPIDR macros ++ ******************************************************************************/ ++#define MPIDR_MT_MASK (ULL(1) << 24) ++#define MPIDR_CPU_MASK MPIDR_AFFLVL_MASK ++#define MPIDR_CLUSTER_MASK (MPIDR_AFFLVL_MASK << MPIDR_AFFINITY_BITS) ++#define MPIDR_AFFINITY_BITS U(8) ++#define MPIDR_AFFLVL_MASK ULL(0xff) ++#define MPIDR_AFF0_SHIFT U(0) ++#define MPIDR_AFF1_SHIFT U(8) ++#define MPIDR_AFF2_SHIFT U(16) ++#define MPIDR_AFF3_SHIFT U(32) ++#define MPIDR_AFF_SHIFT(_n) MPIDR_AFF##_n##_SHIFT ++#define MPIDR_AFFINITY_MASK ULL(0xff00ffffff) ++#define MPIDR_AFFLVL_SHIFT U(3) ++#define MPIDR_AFFLVL0 ULL(0x0) ++#define MPIDR_AFFLVL1 ULL(0x1) ++#define MPIDR_AFFLVL2 ULL(0x2) ++#define MPIDR_AFFLVL3 ULL(0x3) ++#define MPIDR_AFFLVL(_n) MPIDR_AFFLVL##_n ++#define MPIDR_AFFLVL0_VAL(mpidr) \ ++ (((mpidr) >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK) ++#define MPIDR_AFFLVL1_VAL(mpidr) \ ++ (((mpidr) >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK) ++#define MPIDR_AFFLVL2_VAL(mpidr) \ ++ (((mpidr) >> MPIDR_AFF2_SHIFT) & MPIDR_AFFLVL_MASK) ++#define MPIDR_AFFLVL3_VAL(mpidr) \ ++ (((mpidr) >> MPIDR_AFF3_SHIFT) & MPIDR_AFFLVL_MASK) ++/* ++ * The MPIDR_MAX_AFFLVL count starts from 0. Take care to ++ * add one while using this macro to define array sizes. ++ * TODO: Support only the first 3 affinity levels for now. ++ */ ++#define MPIDR_MAX_AFFLVL U(2) ++ ++#define MPID_MASK (MPIDR_MT_MASK | \ ++ (MPIDR_AFFLVL_MASK << MPIDR_AFF3_SHIFT) | \ ++ (MPIDR_AFFLVL_MASK << MPIDR_AFF2_SHIFT) | \ ++ (MPIDR_AFFLVL_MASK << MPIDR_AFF1_SHIFT) | \ ++ (MPIDR_AFFLVL_MASK << MPIDR_AFF0_SHIFT)) ++ ++#define MPIDR_AFF_ID(mpid, n) \ ++ (((mpid) >> MPIDR_AFF_SHIFT(n)) & MPIDR_AFFLVL_MASK) ++ ++/* ++ * An invalid MPID. This value can be used by functions that return an MPID to ++ * indicate an error. ++ */ ++#define INVALID_MPID U(0xFFFFFFFF) ++ ++/******************************************************************************* ++ * Definitions for CPU system register interface to GICv3 ++ ******************************************************************************/ ++#define ICC_IGRPEN1_EL1 S3_0_C12_C12_7 ++#define ICC_SGI1R S3_0_C12_C11_5 ++#define ICC_SRE_EL1 S3_0_C12_C12_5 ++#define ICC_SRE_EL2 S3_4_C12_C9_5 ++#define ICC_SRE_EL3 S3_6_C12_C12_5 ++#define ICC_CTLR_EL1 S3_0_C12_C12_4 ++#define ICC_CTLR_EL3 S3_6_C12_C12_4 ++#define ICC_PMR_EL1 S3_0_C4_C6_0 ++#define ICC_RPR_EL1 S3_0_C12_C11_3 ++#define ICC_IGRPEN1_EL3 S3_6_c12_c12_7 ++#define ICC_IGRPEN0_EL1 S3_0_c12_c12_6 ++#define ICC_HPPIR0_EL1 S3_0_c12_c8_2 ++#define ICC_HPPIR1_EL1 S3_0_c12_c12_2 ++#define ICC_IAR0_EL1 S3_0_c12_c8_0 ++#define ICC_IAR1_EL1 S3_0_c12_c12_0 ++#define ICC_EOIR0_EL1 S3_0_c12_c8_1 ++#define ICC_EOIR1_EL1 S3_0_c12_c12_1 ++#define ICC_SGI0R_EL1 S3_0_c12_c11_7 ++ ++/******************************************************************************* ++ * Generic timer memory mapped registers & offsets ++ ******************************************************************************/ ++#define CNTCR_OFF U(0x000) ++#define CNTFID_OFF U(0x020) ++ ++#define CNTCR_EN (U(1) << 0) ++#define CNTCR_HDBG (U(1) << 1) ++#define CNTCR_FCREQ(x) ((x) << 8) ++ ++/******************************************************************************* ++ * System register bit definitions ++ ******************************************************************************/ ++/* CLIDR definitions */ ++#define LOUIS_SHIFT U(21) ++#define LOC_SHIFT U(24) ++#define CLIDR_FIELD_WIDTH U(3) ++ ++/* CSSELR definitions */ ++#define LEVEL_SHIFT U(1) ++ ++/* Data cache set/way op type defines */ ++#define DCISW U(0x0) ++#define DCCISW U(0x1) ++#define DCCSW U(0x2) ++ ++/* ID_AA64PFR0_EL1 definitions */ ++#define ID_AA64PFR0_EL0_SHIFT U(0) ++#define ID_AA64PFR0_EL1_SHIFT U(4) ++#define ID_AA64PFR0_EL2_SHIFT U(8) ++#define ID_AA64PFR0_EL3_SHIFT U(12) ++#define ID_AA64PFR0_AMU_SHIFT U(44) ++#define ID_AA64PFR0_AMU_LENGTH U(4) ++#define ID_AA64PFR0_AMU_MASK ULL(0xf) ++#define ID_AA64PFR0_ELX_MASK ULL(0xf) ++#define ID_AA64PFR0_SVE_SHIFT U(32) ++#define ID_AA64PFR0_SVE_MASK ULL(0xf) ++#define ID_AA64PFR0_SVE_LENGTH U(4) ++#define ID_AA64PFR0_MPAM_SHIFT U(40) ++#define ID_AA64PFR0_MPAM_MASK ULL(0xf) ++#define ID_AA64PFR0_DIT_SHIFT U(48) ++#define ID_AA64PFR0_DIT_MASK ULL(0xf) ++#define ID_AA64PFR0_DIT_LENGTH U(4) ++#define ID_AA64PFR0_DIT_SUPPORTED U(1) ++#define ID_AA64PFR0_CSV2_SHIFT U(56) ++#define ID_AA64PFR0_CSV2_MASK ULL(0xf) ++#define ID_AA64PFR0_CSV2_LENGTH U(4) ++ ++/* ID_AA64DFR0_EL1.PMS definitions (for ARMv8.2+) */ ++#define ID_AA64DFR0_PMS_SHIFT U(32) ++#define ID_AA64DFR0_PMS_LENGTH U(4) ++#define ID_AA64DFR0_PMS_MASK ULL(0xf) ++ ++/* ID_AA64DFR0_EL1.DEBUG definitions */ ++#define ID_AA64DFR0_DEBUG_SHIFT U(0) ++#define ID_AA64DFR0_DEBUG_LENGTH U(4) ++#define ID_AA64DFR0_DEBUG_MASK ULL(0xf) ++#define ID_AA64DFR0_DEBUG_BITS (ID_AA64DFR0_DEBUG_MASK << \ ++ ID_AA64DFR0_DEBUG_SHIFT) ++#define ID_AA64DFR0_V8_DEBUG_ARCH_SUPPORTED U(6) ++#define ID_AA64DFR0_V8_DEBUG_ARCH_VHE_SUPPORTED U(7) ++#define ID_AA64DFR0_V8_2_DEBUG_ARCH_SUPPORTED U(8) ++#define ID_AA64DFR0_V8_4_DEBUG_ARCH_SUPPORTED U(9) ++ ++#define EL_IMPL_NONE ULL(0) ++#define EL_IMPL_A64ONLY ULL(1) ++#define EL_IMPL_A64_A32 ULL(2) ++ ++#define ID_AA64PFR0_GIC_SHIFT U(24) ++#define ID_AA64PFR0_GIC_WIDTH U(4) ++#define ID_AA64PFR0_GIC_MASK ULL(0xf) ++ ++/* ID_AA64ISAR1_EL1 definitions */ ++#define ID_AA64ISAR1_EL1 S3_0_C0_C6_1 ++#define ID_AA64ISAR1_GPI_SHIFT U(28) ++#define ID_AA64ISAR1_GPI_WIDTH U(4) ++#define ID_AA64ISAR1_GPI_MASK ULL(0xf) ++#define ID_AA64ISAR1_GPA_SHIFT U(24) ++#define ID_AA64ISAR1_GPA_WIDTH U(4) ++#define ID_AA64ISAR1_GPA_MASK ULL(0xf) ++#define ID_AA64ISAR1_API_SHIFT U(8) ++#define ID_AA64ISAR1_API_WIDTH U(4) ++#define ID_AA64ISAR1_API_MASK ULL(0xf) ++#define ID_AA64ISAR1_APA_SHIFT U(4) ++#define ID_AA64ISAR1_APA_WIDTH U(4) ++#define ID_AA64ISAR1_APA_MASK ULL(0xf) ++ ++/* ID_AA64MMFR0_EL1 definitions */ ++#define ID_AA64MMFR0_EL1_PARANGE_SHIFT U(0) ++#define ID_AA64MMFR0_EL1_PARANGE_MASK ULL(0xf) ++ ++#define PARANGE_0000 U(32) ++#define PARANGE_0001 U(36) ++#define PARANGE_0010 U(40) ++#define PARANGE_0011 U(42) ++#define PARANGE_0100 U(44) ++#define PARANGE_0101 U(48) ++#define PARANGE_0110 U(52) ++ ++#define ID_AA64MMFR0_EL1_ECV_SHIFT U(60) ++#define ID_AA64MMFR0_EL1_ECV_MASK ULL(0xf) ++#define ID_AA64MMFR0_EL1_ECV_NOT_SUPPORTED ULL(0x0) ++#define ID_AA64MMFR0_EL1_ECV_SUPPORTED ULL(0x1) ++#define ID_AA64MMFR0_EL1_ECV_SELF_SYNCH ULL(0x2) ++ ++#define ID_AA64MMFR0_EL1_FGT_SHIFT U(56) ++#define ID_AA64MMFR0_EL1_FGT_MASK ULL(0xf) ++#define ID_AA64MMFR0_EL1_FGT_NOT_SUPPORTED ULL(0x0) ++#define ID_AA64MMFR0_EL1_FGT_SUPPORTED ULL(0x1) ++ ++#define ID_AA64MMFR0_EL1_TGRAN4_SHIFT U(28) ++#define ID_AA64MMFR0_EL1_TGRAN4_MASK ULL(0xf) ++#define ID_AA64MMFR0_EL1_TGRAN4_SUPPORTED ULL(0x0) ++#define ID_AA64MMFR0_EL1_TGRAN4_NOT_SUPPORTED ULL(0xf) ++ ++#define ID_AA64MMFR0_EL1_TGRAN64_SHIFT U(24) ++#define ID_AA64MMFR0_EL1_TGRAN64_MASK ULL(0xf) ++#define ID_AA64MMFR0_EL1_TGRAN64_SUPPORTED ULL(0x0) ++#define ID_AA64MMFR0_EL1_TGRAN64_NOT_SUPPORTED ULL(0xf) ++ ++#define ID_AA64MMFR0_EL1_TGRAN16_SHIFT U(20) ++#define ID_AA64MMFR0_EL1_TGRAN16_MASK ULL(0xf) ++#define ID_AA64MMFR0_EL1_TGRAN16_SUPPORTED ULL(0x1) ++#define ID_AA64MMFR0_EL1_TGRAN16_NOT_SUPPORTED ULL(0x0) ++ ++/* ID_AA64MMFR2_EL1 definitions */ ++#define ID_AA64MMFR2_EL1 S3_0_C0_C7_2 ++ ++#define ID_AA64MMFR2_EL1_ST_SHIFT U(28) ++#define ID_AA64MMFR2_EL1_ST_MASK ULL(0xf) ++ ++#define ID_AA64MMFR2_EL1_CNP_SHIFT U(0) ++#define ID_AA64MMFR2_EL1_CNP_MASK ULL(0xf) ++ ++/* ID_AA64PFR1_EL1 definitions */ ++#define ID_AA64PFR1_EL1_SSBS_SHIFT U(4) ++#define ID_AA64PFR1_EL1_SSBS_MASK ULL(0xf) ++ ++#define SSBS_UNAVAILABLE ULL(0) /* No architectural SSBS support */ ++ ++#define ID_AA64PFR1_EL1_BT_SHIFT U(0) ++#define ID_AA64PFR1_EL1_BT_MASK ULL(0xf) ++ ++#define BTI_IMPLEMENTED ULL(1) /* The BTI mechanism is implemented */ ++ ++#define ID_AA64PFR1_EL1_MTE_SHIFT U(8) ++#define ID_AA64PFR1_EL1_MTE_MASK ULL(0xf) ++ ++#define MTE_UNIMPLEMENTED ULL(0) ++#define MTE_IMPLEMENTED_EL0 ULL(1) /* MTE is only implemented at EL0 */ ++#define MTE_IMPLEMENTED_ELX ULL(2) /* MTE is implemented at all ELs */ ++ ++/* ID_PFR1_EL1 definitions */ ++#define ID_PFR1_VIRTEXT_SHIFT U(12) ++#define ID_PFR1_VIRTEXT_MASK U(0xf) ++#define GET_VIRT_EXT(id) (((id) >> ID_PFR1_VIRTEXT_SHIFT) \ ++ & ID_PFR1_VIRTEXT_MASK) ++ ++/* SCTLR definitions */ ++#define SCTLR_EL2_RES1 ((U(1) << 29) | (U(1) << 28) | (U(1) << 23) | \ ++ (U(1) << 22) | (U(1) << 18) | (U(1) << 16) | \ ++ (U(1) << 11) | (U(1) << 5) | (U(1) << 4)) ++ ++#define SCTLR_EL1_RES1 ((U(1) << 29) | (U(1) << 28) | (U(1) << 23) | \ ++ (U(1) << 22) | (U(1) << 20) | (U(1) << 11)) ++#define SCTLR_AARCH32_EL1_RES1 \ ++ ((U(1) << 23) | (U(1) << 22) | (U(1) << 11) | \ ++ (U(1) << 4) | (U(1) << 3)) ++ ++#define SCTLR_EL3_RES1 ((U(1) << 29) | (U(1) << 28) | (U(1) << 23) | \ ++ (U(1) << 22) | (U(1) << 18) | (U(1) << 16) | \ ++ (U(1) << 11) | (U(1) << 5) | (U(1) << 4)) ++ ++#define SCTLR_M_BIT (ULL(1) << 0) ++#define SCTLR_A_BIT (ULL(1) << 1) ++#define SCTLR_C_BIT (ULL(1) << 2) ++#define SCTLR_SA_BIT (ULL(1) << 3) ++#define SCTLR_SA0_BIT (ULL(1) << 4) ++#define SCTLR_CP15BEN_BIT (ULL(1) << 5) ++#define SCTLR_ITD_BIT (ULL(1) << 7) ++#define SCTLR_SED_BIT (ULL(1) << 8) ++#define SCTLR_UMA_BIT (ULL(1) << 9) ++#define SCTLR_I_BIT (ULL(1) << 12) ++#define SCTLR_EnDB_BIT (ULL(1) << 13) ++#define SCTLR_DZE_BIT (ULL(1) << 14) ++#define SCTLR_UCT_BIT (ULL(1) << 15) ++#define SCTLR_NTWI_BIT (ULL(1) << 16) ++#define SCTLR_NTWE_BIT (ULL(1) << 18) ++#define SCTLR_WXN_BIT (ULL(1) << 19) ++#define SCTLR_UWXN_BIT (ULL(1) << 20) ++#define SCTLR_IESB_BIT (ULL(1) << 21) ++#define SCTLR_E0E_BIT (ULL(1) << 24) ++#define SCTLR_EE_BIT (ULL(1) << 25) ++#define SCTLR_UCI_BIT (ULL(1) << 26) ++#define SCTLR_EnDA_BIT (ULL(1) << 27) ++#define SCTLR_EnIB_BIT (ULL(1) << 30) ++#define SCTLR_EnIA_BIT (ULL(1) << 31) ++#define SCTLR_DSSBS_BIT (ULL(1) << 44) ++#define SCTLR_RESET_VAL SCTLR_EL3_RES1 ++ ++/* CPACR_El1 definitions */ ++#define CPACR_EL1_FPEN(x) ((x) << 20) ++#define CPACR_EL1_FP_TRAP_EL0 U(0x1) ++#define CPACR_EL1_FP_TRAP_ALL U(0x2) ++#define CPACR_EL1_FP_TRAP_NONE U(0x3) ++ ++/* SCR definitions */ ++#define SCR_RES1_BITS ((U(1) << 4) | (U(1) << 5)) ++#define SCR_ATA_BIT (U(1) << 26) ++#define SCR_FIEN_BIT (U(1) << 21) ++#define SCR_API_BIT (U(1) << 17) ++#define SCR_APK_BIT (U(1) << 16) ++#define SCR_TWE_BIT (U(1) << 13) ++#define SCR_TWI_BIT (U(1) << 12) ++#define SCR_ST_BIT (U(1) << 11) ++#define SCR_RW_BIT (U(1) << 10) ++#define SCR_SIF_BIT (U(1) << 9) ++#define SCR_HCE_BIT (U(1) << 8) ++#define SCR_SMD_BIT (U(1) << 7) ++#define SCR_EA_BIT (U(1) << 3) ++#define SCR_FIQ_BIT (U(1) << 2) ++#define SCR_IRQ_BIT (U(1) << 1) ++#define SCR_NS_BIT (U(1) << 0) ++#define SCR_VALID_BIT_MASK U(0x2f8f) ++#define SCR_RESET_VAL SCR_RES1_BITS ++ ++/* MDCR_EL3 definitions */ ++#define MDCR_SPD32(x) ((x) << 14) ++#define MDCR_SPD32_LEGACY ULL(0x0) ++#define MDCR_SPD32_DISABLE ULL(0x2) ++#define MDCR_SPD32_ENABLE ULL(0x3) ++#define MDCR_SDD_BIT (ULL(1) << 16) ++#define MDCR_NSPB(x) ((x) << 12) ++#define MDCR_NSPB_EL1 ULL(0x3) ++#define MDCR_TDOSA_BIT (ULL(1) << 10) ++#define MDCR_TDA_BIT (ULL(1) << 9) ++#define MDCR_TPM_BIT (ULL(1) << 6) ++#define MDCR_SCCD_BIT (ULL(1) << 23) ++#define MDCR_EL3_RESET_VAL ULL(0x0) ++ ++/* MDCR_EL2 definitions */ ++#define MDCR_EL2_TPMS (U(1) << 14) ++#define MDCR_EL2_E2PB(x) ((x) << 12) ++#define MDCR_EL2_E2PB_EL1 U(0x3) ++#define MDCR_EL2_TDRA_BIT (U(1) << 11) ++#define MDCR_EL2_TDOSA_BIT (U(1) << 10) ++#define MDCR_EL2_TDA_BIT (U(1) << 9) ++#define MDCR_EL2_TDE_BIT (U(1) << 8) ++#define MDCR_EL2_HPME_BIT (U(1) << 7) ++#define MDCR_EL2_TPM_BIT (U(1) << 6) ++#define MDCR_EL2_TPMCR_BIT (U(1) << 5) ++#define MDCR_EL2_RESET_VAL U(0x0) ++ ++/* HSTR_EL2 definitions */ ++#define HSTR_EL2_RESET_VAL U(0x0) ++#define HSTR_EL2_T_MASK U(0xff) ++ ++/* CNTHP_CTL_EL2 definitions */ ++#define CNTHP_CTL_ENABLE_BIT (U(1) << 0) ++#define CNTHP_CTL_RESET_VAL U(0x0) ++ ++/* VTTBR_EL2 definitions */ ++#define VTTBR_RESET_VAL ULL(0x0) ++#define VTTBR_VMID_MASK ULL(0xff) ++#define VTTBR_VMID_SHIFT U(48) ++#define VTTBR_BADDR_MASK ULL(0xffffffffffff) ++#define VTTBR_BADDR_SHIFT U(0) ++ ++/* HCR definitions */ ++#define HCR_API_BIT (ULL(1) << 41) ++#define HCR_APK_BIT (ULL(1) << 40) ++#define HCR_TGE_BIT (ULL(1) << 27) ++#define HCR_RW_SHIFT U(31) ++#define HCR_RW_BIT (ULL(1) << HCR_RW_SHIFT) ++#define HCR_AMO_BIT (ULL(1) << 5) ++#define HCR_IMO_BIT (ULL(1) << 4) ++#define HCR_FMO_BIT (ULL(1) << 3) ++ ++/* ISR definitions */ ++#define ISR_A_SHIFT U(8) ++#define ISR_I_SHIFT U(7) ++#define ISR_F_SHIFT U(6) ++ ++/* CNTHCTL_EL2 definitions */ ++#define CNTHCTL_RESET_VAL U(0x0) ++#define EVNTEN_BIT (U(1) << 2) ++#define EL1PCEN_BIT (U(1) << 1) ++#define EL1PCTEN_BIT (U(1) << 0) ++ ++/* CNTKCTL_EL1 definitions */ ++#define EL0PTEN_BIT (U(1) << 9) ++#define EL0VTEN_BIT (U(1) << 8) ++#define EL0PCTEN_BIT (U(1) << 0) ++#define EL0VCTEN_BIT (U(1) << 1) ++#define EVNTEN_BIT (U(1) << 2) ++#define EVNTDIR_BIT (U(1) << 3) ++#define EVNTI_SHIFT U(4) ++#define EVNTI_MASK U(0xf) ++ ++/* CPTR_EL3 definitions */ ++#define TCPAC_BIT (U(1) << 31) ++#define TAM_BIT (U(1) << 30) ++#define TTA_BIT (U(1) << 20) ++#define TFP_BIT (U(1) << 10) ++#define CPTR_EZ_BIT (U(1) << 8) ++#define CPTR_EL3_RESET_VAL U(0x0) ++ ++/* CPTR_EL2 definitions */ ++#define CPTR_EL2_RES1 ((ULL(3) << 12) | (ULL(1) << 9) | (ULL(0xff))) ++#define CPTR_EL2_TCPAC_BIT (ULL(1) << 31) ++#define CPTR_EL2_TAM_BIT (ULL(1) << 30) ++#define CPTR_EL2_TTA_BIT (ULL(1) << 20) ++#define CPTR_EL2_TFP_BIT (ULL(1) << 10) ++#define CPTR_EL2_TZ_BIT (ULL(1) << 8) ++#define CPTR_EL2_RESET_VAL CPTR_EL2_RES1 ++ ++/* CPSR/SPSR definitions */ ++#define DAIF_FIQ_BIT (U(1) << 0) ++#define DAIF_IRQ_BIT (U(1) << 1) ++#define DAIF_ABT_BIT (U(1) << 2) ++#define DAIF_DBG_BIT (U(1) << 3) ++#define SPSR_DAIF_SHIFT U(6) ++#define SPSR_DAIF_MASK U(0xf) ++ ++#define SPSR_AIF_SHIFT U(6) ++#define SPSR_AIF_MASK U(0x7) ++ ++#define SPSR_E_SHIFT U(9) ++#define SPSR_E_MASK U(0x1) ++#define SPSR_E_LITTLE U(0x0) ++#define SPSR_E_BIG U(0x1) ++ ++#define SPSR_T_SHIFT U(5) ++#define SPSR_T_MASK U(0x1) ++#define SPSR_T_ARM U(0x0) ++#define SPSR_T_THUMB U(0x1) ++ ++#define SPSR_M_SHIFT U(4) ++#define SPSR_M_MASK U(0x1) ++#define SPSR_M_AARCH64 U(0x0) ++#define SPSR_M_AARCH32 U(0x1) ++ ++#define DISABLE_ALL_EXCEPTIONS \ ++ (DAIF_FIQ_BIT | DAIF_IRQ_BIT | DAIF_ABT_BIT | DAIF_DBG_BIT) ++ ++#define DISABLE_INTERRUPTS (DAIF_FIQ_BIT | DAIF_IRQ_BIT) ++ ++/* ++ * RMR_EL3 definitions ++ */ ++#define RMR_EL3_RR_BIT (U(1) << 1) ++#define RMR_EL3_AA64_BIT (U(1) << 0) ++ ++/* ++ * HI-VECTOR address for AArch32 state ++ */ ++#define HI_VECTOR_BASE U(0xFFFF0000) ++ ++/* ++ * TCR defintions ++ */ ++#define TCR_EL3_RES1 ((ULL(1) << 31) | (ULL(1) << 23)) ++#define TCR_EL2_RES1 ((ULL(1) << 31) | (ULL(1) << 23)) ++#define TCR_EL1_IPS_SHIFT U(32) ++#define TCR_EL2_PS_SHIFT U(16) ++#define TCR_EL3_PS_SHIFT U(16) ++ ++#define TCR_TxSZ_MIN ULL(16) ++#define TCR_TxSZ_MAX ULL(39) ++#define TCR_TxSZ_MAX_TTST ULL(48) ++ ++#define TCR_T0SZ_SHIFT U(0) ++#define TCR_T1SZ_SHIFT U(16) ++ ++/* (internal) physical address size bits in EL3/EL1 */ ++#define TCR_PS_BITS_4GB ULL(0x0) ++#define TCR_PS_BITS_64GB ULL(0x1) ++#define TCR_PS_BITS_1TB ULL(0x2) ++#define TCR_PS_BITS_4TB ULL(0x3) ++#define TCR_PS_BITS_16TB ULL(0x4) ++#define TCR_PS_BITS_256TB ULL(0x5) ++ ++#define ADDR_MASK_48_TO_63 ULL(0xFFFF000000000000) ++#define ADDR_MASK_44_TO_47 ULL(0x0000F00000000000) ++#define ADDR_MASK_42_TO_43 ULL(0x00000C0000000000) ++#define ADDR_MASK_40_TO_41 ULL(0x0000030000000000) ++#define ADDR_MASK_36_TO_39 ULL(0x000000F000000000) ++#define ADDR_MASK_32_TO_35 ULL(0x0000000F00000000) ++ ++#define TCR_RGN_INNER_NC (ULL(0x0) << 8) ++#define TCR_RGN_INNER_WBA (ULL(0x1) << 8) ++#define TCR_RGN_INNER_WT (ULL(0x2) << 8) ++#define TCR_RGN_INNER_WBNA (ULL(0x3) << 8) ++ ++#define TCR_RGN_OUTER_NC (ULL(0x0) << 10) ++#define TCR_RGN_OUTER_WBA (ULL(0x1) << 10) ++#define TCR_RGN_OUTER_WT (ULL(0x2) << 10) ++#define TCR_RGN_OUTER_WBNA (ULL(0x3) << 10) ++ ++#define TCR_SH_NON_SHAREABLE (ULL(0x0) << 12) ++#define TCR_SH_OUTER_SHAREABLE (ULL(0x2) << 12) ++#define TCR_SH_INNER_SHAREABLE (ULL(0x3) << 12) ++ ++#define TCR_RGN1_INNER_NC (ULL(0x0) << 24) ++#define TCR_RGN1_INNER_WBA (ULL(0x1) << 24) ++#define TCR_RGN1_INNER_WT (ULL(0x2) << 24) ++#define TCR_RGN1_INNER_WBNA (ULL(0x3) << 24) ++ ++#define TCR_RGN1_OUTER_NC (ULL(0x0) << 26) ++#define TCR_RGN1_OUTER_WBA (ULL(0x1) << 26) ++#define TCR_RGN1_OUTER_WT (ULL(0x2) << 26) ++#define TCR_RGN1_OUTER_WBNA (ULL(0x3) << 26) ++ ++#define TCR_SH1_NON_SHAREABLE (ULL(0x0) << 28) ++#define TCR_SH1_OUTER_SHAREABLE (ULL(0x2) << 28) ++#define TCR_SH1_INNER_SHAREABLE (ULL(0x3) << 28) ++ ++#define TCR_TG0_SHIFT U(14) ++#define TCR_TG0_MASK ULL(3) ++#define TCR_TG0_4K (ULL(0) << TCR_TG0_SHIFT) ++#define TCR_TG0_64K (ULL(1) << TCR_TG0_SHIFT) ++#define TCR_TG0_16K (ULL(2) << TCR_TG0_SHIFT) ++ ++#define TCR_TG1_SHIFT U(30) ++#define TCR_TG1_MASK ULL(3) ++#define TCR_TG1_16K (ULL(1) << TCR_TG1_SHIFT) ++#define TCR_TG1_4K (ULL(2) << TCR_TG1_SHIFT) ++#define TCR_TG1_64K (ULL(3) << TCR_TG1_SHIFT) ++ ++#define TCR_EPD0_BIT (ULL(1) << 7) ++#define TCR_EPD1_BIT (ULL(1) << 23) ++ ++#define MODE_SP_SHIFT U(0x0) ++#define MODE_SP_MASK U(0x1) ++#define MODE_SP_EL0 U(0x0) ++#define MODE_SP_ELX U(0x1) ++ ++#define MODE_RW_SHIFT U(0x4) ++#define MODE_RW_MASK U(0x1) ++#define MODE_RW_64 U(0x0) ++#define MODE_RW_32 U(0x1) ++ ++#define MODE_EL_SHIFT U(0x2) ++#define MODE_EL_MASK U(0x3) ++#define MODE_EL3 U(0x3) ++#define MODE_EL2 U(0x2) ++#define MODE_EL1 U(0x1) ++#define MODE_EL0 U(0x0) ++ ++#define MODE32_SHIFT U(0) ++#define MODE32_MASK U(0xf) ++#define MODE32_usr U(0x0) ++#define MODE32_fiq U(0x1) ++#define MODE32_irq U(0x2) ++#define MODE32_svc U(0x3) ++#define MODE32_mon U(0x6) ++#define MODE32_abt U(0x7) ++#define MODE32_hyp U(0xa) ++#define MODE32_und U(0xb) ++#define MODE32_sys U(0xf) ++ ++#define GET_RW(mode) (((mode) >> MODE_RW_SHIFT) & MODE_RW_MASK) ++#define GET_EL(mode) (((mode) >> MODE_EL_SHIFT) & MODE_EL_MASK) ++#define GET_SP(mode) (((mode) >> MODE_SP_SHIFT) & MODE_SP_MASK) ++#define GET_M32(mode) (((mode) >> MODE32_SHIFT) & MODE32_MASK) ++ ++#define SPSR_64(el, sp, daif) \ ++ ((MODE_RW_64 << MODE_RW_SHIFT) | \ ++ (((el) & MODE_EL_MASK) << MODE_EL_SHIFT) | \ ++ (((sp) & MODE_SP_MASK) << MODE_SP_SHIFT) | \ ++ (((daif) & SPSR_DAIF_MASK) << SPSR_DAIF_SHIFT)) ++ ++#define SPSR_MODE32(mode, isa, endian, aif) \ ++ ((MODE_RW_32 << MODE_RW_SHIFT) | \ ++ (((mode) & MODE32_MASK) << MODE32_SHIFT) | \ ++ (((isa) & SPSR_T_MASK) << SPSR_T_SHIFT) | \ ++ (((endian) & SPSR_E_MASK) << SPSR_E_SHIFT) | \ ++ (((aif) & SPSR_AIF_MASK) << SPSR_AIF_SHIFT)) ++ ++/* ++ * TTBR Definitions ++ */ ++#define TTBR_CNP_BIT ULL(0x1) ++ ++/* ++ * CTR_EL0 definitions ++ */ ++#define CTR_CWG_SHIFT U(24) ++#define CTR_CWG_MASK U(0xf) ++#define CTR_ERG_SHIFT U(20) ++#define CTR_ERG_MASK U(0xf) ++#define CTR_DMINLINE_SHIFT U(16) ++#define CTR_DMINLINE_MASK U(0xf) ++#define CTR_L1IP_SHIFT U(14) ++#define CTR_L1IP_MASK U(0x3) ++#define CTR_IMINLINE_SHIFT U(0) ++#define CTR_IMINLINE_MASK U(0xf) ++ ++#define MAX_CACHE_LINE_SIZE U(0x800) /* 2KB */ ++ ++/* Physical timer control register bit fields shifts and masks */ ++#define CNTP_CTL_ENABLE_SHIFT U(0) ++#define CNTP_CTL_IMASK_SHIFT U(1) ++#define CNTP_CTL_ISTATUS_SHIFT U(2) ++ ++#define CNTP_CTL_ENABLE_MASK U(1) ++#define CNTP_CTL_IMASK_MASK U(1) ++#define CNTP_CTL_ISTATUS_MASK U(1) ++ ++/* Exception Syndrome register bits and bobs */ ++#define ESR_EC_SHIFT U(26) ++#define ESR_EC_MASK U(0x3f) ++#define ESR_EC_LENGTH U(6) ++#define EC_UNKNOWN U(0x0) ++#define EC_WFE_WFI U(0x1) ++#define EC_AARCH32_CP15_MRC_MCR U(0x3) ++#define EC_AARCH32_CP15_MRRC_MCRR U(0x4) ++#define EC_AARCH32_CP14_MRC_MCR U(0x5) ++#define EC_AARCH32_CP14_LDC_STC U(0x6) ++#define EC_FP_SIMD U(0x7) ++#define EC_AARCH32_CP10_MRC U(0x8) ++#define EC_AARCH32_CP14_MRRC_MCRR U(0xc) ++#define EC_ILLEGAL U(0xe) ++#define EC_AARCH32_SVC U(0x11) ++#define EC_AARCH32_HVC U(0x12) ++#define EC_AARCH32_SMC U(0x13) ++#define EC_AARCH64_SVC U(0x15) ++#define EC_AARCH64_HVC U(0x16) ++#define EC_AARCH64_SMC U(0x17) ++#define EC_AARCH64_SYS U(0x18) ++#define EC_IABORT_LOWER_EL U(0x20) ++#define EC_IABORT_CUR_EL U(0x21) ++#define EC_PC_ALIGN U(0x22) ++#define EC_DABORT_LOWER_EL U(0x24) ++#define EC_DABORT_CUR_EL U(0x25) ++#define EC_SP_ALIGN U(0x26) ++#define EC_AARCH32_FP U(0x28) ++#define EC_AARCH64_FP U(0x2c) ++#define EC_SERROR U(0x2f) ++ ++/* ++ * External Abort bit in Instruction and Data Aborts synchronous exception ++ * syndromes. ++ */ ++#define ESR_ISS_EABORT_EA_BIT U(9) ++ ++#define EC_BITS(x) (((x) >> ESR_EC_SHIFT) & ESR_EC_MASK) ++ ++/* Reset bit inside the Reset management register for EL3 (RMR_EL3) */ ++#define RMR_RESET_REQUEST_SHIFT U(0x1) ++#define RMR_WARM_RESET_CPU (U(1) << RMR_RESET_REQUEST_SHIFT) ++ ++/******************************************************************************* ++ * Definitions of register offsets, fields and macros for CPU system ++ * instructions. ++ ******************************************************************************/ ++ ++#define TLBI_ADDR_SHIFT U(12) ++#define TLBI_ADDR_MASK ULL(0x00000FFFFFFFFFFF) ++#define TLBI_ADDR(x) (((x) >> TLBI_ADDR_SHIFT) & TLBI_ADDR_MASK) ++ ++/******************************************************************************* ++ * Definitions of register offsets and fields in the CNTCTLBase Frame of the ++ * system level implementation of the Generic Timer. ++ ******************************************************************************/ ++#define CNTCTLBASE_CNTFRQ U(0x0) ++#define CNTNSAR U(0x4) ++#define CNTNSAR_NS_SHIFT(x) (x) ++ ++#define CNTACR_BASE(x) (U(0x40) + ((x) << 2)) ++#define CNTACR_RPCT_SHIFT U(0x0) ++#define CNTACR_RVCT_SHIFT U(0x1) ++#define CNTACR_RFRQ_SHIFT U(0x2) ++#define CNTACR_RVOFF_SHIFT U(0x3) ++#define CNTACR_RWVT_SHIFT U(0x4) ++#define CNTACR_RWPT_SHIFT U(0x5) ++ ++/******************************************************************************* ++ * Definitions of register offsets and fields in the CNTBaseN Frame of the ++ * system level implementation of the Generic Timer. ++ ******************************************************************************/ ++/* Physical Count register. */ ++#define CNTPCT_LO U(0x0) ++/* Counter Frequency register. */ ++#define CNTBASEN_CNTFRQ U(0x10) ++/* Physical Timer CompareValue register. */ ++#define CNTP_CVAL_LO U(0x20) ++/* Physical Timer Control register. */ ++#define CNTP_CTL U(0x2c) ++ ++/* PMCR_EL0 definitions */ ++#define PMCR_EL0_RESET_VAL U(0x0) ++#define PMCR_EL0_N_SHIFT U(11) ++#define PMCR_EL0_N_MASK U(0x1f) ++#define PMCR_EL0_N_BITS (PMCR_EL0_N_MASK << PMCR_EL0_N_SHIFT) ++#define PMCR_EL0_LC_BIT (U(1) << 6) ++#define PMCR_EL0_DP_BIT (U(1) << 5) ++#define PMCR_EL0_X_BIT (U(1) << 4) ++#define PMCR_EL0_D_BIT (U(1) << 3) ++#define PMCR_EL0_E_BIT (U(1) << 0) ++ ++/* PMCNTENSET_EL0 definitions */ ++#define PMCNTENSET_EL0_C_BIT (U(1) << 31) ++#define PMCNTENSET_EL0_P_BIT(x) (U(1) << x) ++ ++/* PMEVTYPER_EL0 definitions */ ++#define PMEVTYPER_EL0_P_BIT (U(1) << 31) ++#define PMEVTYPER_EL0_NSK_BIT (U(1) << 29) ++#define PMEVTYPER_EL0_NSH_BIT (U(1) << 27) ++#define PMEVTYPER_EL0_M_BIT (U(1) << 26) ++#define PMEVTYPER_EL0_MT_BIT (U(1) << 25) ++#define PMEVTYPER_EL0_SH_BIT (U(1) << 24) ++#define PMEVTYPER_EL0_EVTCOUNT_BITS U(0x000003FF) ++ ++/* PMCCFILTR_EL0 definitions */ ++#define PMCCFILTR_EL0_P_BIT (U(1) << 31) ++#define PMCCFILTR_EL0_NSK_BIT (U(1) << 29) ++#define PMCCFILTR_EL0_NSH_BIT (U(1) << 27) ++#define PMCCFILTR_EL0_M_BIT (U(1) << 26) ++#define PMCCFILTR_EL0_MT_BIT (U(1) << 25) ++#define PMCCFILTR_EL0_SH_BIT (U(1) << 24) ++ ++/* PMU event counter ID definitions */ ++#define PMU_EV_PC_WRITE_RETIRED U(0x000C) ++ ++/******************************************************************************* ++ * Definitions for system register interface to SVE ++ ******************************************************************************/ ++#define ZCR_EL3 S3_6_C1_C2_0 ++#define ZCR_EL2 S3_4_C1_C2_0 ++ ++/* ZCR_EL3 definitions */ ++#define ZCR_EL3_LEN_MASK U(0xf) ++ ++/* ZCR_EL2 definitions */ ++#define ZCR_EL2_LEN_MASK U(0xf) ++ ++/******************************************************************************* ++ * Definitions of MAIR encodings for device and normal memory ++ ******************************************************************************/ ++/* ++ * MAIR encodings for device memory attributes. ++ */ ++#define MAIR_DEV_nGnRnE ULL(0x0) ++#define MAIR_DEV_nGnRE ULL(0x4) ++#define MAIR_DEV_nGRE ULL(0x8) ++#define MAIR_DEV_GRE ULL(0xc) ++ ++/* ++ * MAIR encodings for normal memory attributes. ++ * ++ * Cache Policy ++ * WT: Write Through ++ * WB: Write Back ++ * NC: Non-Cacheable ++ * ++ * Transient Hint ++ * NTR: Non-Transient ++ * TR: Transient ++ * ++ * Allocation Policy ++ * RA: Read Allocate ++ * WA: Write Allocate ++ * RWA: Read and Write Allocate ++ * NA: No Allocation ++ */ ++#define MAIR_NORM_WT_TR_WA ULL(0x1) ++#define MAIR_NORM_WT_TR_RA ULL(0x2) ++#define MAIR_NORM_WT_TR_RWA ULL(0x3) ++#define MAIR_NORM_NC ULL(0x4) ++#define MAIR_NORM_WB_TR_WA ULL(0x5) ++#define MAIR_NORM_WB_TR_RA ULL(0x6) ++#define MAIR_NORM_WB_TR_RWA ULL(0x7) ++#define MAIR_NORM_WT_NTR_NA ULL(0x8) ++#define MAIR_NORM_WT_NTR_WA ULL(0x9) ++#define MAIR_NORM_WT_NTR_RA ULL(0xa) ++#define MAIR_NORM_WT_NTR_RWA ULL(0xb) ++#define MAIR_NORM_WB_NTR_NA ULL(0xc) ++#define MAIR_NORM_WB_NTR_WA ULL(0xd) ++#define MAIR_NORM_WB_NTR_RA ULL(0xe) ++#define MAIR_NORM_WB_NTR_RWA ULL(0xf) ++ ++#define MAIR_NORM_OUTER_SHIFT U(4) ++ ++#define MAKE_MAIR_NORMAL_MEMORY(inner, outer) \ ++ ((inner) | ((outer) << MAIR_NORM_OUTER_SHIFT)) ++ ++/* PAR_EL1 fields */ ++#define PAR_F_SHIFT U(0) ++#define PAR_F_MASK ULL(0x1) ++#define PAR_ADDR_SHIFT U(12) ++#define PAR_ADDR_MASK (BIT(40) - ULL(1)) /* 40-bits-wide page address */ ++ ++/******************************************************************************* ++ * Definitions for system register interface to SPE ++ ******************************************************************************/ ++#define PMBLIMITR_EL1 S3_0_C9_C10_0 ++ ++/******************************************************************************* ++ * Definitions for system register interface to MPAM ++ ******************************************************************************/ ++#define MPAMIDR_EL1 S3_0_C10_C4_4 ++#define MPAM2_EL2 S3_4_C10_C5_0 ++#define MPAMHCR_EL2 S3_4_C10_C4_0 ++#define MPAM3_EL3 S3_6_C10_C5_0 ++ ++/******************************************************************************* ++ * Definitions for system register interface to AMU for ARMv8.4 onwards ++ ******************************************************************************/ ++#define AMCR_EL0 S3_3_C13_C2_0 ++#define AMCFGR_EL0 S3_3_C13_C2_1 ++#define AMCGCR_EL0 S3_3_C13_C2_2 ++#define AMUSERENR_EL0 S3_3_C13_C2_3 ++#define AMCNTENCLR0_EL0 S3_3_C13_C2_4 ++#define AMCNTENSET0_EL0 S3_3_C13_C2_5 ++#define AMCNTENCLR1_EL0 S3_3_C13_C3_0 ++#define AMCNTENSET1_EL0 S3_3_C13_C3_1 ++ ++/* Activity Monitor Group 0 Event Counter Registers */ ++#define AMEVCNTR00_EL0 S3_3_C13_C4_0 ++#define AMEVCNTR01_EL0 S3_3_C13_C4_1 ++#define AMEVCNTR02_EL0 S3_3_C13_C4_2 ++#define AMEVCNTR03_EL0 S3_3_C13_C4_3 ++ ++/* Activity Monitor Group 0 Event Type Registers */ ++#define AMEVTYPER00_EL0 S3_3_C13_C6_0 ++#define AMEVTYPER01_EL0 S3_3_C13_C6_1 ++#define AMEVTYPER02_EL0 S3_3_C13_C6_2 ++#define AMEVTYPER03_EL0 S3_3_C13_C6_3 ++ ++/* Activity Monitor Group 1 Event Counter Registers */ ++#define AMEVCNTR10_EL0 S3_3_C13_C12_0 ++#define AMEVCNTR11_EL0 S3_3_C13_C12_1 ++#define AMEVCNTR12_EL0 S3_3_C13_C12_2 ++#define AMEVCNTR13_EL0 S3_3_C13_C12_3 ++#define AMEVCNTR14_EL0 S3_3_C13_C12_4 ++#define AMEVCNTR15_EL0 S3_3_C13_C12_5 ++#define AMEVCNTR16_EL0 S3_3_C13_C12_6 ++#define AMEVCNTR17_EL0 S3_3_C13_C12_7 ++#define AMEVCNTR18_EL0 S3_3_C13_C13_0 ++#define AMEVCNTR19_EL0 S3_3_C13_C13_1 ++#define AMEVCNTR1A_EL0 S3_3_C13_C13_2 ++#define AMEVCNTR1B_EL0 S3_3_C13_C13_3 ++#define AMEVCNTR1C_EL0 S3_3_C13_C13_4 ++#define AMEVCNTR1D_EL0 S3_3_C13_C13_5 ++#define AMEVCNTR1E_EL0 S3_3_C13_C13_6 ++#define AMEVCNTR1F_EL0 S3_3_C13_C13_7 ++ ++/* Activity Monitor Group 1 Event Type Registers */ ++#define AMEVTYPER10_EL0 S3_3_C13_C14_0 ++#define AMEVTYPER11_EL0 S3_3_C13_C14_1 ++#define AMEVTYPER12_EL0 S3_3_C13_C14_2 ++#define AMEVTYPER13_EL0 S3_3_C13_C14_3 ++#define AMEVTYPER14_EL0 S3_3_C13_C14_4 ++#define AMEVTYPER15_EL0 S3_3_C13_C14_5 ++#define AMEVTYPER16_EL0 S3_3_C13_C14_6 ++#define AMEVTYPER17_EL0 S3_3_C13_C14_7 ++#define AMEVTYPER18_EL0 S3_3_C13_C15_0 ++#define AMEVTYPER19_EL0 S3_3_C13_C15_1 ++#define AMEVTYPER1A_EL0 S3_3_C13_C15_2 ++#define AMEVTYPER1B_EL0 S3_3_C13_C15_3 ++#define AMEVTYPER1C_EL0 S3_3_C13_C15_4 ++#define AMEVTYPER1D_EL0 S3_3_C13_C15_5 ++#define AMEVTYPER1E_EL0 S3_3_C13_C15_6 ++#define AMEVTYPER1F_EL0 S3_3_C13_C15_7 ++ ++/* AMCGCR_EL0 definitions */ ++#define AMCGCR_EL0_CG1NC_SHIFT U(8) ++#define AMCGCR_EL0_CG1NC_LENGTH U(8) ++#define AMCGCR_EL0_CG1NC_MASK U(0xff) ++ ++/* MPAM register definitions */ ++#define MPAM3_EL3_MPAMEN_BIT (ULL(1) << 63) ++#define MPAMHCR_EL2_TRAP_MPAMIDR_EL1 (ULL(1) << 31) ++ ++#define MPAM2_EL2_TRAPMPAM0EL1 (ULL(1) << 49) ++#define MPAM2_EL2_TRAPMPAM1EL1 (ULL(1) << 48) ++ ++#define MPAMIDR_HAS_HCR_BIT (ULL(1) << 17) ++ ++/******************************************************************************* ++ * RAS system registers ++ ******************************************************************************/ ++#define DISR_EL1 S3_0_C12_C1_1 ++#define DISR_A_BIT U(31) ++ ++#define ERRIDR_EL1 S3_0_C5_C3_0 ++#define ERRIDR_MASK U(0xffff) ++ ++#define ERRSELR_EL1 S3_0_C5_C3_1 ++ ++/* System register access to Standard Error Record registers */ ++#define ERXFR_EL1 S3_0_C5_C4_0 ++#define ERXCTLR_EL1 S3_0_C5_C4_1 ++#define ERXSTATUS_EL1 S3_0_C5_C4_2 ++#define ERXADDR_EL1 S3_0_C5_C4_3 ++#define ERXPFGF_EL1 S3_0_C5_C4_4 ++#define ERXPFGCTL_EL1 S3_0_C5_C4_5 ++#define ERXPFGCDN_EL1 S3_0_C5_C4_6 ++#define ERXMISC0_EL1 S3_0_C5_C5_0 ++#define ERXMISC1_EL1 S3_0_C5_C5_1 ++ ++#define ERXCTLR_ED_BIT (U(1) << 0) ++#define ERXCTLR_UE_BIT (U(1) << 4) ++ ++#define ERXPFGCTL_UC_BIT (U(1) << 1) ++#define ERXPFGCTL_UEU_BIT (U(1) << 2) ++#define ERXPFGCTL_CDEN_BIT (U(1) << 31) ++ ++/******************************************************************************* ++ * Armv8.3 Pointer Authentication Registers ++ ******************************************************************************/ ++#define APIAKeyLo_EL1 S3_0_C2_C1_0 ++#define APIAKeyHi_EL1 S3_0_C2_C1_1 ++#define APIBKeyLo_EL1 S3_0_C2_C1_2 ++#define APIBKeyHi_EL1 S3_0_C2_C1_3 ++#define APDAKeyLo_EL1 S3_0_C2_C2_0 ++#define APDAKeyHi_EL1 S3_0_C2_C2_1 ++#define APDBKeyLo_EL1 S3_0_C2_C2_2 ++#define APDBKeyHi_EL1 S3_0_C2_C2_3 ++#define APGAKeyLo_EL1 S3_0_C2_C3_0 ++#define APGAKeyHi_EL1 S3_0_C2_C3_1 ++ ++/******************************************************************************* ++ * Armv8.4 Data Independent Timing Registers ++ ******************************************************************************/ ++#define DIT S3_3_C4_C2_5 ++#define DIT_BIT BIT(24) ++ ++/******************************************************************************* ++ * Armv8.5 - new MSR encoding to directly access PSTATE.SSBS field ++ ******************************************************************************/ ++#define SSBS S3_3_C4_C2_6 ++ ++/******************************************************************************* ++ * Armv8.5 - Memory Tagging Extension Registers ++ ******************************************************************************/ ++#define TFSRE0_EL1 S3_0_C5_C6_1 ++#define TFSR_EL1 S3_0_C5_C6_0 ++#define RGSR_EL1 S3_0_C1_C0_5 ++#define GCR_EL1 S3_0_C1_C0_6 ++ ++/******************************************************************************* ++ * Armv8.6 - Fine Grained Virtualization Traps Registers ++ ******************************************************************************/ ++#define HFGRTR_EL2 S3_4_C1_C1_4 ++#define HFGWTR_EL2 S3_4_C1_C1_5 ++#define HFGITR_EL2 S3_4_C1_C1_6 ++#define HDFGRTR_EL2 S3_4_C3_C1_4 ++#define HDFGWTR_EL2 S3_4_C3_C1_5 ++ ++/******************************************************************************* ++ * Armv8.6 - Enhanced Counter Virtualization Registers ++ ******************************************************************************/ ++#define CNTPOFF_EL2 S3_4_C14_C0_6 ++ ++ ++#endif /* ARCH_H */ +diff --git a/environments/shim/include/lib/aarch64/arch_features.h b/environments/shim/include/lib/aarch64/arch_features.h +new file mode 100644 +index 0000000..15eb784 +--- /dev/null ++++ b/environments/shim/include/lib/aarch64/arch_features.h +@@ -0,0 +1,95 @@ ++/* ++ * Copyright (c) 2020, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef ARCH_FEATURES_H ++#define ARCH_FEATURES_H ++ ++#include ++ ++#include ++ ++static inline bool is_armv7_gentimer_present(void) ++{ ++ /* The Generic Timer is always present in an ARMv8-A implementation */ ++ return true; ++} ++ ++static inline bool is_armv8_2_sve_present(void) ++{ ++ return ((read_id_aa64pfr0_el1() >> ID_AA64PFR0_SVE_SHIFT) & ++ ID_AA64PFR0_SVE_MASK) == 1U; ++} ++ ++static inline bool is_armv8_2_ttcnp_present(void) ++{ ++ return ((read_id_aa64mmfr2_el1() >> ID_AA64MMFR2_EL1_CNP_SHIFT) & ++ ID_AA64MMFR2_EL1_CNP_MASK) != 0U; ++} ++ ++static inline bool is_armv8_3_pauth_present(void) ++{ ++ uint64_t mask = (ID_AA64ISAR1_GPI_MASK << ID_AA64ISAR1_GPI_SHIFT) | ++ (ID_AA64ISAR1_GPA_MASK << ID_AA64ISAR1_GPA_SHIFT) | ++ (ID_AA64ISAR1_API_MASK << ID_AA64ISAR1_API_SHIFT) | ++ (ID_AA64ISAR1_APA_MASK << ID_AA64ISAR1_APA_SHIFT); ++ ++ /* If any of the fields is not zero, PAuth is present */ ++ return (read_id_aa64isar1_el1() & mask) != 0U; ++} ++ ++static inline bool is_armv8_3_pauth_apa_api_present(void) ++{ ++ uint64_t mask = (ID_AA64ISAR1_API_MASK << ID_AA64ISAR1_API_SHIFT) | ++ (ID_AA64ISAR1_APA_MASK << ID_AA64ISAR1_APA_SHIFT); ++ ++ return (read_id_aa64isar1_el1() & mask) != 0U; ++} ++ ++static inline bool is_armv8_3_pauth_gpa_gpi_present(void) ++{ ++ uint64_t mask = (ID_AA64ISAR1_GPI_MASK << ID_AA64ISAR1_GPI_SHIFT) | ++ (ID_AA64ISAR1_GPA_MASK << ID_AA64ISAR1_GPA_SHIFT); ++ ++ return (read_id_aa64isar1_el1() & mask) != 0U; ++} ++ ++static inline bool is_armv8_4_ttst_present(void) ++{ ++ return ((read_id_aa64mmfr2_el1() >> ID_AA64MMFR2_EL1_ST_SHIFT) & ++ ID_AA64MMFR2_EL1_ST_MASK) == 1U; ++} ++ ++static inline bool is_armv8_5_bti_present(void) ++{ ++ return ((read_id_aa64pfr1_el1() >> ID_AA64PFR1_EL1_BT_SHIFT) & ++ ID_AA64PFR1_EL1_BT_MASK) == BTI_IMPLEMENTED; ++} ++ ++static inline unsigned int get_armv8_5_mte_support(void) ++{ ++ return ((read_id_aa64pfr1_el1() >> ID_AA64PFR1_EL1_MTE_SHIFT) & ++ ID_AA64PFR1_EL1_MTE_MASK); ++} ++ ++static inline bool is_armv8_6_fgt_present(void) ++{ ++ return ((read_id_aa64mmfr0_el1() >> ID_AA64MMFR0_EL1_FGT_SHIFT) & ++ ID_AA64MMFR0_EL1_FGT_MASK) == ID_AA64MMFR0_EL1_FGT_SUPPORTED; ++} ++ ++static inline unsigned long int get_armv8_6_ecv_support(void) ++{ ++ return ((read_id_aa64mmfr0_el1() >> ID_AA64MMFR0_EL1_ECV_SHIFT) & ++ ID_AA64MMFR0_EL1_ECV_MASK); ++} ++ ++static inline uint32_t arch_get_debug_version(void) ++{ ++ return ((read_id_aa64dfr0_el1() & ID_AA64DFR0_DEBUG_BITS) >> ++ ID_AA64DFR0_DEBUG_SHIFT); ++} ++ ++#endif /* ARCH_FEATURES_H */ +diff --git a/environments/shim/include/lib/aarch64/arch_helpers.h b/environments/shim/include/lib/aarch64/arch_helpers.h +new file mode 100644 +index 0000000..9bcd0bb +--- /dev/null ++++ b/environments/shim/include/lib/aarch64/arch_helpers.h +@@ -0,0 +1,526 @@ ++/* ++ * Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef ARCH_HELPERS_H ++#define ARCH_HELPERS_H ++ ++#include ++#include ++#include ++#include ++#include ++ ++/********************************************************************** ++ * Macros which create inline functions to read or write CPU system ++ * registers ++ *********************************************************************/ ++ ++#define _DEFINE_SYSREG_READ_FUNC(_name, _reg_name) \ ++static inline u_register_t read_ ## _name(void) \ ++{ \ ++ u_register_t v; \ ++ __asm__ volatile ("mrs %0, " #_reg_name : "=r" (v)); \ ++ return v; \ ++} ++ ++#define _DEFINE_SYSREG_WRITE_FUNC(_name, _reg_name) \ ++static inline void write_ ## _name(u_register_t v) \ ++{ \ ++ __asm__ volatile ("msr " #_reg_name ", %0" : : "r" (v)); \ ++} ++ ++#define SYSREG_WRITE_CONST(reg_name, v) \ ++ __asm__ volatile ("msr " #reg_name ", %0" : : "i" (v)) ++ ++/* Define read function for system register */ ++#define DEFINE_SYSREG_READ_FUNC(_name) \ ++ _DEFINE_SYSREG_READ_FUNC(_name, _name) ++ ++/* Define read & write function for system register */ ++#define DEFINE_SYSREG_RW_FUNCS(_name) \ ++ _DEFINE_SYSREG_READ_FUNC(_name, _name) \ ++ _DEFINE_SYSREG_WRITE_FUNC(_name, _name) ++ ++/* Define read & write function for renamed system register */ ++#define DEFINE_RENAME_SYSREG_RW_FUNCS(_name, _reg_name) \ ++ _DEFINE_SYSREG_READ_FUNC(_name, _reg_name) \ ++ _DEFINE_SYSREG_WRITE_FUNC(_name, _reg_name) ++ ++/* Define read function for renamed system register */ ++#define DEFINE_RENAME_SYSREG_READ_FUNC(_name, _reg_name) \ ++ _DEFINE_SYSREG_READ_FUNC(_name, _reg_name) ++ ++/* Define write function for renamed system register */ ++#define DEFINE_RENAME_SYSREG_WRITE_FUNC(_name, _reg_name) \ ++ _DEFINE_SYSREG_WRITE_FUNC(_name, _reg_name) ++ ++/********************************************************************** ++ * Macros to create inline functions for system instructions ++ *********************************************************************/ ++ ++/* Define function for simple system instruction */ ++#define DEFINE_SYSOP_FUNC(_op) \ ++static inline void _op(void) \ ++{ \ ++ __asm__ (#_op); \ ++} ++ ++/* Define function for system instruction with type specifier */ ++#define DEFINE_SYSOP_TYPE_FUNC(_op, _type) \ ++static inline void _op ## _type(void) \ ++{ \ ++ __asm__ (#_op " " #_type); \ ++} ++ ++/* Define function for system instruction with register parameter */ ++#define DEFINE_SYSOP_TYPE_PARAM_FUNC(_op, _type) \ ++static inline void _op ## _type(uint64_t v) \ ++{ \ ++ __asm__ (#_op " " #_type ", %0" : : "r" (v)); \ ++} ++ ++/******************************************************************************* ++ * TLB maintenance accessor prototypes ++ ******************************************************************************/ ++ ++#if ERRATA_A57_813419 ++/* ++ * Define function for TLBI instruction with type specifier that implements ++ * the workaround for errata 813419 of Cortex-A57. ++ */ ++#define DEFINE_TLBIOP_ERRATA_A57_813419_TYPE_FUNC(_type)\ ++static inline void tlbi ## _type(void) \ ++{ \ ++ __asm__("tlbi " #_type "\n" \ ++ "dsb ish\n" \ ++ "tlbi " #_type); \ ++} ++ ++/* ++ * Define function for TLBI instruction with register parameter that implements ++ * the workaround for errata 813419 of Cortex-A57. ++ */ ++#define DEFINE_TLBIOP_ERRATA_A57_813419_TYPE_PARAM_FUNC(_type) \ ++static inline void tlbi ## _type(uint64_t v) \ ++{ \ ++ __asm__("tlbi " #_type ", %0\n" \ ++ "dsb ish\n" \ ++ "tlbi " #_type ", %0" : : "r" (v)); \ ++} ++#endif /* ERRATA_A57_813419 */ ++ ++DEFINE_SYSOP_TYPE_FUNC(tlbi, alle1) ++DEFINE_SYSOP_TYPE_FUNC(tlbi, alle1is) ++DEFINE_SYSOP_TYPE_FUNC(tlbi, alle2) ++DEFINE_SYSOP_TYPE_FUNC(tlbi, alle2is) ++#if ERRATA_A57_813419 ++DEFINE_TLBIOP_ERRATA_A57_813419_TYPE_FUNC(alle3) ++DEFINE_TLBIOP_ERRATA_A57_813419_TYPE_FUNC(alle3is) ++#else ++DEFINE_SYSOP_TYPE_FUNC(tlbi, alle3) ++DEFINE_SYSOP_TYPE_FUNC(tlbi, alle3is) ++#endif ++DEFINE_SYSOP_TYPE_FUNC(tlbi, vmalle1) ++ ++DEFINE_SYSOP_TYPE_PARAM_FUNC(tlbi, vaae1is) ++DEFINE_SYSOP_TYPE_PARAM_FUNC(tlbi, vaale1is) ++DEFINE_SYSOP_TYPE_PARAM_FUNC(tlbi, vae2is) ++DEFINE_SYSOP_TYPE_PARAM_FUNC(tlbi, vale2is) ++#if ERRATA_A57_813419 ++DEFINE_TLBIOP_ERRATA_A57_813419_TYPE_PARAM_FUNC(vae3is) ++DEFINE_TLBIOP_ERRATA_A57_813419_TYPE_PARAM_FUNC(vale3is) ++#else ++DEFINE_SYSOP_TYPE_PARAM_FUNC(tlbi, vae3is) ++DEFINE_SYSOP_TYPE_PARAM_FUNC(tlbi, vale3is) ++#endif ++ ++/******************************************************************************* ++ * Cache maintenance accessor prototypes ++ ******************************************************************************/ ++DEFINE_SYSOP_TYPE_PARAM_FUNC(dc, isw) ++DEFINE_SYSOP_TYPE_PARAM_FUNC(dc, cisw) ++DEFINE_SYSOP_TYPE_PARAM_FUNC(dc, csw) ++DEFINE_SYSOP_TYPE_PARAM_FUNC(dc, cvac) ++DEFINE_SYSOP_TYPE_PARAM_FUNC(dc, ivac) ++DEFINE_SYSOP_TYPE_PARAM_FUNC(dc, civac) ++DEFINE_SYSOP_TYPE_PARAM_FUNC(dc, cvau) ++DEFINE_SYSOP_TYPE_PARAM_FUNC(dc, zva) ++ ++/******************************************************************************* ++ * Address translation accessor prototypes ++ ******************************************************************************/ ++DEFINE_SYSOP_TYPE_PARAM_FUNC(at, s12e1r) ++DEFINE_SYSOP_TYPE_PARAM_FUNC(at, s12e1w) ++DEFINE_SYSOP_TYPE_PARAM_FUNC(at, s12e0r) ++DEFINE_SYSOP_TYPE_PARAM_FUNC(at, s12e0w) ++DEFINE_SYSOP_TYPE_PARAM_FUNC(at, s1e1r) ++DEFINE_SYSOP_TYPE_PARAM_FUNC(at, s1e2r) ++DEFINE_SYSOP_TYPE_PARAM_FUNC(at, s1e3r) ++ ++void flush_dcache_range(uintptr_t addr, size_t size); ++void clean_dcache_range(uintptr_t addr, size_t size); ++void inv_dcache_range(uintptr_t addr, size_t size); ++ ++void dcsw_op_louis(u_register_t op_type); ++void dcsw_op_all(u_register_t op_type); ++ ++void disable_mmu(void); ++void disable_mmu_icache(void); ++ ++/******************************************************************************* ++ * Misc. accessor prototypes ++ ******************************************************************************/ ++ ++#define write_daifclr(val) SYSREG_WRITE_CONST(daifclr, val) ++#define write_daifset(val) SYSREG_WRITE_CONST(daifset, val) ++ ++DEFINE_SYSREG_RW_FUNCS(par_el1) ++DEFINE_SYSREG_READ_FUNC(id_pfr1_el1) ++DEFINE_SYSREG_READ_FUNC(id_aa64isar1_el1) ++DEFINE_SYSREG_READ_FUNC(id_aa64pfr0_el1) ++DEFINE_SYSREG_READ_FUNC(id_aa64pfr1_el1) ++DEFINE_SYSREG_READ_FUNC(id_aa64dfr0_el1) ++DEFINE_SYSREG_READ_FUNC(id_afr0_el1) ++DEFINE_SYSREG_READ_FUNC(CurrentEl) ++DEFINE_SYSREG_READ_FUNC(ctr_el0) ++DEFINE_SYSREG_RW_FUNCS(daif) ++DEFINE_SYSREG_RW_FUNCS(spsr_el1) ++DEFINE_SYSREG_RW_FUNCS(spsr_el2) ++DEFINE_SYSREG_RW_FUNCS(spsr_el3) ++DEFINE_SYSREG_RW_FUNCS(elr_el1) ++DEFINE_SYSREG_RW_FUNCS(elr_el2) ++DEFINE_SYSREG_RW_FUNCS(elr_el3) ++ ++DEFINE_SYSOP_FUNC(wfi) ++DEFINE_SYSOP_FUNC(wfe) ++DEFINE_SYSOP_FUNC(sev) ++DEFINE_SYSOP_TYPE_FUNC(dsb, sy) ++DEFINE_SYSOP_TYPE_FUNC(dmb, sy) ++DEFINE_SYSOP_TYPE_FUNC(dmb, st) ++DEFINE_SYSOP_TYPE_FUNC(dmb, ld) ++DEFINE_SYSOP_TYPE_FUNC(dsb, ish) ++DEFINE_SYSOP_TYPE_FUNC(dsb, nsh) ++DEFINE_SYSOP_TYPE_FUNC(dsb, ishst) ++DEFINE_SYSOP_TYPE_FUNC(dmb, oshld) ++DEFINE_SYSOP_TYPE_FUNC(dmb, oshst) ++DEFINE_SYSOP_TYPE_FUNC(dmb, osh) ++DEFINE_SYSOP_TYPE_FUNC(dmb, nshld) ++DEFINE_SYSOP_TYPE_FUNC(dmb, nshst) ++DEFINE_SYSOP_TYPE_FUNC(dmb, nsh) ++DEFINE_SYSOP_TYPE_FUNC(dmb, ishld) ++DEFINE_SYSOP_TYPE_FUNC(dmb, ishst) ++DEFINE_SYSOP_TYPE_FUNC(dmb, ish) ++DEFINE_SYSOP_FUNC(isb) ++ ++static inline void enable_irq(void) ++{ ++ /* ++ * The compiler memory barrier will prevent the compiler from ++ * scheduling non-volatile memory access after the write to the ++ * register. ++ * ++ * This could happen if some initialization code issues non-volatile ++ * accesses to an area used by an interrupt handler, in the assumption ++ * that it is safe as the interrupts are disabled at the time it does ++ * that (according to program order). However, non-volatile accesses ++ * are not necessarily in program order relatively with volatile inline ++ * assembly statements (and volatile accesses). ++ */ ++ COMPILER_BARRIER(); ++ write_daifclr(DAIF_IRQ_BIT); ++ isb(); ++} ++ ++static inline void enable_fiq(void) ++{ ++ COMPILER_BARRIER(); ++ write_daifclr(DAIF_FIQ_BIT); ++ isb(); ++} ++ ++static inline void enable_serror(void) ++{ ++ COMPILER_BARRIER(); ++ write_daifclr(DAIF_ABT_BIT); ++ isb(); ++} ++ ++static inline void enable_debug_exceptions(void) ++{ ++ COMPILER_BARRIER(); ++ write_daifclr(DAIF_DBG_BIT); ++ isb(); ++} ++ ++static inline void disable_irq(void) ++{ ++ COMPILER_BARRIER(); ++ write_daifset(DAIF_IRQ_BIT); ++ isb(); ++} ++ ++static inline void disable_fiq(void) ++{ ++ COMPILER_BARRIER(); ++ write_daifset(DAIF_FIQ_BIT); ++ isb(); ++} ++ ++static inline void disable_serror(void) ++{ ++ COMPILER_BARRIER(); ++ write_daifset(DAIF_ABT_BIT); ++ isb(); ++} ++ ++static inline void disable_debug_exceptions(void) ++{ ++ COMPILER_BARRIER(); ++ write_daifset(DAIF_DBG_BIT); ++ isb(); ++} ++ ++void __dead2 smc(uint64_t x0, uint64_t x1, uint64_t x2, uint64_t x3, ++ uint64_t x4, uint64_t x5, uint64_t x6, uint64_t x7); ++ ++/******************************************************************************* ++ * System register accessor prototypes ++ ******************************************************************************/ ++DEFINE_SYSREG_READ_FUNC(midr_el1) ++DEFINE_SYSREG_READ_FUNC(mpidr_el1) ++DEFINE_SYSREG_READ_FUNC(id_aa64mmfr0_el1) ++ ++DEFINE_SYSREG_RW_FUNCS(scr_el3) ++DEFINE_SYSREG_RW_FUNCS(hcr_el2) ++ ++DEFINE_SYSREG_RW_FUNCS(vbar_el1) ++DEFINE_SYSREG_RW_FUNCS(vbar_el2) ++DEFINE_SYSREG_RW_FUNCS(vbar_el3) ++ ++DEFINE_SYSREG_RW_FUNCS(sctlr_el1) ++DEFINE_SYSREG_RW_FUNCS(sctlr_el2) ++DEFINE_SYSREG_RW_FUNCS(sctlr_el3) ++ ++DEFINE_SYSREG_RW_FUNCS(actlr_el1) ++DEFINE_SYSREG_RW_FUNCS(actlr_el2) ++DEFINE_SYSREG_RW_FUNCS(actlr_el3) ++ ++DEFINE_SYSREG_RW_FUNCS(esr_el1) ++DEFINE_SYSREG_RW_FUNCS(esr_el2) ++DEFINE_SYSREG_RW_FUNCS(esr_el3) ++ ++DEFINE_SYSREG_RW_FUNCS(afsr0_el1) ++DEFINE_SYSREG_RW_FUNCS(afsr0_el2) ++DEFINE_SYSREG_RW_FUNCS(afsr0_el3) ++ ++DEFINE_SYSREG_RW_FUNCS(afsr1_el1) ++DEFINE_SYSREG_RW_FUNCS(afsr1_el2) ++DEFINE_SYSREG_RW_FUNCS(afsr1_el3) ++ ++DEFINE_SYSREG_RW_FUNCS(far_el1) ++DEFINE_SYSREG_RW_FUNCS(far_el2) ++DEFINE_SYSREG_RW_FUNCS(far_el3) ++ ++DEFINE_SYSREG_RW_FUNCS(mair_el1) ++DEFINE_SYSREG_RW_FUNCS(mair_el2) ++DEFINE_SYSREG_RW_FUNCS(mair_el3) ++ ++DEFINE_SYSREG_RW_FUNCS(amair_el1) ++DEFINE_SYSREG_RW_FUNCS(amair_el2) ++DEFINE_SYSREG_RW_FUNCS(amair_el3) ++ ++DEFINE_SYSREG_READ_FUNC(rvbar_el1) ++DEFINE_SYSREG_READ_FUNC(rvbar_el2) ++DEFINE_SYSREG_READ_FUNC(rvbar_el3) ++ ++DEFINE_SYSREG_RW_FUNCS(rmr_el1) ++DEFINE_SYSREG_RW_FUNCS(rmr_el2) ++DEFINE_SYSREG_RW_FUNCS(rmr_el3) ++ ++DEFINE_SYSREG_RW_FUNCS(tcr_el1) ++DEFINE_SYSREG_RW_FUNCS(tcr_el2) ++DEFINE_SYSREG_RW_FUNCS(tcr_el3) ++ ++DEFINE_SYSREG_RW_FUNCS(ttbr0_el1) ++DEFINE_SYSREG_RW_FUNCS(ttbr0_el2) ++DEFINE_SYSREG_RW_FUNCS(ttbr0_el3) ++ ++DEFINE_SYSREG_RW_FUNCS(ttbr1_el1) ++ ++DEFINE_SYSREG_RW_FUNCS(vttbr_el2) ++ ++DEFINE_SYSREG_RW_FUNCS(cptr_el2) ++DEFINE_SYSREG_RW_FUNCS(cptr_el3) ++ ++DEFINE_SYSREG_RW_FUNCS(cpacr_el1) ++DEFINE_SYSREG_RW_FUNCS(cntfrq_el0) ++DEFINE_SYSREG_RW_FUNCS(cnthp_ctl_el2) ++DEFINE_SYSREG_RW_FUNCS(cnthp_tval_el2) ++DEFINE_SYSREG_RW_FUNCS(cnthp_cval_el2) ++DEFINE_SYSREG_RW_FUNCS(cntps_ctl_el1) ++DEFINE_SYSREG_RW_FUNCS(cntps_tval_el1) ++DEFINE_SYSREG_RW_FUNCS(cntps_cval_el1) ++DEFINE_SYSREG_RW_FUNCS(cntp_ctl_el0) ++DEFINE_SYSREG_RW_FUNCS(cntp_tval_el0) ++DEFINE_SYSREG_RW_FUNCS(cntp_cval_el0) ++DEFINE_SYSREG_READ_FUNC(cntpct_el0) ++DEFINE_SYSREG_RW_FUNCS(cnthctl_el2) ++ ++#define get_cntp_ctl_enable(x) (((x) >> CNTP_CTL_ENABLE_SHIFT) & \ ++ CNTP_CTL_ENABLE_MASK) ++#define get_cntp_ctl_imask(x) (((x) >> CNTP_CTL_IMASK_SHIFT) & \ ++ CNTP_CTL_IMASK_MASK) ++#define get_cntp_ctl_istatus(x) (((x) >> CNTP_CTL_ISTATUS_SHIFT) & \ ++ CNTP_CTL_ISTATUS_MASK) ++ ++#define set_cntp_ctl_enable(x) ((x) |= (U(1) << CNTP_CTL_ENABLE_SHIFT)) ++#define set_cntp_ctl_imask(x) ((x) |= (U(1) << CNTP_CTL_IMASK_SHIFT)) ++ ++#define clr_cntp_ctl_enable(x) ((x) &= ~(U(1) << CNTP_CTL_ENABLE_SHIFT)) ++#define clr_cntp_ctl_imask(x) ((x) &= ~(U(1) << CNTP_CTL_IMASK_SHIFT)) ++ ++DEFINE_SYSREG_RW_FUNCS(tpidr_el3) ++ ++DEFINE_SYSREG_RW_FUNCS(cntvoff_el2) ++ ++DEFINE_SYSREG_RW_FUNCS(vpidr_el2) ++DEFINE_SYSREG_RW_FUNCS(vmpidr_el2) ++ ++DEFINE_SYSREG_READ_FUNC(isr_el1) ++ ++DEFINE_SYSREG_RW_FUNCS(mdcr_el2) ++DEFINE_SYSREG_RW_FUNCS(mdcr_el3) ++DEFINE_SYSREG_RW_FUNCS(hstr_el2) ++DEFINE_SYSREG_RW_FUNCS(pmcr_el0) ++DEFINE_SYSREG_RW_FUNCS(pmcntenset_el0) ++DEFINE_SYSREG_READ_FUNC(pmccntr_el0) ++DEFINE_SYSREG_RW_FUNCS(pmccfiltr_el0) ++ ++DEFINE_SYSREG_RW_FUNCS(pmevtyper0_el0) ++DEFINE_SYSREG_READ_FUNC(pmevcntr0_el0) ++ ++/* GICv3 System Registers */ ++ ++DEFINE_RENAME_SYSREG_RW_FUNCS(icc_sre_el1, ICC_SRE_EL1) ++DEFINE_RENAME_SYSREG_RW_FUNCS(icc_sre_el2, ICC_SRE_EL2) ++DEFINE_RENAME_SYSREG_RW_FUNCS(icc_sre_el3, ICC_SRE_EL3) ++DEFINE_RENAME_SYSREG_RW_FUNCS(icc_pmr_el1, ICC_PMR_EL1) ++DEFINE_RENAME_SYSREG_READ_FUNC(icc_rpr_el1, ICC_RPR_EL1) ++DEFINE_RENAME_SYSREG_RW_FUNCS(icc_igrpen1_el3, ICC_IGRPEN1_EL3) ++DEFINE_RENAME_SYSREG_RW_FUNCS(icc_igrpen1_el1, ICC_IGRPEN1_EL1) ++DEFINE_RENAME_SYSREG_RW_FUNCS(icc_igrpen0_el1, ICC_IGRPEN0_EL1) ++DEFINE_RENAME_SYSREG_READ_FUNC(icc_hppir0_el1, ICC_HPPIR0_EL1) ++DEFINE_RENAME_SYSREG_READ_FUNC(icc_hppir1_el1, ICC_HPPIR1_EL1) ++DEFINE_RENAME_SYSREG_READ_FUNC(icc_iar0_el1, ICC_IAR0_EL1) ++DEFINE_RENAME_SYSREG_READ_FUNC(icc_iar1_el1, ICC_IAR1_EL1) ++DEFINE_RENAME_SYSREG_WRITE_FUNC(icc_eoir0_el1, ICC_EOIR0_EL1) ++DEFINE_RENAME_SYSREG_WRITE_FUNC(icc_eoir1_el1, ICC_EOIR1_EL1) ++DEFINE_RENAME_SYSREG_WRITE_FUNC(icc_sgi0r_el1, ICC_SGI0R_EL1) ++DEFINE_RENAME_SYSREG_RW_FUNCS(icc_sgi1r, ICC_SGI1R) ++ ++DEFINE_RENAME_SYSREG_RW_FUNCS(amcgcr_el0, AMCGCR_EL0) ++DEFINE_RENAME_SYSREG_RW_FUNCS(amcntenclr0_el0, AMCNTENCLR0_EL0) ++DEFINE_RENAME_SYSREG_RW_FUNCS(amcntenset0_el0, AMCNTENSET0_EL0) ++DEFINE_RENAME_SYSREG_RW_FUNCS(amcntenclr1_el0, AMCNTENCLR1_EL0) ++DEFINE_RENAME_SYSREG_RW_FUNCS(amcntenset1_el0, AMCNTENSET1_EL0) ++ ++DEFINE_RENAME_SYSREG_READ_FUNC(mpamidr_el1, MPAMIDR_EL1) ++DEFINE_RENAME_SYSREG_RW_FUNCS(mpam3_el3, MPAM3_EL3) ++DEFINE_RENAME_SYSREG_RW_FUNCS(mpam2_el2, MPAM2_EL2) ++DEFINE_RENAME_SYSREG_RW_FUNCS(mpamhcr_el2, MPAMHCR_EL2) ++ ++DEFINE_RENAME_SYSREG_RW_FUNCS(pmblimitr_el1, PMBLIMITR_EL1) ++ ++DEFINE_RENAME_SYSREG_WRITE_FUNC(zcr_el3, ZCR_EL3) ++DEFINE_RENAME_SYSREG_WRITE_FUNC(zcr_el2, ZCR_EL2) ++ ++DEFINE_RENAME_SYSREG_READ_FUNC(erridr_el1, ERRIDR_EL1) ++DEFINE_RENAME_SYSREG_WRITE_FUNC(errselr_el1, ERRSELR_EL1) ++ ++DEFINE_RENAME_SYSREG_READ_FUNC(erxfr_el1, ERXFR_EL1) ++DEFINE_RENAME_SYSREG_RW_FUNCS(erxctlr_el1, ERXCTLR_EL1) ++DEFINE_RENAME_SYSREG_RW_FUNCS(erxstatus_el1, ERXSTATUS_EL1) ++DEFINE_RENAME_SYSREG_READ_FUNC(erxaddr_el1, ERXADDR_EL1) ++DEFINE_RENAME_SYSREG_READ_FUNC(erxmisc0_el1, ERXMISC0_EL1) ++DEFINE_RENAME_SYSREG_READ_FUNC(erxmisc1_el1, ERXMISC1_EL1) ++ ++/* Armv8.2 Registers */ ++DEFINE_RENAME_SYSREG_READ_FUNC(id_aa64mmfr2_el1, ID_AA64MMFR2_EL1) ++ ++/* Armv8.3 Pointer Authentication Registers */ ++/* Instruction keys A and B */ ++DEFINE_RENAME_SYSREG_RW_FUNCS(apiakeyhi_el1, APIAKeyHi_EL1) ++DEFINE_RENAME_SYSREG_RW_FUNCS(apiakeylo_el1, APIAKeyLo_EL1) ++ ++DEFINE_RENAME_SYSREG_RW_FUNCS(apibkeyhi_el1, APIBKeyHi_EL1) ++DEFINE_RENAME_SYSREG_RW_FUNCS(apibkeylo_el1, APIBKeyLo_EL1) ++ ++/* Data keys A and B */ ++DEFINE_RENAME_SYSREG_RW_FUNCS(apdakeyhi_el1, APDAKeyHi_EL1) ++DEFINE_RENAME_SYSREG_RW_FUNCS(apdakeylo_el1, APDAKeyLo_EL1) ++ ++DEFINE_RENAME_SYSREG_RW_FUNCS(apdbkeyhi_el1, APDBKeyHi_EL1) ++DEFINE_RENAME_SYSREG_RW_FUNCS(apdbkeylo_el1, APDBKeyLo_EL1) ++ ++/* Generic key */ ++DEFINE_RENAME_SYSREG_RW_FUNCS(apgakeyhi_el1, APGAKeyHi_EL1) ++DEFINE_RENAME_SYSREG_RW_FUNCS(apgakeylo_el1, APGAKeyLo_EL1) ++ ++/* MTE registers */ ++DEFINE_RENAME_SYSREG_RW_FUNCS(tfsre0_el1, TFSRE0_EL1) ++DEFINE_RENAME_SYSREG_RW_FUNCS(tfsr_el1, TFSR_EL1) ++DEFINE_RENAME_SYSREG_RW_FUNCS(rgsr_el1, RGSR_EL1) ++DEFINE_RENAME_SYSREG_RW_FUNCS(gcr_el1, GCR_EL1) ++ ++/* Armv8.6 Fine Grained Virtualization Traps Registers */ ++DEFINE_RENAME_SYSREG_RW_FUNCS(hfgrtr_el2, HFGRTR_EL2) ++DEFINE_RENAME_SYSREG_RW_FUNCS(hfgwtr_el2, HFGWTR_EL2) ++DEFINE_RENAME_SYSREG_RW_FUNCS(hfgitr_el2, HFGITR_EL2) ++DEFINE_RENAME_SYSREG_RW_FUNCS(hdfgrtr_el2, HDFGRTR_EL2) ++DEFINE_RENAME_SYSREG_RW_FUNCS(hdfgwtr_el2, HDFGWTR_EL2) ++ ++/* Armv8.6 Enhanced Counter Virtualization Register */ ++DEFINE_RENAME_SYSREG_RW_FUNCS(cntpoff_el2, CNTPOFF_EL2) ++ ++#define IS_IN_EL(x) \ ++ (GET_EL(read_CurrentEl()) == MODE_EL##x) ++ ++#define IS_IN_EL1() IS_IN_EL(1) ++#define IS_IN_EL2() IS_IN_EL(2) ++#define IS_IN_EL3() IS_IN_EL(3) ++ ++static inline unsigned int get_current_el(void) ++{ ++ return GET_EL(read_CurrentEl()); ++} ++ ++/* ++ * Check if an EL is implemented from AA64PFR0 register fields. ++ */ ++static inline uint64_t el_implemented(unsigned int el) ++{ ++ if (el > 3U) { ++ return EL_IMPL_NONE; ++ } else { ++ unsigned int shift = ID_AA64PFR0_EL1_SHIFT * el; ++ ++ return (read_id_aa64pfr0_el1() >> shift) & ID_AA64PFR0_ELX_MASK; ++ } ++} ++ ++/* Read the count value of the system counter. */ ++static inline uint64_t syscounter_read(void) ++{ ++ /* ++ * The instruction barrier is needed to guarantee that we read an ++ * accurate value. Otherwise, the CPU might speculatively read it and ++ * return a stale value. ++ */ ++ isb(); ++ return read_cntpct_el0(); ++} ++ ++#endif /* ARCH_HELPERS_H */ +diff --git a/environments/shim/include/lib/cassert.h b/environments/shim/include/lib/cassert.h +new file mode 100644 +index 0000000..8844e8b +--- /dev/null ++++ b/environments/shim/include/lib/cassert.h +@@ -0,0 +1,18 @@ ++/* ++ * Copyright (c) 2018, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef __CASSERT_H__ ++#define __CASSERT_H__ ++ ++/******************************************************************************* ++ * Macro to flag a compile time assertion. It uses the preprocessor to generate ++ * an invalid C construct if 'cond' evaluates to false. ++ * The following compilation error is triggered if the assertion fails: ++ * "error: size of array 'msg' is negative" ++ ******************************************************************************/ ++#define CASSERT(cond, msg) typedef char msg[(cond) ? 1 : -1] ++ ++#endif /* __CASSERT_H__ */ +diff --git a/environments/shim/include/lib/libc/aarch64/endian_.h b/environments/shim/include/lib/libc/aarch64/endian_.h +new file mode 100644 +index 0000000..7c79fd4 +--- /dev/null ++++ b/environments/shim/include/lib/libc/aarch64/endian_.h +@@ -0,0 +1,128 @@ ++/*- ++ * SPDX-License-Identifier: BSD-3-Clause ++ * ++ * Copyright (c) 2001 David E. O'Brien ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the name of the University nor the names of its contributors ++ * may be used to endorse or promote products derived from this software ++ * without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ * ++ * @(#)endian.h 8.1 (Berkeley) 6/10/93 ++ * $NetBSD: endian.h,v 1.7 1999/08/21 05:53:51 simonb Exp $ ++ * $FreeBSD$ ++ */ ++/* ++ * Portions copyright (c) 2018, ARM Limited and Contributors. ++ * All rights reserved. ++ */ ++ ++#ifndef ENDIAN__H ++#define ENDIAN__H ++ ++#include ++ ++/* ++ * Definitions for byte order, according to byte significance from low ++ * address to high. ++ */ ++#define _LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ ++#define _BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ ++#define _PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ ++ ++#define _BYTE_ORDER _LITTLE_ENDIAN ++ ++#if __BSD_VISIBLE ++#define LITTLE_ENDIAN _LITTLE_ENDIAN ++#define BIG_ENDIAN _BIG_ENDIAN ++#define PDP_ENDIAN _PDP_ENDIAN ++#define BYTE_ORDER _BYTE_ORDER ++#endif ++ ++#define _QUAD_HIGHWORD 1 ++#define _QUAD_LOWWORD 0 ++#define __ntohl(x) (__bswap32(x)) ++#define __ntohs(x) (__bswap16(x)) ++#define __htonl(x) (__bswap32(x)) ++#define __htons(x) (__bswap16(x)) ++ ++static __inline uint64_t ++__bswap64(uint64_t x) ++{ ++ uint64_t ret; ++ ++ __asm __volatile("rev %0, %1\n" ++ : "=&r" (ret), "+r" (x)); ++ ++ return (ret); ++} ++ ++static __inline uint32_t ++__bswap32_var(uint32_t v) ++{ ++ uint32_t ret; ++ ++ __asm __volatile("rev32 %x0, %x1\n" ++ : "=&r" (ret), "+r" (v)); ++ ++ return (ret); ++} ++ ++static __inline uint16_t ++__bswap16_var(uint16_t v) ++{ ++ uint32_t ret; ++ ++ __asm __volatile("rev16 %w0, %w1\n" ++ : "=&r" (ret), "+r" (v)); ++ ++ return ((uint16_t)ret); ++} ++ ++#ifdef __OPTIMIZE__ ++ ++#define __bswap32_constant(x) \ ++ ((((x) & 0xff000000U) >> 24) | \ ++ (((x) & 0x00ff0000U) >> 8) | \ ++ (((x) & 0x0000ff00U) << 8) | \ ++ (((x) & 0x000000ffU) << 24)) ++ ++#define __bswap16_constant(x) \ ++ ((((x) & 0xff00) >> 8) | \ ++ (((x) & 0x00ff) << 8)) ++ ++#define __bswap16(x) \ ++ ((uint16_t)(__builtin_constant_p(x) ? \ ++ __bswap16_constant((uint16_t)(x)) : \ ++ __bswap16_var(x))) ++ ++#define __bswap32(x) \ ++ ((uint32_t)(__builtin_constant_p(x) ? \ ++ __bswap32_constant((uint32_t)(x)) : \ ++ __bswap32_var(x))) ++ ++#else ++#define __bswap16(x) __bswap16_var(x) ++#define __bswap32(x) __bswap32_var(x) ++ ++#endif /* __OPTIMIZE__ */ ++#endif /* ENDIAN__H */ +diff --git a/environments/shim/include/lib/libc/aarch64/limits_.h b/environments/shim/include/lib/libc/aarch64/limits_.h +new file mode 100644 +index 0000000..e36cfe7 +--- /dev/null ++++ b/environments/shim/include/lib/libc/aarch64/limits_.h +@@ -0,0 +1,26 @@ ++/* ++ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#define SCHAR_MAX 0x7F ++#define SCHAR_MIN (-SCHAR_MIN - 1) ++#define CHAR_MAX 0x7F ++#define CHAR_MIN (-CHAR_MAX - 1) ++#define UCHAR_MAX 0xFFU ++#define SHRT_MAX 0x7FFF ++#define SHRT_MIN (-SHRT_MAX - 1) ++#define USHRT_MAX 0xFFFFU ++#define INT_MAX 0x7FFFFFFF ++#define INT_MIN (-INT_MAX - 1) ++#define UINT_MAX 0xFFFFFFFFU ++#define LONG_MAX 0x7FFFFFFFFFFFFFFFL ++#define LONG_MIN (-LONG_MAX - 1L) ++#define ULONG_MAX 0xFFFFFFFFFFFFFFFFUL ++#define LLONG_MAX 0x7FFFFFFFFFFFFFFFLL ++#define LLONG_MIN (-LLONG_MAX - 1LL) ++#define ULLONG_MAX 0xFFFFFFFFFFFFFFFFULL ++ ++#define __LONG_BIT 64 ++#define __WORD_BIT 32 +diff --git a/environments/shim/include/lib/libc/aarch64/setjmp_.h b/environments/shim/include/lib/libc/aarch64/setjmp_.h +new file mode 100644 +index 0000000..174b3eb +--- /dev/null ++++ b/environments/shim/include/lib/libc/aarch64/setjmp_.h +@@ -0,0 +1,30 @@ ++/* ++ * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef SETJMP__H ++#define SETJMP__H ++ ++#define JMP_CTX_X19 0x0 ++#define JMP_CTX_X21 0x10 ++#define JMP_CTX_X23 0x20 ++#define JMP_CTX_X25 0x30 ++#define JMP_CTX_X27 0x40 ++#define JMP_CTX_X29 0x50 ++#define JMP_CTX_SP 0x60 ++#define JMP_CTX_END 0x70 /* Aligned to 16 bytes */ ++ ++#define JMP_SIZE (JMP_CTX_END >> 3) ++ ++#ifndef __ASSEMBLY__ ++ ++#include ++ ++/* Jump buffer hosting x18 - x30 and sp_el0 registers */ ++typedef uint64_t jmp_buf[JMP_SIZE] __aligned(16); ++ ++#endif /* __ASSEMBLY__ */ ++ ++#endif /* SETJMP__H */ +diff --git a/environments/shim/include/lib/libc/aarch64/stddef_.h b/environments/shim/include/lib/libc/aarch64/stddef_.h +new file mode 100644 +index 0000000..6ecc606 +--- /dev/null ++++ b/environments/shim/include/lib/libc/aarch64/stddef_.h +@@ -0,0 +1,15 @@ ++/* ++ * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef STDDEF__H ++#define STDDEF__H ++ ++#ifndef SIZET_ ++typedef unsigned long size_t; ++#define SIZET_ ++#endif ++ ++#endif /* STDDEF__H */ +diff --git a/environments/shim/include/lib/libc/aarch64/stdio_.h b/environments/shim/include/lib/libc/aarch64/stdio_.h +new file mode 100644 +index 0000000..afaeadc +--- /dev/null ++++ b/environments/shim/include/lib/libc/aarch64/stdio_.h +@@ -0,0 +1,15 @@ ++/* ++ * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef STDIO__H ++#define STDIO__H ++ ++#ifndef SSIZET_ ++typedef long ssize_t; ++#define SSIZET_ ++#endif ++ ++#endif /* STDIO__H */ +diff --git a/environments/shim/include/lib/libc/assert.h b/environments/shim/include/lib/libc/assert.h +new file mode 100644 +index 0000000..ec28c26 +--- /dev/null ++++ b/environments/shim/include/lib/libc/assert.h +@@ -0,0 +1,28 @@ ++/* ++ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef ASSERT_H ++#define ASSERT_H ++ ++#include ++ ++#include ++ ++#if ENABLE_ASSERTIONS ++#define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e)) ++#else ++#define assert(e) ((void)0) ++#endif /* ENABLE_ASSERTIONS */ ++ ++__dead2 void __assert(const char *file, unsigned int line, ++ const char *assertion); ++ ++#define COMPILE_TIME_ASSERT(x) \ ++ do { \ ++ switch (0) { case 0: case ((x) ? 1: 0): default : break; } \ ++ } while (0) ++ ++#endif /* ASSERT_H */ +diff --git a/environments/shim/include/lib/libc/cdefs.h b/environments/shim/include/lib/libc/cdefs.h +new file mode 100644 +index 0000000..c3dd6f1 +--- /dev/null ++++ b/environments/shim/include/lib/libc/cdefs.h +@@ -0,0 +1,33 @@ ++/* ++ * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef CDEFS_H ++#define CDEFS_H ++ ++#define __dead2 __attribute__((__noreturn__)) ++#define __deprecated __attribute__((__deprecated__)) ++#define __packed __attribute__((__packed__)) ++#define __used __attribute__((__used__)) ++#define __unused __attribute__((__unused__)) ++#define __aligned(x) __attribute__((__aligned__(x))) ++#define __section(x) __attribute__((__section__(x))) ++/* ++ * For compatibility with TF-A codebase. ++ */ ++#define __init ++ ++ ++#define __printflike(fmtarg, firstvararg) \ ++ __attribute__((__format__ (__printf__, fmtarg, firstvararg))) ++ ++#define __weak_reference(sym, alias) \ ++ __asm__(".weak alias"); \ ++ __asm__(".equ alias, sym") ++ ++#define __STRING(x) #x ++#define __XSTRING(x) __STRING(x) ++ ++#endif /* CDEFS_H */ +diff --git a/environments/shim/include/lib/libc/compiler.h b/environments/shim/include/lib/libc/compiler.h +new file mode 100644 +index 0000000..b9474cf +--- /dev/null ++++ b/environments/shim/include/lib/libc/compiler.h +@@ -0,0 +1,32 @@ ++/* SPDX-License-Identifier: BSD-2-Clause */ ++/* ++ * Copyright (c) 2014, STMicroelectronics International N.V. ++ * Copyright (c) 2021, Arm Limited. ++ */ ++ ++#ifndef COMPILER_H ++#define COMPILER_H ++ ++#define __packed __attribute__((__packed__)) ++#define __noreturn __attribute__((__noreturn__)) ++#define __maybe_unused __attribute__((__unused__)) ++ ++#define __GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + \ ++ __GNUC_PATCHLEVEL__) ++ ++#if __GCC_VERSION >= 50100 && !defined(__CHECKER__) ++#define __HAVE_BUILTIN_OVERFLOW 1 ++#endif ++ ++#ifdef __HAVE_BUILTIN_OVERFLOW ++#define __compiler_add_overflow(a, b, res) \ ++ __builtin_add_overflow((a), (b), (res)) ++ ++#define __compiler_sub_overflow(a, b, res) \ ++ __builtin_sub_overflow((a), (b), (res)) ++ ++#define __compiler_mul_overflow(a, b, res) \ ++ __builtin_mul_overflow((a), (b), (res)) ++#endif /*!__HAVE_BUILTIN_OVERFLOW*/ ++ ++#endif /* CDEFS_H */ +diff --git a/environments/shim/include/lib/libc/endian.h b/environments/shim/include/lib/libc/endian.h +new file mode 100644 +index 0000000..4100f57 +--- /dev/null ++++ b/environments/shim/include/lib/libc/endian.h +@@ -0,0 +1,191 @@ ++/*- ++ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD ++ * ++ * Copyright (c) 2002 Thomas Moestl ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE ++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ * ++ * $FreeBSD$ ++ */ ++/* ++ * Portions copyright (c) 2018, ARM Limited and Contributors. ++ * All rights reserved. ++ */ ++ ++#ifndef ENDIAN_H ++#define ENDIAN_H ++ ++#include ++#include ++#include ++ ++/* ++ * General byte order swapping functions. ++ */ ++#define bswap16(x) __bswap16(x) ++#define bswap32(x) __bswap32(x) ++#define bswap64(x) __bswap64(x) ++ ++/* ++ * Host to big endian, host to little endian, big endian to host, and little ++ * endian to host byte order functions as detailed in byteorder(9). ++ */ ++#if _BYTE_ORDER == _LITTLE_ENDIAN ++#define htobe16(x) bswap16((x)) ++#define htobe32(x) bswap32((x)) ++#define htobe64(x) bswap64((x)) ++#define htole16(x) ((uint16_t)(x)) ++#define htole32(x) ((uint32_t)(x)) ++#define htole64(x) ((uint64_t)(x)) ++ ++#define be16toh(x) bswap16((x)) ++#define be32toh(x) bswap32((x)) ++#define be64toh(x) bswap64((x)) ++#define le16toh(x) ((uint16_t)(x)) ++#define le32toh(x) ((uint32_t)(x)) ++#define le64toh(x) ((uint64_t)(x)) ++#else /* _BYTE_ORDER != _LITTLE_ENDIAN */ ++#define htobe16(x) ((uint16_t)(x)) ++#define htobe32(x) ((uint32_t)(x)) ++#define htobe64(x) ((uint64_t)(x)) ++#define htole16(x) bswap16((x)) ++#define htole32(x) bswap32((x)) ++#define htole64(x) bswap64((x)) ++ ++#define be16toh(x) ((uint16_t)(x)) ++#define be32toh(x) ((uint32_t)(x)) ++#define be64toh(x) ((uint64_t)(x)) ++#define le16toh(x) bswap16((x)) ++#define le32toh(x) bswap32((x)) ++#define le64toh(x) bswap64((x)) ++#endif /* _BYTE_ORDER == _LITTLE_ENDIAN */ ++ ++/* Alignment-agnostic encode/decode bytestream to/from little/big endian. */ ++ ++static __inline uint16_t ++be16dec(const void *pp) ++{ ++ uint8_t const *p = (uint8_t const *)pp; ++ ++ return ((p[0] << 8) | p[1]); ++} ++ ++static __inline uint32_t ++be32dec(const void *pp) ++{ ++ uint8_t const *p = (uint8_t const *)pp; ++ ++ return (((unsigned)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]); ++} ++ ++static __inline uint64_t ++be64dec(const void *pp) ++{ ++ uint8_t const *p = (uint8_t const *)pp; ++ ++ return (((uint64_t)be32dec(p) << 32) | be32dec(p + 4)); ++} ++ ++static __inline uint16_t ++le16dec(const void *pp) ++{ ++ uint8_t const *p = (uint8_t const *)pp; ++ ++ return ((p[1] << 8) | p[0]); ++} ++ ++static __inline uint32_t ++le32dec(const void *pp) ++{ ++ uint8_t const *p = (uint8_t const *)pp; ++ ++ return (((unsigned)p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]); ++} ++ ++static __inline uint64_t ++le64dec(const void *pp) ++{ ++ uint8_t const *p = (uint8_t const *)pp; ++ ++ return (((uint64_t)le32dec(p + 4) << 32) | le32dec(p)); ++} ++ ++static __inline void ++be16enc(void *pp, uint16_t u) ++{ ++ uint8_t *p = (uint8_t *)pp; ++ ++ p[0] = (u >> 8) & 0xff; ++ p[1] = u & 0xff; ++} ++ ++static __inline void ++be32enc(void *pp, uint32_t u) ++{ ++ uint8_t *p = (uint8_t *)pp; ++ ++ p[0] = (u >> 24) & 0xff; ++ p[1] = (u >> 16) & 0xff; ++ p[2] = (u >> 8) & 0xff; ++ p[3] = u & 0xff; ++} ++ ++static __inline void ++be64enc(void *pp, uint64_t u) ++{ ++ uint8_t *p = (uint8_t *)pp; ++ ++ be32enc(p, (uint32_t)(u >> 32)); ++ be32enc(p + 4, (uint32_t)(u & 0xffffffffU)); ++} ++ ++static __inline void ++le16enc(void *pp, uint16_t u) ++{ ++ uint8_t *p = (uint8_t *)pp; ++ ++ p[0] = u & 0xff; ++ p[1] = (u >> 8) & 0xff; ++} ++ ++static __inline void ++le32enc(void *pp, uint32_t u) ++{ ++ uint8_t *p = (uint8_t *)pp; ++ ++ p[0] = u & 0xff; ++ p[1] = (u >> 8) & 0xff; ++ p[2] = (u >> 16) & 0xff; ++ p[3] = (u >> 24) & 0xff; ++} ++ ++static __inline void ++le64enc(void *pp, uint64_t u) ++{ ++ uint8_t *p = (uint8_t *)pp; ++ ++ le32enc(p, (uint32_t)(u & 0xffffffffU)); ++ le32enc(p + 4, (uint32_t)(u >> 32)); ++} ++ ++#endif /* ENDIAN_H */ +diff --git a/environments/shim/include/lib/libc/errno.h b/environments/shim/include/lib/libc/errno.h +new file mode 100644 +index 0000000..029912f +--- /dev/null ++++ b/environments/shim/include/lib/libc/errno.h +@@ -0,0 +1,169 @@ ++/*- ++ * SPDX-License-Identifier: BSD-3-Clause ++ * ++ * Copyright (c) 1982, 1986, 1989, 1993 ++ * The Regents of the University of California. All rights reserved. ++ * (c) UNIX System Laboratories, Inc. ++ * All or some portions of this file are derived from material licensed ++ * to the University of California by American Telephone and Telegraph ++ * Co. or Unix System Laboratories, Inc. and are reproduced herein with ++ * the permission of UNIX System Laboratories, Inc. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the name of the University nor the names of its contributors ++ * may be used to endorse or promote products derived from this software ++ * without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ * ++ * @(#)errno.h 8.5 (Berkeley) 1/21/94 ++ * $FreeBSD$ ++ */ ++/* ++ * Portions copyright (c) 2018, ARM Limited and Contributors. ++ * All rights reserved. ++ */ ++ ++#ifndef ERRNO_H ++#define ERRNO_H ++ ++#define EPERM 1 /* Operation not permitted */ ++#define ENOENT 2 /* No such file or directory */ ++#define ESRCH 3 /* No such process */ ++#define EINTR 4 /* Interrupted system call */ ++#define EIO 5 /* Input/output error */ ++#define ENXIO 6 /* Device not configured */ ++#define E2BIG 7 /* Argument list too long */ ++#define ENOEXEC 8 /* Exec format error */ ++#define EBADF 9 /* Bad file descriptor */ ++#define ECHILD 10 /* No child processes */ ++#define EDEADLK 11 /* Resource deadlock avoided */ ++ /* 11 was EAGAIN */ ++#define ENOMEM 12 /* Cannot allocate memory */ ++#define EACCES 13 /* Permission denied */ ++#define EFAULT 14 /* Bad address */ ++#define ENOTBLK 15 /* Block device required */ ++#define EBUSY 16 /* Device busy */ ++#define EEXIST 17 /* File exists */ ++#define EXDEV 18 /* Cross-device link */ ++#define ENODEV 19 /* Operation not supported by device */ ++#define ENOTDIR 20 /* Not a directory */ ++#define EISDIR 21 /* Is a directory */ ++#define EINVAL 22 /* Invalid argument */ ++#define ENFILE 23 /* Too many open files in system */ ++#define EMFILE 24 /* Too many open files */ ++#define ENOTTY 25 /* Inappropriate ioctl for device */ ++#define ETXTBSY 26 /* Text file busy */ ++#define EFBIG 27 /* File too large */ ++#define ENOSPC 28 /* No space left on device */ ++#define ESPIPE 29 /* Illegal seek */ ++#define EROFS 30 /* Read-only filesystem */ ++#define EMLINK 31 /* Too many links */ ++#define EPIPE 32 /* Broken pipe */ ++ ++/* math software */ ++#define EDOM 33 /* Numerical argument out of domain */ ++#define ERANGE 34 /* Result too large */ ++ ++/* non-blocking and interrupt i/o */ ++#define EAGAIN 35 /* Resource temporarily unavailable */ ++#define EWOULDBLOCK EAGAIN /* Operation would block */ ++#define EINPROGRESS 36 /* Operation now in progress */ ++#define EALREADY 37 /* Operation already in progress */ ++ ++/* ipc/network software -- argument errors */ ++#define ENOTSOCK 38 /* Socket operation on non-socket */ ++#define EDESTADDRREQ 39 /* Destination address required */ ++#define EMSGSIZE 40 /* Message too long */ ++#define EPROTOTYPE 41 /* Protocol wrong type for socket */ ++#define ENOPROTOOPT 42 /* Protocol not available */ ++#define EPROTONOSUPPORT 43 /* Protocol not supported */ ++#define ESOCKTNOSUPPORT 44 /* Socket type not supported */ ++#define EOPNOTSUPP 45 /* Operation not supported */ ++#define ENOTSUP EOPNOTSUPP /* Operation not supported */ ++#define EPFNOSUPPORT 46 /* Protocol family not supported */ ++#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */ ++#define EADDRINUSE 48 /* Address already in use */ ++#define EADDRNOTAVAIL 49 /* Can't assign requested address */ ++ ++/* ipc/network software -- operational errors */ ++#define ENETDOWN 50 /* Network is down */ ++#define ENETUNREACH 51 /* Network is unreachable */ ++#define ENETRESET 52 /* Network dropped connection on reset */ ++#define ECONNABORTED 53 /* Software caused connection abort */ ++#define ECONNRESET 54 /* Connection reset by peer */ ++#define ENOBUFS 55 /* No buffer space available */ ++#define EISCONN 56 /* Socket is already connected */ ++#define ENOTCONN 57 /* Socket is not connected */ ++#define ESHUTDOWN 58 /* Can't send after socket shutdown */ ++#define ETOOMANYREFS 59 /* Too many references: can't splice */ ++#define ETIMEDOUT 60 /* Operation timed out */ ++#define ECONNREFUSED 61 /* Connection refused */ ++ ++#define ELOOP 62 /* Too many levels of symbolic links */ ++#define ENAMETOOLONG 63 /* File name too long */ ++ ++/* should be rearranged */ ++#define EHOSTDOWN 64 /* Host is down */ ++#define EHOSTUNREACH 65 /* No route to host */ ++#define ENOTEMPTY 66 /* Directory not empty */ ++ ++/* quotas & mush */ ++#define EPROCLIM 67 /* Too many processes */ ++#define EUSERS 68 /* Too many users */ ++#define EDQUOT 69 /* Disc quota exceeded */ ++ ++/* Network File System */ ++#define ESTALE 70 /* Stale NFS file handle */ ++#define EREMOTE 71 /* Too many levels of remote in path */ ++#define EBADRPC 72 /* RPC struct is bad */ ++#define ERPCMISMATCH 73 /* RPC version wrong */ ++#define EPROGUNAVAIL 74 /* RPC prog. not avail */ ++#define EPROGMISMATCH 75 /* Program version wrong */ ++#define EPROCUNAVAIL 76 /* Bad procedure for program */ ++ ++#define ENOLCK 77 /* No locks available */ ++#define ENOSYS 78 /* Function not implemented */ ++ ++#define EFTYPE 79 /* Inappropriate file type or format */ ++#define EAUTH 80 /* Authentication error */ ++#define ENEEDAUTH 81 /* Need authenticator */ ++#define EIDRM 82 /* Identifier removed */ ++#define ENOMSG 83 /* No message of desired type */ ++#define EOVERFLOW 84 /* Value too large to be stored in data type */ ++#define ECANCELED 85 /* Operation canceled */ ++#define EILSEQ 86 /* Illegal byte sequence */ ++#define ENOATTR 87 /* Attribute not found */ ++ ++#define EDOOFUS 88 /* Programming error */ ++ ++#define EBADMSG 89 /* Bad message */ ++#define EMULTIHOP 90 /* Multihop attempted */ ++#define ENOLINK 91 /* Link has been severed */ ++#define EPROTO 92 /* Protocol error */ ++ ++#define ENOTCAPABLE 93 /* Capabilities insufficient */ ++#define ECAPMODE 94 /* Not permitted in capability mode */ ++#define ENOTRECOVERABLE 95 /* State not recoverable */ ++#define EOWNERDEAD 96 /* Previous owner died */ ++ ++#define ELAST 96 /* Must be equal largest errno */ ++ ++#endif /* ERRNO_H */ +diff --git a/environments/shim/include/lib/libc/inttypes.h b/environments/shim/include/lib/libc/inttypes.h +new file mode 100644 +index 0000000..3563870 +--- /dev/null ++++ b/environments/shim/include/lib/libc/inttypes.h +@@ -0,0 +1,54 @@ ++/* SPDX-License-Identifier: BSD-2-Clause */ ++/* ++ * Copyright (c) 2014, STMicroelectronics International N.V. ++ */ ++#ifndef INTTYPES_H ++#define INTTYPES_H ++ ++#include ++ ++#ifdef __ILP32__ ++#define __PRI64_PREFIX "ll" ++#endif ++#ifdef __LP64__ ++#define __PRI64_PREFIX "l" ++#endif ++#define __PRIPTR_PREFIX "l" ++ ++#define PRId8 "d" ++#define PRId16 "d" ++#define PRId32 "d" ++#define PRId64 __PRI64_PREFIX "d" ++#define PRIdPTR __PRIPTR_PREFIX "d" ++ ++#define PRIi8 "i" ++#define PRIi16 "i" ++#define PRIi32 "i" ++#define PRIi64 __PRI64_PREFIX "i" ++#define PRIiPTR __PRIPTR_PREFIX "i" ++ ++#define PRIo8 "o" ++#define PRIo16 "o" ++#define PRIo32 "o" ++#define PRIo64 __PRI64_PREFIX "o" ++#define PRIoPTR __PRIPTR_PREFIX "o" ++ ++#define PRIu8 "u" ++#define PRIu16 "u" ++#define PRIu32 "u" ++#define PRIu64 __PRI64_PREFIX "u" ++#define PRIuPTR __PRIPTR_PREFIX "u" ++ ++#define PRIx8 "x" ++#define PRIx16 "x" ++#define PRIx32 "x" ++#define PRIx64 __PRI64_PREFIX "x" ++#define PRIxPTR __PRIPTR_PREFIX "x" ++ ++#define PRIX8 "X" ++#define PRIX16 "X" ++#define PRIX32 "X" ++#define PRIX64 __PRI64_PREFIX "X" ++#define PRIXPTR __PRIPTR_PREFIX "X" ++ ++#endif /*INTTYPES_H*/ +diff --git a/environments/shim/include/lib/libc/limits.h b/environments/shim/include/lib/libc/limits.h +new file mode 100644 +index 0000000..41bb658 +--- /dev/null ++++ b/environments/shim/include/lib/libc/limits.h +@@ -0,0 +1,19 @@ ++/* ++ * Copyright (c) 2012-2017 Roberto E. Vargas Caballero ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++/* ++ * Portions copyright (c) 2018, ARM Limited and Contributors. ++ * All rights reserved. ++ */ ++ ++#ifndef LIMITS_H ++#define LIMITS_H ++ ++#include ++ ++#define CHAR_BIT 8 ++#define MB_LEN_MAX 1 ++ ++#endif /* LIMITS_H */ +diff --git a/environments/shim/include/lib/libc/malloc.h b/environments/shim/include/lib/libc/malloc.h +new file mode 100644 +index 0000000..7c21108 +--- /dev/null ++++ b/environments/shim/include/lib/libc/malloc.h +@@ -0,0 +1,131 @@ ++/* SPDX-License-Identifier: BSD-2-Clause */ ++/* ++ * Copyright (c) 2014, STMicroelectronics International N.V. ++ * Copyright (c) 2021, Arm Limited. ++ */ ++#ifndef MALLOC_H ++#define MALLOC_H ++ ++#include ++#include ++ ++void free(void *ptr); ++ ++#ifdef ENABLE_MDBG ++ ++void *mdbg_malloc(const char *fname, int lineno, size_t size); ++void *mdbg_calloc(const char *fname, int lineno, size_t nmemb, size_t size); ++void *mdbg_realloc(const char *fname, int lineno, void *ptr, size_t size); ++ ++void mdbg_check(int bufdump); ++ ++#define malloc(size) mdbg_malloc(__FILE__, __LINE__, (size)) ++#define calloc(nmemb, size) \ ++ mdbg_calloc(__FILE__, __LINE__, (nmemb), (size)) ++#define realloc(ptr, size) \ ++ mdbg_realloc(__FILE__, __LINE__, (ptr), (size)) ++ ++#else ++ ++void *malloc(size_t size); ++void *calloc(size_t nmemb, size_t size); ++void *realloc(void *ptr, size_t size); ++ ++#define mdbg_check(x) do { } while (0) ++ ++#endif ++ ++ ++/* ++ * Returns true if the supplied memory area is within a buffer ++ * previously allocated (and not freed yet). ++ * ++ * Used internally by TAs ++ */ ++bool malloc_buffer_is_within_alloced(void *buf, size_t len); ++ ++/* ++ * Returns true if the supplied memory area is overlapping the area used ++ * for heap. ++ * ++ * Used internally by TAs ++ */ ++bool malloc_buffer_overlaps_heap(void *buf, size_t len); ++ ++/* ++ * Adds a pool of memory to allocate from. ++ */ ++void malloc_add_pool(void *buf, size_t len); ++ ++#ifdef CFG_WITH_STATS ++/* ++ * Get/reset allocation statistics ++ */ ++ ++#define TEE_ALLOCATOR_DESC_LENGTH 32 ++struct malloc_stats { ++ char desc[TEE_ALLOCATOR_DESC_LENGTH]; ++ uint32_t allocated; /* Bytes currently allocated */ ++ uint32_t max_allocated; /* Tracks max value of allocated */ ++ uint32_t size; /* Total size for this allocator */ ++ uint32_t num_alloc_fail; /* Number of failed alloc requests */ ++ uint32_t biggest_alloc_fail; /* Size of biggest failed alloc */ ++ uint32_t biggest_alloc_fail_used; /* Alloc bytes when above occurred */ ++}; ++ ++void malloc_get_stats(struct malloc_stats *stats); ++void malloc_reset_stats(void); ++#endif /* CFG_WITH_STATS */ ++ ++ ++#ifdef CFG_VIRTUALIZATION ++ ++void nex_free(void *ptr); ++ ++#ifdef ENABLE_MDBG ++ ++void *nex_mdbg_malloc(const char *fname, int lineno, size_t size); ++void *nex_mdbg_calloc(const char *fname, int lineno, size_t nmemb, size_t size); ++void *nex_mdbg_realloc(const char *fname, int lineno, void *ptr, size_t size); ++ ++void nex_mdbg_check(int bufdump); ++ ++#define nex_malloc(size) nex_mdbg_malloc(__FILE__, __LINE__, (size)) ++#define nex_calloc(nmemb, size) \ ++ nex_mdbg_calloc(__FILE__, __LINE__, (nmemb), (size)) ++#define nex_realloc(ptr, size) \ ++ nex_mdbg_realloc(__FILE__, __LINE__, (ptr), (size)) ++ ++#else /* ENABLE_MDBG */ ++ ++void *nex_malloc(size_t size); ++void *nex_calloc(size_t nmemb, size_t size); ++void *nex_realloc(void *ptr, size_t size); ++ ++#define nex_mdbg_check(x) do { } while (0) ++ ++#endif /* ENABLE_MDBG */ ++ ++bool nex_malloc_buffer_is_within_alloced(void *buf, size_t len); ++bool nex_malloc_buffer_overlaps_heap(void *buf, size_t len); ++void nex_malloc_add_pool(void *buf, size_t len); ++ ++#ifdef CFG_WITH_STATS ++/* ++ * Get/reset allocation statistics ++ */ ++ ++void nex_malloc_get_stats(struct malloc_stats *stats); ++void nex_malloc_reset_stats(void); ++ ++#endif /* CFG_WITH_STATS */ ++#else /* CFG_VIRTUALIZATION */ ++ ++#define nex_free(ptr) free(ptr) ++#define nex_malloc(size) malloc(size) ++#define nex_calloc(nmemb, size) calloc(nmemb, size) ++#define nex_realloc(ptr, size) realloc(ptr, size) ++ ++#endif /* CFG_VIRTUALIZATION */ ++ ++#endif /* MALLOC_H */ +diff --git a/environments/shim/include/lib/libc/setjmp.h b/environments/shim/include/lib/libc/setjmp.h +new file mode 100644 +index 0000000..5661201 +--- /dev/null ++++ b/environments/shim/include/lib/libc/setjmp.h +@@ -0,0 +1,20 @@ ++/* ++ * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef SETJMP_H ++#define SETJMP_H ++ ++#include ++ ++#ifndef __ASSEMBLY__ ++ ++#include ++ ++int setjmp(jmp_buf env); ++__dead2 void longjmp(jmp_buf env, int val); ++ ++#endif /* __ASSEMBLY__ */ ++#endif /* SETJMP_H */ +diff --git a/environments/shim/include/lib/libc/stdarg.h b/environments/shim/include/lib/libc/stdarg.h +new file mode 100644 +index 0000000..e260b9b +--- /dev/null ++++ b/environments/shim/include/lib/libc/stdarg.h +@@ -0,0 +1,20 @@ ++/* ++ * Copyright (c) 2012-2017 Roberto E. Vargas Caballero ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++/* ++ * Portions copyright (c) 2018, ARM Limited and Contributors. ++ * All rights reserved. ++ */ ++ ++#ifndef STDARG_H ++#define STDARG_H ++ ++#define va_list __builtin_va_list ++#define va_start(ap, last) __builtin_va_start(ap, last) ++#define va_end(ap) __builtin_va_end(ap) ++#define va_copy(to, from) __builtin_va_copy(to, from) ++#define va_arg(to, type) __builtin_va_arg(to, type) ++ ++#endif /* STDARG_H */ +diff --git a/environments/shim/include/lib/libc/stdbool.h b/environments/shim/include/lib/libc/stdbool.h +new file mode 100644 +index 0000000..e39aef7 +--- /dev/null ++++ b/environments/shim/include/lib/libc/stdbool.h +@@ -0,0 +1,17 @@ ++/* ++ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef STDBOOL_H ++#define STDBOOL_H ++ ++#define bool _Bool ++ ++#define true 1 ++#define false 0 ++ ++#define __bool_true_false_are_defined 1 ++ ++#endif /* STDBOOL_H */ +diff --git a/environments/shim/include/lib/libc/stddef.h b/environments/shim/include/lib/libc/stddef.h +new file mode 100644 +index 0000000..58a519e +--- /dev/null ++++ b/environments/shim/include/lib/libc/stddef.h +@@ -0,0 +1,27 @@ ++/* ++ * Copyright (c) 2012-2017 Roberto E. Vargas Caballero ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++/* ++ * Portions copyright (c) 2018-2019, ARM Limited and Contributors. ++ * All rights reserved. ++ */ ++ ++#ifndef STDDEF_H ++#define STDDEF_H ++ ++#include ++ ++#ifndef _PTRDIFF_T ++typedef long ptrdiff_t; ++#define _PTRDIFF_T ++#endif ++ ++#ifndef NULL ++#define NULL ((void *) 0) ++#endif ++ ++#define offsetof(st, m) __builtin_offsetof(st, m) ++ ++#endif /* STDDEF_H */ +diff --git a/environments/shim/include/lib/libc/stdint.h b/environments/shim/include/lib/libc/stdint.h +new file mode 100644 +index 0000000..d5dbfc4 +--- /dev/null ++++ b/environments/shim/include/lib/libc/stdint.h +@@ -0,0 +1,148 @@ ++/* ++ * Copyright (c) 2012-2017 Roberto E. Vargas Caballero ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++/* ++ * Portions copyright (c) 2018-2021, ARM Limited and Contributors. ++ * All rights reserved. ++ */ ++ ++#ifndef STDINT_H ++#define STDINT_H ++ ++#include ++ ++#define INT8_MAX CHAR_MAX ++#define INT8_MIN CHAR_MIN ++#define UINT8_MAX UCHAR_MAX ++ ++#define INT16_MAX SHRT_MAX ++#define INT16_MIN SHRT_MIN ++#define UINT16_MAX USHRT_MAX ++ ++#define INT32_MAX INT_MAX ++#define INT32_MIN INT_MIN ++#define UINT32_MAX UINT_MAX ++ ++#define INT64_MAX LLONG_MAX ++#define INT64_MIN LLONG_MIN ++#define UINT64_MAX ULLONG_MAX ++ ++#define INT_LEAST8_MIN INT8_MIN ++#define INT_LEAST8_MAX INT8_MAX ++#define UINT_LEAST8_MAX UINT8_MAX ++ ++#define INT_LEAST16_MIN INT16_MIN ++#define INT_LEAST16_MAX INT16_MAX ++#define UINT_LEAST16_MAX UINT16_MAX ++ ++#define INT_LEAST32_MIN INT32_MIN ++#define INT_LEAST32_MAX INT32_MAX ++#define UINT_LEAST32_MAX UINT32_MAX ++ ++#define INT_LEAST64_MIN INT64_MIN ++#define INT_LEAST64_MAX INT64_MAX ++#define UINT_LEAST64_MAX UINT64_MAX ++ ++#define INT_FAST8_MIN INT32_MIN ++#define INT_FAST8_MAX INT32_MAX ++#define UINT_FAST8_MAX UINT32_MAX ++ ++#define INT_FAST16_MIN INT32_MIN ++#define INT_FAST16_MAX INT32_MAX ++#define UINT_FAST16_MAX UINT32_MAX ++ ++#define INT_FAST32_MIN INT32_MIN ++#define INT_FAST32_MAX INT32_MAX ++#define UINT_FAST32_MAX UINT32_MAX ++ ++#define INT_FAST64_MIN INT64_MIN ++#define INT_FAST64_MAX INT64_MAX ++#define UINT_FAST64_MAX UINT64_MAX ++ ++#define INTPTR_MIN LONG_MIN ++#define INTPTR_MAX LONG_MAX ++#define UINTPTR_MAX ULONG_MAX ++ ++#define INTMAX_MIN LLONG_MIN ++#define INTMAX_MAX LLONG_MAX ++#define UINTMAX_MAX ULLONG_MAX ++ ++#define PTRDIFF_MIN LONG_MIN ++#define PTRDIFF_MAX LONG_MAX ++ ++#define SIZE_MAX ULONG_MAX ++ ++#define INT8_C(x) x ++#define INT16_C(x) x ++#define INT32_C(x) x ++#define INT64_C(x) x ## LL ++ ++#define UINT8_C(x) x ++#define UINT16_C(x) x ++#define UINT32_C(x) x ## U ++#define UINT64_C(x) x ## ULL ++ ++#define INTMAX_C(x) x ## LL ++#define UINTMAX_C(x) x ## ULL ++ ++typedef signed char int8_t; ++typedef short int16_t; ++typedef int int32_t; ++typedef long long int64_t; ++ ++typedef unsigned char uint8_t; ++typedef unsigned short uint16_t; ++typedef unsigned int uint32_t; ++typedef unsigned long long uint64_t; ++ ++typedef signed char int8_least_t; ++typedef short int16_least_t; ++typedef int int32_least_t; ++typedef long long int64_least_t; ++ ++typedef unsigned char uint8_least_t; ++typedef unsigned short uint16_least_t; ++typedef unsigned int uint32_least_t; ++typedef unsigned long long uint64_least_t; ++ ++typedef int int8_fast_t; ++typedef int int16_fast_t; ++typedef int int32_fast_t; ++typedef long long int64_fast_t; ++ ++typedef unsigned int uint8_fast_t; ++typedef unsigned int uint16_fast_t; ++typedef unsigned int uint32_fast_t; ++typedef unsigned long long uint64_fast_t; ++ ++typedef long intptr_t; ++typedef unsigned long uintptr_t; ++ ++/* 7.18.1.2 Minimum-width integer types */ ++typedef int8_t int_least8_t; ++typedef int16_t int_least16_t; ++typedef int32_t int_least32_t; ++typedef int64_t int_least64_t; ++typedef uint8_t uint_least8_t; ++typedef uint16_t uint_least16_t; ++typedef uint32_t uint_least32_t; ++typedef uint64_t uint_least64_t; ++ ++/* ++* Conceptually, these are supposed to be the largest integers representable in C, ++* but GCC and Clang define them as long long for compatibility. ++*/ ++typedef long long intmax_t; ++typedef unsigned long long uintmax_t; ++ ++typedef long register_t; ++typedef unsigned long u_register_t; ++ ++#ifdef __aarch64__ ++typedef __int128 int128_t; ++typedef unsigned __int128 uint128_t; ++#endif /* __aarch64__ */ ++ ++#endif /* STDINT_H */ +diff --git a/environments/shim/include/lib/libc/stdio.h b/environments/shim/include/lib/libc/stdio.h +new file mode 100644 +index 0000000..88d4d73 +--- /dev/null ++++ b/environments/shim/include/lib/libc/stdio.h +@@ -0,0 +1,33 @@ ++/* ++ * Copyright (c) 2012-2017 Roberto E. Vargas Caballero ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++/* ++ * Portions copyright (c) 2018-2021, ARM Limited and Contributors. ++ * All rights reserved. ++ */ ++ ++#ifndef STDIO_H ++#define STDIO_H ++ ++#include ++#include ++#include ++ ++#define EOF -1 ++ ++int printf(const char *fmt, ...) __printflike(1, 2); ++int snprintf(char *s, size_t n, const char *fmt, ...) __printflike(3, 4); ++ ++#ifdef STDARG_H ++int vprintf(const char *fmt, va_list args) __printflike(1, 0); ++int vsnprintf(char *str, size_t size, const char *format, va_list ap) __printflike(3, 0); ++#endif ++ ++int putchar(int c); ++int puts(const char *s); ++ ++typedef struct _FILE FILE; ++ ++#endif /* STDIO_H */ +diff --git a/environments/shim/include/lib/libc/stdlib.h b/environments/shim/include/lib/libc/stdlib.h +new file mode 100644 +index 0000000..bbd6889 +--- /dev/null ++++ b/environments/shim/include/lib/libc/stdlib.h +@@ -0,0 +1,34 @@ ++/* ++ * Copyright (c) 2012-2017 Roberto E. Vargas Caballero ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++/* ++ * Portions copyright (c) 2018-2021, ARM Limited and Contributors. ++ * All rights reserved. ++ */ ++ ++#ifndef STDLIB_H ++#define STDLIB_H ++ ++#include ++ ++#define EXIT_FAILURE 1 ++#define EXIT_SUCCESS 0 ++ ++#define _ATEXIT_MAX 1 ++ ++#define RAND_MAX 0x7ffffffd ++ ++extern void abort(void); ++extern int atexit(void (*func)(void)); ++extern void exit(int status); ++ ++int rand(void); ++void srand(unsigned int seed); ++ ++void malloc_add_pool(void *buf, size_t len); ++void *malloc(size_t size); ++void free(void *ptr); ++ ++#endif /* STDLIB_H */ +diff --git a/environments/shim/include/lib/libc/string.h b/environments/shim/include/lib/libc/string.h +new file mode 100644 +index 0000000..8df8cf9 +--- /dev/null ++++ b/environments/shim/include/lib/libc/string.h +@@ -0,0 +1,30 @@ ++/* ++ * Copyright (c) 2012-2017 Roberto E. Vargas Caballero ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++/* ++ * Portions copyright (c) 2018-2019, ARM Limited and Contributors. ++ * All rights reserved. ++ */ ++ ++#ifndef STRING_H ++#define STRING_H ++ ++#include ++ ++void *memcpy(void *dst, const void *src, size_t len); ++void *memmove(void *dst, const void *src, size_t len); ++int memcmp(const void *s1, const void *s2, size_t len); ++int strcmp(const char *s1, const char *s2); ++int strncmp(const char *s1, const char *s2, size_t n); ++void *memchr(const void *src, int c, size_t len); ++char *strchr(const char *s, int c); ++void *memset(void *dst, int val, size_t count); ++size_t strlen(const char *s); ++size_t strnlen(const char *s, size_t maxlen); ++char *strrchr(const char *p, int ch); ++size_t strlcpy(char * dst, const char * src, size_t dsize); ++char *strncpy(char *dst, const char *src, size_t n); ++ ++#endif /* STRING_H */ +diff --git a/environments/shim/include/lib/libc/time.h b/environments/shim/include/lib/libc/time.h +new file mode 100644 +index 0000000..c1c95e5 +--- /dev/null ++++ b/environments/shim/include/lib/libc/time.h +@@ -0,0 +1,18 @@ ++/* ++ * Copyright (c) 2012-2017 Roberto E. Vargas Caballero ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++/* ++ * Portions copyright (c) 2018-2019, ARM Limited and Contributors. ++ * All rights reserved. ++ */ ++ ++#ifndef TIME_H ++#define TIME_H ++ ++#include ++ ++typedef long int time_t; ++ ++#endif /* TIME_H */ +diff --git a/environments/shim/include/lib/libc/util.h b/environments/shim/include/lib/libc/util.h +new file mode 100644 +index 0000000..03ab476 +--- /dev/null ++++ b/environments/shim/include/lib/libc/util.h +@@ -0,0 +1,165 @@ ++/* SPDX-License-Identifier: BSD-2-Clause */ ++/* ++ * Copyright (c) 2014, STMicroelectronics International N.V. ++ */ ++#ifndef UTIL_H ++#define UTIL_H ++ ++#include ++#include ++ ++#define SIZE_4K UINTPTR_C(0x1000) ++#define SIZE_1M UINTPTR_C(0x100000) ++#define SIZE_2M UINTPTR_C(0x200000) ++#define SIZE_4M UINTPTR_C(0x400000) ++#define SIZE_8M UINTPTR_C(0x800000) ++#define SIZE_2G UINTPTR_C(0x80000000) ++ ++#ifndef MAX ++#ifndef __ASSEMBLER__ ++#define MAX(a, b) \ ++ (__extension__({ __typeof__(a) _a = (a); \ ++ __typeof__(b) _b = (b); \ ++ _a > _b ? _a : _b; })) ++ ++#define MIN(a, b) \ ++ (__extension__({ __typeof__(a) _a = (a); \ ++ __typeof__(b) _b = (b); \ ++ _a < _b ? _a : _b; })) ++#else ++#define MAX(a, b) (((a) > (b)) ? (a) : (b)) ++#define MIN(a, b) (((a) < (b)) ? (a) : (b)) ++#endif ++#endif ++ ++/* ++ * In some particular conditions MAX and MIN macros fail to ++ * build from C source file implmentation. In such case one ++ * need to use MAX_UNSAFE/MIN_UNSAFE instead. ++ */ ++#define MAX_UNSAFE(a, b) (((a) > (b)) ? (a) : (b)) ++#define MIN_UNSAFE(a, b) (((a) < (b)) ? (a) : (b)) ++ ++#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) ++ ++#ifndef __ASSEMBLER__ ++/* Round up the even multiple of size, size has to be a multiple of 2 */ ++#define ROUNDUP(v, size) (((v) + ((__typeof__(v))(size) - 1)) & \ ++ ~((__typeof__(v))(size) - 1)) ++ ++#define ROUNDUP_OVERFLOW(v, size, res) (__extension__({ \ ++ typeof(*(res)) __roundup_tmp = 0; \ ++ typeof(v) __roundup_mask = (typeof(v))(size) - 1; \ ++ \ ++ ADD_OVERFLOW((v), __roundup_mask, &__roundup_tmp) ? 1 : \ ++ (void)(*(res) = __roundup_tmp & ~__roundup_mask), 0; \ ++})) ++ ++/* ++ * Rounds up to the nearest multiple of y and then divides by y. Safe ++ * against overflow, y has to be a multiple of 2. ++ * ++ * This macro is intended to be used to convert from "number of bytes" to ++ * "number of pages" or similar units. Example: ++ * num_pages = ROUNDUP_DIV(num_bytes, SMALL_PAGE_SIZE); ++ */ ++#define ROUNDUP_DIV(x, y) (__extension__({ \ ++ typeof(x) __roundup_x = (x); \ ++ typeof(y) __roundup_mask = (typeof(x))(y) - 1; \ ++ \ ++ (__roundup_x / (y)) + (__roundup_x & __roundup_mask ? 1 : 0); \ ++})) ++ ++/* Round down the even multiple of size, size has to be a multiple of 2 */ ++#define ROUNDDOWN(v, size) ((v) & ~((__typeof__(v))(size) - 1)) ++ ++/* Unsigned integer division with nearest rounding variant */ ++#define UDIV_ROUND_NEAREST(x, y) \ ++ (__extension__ ({ __typeof__(x) _x = (x); \ ++ __typeof__(y) _y = (y); \ ++ (_x + (_y / 2)) / _y; })) ++#else ++#define ROUNDUP(x, y) ((((x) + (y) - 1) / (y)) * (y)) ++#define ROUNDDOWN(x, y) (((x) / (y)) * (y)) ++#define UDIV_ROUND_NEAREST(x, y) (((x) + ((y) / 2)) / (y)) ++#endif ++ ++/* x has to be of an unsigned type */ ++#define IS_POWER_OF_TWO(x) (((x) != 0) && (((x) & (~(x) + 1)) == (x))) ++ ++#define ALIGNMENT_IS_OK(p, type) \ ++ (((uintptr_t)(p) & (__alignof__(type) - 1)) == 0) ++ ++#define TO_STR(x) _TO_STR(x) ++#define _TO_STR(x) #x ++ ++#define CONCAT(x, y) _CONCAT(x, y) ++#define _CONCAT(x, y) x##y ++ ++#define container_of(ptr, type, member) \ ++ (__extension__({ \ ++ const typeof(((type *)0)->member) *__ptr = (ptr); \ ++ (type *)((unsigned long)(__ptr) - offsetof(type, member)); \ ++ })) ++ ++#define MEMBER_SIZE(type, member) sizeof(((type *)0)->member) ++ ++#ifdef __ASSEMBLER__ ++#define BIT32(nr) (1 << (nr)) ++#define BIT64(nr) (1 << (nr)) ++#define SHIFT_U32(v, shift) ((v) << (shift)) ++#define SHIFT_U64(v, shift) ((v) << (shift)) ++#else ++#define BIT32(nr) (UINT32_C(1) << (nr)) ++#define BIT64(nr) (UINT64_C(1) << (nr)) ++#define SHIFT_U32(v, shift) ((uint32_t)(v) << (shift)) ++#define SHIFT_U64(v, shift) ((uint64_t)(v) << (shift)) ++#endif ++#define BIT(nr) BIT32(nr) ++ ++/* ++ * Create a contiguous bitmask starting at bit position @l and ending at ++ * position @h. For example ++ * GENMASK_64(39, 21) gives us the 64bit vector 0x000000ffffe00000. ++ */ ++#define GENMASK_32(h, l) \ ++ (((~UINT32_C(0)) << (l)) & (~UINT32_C(0) >> (32 - 1 - (h)))) ++ ++#define GENMASK_64(h, l) \ ++ (((~UINT64_C(0)) << (l)) & (~UINT64_C(0) >> (64 - 1 - (h)))) ++ ++/* ++ * Checking overflow for addition, subtraction and multiplication. Result ++ * of operation is stored in res which is a pointer to some kind of ++ * integer. ++ * ++ * The macros return true if an overflow occurred and *res is undefined. ++ */ ++#define ADD_OVERFLOW(a, b, res) __compiler_add_overflow((a), (b), (res)) ++#define SUB_OVERFLOW(a, b, res) __compiler_sub_overflow((a), (b), (res)) ++#define MUL_OVERFLOW(a, b, res) __compiler_mul_overflow((a), (b), (res)) ++ ++/* Return a signed +1, 0 or -1 value based on data comparison */ ++#define CMP_TRILEAN(a, b) \ ++ (__extension__({ \ ++ __typeof__(a) _a = (a); \ ++ __typeof__(b) _b = (b); \ ++ \ ++ _a > _b ? 1 : _a < _b ? -1 : 0; \ ++ })) ++ ++#ifndef __ASSEMBLER__ ++static inline uint64_t reg_pair_to_64(uint32_t reg0, uint32_t reg1) ++{ ++ return (uint64_t)reg0 << 32 | reg1; ++} ++ ++static inline void reg_pair_from_64(uint64_t val, uint32_t *reg0, ++ uint32_t *reg1) ++{ ++ *reg0 = val >> 32; ++ *reg1 = val; ++} ++#endif ++ ++#endif /*UTIL_H*/ +diff --git a/environments/shim/include/lib/libc/uuid.h b/environments/shim/include/lib/libc/uuid.h +new file mode 100644 +index 0000000..3a1699b +--- /dev/null ++++ b/environments/shim/include/lib/libc/uuid.h +@@ -0,0 +1,56 @@ ++/*- ++ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD ++ * ++ * Copyright (c) 2002 Marcel Moolenaar ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ++ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ++ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ++ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ++ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ++ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ++ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * $FreeBSD$ ++ */ ++ ++/* ++ * Portions copyright (c) 2014-2020, ARM Limited and Contributors. ++ * All rights reserved. ++ */ ++ ++#ifndef _SYS_UUID_H_ ++#define _SYS_UUID_H_ ++ ++#include ++#include ++ ++/* Length of a node address (an IEEE 802 address). */ ++#define _UUID_NODE_LEN 6 ++ ++struct uuid { ++ uint8_t time_low[4]; ++ uint8_t time_mid[2]; ++ uint8_t time_hi_and_version[2]; ++ uint8_t clock_seq_hi_and_reserved; ++ uint8_t clock_seq_low; ++ uint8_t node[_UUID_NODE_LEN]; ++}; ++ ++typedef struct uuid uuid_t; ++ ++#endif /* _SYS_UUID_H_ */ +diff --git a/environments/shim/include/lib/mmio.h b/environments/shim/include/lib/mmio.h +new file mode 100644 +index 0000000..e8a7df0 +--- /dev/null ++++ b/environments/shim/include/lib/mmio.h +@@ -0,0 +1,42 @@ ++/* ++ * Copyright (c) 2018, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef __MMIO_H__ ++#define __MMIO_H__ ++ ++#include ++ ++static inline void mmio_write_8(uintptr_t addr, uint8_t value) ++{ ++ *(volatile uint8_t*)addr = value; ++} ++ ++static inline uint8_t mmio_read_8(uintptr_t addr) ++{ ++ return *(volatile uint8_t*)addr; ++} ++ ++static inline void mmio_write_32(uintptr_t addr, uint32_t value) ++{ ++ *(volatile uint32_t*)addr = value; ++} ++ ++static inline uint32_t mmio_read_32(uintptr_t addr) ++{ ++ return *(volatile uint32_t*)addr; ++} ++ ++static inline void mmio_write_64(uintptr_t addr, uint64_t value) ++{ ++ *(volatile uint64_t*)addr = value; ++} ++ ++static inline uint64_t mmio_read_64(uintptr_t addr) ++{ ++ return *(volatile uint64_t*)addr; ++} ++ ++#endif /* __MMIO_H__ */ +diff --git a/environments/shim/include/lib/spinlock.h b/environments/shim/include/lib/spinlock.h +new file mode 100644 +index 0000000..27ea730 +--- /dev/null ++++ b/environments/shim/include/lib/spinlock.h +@@ -0,0 +1,18 @@ ++/* ++ * Copyright (c) 2018, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef __SPINLOCK_H__ ++#define __SPINLOCK_H__ ++ ++typedef struct spinlock { ++ volatile unsigned int lock; ++} spinlock_t; ++ ++void init_spinlock(spinlock_t *lock); ++void spin_lock(spinlock_t *lock); ++void spin_unlock(spinlock_t *lock); ++ ++#endif /* __SPINLOCK_H__ */ +diff --git a/environments/shim/include/lib/status.h b/environments/shim/include/lib/status.h +new file mode 100644 +index 0000000..8cb6145 +--- /dev/null ++++ b/environments/shim/include/lib/status.h +@@ -0,0 +1,28 @@ ++/* ++ * Copyright (c) 2018, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef __STATUS_H__ ++#define __STATUS_H__ ++ ++/* Status Code definitions */ ++#define STATUS_SUCCESS 0x00 ++#define STATUS_INVALID_PARAMETER 0x01 ++#define STATUS_UNSUPPORTED 0x02 ++#define STATUS_OUT_OF_RESOURCES 0x03 ++#define STATUS_NOT_FOUND 0x04 ++#define STATUS_ABORTED 0x05 ++#define STATUS_LOAD_ERROR 0x06 ++#define STATUS_NEVER_RETURN 0x07 ++#define STATUS_BUSY 0x08 ++#define STATUS_NOT_INIT 0x09 ++#define STATUS_BUFFER_TOO_SMALL 0x0A ++#define STATUS_COMPROMISED_DATA 0x0B ++#define STATUS_ALREADY_LOADED 0x0C ++#define STATUS_FAIL 0x0D ++ ++typedef unsigned int STATUS; ++ ++#endif /* __STATUS_H__ */ +diff --git a/environments/shim/include/lib/tftf_lib.h b/environments/shim/include/lib/tftf_lib.h +new file mode 100644 +index 0000000..f9d1a6e +--- /dev/null ++++ b/environments/shim/include/lib/tftf_lib.h +@@ -0,0 +1,236 @@ ++/* ++ * Copyright (c) 2018-2020, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef __TFTF_LIB_H__ ++#define __TFTF_LIB_H__ ++ ++#ifndef __ASSEMBLY__ ++ ++#include ++#include ++#include ++#include ++ ++/* ++ * Possible error codes for signaling the result of a test ++ * TEST_RESULT_MIN and TEST_RESULT_MAX are only used as bounds in the enum. ++ */ ++typedef enum { ++ /* ++ * NA = Not applicable. ++ * Initial value for a test result. ++ * Used for CPUs that don't participate in the test. ++ */ ++ TEST_RESULT_NA = -1, ++ ++ TEST_RESULT_MIN = 0, ++ TEST_RESULT_SKIPPED = TEST_RESULT_MIN, ++ TEST_RESULT_SUCCESS, ++ TEST_RESULT_FAIL, ++ TEST_RESULT_CRASHED, ++ ++ TEST_RESULT_MAX ++} test_result_t; ++ ++#define TEST_RESULT_IS_VALID(result) \ ++ ((result >= TEST_RESULT_MIN) && (result < TEST_RESULT_MAX)) ++ ++/* ++ * PSCI Function Wrappers ++ * ++ * SMC calls to PSCI functions ++ */ ++int32_t tftf_psci_cpu_on(u_register_t target_cpu, ++ uintptr_t entry_point_address, ++ u_register_t context_id); ++int32_t tftf_psci_cpu_off(void); ++int32_t tftf_psci_affinity_info(u_register_t target_affinity, ++ uint32_t lowest_affinity_level); ++int32_t tftf_psci_node_hw_state(u_register_t target_cpu, uint32_t power_level); ++int32_t tftf_get_psci_feature_info(uint32_t psci_func_id); ++u_register_t tftf_psci_stat_count(u_register_t target_cpu, ++ uint32_t power_state); ++u_register_t tftf_psci_stat_residency(u_register_t target_cpu, ++ uint32_t power_state); ++ ++/* ++ * PSCI Helper functions ++ */ ++ ++/* ++ * Gets the context ID used when calling tftf_psci_cpu_on(). ++ */ ++u_register_t tftf_get_cpu_on_ctx_id(unsigned int core_pos); ++ ++/* ++ * Sets the context ID used when calling tftf_psci_cpu_on(). ++ */ ++void tftf_set_cpu_on_ctx_id(unsigned int core_pos, u_register_t context_id); ++ ++/* ++ * Gets the PSCI version of Trusted Firmware-A. The version number returned ++ * is a 32-bit unsigned integer, with the upper 16 bits denoting the major ++ * revision, and the lower 16 bits denoting the minor revision. ++ */ ++unsigned int tftf_get_psci_version(void); ++ ++/* ++ * Returns 0 if version is not a valid PSCI version supported by TFTF. ++ * Otherwise it returns a value different of 0. ++ */ ++int tftf_is_valid_psci_version(unsigned int version); ++ ++ ++/* ++ * The function constructs a composite state_id up-to the specified ++ * affinity level querying the relevant state property from the platform. ++ * It chooses the first matching state property from the array returned ++ * by platform. In case the requested affinity level is not supported by ++ * the platform, then this function uses DUMMY_STATE_ID as the local state ++ * for that level. This allows the tests to construct composite state-id ++ * for invalid affinity levels as well. It returns the expected return ++ * value from CPU SUSPEND call. ++ */ ++int tftf_psci_make_composite_state_id(uint32_t affinity_level, ++ uint32_t state_type, uint32_t *state_id); ++ ++/* ++ * This function composes the power state parameter in the right format ++ * needed by PSCI. The detection of the power state format is done during ++ * cold boot by tftf_detect_psci_pstate_format() function. ++ */ ++uint32_t tftf_make_psci_pstate(uint32_t affinity_level, ++ uint32_t state_type, ++ uint32_t state_id); ++ ++/* ++ * Returns 1, if the EL3 software supports PSCI's original format state ID as ++ * NULL else returns zero ++ */ ++unsigned int tftf_is_psci_state_id_null(void); ++ ++/* ++ * Returns 1, if the EL3 software supports PSCI's original state format else ++ * returns zero ++ */ ++unsigned int tftf_is_psci_pstate_format_original(void); ++ ++/* Functions to wait for a specified number of ms or us */ ++void waitms(uint64_t ms); ++void waitus(uint64_t us); ++ ++/* ++ * SMC calls take a function identifier and up to 7 arguments. ++ * Additionally, few SMC calls that originate from EL2 leverage the seventh ++ * argument explicitly. Given that TFTF runs in EL2, we need to be able to ++ * specify it. ++ */ ++typedef struct { ++ /* Function identifier. Identifies which function is being invoked. */ ++ uint32_t fid; ++ ++ u_register_t arg1; ++ u_register_t arg2; ++ u_register_t arg3; ++ u_register_t arg4; ++ u_register_t arg5; ++ u_register_t arg6; ++ u_register_t arg7; ++} smc_args; ++ ++/* SMC calls can return up to 8 register values */ ++typedef struct { ++ u_register_t ret0; ++ u_register_t ret1; ++ u_register_t ret2; ++ u_register_t ret3; ++ u_register_t ret4; ++ u_register_t ret5; ++ u_register_t ret6; ++ u_register_t ret7; ++} smc_ret_values; ++ ++/* ++ * Trigger an SMC call. ++ */ ++smc_ret_values tftf_smc(const smc_args *args); ++ ++/* ++ * Trigger an HVC call. ++ */ ++typedef smc_args hvc_args; ++ ++typedef smc_ret_values hvc_ret_values; ++ ++hvc_ret_values tftf_hvc(const hvc_args *args); ++ ++/* ++ * Write a formatted string in the test output buffer. ++ * Just like the standard libc's printf() function, the string produced is under ++ * the control of a format string that specifies how subsequent arguments are ++ * converted. ++ * ++ * The string will appear in the test report. ++ * Use mp_printf() instead for volatile debug messages that are not meant to be ++ * stored into the test report. ++ * Note: The test output buffer referred here is a temporary buffer stored in ++ * RAM. This function doesn't write anything into NVM. ++ * ++ * Upon successful return, return the number of characters printed (not ++ * including the final '\0' character). If an output error is encountered, ++ * a negative value is returned. If the function is not able to print any ++ * character at all, this is considered as an output error. Note that a partial ++ * write (i.e. when the string is truncated) is not considered as an output ++ * error. ++ */ ++__attribute__((format(printf, 1, 2))) ++int tftf_testcase_printf(const char *format, ...); ++ ++/* ++ * This function is meant to be used by tests. ++ * It tells the framework that the test is going to reset the platform. ++ * ++ * It the test omits to call this function before resetting, the framework will ++ * consider the test has crashed upon resumption. ++ */ ++void tftf_notify_reboot(void); ++ ++/* ++ * Returns 0 if the test function is executed for the first time, ++ * or 1 if the test rebooted the platform and the test function is being ++ * executed again. ++ * This function is used for tests that reboot the platform, so that they can ++ * execute different code paths on 1st execution and subsequent executions. ++ */ ++unsigned int tftf_is_rebooted(void); ++ ++static inline unsigned int make_mpid(unsigned int clusterid, ++#if PLAT_MAX_PE_PER_CPU > 1 ++ unsigned int coreid, ++ unsigned int threadid) ++#else ++ unsigned int coreid) ++#endif ++{ ++ /* ++ * If MT bit is set then need to shift the affinities and also set the ++ * MT bit. ++ */ ++ if ((read_mpidr_el1() & MPIDR_MT_MASK) != 0) ++ return MPIDR_MT_MASK | ++#if PLAT_MAX_PE_PER_CPU > 1 ++ ((threadid & MPIDR_AFFLVL_MASK) << MPIDR_AFF0_SHIFT) | ++#endif ++ ((coreid & MPIDR_AFFLVL_MASK) << MPIDR_AFF1_SHIFT) | ++ ((clusterid & MPIDR_AFFLVL_MASK) << MPIDR_AFF2_SHIFT); ++ else ++ return ((coreid & MPIDR_AFFLVL_MASK) << MPIDR_AFF0_SHIFT) | ++ ((clusterid & MPIDR_AFFLVL_MASK) << MPIDR_AFF1_SHIFT); ++ ++} ++ ++#endif /* __ASSEMBLY__ */ ++#endif /* __TFTF_LIB_H__ */ +diff --git a/environments/shim/include/lib/utils_def.h b/environments/shim/include/lib/utils_def.h +new file mode 100644 +index 0000000..78d4131 +--- /dev/null ++++ b/environments/shim/include/lib/utils_def.h +@@ -0,0 +1,165 @@ ++/* ++ * Copyright (c) 2016-2020, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef UTILS_DEF_H ++#define UTILS_DEF_H ++ ++/* Compute the number of elements in the given array */ ++#define ARRAY_SIZE(a) \ ++ (sizeof(a) / sizeof((a)[0])) ++ ++#define IS_POWER_OF_TWO(x) \ ++ (((x) & ((x) - 1)) == 0) ++ ++#define SIZE_FROM_LOG2_WORDS(n) (4 << (n)) ++ ++#define BIT_32(nr) (U(1) << (nr)) ++#define BIT_64(nr) (ULL(1) << (nr)) ++ ++#ifndef __aarch64__ ++#define BIT BIT_32 ++#else ++#define BIT BIT_64 ++#endif ++ ++/* ++ * Create a contiguous bitmask starting at bit position @l and ending at ++ * position @h. For example ++ * GENMASK_64(39, 21) gives us the 64bit vector 0x000000ffffe00000. ++ */ ++#if defined(__LINKER__) || defined(__ASSEMBLY__) ++#define GENMASK_32(h, l) \ ++ (((0xFFFFFFFF) << (l)) & (0xFFFFFFFF >> (32 - 1 - (h)))) ++ ++#define GENMASK_64(h, l) \ ++ ((~0 << (l)) & (~0 >> (64 - 1 - (h)))) ++#else ++#define GENMASK_32(h, l) \ ++ (((~UINT32_C(0)) << (l)) & (~UINT32_C(0) >> (32 - 1 - (h)))) ++ ++#define GENMASK_64(h, l) \ ++ (((~UINT64_C(0)) << (l)) & (~UINT64_C(0) >> (64 - 1 - (h)))) ++#endif ++ ++#ifndef __aarch64__ ++#define GENMASK GENMASK_32 ++#else ++#define GENMASK GENMASK_64 ++#endif ++ ++/* ++ * This variant of div_round_up can be used in macro definition but should not ++ * be used in C code as the `div` parameter is evaluated twice. ++ */ ++#define DIV_ROUND_UP_2EVAL(n, d) (((n) + (d) - 1) / (d)) ++ ++#define div_round_up(val, div) __extension__ ({ \ ++ __typeof__(div) _div = (div); \ ++ ((val) + _div - (__typeof__(div)) 1) / _div; \ ++}) ++ ++#define MIN(x, y) __extension__ ({ \ ++ __typeof__(x) _x = (x); \ ++ __typeof__(y) _y = (y); \ ++ (void)(&_x == &_y); \ ++ _x < _y ? _x : _y; \ ++}) ++ ++#define MAX(x, y) __extension__ ({ \ ++ __typeof__(x) _x = (x); \ ++ __typeof__(y) _y = (y); \ ++ (void)(&_x == &_y); \ ++ _x > _y ? _x : _y; \ ++}) ++ ++/* ++ * The round_up() macro rounds up a value to the given boundary in a ++ * type-agnostic yet type-safe manner. The boundary must be a power of two. ++ * In other words, it computes the smallest multiple of boundary which is ++ * greater than or equal to value. ++ * ++ * round_down() is similar but rounds the value down instead. ++ */ ++#define round_boundary(value, boundary) \ ++ ((__typeof__(value))((boundary) - 1)) ++ ++#define round_up(value, boundary) \ ++ ((((value) - 1) | round_boundary(value, boundary)) + 1) ++ ++#define round_down(value, boundary) \ ++ ((value) & ~round_boundary(value, boundary)) ++ ++/* ++ * Evaluates to 1 if (ptr + inc) overflows, 0 otherwise. ++ * Both arguments must be unsigned pointer values (i.e. uintptr_t). ++ */ ++#define check_uptr_overflow(_ptr, _inc) \ ++ ((_ptr) > (UINTPTR_MAX - (_inc))) ++ ++/* ++ * Evaluates to 1 if (u32 + inc) overflows, 0 otherwise. ++ * Both arguments must be 32-bit unsigned integers (i.e. effectively uint32_t). ++ */ ++#define check_u32_overflow(_u32, _inc) \ ++ ((_u32) > (UINT32_MAX - (_inc))) ++ ++/* ++ * For those constants to be shared between C and other sources, apply a 'U', ++ * 'UL', 'ULL', 'L' or 'LL' suffix to the argument only in C, to avoid ++ * undefined or unintended behaviour. ++ * ++ * The GNU assembler and linker do not support these suffixes (it causes the ++ * build process to fail) therefore the suffix is omitted when used in linker ++ * scripts and assembler files. ++*/ ++#if defined(__LINKER__) || defined(__ASSEMBLY__) ++# define U(_x) (_x) ++# define UL(_x) (_x) ++# define ULL(_x) (_x) ++# define L(_x) (_x) ++# define LL(_x) (_x) ++#else ++# define U(_x) (_x##U) ++# define UL(_x) (_x##UL) ++# define ULL(_x) (_x##ULL) ++# define L(_x) (_x##L) ++# define LL(_x) (_x##LL) ++#endif ++ ++/* Register size of the current architecture. */ ++#ifndef __aarch64__ ++#define REGSZ U(4) ++#else ++#define REGSZ U(8) ++#endif ++ ++/* ++ * Test for the current architecture version to be at least the version ++ * expected. ++ */ ++#define ARM_ARCH_AT_LEAST(_maj, _min) \ ++ ((ARM_ARCH_MAJOR > (_maj)) || \ ++ ((ARM_ARCH_MAJOR == (_maj)) && (ARM_ARCH_MINOR >= (_min)))) ++ ++/* ++ * Import an assembly or linker symbol as a C expression with the specified ++ * type ++ */ ++#define IMPORT_SYM(type, sym, name) \ ++ extern char sym[];\ ++ static const __attribute__((unused)) type name = (type) sym; ++ ++/* ++ * When the symbol is used to hold a pointer, its alignment can be asserted ++ * with this macro. For example, if there is a linker symbol that is going to ++ * be used as a 64-bit pointer, the value of the linker symbol must also be ++ * aligned to 64 bit. This macro makes sure this is the case. ++ */ ++#define ASSERT_SYM_PTR_ALIGN(sym) assert(((size_t)(sym) % __alignof__(*(sym))) == 0) ++ ++#define COMPILER_BARRIER() __asm__ volatile ("" ::: "memory") ++ ++#endif /* UTILS_DEF_H */ +diff --git a/environments/shim/include/lib/xlat_tables/aarch64/xlat_tables_aarch64.h b/environments/shim/include/lib/xlat_tables/aarch64/xlat_tables_aarch64.h +new file mode 100644 +index 0000000..8c29d00 +--- /dev/null ++++ b/environments/shim/include/lib/xlat_tables/aarch64/xlat_tables_aarch64.h +@@ -0,0 +1,96 @@ ++/* ++ * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef XLAT_TABLES_AARCH64_H ++#define XLAT_TABLES_AARCH64_H ++ ++#include ++#include ++#include ++ ++#if !defined(PAGE_SIZE) ++#error "PAGE_SIZE is not defined." ++#endif ++ ++/* ++ * Encode a Physical Address Space size for its use in TCR_ELx. ++ */ ++unsigned long long tcr_physical_addr_size_bits(unsigned long long max_addr); ++ ++/* ++ * In AArch64 state, the MMU may support 4 KB, 16 KB and 64 KB page ++ * granularity. For 4KB granularity, a level 0 table descriptor doesn't support ++ * block translation. For 16KB, the same thing happens to levels 0 and 1. For ++ * 64KB, same for level 1. See section D4.3.1 of the ARMv8-A Architecture ++ * Reference Manual (DDI 0487A.k) for more information. ++ * ++ * The define below specifies the first table level that allows block ++ * descriptors. ++ */ ++#if PAGE_SIZE == PAGE_SIZE_4KB ++# define MIN_LVL_BLOCK_DESC U(1) ++#elif (PAGE_SIZE == PAGE_SIZE_16KB) || (PAGE_SIZE == PAGE_SIZE_64KB) ++# define MIN_LVL_BLOCK_DESC U(2) ++#endif ++ ++#define XLAT_TABLE_LEVEL_MIN U(0) ++ ++/* ++ * Define the architectural limits of the virtual address space in AArch64 ++ * state. ++ * ++ * TCR.TxSZ is calculated as 64 minus the width of said address space. ++ * The value of TCR.TxSZ must be in the range 16 to 39 [1] or 48 [2], ++ * depending on Small Translation Table Support which means that ++ * the virtual address space width must be in the range 48 to 25 or 16 bits. ++ * ++ * [1] See the ARMv8-A Architecture Reference Manual (DDI 0487A.j) for more ++ * information: ++ * Page 1730: 'Input address size', 'For all translation stages'. ++ * [2] See section 12.2.55 in the ARMv8-A Architecture Reference Manual ++ * (DDI 0487D.a) ++ */ ++/* Maximum value of TCR_ELx.T(0,1)SZ is 39 */ ++#define MIN_VIRT_ADDR_SPACE_SIZE (ULL(1) << (U(64) - TCR_TxSZ_MAX)) ++ ++/* Maximum value of TCR_ELx.T(0,1)SZ is 48 */ ++#define MIN_VIRT_ADDR_SPACE_SIZE_TTST \ ++ (ULL(1) << (U(64) - TCR_TxSZ_MAX_TTST)) ++#define MAX_VIRT_ADDR_SPACE_SIZE (ULL(1) << (U(64) - TCR_TxSZ_MIN)) ++ ++/* ++ * Here we calculate the initial lookup level from the value of the given ++ * virtual address space size. For a 4 KB page size, ++ * - level 0 supports virtual address spaces of widths 48 to 40 bits; ++ * - level 1 from 39 to 31; ++ * - level 2 from 30 to 22. ++ * - level 3 from 21 to 16. ++ * ++ * Small Translation Table (Armv8.4-TTST) support allows the starting level ++ * of the translation table from 3 for 4KB granularity. See section 12.2.55 in ++ * the ARMv8-A Architecture Reference Manual (DDI 0487D.a). In Armv8.3 and below ++ * wider or narrower address spaces are not supported. As a result, level 3 ++ * cannot be used as initial lookup level with 4 KB granularity. See section ++ * D4.2.5 in the ARMv8-A Architecture Reference Manual (DDI 0487A.j) for more ++ * information. ++ * ++ * For example, for a 35-bit address space (i.e. virt_addr_space_size == ++ * 1 << 35), TCR.TxSZ will be programmed to (64 - 35) = 29. According to Table ++ * D4-11 in the ARM ARM, the initial lookup level for an address space like that ++ * is 1. ++ * ++ * Note that this macro assumes that the given virtual address space size is ++ * valid. ++ */ ++#define GET_XLAT_TABLE_LEVEL_BASE(_virt_addr_space_sz) \ ++ (((_virt_addr_space_sz) > (ULL(1) << L0_XLAT_ADDRESS_SHIFT)) \ ++ ? 0U \ ++ : (((_virt_addr_space_sz) > (ULL(1) << L1_XLAT_ADDRESS_SHIFT)) \ ++ ? 1U \ ++ : (((_virt_addr_space_sz) > (ULL(1) << L2_XLAT_ADDRESS_SHIFT)) \ ++ ? 2U : 3U))) ++ ++#endif /* XLAT_TABLES_AARCH64_H */ +diff --git a/environments/shim/include/lib/xlat_tables/xlat_mmu_helpers.h b/environments/shim/include/lib/xlat_tables/xlat_mmu_helpers.h +new file mode 100644 +index 0000000..15ab2ef +--- /dev/null ++++ b/environments/shim/include/lib/xlat_tables/xlat_mmu_helpers.h +@@ -0,0 +1,91 @@ ++/* ++ * Copyright (c) 2014-2020, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef XLAT_MMU_HELPERS_H ++#define XLAT_MMU_HELPERS_H ++ ++/* ++ * The following flags are passed to enable_mmu_xxx() to override the default ++ * values used to program system registers while enabling the MMU. ++ */ ++ ++/* ++ * When this flag is used, all data access to Normal memory from this EL and all ++ * Normal memory accesses to the translation tables of this EL are non-cacheable ++ * for all levels of data and unified cache until the caches are enabled by ++ * setting the bit SCTLR_ELx.C. ++ */ ++#define DISABLE_DCACHE (U(1) << 0) ++ ++/* ++ * Mark the translation tables as non-cacheable for the MMU table walker, which ++ * is a different observer from the PE/CPU. If the flag is not specified, the ++ * tables are cacheable for the MMU table walker. ++ * ++ * Note that, as far as the PE/CPU observer is concerned, the attributes used ++ * are the ones specified in the translation tables themselves. The MAIR ++ * register specifies the cacheability through the field AttrIndx of the lower ++ * attributes of the translation tables. The shareability is specified in the SH ++ * field of the lower attributes. ++ * ++ * The MMU table walker uses the attributes specified in the fields ORGNn, IRGNn ++ * and SHn of the TCR register to access the translation tables. ++ * ++ * The attributes specified in the TCR register and the tables can be different ++ * as there are no checks to prevent that. Special care must be taken to ensure ++ * that there aren't mismatches. The behaviour in that case is described in the ++ * sections 'Mismatched memory attributes' in the ARMv8 ARM. ++ */ ++#define XLAT_TABLE_NC (U(1) << 1) ++ ++/* ++ * Offsets into a mmu_cfg_params array generated by setup_mmu_cfg(). All ++ * parameters are 64 bits wide. ++ */ ++#define MMU_CFG_MAIR 0 ++#define MMU_CFG_TCR 1 ++#define MMU_CFG_TTBR0 2 ++#define MMU_CFG_PARAM_MAX 3 ++ ++#ifndef __ASSEMBLY__ ++ ++#include ++#include ++#include ++ ++/* ++ * Return the values that the MMU configuration registers must contain for the ++ * specified translation context. `params` must be a pointer to array of size ++ * MMU_CFG_PARAM_MAX. ++ */ ++void setup_mmu_cfg(uint64_t *params, unsigned int flags, ++ const uint64_t *base_table, unsigned long long max_pa, ++ uintptr_t max_va, int xlat_regime); ++ ++#ifndef __aarch64__ ++/* AArch32 specific translation table API */ ++void enable_mmu_svc_mon(unsigned int flags); ++void enable_mmu_hyp(unsigned int flags); ++ ++void enable_mmu_direct_svc_mon(unsigned int flags); ++void enable_mmu_direct_hyp(unsigned int flags); ++#else ++/* AArch64 specific translation table APIs */ ++void enable_mmu_el1(unsigned int flags); ++void enable_mmu_el2(unsigned int flags); ++void enable_mmu_el3(unsigned int flags); ++ ++void enable_mmu_direct_el1(unsigned int flags); ++void enable_mmu_direct_el2(unsigned int flags); ++void enable_mmu_direct_el3(unsigned int flags); ++#endif /* !__aarch64__ */ ++ ++bool xlat_arch_is_granule_size_supported(size_t size); ++size_t xlat_arch_get_max_supported_granule_size(void); ++ ++#endif /* __ASSEMBLY__ */ ++ ++#endif /* XLAT_MMU_HELPERS_H */ +diff --git a/environments/shim/include/lib/xlat_tables/xlat_tables_arch.h b/environments/shim/include/lib/xlat_tables/xlat_tables_arch.h +new file mode 100644 +index 0000000..c8f29e4 +--- /dev/null ++++ b/environments/shim/include/lib/xlat_tables/xlat_tables_arch.h +@@ -0,0 +1,31 @@ ++/* ++ * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef XLAT_TABLES_ARCH_H ++#define XLAT_TABLES_ARCH_H ++ ++#ifndef __aarch64__ ++#include "aarch32/xlat_tables_aarch32.h" ++#else ++#include "aarch64/xlat_tables_aarch64.h" ++#endif ++ ++/* ++ * Evaluates to 1 if the given physical address space size is a power of 2, ++ * or 0 if it's not. ++ */ ++#define CHECK_PHY_ADDR_SPACE_SIZE(size) \ ++ (IS_POWER_OF_TWO(size)) ++ ++/* ++ * Compute the number of entries required at the initial lookup level to address ++ * the whole virtual address space. ++ */ ++#define GET_NUM_BASE_LEVEL_ENTRIES(addr_space_size) \ ++ ((addr_space_size) >> \ ++ XLAT_ADDR_SHIFT(GET_XLAT_TABLE_LEVEL_BASE(addr_space_size))) ++ ++#endif /* XLAT_TABLES_ARCH_H */ +diff --git a/environments/shim/include/lib/xlat_tables/xlat_tables_defs.h b/environments/shim/include/lib/xlat_tables/xlat_tables_defs.h +new file mode 100644 +index 0000000..1fd3c83 +--- /dev/null ++++ b/environments/shim/include/lib/xlat_tables/xlat_tables_defs.h +@@ -0,0 +1,182 @@ ++/* ++ * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef XLAT_TABLES_DEFS_H ++#define XLAT_TABLES_DEFS_H ++ ++#include ++#include ++#include ++ ++/* Miscellaneous MMU related constants */ ++#define NUM_2MB_IN_GB (U(1) << 9) ++#define NUM_4K_IN_2MB (U(1) << 9) ++#define NUM_GB_IN_4GB (U(1) << 2) ++ ++#define TWO_MB_SHIFT U(21) ++#define ONE_GB_SHIFT U(30) ++#define FOUR_KB_SHIFT U(12) ++ ++#define ONE_GB_INDEX(x) ((x) >> ONE_GB_SHIFT) ++#define TWO_MB_INDEX(x) ((x) >> TWO_MB_SHIFT) ++#define FOUR_KB_INDEX(x) ((x) >> FOUR_KB_SHIFT) ++ ++#define PAGE_SIZE_4KB U(4096) ++#define PAGE_SIZE_16KB U(16384) ++#define PAGE_SIZE_64KB U(65536) ++ ++#define INVALID_DESC U(0x0) ++/* ++ * A block descriptor points to a region of memory bigger than the granule size ++ * (e.g. a 2MB region when the granule size is 4KB). ++ */ ++#define BLOCK_DESC U(0x1) /* Table levels 0-2 */ ++/* A table descriptor points to the next level of translation table. */ ++#define TABLE_DESC U(0x3) /* Table levels 0-2 */ ++/* ++ * A page descriptor points to a page, i.e. a memory region whose size is the ++ * translation granule size (e.g. 4KB). ++ */ ++#define PAGE_DESC U(0x3) /* Table level 3 */ ++ ++#define DESC_MASK U(0x3) ++ ++#define FIRST_LEVEL_DESC_N ONE_GB_SHIFT ++#define SECOND_LEVEL_DESC_N TWO_MB_SHIFT ++#define THIRD_LEVEL_DESC_N FOUR_KB_SHIFT ++ ++/* XN: Translation regimes that support one VA range (EL2 and EL3). */ ++#define XN (ULL(1) << 2) ++/* UXN, PXN: Translation regimes that support two VA ranges (EL1&0). */ ++#define UXN (ULL(1) << 2) ++#define PXN (ULL(1) << 1) ++#define CONT_HINT (ULL(1) << 0) ++#define UPPER_ATTRS(x) (((x) & ULL(0x7)) << 52) ++ ++#define NON_GLOBAL (U(1) << 9) ++#define ACCESS_FLAG (U(1) << 8) ++#define NSH (U(0x0) << 6) ++#define OSH (U(0x2) << 6) ++#define ISH (U(0x3) << 6) ++ ++#ifdef __aarch64__ ++/* Guarded Page bit */ ++#define GP (ULL(1) << 50) ++#endif ++ ++#define TABLE_ADDR_MASK ULL(0x0000FFFFFFFFF000) ++ ++/* ++ * The ARMv8-A architecture allows translation granule sizes of 4KB, 16KB or ++ * 64KB. However, only 4KB are supported at the moment. ++ */ ++#define PAGE_SIZE_SHIFT FOUR_KB_SHIFT ++#define PAGE_SIZE (U(1) << PAGE_SIZE_SHIFT) ++#define PAGE_SIZE_MASK (PAGE_SIZE - U(1)) ++#define IS_PAGE_ALIGNED(addr) (((addr) & PAGE_SIZE_MASK) == U(0)) ++ ++#if (ARM_ARCH_MAJOR == 7) && !ARMV7_SUPPORTS_LARGE_PAGE_ADDRESSING ++#define XLAT_ENTRY_SIZE_SHIFT U(2) /* Each MMU table entry is 4 bytes */ ++#else ++#define XLAT_ENTRY_SIZE_SHIFT U(3) /* Each MMU table entry is 8 bytes */ ++#endif ++#define XLAT_ENTRY_SIZE (U(1) << XLAT_ENTRY_SIZE_SHIFT) ++ ++#define XLAT_TABLE_SIZE_SHIFT PAGE_SIZE_SHIFT /* Size of one complete table */ ++#define XLAT_TABLE_SIZE (U(1) << XLAT_TABLE_SIZE_SHIFT) ++ ++#define XLAT_TABLE_LEVEL_MAX U(3) ++ ++/* Values for number of entries in each MMU translation table */ ++#define XLAT_TABLE_ENTRIES_SHIFT (XLAT_TABLE_SIZE_SHIFT - XLAT_ENTRY_SIZE_SHIFT) ++#define XLAT_TABLE_ENTRIES (U(1) << XLAT_TABLE_ENTRIES_SHIFT) ++#define XLAT_TABLE_ENTRIES_MASK (XLAT_TABLE_ENTRIES - U(1)) ++ ++/* Values to convert a memory address to an index into a translation table */ ++#define L3_XLAT_ADDRESS_SHIFT PAGE_SIZE_SHIFT ++#define L2_XLAT_ADDRESS_SHIFT (L3_XLAT_ADDRESS_SHIFT + XLAT_TABLE_ENTRIES_SHIFT) ++#define L1_XLAT_ADDRESS_SHIFT (L2_XLAT_ADDRESS_SHIFT + XLAT_TABLE_ENTRIES_SHIFT) ++#define L0_XLAT_ADDRESS_SHIFT (L1_XLAT_ADDRESS_SHIFT + XLAT_TABLE_ENTRIES_SHIFT) ++#define XLAT_ADDR_SHIFT(level) (PAGE_SIZE_SHIFT + \ ++ ((XLAT_TABLE_LEVEL_MAX - (level)) * XLAT_TABLE_ENTRIES_SHIFT)) ++ ++#define XLAT_BLOCK_SIZE(level) (UL(1) << XLAT_ADDR_SHIFT(level)) ++/* Mask to get the bits used to index inside a block of a certain level */ ++#define XLAT_BLOCK_MASK(level) (XLAT_BLOCK_SIZE(level) - UL(1)) ++/* Mask to get the address bits common to a block of a certain table level*/ ++#define XLAT_ADDR_MASK(level) (~XLAT_BLOCK_MASK(level)) ++/* ++ * Extract from the given virtual address the index into the given lookup level. ++ * This macro assumes the system is using the 4KB translation granule. ++ */ ++#define XLAT_TABLE_IDX(virtual_addr, level) \ ++ (((virtual_addr) >> XLAT_ADDR_SHIFT(level)) & ULL(0x1FF)) ++ ++/* ++ * The ARMv8 translation table descriptor format defines AP[2:1] as the Access ++ * Permissions bits, and does not define an AP[0] bit. ++ * ++ * AP[1] is valid only for a stage 1 translation that supports two VA ranges ++ * (i.e. in the ARMv8A.0 architecture, that is the S-EL1&0 regime). It is RES1 ++ * when stage 1 translations can only support one VA range. ++ */ ++#define AP2_SHIFT U(0x7) ++#define AP2_RO ULL(0x1) ++#define AP2_RW ULL(0x0) ++ ++#define AP1_SHIFT U(0x6) ++#define AP1_ACCESS_UNPRIVILEGED ULL(0x1) ++#define AP1_NO_ACCESS_UNPRIVILEGED ULL(0x0) ++#define AP1_RES1 ULL(0x1) ++ ++/* ++ * The following definitions must all be passed to the LOWER_ATTRS() macro to ++ * get the right bitmask. ++ */ ++#define AP_RO (AP2_RO << 5) ++#define AP_RW (AP2_RW << 5) ++#define AP_ACCESS_UNPRIVILEGED (AP1_ACCESS_UNPRIVILEGED << 4) ++#define AP_NO_ACCESS_UNPRIVILEGED (AP1_NO_ACCESS_UNPRIVILEGED << 4) ++#define AP_ONE_VA_RANGE_RES1 (AP1_RES1 << 4) ++#define NS (U(0x1) << 3) ++#define ATTR_NON_CACHEABLE_INDEX ULL(0x2) ++#define ATTR_DEVICE_INDEX ULL(0x1) ++#define ATTR_IWBWA_OWBWA_NTR_INDEX ULL(0x0) ++#define LOWER_ATTRS(x) (((x) & U(0xfff)) << 2) ++ ++/* Normal Memory, Outer Write-Through non-transient, Inner Non-cacheable */ ++#define ATTR_NON_CACHEABLE MAKE_MAIR_NORMAL_MEMORY(MAIR_NORM_NC, MAIR_NORM_NC) ++/* Device-nGnRE */ ++#define ATTR_DEVICE MAIR_DEV_nGnRE ++/* Normal Memory, Outer Write-Back non-transient, Inner Write-Back non-transient */ ++#define ATTR_IWBWA_OWBWA_NTR MAKE_MAIR_NORMAL_MEMORY(MAIR_NORM_WB_NTR_RWA, MAIR_NORM_WB_NTR_RWA) ++#define MAIR_ATTR_SET(attr, index) ((attr) << ((index) << 3)) ++#define ATTR_INDEX_MASK U(0x3) ++#define ATTR_INDEX_GET(attr) (((attr) >> 2) & ATTR_INDEX_MASK) ++ ++/* ++ * Shift values for the attributes fields in a block or page descriptor. ++ * See section D4.3.3 in the ARMv8-A ARM (issue B.a). ++ */ ++ ++/* Memory attributes index field, AttrIndx[2:0]. */ ++#define ATTR_INDEX_SHIFT 2 ++/* Non-secure bit, NS. */ ++#define NS_SHIFT 5 ++/* Shareability field, SH[1:0] */ ++#define SHAREABILITY_SHIFT 8 ++/* The Access Flag, AF. */ ++#define ACCESS_FLAG_SHIFT 10 ++/* The not global bit, nG. */ ++#define NOT_GLOBAL_SHIFT 11 ++/* Contiguous hint bit. */ ++#define CONT_HINT_SHIFT 52 ++/* Execute-never bits, XN. */ ++#define PXN_SHIFT 53 ++#define XN_SHIFT 54 ++#define UXN_SHIFT XN_SHIFT ++ ++#endif /* XLAT_TABLES_DEFS_H */ +diff --git a/environments/shim/include/lib/xlat_tables/xlat_tables_v2.h b/environments/shim/include/lib/xlat_tables/xlat_tables_v2.h +new file mode 100644 +index 0000000..0fe388b +--- /dev/null ++++ b/environments/shim/include/lib/xlat_tables/xlat_tables_v2.h +@@ -0,0 +1,367 @@ ++/* ++ * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef XLAT_TABLES_V2_H ++#define XLAT_TABLES_V2_H ++ ++#include ++#include ++ ++#ifndef __ASSEMBLY__ ++#include ++#include ++#include ++ ++/* ++ * Default granularity size for an mmap_region_t. ++ * Useful when no specific granularity is required. ++ * ++ * By default, choose the biggest possible block size allowed by the ++ * architectural state and granule size in order to minimize the number of page ++ * tables required for the mapping. ++ */ ++#define REGION_DEFAULT_GRANULARITY XLAT_BLOCK_SIZE(MIN_LVL_BLOCK_DESC) ++ ++/* Helper macro to define an mmap_region_t. */ ++#define MAP_REGION(_pa, _va, _sz, _attr) \ ++ MAP_REGION_FULL_SPEC(_pa, _va, _sz, _attr, REGION_DEFAULT_GRANULARITY) ++ ++/* Helper macro to define an mmap_region_t with an identity mapping. */ ++#define MAP_REGION_FLAT(_adr, _sz, _attr) \ ++ MAP_REGION(_adr, _adr, _sz, _attr) ++ ++/* ++ * Helper macro to define entries for mmap_region_t. It allows to define 'pa' ++ * and sets 'va' to 0 for each region. To be used with mmap_add_alloc_va(). ++ */ ++#define MAP_REGION_ALLOC_VA(pa, sz, attr) MAP_REGION(pa, 0, sz, attr) ++ ++/* ++ * Helper macro to define an mmap_region_t to map with the desired granularity ++ * of translation tables. ++ * ++ * The granularity value passed to this macro must be a valid block or page ++ * size. When using a 4KB translation granule, this might be 4KB, 2MB or 1GB. ++ * Passing REGION_DEFAULT_GRANULARITY is also allowed and means that the library ++ * is free to choose the granularity for this region. In this case, it is ++ * equivalent to the MAP_REGION() macro. ++ */ ++#define MAP_REGION2(_pa, _va, _sz, _attr, _gr) \ ++ MAP_REGION_FULL_SPEC(_pa, _va, _sz, _attr, _gr) ++ ++/* ++ * Shifts and masks to access fields of an mmap attribute ++ */ ++#define MT_TYPE_MASK U(0x7) ++#define MT_TYPE(_attr) ((_attr) & MT_TYPE_MASK) ++/* Access permissions (RO/RW) */ ++#define MT_PERM_SHIFT U(3) ++/* Security state (SECURE/NS) */ ++#define MT_SEC_SHIFT U(4) ++/* Access permissions for instruction execution (EXECUTE/EXECUTE_NEVER) */ ++#define MT_EXECUTE_SHIFT U(5) ++/* In the EL1&0 translation regime, User (EL0) or Privileged (EL1). */ ++#define MT_USER_SHIFT U(6) ++/* All other bits are reserved */ ++ ++/* ++ * Memory mapping attributes ++ */ ++ ++/* ++ * Memory types supported. ++ * These are organised so that, going down the list, the memory types are ++ * getting weaker; conversely going up the list the memory types are getting ++ * stronger. ++ */ ++#define MT_DEVICE U(0) ++#define MT_NON_CACHEABLE U(1) ++#define MT_MEMORY U(2) ++/* Values up to 7 are reserved to add new memory types in the future */ ++ ++#define MT_RO (U(0) << MT_PERM_SHIFT) ++#define MT_RW (U(1) << MT_PERM_SHIFT) ++ ++#define MT_SECURE (U(0) << MT_SEC_SHIFT) ++#define MT_NS (U(1) << MT_SEC_SHIFT) ++ ++/* ++ * Access permissions for instruction execution are only relevant for normal ++ * read-only memory, i.e. MT_MEMORY | MT_RO. They are ignored (and potentially ++ * overridden) otherwise: ++ * - Device memory is always marked as execute-never. ++ * - Read-write normal memory is always marked as execute-never. ++ */ ++#define MT_EXECUTE (U(0) << MT_EXECUTE_SHIFT) ++#define MT_EXECUTE_NEVER (U(1) << MT_EXECUTE_SHIFT) ++ ++/* ++ * When mapping a region at EL0 or EL1, this attribute will be used to determine ++ * if a User mapping (EL0) will be created or a Privileged mapping (EL1). ++ */ ++#define MT_USER (U(1) << MT_USER_SHIFT) ++#define MT_PRIVILEGED (U(0) << MT_USER_SHIFT) ++ ++/* Compound attributes for most common usages */ ++#define MT_CODE (MT_MEMORY | MT_RO | MT_EXECUTE) ++#define MT_RO_DATA (MT_MEMORY | MT_RO | MT_EXECUTE_NEVER) ++#define MT_RW_DATA (MT_MEMORY | MT_RW | MT_EXECUTE_NEVER) ++ ++/* ++ * Structure for specifying a single region of memory. ++ */ ++typedef struct mmap_region { ++ unsigned long long base_pa; ++ uintptr_t base_va; ++ size_t size; ++ unsigned int attr; ++ /* Desired granularity. See the MAP_REGION2() macro for more details. */ ++ size_t granularity; ++} mmap_region_t; ++ ++/* ++ * Translation regimes supported by this library. EL_REGIME_INVALID tells the ++ * library to detect it at runtime. ++ */ ++#define EL1_EL0_REGIME 1 ++#define EL2_REGIME 2 ++#define EL3_REGIME 3 ++#define EL_REGIME_INVALID -1 ++ ++/* ++ * Declare the translation context type. ++ * Its definition is private. ++ */ ++typedef struct xlat_ctx xlat_ctx_t; ++ ++/* ++ * Statically allocate a translation context and associated structures. Also ++ * initialize them. ++ * ++ * _ctx_name: ++ * Prefix for the translation context variable. ++ * E.g. If _ctx_name is 'foo', the variable will be called 'foo_xlat_ctx'. ++ * Useful to distinguish multiple contexts from one another. ++ * ++ * _mmap_count: ++ * Number of mmap_region_t to allocate. ++ * Would typically be MAX_MMAP_REGIONS for the translation context describing ++ * the software image currently executing. ++ * ++ * _xlat_tables_count: ++ * Number of sub-translation tables to allocate. ++ * Would typically be MAX_XLAT_TABLES for the translation context describing ++ * the software image currently executing. ++ * Note that this is only for sub-tables ; at the initial lookup level, there ++ * is always a single table. ++ * ++ * _virt_addr_space_size, _phy_addr_space_size: ++ * Size (in bytes) of the virtual (resp. physical) address space. ++ * Would typically be PLAT_VIRT_ADDR_SPACE_SIZE ++ * (resp. PLAT_PHY_ADDR_SPACE_SIZE) for the translation context describing the ++ * software image currently executing. ++ */ ++#define REGISTER_XLAT_CONTEXT(_ctx_name, _mmap_count, _xlat_tables_count, \ ++ _virt_addr_space_size, _phy_addr_space_size) \ ++ REGISTER_XLAT_CONTEXT_FULL_SPEC(_ctx_name, (_mmap_count), \ ++ (_xlat_tables_count), \ ++ (_virt_addr_space_size), \ ++ (_phy_addr_space_size), \ ++ EL_REGIME_INVALID, "xlat_table") ++ ++/* ++ * Same as REGISTER_XLAT_CONTEXT plus the additional parameters: ++ * ++ * _xlat_regime: ++ * Specify the translation regime managed by this xlat_ctx_t instance. The ++ * values are the one from the EL*_REGIME definitions. ++ * ++ * _section_name: ++ * Specify the name of the section where the translation tables have to be ++ * placed by the linker. ++ */ ++#define REGISTER_XLAT_CONTEXT2(_ctx_name, _mmap_count, _xlat_tables_count, \ ++ _virt_addr_space_size, _phy_addr_space_size, \ ++ _xlat_regime, _section_name) \ ++ REGISTER_XLAT_CONTEXT_FULL_SPEC(_ctx_name, (_mmap_count), \ ++ (_xlat_tables_count), \ ++ (_virt_addr_space_size), \ ++ (_phy_addr_space_size), \ ++ (_xlat_regime), (_section_name)) ++ ++/****************************************************************************** ++ * Generic translation table APIs. ++ * Each API comes in 2 variants: ++ * - one that acts on the current translation context for this software image ++ * - another that acts on the given translation context instead. This variant ++ * is named after the 1st version, with an additional '_ctx' suffix. ++ *****************************************************************************/ ++ ++/* ++ * Initialize translation tables from the current list of mmap regions. Calling ++ * this function marks the transition point after which static regions can no ++ * longer be added. ++ */ ++void init_xlat_tables(void); ++void init_xlat_tables_ctx(xlat_ctx_t *ctx); ++ ++/* ++ * Fill all fields of a dynamic translation tables context. It must be done ++ * either statically with REGISTER_XLAT_CONTEXT() or at runtime with this ++ * function. ++ */ ++void xlat_setup_dynamic_ctx(xlat_ctx_t *ctx, unsigned long long pa_max, ++ uintptr_t va_max, struct mmap_region *mmap, ++ unsigned int mmap_num, uint64_t **tables, ++ unsigned int tables_num, uint64_t *base_table, ++ int xlat_regime, int *mapped_regions); ++ ++/* ++ * Add a static region with defined base PA and base VA. This function can only ++ * be used before initializing the translation tables. The region cannot be ++ * removed afterwards. ++ */ ++void mmap_add_region(unsigned long long base_pa, uintptr_t base_va, ++ size_t size, unsigned int attr); ++void mmap_add_region_ctx(xlat_ctx_t *ctx, const mmap_region_t *mm); ++ ++/* ++ * Add an array of static regions with defined base PA and base VA. This ++ * function can only be used before initializing the translation tables. The ++ * regions cannot be removed afterwards. ++ */ ++void mmap_add(const mmap_region_t *mm); ++void mmap_add_ctx(xlat_ctx_t *ctx, const mmap_region_t *mm); ++ ++/* ++ * Add a region with defined base PA. Returns base VA calculated using the ++ * highest existing region in the mmap array even if it fails to allocate the ++ * region. ++ */ ++void mmap_add_region_alloc_va(unsigned long long base_pa, uintptr_t *base_va, ++ size_t size, unsigned int attr); ++void mmap_add_region_alloc_va_ctx(xlat_ctx_t *ctx, mmap_region_t *mm); ++ ++/* ++ * Add an array of static regions with defined base PA, and fill the base VA ++ * field on the array of structs. This function can only be used before ++ * initializing the translation tables. The regions cannot be removed afterwards. ++ */ ++void mmap_add_alloc_va(mmap_region_t *mm); ++ ++#if PLAT_XLAT_TABLES_DYNAMIC ++/* ++ * Add a dynamic region with defined base PA and base VA. This type of region ++ * can be added and removed even after the translation tables are initialized. ++ * ++ * Returns: ++ * 0: Success. ++ * EINVAL: Invalid values were used as arguments. ++ * ERANGE: Memory limits were surpassed. ++ * ENOMEM: Not enough space in the mmap array or not enough free xlat tables. ++ * EPERM: It overlaps another region in an invalid way. ++ */ ++int mmap_add_dynamic_region(unsigned long long base_pa, uintptr_t base_va, ++ size_t size, unsigned int attr); ++int mmap_add_dynamic_region_ctx(xlat_ctx_t *ctx, mmap_region_t *mm); ++ ++/* ++ * Add a dynamic region with defined base PA. Returns base VA calculated using ++ * the highest existing region in the mmap array even if it fails to allocate ++ * the region. ++ * ++ * mmap_add_dynamic_region_alloc_va() returns the allocated VA in 'base_va'. ++ * mmap_add_dynamic_region_alloc_va_ctx() returns it in 'mm->base_va'. ++ * ++ * It returns the same error values as mmap_add_dynamic_region(). ++ */ ++int mmap_add_dynamic_region_alloc_va(unsigned long long base_pa, ++ uintptr_t *base_va, ++ size_t size, unsigned int attr); ++int mmap_add_dynamic_region_alloc_va_ctx(xlat_ctx_t *ctx, mmap_region_t *mm); ++ ++/* ++ * Remove a region with the specified base VA and size. Only dynamic regions can ++ * be removed, and they can be removed even if the translation tables are ++ * initialized. ++ * ++ * Returns: ++ * 0: Success. ++ * EINVAL: The specified region wasn't found. ++ * EPERM: Trying to remove a static region. ++ */ ++int mmap_remove_dynamic_region(uintptr_t base_va, size_t size); ++int mmap_remove_dynamic_region_ctx(xlat_ctx_t *ctx, ++ uintptr_t base_va, ++ size_t size); ++ ++#endif /* PLAT_XLAT_TABLES_DYNAMIC */ ++ ++/* ++ * Change the memory attributes of the memory region starting from a given ++ * virtual address in a set of translation tables. ++ * ++ * This function can only be used after the translation tables have been ++ * initialized. ++ * ++ * The base address of the memory region must be aligned on a page boundary. ++ * The size of this memory region must be a multiple of a page size. ++ * The memory region must be already mapped by the given translation tables ++ * and it must be mapped at the granularity of a page. ++ * ++ * Return 0 on success, a negative value on error. ++ * ++ * In case of error, the memory attributes remain unchanged and this function ++ * has no effect. ++ * ++ * ctx ++ * Translation context to work on. ++ * base_va: ++ * Virtual address of the 1st page to change the attributes of. ++ * size: ++ * Size in bytes of the memory region. ++ * attr: ++ * New attributes of the page tables. The attributes that can be changed are ++ * data access (MT_RO/MT_RW), instruction access (MT_EXECUTE_NEVER/MT_EXECUTE) ++ * and user/privileged access (MT_USER/MT_PRIVILEGED) in the case of contexts ++ * that are used in the EL1&0 translation regime. Also, note that this ++ * function doesn't allow to remap a region as RW and executable, or to remap ++ * device memory as executable. ++ * ++ * NOTE: The caller of this function must be able to write to the translation ++ * tables, i.e. the memory where they are stored must be mapped with read-write ++ * access permissions. This function assumes it is the case. If this is not ++ * the case then this function might trigger a data abort exception. ++ * ++ * NOTE2: The caller is responsible for making sure that the targeted ++ * translation tables are not modified by any other code while this function is ++ * executing. ++ */ ++int xlat_change_mem_attributes_ctx(const xlat_ctx_t *ctx, uintptr_t base_va, ++ size_t size, uint32_t attr); ++int xlat_change_mem_attributes(uintptr_t base_va, size_t size, uint32_t attr); ++ ++/* ++ * Query the memory attributes of a memory page in a set of translation tables. ++ * ++ * Return 0 on success, a negative error code on error. ++ * On success, the attributes are stored into *attr. ++ * ++ * ctx ++ * Translation context to work on. ++ * base_va ++ * Virtual address of the page to get the attributes of. ++ * There are no alignment restrictions on this address. The attributes of the ++ * memory page it lies within are returned. ++ * attr ++ * Output parameter where to store the attributes of the targeted memory page. ++ */ ++int xlat_get_mem_attributes_ctx(const xlat_ctx_t *ctx, uintptr_t base_va, ++ uint32_t *attr); ++int xlat_get_mem_attributes(uintptr_t base_va, uint32_t *attr); ++ ++#endif /*__ASSEMBLY__*/ ++#endif /* XLAT_TABLES_V2_H */ +diff --git a/environments/shim/include/lib/xlat_tables/xlat_tables_v2_helpers.h b/environments/shim/include/lib/xlat_tables/xlat_tables_v2_helpers.h +new file mode 100644 +index 0000000..aa2bd66 +--- /dev/null ++++ b/environments/shim/include/lib/xlat_tables/xlat_tables_v2_helpers.h +@@ -0,0 +1,163 @@ ++/* ++ * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++/* ++ * This header file contains internal definitions that are not supposed to be ++ * used outside of this library code. ++ */ ++ ++#ifndef XLAT_TABLES_V2_HELPERS_H ++#define XLAT_TABLES_V2_HELPERS_H ++ ++#ifndef XLAT_TABLES_V2_H ++#error "Do not include this header file directly. Include xlat_tables_v2.h instead." ++#endif ++ ++#ifndef __ASSEMBLY__ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/* Forward declaration */ ++struct mmap_region; ++ ++/* ++ * Helper macro to define an mmap_region_t. This macro allows to specify all ++ * the fields of the structure but its parameter list is not guaranteed to ++ * remain stable as we add members to mmap_region_t. ++ */ ++#define MAP_REGION_FULL_SPEC(_pa, _va, _sz, _attr, _gr) \ ++ { \ ++ .base_pa = (_pa), \ ++ .base_va = (_va), \ ++ .size = (_sz), \ ++ .attr = (_attr), \ ++ .granularity = (_gr), \ ++ } ++ ++/* Struct that holds all information about the translation tables. */ ++struct xlat_ctx { ++ /* ++ * Max allowed Virtual and Physical Addresses. ++ */ ++ unsigned long long pa_max_address; ++ uintptr_t va_max_address; ++ ++ /* ++ * Array of all memory regions stored in order of ascending end address ++ * and ascending size to simplify the code that allows overlapping ++ * regions. The list is terminated by the first entry with size == 0. ++ * The max size of the list is stored in `mmap_num`. `mmap` points to an ++ * array of mmap_num + 1 elements, so that there is space for the final ++ * null entry. ++ */ ++ struct mmap_region *mmap; ++ int mmap_num; ++ ++ /* ++ * Array of finer-grain translation tables. ++ * For example, if the initial lookup level is 1 then this array would ++ * contain both level-2 and level-3 entries. ++ */ ++ uint64_t (*tables)[XLAT_TABLE_ENTRIES]; ++ int tables_num; ++ /* ++ * Keep track of how many regions are mapped in each table. The base ++ * table can't be unmapped so it isn't needed to keep track of it. ++ */ ++#if PLAT_XLAT_TABLES_DYNAMIC ++ int *tables_mapped_regions; ++#endif /* PLAT_XLAT_TABLES_DYNAMIC */ ++ ++ int next_table; ++ ++ /* ++ * Base translation table. It doesn't need to have the same amount of ++ * entries as the ones used for other levels. ++ */ ++ uint64_t *base_table; ++ unsigned int base_table_entries; ++ ++ /* ++ * Max Physical and Virtual addresses currently in use by the ++ * translation tables. These might get updated as we map/unmap memory ++ * regions but they will never go beyond pa/va_max_address. ++ */ ++ unsigned long long max_pa; ++ uintptr_t max_va; ++ ++ /* Level of the base translation table. */ ++ unsigned int base_level; ++ ++ /* Set to true when the translation tables are initialized. */ ++ bool initialized; ++ ++ /* ++ * Translation regime managed by this xlat_ctx_t. It should be one of ++ * the EL*_REGIME defines. ++ */ ++ int xlat_regime; ++}; ++ ++#if PLAT_XLAT_TABLES_DYNAMIC ++#define XLAT_ALLOC_DYNMAP_STRUCT(_ctx_name, _xlat_tables_count) \ ++ static int _ctx_name##_mapped_regions[_xlat_tables_count]; ++ ++#define XLAT_REGISTER_DYNMAP_STRUCT(_ctx_name) \ ++ .tables_mapped_regions = _ctx_name##_mapped_regions, ++#else ++#define XLAT_ALLOC_DYNMAP_STRUCT(_ctx_name, _xlat_tables_count) \ ++ /* do nothing */ ++ ++#define XLAT_REGISTER_DYNMAP_STRUCT(_ctx_name) \ ++ /* do nothing */ ++#endif /* PLAT_XLAT_TABLES_DYNAMIC */ ++ ++#define REGISTER_XLAT_CONTEXT_FULL_SPEC(_ctx_name, _mmap_count, \ ++ _xlat_tables_count, _virt_addr_space_size, \ ++ _phy_addr_space_size, _xlat_regime, _section_name)\ ++ CASSERT(CHECK_PHY_ADDR_SPACE_SIZE(_phy_addr_space_size), \ ++ assert_invalid_physical_addr_space_sizefor_##_ctx_name);\ ++ \ ++ static mmap_region_t _ctx_name##_mmap[_mmap_count + 1]; \ ++ \ ++ static uint64_t _ctx_name##_xlat_tables[_xlat_tables_count] \ ++ [XLAT_TABLE_ENTRIES] \ ++ __aligned(XLAT_TABLE_SIZE) __section(_section_name); \ ++ \ ++ static uint64_t _ctx_name##_base_xlat_table \ ++ [GET_NUM_BASE_LEVEL_ENTRIES(_virt_addr_space_size)] \ ++ __aligned(GET_NUM_BASE_LEVEL_ENTRIES(_virt_addr_space_size)\ ++ * sizeof(uint64_t)); \ ++ \ ++ XLAT_ALLOC_DYNMAP_STRUCT(_ctx_name, _xlat_tables_count) \ ++ \ ++ static xlat_ctx_t _ctx_name##_xlat_ctx = { \ ++ .va_max_address = (_virt_addr_space_size) - 1UL, \ ++ .pa_max_address = (_phy_addr_space_size) - 1ULL, \ ++ .mmap = _ctx_name##_mmap, \ ++ .mmap_num = (_mmap_count), \ ++ .base_level = GET_XLAT_TABLE_LEVEL_BASE(_virt_addr_space_size),\ ++ .base_table = _ctx_name##_base_xlat_table, \ ++ .base_table_entries = \ ++ GET_NUM_BASE_LEVEL_ENTRIES(_virt_addr_space_size),\ ++ .tables = _ctx_name##_xlat_tables, \ ++ .tables_num = _xlat_tables_count, \ ++ XLAT_REGISTER_DYNMAP_STRUCT(_ctx_name) \ ++ .xlat_regime = (_xlat_regime), \ ++ .max_pa = 0U, \ ++ .max_va = 0U, \ ++ .next_table = 0, \ ++ .initialized = false, \ ++ } ++ ++#endif /*__ASSEMBLY__*/ ++ ++#endif /* XLAT_TABLES_V2_HELPERS_H */ +diff --git a/environments/shim/include/platform_def.h b/environments/shim/include/platform_def.h +new file mode 100644 +index 0000000..a1f09d6 +--- /dev/null ++++ b/environments/shim/include/platform_def.h +@@ -0,0 +1,150 @@ ++/* ++ * Copyright (c) 2020-2021, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++#include ++ ++#ifndef PLATFORM_DEF_H ++#define PLATFORM_DEF_H ++ ++/* Platform binary types for linking */ ++#define PLATFORM_LINKER_FORMAT "elf64-littleaarch64" ++#define PLATFORM_LINKER_ARCH aarch64 ++ ++#ifdef SECURE_STORAGE ++#define SP_IMAGE_BASE 0xFEE01000 ++#define SP_IMAGE_SIZE 0x200000 ++#endif ++ ++#ifdef CRYPTO ++#define SP_IMAGE_BASE 0xFEC01000 ++#define SP_IMAGE_SIZE 0x200000 ++#endif ++ ++#define TC0_CLUSTER_COUNT 1 ++#define TC0_MAX_CPUS_PER_CLUSTER 4 ++#define TC0_MAX_PE_PER_CPU 1 ++ ++/******************************************************************************* ++ * Run-time address of the TFTF image. ++ * It has to match the location where the Trusted Firmware-A loads the BL33 ++ * image. ++ ******************************************************************************/ ++#define TFTF_BASE 0xE0000000 ++ ++#define TC0_DRAM1_BASE 0x80000000 ++#define TC0_DRAM1_SIZE 0x80000000 ++#define DRAM_BASE TC0_DRAM1_BASE ++ ++/* ++ * TF-A reserves DRAM space 0xFD000000 - 0xFEFFFFFF for Trusted DRAM ++ * TF-A reserves DRAM space 0xFF000000 - 0xFFFFFFFF for TZC ++ */ ++#define ARM_TZC_DRAM1_SIZE 0x01000000 ++#define ARM_TRUSTED_DRAM1_SIZE 0x02000000 ++ ++#define DRAM_SIZE (TC0_DRAM1_SIZE - \ ++ ARM_TRUSTED_DRAM1_SIZE - \ ++ ARM_TZC_DRAM1_SIZE) ++ ++/* REFCLK CNTControl, Generic Timer. Secure Access only. */ ++#define SYS_CNT_CONTROL_BASE 0x2a430000 ++/* REFCLK CNTRead, Generic Timer. */ ++#define SYS_CNT_READ_BASE 0x2a800000 ++/* AP_REFCLK CNTBase1, Generic Timer. */ ++#define SYS_CNT_BASE1 0x2A830000 ++ ++/* Base address of non-trusted watchdog (SP805) */ ++#define SP805_WDOG_BASE 0x1C0F0000 ++ ++/* Base address and size of external NVM flash */ ++#define FLASH_BASE 0x08000000 ++ ++#define NOR_FLASH_BLOCK_SIZE 0x40000 /* 256KB */ ++#define FLASH_SIZE 0x4000000 /* 64MB */ ++ ++/* ++ * If you want to use DRAM for non-volatile memory then the first 128MB ++ * can be used. However for tests that involve power resets this is not ++ * suitable since the state will be lost. ++ */ ++#define TFTF_NVM_OFFSET 0x0 ++#define TFTF_NVM_SIZE 0x8000000 /* 128 MB */ ++ ++/* Sub-system Peripherals */ ++#define TC0_DEVICE0_BASE 0x21000000 ++#define TC0_DEVICE0_SIZE 0x5f000000 ++ ++/* Following covers Peripherals and PCIe expansion area */ ++#define TC0_DEVICE1_BASE 0x60000000 ++#define TC0_DEVICE1_SIZE 0x20000000 ++ ++/* GIC-600 & interrupt handling related constants */ ++#define TC0_GICD_BASE 0x30000000 ++#define TC0_GICR_BASE 0x30140000 ++#define TC0_GICC_BASE 0x2C000000 ++ ++/* SoC's PL011 UART0 related constants */ ++#define PL011_UART0_BASE 0x7FF70000 ++#define PL011_UART0_CLK_IN_HZ 7372800 ++ ++/* SoC's PL011 UART1 related constants */ ++#define PL011_UART1_BASE 0x7FF80000 ++#define PL011_UART1_CLK_IN_HZ 7372800 ++ ++#define PLAT_ARM_UART_BASE PL011_UART0_BASE ++#define PLAT_ARM_UART_CLK_IN_HZ PL011_UART0_CLK_IN_HZ ++ ++/* Size of cacheable stacks */ ++#define PLATFORM_STACK_SIZE 0x1400 ++ ++/* Size of coherent stacks */ ++#define PCPU_DV_MEM_STACK_SIZE 0x600 ++ ++#define PLATFORM_CORE_COUNT (TC0_CLUSTER_COUNT * TC0_MAX_CPUS_PER_CLUSTER) ++#define PLATFORM_NUM_AFFS (TC0_CLUSTER_COUNT + PLATFORM_CORE_COUNT) ++#define PLATFORM_MAX_AFFLVL MPIDR_AFFLVL1 ++ ++#define PLAT_MAX_PWR_LEVEL PLATFORM_MAX_AFFLVL ++#define PLAT_MAX_PWR_STATES_PER_LVL 2 ++ ++/* I/O Storage NOR flash device */ ++#define MAX_IO_DEVICES 1 ++#define MAX_IO_HANDLES 1 ++ ++/* Local state bit width for each level in the state-ID field of power state */ ++#define PLAT_LOCAL_PSTATE_WIDTH 4 ++ ++/* Platform specific page table and MMU setup constants */ ++#define PLAT_PHY_ADDR_SPACE_SIZE (1ull << 36) ++#define PLAT_VIRT_ADDR_SPACE_SIZE (1ull << 36) ++#define MAX_XLAT_TABLES 5 ++#define MAX_MMAP_REGIONS 16 ++ ++/******************************************************************************* ++ * Used to align variables on the biggest cache line size in the platform. ++ * This is known only to the platform as it might have a combination of ++ * integrated and external caches. ++ ******************************************************************************/ ++#define CACHE_WRITEBACK_SHIFT 6 ++#define CACHE_WRITEBACK_GRANULE (1 << CACHE_WRITEBACK_SHIFT) ++ ++/* Non-Secure Software Generated Interupts IDs */ ++#define IRQ_NS_SGI_0 0 ++#define IRQ_NS_SGI_7 7 ++ ++/* AP UART1 interrupt is considered as the maximum SPI */ ++#define PLAT_MAX_SPI_OFFSET_ID 64 ++ ++/* AP_REFCLK Generic Timer, Non-secure. */ ++#define IRQ_CNTPSIRQ1 92 ++ ++/* Per-CPU Hypervisor Timer Interrupt ID */ ++#define IRQ_PCPU_HP_TIMER 26 ++ ++/* Times(in ms) used by test code for completion of different events */ ++#define PLAT_SUSPEND_ENTRY_TIME 15 ++#define PLAT_SUSPEND_ENTRY_EXIT_TIME 30 ++ ++#endif /* PLATFORM_DEF_H */ +diff --git a/environments/shim/include/runtime_services/ffa_helpers.h b/environments/shim/include/runtime_services/ffa_helpers.h +new file mode 100644 +index 0000000..c68a014 +--- /dev/null ++++ b/environments/shim/include/runtime_services/ffa_helpers.h +@@ -0,0 +1,399 @@ ++/* ++ * Copyright (c) 2018-2020, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef FFA_HELPERS_H ++#define FFA_HELPERS_H ++ ++#include ++#include ++#include ++ ++/* This error code must be different to the ones used by FFA */ ++#define FFA_TFTF_ERROR -42 ++ ++/* Hypervisor ID at physical FFA instance */ ++#define HYP_ID (0) ++ ++/* By convention, SP IDs (as opposed to VM IDs) have bit 15 set */ ++#define SP_ID(x) ((x) | (1 << 15)) ++ ++typedef unsigned short ffa_vm_id_t; ++typedef unsigned short ffa_vm_count_t; ++typedef unsigned short ffa_vcpu_count_t; ++typedef uint32_t ffa_int_id_t; ++typedef uint64_t ffa_memory_handle_t; ++/** Flags to indicate properties of receivers during memory region retrieval. */ ++typedef uint8_t ffa_memory_receiver_flags_t; ++ ++#ifndef __ASSEMBLY__ ++ ++#include ++ ++struct mailbox_buffers { ++ const void *recv; ++ void *send; ++}; ++ ++struct ffa_partition_info { ++ /** The ID of the VM the information is about */ ++ ffa_vm_id_t id; ++ /** The number of execution contexts implemented by the partition */ ++ uint16_t exec_context; ++ /** The Partition's properties, e.g. supported messaging methods */ ++ uint32_t properties; ++}; ++ ++enum ffa_data_access { ++ FFA_DATA_ACCESS_NOT_SPECIFIED, ++ FFA_DATA_ACCESS_RO, ++ FFA_DATA_ACCESS_RW, ++ FFA_DATA_ACCESS_RESERVED, ++}; ++ ++enum ffa_instruction_access { ++ FFA_INSTRUCTION_ACCESS_NOT_SPECIFIED, ++ FFA_INSTRUCTION_ACCESS_NX, ++ FFA_INSTRUCTION_ACCESS_X, ++ FFA_INSTRUCTION_ACCESS_RESERVED, ++}; ++ ++enum ffa_memory_type { ++ FFA_MEMORY_NOT_SPECIFIED_MEM, ++ FFA_MEMORY_DEVICE_MEM, ++ FFA_MEMORY_NORMAL_MEM, ++}; ++ ++enum ffa_memory_cacheability { ++ FFA_MEMORY_CACHE_RESERVED = 0x0, ++ FFA_MEMORY_CACHE_NON_CACHEABLE = 0x1, ++ FFA_MEMORY_CACHE_RESERVED_1 = 0x2, ++ FFA_MEMORY_CACHE_WRITE_BACK = 0x3, ++ FFA_MEMORY_DEV_NGNRNE = 0x0, ++ FFA_MEMORY_DEV_NGNRE = 0x1, ++ FFA_MEMORY_DEV_NGRE = 0x2, ++ FFA_MEMORY_DEV_GRE = 0x3, ++}; ++ ++enum ffa_memory_shareability { ++ FFA_MEMORY_SHARE_NON_SHAREABLE, ++ FFA_MEMORY_SHARE_RESERVED, ++ FFA_MEMORY_OUTER_SHAREABLE, ++ FFA_MEMORY_INNER_SHAREABLE, ++}; ++ ++typedef uint8_t ffa_memory_access_permissions_t; ++ ++/** ++ * This corresponds to table "Memory region attributes descriptor" of the FF-A ++ * 1.0 specification. ++ */ ++typedef uint8_t ffa_memory_attributes_t; ++ ++#define FFA_DATA_ACCESS_OFFSET (0x0U) ++#define FFA_DATA_ACCESS_MASK ((0x3U) << FFA_DATA_ACCESS_OFFSET) ++ ++#define FFA_INSTRUCTION_ACCESS_OFFSET (0x2U) ++#define FFA_INSTRUCTION_ACCESS_MASK ((0x3U) << FFA_INSTRUCTION_ACCESS_OFFSET) ++ ++#define FFA_MEMORY_TYPE_OFFSET (0x4U) ++#define FFA_MEMORY_TYPE_MASK ((0x3U) << FFA_MEMORY_TYPE_OFFSET) ++ ++#define FFA_MEMORY_CACHEABILITY_OFFSET (0x2U) ++#define FFA_MEMORY_CACHEABILITY_MASK ((0x3U) << FFA_MEMORY_CACHEABILITY_OFFSET) ++ ++#define FFA_MEMORY_SHAREABILITY_OFFSET (0x0U) ++#define FFA_MEMORY_SHAREABILITY_MASK ((0x3U) << FFA_MEMORY_SHAREABILITY_OFFSET) ++ ++#define ATTR_FUNCTION_SET(name, container_type, offset, mask) \ ++ static inline void ffa_set_##name##_attr(container_type *attr, \ ++ const enum ffa_##name perm) \ ++ { \ ++ *attr = (*attr & ~(mask)) | ((perm << offset) & mask); \ ++ } ++ ++#define ATTR_FUNCTION_GET(name, container_type, offset, mask) \ ++ static inline enum ffa_##name ffa_get_##name##_attr( \ ++ container_type attr) \ ++ { \ ++ return (enum ffa_##name)((attr & mask) >> offset); \ ++ } ++ ++ATTR_FUNCTION_SET(data_access, ffa_memory_access_permissions_t, ++ FFA_DATA_ACCESS_OFFSET, FFA_DATA_ACCESS_MASK) ++ATTR_FUNCTION_GET(data_access, ffa_memory_access_permissions_t, ++ FFA_DATA_ACCESS_OFFSET, FFA_DATA_ACCESS_MASK) ++ ++ATTR_FUNCTION_SET(instruction_access, ffa_memory_access_permissions_t, ++ FFA_INSTRUCTION_ACCESS_OFFSET, FFA_INSTRUCTION_ACCESS_MASK) ++ATTR_FUNCTION_GET(instruction_access, ffa_memory_access_permissions_t, ++ FFA_INSTRUCTION_ACCESS_OFFSET, FFA_INSTRUCTION_ACCESS_MASK) ++ ++ATTR_FUNCTION_SET(memory_type, ffa_memory_attributes_t, FFA_MEMORY_TYPE_OFFSET, ++ FFA_MEMORY_TYPE_MASK) ++ATTR_FUNCTION_GET(memory_type, ffa_memory_attributes_t, FFA_MEMORY_TYPE_OFFSET, ++ FFA_MEMORY_TYPE_MASK) ++ ++ATTR_FUNCTION_SET(memory_cacheability, ffa_memory_attributes_t, ++ FFA_MEMORY_CACHEABILITY_OFFSET, FFA_MEMORY_CACHEABILITY_MASK) ++ATTR_FUNCTION_GET(memory_cacheability, ffa_memory_attributes_t, ++ FFA_MEMORY_CACHEABILITY_OFFSET, FFA_MEMORY_CACHEABILITY_MASK) ++ ++ATTR_FUNCTION_SET(memory_shareability, ffa_memory_attributes_t, ++ FFA_MEMORY_SHAREABILITY_OFFSET, FFA_MEMORY_SHAREABILITY_MASK) ++ATTR_FUNCTION_GET(memory_shareability, ffa_memory_attributes_t, ++ FFA_MEMORY_SHAREABILITY_OFFSET, FFA_MEMORY_SHAREABILITY_MASK) ++ ++#define FFA_MEMORY_HANDLE_ALLOCATOR_MASK \ ++ ((ffa_memory_handle_t)(UINT64_C(1) << 63)) ++#define FFA_MEMORY_HANDLE_ALLOCATOR_HYPERVISOR \ ++ ((ffa_memory_handle_t)(UINT64_C(1) << 63)) ++#define FFA_MEMORY_HANDLE_INVALID (~UINT64_C(0)) ++ ++/** ++ * A set of contiguous pages which is part of a memory region. This corresponds ++ * to table "Constituent memory region descriptor" of the FFA 1.0 specification. ++ */ ++struct ffa_memory_region_constituent { ++ /** ++ * The base IPA of the constituent memory region, aligned to 4 kiB page ++ * size granularity. ++ */ ++ void *address; ++ /** The number of 4 kiB pages in the constituent memory region. */ ++ uint32_t page_count; ++ /** Reserved field, must be 0. */ ++ uint32_t reserved; ++}; ++ ++/** ++ * A set of pages comprising a memory region. This corresponds to table ++ * "Composite memory region descriptor" of the FFA 1.0 specification. ++ */ ++struct ffa_composite_memory_region { ++ /** ++ * The total number of 4 kiB pages included in this memory region. This ++ * must be equal to the sum of page counts specified in each ++ * `ffa_memory_region_constituent`. ++ */ ++ uint32_t page_count; ++ /** ++ * The number of constituents (`ffa_memory_region_constituent`) ++ * included in this memory region range. ++ */ ++ uint32_t constituent_count; ++ /** Reserved field, must be 0. */ ++ uint64_t reserved_0; ++ /** An array of `constituent_count` memory region constituents. */ ++ struct ffa_memory_region_constituent constituents[]; ++}; ++ ++/** ++ * This corresponds to table "Memory access permissions descriptor" of the FFA ++ * 1.0 specification. ++ */ ++struct ffa_memory_region_attributes { ++ /** The ID of the VM to which the memory is being given or shared. */ ++ ffa_vm_id_t receiver; ++ /** ++ * The permissions with which the memory region should be mapped in the ++ * receiver's page table. ++ */ ++ ffa_memory_access_permissions_t permissions; ++ /** ++ * Flags used during FFA_MEM_RETRIEVE_REQ and FFA_MEM_RETRIEVE_RESP ++ * for memory regions with multiple borrowers. ++ */ ++ ffa_memory_receiver_flags_t flags; ++}; ++ ++/** Flags to control the behaviour of a memory sharing transaction. */ ++typedef uint32_t ffa_memory_region_flags_t; ++ ++/** ++ * Clear memory region contents after unmapping it from the sender and before ++ * mapping it for any receiver. ++ */ ++#define FFA_MEMORY_REGION_FLAG_CLEAR 0x1U ++ ++/** ++ * Whether the hypervisor may time slice the memory sharing or retrieval ++ * operation. ++ */ ++#define FFA_MEMORY_REGION_FLAG_TIME_SLICE 0x2U ++ ++/** ++ * Whether the hypervisor should clear the memory region after the receiver ++ * relinquishes it or is aborted. ++ */ ++#define FFA_MEMORY_REGION_FLAG_CLEAR_RELINQUISH 0x4U ++ ++#define FFA_MEMORY_REGION_TRANSACTION_TYPE_MASK ((0x3U) << 3) ++#define FFA_MEMORY_REGION_TRANSACTION_TYPE_UNSPECIFIED ((0x0U) << 3) ++#define FFA_MEMORY_REGION_TRANSACTION_TYPE_SHARE ((0x1U) << 3) ++#define FFA_MEMORY_REGION_TRANSACTION_TYPE_LEND ((0x2U) << 3) ++#define FFA_MEMORY_REGION_TRANSACTION_TYPE_DONATE ((0x3U) << 3) ++ ++/** The maximum number of recipients a memory region may be sent to. */ ++#define MAX_MEM_SHARE_RECIPIENTS 1U ++ ++/** ++ * This corresponds to table "Endpoint memory access descriptor" of the FFA 1.0 ++ * specification. ++ */ ++struct ffa_memory_access { ++ struct ffa_memory_region_attributes receiver_permissions; ++ /** ++ * Offset in bytes from the start of the outer `ffa_memory_region` to ++ * an `ffa_composite_memory_region` struct. ++ */ ++ uint32_t composite_memory_region_offset; ++ uint64_t reserved_0; ++}; ++ ++/** ++ * Information about a set of pages which are being shared. This corresponds to ++ * table "Lend, donate or share memory transaction descriptor" of the FFA ++ * 1.0 specification. Note that it is also used for retrieve requests and ++ * responses. ++ */ ++struct ffa_memory_region { ++ /** ++ * The ID of the VM which originally sent the memory region, i.e. the ++ * owner. ++ */ ++ ffa_vm_id_t sender; ++ ffa_memory_attributes_t attributes; ++ /** Reserved field, must be 0. */ ++ uint8_t reserved_0; ++ /** Flags to control behaviour of the transaction. */ ++ ffa_memory_region_flags_t flags; ++ ffa_memory_handle_t handle; ++ /** ++ * An implementation defined value associated with the receiver and the ++ * memory region. ++ */ ++ uint64_t tag; ++ /** Reserved field, must be 0. */ ++ uint32_t reserved_1; ++ /** ++ * The number of `ffa_memory_access` entries included in this ++ * transaction. ++ */ ++ uint32_t receiver_count; ++ /** ++ * An array of `attribute_count` endpoint memory access descriptors. ++ * Each one specifies a memory region offset, an endpoint and the ++ * attributes with which this memory region should be mapped in that ++ * endpoint's page table. ++ */ ++ struct ffa_memory_access receivers[]; ++}; ++ ++/** ++ * Descriptor used for FFA_MEM_RELINQUISH requests. This corresponds to table ++ * "Descriptor to relinquish a memory region" of the FFA 1.0 specification. ++ */ ++struct ffa_mem_relinquish { ++ ffa_memory_handle_t handle; ++ ffa_memory_region_flags_t flags; ++ uint32_t endpoint_count; ++ ffa_vm_id_t endpoints[]; ++}; ++ ++static inline ffa_memory_handle_t ffa_assemble_handle(uint32_t h1, uint32_t h2) ++{ ++ return (uint64_t)h1 | (uint64_t)h2 << 32; ++} ++ ++static inline ffa_memory_handle_t ffa_mem_success_handle(smc_ret_values r) ++{ ++ return ffa_assemble_handle(r.ret2, r.ret3); ++} ++ ++/** ++ * Gets the `ffa_composite_memory_region` for the given receiver from an ++ * `ffa_memory_region`, or NULL if it is not valid. ++ */ ++static inline struct ffa_composite_memory_region * ++ffa_memory_region_get_composite(struct ffa_memory_region *memory_region, ++ uint32_t receiver_index) ++{ ++ uint32_t offset = memory_region->receivers[receiver_index] ++ .composite_memory_region_offset; ++ ++ if (offset == 0) { ++ return NULL; ++ } ++ ++ return (struct ffa_composite_memory_region *)((uint8_t *)memory_region + ++ offset); ++} ++ ++static inline uint32_t ffa_mem_relinquish_init( ++ struct ffa_mem_relinquish *relinquish_request, ++ ffa_memory_handle_t handle, ffa_memory_region_flags_t flags, ++ ffa_vm_id_t sender) ++{ ++ relinquish_request->handle = handle; ++ relinquish_request->flags = flags; ++ relinquish_request->endpoint_count = 1; ++ relinquish_request->endpoints[0] = sender; ++ return sizeof(struct ffa_mem_relinquish) + sizeof(ffa_vm_id_t); ++} ++ ++uint32_t ffa_memory_retrieve_request_init( ++ struct ffa_memory_region *memory_region, ffa_memory_handle_t handle, ++ ffa_vm_id_t sender, ffa_vm_id_t receiver, uint32_t tag, ++ ffa_memory_region_flags_t flags, enum ffa_data_access data_access, ++ enum ffa_instruction_access instruction_access, ++ enum ffa_memory_type type, enum ffa_memory_cacheability cacheability, ++ enum ffa_memory_shareability shareability); ++ ++uint32_t ffa_memory_region_init( ++ struct ffa_memory_region *memory_region, size_t memory_region_max_size, ++ ffa_vm_id_t sender, ffa_vm_id_t receiver, ++ const struct ffa_memory_region_constituent constituents[], ++ uint32_t constituent_count, uint32_t tag, ++ ffa_memory_region_flags_t flags, enum ffa_data_access data_access, ++ enum ffa_instruction_access instruction_access, ++ enum ffa_memory_type type, enum ffa_memory_cacheability cacheability, ++ enum ffa_memory_shareability shareability, uint32_t *total_length, ++ uint32_t *fragment_length); ++ ++bool check_spmc_execution_level(void); ++smc_ret_values ffa_msg_send_direct_req(uint32_t source_id, uint32_t dest_id, uint32_t message); ++smc_ret_values ffa_msg_send_direct_req64(uint32_t source_id, uint32_t dest_id, uint64_t message); ++smc_ret_values ffa_msg_send_direct_req64_5args(uint32_t source_id, uint32_t dest_id, ++ uint64_t arg0, uint64_t arg1, ++ uint64_t arg2, uint64_t arg3, ++ uint64_t arg4); ++ ++smc_ret_values ffa_run(uint32_t dest_id, uint32_t vcpu_id); ++smc_ret_values ffa_version(uint32_t input_version); ++smc_ret_values ffa_id_get(void); ++smc_ret_values ffa_msg_wait(void); ++smc_ret_values ffa_msg_send_direct_resp(ffa_vm_id_t source_id, ++ ffa_vm_id_t dest_id, uint32_t message); ++smc_ret_values ffa_error(int32_t error_code); ++smc_ret_values ffa_features(uint32_t feature); ++smc_ret_values ffa_partition_info_get(const uint32_t uuid[4]); ++smc_ret_values ffa_rx_release(void); ++smc_ret_values ffa_rxtx_map(uintptr_t send, uintptr_t recv, uint32_t pages); ++ ++smc_ret_values ffa_mem_donate(uint32_t descriptor_length, ++ uint32_t fragment_length); ++smc_ret_values ffa_mem_lend(uint32_t descriptor_length, ++ uint32_t fragment_length); ++smc_ret_values ffa_mem_share(uint32_t descriptor_length, ++ uint32_t fragment_length); ++smc_ret_values ffa_mem_retrieve_req(uint32_t descriptor_length, ++ uint32_t fragment_length); ++smc_ret_values ffa_mem_relinquish(void); ++smc_ret_values ffa_mem_reclaim(uint64_t handle, uint32_t flags); ++ ++#endif /* __ASSEMBLY__ */ ++ ++#endif /* FFA_HELPERS_H */ +diff --git a/environments/shim/include/runtime_services/ffa_svc.h b/environments/shim/include/runtime_services/ffa_svc.h +new file mode 100644 +index 0000000..f08e803 +--- /dev/null ++++ b/environments/shim/include/runtime_services/ffa_svc.h +@@ -0,0 +1,140 @@ ++/* ++ * Copyright (c) 2018-2020, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef FFA_SVC_H ++#define FFA_SVC_H ++ ++#include ++#include ++#include ++ ++/* FFA error codes. */ ++#define FFA_ERROR_NOT_SUPPORTED -1 ++#define FFA_ERROR_INVALID_PARAMETER -2 ++#define FFA_ERROR_NO_MEMORY -3 ++#define FFA_ERROR_BUSY -4 ++#define FFA_ERROR_INTERRUPTED -5 ++#define FFA_ERROR_DENIED -6 ++#define FFA_ERROR_RETRY -7 ++ ++/* The macros below are used to identify FFA calls from the SMC function ID */ ++#define FFA_FNUM_MIN_VALUE U(0x60) ++#define FFA_FNUM_MAX_VALUE U(0x7f) ++#define is_ffa_fid(fid) __extension__ ({ \ ++ __typeof__(fid) _fid = (fid); \ ++ ((GET_SMC_NUM(_fid) >= FFA_FNUM_MIN_VALUE) && \ ++ (GET_SMC_NUM(_fid) <= FFA_FNUM_MAX_VALUE)); }) ++ ++/* FFA_VERSION helpers */ ++#define FFA_VERSION_MAJOR U(1) ++#define FFA_VERSION_MAJOR_SHIFT 16 ++#define FFA_VERSION_MAJOR_MASK U(0x7FFF) ++#define FFA_VERSION_MINOR U(0) ++#define FFA_VERSION_MINOR_SHIFT 0 ++#define FFA_VERSION_MINOR_MASK U(0xFFFF) ++#define FFA_VERSION_BIT31_MASK U(1 << 31) ++ ++#define MAKE_FFA_VERSION(major, minor) \ ++ ((((major) & FFA_VERSION_MAJOR_MASK) << FFA_VERSION_MAJOR_SHIFT) | \ ++ (((minor) & FFA_VERSION_MINOR_MASK) << FFA_VERSION_MINOR_SHIFT)) ++#define FFA_VERSION_COMPILED MAKE_FFA_VERSION(FFA_VERSION_MAJOR, \ ++ FFA_VERSION_MINOR) ++ ++/* FFA_MSG_SEND helpers */ ++#define FFA_MSG_SEND_ATTRS_BLK_SHIFT U(0) ++#define FFA_MSG_SEND_ATTRS_BLK_MASK U(0x1) ++#define FFA_MSG_SEND_ATTRS_BLK U(0) ++#define FFA_MSG_SEND_ATTRS_BLK_NOT U(1) ++#define FFA_MSG_SEND_ATTRS(blk) \ ++ (((blk) & FFA_MSG_SEND_ATTRS_BLK_MASK) \ ++ << FFA_MSG_SEND_ATTRS_BLK_SHIFT) ++ ++/* Get FFA fastcall std FID from function number */ ++#define FFA_FID(smc_cc, func_num) \ ++ ((SMC_TYPE_FAST << FUNCID_TYPE_SHIFT) | \ ++ ((smc_cc) << FUNCID_CC_SHIFT) | \ ++ (OEN_STD_START << FUNCID_OEN_SHIFT) | \ ++ ((func_num) << FUNCID_NUM_SHIFT)) ++ ++/* FFA function numbers */ ++#define FFA_FNUM_ERROR U(0x60) ++#define FFA_FNUM_SUCCESS U(0x61) ++#define FFA_FNUM_INTERRUPT U(0x62) ++#define FFA_FNUM_VERSION U(0x63) ++#define FFA_FNUM_FEATURES U(0x64) ++#define FFA_FNUM_RX_RELEASE U(0x65) ++#define FFA_FNUM_RXTX_MAP U(0x66) ++#define FFA_FNUM_RXTX_UNMAP U(0x67) ++#define FFA_FNUM_PARTITION_INFO_GET U(0x68) ++#define FFA_FNUM_ID_GET U(0x69) ++#define FFA_FNUM_MSG_POLL U(0x6A) ++#define FFA_FNUM_MSG_WAIT U(0x6B) ++#define FFA_FNUM_MSG_YIELD U(0x6C) ++#define FFA_FNUM_MSG_RUN U(0x6D) ++#define FFA_FNUM_MSG_SEND U(0x6E) ++#define FFA_FNUM_MSG_SEND_DIRECT_REQ U(0x6F) ++#define FFA_FNUM_MSG_SEND_DIRECT_RESP U(0x70) ++#define FFA_FNUM_MEM_DONATE U(0x71) ++#define FFA_FNUM_MEM_LEND U(0x72) ++#define FFA_FNUM_MEM_SHARE U(0x73) ++#define FFA_FNUM_MEM_RETRIEVE_REQ U(0x74) ++#define FFA_FNUM_MEM_RETRIEVE_RESP U(0x75) ++#define FFA_FNUM_MEM_RELINQUISH U(0x76) ++#define FFA_FNUM_MEM_RECLAIM U(0x77) ++ ++/* FFA SMC32 FIDs */ ++#define FFA_ERROR FFA_FID(SMC_32, FFA_FNUM_ERROR) ++#define FFA_SUCCESS_SMC32 FFA_FID(SMC_32, FFA_FNUM_SUCCESS) ++#define FFA_INTERRUPT FFA_FID(SMC_32, FFA_FNUM_INTERRUPT) ++#define FFA_VERSION FFA_FID(SMC_32, FFA_FNUM_VERSION) ++#define FFA_FEATURES FFA_FID(SMC_32, FFA_FNUM_FEATURES) ++#define FFA_RX_RELEASE FFA_FID(SMC_32, FFA_FNUM_RX_RELEASE) ++#define FFA_RXTX_MAP_SMC32 FFA_FID(SMC_32, FFA_FNUM_RXTX_MAP) ++#define FFA_RXTX_UNMAP FFA_FID(SMC_32, FFA_FNUM_RXTX_UNMAP) ++#define FFA_PARTITION_INFO_GET FFA_FID(SMC_32, FFA_FNUM_PARTITION_INFO_GET) ++#define FFA_ID_GET FFA_FID(SMC_32, FFA_FNUM_ID_GET) ++#define FFA_MSG_POLL FFA_FID(SMC_32, FFA_FNUM_MSG_POLL) ++#define FFA_MSG_WAIT FFA_FID(SMC_32, FFA_FNUM_MSG_WAIT) ++#define FFA_MSG_YIELD FFA_FID(SMC_32, FFA_FNUM_MSG_YIELD) ++#define FFA_MSG_RUN FFA_FID(SMC_32, FFA_FNUM_MSG_RUN) ++#define FFA_MSG_SEND FFA_FID(SMC_32, FFA_FNUM_MSG_SEND) ++#define FFA_MSG_SEND_DIRECT_REQ_SMC32 \ ++ FFA_FID(SMC_32, FFA_FNUM_MSG_SEND_DIRECT_REQ) ++#define FFA_MSG_SEND_DIRECT_RESP_SMC32 \ ++ FFA_FID(SMC_32, FFA_FNUM_MSG_SEND_DIRECT_RESP) ++#define FFA_MEM_DONATE_SMC32 FFA_FID(SMC_32, FFA_FNUM_MEM_DONATE) ++#define FFA_MEM_LEND_SMC32 FFA_FID(SMC_32, FFA_FNUM_MEM_LEND) ++#define FFA_MEM_SHARE_SMC32 FFA_FID(SMC_32, FFA_FNUM_MEM_SHARE) ++#define FFA_MEM_RETRIEVE_REQ_SMC32 \ ++ FFA_FID(SMC_32, FFA_FNUM_MEM_RETRIEVE_REQ) ++#define FFA_MEM_RETRIEVE_RESP FFA_FID(SMC_32, FFA_FNUM_MEM_RETRIEVE_RESP) ++#define FFA_MEM_RELINQUISH FFA_FID(SMC_32, FFA_FNUM_MEM_RELINQUISH) ++#define FFA_MEM_RECLAIM FFA_FID(SMC_32, FFA_FNUM_MEM_RECLAIM) ++ ++/* FFA SMC64 FIDs */ ++#define FFA_SUCCESS_SMC64 FFA_FID(SMC_64, FFA_FNUM_SUCCESS) ++#define FFA_RXTX_MAP_SMC64 FFA_FID(SMC_64, FFA_FNUM_RXTX_MAP) ++#define FFA_MSG_SEND_DIRECT_REQ_SMC64 \ ++ FFA_FID(SMC_64, FFA_FNUM_MSG_SEND_DIRECT_REQ) ++#define FFA_MSG_SEND_DIRECT_RESP_SMC64 \ ++ FFA_FID(SMC_64, FFA_FNUM_MSG_SEND_DIRECT_RESP) ++#define FFA_MEM_DONATE_SMC64 FFA_FID(SMC_64, FFA_FNUM_MEM_DONATE) ++#define FFA_MEM_LEND_SMC64 FFA_FID(SMC_64, FFA_FNUM_MEM_LEND) ++#define FFA_MEM_SHARE_SMC64 FFA_FID(SMC_64, FFA_FNUM_MEM_SHARE) ++#define FFA_MEM_RETRIEVE_REQ_SMC64 \ ++ FFA_FID(SMC_64, FFA_FNUM_MEM_RETRIEVE_REQ) ++ ++/* ++ * Reserve a special value for traffic targeted to the Hypervisor or SPM. ++ */ ++#define FFA_TARGET_INFO_MBZ U(0x0) ++ ++/* ++ * Reserve a special value for MBZ parameters. ++ */ ++#define FFA_PARAM_MBZ U(0x0) ++ ++#endif /* FFA_SVC_H */ +diff --git a/environments/shim/include/runtime_services/smccc.h b/environments/shim/include/runtime_services/smccc.h +new file mode 100644 +index 0000000..283b463 +--- /dev/null ++++ b/environments/shim/include/runtime_services/smccc.h +@@ -0,0 +1,80 @@ ++/* ++ * Copyright (c) 2018-2020, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef __SMCCC_H__ ++#define __SMCCC_H__ ++ ++#include ++ ++#define SMCCC_VERSION_MAJOR_SHIFT U(16) ++#define SMCCC_VERSION_MAJOR_MASK U(0x7FFF) ++#define SMCCC_VERSION_MINOR_SHIFT U(0) ++#define SMCCC_VERSION_MINOR_MASK U(0xFFFF) ++#define MAKE_SMCCC_VERSION(_major, _minor) \ ++ ((((uint32_t)(_major) & SMCCC_VERSION_MAJOR_MASK) << \ ++ SMCCC_VERSION_MAJOR_SHIFT) \ ++ | (((uint32_t)(_minor) & SMCCC_VERSION_MINOR_MASK) << \ ++ SMCCC_VERSION_MINOR_SHIFT)) ++ ++#define SMC_UNKNOWN -1 ++#define SMC_OK 0 ++ ++/* Return codes for Arm Architecture Service SMC calls */ ++#define SMC_ARCH_CALL_SUCCESS 0 ++#define SMC_ARCH_CALL_NOT_SUPPORTED -1 ++#define SMC_ARCH_CALL_NOT_REQUIRED -2 ++#define SMC_ARCH_CALL_INVAL_PARAM -3 ++ ++/******************************************************************************* ++ * Bit definitions inside the function id as per the SMC calling convention ++ ******************************************************************************/ ++#define FUNCID_TYPE_SHIFT 31 ++#define FUNCID_CC_SHIFT 30 ++#define FUNCID_OEN_SHIFT 24 ++#define FUNCID_NUM_SHIFT 0 ++ ++#define FUNCID_TYPE_MASK 0x1 ++#define FUNCID_CC_MASK 0x1 ++#define FUNCID_OEN_MASK 0x3f ++#define FUNCID_NUM_MASK 0xffff ++ ++#define FUNCID_TYPE_WIDTH 1 ++#define FUNCID_CC_WIDTH 1 ++#define FUNCID_OEN_WIDTH 6 ++#define FUNCID_NUM_WIDTH 16 ++ ++#define SMC_64 1 ++#define SMC_32 0 ++#define SMC_TYPE_FAST 1 ++#define SMC_TYPE_STD 0 ++ ++/******************************************************************************* ++ * Owning entity number definitions inside the function id as per the SMC ++ * calling convention ++ ******************************************************************************/ ++#define OEN_ARM_START 0 ++#define OEN_ARM_END 0 ++#define OEN_CPU_START 1 ++#define OEN_CPU_END 1 ++#define OEN_SIP_START 2 ++#define OEN_SIP_END 2 ++#define OEN_OEM_START 3 ++#define OEN_OEM_END 3 ++#define OEN_STD_START 4 /* Standard Calls */ ++#define OEN_STD_END 4 ++#define OEN_TAP_START 48 /* Trusted Applications */ ++#define OEN_TAP_END 49 ++#define OEN_TOS_START 50 /* Trusted OS */ ++#define OEN_TOS_END 63 ++#define OEN_LIMIT 64 ++ ++/******************************************************************************* ++ * Argument definitions passed to SMC call ++ ******************************************************************************/ ++#define SMC_GET_SOC_VERSION 0 ++#define SMC_GET_SOC_REVISION 1 ++ ++#endif /* __SMCCC_H__ */ +diff --git a/environments/shim/include/shim_sp.h b/environments/shim/include/shim_sp.h +new file mode 100644 +index 0000000..53b8e06 +--- /dev/null ++++ b/environments/shim/include/shim_sp.h +@@ -0,0 +1,47 @@ ++/* ++ * Copyright (c) 2021, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef SP_H ++#define SP_H ++ ++#include ++ ++/* Linker symbols used to figure out the memory layout of the S-EL1 shim. */ ++extern uintptr_t __SHIM_TEXT_START__, __SHIM_TEXT_END__; ++#define SHIM_TEXT_START ((uintptr_t)&__SHIM_TEXT_START__) ++#define SHIM_TEXT_END ((uintptr_t)&__SHIM_TEXT_END__) ++ ++extern uintptr_t __SHIM_RODATA_START__, __SHIM_RODATA_END__; ++#define SHIM_RODATA_START ((uintptr_t)&__SHIM_RODATA_START__) ++#define SHIM_RODATA_END ((uintptr_t)&__SHIM_RODATA_END__) ++ ++extern uintptr_t __SHIM_DATA_START__, __SHIM_DATA_END__; ++#define SHIM_DATA_START ((uintptr_t)&__SHIM_DATA_START__) ++#define SHIM_DATA_END ((uintptr_t)&__SHIM_DATA_END__) ++ ++extern uintptr_t __SHIM_BSS_START__, __SHIM_BSS_END__; ++#define SHIM_BSS_START ((uintptr_t)&__SHIM_BSS_START__) ++#define SHIM_BSS_END ((uintptr_t)&__SHIM_BSS_END__) ++ ++/* Linker symbols used to figure out the memory layout of TS (S-EL0). */ ++extern uintptr_t __TEXT_START__, __TEXT_END__; ++#define SP_TEXT_START ((uintptr_t)&__TEXT_START__) ++#define SP_TEXT_END ((uintptr_t)&__TEXT_END__) ++ ++extern uintptr_t __RODATA_START__, __RODATA_END__; ++#define SP_RODATA_START ((uintptr_t)&__RODATA_START__) ++#define SP_RODATA_END ((uintptr_t)&__RODATA_END__) ++ ++extern uintptr_t __DATA_START__, __DATA_END__; ++#define SP_DATA_START ((uintptr_t)&__DATA_START__) ++#define SP_DATA_END ((uintptr_t)&__DATA_END__) ++ ++extern uintptr_t __BSS_START__, __BSS_END__; ++#define SP_BSS_START ((uintptr_t)&__BSS_START__) ++#define SP_BSS_END ((uintptr_t)&__BSS_END__) ++ ++ ++#endif /* __SP_H__ */ +diff --git a/environments/shim/include/tftf.h b/environments/shim/include/tftf.h +new file mode 100644 +index 0000000..746e137 +--- /dev/null ++++ b/environments/shim/include/tftf.h +@@ -0,0 +1,174 @@ ++/* ++ * Copyright (c) 2018-2021, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef __TFTF_H__ ++#define __TFTF_H__ ++ ++#ifndef __ASSEMBLY__ ++#include ++#include ++#include ++ ++#define TFTF_WELCOME_STR "Booting trusted firmware test framework" ++ ++/* Maximum size of test output (in bytes) */ ++#define TESTCASE_OUTPUT_MAX_SIZE 512 ++ ++/* Size of build message used to differentiate different TFTF binaries */ ++#define BUILD_MESSAGE_SIZE 0x20 ++ ++typedef unsigned int STATUS; ++ ++extern const char build_message[]; ++ ++typedef test_result_t (*test_function_t)(void); ++ ++typedef struct { ++ /* Test result (success, crashed, failed, ...). */ ++ test_result_t result; ++ unsigned long long duration; ++ /* ++ * Offset of test output string from TEST_NVM_RESULT_BUFFER_OFFSET. ++ * Only relevant if test has an output, i.e. if \a output_size is not ++ * zero. ++ */ ++ unsigned output_offset; ++ /* Size of test output string, excluding final \0. */ ++ unsigned output_size; ++} TESTCASE_RESULT; ++ ++typedef struct { ++ unsigned index; ++ const char *name; ++ const char *description; ++ test_function_t test; ++} test_case_t; ++ ++typedef struct { ++ const char *name; ++ const char *description; ++ const test_case_t *testcases; ++} test_suite_t; ++ ++/* ++ * Reference to a specific test. ++ */ ++typedef struct { ++ unsigned int testsuite_idx; ++ unsigned int testcase_idx; ++} test_ref_t; ++ ++/* ++ * The progress in the execution of a test. ++ * This is used to implement the following state machine. ++ * ++ * +-> TEST_READY (initial state of the test) <--------------+ ++ * | | | ++ * | | Test framework prepares the test environment. | ++ * | | | ++ * | v | ++ * | TEST_IN_PROGRESS | ++ * | | | ++ * | | Hand over to the test function. | ++ * | | If the test wants to reboot the platform ---> TEST_REBOOTING | ++ * | | Test function returns into framework. | | ++ * | | | Reboot | ++ * | | | | ++ * | | +---------+ ++ * | v ++ * | TEST_COMPLETE ++ * | | ++ * | | Do some framework management. ++ * | | Move to next test. ++ * +--------+ ++ */ ++typedef enum { ++ TEST_PROGRESS_MIN = 0, ++ TEST_READY = TEST_PROGRESS_MIN, ++ TEST_IN_PROGRESS, ++ TEST_COMPLETE, ++ TEST_REBOOTING, ++ ++ TEST_PROGRESS_MAX, ++} test_progress_t; ++ ++#define TEST_PROGRESS_IS_VALID(_progress) \ ++ ((_progress >= TEST_PROGRESS_MIN) && (_progress < TEST_PROGRESS_MAX)) ++ ++/* ++ * The definition of this global variable is generated by the script ++ * 'tftf_generate_test_list' during the build process ++ */ ++extern const test_suite_t testsuites[]; ++ ++extern TESTCASE_RESULT testcase_results[]; ++ ++/* Set/Get the test to run in NVM */ ++STATUS tftf_set_test_to_run(const test_ref_t test_to_run); ++STATUS tftf_get_test_to_run(test_ref_t *test_to_run); ++/* Set/Get the progress of the current test in NVM */ ++STATUS tftf_set_test_progress(test_progress_t test_progress); ++STATUS tftf_get_test_progress(test_progress_t *test_progress); ++ ++/** ++** Save test result into NVM. ++*/ ++STATUS tftf_testcase_set_result(const test_case_t *testcase, ++ test_result_t result, ++ unsigned long long duration); ++/** ++** Get a testcase result from NVM. ++** ++** @param[in] testcase The targeted testcase. ++** @param[out] result Testcase result. Only \a result.result and ++** \a result.duration are of interest for the caller and the 2 other fields ++** should be ignored (they correspond to a location in NVM). ++** @param[out] test_output Buffer to store the test output, if any. ++** \a test_output must be big enough to hold the whole test output. ++** Test output will be \a TESTCASE_OUTPUT_MAX_SIZE bytes maximum. ++*/ ++STATUS tftf_testcase_get_result(const test_case_t *testcase, TESTCASE_RESULT *result, char *test_output); ++ ++void print_testsuite_start(const test_suite_t *testsuite); ++void print_test_start(const test_case_t *test); ++void print_test_end(const test_case_t *test); ++void print_tests_summary(void); ++ ++/* ++ * Exit the TFTF. ++ * This function can be used when a fatal error is encountered or as part of the ++ * normal termination process. It does the necessary cleanups then put the ++ * core in a low-power state. ++ */ ++void __dead2 tftf_exit(void); ++ ++void tftf_arch_setup(void); ++ ++/* ++ * This function detects the power state format used by PSCI which can ++ * be either extended or original format. For the Original format, ++ * the State-ID can either be NULL or can be using the recommended encoding. ++ * This function needs to be invoked once during cold boot prior to the ++ * invocation of any PSCI power state helper functions. ++ */ ++void tftf_detect_psci_pstate_format(void); ++ ++/* ++ * Run the next test on the calling CPU. ++ * Once the test is complete, if the calling CPU is the last one to exit the ++ * test then do the necessary bookkeeping, report the overall test result and ++ * move on to the next test. Otherwise, shut down the calling CPU. ++ * ++ * This function never returns. ++ */ ++void __dead2 run_tests(void); ++ ++/* Entry point for a CPU that has just been powered up */ ++void tftf_hotplug_entry(void); ++ ++#endif /*__ASSEMBLY__*/ ++ ++#endif +diff --git a/environments/shim/lib/aarch64/cache_helpers.S b/environments/shim/lib/aarch64/cache_helpers.S +new file mode 100644 +index 0000000..9e67dad +--- /dev/null ++++ b/environments/shim/lib/aarch64/cache_helpers.S +@@ -0,0 +1,210 @@ ++/* ++ * Copyright (c) 2013-2021, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#define __ASSEMBLY__ ++#include ++#include ++ ++ .globl flush_dcache_range ++ .globl clean_dcache_range ++ .globl inv_dcache_range ++ .globl dcsw_op_louis ++ .globl dcsw_op_all ++ .globl dcsw_op_level1 ++ .globl dcsw_op_level2 ++ .globl dcsw_op_level3 ++ ++/* ++ * This macro can be used for implementing various data cache operations `op` ++ */ ++.macro do_dcache_maintenance_by_mva op ++ /* Exit early if size is zero */ ++ cbz x1, exit_loop_\op ++ dcache_line_size x2, x3 ++ add x1, x0, x1 ++ sub x3, x2, #1 ++ bic x0, x0, x3 ++loop_\op: ++ dc \op, x0 ++ add x0, x0, x2 ++ cmp x0, x1 ++ b.lo loop_\op ++ dsb sy ++exit_loop_\op: ++ ret ++.endm ++ /* ------------------------------------------ ++ * Clean+Invalidate from base address till ++ * size. 'x0' = addr, 'x1' = size ++ * ------------------------------------------ ++ */ ++func flush_dcache_range ++ do_dcache_maintenance_by_mva civac ++endfunc flush_dcache_range ++ ++ /* ------------------------------------------ ++ * Clean from base address till size. ++ * 'x0' = addr, 'x1' = size ++ * ------------------------------------------ ++ */ ++func clean_dcache_range ++ do_dcache_maintenance_by_mva cvac ++endfunc clean_dcache_range ++ ++ /* ------------------------------------------ ++ * Invalidate from base address till ++ * size. 'x0' = addr, 'x1' = size ++ * ------------------------------------------ ++ */ ++func inv_dcache_range ++ do_dcache_maintenance_by_mva ivac ++endfunc inv_dcache_range ++ ++ ++ /* --------------------------------------------------------------- ++ * Data cache operations by set/way to the level specified ++ * ++ * The main function, do_dcsw_op requires: ++ * x0: The operation type (0-2), as defined in arch.h ++ * x3: The last cache level to operate on ++ * x9: clidr_el1 ++ * x10: The cache level to begin operation from ++ * and will carry out the operation on each data cache from level 0 ++ * to the level in x3 in sequence ++ * ++ * The dcsw_op macro sets up the x3 and x9 parameters based on ++ * clidr_el1 cache information before invoking the main function ++ * --------------------------------------------------------------- ++ */ ++ ++ .macro dcsw_op shift, fw, ls ++ mrs x9, clidr_el1 ++ ubfx x3, x9, \shift, \fw ++ lsl x3, x3, \ls ++ mov x10, xzr ++ b do_dcsw_op ++ .endm ++ ++func do_dcsw_op ++ cbz x3, exit ++ adr x14, dcsw_loop_table // compute inner loop address ++ add x14, x14, x0, lsl #5 // inner loop is 8x32-bit instructions ++#if ENABLE_BTI ++ add x14, x14, x0, lsl #2 // inner loop is + "bti j" instruction ++#endif ++ mov x0, x9 ++ mov w8, #1 ++loop1: ++ add x2, x10, x10, lsr #1 // work out 3x current cache level ++ lsr x1, x0, x2 // extract cache type bits from clidr ++ and x1, x1, #7 // mask the bits for current cache only ++ cmp x1, #2 // see what cache we have at this level ++ b.lo level_done // nothing to do if no cache or icache ++ ++ msr csselr_el1, x10 // select current cache level in csselr ++ isb // isb to sych the new cssr&csidr ++ mrs x1, ccsidr_el1 // read the new ccsidr ++ and x2, x1, #7 // extract the length of the cache lines ++ add x2, x2, #4 // add 4 (line length offset) ++ ubfx x4, x1, #3, #10 // maximum way number ++ clz w5, w4 // bit position of way size increment ++ lsl w9, w4, w5 // w9 = aligned max way number ++ lsl w16, w8, w5 // w16 = way number loop decrement ++ orr w9, w10, w9 // w9 = combine way and cache number ++ ubfx w6, w1, #13, #15 // w6 = max set number ++ lsl w17, w8, w2 // w17 = set number loop decrement ++ dsb sy // barrier before we start this level ++ br x14 // jump to DC operation specific loop ++ ++ .macro dcsw_loop _op ++#if ENABLE_BTI ++ bti j ++#endif ++loop2_\_op: ++ lsl w7, w6, w2 // w7 = aligned max set number ++ ++loop3_\_op: ++ orr w11, w9, w7 // combine cache, way and set number ++ dc \_op, x11 ++ subs w7, w7, w17 // decrement set number ++ b.hs loop3_\_op ++ ++ subs x9, x9, x16 // decrement way number ++ b.hs loop2_\_op ++ ++ b level_done ++ .endm ++ ++level_done: ++ add x10, x10, #2 // increment cache number ++ cmp x3, x10 ++ b.hi loop1 ++ msr csselr_el1, xzr // select cache level 0 in csselr ++ dsb sy // barrier to complete final cache operation ++ isb ++exit: ++ ret ++endfunc do_dcsw_op ++ ++dcsw_loop_table: ++ dcsw_loop isw ++ dcsw_loop cisw ++ dcsw_loop csw ++ ++ ++func dcsw_op_louis ++ dcsw_op #LOUIS_SHIFT, #CLIDR_FIELD_WIDTH, #LEVEL_SHIFT ++endfunc dcsw_op_louis ++ ++ ++func dcsw_op_all ++ dcsw_op #LOC_SHIFT, #CLIDR_FIELD_WIDTH, #LEVEL_SHIFT ++endfunc dcsw_op_all ++ ++ /* --------------------------------------------------------------- ++ * Helper macro for data cache operations by set/way for the ++ * level specified ++ * --------------------------------------------------------------- ++ */ ++ .macro dcsw_op_level level ++ mrs x9, clidr_el1 ++ mov x3, \level ++ sub x10, x3, #2 ++ b do_dcsw_op ++ .endm ++ ++ /* --------------------------------------------------------------- ++ * Data cache operations by set/way for level 1 cache ++ * ++ * The main function, do_dcsw_op requires: ++ * x0: The operation type (0-2), as defined in arch.h ++ * --------------------------------------------------------------- ++ */ ++func dcsw_op_level1 ++ dcsw_op_level #(1 << LEVEL_SHIFT) ++endfunc dcsw_op_level1 ++ ++ /* --------------------------------------------------------------- ++ * Data cache operations by set/way for level 2 cache ++ * ++ * The main function, do_dcsw_op requires: ++ * x0: The operation type (0-2), as defined in arch.h ++ * --------------------------------------------------------------- ++ */ ++func dcsw_op_level2 ++ dcsw_op_level #(2 << LEVEL_SHIFT) ++endfunc dcsw_op_level2 ++ ++ /* --------------------------------------------------------------- ++ * Data cache operations by set/way for level 3 cache ++ * ++ * The main function, do_dcsw_op requires: ++ * x0: The operation type (0-2), as defined in arch.h ++ * --------------------------------------------------------------- ++ */ ++func dcsw_op_level3 ++ dcsw_op_level #(3 << LEVEL_SHIFT) ++endfunc dcsw_op_level3 +diff --git a/environments/shim/lib/aarch64/misc_helpers.S b/environments/shim/lib/aarch64/misc_helpers.S +new file mode 100644 +index 0000000..16d6899 +--- /dev/null ++++ b/environments/shim/lib/aarch64/misc_helpers.S +@@ -0,0 +1,226 @@ ++/* ++ * Copyright (c) 2018-2021, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#define __ASSEMBLY__ ++#include ++#include ++#include ++#include ++ ++ .globl smc ++ ++ .globl zeromem16 ++ .globl memcpy16 ++ ++ .globl disable_mmu ++ .globl disable_mmu_icache ++ ++func smc ++ smc #0 ++endfunc smc ++ ++/* ----------------------------------------------------------------------- ++ * void zeromem16(void *mem, unsigned int length); ++ * ++ * Initialise a memory region to 0. ++ * The memory address must be 16-byte aligned. ++ * ----------------------------------------------------------------------- ++ */ ++func zeromem16 ++#if ENABLE_ASSERTIONS ++ tst x0, #0xf ++ ASM_ASSERT(eq) ++#endif ++ add x2, x0, x1 ++/* zero 16 bytes at a time */ ++z_loop16: ++ sub x3, x2, x0 ++ cmp x3, #16 ++ b.lt z_loop1 ++ stp xzr, xzr, [x0], #16 ++ b z_loop16 ++/* zero byte per byte */ ++z_loop1: ++ cmp x0, x2 ++ b.eq z_end ++ strb wzr, [x0], #1 ++ b z_loop1 ++z_end: ++ ret ++endfunc zeromem16 ++ ++ ++/* -------------------------------------------------------------------------- ++ * void memcpy16(void *dest, const void *src, unsigned int length) ++ * ++ * Copy length bytes from memory area src to memory area dest. ++ * The memory areas should not overlap. ++ * Destination and source addresses must be 16-byte aligned. ++ * -------------------------------------------------------------------------- ++ */ ++func memcpy16 ++#if ENABLE_ASSERTIONS ++ orr x3, x0, x1 ++ tst x3, #0xf ++ ASM_ASSERT(eq) ++#endif ++/* copy 16 bytes at a time */ ++m_loop16: ++ cmp x2, #16 ++ b.lt m_loop1 ++ ldp x3, x4, [x1], #16 ++ stp x3, x4, [x0], #16 ++ sub x2, x2, #16 ++ b m_loop16 ++/* copy byte per byte */ ++m_loop1: ++ cbz x2, m_end ++ ldrb w3, [x1], #1 ++ strb w3, [x0], #1 ++ subs x2, x2, #1 ++ b.ne m_loop1 ++m_end: ++ ret ++endfunc memcpy16 ++ ++/* --------------------------------------------------------------------------- ++ * Disable the MMU at the current exception level (NS-EL1 or EL2) ++ * This is implemented in assembler to ensure that the data cache is cleaned ++ * and invalidated after the MMU is disabled without any intervening cacheable ++ * data accesses ++ * --------------------------------------------------------------------------- ++ */ ++func disable_mmu ++ mov x1, #(SCTLR_M_BIT | SCTLR_C_BIT) ++do_disable_mmu: ++ asm_read_sctlr_el1_or_el2 ++ bic x0, x0, x1 ++ asm_write_sctlr_el1_or_el2 x1 ++ isb /* ensure MMU is off */ ++ mov x0, #DCCISW /* DCache clean and invalidate */ ++ b dcsw_op_all ++endfunc disable_mmu ++ ++func disable_mmu_icache ++ mov x1, #(SCTLR_M_BIT | SCTLR_C_BIT | SCTLR_I_BIT) ++ b do_disable_mmu ++endfunc disable_mmu_icache ++ ++/* Need this label for asm_read/write_sctlr_el1_or_el2 */ ++dead: ++ b dead ++ ++/* --------------------------------------------------------------------------- ++ * Helper to fixup Global Offset table (GOT) and dynamic relocations ++ * (.rela.dyn) at runtime. ++ * ++ * This function is meant to be used when the firmware is compiled with -fpie ++ * and linked with -pie options. We rely on the linker script exporting ++ * appropriate markers for start and end of the section. For GOT, we ++ * expect __GOT_START__ and __GOT_END__. Similarly for .rela.dyn, we expect ++ * __RELA_START__ and __RELA_END__. ++ * ++ * The function takes the limits of the memory to apply fixups to as ++ * arguments (which is usually the limits of the relocable BL image). ++ * x0 - the start of the fixup region ++ * x1 - the limit of the fixup region ++ * These addresses have to be page (4KB aligned). ++ * --------------------------------------------------------------------------- ++ */ ++.globl fixup_gdt_reloc ++func fixup_gdt_reloc ++ mov x6, x0 ++ mov x7, x1 ++ ++ /* Test if the limits are 4K aligned */ ++#if ENABLE_ASSERTIONS ++ orr x0, x0, x1 ++ tst x0, #(PAGE_SIZE - 1) ++ ASM_ASSERT(eq) ++#endif ++ /* ++ * Calculate the offset based on return address in x30. ++ * Assume that this function is called within a page at the start of ++ * fixup region. ++ */ ++ and x2, x30, #~(PAGE_SIZE - 1) ++ sub x0, x2, x6 /* Diff(S) = Current Address - Compiled Address */ ++ ++ adrp x1, __GOT_START__ ++ add x1, x1, :lo12:__GOT_START__ ++ adrp x2, __GOT_END__ ++ add x2, x2, :lo12:__GOT_END__ ++ ++ /* ++ * GOT is an array of 64_bit addresses which must be fixed up as ++ * new_addr = old_addr + Diff(S). ++ * The new_addr is the address currently the binary is executing from ++ * and old_addr is the address at compile time. ++ */ ++1: ++ ldr x3, [x1] ++ /* Skip adding offset if address is < lower limit */ ++ cmp x3, x6 ++ b.lo 2f ++ /* Skip adding offset if address is >= upper limit */ ++ cmp x3, x7 ++ b.ge 2f ++ add x3, x3, x0 ++ str x3, [x1] ++2: ++ add x1, x1, #8 ++ cmp x1, x2 ++ b.lo 1b ++ ++ /* Starting dynamic relocations. Use adrp/adr to get RELA_START and END */ ++ adrp x1, __RELA_START__ ++ add x1, x1, :lo12:__RELA_START__ ++ adrp x2, __RELA_END__ ++ add x2, x2, :lo12:__RELA_END__ ++ /* ++ * According to ELF-64 specification, the RELA data structure is as ++ * follows: ++ * typedef struct ++ * { ++ * Elf64_Addr r_offset; ++ * Elf64_Xword r_info; ++ * Elf64_Sxword r_addend; ++ * } Elf64_Rela; ++ * ++ * r_offset is address of reference ++ * r_info is symbol index and type of relocation (in this case ++ * 0x403 which corresponds to R_AARCH64_RELATIVE). ++ * r_addend is constant part of expression. ++ * ++ * Size of Elf64_Rela structure is 24 bytes. ++ */ ++1: ++ /* Assert that the relocation type is R_AARCH64_RELATIVE */ ++#if ENABLE_ASSERTIONS ++ ldr x3, [x1, #8] ++ cmp x3, #0x403 ++ ASM_ASSERT(eq) ++#endif ++ ldr x3, [x1] /* r_offset */ ++ add x3, x0, x3 ++ ldr x4, [x1, #16] /* r_addend */ ++ ++ /* Skip adding offset if r_addend is < lower limit */ ++ cmp x4, x6 ++ b.lo 2f ++ /* Skip adding offset if r_addend entry is >= upper limit */ ++ cmp x4, x7 ++ b.ge 2f ++ ++ add x4, x0, x4 /* Diff(S) + r_addend */ ++ str x4, [x3] ++ ++2: add x1, x1, #24 ++ cmp x1, x2 ++ b.lo 1b ++ ++ ret ++endfunc fixup_gdt_reloc +diff --git a/environments/shim/lib/libc/assert.c b/environments/shim/lib/libc/assert.c +new file mode 100644 +index 0000000..dbf8507 +--- /dev/null ++++ b/environments/shim/lib/libc/assert.c +@@ -0,0 +1,17 @@ ++/* ++ * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include ++#include ++#include ++ ++#include ++ ++void __assert(const char *file, unsigned int line, const char *assertion) ++{ ++ printf("ASSERT: %s:%d:%s\n", file, line, assertion); ++ panic(); ++} +diff --git a/environments/shim/lib/libc/bget_malloc.c b/environments/shim/lib/libc/bget_malloc.c +new file mode 100644 +index 0000000..62ec4bf +--- /dev/null ++++ b/environments/shim/lib/libc/bget_malloc.c +@@ -0,0 +1,951 @@ ++// SPDX-License-Identifier: BSD-2-Clause ++/* ++ * Copyright (c) 2014, STMicroelectronics International N.V. ++ */ ++ ++#define PROTOTYPES ++ ++/* ++ * BGET CONFIGURATION ++ * ================== ++ */ ++/* #define BGET_ENABLE_ALL_OPTIONS */ ++#ifdef BGET_ENABLE_OPTION ++#define TestProg 20000 /* Generate built-in test program ++ if defined. The value specifies ++ how many buffer allocation attempts ++ the test program should make. */ ++#endif ++ ++ ++#ifdef __LP64__ ++#define SizeQuant 16 ++#endif ++#ifdef __ILP32__ ++#define SizeQuant 8 ++#endif ++ /* Buffer allocation size quantum: ++ all buffers allocated are a ++ multiple of this size. This ++ MUST be a power of two. */ ++ ++#ifdef BGET_ENABLE_OPTION ++#define BufDump 1 /* Define this symbol to enable the ++ bpoold() function which dumps the ++ buffers in a buffer pool. */ ++ ++#define BufValid 1 /* Define this symbol to enable the ++ bpoolv() function for validating ++ a buffer pool. */ ++ ++#define DumpData 1 /* Define this symbol to enable the ++ bufdump() function which allows ++ dumping the contents of an allocated ++ or free buffer. */ ++ ++#define BufStats 1 /* Define this symbol to enable the ++ bstats() function which calculates ++ the total free space in the buffer ++ pool, the largest available ++ buffer, and the total space ++ currently allocated. */ ++ ++#define FreeWipe 1 /* Wipe free buffers to a guaranteed ++ pattern of garbage to trip up ++ miscreants who attempt to use ++ pointers into released buffers. */ ++ ++#define BestFit 1 /* Use a best fit algorithm when ++ searching for space for an ++ allocation request. This uses ++ memory more efficiently, but ++ allocation will be much slower. */ ++ ++#define BECtl 1 /* Define this symbol to enable the ++ bectl() function for automatic ++ pool space control. */ ++#endif ++ ++#ifdef MEM_DEBUG ++#undef NDEBUG ++#define DumpData 1 ++#define BufValid 1 ++#define FreeWipe 1 ++#endif ++ ++#ifdef CFG_WITH_STATS ++#define BufStats 1 ++#endif ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#if defined(__KERNEL__) ++/* Compiling for TEE Core */ ++#include ++#include ++#include ++ ++static void tag_asan_free(void *buf, size_t len) ++{ ++ asan_tag_heap_free(buf, (uint8_t *)buf + len); ++} ++ ++static void tag_asan_alloced(void *buf, size_t len) ++{ ++ asan_tag_access(buf, (uint8_t *)buf + len); ++} ++ ++static void *memset_unchecked(void *s, int c, size_t n) ++{ ++ return asan_memset_unchecked(s, c, n); ++} ++ ++static __maybe_unused void *memcpy_unchecked(void *dst, const void *src, ++ size_t n) ++{ ++ return asan_memcpy_unchecked(dst, src, n); ++} ++ ++#else /*__KERNEL__*/ ++/* Compiling for TA */ ++ ++static void tag_asan_free(void *buf __unused, size_t len __unused) ++{ ++} ++ ++static void tag_asan_alloced(void *buf __unused, size_t len __unused) ++{ ++} ++ ++static void *memset_unchecked(void *s, int c, size_t n) ++{ ++ return memset(s, c, n); ++} ++ ++static __maybe_unused void *memcpy_unchecked(void *dst, const void *src, ++ size_t n) ++{ ++ return memcpy(dst, src, n); ++} ++ ++#endif /*__KERNEL__*/ ++ ++#include "bget.c" /* this is ugly, but this is bget */ ++ ++struct malloc_pool { ++ void *buf; ++ size_t len; ++}; ++ ++struct malloc_ctx { ++ struct bpoolset poolset; ++ struct malloc_pool *pool; ++ size_t pool_len; ++#ifdef BufStats ++ struct malloc_stats mstats; ++#endif ++#ifdef __KERNEL__ ++ unsigned int spinlock; ++#endif ++}; ++ ++#ifdef __KERNEL__ ++ ++static uint32_t malloc_lock(struct malloc_ctx *ctx) ++{ ++ return cpu_spin_lock_xsave(&ctx->spinlock); ++} ++ ++static void malloc_unlock(struct malloc_ctx *ctx, uint32_t exceptions) ++{ ++ cpu_spin_unlock_xrestore(&ctx->spinlock, exceptions); ++} ++ ++#else /* __KERNEL__ */ ++ ++static uint32_t malloc_lock(struct malloc_ctx *ctx __unused) ++{ ++ return 0; ++} ++ ++static void malloc_unlock(struct malloc_ctx *ctx __unused, ++ uint32_t exceptions __unused) ++{ ++} ++ ++#endif /* __KERNEL__ */ ++ ++#define DEFINE_CTX(name) struct malloc_ctx name = \ ++ { .poolset = { .freelist = { {0, 0}, \ ++ {&name.poolset.freelist, \ ++ &name.poolset.freelist}}}} ++ ++static DEFINE_CTX(malloc_ctx); ++ ++#ifdef CFG_VIRTUALIZATION ++static __nex_data DEFINE_CTX(nex_malloc_ctx); ++#endif ++ ++static void print_oom(size_t req_size __maybe_unused, void *ctx __maybe_unused) ++{ ++#if defined(__KERNEL__) && defined(CFG_CORE_DUMP_OOM) ++ EMSG("Memory allocation failed: size %zu context %p", req_size, ctx); ++ EPRINT_STACK(); ++#endif ++} ++ ++#ifdef BufStats ++ ++static void raw_malloc_return_hook(void *p, size_t requested_size, ++ struct malloc_ctx *ctx) ++{ ++ if (ctx->poolset.totalloc > ctx->mstats.max_allocated) ++ ctx->mstats.max_allocated = ctx->poolset.totalloc; ++ ++ if (!p) { ++ ctx->mstats.num_alloc_fail++; ++ print_oom(requested_size, ctx); ++ if (requested_size > ctx->mstats.biggest_alloc_fail) { ++ ctx->mstats.biggest_alloc_fail = requested_size; ++ ctx->mstats.biggest_alloc_fail_used = ++ ctx->poolset.totalloc; ++ } ++ } ++} ++ ++static void gen_malloc_reset_stats(struct malloc_ctx *ctx) ++{ ++ uint32_t exceptions = malloc_lock(ctx); ++ ++ ctx->mstats.max_allocated = 0; ++ ctx->mstats.num_alloc_fail = 0; ++ ctx->mstats.biggest_alloc_fail = 0; ++ ctx->mstats.biggest_alloc_fail_used = 0; ++ malloc_unlock(ctx, exceptions); ++} ++ ++void malloc_reset_stats(void) ++{ ++ gen_malloc_reset_stats(&malloc_ctx); ++} ++ ++static void gen_malloc_get_stats(struct malloc_ctx *ctx, ++ struct malloc_stats *stats) ++{ ++ uint32_t exceptions = malloc_lock(ctx); ++ ++ memcpy_unchecked(stats, &ctx->mstats, sizeof(*stats)); ++ stats->allocated = ctx->poolset.totalloc; ++ malloc_unlock(ctx, exceptions); ++} ++ ++void malloc_get_stats(struct malloc_stats *stats) ++{ ++ gen_malloc_get_stats(&malloc_ctx, stats); ++} ++ ++#else /* BufStats */ ++ ++static void raw_malloc_return_hook(void *p, size_t requested_size, ++ struct malloc_ctx *ctx ) ++{ ++ if (!p) ++ print_oom(requested_size, ctx); ++} ++ ++#endif /* BufStats */ ++ ++#ifdef BufValid ++static void raw_malloc_validate_pools(struct malloc_ctx *ctx) ++{ ++ size_t n; ++ ++ for (n = 0; n < ctx->pool_len; n++) ++ bpoolv(ctx->pool[n].buf); ++} ++#else ++static void raw_malloc_validate_pools(struct malloc_ctx *ctx __unused) ++{ ++} ++#endif ++ ++struct bpool_iterator { ++ struct bfhead *next_buf; ++ size_t pool_idx; ++}; ++ ++static void bpool_foreach_iterator_init(struct malloc_ctx *ctx, ++ struct bpool_iterator *iterator) ++{ ++ iterator->pool_idx = 0; ++ iterator->next_buf = BFH(ctx->pool[0].buf); ++} ++ ++static bool bpool_foreach_pool(struct bpool_iterator *iterator, void **buf, ++ size_t *len, bool *isfree) ++{ ++ struct bfhead *b = iterator->next_buf; ++ bufsize bs = b->bh.bsize; ++ ++ if (bs == ESent) ++ return false; ++ ++ if (bs < 0) { ++ /* Allocated buffer */ ++ bs = -bs; ++ ++ *isfree = false; ++ } else { ++ /* Free Buffer */ ++ *isfree = true; ++ ++ /* Assert that the free list links are intact */ ++ assert(b->ql.blink->ql.flink == b); ++ assert(b->ql.flink->ql.blink == b); ++ } ++ ++ *buf = (uint8_t *)b + sizeof(struct bhead); ++ *len = bs - sizeof(struct bhead); ++ ++ iterator->next_buf = BFH((uint8_t *)b + bs); ++ return true; ++} ++ ++static bool bpool_foreach(struct malloc_ctx *ctx, ++ struct bpool_iterator *iterator, void **buf) ++{ ++ while (true) { ++ size_t len; ++ bool isfree; ++ ++ if (bpool_foreach_pool(iterator, buf, &len, &isfree)) { ++ if (isfree) ++ continue; ++ return true; ++ } ++ ++ if ((iterator->pool_idx + 1) >= ctx->pool_len) ++ return false; ++ ++ iterator->pool_idx++; ++ iterator->next_buf = BFH(ctx->pool[iterator->pool_idx].buf); ++ } ++} ++ ++/* Convenience macro for looping over all allocated buffers */ ++#define BPOOL_FOREACH(ctx, iterator, bp) \ ++ for (bpool_foreach_iterator_init((ctx),(iterator)); \ ++ bpool_foreach((ctx),(iterator), (bp));) ++ ++static void *raw_malloc(size_t hdr_size, size_t ftr_size, size_t pl_size, ++ struct malloc_ctx *ctx) ++{ ++ void *ptr = NULL; ++ bufsize s; ++ ++ /* ++ * Make sure that malloc has correct alignment of returned buffers. ++ * The assumption is that uintptr_t will be as wide as the largest ++ * required alignment of any type. ++ */ ++ COMPILE_TIME_ASSERT(SizeQuant >= sizeof(uintptr_t)); ++ ++ raw_malloc_validate_pools(ctx); ++ ++ /* Compute total size */ ++ if (ADD_OVERFLOW(pl_size, hdr_size, &s)) ++ goto out; ++ if (ADD_OVERFLOW(s, ftr_size, &s)) ++ goto out; ++ ++ /* BGET doesn't like 0 sized allocations */ ++ if (!s) ++ s++; ++ ++ ptr = bget(s, &ctx->poolset); ++out: ++ raw_malloc_return_hook(ptr, pl_size, ctx); ++ ++ return ptr; ++} ++ ++static void raw_free(void *ptr, struct malloc_ctx *ctx, bool wipe) ++{ ++ raw_malloc_validate_pools(ctx); ++ ++ if (ptr) ++ brel(ptr, &ctx->poolset, wipe); ++} ++ ++static void *raw_calloc(size_t hdr_size, size_t ftr_size, size_t pl_nmemb, ++ size_t pl_size, struct malloc_ctx *ctx) ++{ ++ void *ptr = NULL; ++ bufsize s; ++ ++ raw_malloc_validate_pools(ctx); ++ ++ /* Compute total size */ ++ if (MUL_OVERFLOW(pl_nmemb, pl_size, &s)) ++ goto out; ++ if (ADD_OVERFLOW(s, hdr_size, &s)) ++ goto out; ++ if (ADD_OVERFLOW(s, ftr_size, &s)) ++ goto out; ++ ++ /* BGET doesn't like 0 sized allocations */ ++ if (!s) ++ s++; ++ ++ ptr = bgetz(s, &ctx->poolset); ++out: ++ raw_malloc_return_hook(ptr, pl_nmemb * pl_size, ctx); ++ ++ return ptr; ++} ++ ++static void *raw_realloc(void *ptr, size_t hdr_size, size_t ftr_size, ++ size_t pl_size, struct malloc_ctx *ctx) ++{ ++ void *p = NULL; ++ bufsize s; ++ ++ /* Compute total size */ ++ if (ADD_OVERFLOW(pl_size, hdr_size, &s)) ++ goto out; ++ if (ADD_OVERFLOW(s, ftr_size, &s)) ++ goto out; ++ ++ raw_malloc_validate_pools(ctx); ++ ++ /* BGET doesn't like 0 sized allocations */ ++ if (!s) ++ s++; ++ ++ p = bgetr(ptr, s, &ctx->poolset); ++out: ++ raw_malloc_return_hook(p, pl_size, ctx); ++ ++ return p; ++} ++ ++/* Most of the stuff in this function is copied from bgetr() in bget.c */ ++static __maybe_unused bufsize bget_buf_size(void *buf) ++{ ++ bufsize osize; /* Old size of buffer */ ++ struct bhead *b; ++ ++ b = BH(((char *)buf) - sizeof(struct bhead)); ++ osize = -b->bsize; ++#ifdef BECtl ++ if (osize == 0) { ++ /* Buffer acquired directly through acqfcn. */ ++ struct bdhead *bd; ++ ++ bd = BDH(((char *)buf) - sizeof(struct bdhead)); ++ osize = bd->tsize - sizeof(struct bdhead); ++ } else ++#endif ++ osize -= sizeof(struct bhead); ++ assert(osize > 0); ++ return osize; ++} ++ ++#ifdef ENABLE_MDBG ++ ++struct mdbg_hdr { ++ const char *fname; ++ uint16_t line; ++ uint32_t pl_size; ++ uint32_t magic; ++#if defined(ARM64) ++ uint64_t pad; ++#endif ++}; ++ ++#define MDBG_HEADER_MAGIC 0xadadadad ++#define MDBG_FOOTER_MAGIC 0xecececec ++ ++static size_t mdbg_get_ftr_size(size_t pl_size) ++{ ++ size_t ftr_pad = ROUNDUP(pl_size, sizeof(uint32_t)) - pl_size; ++ ++ return ftr_pad + sizeof(uint32_t); ++} ++ ++static uint32_t *mdbg_get_footer(struct mdbg_hdr *hdr) ++{ ++ uint32_t *footer; ++ ++ footer = (uint32_t *)((uint8_t *)(hdr + 1) + hdr->pl_size + ++ mdbg_get_ftr_size(hdr->pl_size)); ++ footer--; ++ return footer; ++} ++ ++static void mdbg_update_hdr(struct mdbg_hdr *hdr, const char *fname, ++ int lineno, size_t pl_size) ++{ ++ uint32_t *footer; ++ ++ hdr->fname = fname; ++ hdr->line = lineno; ++ hdr->pl_size = pl_size; ++ hdr->magic = MDBG_HEADER_MAGIC; ++ ++ footer = mdbg_get_footer(hdr); ++ *footer = MDBG_FOOTER_MAGIC; ++} ++ ++static void *gen_mdbg_malloc(struct malloc_ctx *ctx, const char *fname, ++ int lineno, size_t size) ++{ ++ struct mdbg_hdr *hdr; ++ uint32_t exceptions = malloc_lock(ctx); ++ ++ /* ++ * Check struct mdbg_hdr doesn't get bad alignment. ++ * This is required by C standard: the buffer returned from ++ * malloc() should be aligned with a fundamental alignment. ++ * For ARM32, the required alignment is 8. For ARM64, it is 16. ++ */ ++ COMPILE_TIME_ASSERT( ++ (sizeof(struct mdbg_hdr) % (__alignof(uintptr_t) * 2)) == 0); ++ ++ hdr = raw_malloc(sizeof(struct mdbg_hdr), ++ mdbg_get_ftr_size(size), size, ctx); ++ if (hdr) { ++ mdbg_update_hdr(hdr, fname, lineno, size); ++ hdr++; ++ } ++ ++ malloc_unlock(ctx, exceptions); ++ return hdr; ++} ++ ++static void assert_header(struct mdbg_hdr *hdr __maybe_unused) ++{ ++ assert(hdr->magic == MDBG_HEADER_MAGIC); ++ assert(*mdbg_get_footer(hdr) == MDBG_FOOTER_MAGIC); ++} ++ ++static void gen_mdbg_free(struct malloc_ctx *ctx, void *ptr, bool wipe) ++{ ++ struct mdbg_hdr *hdr = ptr; ++ ++ if (hdr) { ++ hdr--; ++ assert_header(hdr); ++ hdr->magic = 0; ++ *mdbg_get_footer(hdr) = 0; ++ raw_free(hdr, ctx, wipe); ++ } ++} ++ ++static void free_helper(void *ptr, bool wipe) ++{ ++ uint32_t exceptions = malloc_lock(&malloc_ctx); ++ ++ gen_mdbg_free(&malloc_ctx, ptr, wipe); ++ malloc_unlock(&malloc_ctx, exceptions); ++} ++ ++static void *gen_mdbg_calloc(struct malloc_ctx *ctx, const char *fname, int lineno, ++ size_t nmemb, size_t size) ++{ ++ struct mdbg_hdr *hdr; ++ uint32_t exceptions = malloc_lock(ctx); ++ ++ hdr = raw_calloc(sizeof(struct mdbg_hdr), ++ mdbg_get_ftr_size(nmemb * size), nmemb, size, ++ ctx); ++ if (hdr) { ++ mdbg_update_hdr(hdr, fname, lineno, nmemb * size); ++ hdr++; ++ } ++ malloc_unlock(ctx, exceptions); ++ return hdr; ++} ++ ++static void *gen_mdbg_realloc_unlocked(struct malloc_ctx *ctx, const char *fname, ++ int lineno, void *ptr, size_t size) ++{ ++ struct mdbg_hdr *hdr = ptr; ++ ++ if (hdr) { ++ hdr--; ++ assert_header(hdr); ++ } ++ hdr = raw_realloc(hdr, sizeof(struct mdbg_hdr), ++ mdbg_get_ftr_size(size), size, ctx); ++ if (hdr) { ++ mdbg_update_hdr(hdr, fname, lineno, size); ++ hdr++; ++ } ++ return hdr; ++} ++ ++static void *gen_mdbg_realloc(struct malloc_ctx *ctx, const char *fname, ++ int lineno, void *ptr, size_t size) ++{ ++ void *p; ++ uint32_t exceptions = malloc_lock(ctx); ++ ++ p = gen_mdbg_realloc_unlocked(ctx, fname, lineno, ptr, size); ++ malloc_unlock(ctx, exceptions); ++ return p; ++} ++ ++#define realloc_unlocked(ctx, ptr, size) \ ++ gen_mdbg_realloc_unlocked(ctx, __FILE__, __LINE__, (ptr), (size)) ++ ++static void *get_payload_start_size(void *raw_buf, size_t *size) ++{ ++ struct mdbg_hdr *hdr = raw_buf; ++ ++ assert(bget_buf_size(hdr) >= hdr->pl_size); ++ *size = hdr->pl_size; ++ return hdr + 1; ++} ++ ++static void gen_mdbg_check(struct malloc_ctx *ctx, int bufdump) ++{ ++ struct bpool_iterator itr; ++ void *b; ++ uint32_t exceptions = malloc_lock(ctx); ++ ++ raw_malloc_validate_pools(ctx); ++ ++ BPOOL_FOREACH(ctx, &itr, &b) { ++ struct mdbg_hdr *hdr = (struct mdbg_hdr *)b; ++ ++ assert_header(hdr); ++ ++ if (bufdump > 0) { ++ const char *fname = hdr->fname; ++ ++ if (!fname) ++ fname = "unknown"; ++ ++ IMSG("buffer: %d bytes %s:%d\n", ++ hdr->pl_size, fname, hdr->line); ++ } ++ } ++ ++ malloc_unlock(ctx, exceptions); ++} ++ ++void *mdbg_malloc(const char *fname, int lineno, size_t size) ++{ ++ return gen_mdbg_malloc(&malloc_ctx, fname, lineno, size); ++} ++ ++void *mdbg_calloc(const char *fname, int lineno, size_t nmemb, size_t size) ++{ ++ return gen_mdbg_calloc(&malloc_ctx, fname, lineno, nmemb, size); ++} ++ ++void *mdbg_realloc(const char *fname, int lineno, void *ptr, size_t size) ++{ ++ return gen_mdbg_realloc(&malloc_ctx, fname, lineno, ptr, size); ++} ++ ++void mdbg_check(int bufdump) ++{ ++ gen_mdbg_check(&malloc_ctx, bufdump); ++} ++#else ++ ++void *malloc(size_t size) ++{ ++ void *p; ++ uint32_t exceptions = malloc_lock(&malloc_ctx); ++ ++ p = raw_malloc(0, 0, size, &malloc_ctx); ++ malloc_unlock(&malloc_ctx, exceptions); ++ return p; ++} ++ ++static void free_helper(void *ptr, bool wipe) ++{ ++ uint32_t exceptions = malloc_lock(&malloc_ctx); ++ ++ raw_free(ptr, &malloc_ctx, wipe); ++ malloc_unlock(&malloc_ctx, exceptions); ++} ++ ++void *calloc(size_t nmemb, size_t size) ++{ ++ void *p; ++ uint32_t exceptions = malloc_lock(&malloc_ctx); ++ ++ p = raw_calloc(0, 0, nmemb, size, &malloc_ctx); ++ malloc_unlock(&malloc_ctx, exceptions); ++ return p; ++} ++ ++static void *realloc_unlocked(struct malloc_ctx *ctx, void *ptr, ++ size_t size) ++{ ++ return raw_realloc(ptr, 0, 0, size, ctx); ++} ++ ++void *realloc(void *ptr, size_t size) ++{ ++ void *p; ++ uint32_t exceptions = malloc_lock(&malloc_ctx); ++ ++ p = realloc_unlocked(&malloc_ctx, ptr, size); ++ malloc_unlock(&malloc_ctx, exceptions); ++ return p; ++} ++ ++static void *get_payload_start_size(void *ptr, size_t *size) ++{ ++ *size = bget_buf_size(ptr); ++ return ptr; ++} ++ ++#endif ++ ++void free(void *ptr) ++{ ++ free_helper(ptr, false); ++} ++ ++void free_wipe(void *ptr) ++{ ++ free_helper(ptr, true); ++} ++ ++static void gen_malloc_add_pool(struct malloc_ctx *ctx, void *buf, size_t len) ++{ ++ void *p; ++ size_t l; ++ uint32_t exceptions; ++ uintptr_t start = (uintptr_t)buf; ++ uintptr_t end = start + len; ++ const size_t min_len = ((sizeof(struct malloc_pool) + (SizeQuant - 1)) & ++ (~(SizeQuant - 1))) + ++ sizeof(struct bhead) * 2; ++ ++ ++ start = ROUNDUP(start, SizeQuant); ++ end = ROUNDDOWN(end, SizeQuant); ++ assert(start < end); ++ ++ if ((end - start) < min_len) { ++ DMSG("Skipping too small pool"); ++ return; ++ } ++ ++ exceptions = malloc_lock(ctx); ++ ++ tag_asan_free((void *)start, end - start); ++ bpool((void *)start, end - start, &ctx->poolset); ++ l = ctx->pool_len + 1; ++ p = realloc_unlocked(ctx, ctx->pool, sizeof(struct malloc_pool) * l); ++ assert(p); ++ ctx->pool = p; ++ ctx->pool[ctx->pool_len].buf = (void *)start; ++ ctx->pool[ctx->pool_len].len = end - start; ++#ifdef BufStats ++ ctx->mstats.size += ctx->pool[ctx->pool_len].len; ++#endif ++ ctx->pool_len = l; ++ malloc_unlock(ctx, exceptions); ++} ++ ++static bool gen_malloc_buffer_is_within_alloced(struct malloc_ctx *ctx, ++ void *buf, size_t len) ++{ ++ struct bpool_iterator itr; ++ void *b; ++ uint8_t *start_buf = buf; ++ uint8_t *end_buf = start_buf + len; ++ bool ret = false; ++ uint32_t exceptions = malloc_lock(ctx); ++ ++ raw_malloc_validate_pools(ctx); ++ ++ /* Check for wrapping */ ++ if (start_buf > end_buf) ++ goto out; ++ ++ BPOOL_FOREACH(ctx, &itr, &b) { ++ uint8_t *start_b; ++ uint8_t *end_b; ++ size_t s; ++ ++ start_b = get_payload_start_size(b, &s); ++ end_b = start_b + s; ++ ++ if (start_buf >= start_b && end_buf <= end_b) { ++ ret = true; ++ goto out; ++ } ++ } ++ ++out: ++ malloc_unlock(ctx, exceptions); ++ ++ return ret; ++} ++ ++static bool gen_malloc_buffer_overlaps_heap(struct malloc_ctx *ctx, ++ void *buf, size_t len) ++{ ++ uintptr_t buf_start = (uintptr_t) buf; ++ uintptr_t buf_end = buf_start + len; ++ size_t n; ++ bool ret = false; ++ uint32_t exceptions = malloc_lock(ctx); ++ ++ raw_malloc_validate_pools(ctx); ++ ++ for (n = 0; n < ctx->pool_len; n++) { ++ uintptr_t pool_start = (uintptr_t)ctx->pool[n].buf; ++ uintptr_t pool_end = pool_start + ctx->pool[n].len; ++ ++ if (buf_start > buf_end || pool_start > pool_end) { ++ ret = true; /* Wrapping buffers, shouldn't happen */ ++ goto out; ++ } ++ ++ if (buf_end > pool_start || buf_start < pool_end) { ++ ret = true; ++ goto out; ++ } ++ } ++ ++out: ++ malloc_unlock(ctx, exceptions); ++ return ret; ++} ++ ++void malloc_add_pool(void *buf, size_t len) ++{ ++ gen_malloc_add_pool(&malloc_ctx, buf, len); ++} ++ ++bool malloc_buffer_is_within_alloced(void *buf, size_t len) ++{ ++ return gen_malloc_buffer_is_within_alloced(&malloc_ctx, buf, len); ++} ++ ++bool malloc_buffer_overlaps_heap(void *buf, size_t len) ++{ ++ return gen_malloc_buffer_overlaps_heap(&malloc_ctx, buf, len); ++} ++ ++#ifdef CFG_VIRTUALIZATION ++ ++#ifndef ENABLE_MDBG ++ ++void *nex_malloc(size_t size) ++{ ++ void *p; ++ uint32_t exceptions = malloc_lock(&nex_malloc_ctx); ++ ++ p = raw_malloc(0, 0, size, &nex_malloc_ctx); ++ malloc_unlock(&nex_malloc_ctx, exceptions); ++ return p; ++} ++ ++void *nex_calloc(size_t nmemb, size_t size) ++{ ++ void *p; ++ uint32_t exceptions = malloc_lock(&nex_malloc_ctx); ++ ++ p = raw_calloc(0, 0, nmemb, size, &nex_malloc_ctx); ++ malloc_unlock(&nex_malloc_ctx, exceptions); ++ return p; ++} ++ ++void *nex_realloc(void *ptr, size_t size) ++{ ++ void *p; ++ uint32_t exceptions = malloc_lock(&nex_malloc_ctx); ++ ++ p = realloc_unlocked(&nex_malloc_ctx, ptr, size); ++ malloc_unlock(&nex_malloc_ctx, exceptions); ++ return p; ++} ++ ++void nex_free(void *ptr) ++{ ++ uint32_t exceptions = malloc_lock(&nex_malloc_ctx); ++ ++ raw_free(ptr, &nex_malloc_ctx, false /* !wipe */); ++ malloc_unlock(&nex_malloc_ctx, exceptions); ++} ++ ++#else /* ENABLE_MDBG */ ++ ++void *nex_mdbg_malloc(const char *fname, int lineno, size_t size) ++{ ++ return gen_mdbg_malloc(&nex_malloc_ctx, fname, lineno, size); ++} ++ ++void *nex_mdbg_calloc(const char *fname, int lineno, size_t nmemb, size_t size) ++{ ++ return gen_mdbg_calloc(&nex_malloc_ctx, fname, lineno, nmemb, size); ++} ++ ++void *nex_mdbg_realloc(const char *fname, int lineno, void *ptr, size_t size) ++{ ++ return gen_mdbg_realloc(&nex_malloc_ctx, fname, lineno, ptr, size); ++} ++ ++void nex_mdbg_check(int bufdump) ++{ ++ gen_mdbg_check(&nex_malloc_ctx, bufdump); ++} ++ ++void nex_free(void *ptr) ++{ ++ uint32_t exceptions = malloc_lock(&nex_malloc_ctx); ++ ++ gen_mdbg_free(&nex_malloc_ctx, ptr, false /* !wipe */); ++ malloc_unlock(&nex_malloc_ctx, exceptions); ++} ++ ++#endif /* ENABLE_MDBG */ ++ ++void nex_malloc_add_pool(void *buf, size_t len) ++{ ++ gen_malloc_add_pool(&nex_malloc_ctx, buf, len); ++} ++ ++bool nex_malloc_buffer_is_within_alloced(void *buf, size_t len) ++{ ++ return gen_malloc_buffer_is_within_alloced(&nex_malloc_ctx, buf, len); ++} ++ ++bool nex_malloc_buffer_overlaps_heap(void *buf, size_t len) ++{ ++ return gen_malloc_buffer_overlaps_heap(&nex_malloc_ctx, buf, len); ++} ++ ++#ifdef BufStats ++ ++void nex_malloc_reset_stats(void) ++{ ++ gen_malloc_reset_stats(&nex_malloc_ctx); ++} ++ ++void nex_malloc_get_stats(struct malloc_stats *stats) ++{ ++ gen_malloc_get_stats(&nex_malloc_ctx, stats); ++} ++ ++#endif ++ ++#endif +diff --git a/environments/shim/lib/libc/memcmp.c b/environments/shim/lib/libc/memcmp.c +new file mode 100644 +index 0000000..a4c798b +--- /dev/null ++++ b/environments/shim/lib/libc/memcmp.c +@@ -0,0 +1,24 @@ ++/* ++ * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include ++ ++int memcmp(const void *s1, const void *s2, size_t len) ++{ ++ const unsigned char *s = s1; ++ const unsigned char *d = s2; ++ unsigned char sc; ++ unsigned char dc; ++ ++ while (len--) { ++ sc = *s++; ++ dc = *d++; ++ if (sc - dc) ++ return (sc - dc); ++ } ++ ++ return 0; ++} +diff --git a/environments/shim/lib/libc/memcpy.c b/environments/shim/lib/libc/memcpy.c +new file mode 100644 +index 0000000..fc0c9fe +--- /dev/null ++++ b/environments/shim/lib/libc/memcpy.c +@@ -0,0 +1,18 @@ ++/* ++ * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include ++ ++void *memcpy(void *dst, const void *src, size_t len) ++{ ++ const char *s = src; ++ char *d = dst; ++ ++ while (len--) ++ *d++ = *s++; ++ ++ return dst; ++} +diff --git a/environments/shim/lib/libc/memmove.c b/environments/shim/lib/libc/memmove.c +new file mode 100644 +index 0000000..63acf26 +--- /dev/null ++++ b/environments/shim/lib/libc/memmove.c +@@ -0,0 +1,31 @@ ++/* ++ * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include ++ ++void *memmove(void *dst, const void *src, size_t len) ++{ ++ /* ++ * The following test makes use of unsigned arithmetic overflow to ++ * more efficiently test the condition !(src <= dst && dst < str+len). ++ * It also avoids the situation where the more explicit test would give ++ * incorrect results were the calculation str+len to overflow (though ++ * that issue is probably moot as such usage is probably undefined ++ * behaviour and a bug anyway. ++ */ ++ if ((size_t)dst - (size_t)src >= len) { ++ /* destination not in source data, so can safely use memcpy */ ++ return memcpy(dst, src, len); ++ } else { ++ /* copy backwards... */ ++ const char *end = dst; ++ const char *s = (const char *)src + len; ++ char *d = (char *)dst + len; ++ while (d != end) ++ *--d = *--s; ++ } ++ return dst; ++} +diff --git a/environments/shim/lib/libc/memset.c b/environments/shim/lib/libc/memset.c +new file mode 100644 +index 0000000..03aa809 +--- /dev/null ++++ b/environments/shim/lib/libc/memset.c +@@ -0,0 +1,17 @@ ++/* ++ * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include ++ ++void *memset(void *dst, int val, size_t count) ++{ ++ char *ptr = dst; ++ ++ while (count--) ++ *ptr++ = val; ++ ++ return dst; ++} +diff --git a/environments/shim/lib/libc/printf.c b/environments/shim/lib/libc/printf.c +new file mode 100644 +index 0000000..60203fb +--- /dev/null ++++ b/environments/shim/lib/libc/printf.c +@@ -0,0 +1,251 @@ ++/* ++ * Copyright (c) 2014-2019, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++ ++#define get_num_va_args(_args, _lcount) \ ++ (((_lcount) > 1) ? va_arg(_args, long long int) : \ ++ (((_lcount) == 1) ? va_arg(_args, long int) : \ ++ va_arg(_args, int))) ++ ++#define get_unum_va_args(_args, _lcount) \ ++ (((_lcount) > 1) ? va_arg(_args, unsigned long long int) : \ ++ (((_lcount) == 1) ? va_arg(_args, unsigned long int) : \ ++ va_arg(_args, unsigned int))) ++ ++static int string_print(const char *str, char padc, int padn) ++{ ++ int i = 0, count = 0; ++ ++ assert(str != NULL); ++ ++ while (str[i] != '\0') ++ i++; ++ ++ if (padn > 0) { ++ while (i < padn) { ++ (void)putchar(padc); ++ count++; ++ padn--; ++ } ++ } ++ ++ for ( ; *str != '\0'; str++) { ++ (void)putchar(*str); ++ count++; ++ } ++ ++ if (padn < 0) { ++ while (i < -padn) { ++ (void)putchar(padc); ++ count++; ++ padn++; ++ } ++ } ++ ++ return count; ++} ++ ++static int unsigned_num_print(unsigned long long int unum, unsigned int radix, ++ char padc, int padn) ++{ ++ /* Just need enough space to store 64 bit decimal integer */ ++ char num_buf[20]; ++ int i = 0, count = 0; ++ int width; ++ unsigned int rem; ++ ++ do { ++ rem = unum % radix; ++ if (rem < 0xa) ++ num_buf[i] = '0' + rem; ++ else ++ num_buf[i] = 'a' + (rem - 0xa); ++ i++; ++ unum /= radix; ++ } while (unum > 0U); ++ ++ width = i; ++ ++ if (padn > 0) { ++ while (width < padn) { ++ (void)putchar(padc); ++ count++; ++ padn--; ++ } ++ } ++ ++ while (--i >= 0) { ++ (void)putchar(num_buf[i]); ++ count++; ++ } ++ ++ if (padn < 0) { ++ while (width < -padn) { ++ (void)putchar(padc); ++ count++; ++ padn++; ++ } ++ } ++ ++ return count; ++} ++ ++/******************************************************************* ++ * Simplified version of printf() with smaller memory footprint. ++ * The following type specifiers are supported by this print ++ * %x - hexadecimal format ++ * %s - string format ++ * %d or %i - signed decimal format ++ * %u - unsigned decimal format ++ * %p - pointer format ++ * ++ * The following length specifiers are supported by this print ++ * %l - long int (64-bit on AArch64) ++ * %ll - long long int (64-bit on AArch64) ++ * %z - size_t sized integer formats (64 bit on AArch64) ++ * ++ * The following padding specifiers are supported by this print ++ * %0NN - Left-pad the number with 0s (NN is a decimal number) ++ * %NN - Left-pad the number or string with spaces (NN is a decimal number) ++ * %-NN - Right-pad the number or string with spaces (NN is a decimal number) ++ * ++ * The print exits on all other formats specifiers other than valid ++ * combinations of the above specifiers. ++ *******************************************************************/ ++int vprintf(const char *fmt, va_list args) ++{ ++ int l_count; ++ int left; ++ long long int num; ++ unsigned long long int unum; ++ char *str; ++ char padc; /* Padding character */ ++ int padn; /* Number of characters to pad */ ++ int count = 0; /* Number of printed characters */ ++ ++ while (*fmt != '\0') { ++ l_count = 0; ++ left = 0; ++ padc = '\0'; ++ padn = 0; ++ ++ if (*fmt == '%') { ++ fmt++; ++ /* Check the format specifier */ ++loop: ++ switch (*fmt) { ++ case '1': ++ case '2': ++ case '3': ++ case '4': ++ case '5': ++ case '6': ++ case '7': ++ case '8': ++ case '9': ++ padc = ' '; ++ for (padn = 0; *fmt >= '0' && *fmt <= '9'; fmt++) ++ padn = (padn * 10) + (*fmt - '0'); ++ if (left) ++ padn = -padn; ++ goto loop; ++ case '-': ++ left = 1; ++ fmt++; ++ goto loop; ++ case 'i': /* Fall through to next one */ ++ case 'd': ++ num = get_num_va_args(args, l_count); ++ if (num < 0) { ++ (void)putchar('-'); ++ unum = (unsigned long long int)-num; ++ padn--; ++ } else ++ unum = (unsigned long long int)num; ++ ++ count += unsigned_num_print(unum, 10, ++ padc, padn); ++ break; ++ case 's': ++ str = va_arg(args, char *); ++ count += string_print(str, padc, padn); ++ break; ++ case 'p': ++ unum = (uintptr_t)va_arg(args, void *); ++ if (unum > 0U) { ++ count += string_print("0x", padc, 0); ++ padn -= 2; ++ } ++ ++ count += unsigned_num_print(unum, 16, ++ padc, padn); ++ break; ++ case 'x': ++ unum = get_unum_va_args(args, l_count); ++ count += unsigned_num_print(unum, 16, ++ padc, padn); ++ break; ++ case 'z': ++ if (sizeof(size_t) == 8U) ++ l_count = 2; ++ ++ fmt++; ++ goto loop; ++ case 'l': ++ l_count++; ++ fmt++; ++ goto loop; ++ case 'u': ++ unum = get_unum_va_args(args, l_count); ++ count += unsigned_num_print(unum, 10, ++ padc, padn); ++ break; ++ case '0': ++ padc = '0'; ++ padn = 0; ++ fmt++; ++ ++ for (;;) { ++ char ch = *fmt; ++ if ((ch < '0') || (ch > '9')) { ++ goto loop; ++ } ++ padn = (padn * 10) + (ch - '0'); ++ fmt++; ++ } ++ assert(0); /* Unreachable */ ++ default: ++ /* Exit on any other format specifier */ ++ return -1; ++ } ++ fmt++; ++ continue; ++ } ++ (void)putchar(*fmt); ++ fmt++; ++ count++; ++ } ++ ++ return count; ++} ++ ++int printf(const char *fmt, ...) ++{ ++ int count; ++ va_list va; ++ ++ va_start(va, fmt); ++ count = vprintf(fmt, va); ++ va_end(va); ++ ++ return count; ++} +diff --git a/environments/shim/lib/libc/putchar.c b/environments/shim/lib/libc/putchar.c +new file mode 100644 +index 0000000..037e28a +--- /dev/null ++++ b/environments/shim/lib/libc/putchar.c +@@ -0,0 +1,20 @@ ++/* ++ * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include ++ ++#include ++ ++int putchar(int c) ++{ ++ int res; ++ if (console_putc((unsigned char)c) >= 0) ++ res = c; ++ else ++ res = EOF; ++ ++ return res; ++} +diff --git a/environments/shim/lib/libc/rand.c b/environments/shim/lib/libc/rand.c +new file mode 100644 +index 0000000..59cb796 +--- /dev/null ++++ b/environments/shim/lib/libc/rand.c +@@ -0,0 +1,65 @@ ++/*- ++ * Portions Copyright (c) 2010, Intel Corporation. All rights reserved.
++ * Copyright (c) 1990, 1993 ++ * The Regents of the University of California. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 4. Neither the name of the University nor the names of its contributors ++ * may be used to endorse or promote products derived from this software ++ * without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ * ++ */ ++//__FBSDID("$FreeBSD: src/lib/libc/stdlib/rand.c,v 1.17.2.1.2.1 2009/10/25 01:10:29 kensmith Exp $"); ++#include ++ ++static unsigned int next = 1; ++ ++/** Compute a pseudo-random number. ++ * ++ * Compute x = (7^5 * x) mod (2^31 - 1) ++ * without overflowing 31 bits: ++ * (2^31 - 1) = 127773 * (7^5) + 2836 ++ * From "Random number generators: good ones are hard to find", ++ * Park and Miller, Communications of the ACM, vol. 31, no. 10, ++ * October 1988, p. 1195. ++**/ ++int ++rand() ++{ ++ int hi, lo, x; ++ ++ /* Can't be initialized with 0, so use another value. */ ++ if (next == 0) ++ next = 123459876; ++ hi = next / 127773; ++ lo = next % 127773; ++ x = 16807 * lo - 2836 * hi; ++ if (x < 0) ++ x += 0x7fffffff; ++ return ((next = x) % ((unsigned int)RAND_MAX + 1)); ++} ++ ++void ++srand(unsigned int seed) ++{ ++ next = (unsigned int)seed; ++} +diff --git a/environments/shim/lib/libc/snprintf.c b/environments/shim/lib/libc/snprintf.c +new file mode 100644 +index 0000000..ef15a26 +--- /dev/null ++++ b/environments/shim/lib/libc/snprintf.c +@@ -0,0 +1,250 @@ ++/* ++ * Copyright (c) 2017-2021, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include ++#include ++#include ++ ++#include ++//#include ++ ++#define get_num_va_args(_args, _lcount) \ ++ (((_lcount) > 1) ? va_arg(_args, long long int) : \ ++ (((_lcount) == 1) ? va_arg(_args, long int) : \ ++ va_arg(_args, int))) ++ ++#define get_unum_va_args(_args, _lcount) \ ++ (((_lcount) > 1) ? va_arg(_args, unsigned long long int) : \ ++ (((_lcount) == 1) ? va_arg(_args, unsigned long int) : \ ++ va_arg(_args, unsigned int))) ++ ++static void string_print(char **s, size_t n, size_t *chars_printed, ++ const char *str) ++{ ++ while (*str != '\0') { ++ if (*chars_printed < n) { ++ *(*s) = *str; ++ (*s)++; ++ } ++ ++ (*chars_printed)++; ++ str++; ++ } ++} ++ ++static void unsigned_num_print(char **s, size_t n, size_t *count, ++ unsigned long long int unum, unsigned int radix, ++ char padc, int padn) ++{ ++ /* Just need enough space to store 64 bit decimal integer */ ++ char num_buf[20]; ++ int i = 0; ++ int width; ++ unsigned int rem; ++ ++ do { ++ rem = unum % radix; ++ if (rem < 0xa) ++ num_buf[i] = '0' + rem; ++ else ++ num_buf[i] = 'a' + (rem - 0xa); ++ i++; ++ unum /= radix; ++ } while (unum > 0U); ++ ++ width = i; ++ ++ if (padn > 0) { ++ while (width < padn) { ++ if (*count < n) { ++ *(*s) = padc; ++ (*s)++; ++ } ++ (*count)++; ++ padn--; ++ } ++ } ++ ++ while (--i >= 0) { ++ if (*count < n) { ++ *(*s) = num_buf[i]; ++ (*s)++; ++ } ++ (*count)++; ++ } ++ ++ if (padn < 0) { ++ while (width < -padn) { ++ if (*count < n) { ++ *(*s) = padc; ++ (*s)++; ++ } ++ (*count)++; ++ padn++; ++ } ++ } ++} ++ ++/* ++ * Scaled down version of vsnprintf(3). ++ */ ++int vsnprintf(char *s, size_t n, const char *fmt, va_list args) ++{ ++ int l_count; ++ int left; ++ char *str; ++ int num; ++ unsigned long long int unum; ++ char padc; /* Padding character */ ++ int padn; /* Number of characters to pad */ ++ size_t count = 0U; ++ ++ if (n == 0U) { ++ /* There isn't space for anything. */ ++ } else if (n == 1U) { ++ /* Buffer is too small to actually write anything else. */ ++ *s = '\0'; ++ n = 0U; ++ } else { ++ /* Reserve space for the terminator character. */ ++ n--; ++ } ++ ++ while (*fmt != '\0') { ++ l_count = 0; ++ left = 0; ++ padc = '\0'; ++ padn = 0; ++ ++ if (*fmt == '%') { ++ fmt++; ++ /* Check the format specifier. */ ++loop: ++ switch (*fmt) { ++ case '1': ++ case '2': ++ case '3': ++ case '4': ++ case '5': ++ case '6': ++ case '7': ++ case '8': ++ case '9': ++ padc = ' '; ++ for (padn = 0; *fmt >= '0' && *fmt <= '9'; fmt++) ++ padn = (padn * 10) + (*fmt - '0'); ++ if (left) ++ padn = -padn; ++ goto loop; ++ case '-': ++ left = 1; ++ fmt++; ++ goto loop; ++ case 'i': ++ case 'd': ++ num = get_num_va_args(args, l_count); ++ ++ if (num < 0) { ++ if (count < n) { ++ *s = '-'; ++ s++; ++ } ++ count++; ++ ++ unum = (unsigned int)-num; ++ } else { ++ unum = (unsigned int)num; ++ } ++ ++ unsigned_num_print(&s, n, &count, unum, 10, ++ padc, padn); ++ break; ++ case 'l': ++ l_count++; ++ fmt++; ++ goto loop; ++ case 's': ++ str = va_arg(args, char *); ++ string_print(&s, n, &count, str); ++ break; ++ case 'u': ++ unum = get_unum_va_args(args, l_count); ++ unsigned_num_print(&s, n, &count, unum, 10, ++ padc, padn); ++ break; ++ case 'x': ++ unum = get_unum_va_args(args, l_count); ++ unsigned_num_print(&s, n, &count, unum, 16, ++ padc, padn); ++ break; ++ case '0': ++ padc = '0'; ++ padn = 0; ++ fmt++; ++ ++ for (;;) { ++ char ch = *fmt; ++ if ((ch < '0') || (ch > '9')) { ++ goto loop; ++ } ++ padn = (padn * 10) + (ch - '0'); ++ fmt++; ++ } ++ assert(0); /* Unreachable */ ++ default: ++ /* ++ * Exit on any other format specifier and abort ++ * when in debug mode. ++ */ ++ WARN("snprintf: specifier with ASCII code '%d' not supported.\n", ++ *fmt); ++ assert(0); ++ return -1; ++ } ++ fmt++; ++ continue; ++ } ++ ++ if (count < n) { ++ *s = *fmt; ++ s++; ++ } ++ ++ fmt++; ++ count++; ++ } ++ ++ if (n > 0U) ++ *s = '\0'; ++ ++ return (int)count; ++} ++ ++/******************************************************************* ++ * Reduced snprintf to be used for Trusted firmware. ++ * The following type specifiers are supported: ++ * ++ * %d or %i - signed decimal format ++ * %s - string format ++ * %u - unsigned decimal format ++ * ++ * The function panics on all other formats specifiers. ++ * ++ * It returns the number of characters that would be written if the ++ * buffer was big enough. If it returns a value lower than n, the ++ * whole string has been written. ++ *******************************************************************/ ++int snprintf(char *s, size_t n, const char *fmt, ...) ++{ ++ va_list args; ++ int chars_printed; ++ ++ va_start(args, fmt); ++ chars_printed = vsnprintf(s, n, fmt, args); ++ va_end(args); ++ ++ return chars_printed; ++} +diff --git a/environments/shim/lib/libc/strcmp.c b/environments/shim/lib/libc/strcmp.c +new file mode 100644 +index 0000000..b742f9b +--- /dev/null ++++ b/environments/shim/lib/libc/strcmp.c +@@ -0,0 +1,52 @@ ++/*- ++ * SPDX-License-Identifier: BSD-3-Clause ++ * ++ * Copyright (c) 1990, 1993 ++ * The Regents of the University of California. All rights reserved. ++ * ++ * This code is derived from software contributed to Berkeley by ++ * Chris Torek. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the name of the University nor the names of its contributors ++ * may be used to endorse or promote products derived from this software ++ * without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ */ ++ ++/* ++ * Portions copyright (c) 2018, ARM Limited and Contributors. ++ * All rights reserved. ++ */ ++ ++#include ++ ++/* ++ * Compare strings. ++ */ ++int ++strcmp(const char *s1, const char *s2) ++{ ++ while (*s1 == *s2++) ++ if (*s1++ == '\0') ++ return (0); ++ return (*(const unsigned char *)s1 - *(const unsigned char *)(s2 - 1)); ++} +diff --git a/environments/shim/lib/libc/strlen.c b/environments/shim/lib/libc/strlen.c +new file mode 100644 +index 0000000..3c27630 +--- /dev/null ++++ b/environments/shim/lib/libc/strlen.c +@@ -0,0 +1,17 @@ ++/* ++ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include ++ ++size_t strlen(const char *s) ++{ ++ const char *cursor = s; ++ ++ while (*cursor) ++ cursor++; ++ ++ return cursor - s; ++} +diff --git a/environments/shim/lib/libc/strstr.c b/environments/shim/lib/libc/strstr.c +new file mode 100644 +index 0000000..572011e +--- /dev/null ++++ b/environments/shim/lib/libc/strstr.c +@@ -0,0 +1,25 @@ ++/* ++ * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include ++#include ++ ++char* strstr(const char* hay, const char* needle) ++{ ++ if (*needle == '\0') ++ return hay; ++ ++ for (int i = 0; i < strlen(hay); i++) ++ { ++ if (*(hay + i) == *needle) ++ { ++ char* ptr = strstr(hay + i + 1, needle + 1); ++ return (ptr) ? ptr - 1 : NULL; ++ } ++ } ++ ++ return NULL; ++} +diff --git a/environments/shim/lib/locks/aarch64/spinlock.S b/environments/shim/lib/locks/aarch64/spinlock.S +new file mode 100644 +index 0000000..1438f54 +--- /dev/null ++++ b/environments/shim/lib/locks/aarch64/spinlock.S +@@ -0,0 +1,34 @@ ++/* ++ * Copyright (c) 2018-2021, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#define __ASSEMBLY__ ++#include ++ ++ .globl init_spinlock ++ .globl spin_lock ++ .globl spin_unlock ++ ++func init_spinlock ++ str wzr, [x0] ++ ret ++endfunc init_spinlock ++ ++func spin_lock ++ mov w2, #1 ++ sevl ++l1: wfe ++l2: ldaxr w1, [x0] ++ cbnz w1, l1 ++ stxr w1, w2, [x0] ++ cbnz w1, l2 ++ ret ++endfunc spin_lock ++ ++ ++func spin_unlock ++ stlr wzr, [x0] ++ ret ++endfunc spin_unlock +diff --git a/environments/shim/lib/smc/aarch64/asm_smc.S b/environments/shim/lib/smc/aarch64/asm_smc.S +new file mode 100644 +index 0000000..b396986 +--- /dev/null ++++ b/environments/shim/lib/smc/aarch64/asm_smc.S +@@ -0,0 +1,76 @@ ++/* ++ * Copyright (c) 2013-2021, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#define __ASSEMBLY__ ++#include ++ ++ .section .text, "ax" ++ ++ .macro smccc_conduit _conduit ++ ++ /* ++ * According to the AAPCS64, x8 is the indirect result location ++ * register. It contains the address of the memory block that the caller ++ * has reserved to hold the result, i.e. the smc_ret_values structure ++ * in our case. ++ * x8 might be clobbered across the SMC call so save it on the stack. ++ * Although x8 contains an 8 byte value, we are allocating 16bytes on the stack ++ * to respect 16byte stack-alignment. ++ */ ++ str x8, [sp, #-16]! ++ ++ /* "Conduit" arguments are already stored in x0-x7 */ ++ \_conduit #0 ++ ++ /* Pop x8 into a caller-saved register */ ++ ldr x9, [sp], #16 ++ ++ /* ++ * Return values are stored in x0-x7, put them in the 'smc_ret_values' ++ * return structure ++ */ ++ stp x0, x1, [x9, #0] ++ stp x2, x3, [x9, #16] ++ stp x4, x5, [x9, #32] ++ stp x6, x7, [x9, #48] ++ ++ .endm ++ ++/* --------------------------------------------------------------------------- ++ * smc_ret_values asm_tftf_smc64(uint32_t fid, ++ * u_register_t arg1, ++ * u_register_t arg2, ++ * u_register_t arg3, ++ * u_register_t arg4, ++ * u_register_t arg5, ++ * u_register_t arg6, ++ * u_register_t arg7); ++ * --------------------------------------------------------------------------- ++ */ ++ .globl asm_tftf_smc64 ++ ++func asm_tftf_smc64 ++ smccc_conduit smc ++ ret ++endfunc asm_tftf_smc64 ++ ++/* --------------------------------------------------------------------------- ++ * hvc_ret_values asm_tftf_hvcc64(uint32_t fid, ++ * u_register_t arg1, ++ * u_register_t arg2, ++ * u_register_t arg3, ++ * u_register_t arg4, ++ * u_register_t arg5, ++ * u_register_t arg6, ++ * u_register_t arg7); ++ * --------------------------------------------------------------------------- ++ */ ++ .globl asm_tftf_hvc64 ++ ++func asm_tftf_hvc64 ++ smccc_conduit hvc ++ ret ++endfunc asm_tftf_hvc64 +diff --git a/environments/shim/lib/smc/aarch64/hvc.c b/environments/shim/lib/smc/aarch64/hvc.c +new file mode 100644 +index 0000000..c833864 +--- /dev/null ++++ b/environments/shim/lib/smc/aarch64/hvc.c +@@ -0,0 +1,30 @@ ++/* ++ * Copyright (c) 2020, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ * ++ */ ++ ++#include ++#include ++ ++hvc_ret_values asm_tftf_hvc64(uint32_t fid, ++ u_register_t arg1, ++ u_register_t arg2, ++ u_register_t arg3, ++ u_register_t arg4, ++ u_register_t arg5, ++ u_register_t arg6, ++ u_register_t arg7); ++ ++hvc_ret_values tftf_hvc(const hvc_args *args) ++{ ++ return asm_tftf_hvc64(args->fid, ++ args->arg1, ++ args->arg2, ++ args->arg3, ++ args->arg4, ++ args->arg5, ++ args->arg6, ++ args->arg7); ++} +diff --git a/environments/shim/lib/utils/mp_printf.c b/environments/shim/lib/utils/mp_printf.c +new file mode 100644 +index 0000000..777c736 +--- /dev/null ++++ b/environments/shim/lib/utils/mp_printf.c +@@ -0,0 +1,24 @@ ++/* ++ * Copyright (c) 2018, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include ++#include ++#include ++ ++/* Lock to avoid concurrent accesses to the serial console */ ++static spinlock_t printf_lock; ++ ++void mp_printf(const char *fmt, ...) ++{ ++ va_list args; ++ va_start(args, fmt); ++ ++ spin_lock(&printf_lock); ++ vprintf(fmt, args); ++ spin_unlock(&printf_lock); ++ ++ va_end(args); ++} +diff --git a/environments/shim/lib/xlat_tables_v2/aarch64/enable_mmu.S b/environments/shim/lib/xlat_tables_v2/aarch64/enable_mmu.S +new file mode 100644 +index 0000000..00e3d51 +--- /dev/null ++++ b/environments/shim/lib/xlat_tables_v2/aarch64/enable_mmu.S +@@ -0,0 +1,98 @@ ++/* ++ * Copyright (c) 2018-2021, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#define __ASSEMBLY__ ++#include ++#include ++#include ++ ++ .global enable_mmu_direct_el1 ++ .global enable_mmu_direct_el2 ++ .global enable_mmu_direct_el3 ++ ++ /* Macros to read and write to system register for a given EL. */ ++ .macro _msr reg_name, el, gp_reg ++ msr \reg_name\()_el\()\el, \gp_reg ++ .endm ++ ++ .macro _mrs gp_reg, reg_name, el ++ mrs \gp_reg, \reg_name\()_el\()\el ++ .endm ++ ++ .macro tlbi_invalidate_all el ++ .if \el == 1 ++ TLB_INVALIDATE(vmalle1) ++ .elseif \el == 2 ++ TLB_INVALIDATE(alle2) ++ .elseif \el == 3 ++ TLB_INVALIDATE(alle3) ++ .else ++ .error "EL must be 1, 2 or 3" ++ .endif ++ .endm ++ ++ /* void enable_mmu_direct_el(unsigned int flags) */ ++ .macro define_mmu_enable_func el ++ func enable_mmu_direct_\()el\el ++#if ENABLE_ASSERTIONS ++ _mrs x1, sctlr, \el ++ tst x1, #SCTLR_M_BIT ++ ASM_ASSERT(eq) ++#endif ++ /* Invalidate all TLB entries */ ++ tlbi_invalidate_all \el ++ ++ mov x7, x0 ++ adrp x0, mmu_cfg_params ++ add x0, x0, :lo12:mmu_cfg_params ++ ++ /* MAIR */ ++ ldr x1, [x0, #(MMU_CFG_MAIR << 3)] ++ _msr mair, \el, x1 ++ ++ /* TCR */ ++ ldr x2, [x0, #(MMU_CFG_TCR << 3)] ++ _msr tcr, \el, x2 ++ ++ /* TTBR */ ++ ldr x3, [x0, #(MMU_CFG_TTBR0 << 3)] ++ _msr ttbr0, \el, x3 ++ ++ /* ++ * Ensure all translation table writes have drained into memory, the TLB ++ * invalidation is complete, and translation register writes are ++ * committed before enabling the MMU ++ */ ++ dsb ish ++ isb ++ ++ /* Set and clear required fields of SCTLR */ ++ _mrs x4, sctlr, \el ++ mov_imm x5, SCTLR_WXN_BIT | SCTLR_C_BIT | SCTLR_M_BIT ++ orr x4, x4, x5 ++ ++ /* Additionally, amend SCTLR fields based on flags */ ++ bic x5, x4, #SCTLR_C_BIT ++ tst x7, #DISABLE_DCACHE ++ csel x4, x5, x4, ne ++ ++ _msr sctlr, \el, x4 ++ isb ++ ++ ret ++ endfunc enable_mmu_direct_\()el\el ++ .endm ++ ++ /* ++ * Define MMU-enabling functions for EL1, EL2 and EL3: ++ * ++ * enable_mmu_direct_el1 ++ * enable_mmu_direct_el2 ++ * enable_mmu_direct_el3 ++ */ ++ define_mmu_enable_func 1 ++ define_mmu_enable_func 2 ++ define_mmu_enable_func 3 +diff --git a/environments/shim/lib/xlat_tables_v2/aarch64/xlat_tables_arch.c b/environments/shim/lib/xlat_tables_v2/aarch64/xlat_tables_arch.c +new file mode 100644 +index 0000000..037dbf8 +--- /dev/null ++++ b/environments/shim/lib/xlat_tables_v2/aarch64/xlat_tables_arch.c +@@ -0,0 +1,295 @@ ++/* ++ * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "../xlat_tables_private.h" ++ ++/* ++ * Returns true if the provided granule size is supported, false otherwise. ++ */ ++bool xlat_arch_is_granule_size_supported(size_t size) ++{ ++ u_register_t id_aa64mmfr0_el1 = read_id_aa64mmfr0_el1(); ++ ++ if (size == PAGE_SIZE_4KB) { ++ return ((id_aa64mmfr0_el1 >> ID_AA64MMFR0_EL1_TGRAN4_SHIFT) & ++ ID_AA64MMFR0_EL1_TGRAN4_MASK) == ++ ID_AA64MMFR0_EL1_TGRAN4_SUPPORTED; ++ } else if (size == PAGE_SIZE_16KB) { ++ return ((id_aa64mmfr0_el1 >> ID_AA64MMFR0_EL1_TGRAN16_SHIFT) & ++ ID_AA64MMFR0_EL1_TGRAN16_MASK) == ++ ID_AA64MMFR0_EL1_TGRAN16_SUPPORTED; ++ } else if (size == PAGE_SIZE_64KB) { ++ return ((id_aa64mmfr0_el1 >> ID_AA64MMFR0_EL1_TGRAN64_SHIFT) & ++ ID_AA64MMFR0_EL1_TGRAN64_MASK) == ++ ID_AA64MMFR0_EL1_TGRAN64_SUPPORTED; ++ } else { ++ return 0; ++ } ++} ++ ++size_t xlat_arch_get_max_supported_granule_size(void) ++{ ++ if (xlat_arch_is_granule_size_supported(PAGE_SIZE_64KB)) { ++ return PAGE_SIZE_64KB; ++ } else if (xlat_arch_is_granule_size_supported(PAGE_SIZE_16KB)) { ++ return PAGE_SIZE_16KB; ++ } else { ++ assert(xlat_arch_is_granule_size_supported(PAGE_SIZE_4KB)); ++ return PAGE_SIZE_4KB; ++ } ++} ++ ++unsigned long long tcr_physical_addr_size_bits(unsigned long long max_addr) ++{ ++ /* Physical address can't exceed 48 bits */ ++ assert((max_addr & ADDR_MASK_48_TO_63) == 0U); ++ ++ /* 48 bits address */ ++ if ((max_addr & ADDR_MASK_44_TO_47) != 0U) ++ return TCR_PS_BITS_256TB; ++ ++ /* 44 bits address */ ++ if ((max_addr & ADDR_MASK_42_TO_43) != 0U) ++ return TCR_PS_BITS_16TB; ++ ++ /* 42 bits address */ ++ if ((max_addr & ADDR_MASK_40_TO_41) != 0U) ++ return TCR_PS_BITS_4TB; ++ ++ /* 40 bits address */ ++ if ((max_addr & ADDR_MASK_36_TO_39) != 0U) ++ return TCR_PS_BITS_1TB; ++ ++ /* 36 bits address */ ++ if ((max_addr & ADDR_MASK_32_TO_35) != 0U) ++ return TCR_PS_BITS_64GB; ++ ++ return TCR_PS_BITS_4GB; ++} ++ ++#if ENABLE_ASSERTIONS ++/* ++ * Physical Address ranges supported in the AArch64 Memory Model. Value 0b110 is ++ * supported in ARMv8.2 onwards. ++ */ ++static const unsigned int pa_range_bits_arr[] = { ++ PARANGE_0000, PARANGE_0001, PARANGE_0010, PARANGE_0011, PARANGE_0100, ++ PARANGE_0101, PARANGE_0110 ++}; ++ ++unsigned long long xlat_arch_get_max_supported_pa(void) ++{ ++ u_register_t pa_range = read_id_aa64mmfr0_el1() & ++ ID_AA64MMFR0_EL1_PARANGE_MASK; ++ ++ /* All other values are reserved */ ++ assert(pa_range < ARRAY_SIZE(pa_range_bits_arr)); ++ ++ return (1ULL << pa_range_bits_arr[pa_range]) - 1ULL; ++} ++ ++/* ++ * Return minimum virtual address space size supported by the architecture ++ */ ++uintptr_t xlat_get_min_virt_addr_space_size(void) ++{ ++ uintptr_t ret; ++ ++ if (is_armv8_4_ttst_present()) ++ ret = MIN_VIRT_ADDR_SPACE_SIZE_TTST; ++ else ++ ret = MIN_VIRT_ADDR_SPACE_SIZE; ++ ++ return ret; ++} ++#endif /* ENABLE_ASSERTIONS*/ ++ ++bool is_mmu_enabled_ctx(const xlat_ctx_t *ctx) ++{ ++ if (ctx->xlat_regime == EL1_EL0_REGIME) { ++ assert(xlat_arch_current_el() >= 1U); ++ return (read_sctlr_el1() & SCTLR_M_BIT) != 0U; ++ } else if (ctx->xlat_regime == EL2_REGIME) { ++ assert(xlat_arch_current_el() >= 2U); ++ return (read_sctlr_el2() & SCTLR_M_BIT) != 0U; ++ } else { ++ assert(ctx->xlat_regime == EL3_REGIME); ++ assert(xlat_arch_current_el() >= 3U); ++ return (read_sctlr_el3() & SCTLR_M_BIT) != 0U; ++ } ++} ++ ++bool is_dcache_enabled(void) ++{ ++ unsigned int el = (unsigned int)GET_EL(read_CurrentEl()); ++ ++ if (el == 1U) { ++ return (read_sctlr_el1() & SCTLR_C_BIT) != 0U; ++ } else if (el == 2U) { ++ return (read_sctlr_el2() & SCTLR_C_BIT) != 0U; ++ } else { ++ return (read_sctlr_el3() & SCTLR_C_BIT) != 0U; ++ } ++} ++ ++uint64_t xlat_arch_regime_get_xn_desc(int xlat_regime) ++{ ++ if (xlat_regime == EL1_EL0_REGIME) { ++ return UPPER_ATTRS(UXN) | UPPER_ATTRS(PXN); ++ } else { ++ assert((xlat_regime == EL2_REGIME) || ++ (xlat_regime == EL3_REGIME)); ++ return UPPER_ATTRS(XN); ++ } ++} ++ ++void xlat_arch_tlbi_va(uintptr_t va, int xlat_regime) ++{ ++ /* ++ * Ensure the translation table write has drained into memory before ++ * invalidating the TLB entry. ++ */ ++ dsbishst(); ++ ++ /* ++ * This function only supports invalidation of TLB entries for the EL3 ++ * and EL1&0 translation regimes. ++ * ++ * Also, it is architecturally UNDEFINED to invalidate TLBs of a higher ++ * exception level (see section D4.9.2 of the ARM ARM rev B.a). ++ */ ++ if (xlat_regime == EL1_EL0_REGIME) { ++ assert(xlat_arch_current_el() >= 1U); ++ tlbivaae1is(TLBI_ADDR(va)); ++ } else if (xlat_regime == EL2_REGIME) { ++ assert(xlat_arch_current_el() >= 2U); ++ tlbivae2is(TLBI_ADDR(va)); ++ } else { ++ assert(xlat_regime == EL3_REGIME); ++ assert(xlat_arch_current_el() >= 3U); ++ tlbivae3is(TLBI_ADDR(va)); ++ } ++} ++ ++void xlat_arch_tlbi_va_sync(void) ++{ ++ /* ++ * A TLB maintenance instruction can complete at any time after ++ * it is issued, but is only guaranteed to be complete after the ++ * execution of DSB by the PE that executed the TLB maintenance ++ * instruction. After the TLB invalidate instruction is ++ * complete, no new memory accesses using the invalidated TLB ++ * entries will be observed by any observer of the system ++ * domain. See section D4.8.2 of the ARMv8 (issue k), paragraph ++ * "Ordering and completion of TLB maintenance instructions". ++ */ ++ dsbish(); ++ ++ /* ++ * The effects of a completed TLB maintenance instruction are ++ * only guaranteed to be visible on the PE that executed the ++ * instruction after the execution of an ISB instruction by the ++ * PE that executed the TLB maintenance instruction. ++ */ ++ isb(); ++} ++ ++unsigned int xlat_arch_current_el(void) ++{ ++ unsigned int el = (unsigned int)GET_EL(read_CurrentEl()); ++ ++ assert(el > 0U); ++ ++ return el; ++} ++ ++void setup_mmu_cfg(uint64_t *params, unsigned int flags, ++ const uint64_t *base_table, unsigned long long max_pa, ++ uintptr_t max_va, int xlat_regime) ++{ ++ uint64_t mair, ttbr0, tcr; ++ uintptr_t virtual_addr_space_size; ++ ++ /* Set attributes in the right indices of the MAIR. */ ++ mair = MAIR_ATTR_SET(ATTR_DEVICE, ATTR_DEVICE_INDEX); ++ mair |= MAIR_ATTR_SET(ATTR_IWBWA_OWBWA_NTR, ATTR_IWBWA_OWBWA_NTR_INDEX); ++ mair |= MAIR_ATTR_SET(ATTR_NON_CACHEABLE, ATTR_NON_CACHEABLE_INDEX); ++ ++ /* ++ * Limit the input address ranges and memory region sizes translated ++ * using TTBR0 to the given virtual address space size. ++ */ ++ assert(max_va < ((uint64_t)UINTPTR_MAX)); ++ ++ virtual_addr_space_size = (uintptr_t)max_va + 1U; ++ ++ assert(virtual_addr_space_size >= ++ xlat_get_min_virt_addr_space_size()); ++ assert(virtual_addr_space_size <= MAX_VIRT_ADDR_SPACE_SIZE); ++ assert(IS_POWER_OF_TWO(virtual_addr_space_size)); ++ ++ /* ++ * __builtin_ctzll(0) is undefined but here we are guaranteed that ++ * virtual_addr_space_size is in the range [1,UINTPTR_MAX]. ++ */ ++ int t0sz = 64 - __builtin_ctzll(virtual_addr_space_size); ++ ++ tcr = (uint64_t)t0sz << TCR_T0SZ_SHIFT; ++ ++ /* ++ * Set the cacheability and shareability attributes for memory ++ * associated with translation table walks. ++ */ ++ if ((flags & XLAT_TABLE_NC) != 0U) { ++ /* Inner & outer non-cacheable non-shareable. */ ++ tcr |= TCR_SH_NON_SHAREABLE | ++ TCR_RGN_OUTER_NC | TCR_RGN_INNER_NC; ++ } else { ++ /* Inner & outer WBWA & shareable. */ ++ tcr |= TCR_SH_INNER_SHAREABLE | ++ TCR_RGN_OUTER_WBA | TCR_RGN_INNER_WBA; ++ } ++ ++ /* ++ * It is safer to restrict the max physical address accessible by the ++ * hardware as much as possible. ++ */ ++ unsigned long long tcr_ps_bits = tcr_physical_addr_size_bits(max_pa); ++ ++ if (xlat_regime == EL1_EL0_REGIME) { ++ /* ++ * TCR_EL1.EPD1: Disable translation table walk for addresses ++ * that are translated using TTBR1_EL1. ++ */ ++ tcr |= TCR_EPD1_BIT | (tcr_ps_bits << TCR_EL1_IPS_SHIFT); ++ } else if (xlat_regime == EL2_REGIME) { ++ tcr |= TCR_EL2_RES1 | (tcr_ps_bits << TCR_EL2_PS_SHIFT); ++ } else { ++ assert(xlat_regime == EL3_REGIME); ++ tcr |= TCR_EL3_RES1 | (tcr_ps_bits << TCR_EL3_PS_SHIFT); ++ } ++ ++ /* Set TTBR bits as well */ ++ ttbr0 = (uint64_t) base_table; ++ ++ if (is_armv8_2_ttcnp_present()) { ++ /* Enable CnP bit so as to share page tables with all PEs. */ ++ ttbr0 |= TTBR_CNP_BIT; ++ } ++ ++ params[MMU_CFG_MAIR] = mair; ++ params[MMU_CFG_TCR] = tcr; ++ params[MMU_CFG_TTBR0] = ttbr0; ++} +diff --git a/environments/shim/lib/xlat_tables_v2/xlat_tables_context.c b/environments/shim/lib/xlat_tables_v2/xlat_tables_context.c +new file mode 100644 +index 0000000..0f3bab9 +--- /dev/null ++++ b/environments/shim/lib/xlat_tables_v2/xlat_tables_context.c +@@ -0,0 +1,181 @@ ++/* ++ * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include "xlat_tables_private.h" ++ ++/* ++ * MMU configuration register values for the active translation context. Used ++ * from the MMU assembly helpers. ++ */ ++uint64_t mmu_cfg_params[MMU_CFG_PARAM_MAX]; ++ ++/* ++ * Allocate and initialise the default translation context for the software ++ * image currently executing. ++ */ ++REGISTER_XLAT_CONTEXT(tf, MAX_MMAP_REGIONS, MAX_XLAT_TABLES, ++ PLAT_VIRT_ADDR_SPACE_SIZE, PLAT_PHY_ADDR_SPACE_SIZE); ++ ++void mmap_add_region(unsigned long long base_pa, uintptr_t base_va, size_t size, ++ unsigned int attr) ++{ ++ mmap_region_t mm = MAP_REGION(base_pa, base_va, size, attr); ++ ++ mmap_add_region_ctx(&tf_xlat_ctx, &mm); ++} ++ ++void mmap_add(const mmap_region_t *mm) ++{ ++ mmap_add_ctx(&tf_xlat_ctx, mm); ++} ++ ++void mmap_add_region_alloc_va(unsigned long long base_pa, uintptr_t *base_va, ++ size_t size, unsigned int attr) ++{ ++ mmap_region_t mm = MAP_REGION_ALLOC_VA(base_pa, size, attr); ++ ++ mmap_add_region_alloc_va_ctx(&tf_xlat_ctx, &mm); ++ ++ *base_va = mm.base_va; ++} ++ ++void mmap_add_alloc_va(mmap_region_t *mm) ++{ ++ while (mm->granularity != 0U) { ++ assert(mm->base_va == 0U); ++ mmap_add_region_alloc_va_ctx(&tf_xlat_ctx, mm); ++ mm++; ++ } ++} ++ ++#if PLAT_XLAT_TABLES_DYNAMIC ++ ++int mmap_add_dynamic_region(unsigned long long base_pa, uintptr_t base_va, ++ size_t size, unsigned int attr) ++{ ++ mmap_region_t mm = MAP_REGION(base_pa, base_va, size, attr); ++ ++ return mmap_add_dynamic_region_ctx(&tf_xlat_ctx, &mm); ++} ++ ++int mmap_add_dynamic_region_alloc_va(unsigned long long base_pa, ++ uintptr_t *base_va, size_t size, ++ unsigned int attr) ++{ ++ mmap_region_t mm = MAP_REGION_ALLOC_VA(base_pa, size, attr); ++ ++ int rc = mmap_add_dynamic_region_alloc_va_ctx(&tf_xlat_ctx, &mm); ++ ++ *base_va = mm.base_va; ++ ++ return rc; ++} ++ ++ ++int mmap_remove_dynamic_region(uintptr_t base_va, size_t size) ++{ ++ return mmap_remove_dynamic_region_ctx(&tf_xlat_ctx, ++ base_va, size); ++} ++ ++#endif /* PLAT_XLAT_TABLES_DYNAMIC */ ++ ++void __init init_xlat_tables(void) ++{ ++ assert(tf_xlat_ctx.xlat_regime == EL_REGIME_INVALID); ++ ++ unsigned int current_el = xlat_arch_current_el(); ++ ++ if (current_el == 1U) { ++ tf_xlat_ctx.xlat_regime = EL1_EL0_REGIME; ++ } else if (current_el == 2U) { ++ tf_xlat_ctx.xlat_regime = EL2_REGIME; ++ } else { ++ assert(current_el == 3U); ++ tf_xlat_ctx.xlat_regime = EL3_REGIME; ++ } ++ ++ init_xlat_tables_ctx(&tf_xlat_ctx); ++} ++ ++int xlat_get_mem_attributes(uintptr_t base_va, uint32_t *attr) ++{ ++ return xlat_get_mem_attributes_ctx(&tf_xlat_ctx, base_va, attr); ++} ++ ++int xlat_change_mem_attributes(uintptr_t base_va, size_t size, uint32_t attr) ++{ ++ return xlat_change_mem_attributes_ctx(&tf_xlat_ctx, base_va, size, attr); ++} ++ ++/* ++ * If dynamic allocation of new regions is disabled then by the time we call the ++ * function enabling the MMU, we'll have registered all the memory regions to ++ * map for the system's lifetime. Therefore, at this point we know the maximum ++ * physical address that will ever be mapped. ++ * ++ * If dynamic allocation is enabled then we can't make any such assumption ++ * because the maximum physical address could get pushed while adding a new ++ * region. Therefore, in this case we have to assume that the whole address ++ * space size might be mapped. ++ */ ++#ifdef PLAT_XLAT_TABLES_DYNAMIC ++#define MAX_PHYS_ADDR tf_xlat_ctx.pa_max_address ++#else ++#define MAX_PHYS_ADDR tf_xlat_ctx.max_pa ++#endif ++ ++#ifndef __aarch64__ ++ ++void enable_mmu_svc_mon(unsigned int flags) ++{ ++ setup_mmu_cfg((uint64_t *)&mmu_cfg_params, flags, ++ tf_xlat_ctx.base_table, MAX_PHYS_ADDR, ++ tf_xlat_ctx.va_max_address, EL1_EL0_REGIME); ++ enable_mmu_direct_svc_mon(flags); ++} ++ ++void enable_mmu_hyp(unsigned int flags) ++{ ++ setup_mmu_cfg((uint64_t *)&mmu_cfg_params, flags, ++ tf_xlat_ctx.base_table, MAX_PHYS_ADDR, ++ tf_xlat_ctx.va_max_address, EL2_REGIME); ++ enable_mmu_direct_hyp(flags); ++} ++ ++#else ++ ++void enable_mmu_el1(unsigned int flags) ++{ ++ setup_mmu_cfg((uint64_t *)&mmu_cfg_params, flags, ++ tf_xlat_ctx.base_table, MAX_PHYS_ADDR, ++ tf_xlat_ctx.va_max_address, EL1_EL0_REGIME); ++ enable_mmu_direct_el1(flags); ++} ++ ++void enable_mmu_el2(unsigned int flags) ++{ ++ setup_mmu_cfg((uint64_t *)&mmu_cfg_params, flags, ++ tf_xlat_ctx.base_table, MAX_PHYS_ADDR, ++ tf_xlat_ctx.va_max_address, EL2_REGIME); ++ enable_mmu_direct_el2(flags); ++} ++ ++void enable_mmu_el3(unsigned int flags) ++{ ++ setup_mmu_cfg((uint64_t *)&mmu_cfg_params, flags, ++ tf_xlat_ctx.base_table, MAX_PHYS_ADDR, ++ tf_xlat_ctx.va_max_address, EL3_REGIME); ++ enable_mmu_direct_el3(flags); ++} ++ ++#endif /* !__aarch64__ */ +diff --git a/environments/shim/lib/xlat_tables_v2/xlat_tables_core.c b/environments/shim/lib/xlat_tables_v2/xlat_tables_core.c +new file mode 100644 +index 0000000..c3dd445 +--- /dev/null ++++ b/environments/shim/lib/xlat_tables_v2/xlat_tables_core.c +@@ -0,0 +1,1226 @@ ++/* ++ * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "xlat_tables_private.h" ++ ++/* Helper function that cleans the data cache only if it is enabled. */ ++static inline __attribute__((unused)) void xlat_clean_dcache_range(uintptr_t addr, size_t size) ++{ ++ if (is_dcache_enabled()) ++ clean_dcache_range(addr, size); ++} ++ ++#if PLAT_XLAT_TABLES_DYNAMIC ++ ++/* ++ * The following functions assume that they will be called using subtables only. ++ * The base table can't be unmapped, so it is not needed to do any special ++ * handling for it. ++ */ ++ ++/* ++ * Returns the index of the array corresponding to the specified translation ++ * table. ++ */ ++static int xlat_table_get_index(const xlat_ctx_t *ctx, const uint64_t *table) ++{ ++ for (int i = 0; i < ctx->tables_num; i++) ++ if (ctx->tables[i] == table) ++ return i; ++ ++ /* ++ * Maybe we were asked to get the index of the base level table, which ++ * should never happen. ++ */ ++ assert(false); ++ ++ return -1; ++} ++ ++/* Returns a pointer to an empty translation table. */ ++static uint64_t *xlat_table_get_empty(const xlat_ctx_t *ctx) ++{ ++ for (int i = 0; i < ctx->tables_num; i++) ++ if (ctx->tables_mapped_regions[i] == 0) ++ return ctx->tables[i]; ++ ++ return NULL; ++} ++ ++/* Increments region count for a given table. */ ++static void xlat_table_inc_regions_count(const xlat_ctx_t *ctx, ++ const uint64_t *table) ++{ ++ int idx = xlat_table_get_index(ctx, table); ++ ++ ctx->tables_mapped_regions[idx]++; ++} ++ ++/* Decrements region count for a given table. */ ++static void xlat_table_dec_regions_count(const xlat_ctx_t *ctx, ++ const uint64_t *table) ++{ ++ int idx = xlat_table_get_index(ctx, table); ++ ++ ctx->tables_mapped_regions[idx]--; ++} ++ ++/* Returns 0 if the specified table isn't empty, otherwise 1. */ ++static bool xlat_table_is_empty(const xlat_ctx_t *ctx, const uint64_t *table) ++{ ++ return ctx->tables_mapped_regions[xlat_table_get_index(ctx, table)] == 0; ++} ++ ++#else /* PLAT_XLAT_TABLES_DYNAMIC */ ++ ++/* Returns a pointer to the first empty translation table. */ ++static uint64_t *xlat_table_get_empty(xlat_ctx_t *ctx) ++{ ++ assert(ctx->next_table < ctx->tables_num); ++ ++ return ctx->tables[ctx->next_table++]; ++} ++ ++#endif /* PLAT_XLAT_TABLES_DYNAMIC */ ++ ++/* ++ * Returns a block/page table descriptor for the given level and attributes. ++ */ ++uint64_t xlat_desc(const xlat_ctx_t *ctx, uint32_t attr, ++ unsigned long long addr_pa, unsigned int level) ++{ ++ uint64_t desc; ++ uint32_t mem_type; ++ ++ /* Make sure that the granularity is fine enough to map this address. */ ++ assert((addr_pa & XLAT_BLOCK_MASK(level)) == 0U); ++ ++ desc = addr_pa; ++ /* ++ * There are different translation table descriptors for level 3 and the ++ * rest. ++ */ ++ desc |= (level == XLAT_TABLE_LEVEL_MAX) ? PAGE_DESC : BLOCK_DESC; ++ /* ++ * Always set the access flag, as this library assumes access flag ++ * faults aren't managed. ++ */ ++ desc |= LOWER_ATTRS(ACCESS_FLAG); ++ /* ++ * Deduce other fields of the descriptor based on the MT_NS and MT_RW ++ * memory region attributes. ++ */ ++ desc |= ((attr & MT_NS) != 0U) ? LOWER_ATTRS(NS) : 0U; ++ desc |= ((attr & MT_RW) != 0U) ? LOWER_ATTRS(AP_RW) : LOWER_ATTRS(AP_RO); ++ ++ /* ++ * Do not allow unprivileged access when the mapping is for a privileged ++ * EL. For translation regimes that do not have mappings for access for ++ * lower exception levels, set AP[2] to AP_NO_ACCESS_UNPRIVILEGED. ++ */ ++ if (ctx->xlat_regime == EL1_EL0_REGIME) { ++ if ((attr & MT_USER) != 0U) { ++ /* EL0 mapping requested, so we give User access */ ++ desc |= LOWER_ATTRS(AP_ACCESS_UNPRIVILEGED); ++ } else { ++ /* EL1 mapping requested, no User access granted */ ++ desc |= LOWER_ATTRS(AP_NO_ACCESS_UNPRIVILEGED); ++ } ++ } else { ++ assert((ctx->xlat_regime == EL2_REGIME) || ++ (ctx->xlat_regime == EL3_REGIME)); ++ desc |= LOWER_ATTRS(AP_ONE_VA_RANGE_RES1); ++ } ++ ++ /* ++ * Deduce shareability domain and executability of the memory region ++ * from the memory type of the attributes (MT_TYPE). ++ * ++ * Data accesses to device memory and non-cacheable normal memory are ++ * coherent for all observers in the system, and correspondingly are ++ * always treated as being Outer Shareable. Therefore, for these 2 types ++ * of memory, it is not strictly needed to set the shareability field ++ * in the translation tables. ++ */ ++ mem_type = MT_TYPE(attr); ++ if (mem_type == MT_DEVICE) { ++ desc |= LOWER_ATTRS(ATTR_DEVICE_INDEX | OSH); ++ /* ++ * Always map device memory as execute-never. ++ * This is to avoid the possibility of a speculative instruction ++ * fetch, which could be an issue if this memory region ++ * corresponds to a read-sensitive peripheral. ++ */ ++ desc |= xlat_arch_regime_get_xn_desc(ctx->xlat_regime); ++ ++ } else { /* Normal memory */ ++ /* ++ * Always map read-write normal memory as execute-never. ++ * This library assumes that it is used by software that does ++ * not self-modify its code, therefore R/W memory is reserved ++ * for data storage, which must not be executable. ++ * ++ * Note that setting the XN bit here is for consistency only. ++ * The function that enables the MMU sets the SCTLR_ELx.WXN bit, ++ * which makes any writable memory region to be treated as ++ * execute-never, regardless of the value of the XN bit in the ++ * translation table. ++ * ++ * For read-only memory, rely on the MT_EXECUTE/MT_EXECUTE_NEVER ++ * attribute to figure out the value of the XN bit. The actual ++ * XN bit(s) to set in the descriptor depends on the context's ++ * translation regime and the policy applied in ++ * xlat_arch_regime_get_xn_desc(). ++ */ ++ if (((attr & MT_RW) != 0U) || ((attr & MT_EXECUTE_NEVER) != 0U)) { ++ desc |= xlat_arch_regime_get_xn_desc(ctx->xlat_regime); ++ } ++ ++ if (mem_type == MT_MEMORY) { ++ desc |= LOWER_ATTRS(ATTR_IWBWA_OWBWA_NTR_INDEX | ISH); ++#if ENABLE_BTI ++ /* Check if Branch Target Identification is implemented */ ++ if (is_armv8_5_bti_present() && ++ ((attr & (MT_TYPE_MASK | MT_RW | ++ MT_EXECUTE_NEVER)) == MT_CODE)) { ++ /* Set GP bit for block and page code entries */ ++ desc |= GP; ++ } ++#endif ++ } else { ++ assert(mem_type == MT_NON_CACHEABLE); ++ desc |= LOWER_ATTRS(ATTR_NON_CACHEABLE_INDEX | OSH); ++ } ++ } ++ ++ return desc; ++} ++ ++/* ++ * Enumeration of actions that can be made when mapping table entries depending ++ * on the previous value in that entry and information about the region being ++ * mapped. ++ */ ++typedef enum { ++ ++ /* Do nothing */ ++ ACTION_NONE, ++ ++ /* Write a block (or page, if in level 3) entry. */ ++ ACTION_WRITE_BLOCK_ENTRY, ++ ++ /* ++ * Create a new table and write a table entry pointing to it. Recurse ++ * into it for further processing. ++ */ ++ ACTION_CREATE_NEW_TABLE, ++ ++ /* ++ * There is a table descriptor in this entry, read it and recurse into ++ * that table for further processing. ++ */ ++ ACTION_RECURSE_INTO_TABLE, ++ ++} action_t; ++ ++/* ++ * Function that returns the first VA of the table affected by the specified ++ * mmap region. ++ */ ++static uintptr_t xlat_tables_find_start_va(mmap_region_t *mm, ++ const uintptr_t table_base_va, ++ const unsigned int level) ++{ ++ uintptr_t table_idx_va; ++ ++ if (mm->base_va > table_base_va) { ++ /* Find the first index of the table affected by the region. */ ++ table_idx_va = mm->base_va & ~XLAT_BLOCK_MASK(level); ++ } else { ++ /* Start from the beginning of the table. */ ++ table_idx_va = table_base_va; ++ } ++ ++ return table_idx_va; ++} ++ ++/* ++ * Function that returns table index for the given VA and level arguments. ++ */ ++static inline unsigned int xlat_tables_va_to_index(const uintptr_t table_base_va, ++ const uintptr_t va, ++ const unsigned int level) ++{ ++ return (unsigned int)((va - table_base_va) >> XLAT_ADDR_SHIFT(level)); ++} ++ ++#if PLAT_XLAT_TABLES_DYNAMIC ++ ++/* ++ * From the given arguments, it decides which action to take when unmapping the ++ * specified region. ++ */ ++static action_t xlat_tables_unmap_region_action(const mmap_region_t *mm, ++ const uintptr_t table_idx_va, const uintptr_t table_idx_end_va, ++ const unsigned int level, const uint64_t desc_type) ++{ ++ action_t action; ++ uintptr_t region_end_va = mm->base_va + mm->size - 1U; ++ ++ if ((mm->base_va <= table_idx_va) && ++ (region_end_va >= table_idx_end_va)) { ++ /* Region covers all block */ ++ ++ if (level == 3U) { ++ /* ++ * Last level, only page descriptors allowed, ++ * erase it. ++ */ ++ assert(desc_type == PAGE_DESC); ++ ++ action = ACTION_WRITE_BLOCK_ENTRY; ++ } else { ++ /* ++ * Other levels can have table descriptors. If ++ * so, recurse into it and erase descriptors ++ * inside it as needed. If there is a block ++ * descriptor, just erase it. If an invalid ++ * descriptor is found, this table isn't ++ * actually mapped, which shouldn't happen. ++ */ ++ if (desc_type == TABLE_DESC) { ++ action = ACTION_RECURSE_INTO_TABLE; ++ } else { ++ assert(desc_type == BLOCK_DESC); ++ action = ACTION_WRITE_BLOCK_ENTRY; ++ } ++ } ++ ++ } else if ((mm->base_va <= table_idx_end_va) || ++ (region_end_va >= table_idx_va)) { ++ /* ++ * Region partially covers block. ++ * ++ * It can't happen in level 3. ++ * ++ * There must be a table descriptor here, if not there ++ * was a problem when mapping the region. ++ */ ++ assert(level < 3U); ++ assert(desc_type == TABLE_DESC); ++ ++ action = ACTION_RECURSE_INTO_TABLE; ++ } else { ++ /* The region doesn't cover the block at all */ ++ action = ACTION_NONE; ++ } ++ ++ return action; ++} ++/* ++ * Recursive function that writes to the translation tables and unmaps the ++ * specified region. ++ */ ++static void xlat_tables_unmap_region(xlat_ctx_t *ctx, mmap_region_t *mm, ++ const uintptr_t table_base_va, ++ uint64_t *const table_base, ++ const unsigned int table_entries, ++ const unsigned int level) ++{ ++ assert((level >= ctx->base_level) && (level <= XLAT_TABLE_LEVEL_MAX)); ++ ++ uint64_t *subtable; ++ uint64_t desc; ++ ++ uintptr_t table_idx_va; ++ uintptr_t table_idx_end_va; /* End VA of this entry */ ++ ++ uintptr_t region_end_va = mm->base_va + mm->size - 1U; ++ ++ unsigned int table_idx; ++ ++ table_idx_va = xlat_tables_find_start_va(mm, table_base_va, level); ++ table_idx = xlat_tables_va_to_index(table_base_va, table_idx_va, level); ++ ++ while (table_idx < table_entries) { ++ ++ table_idx_end_va = table_idx_va + XLAT_BLOCK_SIZE(level) - 1U; ++ ++ desc = table_base[table_idx]; ++ uint64_t desc_type = desc & DESC_MASK; ++ ++ action_t action = xlat_tables_unmap_region_action(mm, ++ table_idx_va, table_idx_end_va, level, ++ desc_type); ++ ++ if (action == ACTION_WRITE_BLOCK_ENTRY) { ++ ++ table_base[table_idx] = INVALID_DESC; ++ xlat_arch_tlbi_va(table_idx_va, ctx->xlat_regime); ++ ++ } else if (action == ACTION_RECURSE_INTO_TABLE) { ++ ++ subtable = (uint64_t *)(uintptr_t)(desc & TABLE_ADDR_MASK); ++ ++ /* Recurse to write into subtable */ ++ xlat_tables_unmap_region(ctx, mm, table_idx_va, ++ subtable, XLAT_TABLE_ENTRIES, ++ level + 1U); ++#if !(HW_ASSISTED_COHERENCY || WARMBOOT_ENABLE_DCACHE_EARLY) ++ xlat_clean_dcache_range((uintptr_t)subtable, ++ XLAT_TABLE_ENTRIES * sizeof(uint64_t)); ++#endif ++ /* ++ * If the subtable is now empty, remove its reference. ++ */ ++ if (xlat_table_is_empty(ctx, subtable)) { ++ table_base[table_idx] = INVALID_DESC; ++ xlat_arch_tlbi_va(table_idx_va, ++ ctx->xlat_regime); ++ } ++ ++ } else { ++ assert(action == ACTION_NONE); ++ } ++ ++ table_idx++; ++ table_idx_va += XLAT_BLOCK_SIZE(level); ++ ++ /* If reached the end of the region, exit */ ++ if (region_end_va <= table_idx_va) ++ break; ++ } ++ ++ if (level > ctx->base_level) ++ xlat_table_dec_regions_count(ctx, table_base); ++} ++ ++#endif /* PLAT_XLAT_TABLES_DYNAMIC */ ++ ++/* ++ * From the given arguments, it decides which action to take when mapping the ++ * specified region. ++ */ ++static action_t xlat_tables_map_region_action(const mmap_region_t *mm, ++ unsigned int desc_type, unsigned long long dest_pa, ++ uintptr_t table_entry_base_va, unsigned int level) ++{ ++ uintptr_t mm_end_va = mm->base_va + mm->size - 1U; ++ uintptr_t table_entry_end_va = ++ table_entry_base_va + XLAT_BLOCK_SIZE(level) - 1U; ++ ++ /* ++ * The descriptor types allowed depend on the current table level. ++ */ ++ ++ if ((mm->base_va <= table_entry_base_va) && ++ (mm_end_va >= table_entry_end_va)) { ++ ++ /* ++ * Table entry is covered by region ++ * -------------------------------- ++ * ++ * This means that this table entry can describe the whole ++ * translation with this granularity in principle. ++ */ ++ ++ if (level == 3U) { ++ /* ++ * Last level, only page descriptors are allowed. ++ */ ++ if (desc_type == PAGE_DESC) { ++ /* ++ * There's another region mapped here, don't ++ * overwrite. ++ */ ++ return ACTION_NONE; ++ } else { ++ assert(desc_type == INVALID_DESC); ++ return ACTION_WRITE_BLOCK_ENTRY; ++ } ++ ++ } else { ++ ++ /* ++ * Other levels. Table descriptors are allowed. Block ++ * descriptors too, but they have some limitations. ++ */ ++ ++ if (desc_type == TABLE_DESC) { ++ /* There's already a table, recurse into it. */ ++ return ACTION_RECURSE_INTO_TABLE; ++ ++ } else if (desc_type == INVALID_DESC) { ++ /* ++ * There's nothing mapped here, create a new ++ * entry. ++ * ++ * Check if the destination granularity allows ++ * us to use a block descriptor or we need a ++ * finer table for it. ++ * ++ * Also, check if the current level allows block ++ * descriptors. If not, create a table instead. ++ */ ++ if (((dest_pa & XLAT_BLOCK_MASK(level)) != 0U) ++ || (level < MIN_LVL_BLOCK_DESC) || ++ (mm->granularity < XLAT_BLOCK_SIZE(level))) ++ return ACTION_CREATE_NEW_TABLE; ++ else ++ return ACTION_WRITE_BLOCK_ENTRY; ++ ++ } else { ++ /* ++ * There's another region mapped here, don't ++ * overwrite. ++ */ ++ assert(desc_type == BLOCK_DESC); ++ ++ return ACTION_NONE; ++ } ++ } ++ ++ } else if ((mm->base_va <= table_entry_end_va) || ++ (mm_end_va >= table_entry_base_va)) { ++ ++ /* ++ * Region partially covers table entry ++ * ----------------------------------- ++ * ++ * This means that this table entry can't describe the whole ++ * translation, a finer table is needed. ++ ++ * There cannot be partial block overlaps in level 3. If that ++ * happens, some of the preliminary checks when adding the ++ * mmap region failed to detect that PA and VA must at least be ++ * aligned to PAGE_SIZE. ++ */ ++ assert(level < 3U); ++ ++ if (desc_type == INVALID_DESC) { ++ /* ++ * The block is not fully covered by the region. Create ++ * a new table, recurse into it and try to map the ++ * region with finer granularity. ++ */ ++ return ACTION_CREATE_NEW_TABLE; ++ ++ } else { ++ assert(desc_type == TABLE_DESC); ++ /* ++ * The block is not fully covered by the region, but ++ * there is already a table here. Recurse into it and ++ * try to map with finer granularity. ++ * ++ * PAGE_DESC for level 3 has the same value as ++ * TABLE_DESC, but this code can't run on a level 3 ++ * table because there can't be overlaps in level 3. ++ */ ++ return ACTION_RECURSE_INTO_TABLE; ++ } ++ } else { ++ ++ /* ++ * This table entry is outside of the region specified in the ++ * arguments, don't write anything to it. ++ */ ++ return ACTION_NONE; ++ } ++} ++ ++/* ++ * Recursive function that writes to the translation tables and maps the ++ * specified region. On success, it returns the VA of the last byte that was ++ * successfully mapped. On error, it returns the VA of the next entry that ++ * should have been mapped. ++ */ ++static uintptr_t xlat_tables_map_region(xlat_ctx_t *ctx, mmap_region_t *mm, ++ uintptr_t table_base_va, ++ uint64_t *const table_base, ++ unsigned int table_entries, ++ unsigned int level) ++{ ++ assert((level >= ctx->base_level) && (level <= XLAT_TABLE_LEVEL_MAX)); ++ ++ uintptr_t mm_end_va = mm->base_va + mm->size - 1U; ++ ++ uintptr_t table_idx_va; ++ unsigned long long table_idx_pa; ++ ++ uint64_t *subtable; ++ uint64_t desc; ++ ++ unsigned int table_idx; ++ ++ table_idx_va = xlat_tables_find_start_va(mm, table_base_va, level); ++ table_idx = xlat_tables_va_to_index(table_base_va, table_idx_va, level); ++ ++#if PLAT_XLAT_TABLES_DYNAMIC ++ if (level > ctx->base_level) ++ xlat_table_inc_regions_count(ctx, table_base); ++#endif ++ ++ while (table_idx < table_entries) { ++ ++ desc = table_base[table_idx]; ++ ++ table_idx_pa = mm->base_pa + table_idx_va - mm->base_va; ++ ++ action_t action = xlat_tables_map_region_action(mm, ++ (uint32_t)(desc & DESC_MASK), table_idx_pa, ++ table_idx_va, level); ++ ++ if (action == ACTION_WRITE_BLOCK_ENTRY) { ++ ++ table_base[table_idx] = ++ xlat_desc(ctx, (uint32_t)mm->attr, table_idx_pa, ++ level); ++ ++ } else if (action == ACTION_CREATE_NEW_TABLE) { ++ uintptr_t end_va; ++ ++ subtable = xlat_table_get_empty(ctx); ++ if (subtable == NULL) { ++ /* Not enough free tables to map this region */ ++ return table_idx_va; ++ } ++ ++ /* Point to new subtable from this one. */ ++ table_base[table_idx] = TABLE_DESC | (unsigned long)subtable; ++ ++ /* Recurse to write into subtable */ ++ end_va = xlat_tables_map_region(ctx, mm, table_idx_va, ++ subtable, XLAT_TABLE_ENTRIES, ++ level + 1U); ++#if !(HW_ASSISTED_COHERENCY || WARMBOOT_ENABLE_DCACHE_EARLY) ++ xlat_clean_dcache_range((uintptr_t)subtable, ++ XLAT_TABLE_ENTRIES * sizeof(uint64_t)); ++#endif ++ if (end_va != ++ (table_idx_va + XLAT_BLOCK_SIZE(level) - 1U)) ++ return end_va; ++ ++ } else if (action == ACTION_RECURSE_INTO_TABLE) { ++ uintptr_t end_va; ++ ++ subtable = (uint64_t *)(uintptr_t)(desc & TABLE_ADDR_MASK); ++ /* Recurse to write into subtable */ ++ end_va = xlat_tables_map_region(ctx, mm, table_idx_va, ++ subtable, XLAT_TABLE_ENTRIES, ++ level + 1U); ++#if !(HW_ASSISTED_COHERENCY || WARMBOOT_ENABLE_DCACHE_EARLY) ++ xlat_clean_dcache_range((uintptr_t)subtable, ++ XLAT_TABLE_ENTRIES * sizeof(uint64_t)); ++#endif ++ if (end_va != ++ (table_idx_va + XLAT_BLOCK_SIZE(level) - 1U)) ++ return end_va; ++ ++ } else { ++ ++ assert(action == ACTION_NONE); ++ ++ } ++ ++ table_idx++; ++ table_idx_va += XLAT_BLOCK_SIZE(level); ++ ++ /* If reached the end of the region, exit */ ++ if (mm_end_va <= table_idx_va) ++ break; ++ } ++ ++ return table_idx_va - 1U; ++} ++ ++/* ++ * Function that verifies that a region can be mapped. ++ * Returns: ++ * 0: Success, the mapping is allowed. ++ * EINVAL: Invalid values were used as arguments. ++ * ERANGE: The memory limits were surpassed. ++ * ENOMEM: There is not enough memory in the mmap array. ++ * EPERM: Region overlaps another one in an invalid way. ++ */ ++static int mmap_add_region_check(const xlat_ctx_t *ctx, const mmap_region_t *mm) ++{ ++ unsigned long long base_pa = mm->base_pa; ++ uintptr_t base_va = mm->base_va; ++ size_t size = mm->size; ++ size_t granularity = mm->granularity; ++ ++ unsigned long long end_pa = base_pa + size - 1U; ++ uintptr_t end_va = base_va + size - 1U; ++ ++ if (!IS_PAGE_ALIGNED(base_pa) || !IS_PAGE_ALIGNED(base_va) || ++ !IS_PAGE_ALIGNED(size)) ++ return -EINVAL; ++ ++ if ((granularity != XLAT_BLOCK_SIZE(1U)) && ++ (granularity != XLAT_BLOCK_SIZE(2U)) && ++ (granularity != XLAT_BLOCK_SIZE(3U))) { ++ return -EINVAL; ++ } ++ ++ /* Check for overflows */ ++ if ((base_pa > end_pa) || (base_va > end_va)) ++ return -ERANGE; ++ ++ if ((base_va + (uintptr_t)size - (uintptr_t)1) > ctx->va_max_address) ++ return -ERANGE; ++ ++ if ((base_pa + (unsigned long long)size - 1ULL) > ctx->pa_max_address) ++ return -ERANGE; ++ ++ /* Check that there is space in the ctx->mmap array */ ++ if (ctx->mmap[ctx->mmap_num - 1].size != 0U) ++ return -ENOMEM; ++ ++ /* Check for PAs and VAs overlaps with all other regions */ ++ for (const mmap_region_t *mm_cursor = ctx->mmap; ++ mm_cursor->size != 0U; ++mm_cursor) { ++ ++ uintptr_t mm_cursor_end_va = mm_cursor->base_va ++ + mm_cursor->size - 1U; ++ ++ /* ++ * Check if one of the regions is completely inside the other ++ * one. ++ */ ++ bool fully_overlapped_va = ++ ((base_va >= mm_cursor->base_va) && ++ (end_va <= mm_cursor_end_va)) || ++ ((mm_cursor->base_va >= base_va) && ++ (mm_cursor_end_va <= end_va)); ++ ++ /* ++ * Full VA overlaps are only allowed if both regions are ++ * identity mapped (zero offset) or have the same VA to PA ++ * offset. Also, make sure that it's not the exact same area. ++ * This can only be done with static regions. ++ */ ++ if (fully_overlapped_va) { ++ ++#if PLAT_XLAT_TABLES_DYNAMIC ++ if (((mm->attr & MT_DYNAMIC) != 0U) || ++ ((mm_cursor->attr & MT_DYNAMIC) != 0U)) ++ return -EPERM; ++#endif /* PLAT_XLAT_TABLES_DYNAMIC */ ++ if ((mm_cursor->base_va - mm_cursor->base_pa) != ++ (base_va - base_pa)) ++ return -EPERM; ++ ++ if ((base_va == mm_cursor->base_va) && ++ (size == mm_cursor->size)) ++ return -EPERM; ++ ++ } else { ++ /* ++ * If the regions do not have fully overlapping VAs, ++ * then they must have fully separated VAs and PAs. ++ * Partial overlaps are not allowed ++ */ ++ ++ unsigned long long mm_cursor_end_pa = ++ mm_cursor->base_pa + mm_cursor->size - 1U; ++ ++ bool separated_pa = (end_pa < mm_cursor->base_pa) || ++ (base_pa > mm_cursor_end_pa); ++ bool separated_va = (end_va < mm_cursor->base_va) || ++ (base_va > mm_cursor_end_va); ++ ++ if (!separated_va || !separated_pa) ++ return -EPERM; ++ } ++ } ++ ++ return 0; ++} ++ ++void mmap_add_region_ctx(xlat_ctx_t *ctx, const mmap_region_t *mm) ++{ ++ mmap_region_t *mm_cursor = ctx->mmap, *mm_destination; ++ const mmap_region_t *mm_end = ctx->mmap + ctx->mmap_num; ++ const mmap_region_t *mm_last; ++ unsigned long long end_pa = mm->base_pa + mm->size - 1U; ++ uintptr_t end_va = mm->base_va + mm->size - 1U; ++ int ret; ++ ++ /* Ignore empty regions */ ++ if (mm->size == 0U) ++ return; ++ ++ /* Static regions must be added before initializing the xlat tables. */ ++ assert(!ctx->initialized); ++ ++ ret = mmap_add_region_check(ctx, mm); ++ if (ret != 0) { ++ ERROR("mmap_add_region_check() failed. error %d\n", ret); ++ assert(false); ++ return; ++ } ++ ++ /* ++ * Find correct place in mmap to insert new region. ++ * ++ * 1 - Lower region VA end first. ++ * 2 - Smaller region size first. ++ * ++ * VA 0 0xFF ++ * ++ * 1st |------| ++ * 2nd |------------| ++ * 3rd |------| ++ * 4th |---| ++ * 5th |---| ++ * 6th |----------| ++ * 7th |-------------------------------------| ++ * ++ * This is required for overlapping regions only. It simplifies adding ++ * regions with the loop in xlat_tables_init_internal because the outer ++ * ones won't overwrite block or page descriptors of regions added ++ * previously. ++ * ++ * Overlapping is only allowed for static regions. ++ */ ++ ++ while (((mm_cursor->base_va + mm_cursor->size - 1U) < end_va) ++ && (mm_cursor->size != 0U)) { ++ ++mm_cursor; ++ } ++ ++ while (((mm_cursor->base_va + mm_cursor->size - 1U) == end_va) && ++ (mm_cursor->size != 0U) && (mm_cursor->size < mm->size)) { ++ ++mm_cursor; ++ } ++ ++ /* ++ * Find the last entry marker in the mmap ++ */ ++ mm_last = ctx->mmap; ++ while ((mm_last->size != 0U) && (mm_last < mm_end)) { ++ ++mm_last; ++ } ++ ++ /* ++ * Check if we have enough space in the memory mapping table. ++ * This shouldn't happen as we have checked in mmap_add_region_check ++ * that there is free space. ++ */ ++ assert(mm_last->size == 0U); ++ ++ /* Make room for new region by moving other regions up by one place */ ++ mm_destination = mm_cursor + 1; ++ (void)memmove(mm_destination, mm_cursor, ++ (uintptr_t)mm_last - (uintptr_t)mm_cursor); ++ ++ /* ++ * Check we haven't lost the empty sentinel from the end of the array. ++ * This shouldn't happen as we have checked in mmap_add_region_check ++ * that there is free space. ++ */ ++ assert(mm_end->size == 0U); ++ ++ *mm_cursor = *mm; ++ ++ if (end_pa > ctx->max_pa) ++ ctx->max_pa = end_pa; ++ if (end_va > ctx->max_va) ++ ctx->max_va = end_va; ++} ++ ++/* ++ * Determine the table level closest to the initial lookup level that ++ * can describe this translation. Then, align base VA to the next block ++ * at the determined level. ++ */ ++static void mmap_alloc_va_align_ctx(xlat_ctx_t *ctx, mmap_region_t *mm) ++{ ++ /* ++ * By or'ing the size and base PA the alignment will be the one ++ * corresponding to the smallest boundary of the two of them. ++ * ++ * There are three different cases. For example (for 4 KiB page size): ++ * ++ * +--------------+------------------++--------------+ ++ * | PA alignment | Size multiple of || VA alignment | ++ * +--------------+------------------++--------------+ ++ * | 2 MiB | 2 MiB || 2 MiB | (1) ++ * | 2 MiB | 4 KiB || 4 KiB | (2) ++ * | 4 KiB | 2 MiB || 4 KiB | (3) ++ * +--------------+------------------++--------------+ ++ * ++ * - In (1), it is possible to take advantage of the alignment of the PA ++ * and the size of the region to use a level 2 translation table ++ * instead of a level 3 one. ++ * ++ * - In (2), the size is smaller than a block entry of level 2, so it is ++ * needed to use a level 3 table to describe the region or the library ++ * will map more memory than the desired one. ++ * ++ * - In (3), even though the region has the size of one level 2 block ++ * entry, it isn't possible to describe the translation with a level 2 ++ * block entry because of the alignment of the base PA. ++ * ++ * Only bits 47:21 of a level 2 block descriptor are used by the MMU, ++ * bits 20:0 of the resulting address are 0 in this case. Because of ++ * this, the PA generated as result of this translation is aligned to ++ * 2 MiB. The PA that was requested to be mapped is aligned to 4 KiB, ++ * though, which means that the resulting translation is incorrect. ++ * The only way to prevent this is by using a finer granularity. ++ */ ++ unsigned long long align_check; ++ ++ align_check = mm->base_pa | (unsigned long long)mm->size; ++ ++ /* ++ * Assume it is always aligned to level 3. There's no need to check that ++ * level because its block size is PAGE_SIZE. The checks to verify that ++ * the addresses and size are aligned to PAGE_SIZE are inside ++ * mmap_add_region. ++ */ ++ for (unsigned int level = ctx->base_level; level <= 2U; ++level) { ++ ++ if ((align_check & XLAT_BLOCK_MASK(level)) != 0U) ++ continue; ++ ++ mm->base_va = round_up(mm->base_va, XLAT_BLOCK_SIZE(level)); ++ return; ++ } ++} ++ ++void mmap_add_region_alloc_va_ctx(xlat_ctx_t *ctx, mmap_region_t *mm) ++{ ++ mm->base_va = ctx->max_va + 1UL; ++ ++ assert(mm->size > 0U); ++ ++ mmap_alloc_va_align_ctx(ctx, mm); ++ ++ /* Detect overflows. More checks are done in mmap_add_region_check(). */ ++ assert(mm->base_va > ctx->max_va); ++ ++ mmap_add_region_ctx(ctx, mm); ++} ++ ++void mmap_add_ctx(xlat_ctx_t *ctx, const mmap_region_t *mm) ++{ ++ const mmap_region_t *mm_cursor = mm; ++ ++ while (mm_cursor->granularity != 0U) { ++ mmap_add_region_ctx(ctx, mm_cursor); ++ mm_cursor++; ++ } ++} ++ ++#if PLAT_XLAT_TABLES_DYNAMIC ++ ++int mmap_add_dynamic_region_ctx(xlat_ctx_t *ctx, mmap_region_t *mm) ++{ ++ mmap_region_t *mm_cursor = ctx->mmap; ++ const mmap_region_t *mm_last = mm_cursor + ctx->mmap_num; ++ unsigned long long end_pa = mm->base_pa + mm->size - 1U; ++ uintptr_t end_va = mm->base_va + mm->size - 1U; ++ int ret; ++ ++ /* Nothing to do */ ++ if (mm->size == 0U) ++ return 0; ++ ++ /* Now this region is a dynamic one */ ++ mm->attr |= MT_DYNAMIC; ++ ++ ret = mmap_add_region_check(ctx, mm); ++ if (ret != 0) ++ return ret; ++ ++ /* ++ * Find the adequate entry in the mmap array in the same way done for ++ * static regions in mmap_add_region_ctx(). ++ */ ++ ++ while (((mm_cursor->base_va + mm_cursor->size - 1U) < end_va) ++ && (mm_cursor->size != 0U)) { ++ ++mm_cursor; ++ } ++ ++ while (((mm_cursor->base_va + mm_cursor->size - 1U) == end_va) && ++ (mm_cursor->size != 0U) && (mm_cursor->size < mm->size)) { ++ ++mm_cursor; ++ } ++ ++ /* Make room for new region by moving other regions up by one place */ ++ (void)memmove(mm_cursor + 1U, mm_cursor, ++ (uintptr_t)mm_last - (uintptr_t)mm_cursor); ++ ++ /* ++ * Check we haven't lost the empty sentinal from the end of the array. ++ * This shouldn't happen as we have checked in mmap_add_region_check ++ * that there is free space. ++ */ ++ assert(mm_last->size == 0U); ++ ++ *mm_cursor = *mm; ++ ++ /* ++ * Update the translation tables if the xlat tables are initialized. If ++ * not, this region will be mapped when they are initialized. ++ */ ++ if (ctx->initialized) { ++ end_va = xlat_tables_map_region(ctx, mm_cursor, ++ 0U, ctx->base_table, ctx->base_table_entries, ++ ctx->base_level); ++#if !(HW_ASSISTED_COHERENCY || WARMBOOT_ENABLE_DCACHE_EARLY) ++ xlat_clean_dcache_range((uintptr_t)ctx->base_table, ++ ctx->base_table_entries * sizeof(uint64_t)); ++#endif ++ /* Failed to map, remove mmap entry, unmap and return error. */ ++ if (end_va != (mm_cursor->base_va + mm_cursor->size - 1U)) { ++ (void)memmove(mm_cursor, mm_cursor + 1U, ++ (uintptr_t)mm_last - (uintptr_t)mm_cursor); ++ ++ /* ++ * Check if the mapping function actually managed to map ++ * anything. If not, just return now. ++ */ ++ if (mm->base_va >= end_va) ++ return -ENOMEM; ++ ++ /* ++ * Something went wrong after mapping some table ++ * entries, undo every change done up to this point. ++ */ ++ mmap_region_t unmap_mm = { ++ .base_pa = 0U, ++ .base_va = mm->base_va, ++ .size = end_va - mm->base_va, ++ .attr = 0U ++ }; ++ xlat_tables_unmap_region(ctx, &unmap_mm, 0U, ++ ctx->base_table, ctx->base_table_entries, ++ ctx->base_level); ++#if !(HW_ASSISTED_COHERENCY || WARMBOOT_ENABLE_DCACHE_EARLY) ++ xlat_clean_dcache_range((uintptr_t)ctx->base_table, ++ ctx->base_table_entries * sizeof(uint64_t)); ++#endif ++ return -ENOMEM; ++ } ++ ++ /* ++ * Make sure that all entries are written to the memory. There ++ * is no need to invalidate entries when mapping dynamic regions ++ * because new table/block/page descriptors only replace old ++ * invalid descriptors, that aren't TLB cached. ++ */ ++ dsbishst(); ++ } ++ ++ if (end_pa > ctx->max_pa) ++ ctx->max_pa = end_pa; ++ if (end_va > ctx->max_va) ++ ctx->max_va = end_va; ++ ++ return 0; ++} ++ ++int mmap_add_dynamic_region_alloc_va_ctx(xlat_ctx_t *ctx, mmap_region_t *mm) ++{ ++ mm->base_va = ctx->max_va + 1UL; ++ ++ if (mm->size == 0U) ++ return 0; ++ ++ mmap_alloc_va_align_ctx(ctx, mm); ++ ++ /* Detect overflows. More checks are done in mmap_add_region_check(). */ ++ if (mm->base_va < ctx->max_va) { ++ return -ENOMEM; ++ } ++ ++ return mmap_add_dynamic_region_ctx(ctx, mm); ++} ++ ++/* ++ * Removes the region with given base Virtual Address and size from the given ++ * context. ++ * ++ * Returns: ++ * 0: Success. ++ * EINVAL: Invalid values were used as arguments (region not found). ++ * EPERM: Tried to remove a static region. ++ */ ++int mmap_remove_dynamic_region_ctx(xlat_ctx_t *ctx, uintptr_t base_va, ++ size_t size) ++{ ++ mmap_region_t *mm = ctx->mmap; ++ const mmap_region_t *mm_last = mm + ctx->mmap_num; ++ int update_max_va_needed = 0; ++ int update_max_pa_needed = 0; ++ ++ /* Check sanity of mmap array. */ ++ assert(mm[ctx->mmap_num].size == 0U); ++ ++ while (mm->size != 0U) { ++ if ((mm->base_va == base_va) && (mm->size == size)) ++ break; ++ ++mm; ++ } ++ ++ /* Check that the region was found */ ++ if (mm->size == 0U) ++ return -EINVAL; ++ ++ /* If the region is static it can't be removed */ ++ if ((mm->attr & MT_DYNAMIC) == 0U) ++ return -EPERM; ++ ++ /* Check if this region is using the top VAs or PAs. */ ++ if ((mm->base_va + mm->size - 1U) == ctx->max_va) ++ update_max_va_needed = 1; ++ if ((mm->base_pa + mm->size - 1U) == ctx->max_pa) ++ update_max_pa_needed = 1; ++ ++ /* Update the translation tables if needed */ ++ if (ctx->initialized) { ++ xlat_tables_unmap_region(ctx, mm, 0U, ctx->base_table, ++ ctx->base_table_entries, ++ ctx->base_level); ++#if !(HW_ASSISTED_COHERENCY || WARMBOOT_ENABLE_DCACHE_EARLY) ++ xlat_clean_dcache_range((uintptr_t)ctx->base_table, ++ ctx->base_table_entries * sizeof(uint64_t)); ++#endif ++ xlat_arch_tlbi_va_sync(); ++ } ++ ++ /* Remove this region by moving the rest down by one place. */ ++ (void)memmove(mm, mm + 1U, (uintptr_t)mm_last - (uintptr_t)mm); ++ ++ /* Check if we need to update the max VAs and PAs */ ++ if (update_max_va_needed == 1) { ++ ctx->max_va = 0U; ++ mm = ctx->mmap; ++ while (mm->size != 0U) { ++ if ((mm->base_va + mm->size - 1U) > ctx->max_va) ++ ctx->max_va = mm->base_va + mm->size - 1U; ++ ++mm; ++ } ++ } ++ ++ if (update_max_pa_needed == 1) { ++ ctx->max_pa = 0U; ++ mm = ctx->mmap; ++ while (mm->size != 0U) { ++ if ((mm->base_pa + mm->size - 1U) > ctx->max_pa) ++ ctx->max_pa = mm->base_pa + mm->size - 1U; ++ ++mm; ++ } ++ } ++ ++ return 0; ++} ++ ++void xlat_setup_dynamic_ctx(xlat_ctx_t *ctx, unsigned long long pa_max, ++ uintptr_t va_max, struct mmap_region *mmap, ++ unsigned int mmap_num, uint64_t **tables, ++ unsigned int tables_num, uint64_t *base_table, ++ int xlat_regime, int *mapped_regions) ++{ ++ ctx->xlat_regime = xlat_regime; ++ ++ ctx->pa_max_address = pa_max; ++ ctx->va_max_address = va_max; ++ ++ ctx->mmap = mmap; ++ ctx->mmap_num = mmap_num; ++ memset(ctx->mmap, 0, sizeof(struct mmap_region) * mmap_num); ++ ++ ctx->tables = (void *) tables; ++ ctx->tables_num = tables_num; ++ ++ uintptr_t va_space_size = va_max + 1; ++ ctx->base_level = GET_XLAT_TABLE_LEVEL_BASE(va_space_size); ++ ctx->base_table = base_table; ++ ctx->base_table_entries = GET_NUM_BASE_LEVEL_ENTRIES(va_space_size); ++ ++ ctx->tables_mapped_regions = mapped_regions; ++ ++ ctx->max_pa = 0; ++ ctx->max_va = 0; ++ ctx->initialized = 0; ++} ++ ++#endif /* PLAT_XLAT_TABLES_DYNAMIC */ ++ ++void __init init_xlat_tables_ctx(xlat_ctx_t *ctx) ++{ ++ assert(ctx != NULL); ++ assert(!ctx->initialized); ++ assert((ctx->xlat_regime == EL3_REGIME) || ++ (ctx->xlat_regime == EL2_REGIME) || ++ (ctx->xlat_regime == EL1_EL0_REGIME)); ++ assert(!is_mmu_enabled_ctx(ctx)); ++ ++ mmap_region_t *mm = ctx->mmap; ++ ++ assert(ctx->va_max_address >= ++ (xlat_get_min_virt_addr_space_size() - 1U)); ++ assert(ctx->va_max_address <= (MAX_VIRT_ADDR_SPACE_SIZE - 1U)); ++ assert(IS_POWER_OF_TWO(ctx->va_max_address + 1U)); ++ ++ xlat_mmap_print(mm); ++ ++ /* All tables must be zeroed before mapping any region. */ ++ ++ for (unsigned int i = 0U; i < ctx->base_table_entries; i++) ++ ctx->base_table[i] = INVALID_DESC; ++ ++ for (int j = 0; j < ctx->tables_num; j++) { ++#if PLAT_XLAT_TABLES_DYNAMIC ++ ctx->tables_mapped_regions[j] = 0; ++#endif ++ for (unsigned int i = 0U; i < XLAT_TABLE_ENTRIES; i++) ++ ctx->tables[j][i] = INVALID_DESC; ++ } ++ ++ while (mm->size != 0U) { ++ uintptr_t end_va = xlat_tables_map_region(ctx, mm, 0U, ++ ctx->base_table, ctx->base_table_entries, ++ ctx->base_level); ++#if !(HW_ASSISTED_COHERENCY || WARMBOOT_ENABLE_DCACHE_EARLY) ++ xlat_clean_dcache_range((uintptr_t)ctx->base_table, ++ ctx->base_table_entries * sizeof(uint64_t)); ++#endif ++ if (end_va != (mm->base_va + mm->size - 1U)) { ++ ERROR("Not enough memory to map region:\n" ++ " VA:0x%lx PA:0x%llx size:0x%zx attr:0x%x\n", ++ mm->base_va, mm->base_pa, mm->size, mm->attr); ++ panic(); ++ } ++ ++ mm++; ++ } ++ ++ assert(ctx->pa_max_address <= xlat_arch_get_max_supported_pa()); ++ assert(ctx->max_va <= ctx->va_max_address); ++ assert(ctx->max_pa <= ctx->pa_max_address); ++ ++ ctx->initialized = true; ++ ++ xlat_tables_print(ctx); ++} +diff --git a/environments/shim/lib/xlat_tables_v2/xlat_tables_private.h b/environments/shim/lib/xlat_tables_v2/xlat_tables_private.h +new file mode 100644 +index 0000000..8f51686 +--- /dev/null ++++ b/environments/shim/lib/xlat_tables_v2/xlat_tables_private.h +@@ -0,0 +1,108 @@ ++/* ++ * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef XLAT_TABLES_PRIVATE_H ++#define XLAT_TABLES_PRIVATE_H ++ ++#include ++#include ++#include ++ ++#if PLAT_XLAT_TABLES_DYNAMIC ++/* ++ * Private shifts and masks to access fields of an mmap attribute ++ */ ++/* Dynamic or static */ ++#define MT_DYN_SHIFT U(31) ++ ++/* ++ * Memory mapping private attributes ++ * ++ * Private attributes not exposed in the public header. ++ */ ++ ++/* ++ * Regions mapped before the MMU can't be unmapped dynamically (they are ++ * static) and regions mapped with MMU enabled can be unmapped. This ++ * behaviour can't be overridden. ++ * ++ * Static regions can overlap each other, dynamic regions can't. ++ */ ++#define MT_STATIC (U(0) << MT_DYN_SHIFT) ++#define MT_DYNAMIC (U(1) << MT_DYN_SHIFT) ++ ++#endif /* PLAT_XLAT_TABLES_DYNAMIC */ ++ ++extern uint64_t mmu_cfg_params[MMU_CFG_PARAM_MAX]; ++ ++/* ++ * Return the execute-never mask that will prevent instruction fetch at the ++ * given translation regime. ++ */ ++uint64_t xlat_arch_regime_get_xn_desc(int xlat_regime); ++ ++/* ++ * Invalidate all TLB entries that match the given virtual address. This ++ * operation applies to all PEs in the same Inner Shareable domain as the PE ++ * that executes this function. This functions must be called for every ++ * translation table entry that is modified. It only affects the specified ++ * translation regime. ++ * ++ * Note, however, that it is architecturally UNDEFINED to invalidate TLB entries ++ * pertaining to a higher exception level, e.g. invalidating EL3 entries from ++ * S-EL1. ++ */ ++void xlat_arch_tlbi_va(uintptr_t va, int xlat_regime); ++ ++/* ++ * This function has to be called at the end of any code that uses the function ++ * xlat_arch_tlbi_va(). ++ */ ++void xlat_arch_tlbi_va_sync(void); ++ ++/* Print VA, PA, size and attributes of all regions in the mmap array. */ ++void xlat_mmap_print(const mmap_region_t *mmap); ++ ++/* ++ * Print the current state of the translation tables by reading them from ++ * memory. ++ */ ++void xlat_tables_print(xlat_ctx_t *ctx); ++ ++/* ++ * Returns a block/page table descriptor for the given level and attributes. ++ */ ++uint64_t xlat_desc(const xlat_ctx_t *ctx, uint32_t attr, ++ unsigned long long addr_pa, unsigned int level); ++ ++/* ++ * Architecture-specific initialization code. ++ */ ++ ++/* Returns the current Exception Level. The returned EL must be 1 or higher. */ ++unsigned int xlat_arch_current_el(void); ++ ++/* ++ * Return the maximum physical address supported by the hardware. ++ * This value depends on the execution state (AArch32/AArch64). ++ */ ++unsigned long long xlat_arch_get_max_supported_pa(void); ++ ++/* ++ * Returns true if the MMU of the translation regime managed by the given ++ * xlat_ctx_t is enabled, false otherwise. ++ */ ++bool is_mmu_enabled_ctx(const xlat_ctx_t *ctx); ++ ++/* Returns true if the data cache is enabled at the current EL. */ ++bool is_dcache_enabled(void); ++ ++/* ++ * Returns minimum virtual address space size supported by the architecture ++ */ ++uintptr_t xlat_get_min_virt_addr_space_size(void); ++ ++#endif /* XLAT_TABLES_PRIVATE_H */ +diff --git a/environments/shim/lib/xlat_tables_v2/xlat_tables_utils.c b/environments/shim/lib/xlat_tables_v2/xlat_tables_utils.c +new file mode 100644 +index 0000000..168d492 +--- /dev/null ++++ b/environments/shim/lib/xlat_tables_v2/xlat_tables_utils.c +@@ -0,0 +1,573 @@ ++/* ++ * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "xlat_tables_private.h" ++ ++#if LOG_LEVEL < LOG_LEVEL_VERBOSE ++ ++void xlat_mmap_print(__unused const mmap_region_t *mmap) ++{ ++ /* Empty */ ++} ++ ++void xlat_tables_print(__unused xlat_ctx_t *ctx) ++{ ++ /* Empty */ ++} ++ ++#else /* if LOG_LEVEL >= LOG_LEVEL_VERBOSE */ ++ ++void xlat_mmap_print(const mmap_region_t *mmap) ++{ ++ printf("mmap:\n"); ++ const mmap_region_t *mm = mmap; ++ ++ while (mm->size != 0U) { ++ printf(" VA:0x%lx PA:0x%llx size:0x%zx attr:0x%x granularity:0x%zx\n", ++ mm->base_va, mm->base_pa, mm->size, mm->attr, ++ mm->granularity); ++ ++mm; ++ }; ++ printf("\n"); ++} ++ ++/* Print the attributes of the specified block descriptor. */ ++static void xlat_desc_print(const xlat_ctx_t *ctx, uint64_t desc) ++{ ++ uint64_t mem_type_index = ATTR_INDEX_GET(desc); ++ int xlat_regime = ctx->xlat_regime; ++ ++ if (mem_type_index == ATTR_IWBWA_OWBWA_NTR_INDEX) { ++ printf("MEM"); ++ } else if (mem_type_index == ATTR_NON_CACHEABLE_INDEX) { ++ printf("NC"); ++ } else { ++ assert(mem_type_index == ATTR_DEVICE_INDEX); ++ printf("DEV"); ++ } ++ ++ if ((xlat_regime == EL3_REGIME) || (xlat_regime == EL2_REGIME)) { ++ /* For EL3 and EL2 only check the AP[2] and XN bits. */ ++ printf(((desc & LOWER_ATTRS(AP_RO)) != 0ULL) ? "-RO" : "-RW"); ++ printf(((desc & UPPER_ATTRS(XN)) != 0ULL) ? "-XN" : "-EXEC"); ++ } else { ++ assert(xlat_regime == EL1_EL0_REGIME); ++ /* ++ * For EL0 and EL1: ++ * - In AArch64 PXN and UXN can be set independently but in ++ * AArch32 there is no UXN (XN affects both privilege levels). ++ * For consistency, we set them simultaneously in both cases. ++ * - RO and RW permissions must be the same in EL1 and EL0. If ++ * EL0 can access that memory region, so can EL1, with the ++ * same permissions. ++ */ ++#if ENABLE_ASSERTIONS ++ uint64_t xn_mask = xlat_arch_regime_get_xn_desc(EL1_EL0_REGIME); ++ uint64_t xn_perm = desc & xn_mask; ++ ++ assert((xn_perm == xn_mask) || (xn_perm == 0ULL)); ++#endif ++ printf(((desc & LOWER_ATTRS(AP_RO)) != 0ULL) ? "-RO" : "-RW"); ++ /* Only check one of PXN and UXN, the other one is the same. */ ++ printf(((desc & UPPER_ATTRS(PXN)) != 0ULL) ? "-XN" : "-EXEC"); ++ /* ++ * Privileged regions can only be accessed from EL1, user ++ * regions can be accessed from EL1 and EL0. ++ */ ++ printf(((desc & LOWER_ATTRS(AP_ACCESS_UNPRIVILEGED)) != 0ULL) ++ ? "-USER" : "-PRIV"); ++ } ++ ++ printf(((LOWER_ATTRS(NS) & desc) != 0ULL) ? "-NS" : "-S"); ++ ++#ifdef __aarch64__ ++ /* Check Guarded Page bit */ ++ if ((desc & GP) != 0ULL) { ++ printf("-GP"); ++ } ++#endif ++} ++ ++static const char * const level_spacers[] = { ++ "[LV0] ", ++ " [LV1] ", ++ " [LV2] ", ++ " [LV3] " ++}; ++ ++static const char *invalid_descriptors_ommited = ++ "%s(%d invalid descriptors omitted)\n"; ++ ++/* ++ * Recursive function that reads the translation tables passed as an argument ++ * and prints their status. ++ */ ++static void xlat_tables_print_internal(xlat_ctx_t *ctx, uintptr_t table_base_va, ++ const uint64_t *table_base, unsigned int table_entries, ++ unsigned int level) ++{ ++ assert(level <= XLAT_TABLE_LEVEL_MAX); ++ ++ uint64_t desc; ++ uintptr_t table_idx_va = table_base_va; ++ unsigned int table_idx = 0U; ++ size_t level_size = XLAT_BLOCK_SIZE(level); ++ ++ /* ++ * Keep track of how many invalid descriptors are counted in a row. ++ * Whenever multiple invalid descriptors are found, only the first one ++ * is printed, and a line is added to inform about how many descriptors ++ * have been omitted. ++ */ ++ int invalid_row_count = 0; ++ ++ while (table_idx < table_entries) { ++ ++ desc = table_base[table_idx]; ++ ++ if ((desc & DESC_MASK) == INVALID_DESC) { ++ ++ if (invalid_row_count == 0) { ++ printf("%sVA:0x%lx size:0x%zx\n", ++ level_spacers[level], ++ table_idx_va, level_size); ++ } ++ invalid_row_count++; ++ ++ } else { ++ ++ if (invalid_row_count > 1) { ++ printf(invalid_descriptors_ommited, ++ level_spacers[level], ++ invalid_row_count - 1); ++ } ++ invalid_row_count = 0; ++ ++ /* ++ * Check if this is a table or a block. Tables are only ++ * allowed in levels other than 3, but DESC_PAGE has the ++ * same value as DESC_TABLE, so we need to check. ++ */ ++ if (((desc & DESC_MASK) == TABLE_DESC) && ++ (level < XLAT_TABLE_LEVEL_MAX)) { ++ /* ++ * Do not print any PA for a table descriptor, ++ * as it doesn't directly map physical memory ++ * but instead points to the next translation ++ * table in the translation table walk. ++ */ ++ printf("%sVA:0x%lx size:0x%zx\n", ++ level_spacers[level], ++ table_idx_va, level_size); ++ ++ uintptr_t addr_inner = desc & TABLE_ADDR_MASK; ++ ++ xlat_tables_print_internal(ctx, table_idx_va, ++ (uint64_t *)addr_inner, ++ XLAT_TABLE_ENTRIES, level + 1U); ++ } else { ++ printf("%sVA:0x%lx PA:0x%llx size:0x%zx ", ++ level_spacers[level], table_idx_va, ++ (uint64_t)(desc & TABLE_ADDR_MASK), ++ level_size); ++ xlat_desc_print(ctx, desc); ++ printf("\n"); ++ } ++ } ++ ++ table_idx++; ++ table_idx_va += level_size; ++ } ++ ++ if (invalid_row_count > 1) { ++ printf(invalid_descriptors_ommited, ++ level_spacers[level], invalid_row_count - 1); ++ } ++} ++ ++void xlat_tables_print(xlat_ctx_t *ctx) ++{ ++ const char *xlat_regime_str; ++ int used_page_tables; ++ ++ if (ctx->xlat_regime == EL1_EL0_REGIME) { ++ xlat_regime_str = "1&0"; ++ } else if (ctx->xlat_regime == EL2_REGIME) { ++ xlat_regime_str = "2"; ++ } else { ++ assert(ctx->xlat_regime == EL3_REGIME); ++ xlat_regime_str = "3"; ++ } ++ VERBOSE("Translation tables state:\n"); ++ VERBOSE(" Xlat regime: EL%s\n", xlat_regime_str); ++ VERBOSE(" Max allowed PA: 0x%llx\n", ctx->pa_max_address); ++ VERBOSE(" Max allowed VA: 0x%lx\n", ctx->va_max_address); ++ VERBOSE(" Max mapped PA: 0x%llx\n", ctx->max_pa); ++ VERBOSE(" Max mapped VA: 0x%lx\n", ctx->max_va); ++ ++ VERBOSE(" Initial lookup level: %u\n", ctx->base_level); ++ VERBOSE(" Entries @initial lookup level: %u\n", ++ ctx->base_table_entries); ++ ++#if PLAT_XLAT_TABLES_DYNAMIC ++ used_page_tables = 0; ++ for (int i = 0; i < ctx->tables_num; ++i) { ++ if (ctx->tables_mapped_regions[i] != 0) ++ ++used_page_tables; ++ } ++#else ++ used_page_tables = ctx->next_table; ++#endif ++ VERBOSE(" Used %d sub-tables out of %d (spare: %d)\n", ++ used_page_tables, ctx->tables_num, ++ ctx->tables_num - used_page_tables); ++ ++ xlat_tables_print_internal(ctx, 0U, ctx->base_table, ++ ctx->base_table_entries, ctx->base_level); ++} ++ ++#endif /* LOG_LEVEL >= LOG_LEVEL_VERBOSE */ ++ ++/* ++ * Do a translation table walk to find the block or page descriptor that maps ++ * virtual_addr. ++ * ++ * On success, return the address of the descriptor within the translation ++ * table. Its lookup level is stored in '*out_level'. ++ * On error, return NULL. ++ * ++ * xlat_table_base ++ * Base address for the initial lookup level. ++ * xlat_table_base_entries ++ * Number of entries in the translation table for the initial lookup level. ++ * virt_addr_space_size ++ * Size in bytes of the virtual address space. ++ */ ++static uint64_t *find_xlat_table_entry(uintptr_t virtual_addr, ++ void *xlat_table_base, ++ unsigned int xlat_table_base_entries, ++ unsigned long long virt_addr_space_size, ++ unsigned int *out_level) ++{ ++ unsigned int start_level; ++ uint64_t *table; ++ unsigned int entries; ++ ++ start_level = GET_XLAT_TABLE_LEVEL_BASE(virt_addr_space_size); ++ ++ table = xlat_table_base; ++ entries = xlat_table_base_entries; ++ ++ for (unsigned int level = start_level; ++ level <= XLAT_TABLE_LEVEL_MAX; ++ ++level) { ++ uint64_t idx, desc, desc_type; ++ ++ idx = XLAT_TABLE_IDX(virtual_addr, level); ++ if (idx >= entries) { ++ WARN("Missing xlat table entry at address 0x%lx\n", ++ virtual_addr); ++ return NULL; ++ } ++ ++ desc = table[idx]; ++ desc_type = desc & DESC_MASK; ++ ++ if (desc_type == INVALID_DESC) { ++ VERBOSE("Invalid entry (memory not mapped)\n"); ++ return NULL; ++ } ++ ++ if (level == XLAT_TABLE_LEVEL_MAX) { ++ /* ++ * Only page descriptors allowed at the final lookup ++ * level. ++ */ ++ assert(desc_type == PAGE_DESC); ++ *out_level = level; ++ return &table[idx]; ++ } ++ ++ if (desc_type == BLOCK_DESC) { ++ *out_level = level; ++ return &table[idx]; ++ } ++ ++ assert(desc_type == TABLE_DESC); ++ table = (uint64_t *)(uintptr_t)(desc & TABLE_ADDR_MASK); ++ entries = XLAT_TABLE_ENTRIES; ++ } ++ ++ /* ++ * This shouldn't be reached, the translation table walk should end at ++ * most at level XLAT_TABLE_LEVEL_MAX and return from inside the loop. ++ */ ++ assert(false); ++ ++ return NULL; ++} ++ ++ ++static int xlat_get_mem_attributes_internal(const xlat_ctx_t *ctx, ++ uintptr_t base_va, uint32_t *attributes, uint64_t **table_entry, ++ unsigned long long *addr_pa, unsigned int *table_level) ++{ ++ uint64_t *entry; ++ uint64_t desc; ++ unsigned int level; ++ unsigned long long virt_addr_space_size; ++ ++ /* ++ * Sanity-check arguments. ++ */ ++ assert(ctx != NULL); ++ assert(ctx->initialized); ++ assert((ctx->xlat_regime == EL1_EL0_REGIME) || ++ (ctx->xlat_regime == EL2_REGIME) || ++ (ctx->xlat_regime == EL3_REGIME)); ++ ++ virt_addr_space_size = (unsigned long long)ctx->va_max_address + 1ULL; ++ assert(virt_addr_space_size > 0U); ++ ++ entry = find_xlat_table_entry(base_va, ++ ctx->base_table, ++ ctx->base_table_entries, ++ virt_addr_space_size, ++ &level); ++ if (entry == NULL) { ++ WARN("Address 0x%lx is not mapped.\n", base_va); ++ return -EINVAL; ++ } ++ ++ if (addr_pa != NULL) { ++ *addr_pa = *entry & TABLE_ADDR_MASK; ++ } ++ ++ if (table_entry != NULL) { ++ *table_entry = entry; ++ } ++ ++ if (table_level != NULL) { ++ *table_level = level; ++ } ++ ++ desc = *entry; ++ ++#if LOG_LEVEL >= LOG_LEVEL_VERBOSE ++ VERBOSE("Attributes: "); ++ xlat_desc_print(ctx, desc); ++ printf("\n"); ++#endif /* LOG_LEVEL >= LOG_LEVEL_VERBOSE */ ++ ++ assert(attributes != NULL); ++ *attributes = 0U; ++ ++ uint64_t attr_index = (desc >> ATTR_INDEX_SHIFT) & ATTR_INDEX_MASK; ++ ++ if (attr_index == ATTR_IWBWA_OWBWA_NTR_INDEX) { ++ *attributes |= MT_MEMORY; ++ } else if (attr_index == ATTR_NON_CACHEABLE_INDEX) { ++ *attributes |= MT_NON_CACHEABLE; ++ } else { ++ assert(attr_index == ATTR_DEVICE_INDEX); ++ *attributes |= MT_DEVICE; ++ } ++ ++ uint64_t ap2_bit = (desc >> AP2_SHIFT) & 1U; ++ ++ if (ap2_bit == AP2_RW) ++ *attributes |= MT_RW; ++ ++ if (ctx->xlat_regime == EL1_EL0_REGIME) { ++ uint64_t ap1_bit = (desc >> AP1_SHIFT) & 1U; ++ ++ if (ap1_bit == AP1_ACCESS_UNPRIVILEGED) ++ *attributes |= MT_USER; ++ } ++ ++ uint64_t ns_bit = (desc >> NS_SHIFT) & 1U; ++ ++ if (ns_bit == 1U) ++ *attributes |= MT_NS; ++ ++ uint64_t xn_mask = xlat_arch_regime_get_xn_desc(ctx->xlat_regime); ++ ++ if ((desc & xn_mask) == xn_mask) { ++ *attributes |= MT_EXECUTE_NEVER; ++ } else { ++ assert((desc & xn_mask) == 0U); ++ } ++ ++ return 0; ++} ++ ++ ++int xlat_get_mem_attributes_ctx(const xlat_ctx_t *ctx, uintptr_t base_va, ++ uint32_t *attr) ++{ ++ return xlat_get_mem_attributes_internal(ctx, base_va, attr, ++ NULL, NULL, NULL); ++} ++ ++ ++int xlat_change_mem_attributes_ctx(const xlat_ctx_t *ctx, uintptr_t base_va, ++ size_t size, uint32_t attr) ++{ ++ /* Note: This implementation isn't optimized. */ ++ ++ assert(ctx != NULL); ++ assert(ctx->initialized); ++ ++ unsigned long long virt_addr_space_size = ++ (unsigned long long)ctx->va_max_address + 1U; ++ assert(virt_addr_space_size > 0U); ++ ++ if (!IS_PAGE_ALIGNED(base_va)) { ++ WARN("%s: Address 0x%lx is not aligned on a page boundary.\n", ++ __func__, base_va); ++ return -EINVAL; ++ } ++ ++ if (size == 0U) { ++ WARN("%s: Size is 0.\n", __func__); ++ return -EINVAL; ++ } ++ ++ if ((size % PAGE_SIZE) != 0U) { ++ WARN("%s: Size 0x%zx is not a multiple of a page size.\n", ++ __func__, size); ++ return -EINVAL; ++ } ++ ++ if (((attr & MT_EXECUTE_NEVER) == 0U) && ((attr & MT_RW) != 0U)) { ++ WARN("%s: Mapping memory as read-write and executable not allowed.\n", ++ __func__); ++ return -EINVAL; ++ } ++ ++ size_t pages_count = size / PAGE_SIZE; ++ ++ VERBOSE("Changing memory attributes of %zu pages starting from address 0x%lx...\n", ++ pages_count, base_va); ++ ++ uintptr_t base_va_original = base_va; ++ ++ /* ++ * Sanity checks. ++ */ ++ for (size_t i = 0U; i < pages_count; ++i) { ++ const uint64_t *entry; ++ uint64_t desc, attr_index; ++ unsigned int level; ++ ++ entry = find_xlat_table_entry(base_va, ++ ctx->base_table, ++ ctx->base_table_entries, ++ virt_addr_space_size, ++ &level); ++ if (entry == NULL) { ++ WARN("Address 0x%lx is not mapped.\n", base_va); ++ return -EINVAL; ++ } ++ ++ desc = *entry; ++ ++ /* ++ * Check that all the required pages are mapped at page ++ * granularity. ++ */ ++ if (((desc & DESC_MASK) != PAGE_DESC) || ++ (level != XLAT_TABLE_LEVEL_MAX)) { ++ WARN("Address 0x%lx is not mapped at the right granularity.\n", ++ base_va); ++ WARN("Granularity is 0x%llx, should be 0x%x.\n", ++ (unsigned long long)XLAT_BLOCK_SIZE(level), PAGE_SIZE); ++ return -EINVAL; ++ } ++ ++ /* ++ * If the region type is device, it shouldn't be executable. ++ */ ++ attr_index = (desc >> ATTR_INDEX_SHIFT) & ATTR_INDEX_MASK; ++ if (attr_index == ATTR_DEVICE_INDEX) { ++ if ((attr & MT_EXECUTE_NEVER) == 0U) { ++ WARN("Setting device memory as executable at address 0x%lx.", ++ base_va); ++ return -EINVAL; ++ } ++ } ++ ++ base_va += PAGE_SIZE; ++ } ++ ++ /* Restore original value. */ ++ base_va = base_va_original; ++ ++ for (unsigned int i = 0U; i < pages_count; ++i) { ++ ++ uint32_t old_attr = 0U, new_attr; ++ uint64_t *entry = NULL; ++ unsigned int level = 0U; ++ unsigned long long addr_pa = 0ULL; ++ ++ (void) xlat_get_mem_attributes_internal(ctx, base_va, &old_attr, ++ &entry, &addr_pa, &level); ++ ++ /* ++ * From attr, only MT_RO/MT_RW, MT_EXECUTE/MT_EXECUTE_NEVER and ++ * MT_USER/MT_PRIVILEGED are taken into account. Any other ++ * information is ignored. ++ */ ++ ++ /* Clean the old attributes so that they can be rebuilt. */ ++ new_attr = old_attr & ~(MT_RW | MT_EXECUTE_NEVER | MT_USER); ++ ++ /* ++ * Update attributes, but filter out the ones this function ++ * isn't allowed to change. ++ */ ++ new_attr |= attr & (MT_RW | MT_EXECUTE_NEVER | MT_USER); ++ ++ /* ++ * The break-before-make sequence requires writing an invalid ++ * descriptor and making sure that the system sees the change ++ * before writing the new descriptor. ++ */ ++ *entry = INVALID_DESC; ++#if !(HW_ASSISTED_COHERENCY || WARMBOOT_ENABLE_DCACHE_EARLY) ++ dccvac((uintptr_t)entry); ++#endif ++ /* Invalidate any cached copy of this mapping in the TLBs. */ ++ xlat_arch_tlbi_va(base_va, ctx->xlat_regime); ++ ++ /* Ensure completion of the invalidation. */ ++ xlat_arch_tlbi_va_sync(); ++ ++ /* Write new descriptor */ ++ *entry = xlat_desc(ctx, new_attr, addr_pa, level); ++#if !(HW_ASSISTED_COHERENCY || WARMBOOT_ENABLE_DCACHE_EARLY) ++ dccvac((uintptr_t)entry); ++#endif ++ base_va += PAGE_SIZE; ++ } ++ ++ /* Ensure that the last descriptor writen is seen by the system. */ ++ dsbish(); ++ ++ return 0; ++} +diff --git a/environments/shim/pl011/aarch64/pl011_console.S b/environments/shim/pl011/aarch64/pl011_console.S +new file mode 100644 +index 0000000..11501d7 +--- /dev/null ++++ b/environments/shim/pl011/aarch64/pl011_console.S +@@ -0,0 +1,246 @@ ++/* ++ * Copyright (c) 2018-2021, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#define __ASSEMBLY__ ++#include ++#include ++#include ++#include ++ ++ .globl console_init ++ .globl console_pl011_putc ++ .globl console_getc ++ .globl console_try_getc ++ .globl console_flush ++ .globl console_core_init ++ .globl console_core_putc ++ .globl console_core_getc ++ .globl console_core_flush ++ ++ /* ++ * The console base is in the data section and not in .bss ++ * even though it is zero-init. In particular, this allows ++ * the console functions to start using this variable before ++ * the runtime memory is initialized for images which do not ++ * need to copy the .data section from ROM to RAM. ++ */ ++ .section .data.console_base ++ .align 3 ++console_base: .quad 0x0 ++ ++ /* ----------------------------------------------- ++ * int console_init(uintptr_t base_addr, ++ * unsigned int uart_clk, unsigned int baud_rate) ++ * ++ * Clobber list : x1 - x3 ++ * ----------------------------------------------- ++ */ ++func console_init ++ adrp x3, console_base ++ str x0, [x3, :lo12:console_base] ++ b console_core_init ++endfunc console_init ++ ++ /* ----------------------------------------------- ++ * int console_core_init(uintptr_t base_addr, ++ * unsigned int uart_clk, unsigned int baud_rate) ++ * Function to initialize the console without a ++ * C Runtime to print debug information. This ++ * function will be accessed by console_init and ++ * crash reporting. ++ * In: x0 - Console base address ++ * w1 - Uart clock in Hz ++ * w2 - Baud rate ++ * Out: w0 - Return 1 on success, 0 on error. ++ * Clobber list : x1 - x3 ++ * ----------------------------------------------- ++ */ ++func console_core_init ++ /* Check the input base address */ ++ cbz x0, init_fail ++ /* Check baud rate and uart clock for sanity */ ++ cbz w1, init_fail ++ cbz w2, init_fail ++ /* Disable uart before programming */ ++ ldr w3, [x0, #UARTCR] ++ bic w3, w3, #PL011_UARTCR_UARTEN ++ str w3, [x0, #UARTCR] ++ /* Program the baudrate */ ++ /* Divisor = (Uart clock * 4) / baudrate */ ++ lsl w1, w1, #2 ++ udiv w2, w1, w2 ++ /* IBRD = Divisor >> 6 */ ++ lsr w1, w2, #6 ++ /* Write the IBRD */ ++ str w1, [x0, #UARTIBRD] ++ /* FBRD = Divisor & 0x3F */ ++ and w1, w2, #0x3f ++ /* Write the FBRD */ ++ str w1, [x0, #UARTFBRD] ++ mov w1, #PL011_LINE_CONTROL ++ str w1, [x0, #UARTLCR_H] ++ /* Clear any pending errors */ ++ str wzr, [x0, #UARTECR] ++ /* Enable tx, rx, and uart overall */ ++ mov w1, #(PL011_UARTCR_RXE | PL011_UARTCR_TXE | PL011_UARTCR_UARTEN) ++ str w1, [x0, #UARTCR] ++ mov w0, #1 ++ ret ++init_fail: ++ mov w0, wzr ++ ret ++endfunc console_core_init ++ ++ /* ------------------------------------------------- ++ * To allow alternate implementation of putc, pl011 ++ * is appended in the function name. ++ * ++ * int console_pl011_putc(int c) ++ * ++ * Clobber list : x1, x2 ++ * ------------------------------------------------- ++ */ ++func console_pl011_putc ++ adrp x1, console_base ++ ldr x1, [x1, :lo12:console_base] ++ b console_core_putc ++endfunc console_pl011_putc ++ ++ /* --------------------------------------------- ++ * int console_core_putc(int c, uintptr_t base_addr) ++ * Function to output a character over the console. It ++ * returns the character printed on success or an error ++ * code. ++ * In : w0 - Character to be printed ++ * x1 - Console base address ++ * Out : w0 - Input character or error code. ++ * Clobber list : x2 ++ * --------------------------------------------- ++ */ ++func console_core_putc ++ /* Check the input parameter */ ++ cbz x1, putc_error ++ /* Prepend '\r' to '\n' */ ++ cmp w0, #0xA ++ b.ne 2f ++1: ++ /* Check if the transmit FIFO is full */ ++ ldr w2, [x1, #UARTFR] ++ tbnz w2, #PL011_UARTFR_TXFF_BIT, 1b ++ mov w2, #0xD ++ str w2, [x1, #UARTDR] ++2: ++ /* Check if the transmit FIFO is full */ ++ ldr w2, [x1, #UARTFR] ++ tbnz w2, #PL011_UARTFR_TXFF_BIT, 2b ++ ++ /* Only write 8 bits */ ++ and w0, w0, #0xFF ++ str w0, [x1, #UARTDR] ++ ret ++putc_error: ++ mov w0, #ERROR_NO_VALID_CONSOLE ++ ret ++endfunc console_core_putc ++ ++ /* --------------------------------------------- ++ * int console_getc(void) ++ * ++ * Clobber list : x0 - x3 ++ * --------------------------------------------- ++ */ ++func console_getc ++ adrp x2, console_base ++ ldr x2, [x2, :lo12:console_base] ++ mov x3, x30 ++ ++ /* Loop until it returns a character or an error. */ ++1: mov x0, x2 ++ bl console_core_getc ++ cmp w0, #ERROR_NO_PENDING_CHAR ++ b.eq 1b ++ ++ ret x3 ++endfunc console_getc ++ ++ /* --------------------------------------------- ++ * int console_try_getc(void) ++ * ++ * Clobber list : x0, x1 ++ * --------------------------------------------- ++ */ ++func console_try_getc ++ adrp x0, console_base ++ ldr x0, [x0, :lo12:console_base] ++ b console_core_getc ++endfunc console_try_getc ++ ++ /* --------------------------------------------- ++ * int console_core_getc(uintptr_t base_addr) ++ * Function to get a character from the console. ++ * It returns the character grabbed on success ++ * or an error code. ++ * In : x0 - Console base address ++ * Out : w0 - Return character or error code. ++ * Clobber list : x0, x1 ++ * --------------------------------------------- ++ */ ++func console_core_getc ++ cbz x0, getc_error ++ ++ /* Check if the receive FIFO is empty */ ++ ldr w1, [x0, #UARTFR] ++ tbnz w1, #PL011_UARTFR_RXFE_BIT, getc_empty ++ ++ /* Read a character from the FIFO */ ++ ldr w0, [x0, #UARTDR] ++ /* Mask out error flags */ ++ and w0, w0, #0xFF ++ ret ++ ++getc_empty: ++ mov w0, #ERROR_NO_PENDING_CHAR ++ ret ++getc_error: ++ mov w0, #ERROR_NO_VALID_CONSOLE ++ ret ++endfunc console_core_getc ++ ++ /* --------------------------------------------- ++ * int console_flush(void) ++ * ++ * Clobber list : x0, x1 ++ * --------------------------------------------- ++ */ ++func console_flush ++ adrp x0, console_base ++ ldr x0, [x0, :lo12:console_base] ++ b console_core_flush ++endfunc console_flush ++ ++ /* --------------------------------------------- ++ * int console_core_flush(uintptr_t base_addr) ++ * Function to force a write of all buffered ++ * data that hasn't been output. ++ * In : x0 - Console base address ++ * Out : w0 - Error code or 0. ++ * Clobber list : x0, x1 ++ * --------------------------------------------- ++ */ ++func console_core_flush ++ cbz x0, flush_error ++ ++1: ++ /* Loop until the transmit FIFO is empty */ ++ ldr w1, [x0, #UARTFR] ++ tbnz w1, #PL011_UARTFR_BUSY_BIT, 1b ++ ++ mov w0, wzr ++ ret ++flush_error: ++ mov w0, #ERROR_NO_VALID_CONSOLE ++ ret ++endfunc console_core_flush +diff --git a/environments/shim/plat/plat_helpers.S b/environments/shim/plat/plat_helpers.S +new file mode 100644 +index 0000000..863b378 +--- /dev/null ++++ b/environments/shim/plat/plat_helpers.S +@@ -0,0 +1,90 @@ ++/* ++ * Copyright (c) 2020, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include ++#include ++#include ++ ++ .globl platform_get_core_pos ++ .globl plat_crash_console_init ++ .globl plat_crash_console_putc ++ .globl plat_crash_console_flush ++ ++/*---------------------------------------------------------------------- ++ * unsigned int platform_get_core_pos(unsigned long mpid) ++ * ++ * Function to calculate the core position on TC0 platforms. ++ * ++ * (ClusterId * TC0_MAX_CPUS_PER_CLUSTER * TC0_MAX_PE_PER_CPU) + ++ * (CPUId * TC0_MAX_PE_PER_CPU) + ++ * ThreadId ++ * ++ * which can be simplified as: ++ * ++ * ((ClusterId * TC0_MAX_CPUS_PER_CLUSTER + CPUId) * TC0_MAX_PE_PER_CPU) ++ * + ThreadId ++ * --------------------------------------------------------------------- ++ */ ++func platform_get_core_pos ++ /* ++ * Check for MT bit in MPIDR. If not set, shift MPIDR to left to make it ++ * look as if in a multi-threaded implementation. ++ */ ++ tst x0, #MPIDR_MT_MASK ++ lsl x3, x0, #MPIDR_AFFINITY_BITS ++ csel x3, x3, x0, eq ++ ++ /* Extract individual affinity fields from MPIDR */ ++ ubfx x0, x3, #MPIDR_AFF0_SHIFT, #MPIDR_AFFINITY_BITS ++ ubfx x1, x3, #MPIDR_AFF1_SHIFT, #MPIDR_AFFINITY_BITS ++ ubfx x2, x3, #MPIDR_AFF2_SHIFT, #MPIDR_AFFINITY_BITS ++ ++ /* Compute linear position */ ++ mov x3, #TC0_MAX_CPUS_PER_CLUSTER ++ madd x1, x2, x3, x1 ++ mov x3, #TC0_MAX_PE_PER_CPU ++ madd x0, x1, x3, x0 ++ ret ++endfunc platform_get_core_pos ++ ++/* --------------------------------------------- ++ * int plat_crash_console_init(void) ++ * Function to initialize the crash console ++ * without a C Runtime to print crash report. ++ * Clobber list : x0 - x4 ++ * --------------------------------------------- ++ */ ++func plat_crash_console_init ++ mov_imm x0, PLAT_ARM_UART_BASE ++ mov_imm x1, PLAT_ARM_UART_CLK_IN_HZ ++ mov_imm x2, PL011_BAUDRATE ++ b console_core_init ++endfunc plat_crash_console_init ++ ++/* --------------------------------------------- ++ * int plat_crash_console_putc(int c) ++ * Function to print a character on the crash ++ * console without a C Runtime. ++ * Clobber list : x1, x2 ++ * --------------------------------------------- ++ */ ++func plat_crash_console_putc ++ mov_imm x1, PLAT_ARM_UART_BASE ++ b console_core_putc ++endfunc plat_crash_console_putc ++ ++/* --------------------------------------------- ++ * int plat_crash_console_flush() ++ * Function to force a write of all buffered ++ * data that hasn't been output. ++ * Out : return -1 on error else return 0. ++ * Clobber list : x0 - x1 ++ * --------------------------------------------- ++ */ ++func plat_crash_console_flush ++ mov_imm x1, PLAT_ARM_UART_BASE ++ b console_core_flush ++endfunc plat_crash_console_flush +diff --git a/environments/shim/shim_main.c b/environments/shim/shim_main.c +new file mode 100644 +index 0000000..dcb5d7a +--- /dev/null ++++ b/environments/shim/shim_main.c +@@ -0,0 +1,119 @@ ++/* ++ * Copyright (c) 2021, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++#define KERNEL_START (uintptr_t)0x80000000 ++#define KERNEL_SIZE (uintptr_t)0x7d000000 ++ ++#define CRYPTO_START (uintptr_t)0xFEC00000 ++#define CRYPTO_SIZE (uintptr_t)0x200000 ++ ++static void shim_print_memory_layout(void) ++{ ++ NOTICE("Secure Partition memory layout:\n"); ++ ++ NOTICE(" Image regions\n"); ++ NOTICE(" Text region : %p - %p\n", ++ (void *)SP_TEXT_START, (void *)SP_TEXT_END); ++ NOTICE(" Read-only data region : %p - %p\n", ++ (void *)SP_RODATA_START, (void *)SP_RODATA_END); ++ NOTICE(" Data region : %p - %p\n", ++ (void *)SP_DATA_START, (void *)SP_DATA_END); ++ NOTICE(" BSS region : %p - %p\n", ++ (void *)SP_BSS_START, (void *)SP_BSS_END); ++ NOTICE(" Total image memory : %p - %p\n", ++ (void *)SP_IMAGE_BASE, ++ (void *)(SP_IMAGE_BASE + SP_IMAGE_SIZE)); ++} ++ ++static void shim_plat_configure_mmu() ++{ ++ NOTICE("SHIM_TEXT_START = %p\n", (void *)SHIM_TEXT_START); ++ mmap_add_region(SHIM_TEXT_START, ++ SHIM_TEXT_START, ++ SHIM_TEXT_END - SHIM_TEXT_START, ++ MT_CODE | MT_PRIVILEGED); ++ mmap_add_region(SHIM_RODATA_START, ++ SHIM_RODATA_START, ++ SHIM_RODATA_END - SHIM_RODATA_START, ++ MT_RO_DATA | MT_PRIVILEGED); ++ mmap_add_region(SHIM_DATA_START, ++ SHIM_DATA_START, ++ SHIM_DATA_END - SHIM_DATA_START, ++ MT_RW_DATA | MT_PRIVILEGED); ++ mmap_add_region(SHIM_BSS_START, ++ SHIM_BSS_START, ++ SHIM_BSS_END - SHIM_BSS_START, ++ MT_RW_DATA | MT_PRIVILEGED); ++ mmap_add_region(SP_TEXT_START, ++ SP_TEXT_START, ++ SP_TEXT_END - SP_TEXT_START, ++ MT_CODE | MT_USER); ++ mmap_add_region(SP_RODATA_START, ++ SP_RODATA_START, ++ SP_RODATA_END - SP_RODATA_START, ++ MT_RO_DATA | MT_USER); ++ mmap_add_region(SP_DATA_START, ++ SP_DATA_START, ++ SP_DATA_END - SP_DATA_START, ++ MT_RW_DATA | MT_USER); ++ mmap_add_region(SP_BSS_START, ++ SP_BSS_START, ++ SP_BSS_END - SP_BSS_START, ++ MT_RW_DATA | MT_USER); ++ ++ mmap_add_region(KERNEL_START, ++ KERNEL_START, ++ KERNEL_SIZE, ++ MT_RW_DATA | MT_USER | MT_NS | MT_EXECUTE_NEVER); ++ ++/* map the crypto address space in the secure storage partition to access the ++ * buffer created by crypto partition ++ */ ++#ifdef SECURE_STORAGE ++ mmap_add_region(CRYPTO_START, ++ CRYPTO_START, ++ CRYPTO_SIZE, ++ MT_RW_DATA | MT_USER | MT_EXECUTE_NEVER); ++#endif ++ ++ init_xlat_tables(); ++} ++ ++int shim_main(void) ++{ ++ assert(IS_IN_EL1() != 0); ++ ++ /* Initialise console */ ++ set_putc_impl(HVC_CALL_AS_STDOUT); ++ ++ NOTICE("Booting S-EL1 Shim\n"); ++ ++ /* Configure and enable Stage-1 MMU, enable D-Cache */ ++ shim_plat_configure_mmu(); ++ enable_mmu_el1(0); ++ ++ shim_print_memory_layout(); ++ ++ set_putc_impl(SVC_CALL_AS_STDOUT); ++ ++ return 0; ++} +diff --git a/environments/shim/sp.ld.S b/environments/shim/sp.ld.S +new file mode 100644 +index 0000000..924ad5b +--- /dev/null ++++ b/environments/shim/sp.ld.S +@@ -0,0 +1,120 @@ ++/* ++ * Copyright (c) 2018-2021, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++ ++#include ++#include ++ ++OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT) ++OUTPUT_ARCH(PLATFORM_LINKER_ARCH) ++ENTRY(shim_entrypoint) ++ ++SECTIONS ++{ ++ . = SP_IMAGE_BASE; ++ ++ ASSERT(. == ALIGN(PAGE_SIZE), ++ "TEXT_START address is not aligned to PAGE_SIZE.") ++ ++ /*----------------- START S-EL1 SHIM ----------------*/ ++ ++ .shim_text : { ++ __SHIM_TEXT_START__ = .; ++ *spm_shim_entrypoint.S.obj(.text*) ++ *(.vectors) ++ . = NEXT(PAGE_SIZE); ++ __SHIM_TEXT_END__ = .; ++ } ++ ++ .shim_rodata : { ++ . = ALIGN(PAGE_SIZE); ++ __SHIM_RODATA_START__ = .; ++ ++ . = NEXT(PAGE_SIZE); ++ __SHIM_RODATA_END__ = .; ++ } ++ ++ .shim_data : { ++ . = ALIGN(PAGE_SIZE); ++ __SHIM_DATA_START__ = .; ++ ++ . = NEXT(PAGE_SIZE); ++ __SHIM_DATA_END__ = .; ++ } ++ ++ .shim_bss (NOLOAD) : { ++ . = ALIGN(PAGE_SIZE); ++ __SHIM_BSS_START__ = .; ++ ++ *(.bss.shim_stacks) ++ *(.bss.tf_base_xlat_table) ++ *(.bss.tf_mmap) ++ *xlat_tables_context.c.obj(COMMON) ++ *xlat_tables_context.c.obj(xlat_table) ++ ++ . = NEXT(PAGE_SIZE); ++ __SHIM_BSS_END__ = .; ++ } ++ ++ /*----------------- END S-EL1 SHIM ----------------*/ ++ ++ .text : { ++ __TEXT_START__ = .; ++ *sp_entrypoint.S.obj(.text*) ++ *(.text*) ++ *(.vectors) ++ . = NEXT(PAGE_SIZE); ++ __TEXT_END__ = .; ++ } ++ ++ .rodata : { ++ . = ALIGN(PAGE_SIZE); ++ __RODATA_START__ = .; ++ *(.rodata*) ++ ++ /* ++ * Keep the .got section in the RO section as it is patched ++ * prior to enabling the MMU and having the .got in RO is better for ++ * security. GOT is a table of addresses so ensure 8-byte alignment. ++ */ ++ . = ALIGN(8); ++ __GOT_START__ = .; ++ *(.got) ++ __GOT_END__ = .; ++ ++ . = NEXT(PAGE_SIZE); ++ __RODATA_END__ = .; ++ } ++ ++ .data : { ++ . = ALIGN(PAGE_SIZE); ++ __DATA_START__ = .; ++ *(.data*) ++ . = NEXT(PAGE_SIZE); ++ __DATA_END__ = .; ++ } ++ ++ /* ++ * .rela.dyn needs to come after .data for the read-elf utility to parse ++ * this section correctly. Ensure 8-byte alignment so that the fields of ++ * RELA data structure are aligned. ++ */ ++ . = ALIGN(8); ++ __RELA_START__ = .; ++ .rela.dyn . : { ++ } ++ __RELA_END__ = .; ++ ++ ++ .bss (NOLOAD) : { ++ . = ALIGN(PAGE_SIZE); ++ __BSS_START__ = .; ++ *(SORT_BY_ALIGNMENT(.bss*)) ++ *(COMMON) ++ . = NEXT(PAGE_SIZE); ++ __BSS_END__ = .; ++ } ++} +diff --git a/environments/shim/spm/common/aarch64/sp_arch_helpers.S b/environments/shim/spm/common/aarch64/sp_arch_helpers.S +new file mode 100644 +index 0000000..bfa8cce +--- /dev/null ++++ b/environments/shim/spm/common/aarch64/sp_arch_helpers.S +@@ -0,0 +1,42 @@ ++/* ++ * Copyright (c) 2018-2021, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#define __ASSEMBLY__ ++#include ++ ++ .globl sp_svc ++ ++func sp_svc ++ /* ++ * Save the address of the svc_args structure on the stack. ++ * ++ * Although x0 contains an 8-byte value, we are allocating 16 bytes ++ * on the stack to respect the 16-byte stack-alignment. ++ */ ++ str x0, [sp, #-16]! ++ ++ /* Load the SVC arguments values into the appropriate registers. */ ++ ldp x6, x7, [x0, #48] ++ ldp x4, x5, [x0, #32] ++ ldp x2, x3, [x0, #16] ++ ldp x0, x1, [x0, #0] ++ ++ svc #0 ++ ++ /* ++ * Pop the svc_args structure address from the stack into a caller-saved ++ * register. ++ */ ++ ldr x9, [sp], #16 ++ ++ /* ++ * The return values are stored in x0-x3, put them in the svc_args ++ * return structure. ++ */ ++ stp x0, x1, [x9, #0] ++ stp x2, x3, [x9, #16] ++ ret ++endfunc sp_svc +diff --git a/environments/shim/spm/common/sp_debug.c b/environments/shim/spm/common/sp_debug.c +new file mode 100644 +index 0000000..8182abb +--- /dev/null ++++ b/environments/shim/spm/common/sp_debug.c +@@ -0,0 +1,68 @@ ++/* ++ * Copyright (c) 2021, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include ++#include ++#include ++#include ++ ++ ++static int (*putc_impl)(int); ++ ++static int putc_hypcall(int c) ++{ ++ spm_debug_log((char)c); ++ ++ return c; ++} ++ ++static int putc_svccall(int c) ++{ ++ /* TODO svc call */ ++ svc_args args = { ++ .fid = SPM_DEBUG_LOG, ++ .arg1 = c ++ }; ++ sp_svc(&args); ++ ++ return c; ++} ++ ++static int putc_uart(int c) ++{ ++ console_pl011_putc(c); ++ ++ return c; ++} ++ ++void set_putc_impl(enum stdout_route route) ++{ ++ switch (route) { ++ ++ case HVC_CALL_AS_STDOUT: ++ putc_impl = putc_hypcall; ++ return; ++ ++ case SVC_CALL_AS_STDOUT: ++ putc_impl = putc_svccall; ++ return; ++ ++ case PL011_AS_STDOUT: ++ default: ++ break; ++ } ++ ++ putc_impl = putc_uart; ++} ++ ++int console_putc(int c) ++{ ++ if (!putc_impl) { ++ return -1; ++ } ++ ++ return putc_impl(c); ++} +diff --git a/environments/shim/spm/common/sp_debug.h b/environments/shim/spm/common/sp_debug.h +new file mode 100644 +index 0000000..e35c602 +--- /dev/null ++++ b/environments/shim/spm/common/sp_debug.h +@@ -0,0 +1,13 @@ ++/* ++ * Copyright (c) 2021, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++enum stdout_route { ++ PL011_AS_STDOUT = 0, ++ HVC_CALL_AS_STDOUT, ++ SVC_CALL_AS_STDOUT, ++}; ++ ++void set_putc_impl(enum stdout_route); +diff --git a/environments/shim/spm/common/sp_helpers.c b/environments/shim/spm/common/sp_helpers.c +new file mode 100644 +index 0000000..1b650d3 +--- /dev/null ++++ b/environments/shim/spm/common/sp_helpers.c +@@ -0,0 +1,97 @@ ++/* ++ * Copyright (c) 2018, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "sp_helpers.h" ++ ++uintptr_t bound_rand(uintptr_t min, uintptr_t max) ++{ ++ /* ++ * This is not ideal as some numbers will never be generated because of ++ * the integer arithmetic rounding. ++ */ ++ return ((rand() * (UINT64_MAX/RAND_MAX)) % (max - min)) + min; ++} ++ ++/******************************************************************************* ++ * Test framework helpers ++ ******************************************************************************/ ++ ++void expect(int expr, int expected) ++{ ++ if (expr != expected) { ++ ERROR("Expected value %i, got %i\n", expected, expr); ++ while (1) ++ continue; ++ } ++} ++ ++void announce_test_section_start(const char *test_sect_desc) ++{ ++ INFO("========================================\n"); ++ INFO("Starting %s tests\n", test_sect_desc); ++ INFO("========================================\n"); ++} ++void announce_test_section_end(const char *test_sect_desc) ++{ ++ INFO("========================================\n"); ++ INFO("End of %s tests\n", test_sect_desc); ++ INFO("========================================\n"); ++} ++ ++void announce_test_start(const char *test_desc) ++{ ++ INFO("[+] %s\n", test_desc); ++} ++ ++void announce_test_end(const char *test_desc) ++{ ++ INFO("Test \"%s\" end.\n", test_desc); ++} ++ ++void sp_sleep(uint32_t ms) ++{ ++ uint64_t timer_freq = mmio_read_32(SYS_CNT_CONTROL_BASE + CNTFID_OFF); ++ VERBOSE("%s: Timer frequency = %llu\n", __func__, timer_freq); ++ ++ VERBOSE("%s: Sleeping for %u milliseconds...\n", __func__, ms); ++ uint64_t time1 = mmio_read_64(SYS_CNT_READ_BASE); ++ volatile uint64_t time2 = time1; ++ while ((time2 - time1) < ((ms * timer_freq) / 1000U)) { ++ time2 = mmio_read_64(SYS_CNT_READ_BASE); ++ } ++} ++ ++/******************************************************************************* ++ * Hypervisor Calls Wrappers ++ ******************************************************************************/ ++ ++ffa_int_id_t spm_interrupt_get(void) ++{ ++ hvc_args args = { ++ .fid = SPM_INTERRUPT_GET ++ }; ++ ++ hvc_ret_values ret = tftf_hvc(&args); ++ ++ return ret.ret0; ++} ++ ++void spm_debug_log(char c) ++{ ++ hvc_args args = { ++ .fid = SPM_DEBUG_LOG, ++ .arg1 = c ++ }; ++ ++ (void)tftf_hvc(&args); ++} +diff --git a/environments/shim/spm/common/sp_helpers.h b/environments/shim/spm/common/sp_helpers.h +new file mode 100644 +index 0000000..ec92227 +--- /dev/null ++++ b/environments/shim/spm/common/sp_helpers.h +@@ -0,0 +1,76 @@ ++/* ++ * Copyright (c) 2018-2020, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef SP_HELPERS_H ++#define SP_HELPERS_H ++ ++#include ++#include ++#include ++ ++#define SPM_VM_ID_FIRST SP_ID(1) ++ ++/* Should match with IDs defined in SPM/Hafnium */ ++#define SPM_INTERRUPT_GET (0xFF04) ++#define SPM_DEBUG_LOG (0xBD000000) ++ ++typedef struct { ++ u_register_t fid; ++ u_register_t arg1; ++ u_register_t arg2; ++ u_register_t arg3; ++ u_register_t arg4; ++ u_register_t arg5; ++ u_register_t arg6; ++ u_register_t arg7; ++} svc_args; ++ ++/* ++ * Trigger an SVC call. ++ * ++ * The arguments to pass through the SVC call must be stored in the svc_args ++ * structure. The return values of the SVC call will be stored in the same ++ * structure (overriding the input arguments). ++ * ++ * Return the first return value. It is equivalent to args.fid but is also ++ * provided as the return value for convenience. ++ */ ++u_register_t sp_svc(svc_args *args); ++ ++/* ++ * Choose a pseudo-random number within the [min,max] range (both limits are ++ * inclusive). ++ */ ++uintptr_t bound_rand(uintptr_t min, uintptr_t max); ++ ++/* ++ * Check that expr == expected. ++ * If not, loop forever. ++ */ ++void expect(int expr, int expected); ++ ++/* ++ * Test framework functions ++ */ ++ ++void announce_test_section_start(const char *test_sect_desc); ++void announce_test_section_end(const char *test_sect_desc); ++ ++void announce_test_start(const char *test_desc); ++void announce_test_end(const char *test_desc); ++ ++/* Sleep for at least 'ms' milliseconds. */ ++void sp_sleep(uint32_t ms); ++ ++/* ++ * Hypervisor Calls Wrappers ++ */ ++ ++ffa_int_id_t spm_interrupt_get(void); ++ ++void spm_debug_log(char c); ++ ++#endif /* SP_HELPERS_H */ +diff --git a/external/bget/bget.cmake b/external/bget/bget.cmake +new file mode 100644 +index 0000000..b51882a +--- /dev/null ++++ b/external/bget/bget.cmake +@@ -0,0 +1,52 @@ ++#------------------------------------------------------------------------------- ++# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. ++# ++# SPDX-License-Identifier: BSD-3-Clause ++# ++#------------------------------------------------------------------------------- ++cmake_minimum_required(VERSION 3.18) ++ ++set(BGET_ARCHIVE_FILE "${CMAKE_BINARY_DIR}/bget.tgz" CACHE PATH "Full path of BGET archive file") ++set(BGET_DIR "${CMAKE_BINARY_DIR}/bget" CACHE PATH "Path to BGET source") ++ ++function(dl_bget) ++ file(DOWNLOAD "https://www.fourmilab.ch/bget/bget.tar.gz" ${BGET_ARCHIVE_FILE} STATUS "_dl_res") ++ list(GET _dl_res 0 _dl_rv) ++ if(_dl_rv) ++ list(GET _dl_res 1 _dl_error) ++ message(FATAL_ERROR "Failed to download bget: ${_dl_error}") ++ endif() ++endfunction() ++ ++set(_bget_src "${TS_ROOT}/environments/shim/lib/libc") ++set(_bget_inc "${TS_ROOT}/environments/shim/include/lib/libc") ++ ++# If bget source is missing from project. ++if(NOT EXISTS "${_bget_inc}/bget.h" OR NOT EXISTS "${_bget_src}/bget.c") ++ # If bget source is not extracted. ++ if(NOT EXISTS "${BGET_DIR}/bget.h") ++ # if the archive is not downloaded ++ if(NOT EXISTS "${BGET_ARCHIVE_FILE}") ++ dl_bget() ++ endif() ++ ++ file(ARCHIVE_EXTRACT ++ INPUT "${BGET_ARCHIVE_FILE}" ++ DESTINATION "${BGET_DIR}" ++ ) ++ ++ if(NOT EXISTS "${BGET_DIR}/bget.c") ++ message(FATAL_ERROR "Failed to extract ${BGET_ARCHIVE_FILE}") ++ endif() ++ endif() ++ ++ # copy files to project ++ file(COPY "${BGET_DIR}/bget.c" DESTINATION "${_bget_src}") ++ file(COPY "${BGET_DIR}/bget.h" DESTINATION "${_bget_inc}") ++ ++ # Apply patch ++ execute_process(COMMAND git apply external/bget/bget.patch ++ WORKING_DIRECTORY ${TS_ROOT} ++ ) ++ ++endif() +diff --git a/external/bget/bget.patch b/external/bget/bget.patch +new file mode 100644 +index 0000000..382c5cd +--- /dev/null ++++ b/external/bget/bget.patch +@@ -0,0 +1,675 @@ ++Copyright (c) 2015, Linaro Limited ++Copyright (c) 2021, Arm Limited ++SPDX-License-Identifier: BSD-2-Clause ++ ++This file contains work dervived form OP-TEE os. The work is based on ++https://github.com/OP-TEE/optee_os SHA: 203ee23d005b2cec2f21b5de334c5a246be32599 ++ ++This patch allows re-creating the same state for the covered fies as can be seen ++in the version designated above. ++ ++diff --git a/environments/shim/include/lib/libc/bget.h b/environments/shim/include/lib/libc/bget.h ++index 0c72d0e..8071639 100644 ++--- a/environments/shim/include/lib/libc/bget.h +++++ b/environments/shim/include/lib/libc/bget.h ++@@ -1,9 +1,23 @@ +++/* +++ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED +++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +++ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +++ * IN NO EVENT SHALL ST BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +++ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +++ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +++ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +++ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +++ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +++ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +++ */ +++ ++ /* ++ ++ Interface definitions for bget.c, the memory management package. ++ ++ */ ++ +++ ++ #ifndef _ ++ #ifdef PROTOTYPES ++ #define _(x) x /* If compiler knows prototypes */ ++@@ -13,18 +27,23 @@ ++ #endif ++ ++ typedef long bufsize; ++-void bpool _((void *buffer, bufsize len)); ++-void *bget _((bufsize size)); ++-void *bgetz _((bufsize size)); ++-void *bgetr _((void *buffer, bufsize newsize)); ++-void brel _((void *buf)); +++struct bpoolset; +++ +++void bpool _((void *buffer, bufsize len, struct bpoolset *poolset)); +++void *bget _((bufsize size, struct bpoolset *poolset)); +++void *bgetz _((bufsize size, struct bpoolset *poolset)); +++void *bgetr _((void *buffer, bufsize newsize, +++ struct bpoolset *poolset)); +++void brel _((void *buf, struct bpoolset *poolset, int wipe)); ++ void bectl _((int (*compact)(bufsize sizereq, int sequence), ++ void *(*acquire)(bufsize size), ++- void (*release)(void *buf), bufsize pool_incr)); +++ void (*release)(void *buf), bufsize pool_incr, +++ struct bpoolset *poolset)); ++ void bstats _((bufsize *curalloc, bufsize *totfree, bufsize *maxfree, ++- long *nget, long *nrel)); +++ long *nget, long *nrel, struct bpoolset *poolset)); ++ void bstatse _((bufsize *pool_incr, long *npool, long *npget, ++- long *nprel, long *ndget, long *ndrel)); +++ long *nprel, long *ndget, long *ndrel, +++ struct bpoolset *poolset)); ++ void bufdump _((void *buf)); ++ void bpoold _((void *pool, int dumpalloc, int dumpfree)); ++ int bpoolv _((void *pool)); ++diff --git a/environments/shim/lib/libc/bget.c b/environments/shim/lib/libc/bget.c ++index 5423cb9..3e3d644 100644 ++--- a/environments/shim/lib/libc/bget.c +++++ b/environments/shim/lib/libc/bget.c ++@@ -398,6 +398,21 @@ ++ ================== ++ */ ++ +++/* +++ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED +++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +++ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +++ * IN NO EVENT SHALL ST BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +++ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +++ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +++ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +++ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +++ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +++ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +++ */ +++ +++/* #define BGET_ENABLE_ALL_OPTIONS */ +++#ifdef BGET_ENABLE_OPTION ++ #define TestProg 20000 /* Generate built-in test program ++ if defined. The value specifies ++ how many buffer allocation attempts ++@@ -414,7 +429,7 @@ ++ ++ #define BufValid 1 /* Define this symbol to enable the ++ bpoolv() function for validating ++- a buffer pool. */ +++ a buffer pool. */ ++ ++ #define DumpData 1 /* Define this symbol to enable the ++ bufdump() function which allows ++@@ -442,8 +457,10 @@ ++ #define BECtl 1 /* Define this symbol to enable the ++ bectl() function for automatic ++ pool space control. */ +++#endif ++ ++ #include +++#include ++ ++ #ifdef lint ++ #define NDEBUG /* Exits in asserts confuse lint */ ++@@ -464,6 +481,12 @@ extern char *sprintf(); /* Sun includes don't define sprintf */ ++ #include ++ #endif ++ +++#ifdef __KERNEL__ +++#ifdef CFG_CORE_BGET_BESTFIT +++#define BestFit 1 +++#endif +++#endif +++ ++ /* Declare the interface, including the requested buffer size type, ++ bufsize. */ ++ ++@@ -506,38 +529,38 @@ struct bfhead { ++ }; ++ #define BFH(p) ((struct bfhead *) (p)) ++ ++-static struct bfhead freelist = { /* List of free buffers */ ++- {0, 0}, ++- {&freelist, &freelist} ++-}; ++- ++- +++/* Poolset definition */ +++struct bpoolset { +++ struct bfhead freelist; ++ #ifdef BufStats ++-static bufsize totalloc = 0; /* Total space currently allocated */ ++-static long numget = 0, numrel = 0; /* Number of bget() and brel() calls */ +++ bufsize totalloc; /* Total space currently allocated */ +++ long numget; /* Number of bget() calls */ +++ long numrel; /* Number of brel() calls */ ++ #ifdef BECtl ++-static long numpblk = 0; /* Number of pool blocks */ ++-static long numpget = 0, numprel = 0; /* Number of block gets and rels */ ++-static long numdget = 0, numdrel = 0; /* Number of direct gets and rels */ +++ long numpblk; /* Number of pool blocks */ +++ long numpget; /* Number of block gets and rels */ +++ long numprel; +++ long numdget; /* Number of direct gets and rels */ +++ long numdrel; ++ #endif /* BECtl */ ++ #endif /* BufStats */ ++ ++ #ifdef BECtl +++ /* Automatic expansion block management functions */ ++ ++-/* Automatic expansion block management functions */ +++ int (*compfcn) _((bufsize sizereq, int sequence)); +++ void *(*acqfcn) _((bufsize size)); +++ void (*relfcn) _((void *buf)); ++ ++-static int (*compfcn) _((bufsize sizereq, int sequence)) = NULL; ++-static void *(*acqfcn) _((bufsize size)) = NULL; ++-static void (*relfcn) _((void *buf)) = NULL; ++- ++-static bufsize exp_incr = 0; /* Expansion block size */ ++-static bufsize pool_len = 0; /* 0: no bpool calls have been made +++ bufsize exp_incr; /* Expansion block size */ +++ bufsize pool_len; /* 0: no bpool calls have been made ++ -1: not all pool blocks are ++ the same size ++ >0: (common) block size for all ++ bpool calls made so far ++ */ ++ #endif +++}; ++ ++ /* Minimum allocation quantum: */ ++ ++@@ -554,8 +577,9 @@ static bufsize pool_len = 0; /* 0: no bpool calls have been made ++ ++ /* BGET -- Allocate a buffer. */ ++ ++-void *bget(requested_size) +++void *bget(requested_size, poolset) ++ bufsize requested_size; +++ struct bpoolset *poolset; ++ { ++ bufsize size = requested_size; ++ struct bfhead *b; ++@@ -574,12 +598,16 @@ void *bget(requested_size) ++ } ++ #ifdef SizeQuant ++ #if SizeQuant > 1 ++- size = (size + (SizeQuant - 1)) & (~(SizeQuant - 1)); +++ if (ADD_OVERFLOW(size, SizeQuant - 1, &size)) +++ return NULL; +++ +++ size = ROUNDDOWN(size, SizeQuant); ++ #endif ++ #endif ++ ++- size += sizeof(struct bhead); /* Add overhead in allocated buffer ++- to size required. */ +++ /* Add overhead in allocated buffer to size required. */ +++ if (ADD_OVERFLOW(size, sizeof(struct bhead), &size)) +++ return NULL; ++ ++ #ifdef BECtl ++ /* If a compact function was provided in the call to bectl(), wrap ++@@ -588,9 +616,9 @@ void *bget(requested_size) ++ ++ while (1) { ++ #endif ++- b = freelist.ql.flink; +++ b = poolset->freelist.ql.flink; ++ #ifdef BestFit ++- best = &freelist; +++ best = &poolset->freelist; ++ #endif ++ ++ ++@@ -598,9 +626,10 @@ void *bget(requested_size) ++ to hold the requested size buffer. */ ++ ++ #ifdef BestFit ++- while (b != &freelist) { +++ while (b != &poolset->freelist) { ++ if (b->bh.bsize >= size) { ++- if ((best == &freelist) || (b->bh.bsize < best->bh.bsize)) { +++ if ((best == &poolset->freelist) || +++ (b->bh.bsize < best->bh.bsize)) { ++ best = b; ++ } ++ } ++@@ -609,7 +638,7 @@ void *bget(requested_size) ++ b = best; ++ #endif /* BestFit */ ++ ++- while (b != &freelist) { +++ while (b != &poolset->freelist) { ++ if ((bufsize) b->bh.bsize >= size) { ++ ++ /* Buffer is big enough to satisfy the request. Allocate it ++@@ -637,10 +666,11 @@ void *bget(requested_size) ++ bn->prevfree = 0; ++ ++ #ifdef BufStats ++- totalloc += size; ++- numget++; /* Increment number of bget() calls */ +++ poolset->totalloc += size; +++ poolset->numget++; /* Increment number of bget() calls */ ++ #endif ++ buf = (void *) ((((char *) ba) + sizeof(struct bhead))); +++ tag_asan_alloced(buf, size); ++ return buf; ++ } else { ++ struct bhead *ba; ++@@ -657,8 +687,8 @@ void *bget(requested_size) ++ b->ql.flink->ql.blink = b->ql.blink; ++ ++ #ifdef BufStats ++- totalloc += b->bh.bsize; ++- numget++; /* Increment number of bget() calls */ +++ poolset->totalloc += b->bh.bsize; +++ poolset->numget++; /* Increment number of bget() calls */ ++ #endif ++ /* Negate size to mark buffer allocated. */ ++ b->bh.bsize = -(b->bh.bsize); ++@@ -669,6 +699,7 @@ void *bget(requested_size) ++ ++ /* Give user buffer starting at queue links. */ ++ buf = (void *) &(b->ql); +++ tag_asan_alloced(buf, size); ++ return buf; ++ } ++ } ++@@ -680,7 +711,8 @@ void *bget(requested_size) ++ defined, notify it of the size requested. If it returns ++ TRUE, try the allocation again. */ ++ ++- if ((compfcn == NULL) || (!(*compfcn)(size, ++compactseq))) { +++ if ((poolset->compfcn == NULL) || +++ (!(poolset->compfcn)(size, ++compactseq))) { ++ break; ++ } ++ } ++@@ -689,7 +721,7 @@ void *bget(requested_size) ++ ++ /* Don't give up yet -- look in the reserve supply. */ ++ ++- if (acqfcn != NULL) { +++ if (poolset->acqfcn != NULL) { ++ if (size > exp_incr - sizeof(struct bhead)) { ++ ++ /* Request is too large to fit in a single expansion ++@@ -706,11 +738,12 @@ void *bget(requested_size) ++ bdh->bh.prevfree = 0; ++ bdh->tsize = size; ++ #ifdef BufStats ++- totalloc += size; ++- numget++; /* Increment number of bget() calls */ ++- numdget++; /* Direct bget() call count */ +++ poolset->totalloc += size; +++ poolset->numget++; /* Increment number of bget() calls */ +++ poolset->numdget++; /* Direct bget() call count */ ++ #endif ++ buf = (void *) (bdh + 1); +++ tag_asan_alloced(buf, size); ++ return buf; ++ } ++ ++@@ -720,10 +753,10 @@ void *bget(requested_size) ++ ++ void *newpool; ++ ++- if ((newpool = (*acqfcn)((bufsize) exp_incr)) != NULL) { ++- bpool(newpool, exp_incr); ++- buf = bget(requested_size); /* This can't, I say, can't ++- get into a loop. */ +++ if ((newpool = poolset->acqfcn((bufsize) exp_incr)) != NULL) { +++ bpool(newpool, exp_incr, poolset); +++ buf = bget(requested_size, pool); /* This can't, I say, can't +++ get into a loop. */ ++ return buf; ++ } ++ } ++@@ -740,10 +773,11 @@ void *bget(requested_size) ++ the entire contents of the buffer to zero, not just the ++ region requested by the caller. */ ++ ++-void *bgetz(size) +++void *bgetz(size, poolset) ++ bufsize size; +++ struct bpoolset *poolset; ++ { ++- char *buf = (char *) bget(size); +++ char *buf = (char *) bget(size, poolset); ++ ++ if (buf != NULL) { ++ struct bhead *b; ++@@ -760,7 +794,7 @@ void *bgetz(size) ++ rsize -= sizeof(struct bhead); ++ } ++ assert(rsize >= size); ++- V memset(buf, 0, (MemSize) rsize); +++ V memset_unchecked(buf, 0, (MemSize) rsize); ++ } ++ return ((void *) buf); ++ } ++@@ -770,15 +804,16 @@ void *bgetz(size) ++ enhanced to allow the buffer to grow into adjacent free ++ blocks and to avoid moving data unnecessarily. */ ++ ++-void *bgetr(buf, size) +++void *bgetr(buf, size, poolset) ++ void *buf; ++ bufsize size; +++ struct bpoolset *poolset; ++ { ++ void *nbuf; ++ bufsize osize; /* Old size of buffer */ ++ struct bhead *b; ++ ++- if ((nbuf = bget(size)) == NULL) { /* Acquire new buffer */ +++ if ((nbuf = bget(size, poolset)) == NULL) { /* Acquire new buffer */ ++ return NULL; ++ } ++ if (buf == NULL) { ++@@ -799,23 +834,34 @@ void *bgetr(buf, size) ++ assert(osize > 0); ++ V memcpy((char *) nbuf, (char *) buf, /* Copy the data */ ++ (MemSize) ((size < osize) ? size : osize)); ++- brel(buf); +++#ifndef __KERNEL__ +++ /* User space reallocations are always zeroed */ +++ if (size > osize) +++ V memset((char *) nbuf + osize, 0, size - osize); +++#endif +++ brel(buf, poolset, false /* !wipe */); ++ return nbuf; ++ } ++ ++ /* BREL -- Release a buffer. */ ++ ++-void brel(buf) +++void brel(buf, poolset, wipe) ++ void *buf; +++ struct bpoolset *poolset; +++ int wipe; ++ { ++ struct bfhead *b, *bn; +++ bufsize bs; ++ ++ b = BFH(((char *) buf) - sizeof(struct bhead)); ++ #ifdef BufStats ++- numrel++; /* Increment number of brel() calls */ +++ poolset->numrel++; /* Increment number of brel() calls */ ++ #endif ++ assert(buf != NULL); ++ +++#ifdef FreeWipe +++ wipe = true; +++#endif ++ #ifdef BECtl ++ if (b->bh.bsize == 0) { /* Directly-acquired buffer? */ ++ struct bdhead *bdh; ++@@ -823,16 +869,19 @@ void brel(buf) ++ bdh = BDH(((char *) buf) - sizeof(struct bdhead)); ++ assert(b->bh.prevfree == 0); ++ #ifdef BufStats ++- totalloc -= bdh->tsize; ++- assert(totalloc >= 0); ++- numdrel++; /* Number of direct releases */ +++ poolset->totalloc -= bdh->tsize; +++ assert(poolset->totalloc >= 0); +++ poolset->numdrel++; /* Number of direct releases */ ++ #endif /* BufStats */ ++-#ifdef FreeWipe ++- V memset((char *) buf, 0x55, ++- (MemSize) (bdh->tsize - sizeof(struct bdhead))); ++-#endif /* FreeWipe */ ++- assert(relfcn != NULL); ++- (*relfcn)((void *) bdh); /* Release it directly. */ +++ if (wipe) { +++ V memset_unchecked((char *) buf, 0x55, +++ (MemSize) (bdh->tsize - +++ sizeof(struct bdhead))); +++ } +++ bs = bdh->tsize - sizeof(struct bdhead); +++ assert(poolset->relfcn != NULL); +++ poolset->relfcn((void *) bdh); /* Release it directly. */ +++ tag_asan_free(buf, bs); ++ return; ++ } ++ #endif /* BECtl */ ++@@ -844,6 +893,7 @@ void brel(buf) ++ bn = NULL; ++ } ++ assert(b->bh.bsize < 0); +++ bs = -b->bh.bsize; ++ ++ /* Back pointer in next buffer must be zero, indicating the ++ same thing: */ ++@@ -851,8 +901,8 @@ void brel(buf) ++ assert(BH((char *) b - b->bh.bsize)->prevfree == 0); ++ ++ #ifdef BufStats ++- totalloc += b->bh.bsize; ++- assert(totalloc >= 0); +++ poolset->totalloc += b->bh.bsize; +++ assert(poolset->totalloc >= 0); ++ #endif ++ ++ /* If the back link is nonzero, the previous buffer is free. */ ++@@ -876,11 +926,11 @@ void brel(buf) ++ /* The previous buffer isn't allocated. Insert this buffer ++ on the free list as an isolated free block. */ ++ ++- assert(freelist.ql.blink->ql.flink == &freelist); ++- assert(freelist.ql.flink->ql.blink == &freelist); ++- b->ql.flink = &freelist; ++- b->ql.blink = freelist.ql.blink; ++- freelist.ql.blink = b; +++ assert(poolset->freelist.ql.blink->ql.flink == &poolset->freelist); +++ assert(poolset->freelist.ql.flink->ql.blink == &poolset->freelist); +++ b->ql.flink = &poolset->freelist; +++ b->ql.blink = poolset->freelist.ql.blink; +++ poolset->freelist.ql.blink = b; ++ b->ql.blink->ql.flink = b; ++ b->bh.bsize = -b->bh.bsize; ++ } ++@@ -912,10 +962,10 @@ void brel(buf) ++ ++ bn = BFH(((char *) b) + b->bh.bsize); ++ } ++-#ifdef FreeWipe ++- V memset(((char *) b) + sizeof(struct bfhead), 0x55, ++- (MemSize) (b->bh.bsize - sizeof(struct bfhead))); ++-#endif +++ if (wipe) { +++ V memset_unchecked(((char *) b) + sizeof(struct bfhead), 0x55, +++ (MemSize) (b->bh.bsize - sizeof(struct bfhead))); +++ } ++ assert(bn->bh.bsize < 0); ++ ++ /* The next buffer is allocated. Set the backpointer in it to point ++@@ -930,7 +980,7 @@ void brel(buf) ++ is defined in such a way that the test will fail unless all ++ pool blocks are the same size. */ ++ ++- if (relfcn != NULL && +++ if (poolset->relfcn != NULL && ++ ((bufsize) b->bh.bsize) == (pool_len - sizeof(struct bhead))) { ++ ++ assert(b->bh.prevfree == 0); ++@@ -940,38 +990,41 @@ void brel(buf) ++ b->ql.blink->ql.flink = b->ql.flink; ++ b->ql.flink->ql.blink = b->ql.blink; ++ ++- (*relfcn)(b); +++ poolset->relfcn(b); ++ #ifdef BufStats ++- numprel++; /* Nr of expansion block releases */ ++- numpblk--; /* Total number of blocks */ +++ poolset->numprel++; /* Nr of expansion block releases */ +++ poolset->numpblk--; /* Total number of blocks */ ++ assert(numpblk == numpget - numprel); ++ #endif /* BufStats */ ++ } ++ #endif /* BECtl */ +++ tag_asan_free(buf, bs); ++ } ++ ++ #ifdef BECtl ++ ++ /* BECTL -- Establish automatic pool expansion control */ ++ ++-void bectl(compact, acquire, release, pool_incr) +++void bectl(compact, acquire, release, pool_incr, poolset) ++ int (*compact) _((bufsize sizereq, int sequence)); ++ void *(*acquire) _((bufsize size)); ++ void (*release) _((void *buf)); ++ bufsize pool_incr; +++ struct bpoolset *poolset; ++ { ++- compfcn = compact; ++- acqfcn = acquire; ++- relfcn = release; ++- exp_incr = pool_incr; +++ poolset->compfcn = compact; +++ poolset->acqfcn = acquire; +++ poolset->relfcn = release; +++ poolset->exp_incr = pool_incr; ++ } ++ #endif ++ ++ /* BPOOL -- Add a region of memory to the buffer pool. */ ++ ++-void bpool(buf, len) +++void bpool(buf, len, poolset) ++ void *buf; ++ bufsize len; +++ struct bpoolset *poolset; ++ { ++ struct bfhead *b = BFH(buf); ++ struct bhead *bn; ++@@ -980,15 +1033,15 @@ void bpool(buf, len) ++ len &= ~(SizeQuant - 1); ++ #endif ++ #ifdef BECtl ++- if (pool_len == 0) { +++ if (poolset->pool_len == 0) { ++ pool_len = len; ++- } else if (len != pool_len) { ++- pool_len = -1; +++ } else if (len != poolset->pool_len) { +++ poolset->pool_len = -1; ++ } ++ #ifdef BufStats ++- numpget++; /* Number of block acquisitions */ ++- numpblk++; /* Number of blocks total */ ++- assert(numpblk == numpget - numprel); +++ poolset->numpget++; /* Number of block acquisitions */ +++ poolset->numpblk++; /* Number of blocks total */ +++ assert(poolset->numpblk == poolset->numpget - poolset->numprel); ++ #endif /* BufStats */ ++ #endif /* BECtl */ ++ ++@@ -1006,11 +1059,11 @@ void bpool(buf, len) ++ ++ /* Chain the new block to the free list. */ ++ ++- assert(freelist.ql.blink->ql.flink == &freelist); ++- assert(freelist.ql.flink->ql.blink == &freelist); ++- b->ql.flink = &freelist; ++- b->ql.blink = freelist.ql.blink; ++- freelist.ql.blink = b; +++ assert(poolset->freelist.ql.blink->ql.flink == &poolset->freelist); +++ assert(poolset->freelist.ql.flink->ql.blink == &poolset->freelist); +++ b->ql.flink = &poolset->freelist; +++ b->ql.blink = poolset->freelist.ql.blink; +++ poolset->freelist.ql.blink = b; ++ b->ql.blink->ql.flink = b; ++ ++ /* Create a dummy allocated buffer at the end of the pool. This dummy ++@@ -1024,8 +1077,8 @@ void bpool(buf, len) ++ len -= sizeof(struct bhead); ++ b->bh.bsize = (bufsize) len; ++ #ifdef FreeWipe ++- V memset(((char *) b) + sizeof(struct bfhead), 0x55, ++- (MemSize) (len - sizeof(struct bfhead))); +++ V memset_unchecked(((char *) b) + sizeof(struct bfhead), 0x55, +++ (MemSize) (len - sizeof(struct bfhead))); ++ #endif ++ bn = BH(((char *) b) + len); ++ bn->prevfree = (bufsize) len; ++@@ -1038,18 +1091,19 @@ void bpool(buf, len) ++ ++ /* BSTATS -- Return buffer allocation free space statistics. */ ++ ++-void bstats(curalloc, totfree, maxfree, nget, nrel) +++void bstats(curalloc, totfree, maxfree, nget, nrel, poolset) ++ bufsize *curalloc, *totfree, *maxfree; ++ long *nget, *nrel; +++ struct bpoolset *poolset; ++ { ++- struct bfhead *b = freelist.ql.flink; +++ struct bfhead *b = poolset->freelist.ql.flink; ++ ++- *nget = numget; ++- *nrel = numrel; ++- *curalloc = totalloc; +++ *nget = poolset->numget; +++ *nrel = poolset->numrel; +++ *curalloc = poolset->totalloc; ++ *totfree = 0; ++ *maxfree = -1; ++- while (b != &freelist) { +++ while (b != &poolset->freelist) { ++ assert(b->bh.bsize > 0); ++ *totfree += b->bh.bsize; ++ if (b->bh.bsize > *maxfree) { ++@@ -1063,16 +1117,18 @@ void bstats(curalloc, totfree, maxfree, nget, nrel) ++ ++ /* BSTATSE -- Return extended statistics */ ++ ++-void bstatse(pool_incr, npool, npget, nprel, ndget, ndrel) +++void bstatse(pool_incr, npool, npget, nprel, ndget, ndrel, poolset) ++ bufsize *pool_incr; ++ long *npool, *npget, *nprel, *ndget, *ndrel; +++ struct bpoolset *poolset; ++ { ++- *pool_incr = (pool_len < 0) ? -exp_incr : exp_incr; ++- *npool = numpblk; ++- *npget = numpget; ++- *nprel = numprel; ++- *ndget = numdget; ++- *ndrel = numdrel; +++ *pool_incr = (poolset->pool_len < 0) ? +++ -poolset->exp_incr : poolset->exp_incr; +++ *npool = poolset->numpblk; +++ *npget = poolset->numpget; +++ *nprel = poolset->numprel; +++ *ndget = poolset->numdget; +++ *ndrel = poolset->numdrel; ++ } ++ #endif /* BECtl */ ++ #endif /* BufStats */ ++@@ -1110,7 +1166,8 @@ void bufdump(buf) ++ } ++ ++ for (i = 0; i < l; i++) { ++- V sprintf(bhex + i * 3, "%02X ", bdump[i]); +++ V snprintf(bhex + i * 3, sizeof(bhex) - i * 3, "%02X ", +++ bdump[i]); ++ bascii[i] = isprint(bdump[i]) ? bdump[i] : ' '; ++ } ++ bascii[i] = 0; ++@@ -1203,7 +1260,7 @@ int bpoolv(buf) ++ if (bs < 0) { ++ bs = -bs; ++ } else { ++- char *lerr = ""; +++ const char *lerr = ""; ++ ++ assert(bs > 0); ++ if (bs <= 0) { +-- +2.29.2 + diff --git a/meta-arm/recipes-security/trusted-services/files/0002-Change-instruction-access-permissions-of-shared-memo.patch b/meta-arm/recipes-security/trusted-services/files/0002-Change-instruction-access-permissions-of-shared-memo.patch new file mode 100644 index 00000000..c63aa8d8 --- /dev/null +++ b/meta-arm/recipes-security/trusted-services/files/0002-Change-instruction-access-permissions-of-shared-memo.patch @@ -0,0 +1,41 @@ +From 5930446f09ab1df10ca70f47a3d1bb21a010effe Mon Sep 17 00:00:00 2001 +From: Davidson K +Date: Fri, 5 Feb 2021 12:29:37 +0530 +Subject: [PATCH 02/13] Change instruction access permissions of shared memory + +According to the FFA spec (Section 5.11.3 - Instruction Access Permissions Usage) +the instruction access permission of the memory that has to be shared should be +set as "Not specified and must be ignored" by the Lender in an invocation of +FFA_MEM_SHARE or FFA_MEM_LEND ABIs. + +Upstream-Status: Pending [Not submitted to upstream yet] +Signed-off-by: Davidson K +Change-Id: I6d84c46da8c648f93673afd7cf06a88cd4de139e +Signed-off-by: Ben Horgan +--- + components/rpc/ffarpc/caller/sp/ffarpc_caller.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/components/rpc/ffarpc/caller/sp/ffarpc_caller.c b/components/rpc/ffarpc/caller/sp/ffarpc_caller.c +index 9d98512..269cbd4 100644 +--- a/components/rpc/ffarpc/caller/sp/ffarpc_caller.c ++++ b/components/rpc/ffarpc/caller/sp/ffarpc_caller.c +@@ -1,5 +1,5 @@ + /* +- * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. ++ * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +@@ -211,7 +211,7 @@ int ffarpc_caller_open(struct ffarpc_caller *s, uint16_t call_ep_id) + desc.mem_region_attr.normal_memory.shareability = sp_shareability_inner_shareable; + + acc_desc.data_access = sp_data_access_read_write; +- acc_desc.instruction_access = sp_instruction_access_not_executable; ++ acc_desc.instruction_access = sp_instruction_access_not_specified; + acc_desc.receiver_id = call_ep_id; + + region.address = shared_buffer; +-- +2.29.2 + diff --git a/meta-arm/recipes-security/trusted-services/files/0003-Set-in_region_count-to-0-during-memory-retrieve.patch b/meta-arm/recipes-security/trusted-services/files/0003-Set-in_region_count-to-0-during-memory-retrieve.patch new file mode 100644 index 00000000..bdc5924c --- /dev/null +++ b/meta-arm/recipes-security/trusted-services/files/0003-Set-in_region_count-to-0-during-memory-retrieve.patch @@ -0,0 +1,39 @@ +From 6109a46678f147b6b617edf3805738f2f41b0f19 Mon Sep 17 00:00:00 2001 +From: Davidson K +Date: Fri, 5 Feb 2021 18:27:05 +0530 +Subject: [PATCH 03/13] Set in_region_count to 0 during memory retrieve + +in_region_count will be used during the lend, donate and share memory +transactions and it is not needed for the retrieve request. + +Upstream-Status: Pending [Not submitted to upstream yet] +Signed-off-by: Davidson K +Change-Id: Id9f805aa7b9e16878a1114f71cd465dc97cc5dfd +Signed-off-by: Ben Horgan +--- + components/rpc/ffarpc/endpoint/ffarpc_call_ep.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c b/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c +index bb40cf3..8109345 100644 +--- a/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c ++++ b/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c +@@ -1,5 +1,5 @@ + /* +- * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. ++ * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +@@ -43,7 +43,7 @@ static void init_shmem_buf(struct ffa_call_ep *call_ep, uint16_t source_id, + struct sp_memory_descriptor desc = { }; + struct sp_memory_access_descriptor acc_desc = { }; + struct sp_memory_region region = { }; +- uint32_t in_region_count = 1; ++ uint32_t in_region_count = 0; + uint32_t out_region_count = 1; + uint64_t handle = 0; + rpc_status_t rpc_status = TS_RPC_ERROR_INTERNAL; +-- +2.29.2 + diff --git a/meta-arm/recipes-security/trusted-services/files/0004-Release-rx-buffer-after-memory-retrieve-request.patch b/meta-arm/recipes-security/trusted-services/files/0004-Release-rx-buffer-after-memory-retrieve-request.patch new file mode 100644 index 00000000..9f2a1e02 --- /dev/null +++ b/meta-arm/recipes-security/trusted-services/files/0004-Release-rx-buffer-after-memory-retrieve-request.patch @@ -0,0 +1,44 @@ +From de8c7b4ba36606067f68799f63b1a6a7de2c1a70 Mon Sep 17 00:00:00 2001 +From: Davidson K +Date: Fri, 19 Feb 2021 11:34:26 +0530 +Subject: [PATCH 04/13] Release rx buffer after memory retrieve request + +After the RX buffer is consumed by the SP, the ownership has to be +transferred to the SPM so that SPM can own it as a producer and write +to it whenever needed. + +Upstream-Status: Pending [Not submitted to upstream yet] +Signed-off-by: Davidson K +Change-Id: Ib058e1ef8a4f5286d1618394de2a74c3b7431476 +Signed-off-by: Ben Horgan +--- + components/rpc/ffarpc/endpoint/ffarpc_call_ep.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c b/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c +index 8109345..f65398b 100644 +--- a/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c ++++ b/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c +@@ -40,6 +40,7 @@ static void init_shmem_buf(struct ffa_call_ep *call_ep, uint16_t source_id, + const uint32_t *req_args, uint32_t *resp_args) + { + sp_result sp_res = SP_RESULT_INTERNAL_ERROR; ++ ffa_result ffa_res; + struct sp_memory_descriptor desc = { }; + struct sp_memory_access_descriptor acc_desc = { }; + struct sp_memory_region region = { }; +@@ -68,6 +69,11 @@ static void init_shmem_buf(struct ffa_call_ep *call_ep, uint16_t source_id, + EMSG("memory retrieve error: %d", sp_res); + } + ++ ffa_res = ffa_rx_release(); ++ if (ffa_res != FFA_OK) { ++ EMSG("ffa_rx_release(): error %"PRId32, ffa_res); ++ } ++ + set_mgmt_resp_args(resp_args, req_args[FFA_CALL_ARGS_OPCODE], rpc_status); + } + +-- +2.29.2 + diff --git a/meta-arm/recipes-security/trusted-services/files/0005-crypto-sp-Create-a-new-deployment-with-the-shim-envi.patch b/meta-arm/recipes-security/trusted-services/files/0005-crypto-sp-Create-a-new-deployment-with-the-shim-envi.patch new file mode 100644 index 00000000..538cf366 --- /dev/null +++ b/meta-arm/recipes-security/trusted-services/files/0005-crypto-sp-Create-a-new-deployment-with-the-shim-envi.patch @@ -0,0 +1,364 @@ +From dfd02cb62a2dad931bb81ff7eeed0a116ccc50be Mon Sep 17 00:00:00 2001 +From: Davidson K +Date: Tue, 9 Mar 2021 17:53:03 +0530 +Subject: [PATCH 05/13] crypto-sp: Create a new deployment with the shim + environment + +The shim environment provides support for the trusted service to +run as secure partition at S-EL0 and a shim layer at S-EL1 with +Hafnium as SPMC running at S-EL2. + +Upstream-Status: Pending [Not submitted to upstream yet] +Signed-off-by: Davidson K +Change-Id: Id3fdf50470e4b9df7388c00e445f75b7bc8362d8 +Signed-off-by: Ben Horgan +--- + deployments/crypto/shim/CMakeLists.txt | 121 +++++++++++++++++++++++++ + deployments/crypto/shim/crypto.dts | 32 +++++++ + deployments/crypto/shim/crypto_sp.c | 117 ++++++++++++++++++++++++ + deployments/crypto/shim/crypto_sp.h | 18 ++++ + deployments/crypto/shim/sp_def.h | 16 ++++ + 5 files changed, 304 insertions(+) + create mode 100644 deployments/crypto/shim/CMakeLists.txt + create mode 100644 deployments/crypto/shim/crypto.dts + create mode 100644 deployments/crypto/shim/crypto_sp.c + create mode 100644 deployments/crypto/shim/crypto_sp.h + create mode 100644 deployments/crypto/shim/sp_def.h + +diff --git a/deployments/crypto/shim/CMakeLists.txt b/deployments/crypto/shim/CMakeLists.txt +new file mode 100644 +index 0000000..65cc215 +--- /dev/null ++++ b/deployments/crypto/shim/CMakeLists.txt +@@ -0,0 +1,121 @@ ++#------------------------------------------------------------------------------- ++# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. ++# ++# SPDX-License-Identifier: BSD-3-Clause ++# ++#------------------------------------------------------------------------------- ++cmake_minimum_required(VERSION 3.16) ++include(../../deployment.cmake REQUIRED) ++ ++#------------------------------------------------------------------------------- ++# The CMakeLists.txt for building the crypto deployment with the shim layer ++# ++# Builds the Crypto service provider for running in an SEL0 secure partition ++# with the shim layer in SEL1 hosted by Hafnium in the role of SPM. ++#------------------------------------------------------------------------------- ++include(${TS_ROOT}/environments/shim/env.cmake) ++project(trusted-services LANGUAGES C ASM) ++add_executable(crypto-sp) ++target_include_directories(crypto-sp PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}") ++set(SP_UUID "d9df52d5-16a2-4bb2-9aa4-d26d3b84e8c0") ++ ++ ++add_components(TARGET "crypto-sp" ++ BASE_DIR ${TS_ROOT} ++ COMPONENTS ++ "components/messaging/ffa/libsp" ++ "components/rpc/ffarpc/endpoint" ++ "components/rpc/ffarpc/caller/sp" ++ "components/rpc/common/caller" ++ "components/rpc/common/interface" ++ "components/rpc/dummy" ++ "components/service/common" ++ "components/service/common/serializer/protobuf" ++ "components/service/common/provider" ++ "components/service/crypto/provider/mbedcrypto" ++ "components/service/crypto/provider/mbedcrypto/entropy_source/mock" ++ "components/service/crypto/provider/serializer/protobuf" ++ "components/service/secure_storage/client/psa" ++ "protocols/rpc/common/packed-c" ++ "protocols/service/secure_storage/packed-c" ++ "protocols/service/crypto/protobuf" ++ "environments/shim" ++) ++ ++target_sources(crypto-sp PRIVATE ++ crypto_sp.c ++) ++ ++######################################################## Build protobuf files ++include(../../../external/nanopb/nanopb.cmake) ++target_link_libraries(crypto-sp PRIVATE nanopb::protobuf-nanopb-static) ++protobuf_generate_all(TGT "crypto-sp" NAMESPACE "protobuf" BASE_DIR "${TS_ROOT}/protocols") ++ ++################################################################# mbedcrypto ++include(../../../external/mbed-crypto/mbedcrypto.cmake) ++target_link_libraries(crypto-sp PRIVATE mbedcrypto) ++ ++if(CMAKE_CROSSCOMPILING) ++ target_link_libraries(crypto-sp PRIVATE stdc++ gcc m) ++endif() ++ ++################################################################# ++ ++target_compile_definitions(crypto-sp PRIVATE ++ ARM64=1 ++ LOG_LEVEL=30 ++ CRYPTO=1 ++) ++ ++target_include_directories(crypto-sp PRIVATE ++ ${TS_ROOT}/deployments/crypto/shim ++) ++ ++if(CMAKE_C_COMPILER_ID STREQUAL "GNU") ++ target_compile_options(crypto-sp PRIVATE ++ -fdiagnostics-show-option ++ -fpic ++ -gdwarf-2 ++ -mstrict-align ++ -O0 ++ -std=gnu99 ++ -ffreestanding ++ -mgeneral-regs-only ++ ) ++ ++ # Options for GCC that control linking ++ target_link_options(crypto-sp PRIVATE ++ -fno-lto ++ -nostdlib ++ -pie ++ -zmax-page-size=4096 ++ ) ++ # Options directly for LD, these are not understood by GCC ++ target_link_options(crypto-sp PRIVATE ++ -Wl,--as-needed ++ -Wl,--sort-section=alignment ++ -T${CMAKE_BINARY_DIR}/crypto-sp.ld ++ -Wl,-Map=crypto.map ++ ) ++endif() ++ ++compiler_generate_stripped_elf(TARGET crypto-sp NAME "${SP_UUID}.stripped.elf" RES STRIPPED_ELF) ++compiler_generate_binary_output(TARGET crypto-sp RES STRIPPED_ELF) ++ ++######################################## install ++if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) ++ set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE) ++endif() ++#TODO: api headers ++install(TARGETS crypto-sp ++ PUBLIC_HEADER DESTINATION ${TS_ENV}/include ++ RUNTIME DESTINATION ${TS_ENV}/bin ++ ) ++install(FILES ${STRIPPED_ELF} DESTINATION ${TS_ENV}/bin) ++ ++get_property(_PROTO_FILES TARGET crypto-sp PROPERTY PROTOBUF_FILES) ++install(FILES ${_PROTO_FILES} DESTINATION ${TS_ENV}/lib/protobuf) ++ ++ ++set(EXPORT_SP_NAME "crypto") ++set(EXPORT_SP_UUID ${SP_UUID}) +diff --git a/deployments/crypto/shim/crypto.dts b/deployments/crypto/shim/crypto.dts +new file mode 100644 +index 0000000..23bd7a2 +--- /dev/null ++++ b/deployments/crypto/shim/crypto.dts +@@ -0,0 +1,32 @@ ++/* ++ * Copyright (c) 2021, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ * ++ * This file is a Partition Manifest (PM) for Crypto Trusted Service ++ * Secure Partition (SP). ++ */ ++ ++/dts-v1/; ++ ++/ { ++ compatible = "arm,ffa-manifest-1.0"; ++ ++ /* Properties */ ++ description = "crypto"; ++ ffa-version = <0x00010000>; /* 31:16 - Major, 15:0 - Minor */ ++ uuid = <0xd9df52d5 0x4bb216a2 0x6dd2a49a 0xc0e8843b>; ++ id = <3>; ++ execution-ctx-count = <1>; ++ exception-level = <2>; /* S-EL1 */ ++ execution-state = <0>; /* AARCH64 */ ++ load-address = <0xfec00000>; ++ entrypoint-offset = <0x00001000>; ++ xlat-granule = <0>; /* 4KiB */ ++ boot-order = <0>; ++ messaging-method = <0>; /* Direct messaging only */ ++ run-time-model = <1>; /* Run to completion */ ++ ++ /* Boot protocol */ ++ gp-register-num = <0x0>; ++}; +diff --git a/deployments/crypto/shim/crypto_sp.c b/deployments/crypto/shim/crypto_sp.c +new file mode 100644 +index 0000000..8b3eba5 +--- /dev/null ++++ b/deployments/crypto/shim/crypto_sp.c +@@ -0,0 +1,117 @@ ++// SPDX-License-Identifier: BSD-3-Clause ++/* ++ * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++ ++#define SP_STORAGE_UUID_BYTES \ ++ { 0x48, 0xef, 0x1e, 0xdc, 0x7a, 0xb1, 0xcf, 0x4c, \ ++ 0xac, 0x8b, 0xdf, 0xcf, 0xf7, 0x71, 0x1b, 0x14, } ++ ++uint16_t own_id = 0; /* !!Needs refactoring as parameter to ffarpc_caller_init */ ++static const uint8_t storage_uuid[] = SP_STORAGE_UUID_BYTES; ++ ++ ++static int sp_init(uint16_t *own_sp_id); ++ ++uint8_t sp_heap[SP_HEAP_SIZE] __aligned(16); ++ ++void __noreturn sp_main(struct ffa_init_info *init_info) ++{ ++ struct mbed_crypto_provider crypto_provider; ++ struct ffa_call_ep ffarpc_call_ep; ++ struct call_ep *crypto_ep; ++ struct ffarpc_caller ffarpc_caller; ++ struct dummy_caller dummy_caller; ++ struct rpc_caller *storage_caller; ++ struct ffa_direct_msg req_msg; ++ uint16_t storage_sp_ids[1]; ++ ++ /* Beginning of the boot phase */ ++ (void) init_info; ++ ++ if (sp_init(&own_id) != 0) goto fatal_error; ++ ++ /* Establish RPC session with secure storage SP */ ++ storage_caller = ffarpc_caller_init(&ffarpc_caller); ++ ++ if (!ffarpc_caller_discover(storage_uuid, storage_sp_ids, sizeof(storage_sp_ids)/sizeof(storage_sp_ids[0])) || ++ ffarpc_caller_open(&ffarpc_caller, storage_sp_ids[0])) { ++ /* ++ * Failed to establish session. To allow the crypto service ++ * to still be initialized, albeit with no persistent storage, ++ * initialise a dummy_caller that will safely ++ * handle rpc requests but will report an error. ++ */ ++ storage_caller = dummy_caller_init(&dummy_caller, ++ TS_RPC_CALL_ACCEPTED, PSA_ERROR_STORAGE_FAILURE); ++ } ++ ++ /* Initialize the crypto service */ ++ crypto_ep = mbed_crypto_provider_init(&crypto_provider, storage_caller); ++ ffa_call_ep_init(&ffarpc_call_ep, crypto_ep); ++ ++ malloc_add_pool(sp_heap, SP_HEAP_SIZE); ++ ++ /* End of boot phase */ ++ ffa_msg_wait(&req_msg); ++ ++ while (1) { ++ if (req_msg.function_id == FFA_MSG_SEND_DIRECT_REQ_32) { ++ ++ struct ffa_direct_msg resp_msg; ++ ++ ffa_call_ep_receive(&ffarpc_call_ep, &req_msg, &resp_msg); ++ ++ ffa_msg_send_direct_resp(req_msg.destination_id, ++ req_msg.source_id, resp_msg.args[0], resp_msg.args[1], ++ resp_msg.args[2], resp_msg.args[3], resp_msg.args[4], ++ &req_msg); ++ } else { ++ EMSG("Received unexpected request"); ++ break; ++ } ++ } ++ ++fatal_error: ++ /* SP is not viable */ ++ EMSG("Crypto SP error"); ++ while (1) {} ++} ++ ++void sp_interrupt_handler(uint32_t interrupt_id) ++{ ++ (void)interrupt_id; ++} ++ ++static int sp_init(uint16_t *own_sp_id) ++{ ++ int status = -1; ++ sp_result sp_res; ++ static uint8_t tx_buffer[4096] __aligned(4096); ++ static uint8_t rx_buffer[4096] __aligned(4096); ++ ++ sp_res = sp_rxtx_buffer_map(tx_buffer, rx_buffer, sizeof(rx_buffer)); ++ if (sp_res == SP_RESULT_OK) { ++ ffa_result ffa_res; ++ ffa_res = ffa_id_get(own_sp_id); ++ if (ffa_res == FFA_OK) { ++ status = 0; ++ } ++ } ++ ++ return status; ++} +diff --git a/deployments/crypto/shim/crypto_sp.h b/deployments/crypto/shim/crypto_sp.h +new file mode 100644 +index 0000000..e3ee0c6 +--- /dev/null ++++ b/deployments/crypto/shim/crypto_sp.h +@@ -0,0 +1,18 @@ ++/* ++ * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef CRYPTO_SP_H ++#define CRYPTO_SP_H ++ ++#define CRYPTO_SP_UUID \ ++ {0xd9df52d5, 0x16a2, 0x4bb2, \ ++ {0x9a, 0xa4, 0xd2, 0x6d, 0x3b, 0x84, 0xe8, 0xc0}} ++ ++#define CRYPTO_SP_UUID_BYTES \ ++ {0xd9, 0xdf, 0x52, 0xd5, 0x16, 0xa2, 0x4b, 0xb2, \ ++ 0x9a, 0xa4, 0xd2, 0x6d, 0x3b, 0x84, 0xe8, 0xc0} ++ ++#endif /* CRYPTO_SP_H */ +diff --git a/deployments/crypto/shim/sp_def.h b/deployments/crypto/shim/sp_def.h +new file mode 100644 +index 0000000..c4eff67 +--- /dev/null ++++ b/deployments/crypto/shim/sp_def.h +@@ -0,0 +1,16 @@ ++/* ++ * Copyright (c) 2021, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef SP_DEF_H ++#define SP_DEF_H ++ ++/* Memory reserved for stacks */ ++#define SP_STACKS_SIZE (32 * 1024) ++ ++/* Memory for heap */ ++#define SP_HEAP_SIZE (480 * 1024) ++ ++#endif /* SP_DEF_H */ +-- +2.29.2 + diff --git a/meta-arm/recipes-security/trusted-services/files/0006-secure-storage-Create-a-new-deployment-with-the-shim.patch b/meta-arm/recipes-security/trusted-services/files/0006-secure-storage-Create-a-new-deployment-with-the-shim.patch new file mode 100644 index 00000000..46cba057 --- /dev/null +++ b/meta-arm/recipes-security/trusted-services/files/0006-secure-storage-Create-a-new-deployment-with-the-shim.patch @@ -0,0 +1,268 @@ +From 47bd3e42cc7e33cd2f41c98112ed159b23149023 Mon Sep 17 00:00:00 2001 +From: Davidson K +Date: Tue, 9 Mar 2021 18:01:05 +0530 +Subject: [PATCH 06/13] secure-storage: Create a new deployment with the shim + environment + +The shim environment provides support for the trusted service to +run as secure partition at S-EL0 and a shim layer at S-EL1 with +Hafnium as SPMC running at S-EL2. + +Upstream-Status: Pending [Not submitted to upstream yet] +Signed-off-by: Davidson K +Change-Id: I6fd23a100b5b1ab8d80742ee2f3a81bfb7595a51 +Signed-off-by: Ben Horgan +--- + .../secure-storage/shim/CMakeLists.txt | 93 +++++++++++++++++++ + .../secure-storage/shim/secure-storage.dts | 33 +++++++ + deployments/secure-storage/shim/sp.c | 74 +++++++++++++++ + deployments/secure-storage/shim/sp_def.h | 16 ++++ + 4 files changed, 216 insertions(+) + create mode 100644 deployments/secure-storage/shim/CMakeLists.txt + create mode 100644 deployments/secure-storage/shim/secure-storage.dts + create mode 100644 deployments/secure-storage/shim/sp.c + create mode 100644 deployments/secure-storage/shim/sp_def.h + +diff --git a/deployments/secure-storage/shim/CMakeLists.txt b/deployments/secure-storage/shim/CMakeLists.txt +new file mode 100644 +index 0000000..bcc3486 +--- /dev/null ++++ b/deployments/secure-storage/shim/CMakeLists.txt +@@ -0,0 +1,93 @@ ++#------------------------------------------------------------------------------- ++# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. ++# ++# SPDX-License-Identifier: BSD-3-Clause ++# ++#------------------------------------------------------------------------------- ++cmake_minimum_required(VERSION 3.16) ++include(../../deployment.cmake REQUIRED) ++ ++#------------------------------------------------------------------------------- ++# The CMakeLists.txt for building the secure-storage deployment for hafnium ++# ++# Builds the secure storage service provider for running in an SEL0 secure ++# partition with the shim layer in SEL1 hosted by Hafnium in the role of SPM. ++#------------------------------------------------------------------------------- ++include(${TS_ROOT}/environments/shim/env.cmake) ++project(trusted-services LANGUAGES C ASM) ++add_executable(secure-storage) ++target_include_directories(secure-storage PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}") ++set(SP_UUID "dc1eef48-b17a-4ccf-ac8b-dfcff7711b14") ++ ++add_components(TARGET "secure-storage" ++ BASE_DIR ${TS_ROOT} ++ COMPONENTS ++ components/messaging/ffa/libsp ++ components/rpc/ffarpc/endpoint ++ components/rpc/common/interface ++ components/service/common/provider ++ components/service/secure_storage/provider/secure_flash_store ++ components/service/secure_storage/provider/secure_flash_store/flash_fs ++ components/service/secure_storage/provider/secure_flash_store/flash ++ protocols/rpc/common/packed-c ++ protocols/service/secure_storage/packed-c ++ environments/shim ++) ++ ++target_sources(secure-storage PRIVATE ++ sp.c ++) ++ ++target_compile_definitions(secure-storage PRIVATE ++ ARM64=1 ++ LOG_LEVEL=30 ++ SECURE_STORAGE=1 ++) ++ ++target_include_directories(secure-storage PRIVATE ++ ${TS_ROOT}/deployments/secure-storage/shim ++) ++ ++if(CMAKE_C_COMPILER_ID STREQUAL "GNU") ++ target_compile_options(secure-storage PRIVATE ++ -fdiagnostics-show-option ++ -fpic ++ -gdwarf-2 ++ -mstrict-align ++ -O0 ++ -std=gnu99 ++ -ffreestanding ++ -mgeneral-regs-only ++ ) ++ ++ # Options for GCC that control linking ++ target_link_options(secure-storage PRIVATE ++ -fno-lto ++ -nostdlib ++ -pie ++ -zmax-page-size=4096 ++ ) ++ # Options directly for LD, these are not understood by GCC ++ target_link_options(secure-storage PRIVATE ++ -Wl,--as-needed ++ -Wl,--sort-section=alignment ++ -T${CMAKE_BINARY_DIR}/secure-storage.ld ++ -Wl,-Map=secure-storage.map ++ ) ++endif() ++ ++compiler_generate_stripped_elf(TARGET secure-storage NAME "${SP_UUID}.stripped.elf" RES STRIPPED_ELF) ++compiler_generate_binary_output(TARGET secure-storage RES STRIPPED_ELF) ++ ++######################################## install ++if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) ++ set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE) ++endif() ++install(TARGETS secure-storage ++ PUBLIC_HEADER DESTINATION ${TS_ENV}/include ++ RUNTIME DESTINATION ${TS_ENV}/bin ++ ) ++install(FILES ${STRIPPED_ELF} DESTINATION ${TS_ENV}/bin) ++ ++set(EXPORT_SP_NAME "secure-storage") ++set(EXPORT_SP_UUID ${SP_UUID}) +diff --git a/deployments/secure-storage/shim/secure-storage.dts b/deployments/secure-storage/shim/secure-storage.dts +new file mode 100644 +index 0000000..5df3153 +--- /dev/null ++++ b/deployments/secure-storage/shim/secure-storage.dts +@@ -0,0 +1,33 @@ ++/* ++ * Copyright (c) 2021, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ * ++ * This file is a Partition Manifest (PM) for the secure-storage ++ * Secure Partition (SP) ++ */ ++ ++ ++/dts-v1/; ++ ++/ { ++ compatible = "arm,ffa-manifest-1.0"; ++ ++ /* Properties */ ++ description = "secure-storage"; ++ ffa-version = <0x00010000>; /* 31:16 - Major, 15:0 - Minor */ ++ uuid = <0xdc1eef48 0x4ccfb17a 0xcfdf8bac 0x141b71f7>; ++ id = <2>; ++ execution-ctx-count = <1>; ++ exception-level = <2>; /* S-EL1 */ ++ execution-state = <0>; /* AARCH64 */ ++ load-address = <0xfee00000>; ++ entrypoint-offset = <0x00001000>; ++ xlat-granule = <0>; /* 4KiB */ ++ boot-order = <0>; ++ messaging-method = <0>; /* Direct messaging only */ ++ run-time-model = <1>; /* Run to completion */ ++ ++ /* Boot protocol */ ++ gp-register-num = <0x0>; ++}; +diff --git a/deployments/secure-storage/shim/sp.c b/deployments/secure-storage/shim/sp.c +new file mode 100644 +index 0000000..2baec88 +--- /dev/null ++++ b/deployments/secure-storage/shim/sp.c +@@ -0,0 +1,74 @@ ++/* ++ * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++uint16_t own_id = 0; ++static uint8_t tx_buffer[4096] __aligned(4096); ++static uint8_t rx_buffer[4096] __aligned(4096); ++ ++uint8_t sp_heap[SP_HEAP_SIZE] __aligned(16); ++ ++void sp_main(struct ffa_init_info *init_info) ++{ ++ ffa_result ffa_res; ++ sp_result sp_res; ++ struct call_ep *sfs_ep; ++ struct ffa_call_ep ffa_call_ep; ++ struct ffa_direct_msg req_msg; ++ struct sfs_provider sfs_provider; ++ ++ /* Beginning of boot phase */ ++ (void) init_info; ++ ++ malloc_add_pool(sp_heap, SP_HEAP_SIZE); ++ ++ ffa_res = ffa_id_get(&own_id); ++ if (ffa_res != FFA_OK) { ++ EMSG("id get error: %d", ffa_res); ++ } ++ ++ sp_res = sp_rxtx_buffer_map(tx_buffer, rx_buffer, sizeof(rx_buffer)); ++ if (sp_res != SP_RESULT_OK) { ++ EMSG("rxtx map error: %d", sp_res); ++ } ++ ++ sfs_ep = sfs_provider_init(&sfs_provider); ++ ffa_call_ep_init(&ffa_call_ep, sfs_ep); ++ ++ /* End of boot phase */ ++ ffa_msg_wait(&req_msg); ++ ++ while (1) { ++ if (req_msg.function_id == FFA_MSG_SEND_DIRECT_REQ_32) { ++ struct ffa_direct_msg resp_msg; ++ ffa_call_ep_receive(&ffa_call_ep, &req_msg, &resp_msg); ++ ++ ffa_msg_send_direct_resp(req_msg.destination_id, ++ req_msg.source_id, resp_msg.args[0], resp_msg.args[1], ++ resp_msg.args[2], resp_msg.args[3], resp_msg.args[4], ++ &req_msg); ++ } else { ++ EMSG("Received unexpected request"); ++ break; ++ } ++ } ++} ++ ++void sp_interrupt_handler(uint32_t interrupt_id) ++{ ++ (void)interrupt_id; ++} +diff --git a/deployments/secure-storage/shim/sp_def.h b/deployments/secure-storage/shim/sp_def.h +new file mode 100644 +index 0000000..aaf045d +--- /dev/null ++++ b/deployments/secure-storage/shim/sp_def.h +@@ -0,0 +1,16 @@ ++/* ++ * Copyright (c) 2021, Arm Limited. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#ifndef SP_DEF_H ++#define SP_DEF_H ++ ++/* Memory reserved for stacks */ ++#define SP_STACKS_SIZE ULL(0xa000) ++ ++/* Memory for heap */ ++#define SP_HEAP_SIZE (300 * 1024) ++ ++#endif /* SP_DEF_H */ +-- +2.29.2 + diff --git a/meta-arm/recipes-security/trusted-services/files/0007-crypto-shim-Don-t-link-against-unrequired-libraries.patch b/meta-arm/recipes-security/trusted-services/files/0007-crypto-shim-Don-t-link-against-unrequired-libraries.patch new file mode 100644 index 00000000..356ed419 --- /dev/null +++ b/meta-arm/recipes-security/trusted-services/files/0007-crypto-shim-Don-t-link-against-unrequired-libraries.patch @@ -0,0 +1,30 @@ +From ab7c90b324371e8c0b49fb45b833d521eca3c06d Mon Sep 17 00:00:00 2001 +From: Ben Horgan +Date: Thu, 8 Apr 2021 09:49:13 +0000 +Subject: [PATCH 07/13] crypto: shim: Don't link against unrequired libraries + +Upstream-Status: Pending [Not submitted to upstream yet] +Change-Id: Ia1b5476d8a8d1ede0023092ddd86f079db4beb7d +Signed-off-by: Ben Horgan +--- + deployments/crypto/shim/CMakeLists.txt | 4 ---- + 1 file changed, 4 deletions(-) + +diff --git a/deployments/crypto/shim/CMakeLists.txt b/deployments/crypto/shim/CMakeLists.txt +index 65cc215..b401d25 100644 +--- a/deployments/crypto/shim/CMakeLists.txt ++++ b/deployments/crypto/shim/CMakeLists.txt +@@ -55,10 +55,6 @@ protobuf_generate_all(TGT "crypto-sp" NAMESPACE "protobuf" BASE_DIR "${TS_ROOT}/ + include(../../../external/mbed-crypto/mbedcrypto.cmake) + target_link_libraries(crypto-sp PRIVATE mbedcrypto) + +-if(CMAKE_CROSSCOMPILING) +- target_link_libraries(crypto-sp PRIVATE stdc++ gcc m) +-endif() +- + ################################################################# + + target_compile_definitions(crypto-sp PRIVATE +-- +2.29.2 + diff --git a/meta-arm/recipes-security/trusted-services/files/0008-libts-arm-linux-Add-version-to-libts.so.patch b/meta-arm/recipes-security/trusted-services/files/0008-libts-arm-linux-Add-version-to-libts.so.patch new file mode 100644 index 00000000..d88810dc --- /dev/null +++ b/meta-arm/recipes-security/trusted-services/files/0008-libts-arm-linux-Add-version-to-libts.so.patch @@ -0,0 +1,34 @@ +From 611050d667ee7e4da0bed578b1a033315bc45ff4 Mon Sep 17 00:00:00 2001 +From: Ben Horgan +Date: Thu, 8 Apr 2021 09:51:25 +0000 +Subject: [PATCH 08/13] libts: arm-linux: Add version to libts.so + +Upstream-Status: Pending [Not submitted to upstream yet] +Change-Id: I6164b05ef49553a39252717d5622dc958ad65be4 +Signed-off-by: Ben Horgan +--- + deployments/libts/arm-linux/CMakeLists.txt | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/deployments/libts/arm-linux/CMakeLists.txt b/deployments/libts/arm-linux/CMakeLists.txt +index ab512d6..a87ed48 100644 +--- a/deployments/libts/arm-linux/CMakeLists.txt ++++ b/deployments/libts/arm-linux/CMakeLists.txt +@@ -1,5 +1,5 @@ + #------------------------------------------------------------------------------- +-# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. ++# Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved. + # + # SPDX-License-Identifier: BSD-3-Clause + # +@@ -45,4 +45,5 @@ include(../libts.cmake REQUIRED) + # + #------------------------------------------------------------------------------- + env_set_link_options(TGT ts) +-target_link_libraries(ts PRIVATE gcc) +\ No newline at end of file ++set_target_properties(ts PROPERTIES VERSION 1.0.0 SOVERSION 1) ++target_link_libraries(ts PRIVATE gcc) +-- +2.29.2 + diff --git a/meta-arm/recipes-security/trusted-services/files/0009-libts-Add-option-to-use-installed-libts.patch b/meta-arm/recipes-security/trusted-services/files/0009-libts-Add-option-to-use-installed-libts.patch new file mode 100644 index 00000000..8f1077fa --- /dev/null +++ b/meta-arm/recipes-security/trusted-services/files/0009-libts-Add-option-to-use-installed-libts.patch @@ -0,0 +1,81 @@ +From 6eb38e38bc50655b659494b3ca4e53dc727f6c53 Mon Sep 17 00:00:00 2001 +From: Ben Horgan +Date: Thu, 8 Apr 2021 10:00:37 +0000 +Subject: [PATCH 09/13] libts: Add option to use installed libts + +Allows using libts as dependency of trusted service tests in yocto +Set LIBTS_USE_INSTALLED to use installed libts. The default is +unchanged. + +Upstream-Status: Pending [Not submitted to upstream yet] +Change-Id: Ied743afc80a490238361feea64a37faadacd8dda +Signed-off-by: Ben Horgan +--- + deployments/ts-demo/ts-demo.cmake | 14 ++++++++++++-- + deployments/ts-service-test/ts-service-test.cmake | 15 +++++++++++++-- + 2 files changed, 25 insertions(+), 4 deletions(-) + +diff --git a/deployments/ts-demo/ts-demo.cmake b/deployments/ts-demo/ts-demo.cmake +index 4c85a40..f968612 100644 +--- a/deployments/ts-demo/ts-demo.cmake ++++ b/deployments/ts-demo/ts-demo.cmake +@@ -1,5 +1,5 @@ + #------------------------------------------------------------------------------- +-# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. ++# Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved. + # + # SPDX-License-Identifier: BSD-3-Clause + # +@@ -16,7 +16,17 @@ + # libts will be imported for the enviroment in which service tests are + # deployed. + #------------------------------------------------------------------------------- +-include(${TS_ROOT}/deployments/libts/libts-import.cmake) ++ ++if (NOT LIBTS_USE_INSTALLED) ++ include(${TS_ROOT}/deployments/libts/libts-import.cmake) ++else() ++ find_library(libts_lib ts REQUIRED) ++ find_path(libts_inc rpc_status.h REQUIRED) ++ add_library(libts SHARED IMPORTED) ++ set_property(TARGET libts PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${libts_inc}") ++ set_property(TARGET libts PROPERTY IMPORTED_LOCATION "${libts_lib}") ++endif() ++ + target_link_libraries(ts-demo PRIVATE libts) + + #------------------------------------------------------------------------------- +diff --git a/deployments/ts-service-test/ts-service-test.cmake b/deployments/ts-service-test/ts-service-test.cmake +index 1593188..5f78b36 100644 +--- a/deployments/ts-service-test/ts-service-test.cmake ++++ b/deployments/ts-service-test/ts-service-test.cmake +@@ -1,5 +1,5 @@ + #------------------------------------------------------------------------------- +-# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. ++# Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved. + # + # SPDX-License-Identifier: BSD-3-Clause + # +@@ -16,7 +16,18 @@ + # libts will be imported for the enviroment in which service tests are + # deployed. + #------------------------------------------------------------------------------- +-include(${TS_ROOT}/deployments/libts/libts-import.cmake) ++ ++if (NOT LIBTS_USE_INSTALLED) ++ include(${TS_ROOT}/deployments/libts/libts-import.cmake) ++else() ++ find_library(libts_lib ts REQUIRED) ++ message("benhor01: ${libts_lib}") ++ find_path(libts_inc rpc_status.h REQUIRED) ++ add_library(libts SHARED IMPORTED) ++ set_property(TARGET libts PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${libts_inc}") ++ set_property(TARGET libts PROPERTY IMPORTED_LOCATION "${libts_lib}") ++endif() ++ + target_link_libraries(ts-service-test PRIVATE libts) + + #------------------------------------------------------------------------------- +-- +2.29.2 + diff --git a/meta-arm/recipes-security/trusted-services/files/0010-external-Add-option-to-use-local-source-or-installed.patch b/meta-arm/recipes-security/trusted-services/files/0010-external-Add-option-to-use-local-source-or-installed.patch new file mode 100644 index 00000000..83aaf3de --- /dev/null +++ b/meta-arm/recipes-security/trusted-services/files/0010-external-Add-option-to-use-local-source-or-installed.patch @@ -0,0 +1,599 @@ +From 10b56be594b945c70af428116ae734660d8e11bb Mon Sep 17 00:00:00 2001 +From: Ben Horgan +Date: Thu, 8 Apr 2021 10:07:13 +0000 +Subject: [PATCH 10/13] external: Add option to use local source or installed + libs + +Upstream-Status: Pending [Not submitted to upstream yet] +Change-Id: I6bd466af8518a928f402f0d6474e607092c7340a +Signed-off-by: Ben Horgan +--- + external/CppUTest/CppUTest.cmake | 138 +++++++++--------- + external/mbed-crypto/mbedcrypto.cmake | 131 ++++++++++------- + external/nanopb/nanopb.cmake | 200 +++++++++++++++----------- + 3 files changed, 264 insertions(+), 205 deletions(-) + +diff --git a/external/CppUTest/CppUTest.cmake b/external/CppUTest/CppUTest.cmake +index c18f3e3..9b65ae5 100644 +--- a/external/CppUTest/CppUTest.cmake ++++ b/external/CppUTest/CppUTest.cmake +@@ -1,44 +1,47 @@ + #------------------------------------------------------------------------------- +-# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. ++# Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved. + # + # SPDX-License-Identifier: BSD-3-Clause + # + #------------------------------------------------------------------------------- + +-set(CPPUTEST_URL "https://github.com/cpputest/cpputest.git" CACHE STRING "CppUTest repository URL") +-set(CPPUTEST_REFSPEC "v3.8" CACHE STRING "CppUTest git refspec") +-set(CPPUTEST_INSTALL_PATH ${CMAKE_CURRENT_BINARY_DIR}/CppUTest_install CACHE PATH "CppUTest installation directory") + +-include(FetchContent) ++if (NOT CPPUTEST_USE_INSTALLED) + +-# Checking git +-find_program(GIT_COMMAND "git") +-if (NOT GIT_COMMAND) +- message(FATAL_ERROR "Please install git") +-endif() ++ set(CPPUTEST_URL "https://github.com/cpputest/cpputest.git" CACHE STRING "CppUTest repository URL") ++ set(CPPUTEST_REFSPEC "v3.8" CACHE STRING "CppUTest git refspec") ++ set(CPPUTEST_INSTALL_PATH ${CMAKE_CURRENT_BINARY_DIR}/CppUTest_install CACHE PATH "CppUTest installation directory") ++ ++ include(FetchContent) ++ ++ # Checking git ++ find_program(GIT_COMMAND "git") ++ if (NOT GIT_COMMAND) ++ message(FATAL_ERROR "Please install git") ++ endif() + +-# Fetching CppUTest +-FetchContent_Declare( +- cpputest +- GIT_REPOSITORY ${CPPUTEST_URL} +- GIT_TAG ${CPPUTEST_REFSPEC} +- GIT_SHALLOW TRUE +- PATCH_COMMAND git stash ++ # Fetching CppUTest ++ FetchContent_Declare( ++ cpputest ++ GIT_REPOSITORY ${CPPUTEST_URL} ++ GIT_TAG ${CPPUTEST_REFSPEC} ++ GIT_SHALLOW TRUE ++ PATCH_COMMAND git stash + COMMAND git apply ${CMAKE_CURRENT_LIST_DIR}/cpputest-cmake-fix.patch +-) ++ ) + +-# FetchContent_GetProperties exports cpputest_SOURCE_DIR and cpputest_BINARY_DIR variables +-FetchContent_GetProperties(cpputest) +-if(NOT cpputest_POPULATED) +- message(STATUS "Fetching CppUTest") +- FetchContent_Populate(cpputest) +-endif() ++ # FetchContent_GetProperties exports cpputest_SOURCE_DIR and cpputest_BINARY_DIR variables ++ FetchContent_GetProperties(cpputest) ++ if(NOT cpputest_POPULATED) ++ message(STATUS "Fetching CppUTest") ++ FetchContent_Populate(cpputest) ++ endif() + +-# Build and install CppUTest configuration time. This makes us able to use CppUTest as a CMake package. +-# Memory leak detection is turned off to avoid conflict with memcheck. +-if(NOT CMAKE_CROSSCOMPILING) +- execute_process(COMMAND +- ${CMAKE_COMMAND} ++ # Build and install CppUTest configuration time. This makes us able to use CppUTest as a CMake package. ++ # Memory leak detection is turned off to avoid conflict with memcheck. ++ if(NOT CMAKE_CROSSCOMPILING) ++ execute_process(COMMAND ++ ${CMAKE_COMMAND} + -DMEMORY_LEAK_DETECTION=OFF + -DLONGLONG=ON + -DC++11=ON +@@ -48,47 +51,54 @@ if(NOT CMAKE_CROSSCOMPILING) + ${cpputest_SOURCE_DIR} + WORKING_DIRECTORY + ${cpputest_BINARY_DIR} +- RESULT_VARIABLE +- _exec_error +- ) +-else() ++ RESULT_VARIABLE ++ _exec_error ++ ) ++ else() ++ execute_process(COMMAND ++ ${CMAKE_COMMAND} ++ -DMEMORY_LEAK_DETECTION=OFF ++ -DLONGLONG=ON ++ -DC++11=ON ++ -DCMAKE_INSTALL_PREFIX=${CPPUTEST_INSTALL_PATH} ++ -DCMAKE_TOOLCHAIN_FILE=${TS_EXTERNAL_LIB_TOOLCHAIN_FILE} ++ -DTESTS=OFF ++ -DEXTENSIONS=OFF ++ -DHAVE_FORK=OFF ++ -DCPP_PLATFORM=armcc ++ -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY ++ -G${CMAKE_GENERATOR} ++ ${cpputest_SOURCE_DIR} ++ WORKING_DIRECTORY ++ ${cpputest_BINARY_DIR} ++ RESULT_VARIABLE ++ _exec_error ++ ) ++ endif() ++ if (NOT _exec_error EQUAL 0) ++ message(FATAL_ERROR "Configuriong CppUTest build failed.") ++ endif() + execute_process(COMMAND +- ${CMAKE_COMMAND} +- -DMEMORY_LEAK_DETECTION=OFF +- -DLONGLONG=ON +- -DC++11=ON +- -DCMAKE_INSTALL_PREFIX=${CPPUTEST_INSTALL_PATH} +- -DCMAKE_TOOLCHAIN_FILE=${TS_EXTERNAL_LIB_TOOLCHAIN_FILE} +- -DTESTS=OFF +- -DEXTENSIONS=OFF +- -DHAVE_FORK=OFF +- -DCPP_PLATFORM=armcc +- -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY +- -G${CMAKE_GENERATOR} +- ${cpputest_SOURCE_DIR} +- WORKING_DIRECTORY +- ${cpputest_BINARY_DIR} +- RESULT_VARIABLE +- _exec_error +- ) +-endif() +-if (NOT _exec_error EQUAL 0) +- message(FATAL_ERROR "Configuriong CppUTest build failed.") +-endif() +-execute_process(COMMAND +- ${CMAKE_COMMAND} ++ ${CMAKE_COMMAND} + --build ${cpputest_BINARY_DIR} + -- install -j8 +- RESULT_VARIABLE ++ RESULT_VARIABLE + _exec_error +- ) +-if (NOT _exec_error EQUAL 0) +- message(FATAL_ERROR "Building CppUTest failed.") ++ ) ++ if (NOT _exec_error EQUAL 0) ++ message(FATAL_ERROR "Building CppUTest failed.") ++ endif() ++ ++ # Finding CppUTest package. CMake will check [package name]_DIR variable. ++ set(CppUTest_DIR ${CPPUTEST_INSTALL_PATH}/lib/CppUTest/cmake CACHE PATH "CppUTest package location" FORCE) ++ find_package(CppUTest CONFIG REQUIRED NO_DEFAULT_PATH PATHS ${CppUTest_DIR}) ++ ++else() ++ ++ find_package(CppUTest REQUIRED) ++ + endif() + +-# Finding CppUTest package. CMake will check [package name]_DIR variable. +-set(CppUTest_DIR ${CPPUTEST_INSTALL_PATH}/lib/CppUTest/cmake CACHE PATH "CppUTest package location" FORCE) +-find_package(CppUTest CONFIG REQUIRED NO_DEFAULT_PATH PATHS ${CppUTest_DIR}) + # CppUTest package files do not set include path properties on the targets. + # Fix this here. + foreach(_cpputest_target IN LISTS CppUTest_LIBRARIES) +diff --git a/external/mbed-crypto/mbedcrypto.cmake b/external/mbed-crypto/mbedcrypto.cmake +index bf00588..f681e74 100644 +--- a/external/mbed-crypto/mbedcrypto.cmake ++++ b/external/mbed-crypto/mbedcrypto.cmake +@@ -1,46 +1,59 @@ + #------------------------------------------------------------------------------- +-# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. ++# Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved. + # + # SPDX-License-Identifier: BSD-3-Clause + # + #------------------------------------------------------------------------------- + +-set(MBEDCRYPTO_URL "https://github.com/ARMmbed/mbed-crypto.git" CACHE STRING "mbedcrypto repository URL") +-set(MBEDCRYPTO_REFSPEC "mbedcrypto-3.1.0" CACHE STRING "mbedcrypto git refspec") +-set(MBEDCRYPTO_INSTALL_PATH "${CMAKE_CURRENT_BINARY_DIR}/mbedcrypto_install" CACHE PATH "mbedcrypto installation directory") +-set(MBEDCRYPTO_PACKAGE_PATH "${MBEDCRYPTO_INSTALL_PATH}/lib/mbedcrypto/cmake" CACHE PATH "mbedcrypto CMake package directory") ++if(NOT MBEDCRYPTO_USE_INSTALLED) + +-include(FetchContent) ++ include(FetchContent) + +-# Checking git +-find_program(GIT_COMMAND "git") +-if (NOT GIT_COMMAND) +- message(FATAL_ERROR "Please install git") +-endif() ++ if (NOT MBEDCRYPTO_SOURCE_PATH) + +-# Fetching mbedcrypto +-FetchContent_Declare( +- mbedcrypto +- GIT_REPOSITORY ${MBEDCRYPTO_URL} +- GIT_TAG ${MBEDCRYPTO_REFSPEC} +- GIT_SHALLOW TRUE +-) +- +-# FetchContent_GetProperties exports mbedcrypto_SOURCE_DIR and mbedcrypto_BINARY_DIR variables +-FetchContent_GetProperties(mbedcrypto) +-if(NOT mbedcrypto_POPULATED) +- message(STATUS "Fetching mbedcrypto") +- FetchContent_Populate(mbedcrypto) +-endif() ++ set(MBEDCRYPTO_URL "https://github.com/ARMmbed/mbed-crypto.git" CACHE STRING "mbedcrypto repository URL") ++ set(MBEDCRYPTO_REFSPEC "mbedcrypto-3.1.0" CACHE STRING "mbedcrypto git refspec") + +-# Convert the include path list to a string. Needed to make parameter passing to +-# mbedcrypto build work fine. +-string(REPLACE ";" "\\;" MBEDCRYPTO_EXTRA_INCLUDES "${MBEDCRYPTO_EXTRA_INCLUDES}") ++ # Checking git ++ find_program(GIT_COMMAND "git") ++ if (NOT GIT_COMMAND) ++ message(FATAL_ERROR "Please install git") ++ endif() + +-#Configure the library +-if(NOT CMAKE_CROSSCOMPILING) +- execute_process(COMMAND +- ${CMAKE_COMMAND} ++ # Fetching mbedcrypto ++ FetchContent_Declare( ++ mbedcrypto ++ GIT_REPOSITORY ${MBEDCRYPTO_URL} ++ GIT_TAG ${MBEDCRYPTO_REFSPEC} ++ GIT_SHALLOW TRUE ++ ) ++ ++ else() ++ ++ FetchContent_Declare( ++ mbedcrypto ++ SOURCE_DIR ${MBEDCRYPTO_SOURCE_PATH} ++ ) ++ ++ endif() ++ ++ # FetchContent_GetProperties exports mbedcrypto_SOURCE_DIR and mbedcrypto_BINARY_DIR variables ++ FetchContent_GetProperties(mbedcrypto) ++ ++ if(NOT mbedcrypto_POPULATED) ++ message(STATUS "Fetching mbedcrypto") ++ FetchContent_Populate(mbedcrypto) ++ endif() ++ ++ set(MBEDCRYPTO_INSTALL_PATH "${CMAKE_CURRENT_BINARY_DIR}/mbedcrypto_install" CACHE PATH "mbedcrypto installation directory") ++ set(MBEDCRYPTO_PACKAGE_PATH "${MBEDCRYPTO_INSTALL_PATH}/lib/mbedcrypto/cmake" CACHE PATH "mbedcrypto CMake package directory") ++ # Convert the include path list to a string. Needed to make parameter passing to ++ # mbedcrypto build work fine. ++ string(REPLACE ";" "\\;" MBEDCRYPTO_EXTRA_INCLUDES "${MBEDCRYPTO_EXTRA_INCLUDES}") ++ #Configure the library ++ if(NOT CMAKE_CROSSCOMPILING) ++ execute_process(COMMAND ++ ${CMAKE_COMMAND} + -DENABLE_PROGRAMS=OFF + -DENABLE_TESTING=OFF + -DCMAKE_INSTALL_PREFIX=${MBEDCRYPTO_INSTALL_PATH} +@@ -49,12 +62,12 @@ if(NOT CMAKE_CROSSCOMPILING) + -Dthirdparty_inc=${MBEDCRYPTO_EXTRA_INCLUDES} + -GUnix\ Makefiles + ${mbedcrypto_SOURCE_DIR} +- WORKING_DIRECTORY ++ WORKING_DIRECTORY + ${mbedcrypto_BINARY_DIR} +- ) +-else() +- execute_process(COMMAND +- ${CMAKE_COMMAND} ++ ) ++ else() ++ execute_process(COMMAND ++ ${CMAKE_COMMAND} + -DENABLE_PROGRAMS=OFF + -DENABLE_TESTING=OFF + -DCMAKE_INSTALL_PREFIX=${MBEDCRYPTO_INSTALL_PATH} +@@ -64,30 +77,38 @@ else() + -Dthirdparty_inc=${MBEDCRYPTO_EXTRA_INCLUDES} + -GUnix\ Makefiles + ${mbedcrypto_SOURCE_DIR} +- WORKING_DIRECTORY ++ WORKING_DIRECTORY + ${mbedcrypto_BINARY_DIR} +- RESULT_VARIABLE _exec_error +- ) ++ RESULT_VARIABLE _exec_error ++ ) + +- if (_exec_error) +- message(FATAL_ERROR "Configuration step of mbedcrypto failed with ${_exec_error}.") ++ if (_exec_error) ++ message(FATAL_ERROR "Configuration step of mbedcrypto failed with ${_exec_error}.") ++ endif() + endif() +-endif() + +-#TODO: add dependnecy to generated project on this file! +-#TODO: add custom target to rebuild mbedcrypto ++ #TODO: add dependnecy to generated project on this file! ++ #TODO: add custom target to rebuild mbedcrypto + +-#Build the library +-execute_process(COMMAND ++ #Build the library ++ execute_process(COMMAND + ${CMAKE_COMMAND} --build ${mbedcrypto_BINARY_DIR} -- install -j8 + RESULT_VARIABLE _exec_error +- ) +-if (_exec_error) +- message(FATAL_ERROR "Build step of mbedcrypto failed with ${_exec_error}.") +-endif() ++ ) ++ if (_exec_error) ++ message(FATAL_ERROR "Build step of mbedcrypto failed with ${_exec_error}.") ++ endif() ++ ++ add_library(mbedcrypto STATIC IMPORTED) ++ set_property(TARGET mbedcrypto PROPERTY IMPORTED_LOCATION "${MBEDCRYPTO_INSTALL_PATH}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}mbedcrypto${CMAKE_STATIC_LIBRARY_SUFFIX}") ++ set_property(TARGET mbedcrypto PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${MBEDCRYPTO_INSTALL_PATH}/include") + +-#Create an imported target to have clean abstraction in the build-system. +-add_library(mbedcrypto STATIC IMPORTED) +-set_property(TARGET mbedcrypto PROPERTY IMPORTED_LOCATION "${MBEDCRYPTO_INSTALL_PATH}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}mbedcrypto${CMAKE_STATIC_LIBRARY_SUFFIX}") +-set_property(TARGET mbedcrypto PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${MBEDCRYPTO_INSTALL_PATH}/include") ++else() ++ ++ find_library(mbedcrypto_lib mbedcrypto REQUIRED) ++ find_path(mbedcrypto_inc mbedtls/version.h REQUIRED) ++ add_library(mbedcrypto STATIC IMPORTED) ++ set_property(TARGET mbedcrypto PROPERTY IMPORTED_LOCATION "${mbedcrypto_lib}") ++ set_property(TARGET mbedcrypto PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${mbedcrypto_inc}") + ++endif() +diff --git a/external/nanopb/nanopb.cmake b/external/nanopb/nanopb.cmake +index eda00e4..f6ac047 100644 +--- a/external/nanopb/nanopb.cmake ++++ b/external/nanopb/nanopb.cmake +@@ -1,12 +1,12 @@ + #------------------------------------------------------------------------------- +-# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. ++# Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved. + # + # SPDX-License-Identifier: BSD-3-Clause + # + #------------------------------------------------------------------------------- + + #[===[.rst: +-NonoPB integration for cmake ++NanoPB integration for cmake + ---------------------------- + + This module will: +@@ -26,107 +26,135 @@ running this module. + + #### Get the dependency + +-set(NANOPB_URL "https://github.com/nanopb/nanopb.git" CACHE STRING "nanopb repository URL") +-set(NANOPB_REFSPEC "nanopb-0.4.2" CACHE STRING "nanopb git refspec") +-set(NANOPB_INSTALL_PATH "${CMAKE_CURRENT_BINARY_DIR}/nanopb_install" CACHE PATH "nanopb installation directory") +-set(NANOPB_PACKAGE_PATH "${NANOPB_INSTALL_PATH}/libnanopb/cmake" CACHE PATH "nanopb CMake package directory") ++if (NOT NANOPB_USE_INSTALLED) + +-include(FetchContent) ++ include(FetchContent) + +-# Checking git +-find_program(GIT_COMMAND "git") +-if (NOT GIT_COMMAND) +- message(FATAL_ERROR "Please install git") +-endif() ++ set(NANOPB_INSTALL_PATH "${CMAKE_CURRENT_BINARY_DIR}/nanopb_install" CACHE PATH "nanopb installation directory") ++ set(NANOPB_PACKAGE_PATH "${NANOPB_INSTALL_PATH}/libnanopb/cmake" CACHE PATH "nanopb CMake package directory") + +-# Fetching nanopb +-FetchContent_Declare( +- nanopb +- GIT_REPOSITORY ${NANOPB_URL} +- GIT_TAG ${NANOPB_REFSPEC} +- GIT_SHALLOW TRUE +- #See the .patch file for details on why it is needed. +- PATCH_COMMAND git stash +- COMMAND git apply ${CMAKE_CURRENT_LIST_DIR}/fix-pyhon-name.patch +-) +- +-# FetchContent_GetProperties exports nanopb_SOURCE_DIR and nanopb_BINARY_DIR variables +-FetchContent_GetProperties(nanopb) +-if(NOT nanopb_POPULATED) +- message(STATUS "Fetching nanopb") +- FetchContent_Populate(nanopb) +-endif() ++ if (NOT NANOPB_SOURCE_PATH) + +-#### Build the runtime and the generator. +-if( NOT CMAKE_CROSSCOMPILING) +- execute_process(COMMAND +- ${CMAKE_COMMAND} +- -DBUILD_SHARED_LIBS=Off +- -DBUILD_STATIC_LIBS=On +- -Dnanopb_BUILD_RUNTIME=On +- -Dnanopb_BUILD_GENERATOR=On +- -Dnanopb_PROTOC_PATH=${nanopb_SOURCE_DIR}/generator/protoc +- -Dnanopb_MSVC_STATIC_RUNTIME=Off +- -DCMAKE_INSTALL_PREFIX=${NANOPB_INSTALL_PATH} +- -DCMAKE_TOOLCHAIN_FILE=${TS_EXTERNAL_LIB_TOOLCHAIN_FILE} +- -GUnix\ Makefiles +- ${nanopb_SOURCE_DIR} +- WORKING_DIRECTORY +- ${nanopb_BINARY_DIR} +- RESULT_VARIABLE _exec_error +- ) +-else() +- execute_process(COMMAND +- ${CMAKE_COMMAND} +- -DBUILD_SHARED_LIBS=Off +- -DBUILD_STATIC_LIBS=On +- -Dnanopb_BUILD_RUNTIME=On +- -Dnanopb_BUILD_GENERATOR=On +- -Dnanopb_PROTOC_PATH=${nanopb_SOURCE_DIR}/generator/protoc +- -Dnanopb_MSVC_STATIC_RUNTIME=Off +- -DCMAKE_INSTALL_PREFIX=${NANOPB_INSTALL_PATH} +- -DCMAKE_TOOLCHAIN_FILE=${TS_EXTERNAL_LIB_TOOLCHAIN_FILE} +- -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY +- -GUnix\ Makefiles +- ${nanopb_SOURCE_DIR} +- WORKING_DIRECTORY +- ${nanopb_BINARY_DIR} +- RESULT_VARIABLE _exec_error +- ) +-endif() ++ set(NANOPB_URL "https://github.com/nanopb/nanopb.git" CACHE STRING "nanopb repository URL") ++ set(NANOPB_REFSPEC "nanopb-0.4.2" CACHE STRING "nanopb git refspec") + +-if (_exec_error) +- message(FATAL_ERROR "Configuration step of nanopb runtime failed with ${_exec_error}.") +-endif() ++ # Checking git ++ find_program(GIT_COMMAND "git") ++ if (NOT GIT_COMMAND) ++ message(FATAL_ERROR "Please install git") ++ endif() ++ ++ # Fetching nanopb ++ FetchContent_Declare( ++ nanopb ++ GIT_REPOSITORY ${NANOPB_URL} ++ GIT_TAG ${NANOPB_REFSPEC} ++ GIT_SHALLOW TRUE ++ #See the .patch file for details on why it is needed. ++ PATCH_COMMAND git stash ++ COMMAND git apply ${CMAKE_CURRENT_LIST_DIR}/fix-pyhon-name.patch ++ ) ++ ++ else() + +-execute_process(COMMAND ++ FetchContent_Declare( ++ nanopb ++ SOURCE_DIR ${NANOPB_SOURCE_PATH} ++ ) ++ ++ endif() ++ ++ # FetchContent_GetProperties exports nanopb_SOURCE_DIR and nanopb_BINARY_DIR variables ++ FetchContent_GetProperties(nanopb) ++ if(NOT nanopb_POPULATED) ++ message(STATUS "Fetching nanopb") ++ FetchContent_Populate(nanopb) ++ endif() ++ ++ #### Build the runtime and the generator. ++ if( NOT CMAKE_CROSSCOMPILING) ++ execute_process(COMMAND ++ ${CMAKE_COMMAND} ++ -DBUILD_SHARED_LIBS=Off ++ -DBUILD_STATIC_LIBS=On ++ -Dnanopb_BUILD_RUNTIME=On ++ -Dnanopb_BUILD_GENERATOR=On ++ -Dnanopb_PROTOC_PATH=${nanopb_SOURCE_DIR}/generator/protoc ++ -Dnanopb_MSVC_STATIC_RUNTIME=Off ++ -DCMAKE_INSTALL_PREFIX=${NANOPB_INSTALL_PATH} ++ -DCMAKE_TOOLCHAIN_FILE=${TS_EXTERNAL_LIB_TOOLCHAIN_FILE} ++ -GUnix\ Makefiles ++ ${nanopb_SOURCE_DIR} ++ WORKING_DIRECTORY ++ ${nanopb_BINARY_DIR} ++ RESULT_VARIABLE _exec_error ++ ) ++ else() ++ execute_process(COMMAND ++ ${CMAKE_COMMAND} ++ -DBUILD_SHARED_LIBS=Off ++ -DBUILD_STATIC_LIBS=On ++ -Dnanopb_BUILD_RUNTIME=On ++ -Dnanopb_BUILD_GENERATOR=On ++ -Dnanopb_PROTOC_PATH=${nanopb_SOURCE_DIR}/generator/protoc ++ -Dnanopb_MSVC_STATIC_RUNTIME=Off ++ -DCMAKE_INSTALL_PREFIX=${NANOPB_INSTALL_PATH} ++ -DCMAKE_TOOLCHAIN_FILE=${TS_EXTERNAL_LIB_TOOLCHAIN_FILE} ++ -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY ++ -GUnix\ Makefiles ++ ${nanopb_SOURCE_DIR} ++ WORKING_DIRECTORY ++ ${nanopb_BINARY_DIR} ++ RESULT_VARIABLE _exec_error ++ ) ++ endif() ++ ++ if (_exec_error) ++ message(FATAL_ERROR "Configuration step of nanopb runtime failed with ${_exec_error}.") ++ endif() ++ ++ execute_process(COMMAND + ${CMAKE_COMMAND} --build ${nanopb_BINARY_DIR} -- install -j8 + RESULT_VARIABLE _exec_error +- ) +-if (_exec_error) +- message(FATAL_ERROR "Build step of nanopb runtime failed with ${_exec_error}.") +-endif() ++ ) ++ if (_exec_error) ++ message(FATAL_ERROR "Build step of nanopb runtime failed with ${_exec_error}.") ++ endif() + +-#### Include Nanopb runtime in the build. +-find_package(Nanopb +- PATHS "${NANOPB_INSTALL_PATH}" +- NO_DEFAULT_PATH ++ #### Include Nanopb runtime in the build. ++ find_package(Nanopb ++ PATHS "${NANOPB_INSTALL_PATH}" ++ NO_DEFAULT_PATH + ) + +-#### Build access to the protobuf compiler +-#TODO: verify protoc dependencies: python3-protobuf +-find_package(Python3 COMPONENTS Interpreter) ++else() ++ ++ #### Build access to the protobuf compiler ++ #TODO: verify protoc dependencies: python3-protobuf ++ find_package(Nanopb REQUIRED) ++ ++endif() + ++find_package(Python3 COMPONENTS Interpreter) + if (NOT Python3_Interpreter_FOUND) + message(FATAL_ERROR "Failed to find python3 interpreter.") + endif() + +-find_file(NANOPB_GENERATOR_PATH +- NAMES nanopb_generator.py +- PATHS ${nanopb_SOURCE_DIR}/generator +- DOC "nanopb protobuf compiler" +- NO_DEFAULT_PATH ++if (NOT NANOPB_USE_INSTALLED) ++ find_file(NANOPB_GENERATOR_PATH ++ NAMES nanopb_generator.py ++ PATHS "${nanopb_SOURCE_DIR}/generator" ++ DOC "nanopb protobuf compiler" ++ REQUIRED ++ NO_DEFAULT_PATH ++ ) ++else() ++ find_file(NANOPB_GENERATOR_PATH ++ NAMES nanopb_generator.py ++ DOC "nanopb protobuf compiler" ++ REQUIRED + ) ++endif() + + if (NOT NANOPB_GENERATOR_PATH) + message(FATAL_ERROR "Nanopb generator was not found!") +-- +2.29.2 + diff --git a/meta-arm/recipes-security/trusted-services/files/0011-aarch64-Allow-the-stack-to-be-further-than-1MB-from-.patch b/meta-arm/recipes-security/trusted-services/files/0011-aarch64-Allow-the-stack-to-be-further-than-1MB-from-.patch new file mode 100644 index 00000000..14b79d6f --- /dev/null +++ b/meta-arm/recipes-security/trusted-services/files/0011-aarch64-Allow-the-stack-to-be-further-than-1MB-from-.patch @@ -0,0 +1,49 @@ +From 0075dc6cf30df6a2d91ab3870dabed4ac220a468 Mon Sep 17 00:00:00 2001 +From: Ben Horgan +Date: Mon, 22 Mar 2021 11:00:40 +0000 +Subject: [PATCH 11/13] aarch64: Allow the stack to be further than 1MB from + where it is set up + +Trusted-services crypto was previously building with the linaro 7.5 + aarch64-linux-gnu but not with arm 10.2 aarch64-none-linux-gnu. +Build error was: +aarch64/sp_entrypoint.S:22:(.text.sp_entrypoint+0x0): + relocation truncated to fit: R_AARCH64_ADR_PREL_LO21 against `.bss.stacks' + +Upstream-Status: Pending [Not submitted to upstream yet] +Signed-off-by: Ben Horgan +Change-Id: Ia422722c986bce50543f026ccbad728e6938f2b0 +Signed-off-by: Ben Horgan +--- + environments/shim/aarch64/sp_entrypoint.S | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/environments/shim/aarch64/sp_entrypoint.S b/environments/shim/aarch64/sp_entrypoint.S +index 8ef330b..ee7f84d 100644 +--- a/environments/shim/aarch64/sp_entrypoint.S ++++ b/environments/shim/aarch64/sp_entrypoint.S +@@ -12,17 +12,18 @@ + .globl sp_entrypoint + + .section .bss.stacks +- .balign CACHE_WRITEBACK_GRANULE ++ .balign CACHE_WRITEBACK_GRANULE + .fill SP_STACKS_SIZE + stacks_end: + + func sp_entrypoint + + /* Setup the stack pointer. */ +- adr x0, stacks_end ++ adrp x0, stacks_end ++ add x0, x0, :lo12:stacks_end + mov sp, x0 + /* Mask FIQs */ +- msr daifset, #DAIF_FIQ_BIT ++ msr daifset, #DAIF_FIQ_BIT + isb + + /* And jump to the C entrypoint. */ +-- +2.29.2 + diff --git a/meta-arm/recipes-security/trusted-services/files/0012-libc-Add-missing-libc-function-declarations.patch b/meta-arm/recipes-security/trusted-services/files/0012-libc-Add-missing-libc-function-declarations.patch new file mode 100644 index 00000000..500227be --- /dev/null +++ b/meta-arm/recipes-security/trusted-services/files/0012-libc-Add-missing-libc-function-declarations.patch @@ -0,0 +1,93 @@ +From 78ddf721076d2baca395f418973d5eb5d19ec4ab Mon Sep 17 00:00:00 2001 +From: Ben Horgan +Date: Tue, 30 Mar 2021 13:15:54 +0000 +Subject: [PATCH 12/13] libc: Add missing libc function declarations + +Upstream-Status: Pending [Not submitted to upstream yet] +Change-Id: I00e54db41b3226cc60a89bf4a81edea0a6fbb2a5 +Signed-off-by: Ben Horgan +--- + environments/shim/include/lib/libc/assert.h | 4 +--- + environments/shim/include/lib/libc/memory.h | 7 +++++++ + environments/shim/include/lib/libc/stdint.h | 18 +++++++++--------- + environments/shim/include/lib/libc/stdlib.h | 2 ++ + 4 files changed, 19 insertions(+), 12 deletions(-) + create mode 100644 environments/shim/include/lib/libc/memory.h + +diff --git a/environments/shim/include/lib/libc/assert.h b/environments/shim/include/lib/libc/assert.h +index ec28c26..e32259b 100644 +--- a/environments/shim/include/lib/libc/assert.h ++++ b/environments/shim/include/lib/libc/assert.h +@@ -1,5 +1,5 @@ + /* +- * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. ++ * Copyright (c) 2018 - 2021, ARM Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +@@ -9,8 +9,6 @@ + + #include + +-#include +- + #if ENABLE_ASSERTIONS + #define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e)) + #else +diff --git a/environments/shim/include/lib/libc/memory.h b/environments/shim/include/lib/libc/memory.h +new file mode 100644 +index 0000000..823bf26 +--- /dev/null ++++ b/environments/shim/include/lib/libc/memory.h +@@ -0,0 +1,7 @@ ++/* ++ * Copyright (c) 2021, ARM Limited and Contributors. All rights reserved. ++ * ++ * SPDX-License-Identifier: BSD-3-Clause ++ */ ++ ++#include +diff --git a/environments/shim/include/lib/libc/stdint.h b/environments/shim/include/lib/libc/stdint.h +index d5dbfc4..b636299 100644 +--- a/environments/shim/include/lib/libc/stdint.h ++++ b/environments/shim/include/lib/libc/stdint.h +@@ -107,15 +107,15 @@ typedef unsigned short uint16_least_t; + typedef unsigned int uint32_least_t; + typedef unsigned long long uint64_least_t; + +-typedef int int8_fast_t; +-typedef int int16_fast_t; +-typedef int int32_fast_t; +-typedef long long int64_fast_t; +- +-typedef unsigned int uint8_fast_t; +-typedef unsigned int uint16_fast_t; +-typedef unsigned int uint32_fast_t; +-typedef unsigned long long uint64_fast_t; ++typedef int int_fast8_t; ++typedef int int_fast16_t; ++typedef int int_fast32_t; ++typedef long long int_fast64_t; ++ ++typedef unsigned int uint_fast8_t; ++typedef unsigned int uint_fast16_t; ++typedef unsigned int uint_fast32_t; ++typedef unsigned long long uint_fast64_t; + + typedef long intptr_t; + typedef unsigned long uintptr_t; +diff --git a/environments/shim/include/lib/libc/stdlib.h b/environments/shim/include/lib/libc/stdlib.h +index bbd6889..7f01cfb 100644 +--- a/environments/shim/include/lib/libc/stdlib.h ++++ b/environments/shim/include/lib/libc/stdlib.h +@@ -30,5 +30,7 @@ void srand(unsigned int seed); + void malloc_add_pool(void *buf, size_t len); + void *malloc(size_t size); + void free(void *ptr); ++void *calloc(size_t nmemb, size_t size); ++void *realloc(void *ptr, size_t size); + + #endif /* STDLIB_H */ +-- +2.29.2 + diff --git a/meta-arm/recipes-security/trusted-services/files/0013-libsp-modify-FFA-ABIs-with-supported-convention.patch b/meta-arm/recipes-security/trusted-services/files/0013-libsp-modify-FFA-ABIs-with-supported-convention.patch new file mode 100644 index 00000000..a0e23756 --- /dev/null +++ b/meta-arm/recipes-security/trusted-services/files/0013-libsp-modify-FFA-ABIs-with-supported-convention.patch @@ -0,0 +1,69 @@ +From 8603e07c95ec9c543c38181f60d0a3ead4a5f237 Mon Sep 17 00:00:00 2001 +From: Arunachalam Ganapathy +Date: Mon, 12 Apr 2021 13:12:41 +0100 +Subject: [PATCH 13/13] libsp: modify FFA ABIs with supported convention + +SPMC at SEL2 (hafnium) only supports 64-bit variant of FFA_RXTX_MAP + +Upstream-Status: Pending [Not submitted to upstream yet] +Signed-off-by: Arunachalam Ganapathy +Change-Id: I17ba68bc298fd5d26dbead23dd0750b84319d9c6 +Signed-off-by: Ben Horgan +--- + components/messaging/ffa/libsp/ffa.c | 6 +++--- + components/messaging/ffa/libsp/sp_rxtx.c | 4 ++-- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/components/messaging/ffa/libsp/ffa.c b/components/messaging/ffa/libsp/ffa.c +index 648d3c8..2bdd31b 100644 +--- a/components/messaging/ffa/libsp/ffa.c ++++ b/components/messaging/ffa/libsp/ffa.c +@@ -1,6 +1,6 @@ + // SPDX-License-Identifier: BSD-3-Clause + /* +- * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. ++ * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved. + */ + + #include // for assert +@@ -133,14 +133,14 @@ ffa_result ffa_rxtx_map(const void *tx_buffer, const void *rx_buffer, + page_count = SHIFT_U32(page_count & FFA_RXTX_MAP_PAGE_COUNT_MASK, + FFA_RXTX_MAP_PAGE_COUNT_SHIFT); + +- ffa_svc(FFA_RXTX_MAP_32, (uintptr_t)tx_buffer, (uintptr_t)rx_buffer, ++ ffa_svc(FFA_RXTX_MAP_64, (uintptr_t)tx_buffer, (uintptr_t)rx_buffer, + page_count, FFA_PARAM_MBZ, FFA_PARAM_MBZ, FFA_PARAM_MBZ, + FFA_PARAM_MBZ, &result); + + if (result.a0 == FFA_ERROR) + return ffa_get_errorcode(&result); + +- assert(result.a0 == FFA_SUCCESS_32); ++ assert(result.a0 == FFA_SUCCESS_64); + return FFA_OK; + } + +diff --git a/components/messaging/ffa/libsp/sp_rxtx.c b/components/messaging/ffa/libsp/sp_rxtx.c +index a3de270..9468d83 100644 +--- a/components/messaging/ffa/libsp/sp_rxtx.c ++++ b/components/messaging/ffa/libsp/sp_rxtx.c +@@ -1,6 +1,6 @@ + // SPDX-License-Identifier: BSD-3-Clause + /* +- * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. ++ * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved. + */ + + #include "sp_rxtx.h" +@@ -99,7 +99,7 @@ sp_result sp_rxtx_buffer_alignment_boundary_get(uintptr_t *alignment) + return SP_RESULT_INVALID_PARAMETERS; + + /* Querying FFX_RXTX_MAP features */ +- result = ffa_features(FFA_RXTX_MAP_32, &interface_props); ++ result = ffa_features(FFA_RXTX_MAP_64, &interface_props); + if (result != FFA_OK) { + *alignment = 0; + return SP_RESULT_FFA(result); +-- +2.29.2 + diff --git a/meta-arm/recipes-security/trusted-services/libts_git.bb b/meta-arm/recipes-security/trusted-services/libts_git.bb new file mode 100644 index 00000000..06a1bce8 --- /dev/null +++ b/meta-arm/recipes-security/trusted-services/libts_git.bb @@ -0,0 +1,41 @@ +SUMMARY = "Trusted services linux library" +HOMEPAGE = "https://trusted-services.readthedocs.io/en/latest/index.html" + +LICENSE = "BSD-3-Clause" +LIC_FILES_CHKSUM = "file://license.rst;md5=ea160bac7f690a069c608516b17997f4" + +SRC_URI = "git://git.trustedfirmware.org/TS/trusted-services.git;protocol=https;branch=integration \ + file://0001-Add-a-new-environment-to-run-TS-with-a-shim-layer-in.patch \ + file://0002-Change-instruction-access-permissions-of-shared-memo.patch \ + file://0003-Set-in_region_count-to-0-during-memory-retrieve.patch \ + file://0004-Release-rx-buffer-after-memory-retrieve-request.patch \ + file://0005-crypto-sp-Create-a-new-deployment-with-the-shim-envi.patch \ + file://0006-secure-storage-Create-a-new-deployment-with-the-shim.patch \ + file://0007-crypto-shim-Don-t-link-against-unrequired-libraries.patch \ + file://0008-libts-arm-linux-Add-version-to-libts.so.patch \ + file://0009-libts-Add-option-to-use-installed-libts.patch \ + file://0010-external-Add-option-to-use-local-source-or-installed.patch \ + file://0011-aarch64-Allow-the-stack-to-be-further-than-1MB-from-.patch \ + file://0012-libc-Add-missing-libc-function-declarations.patch \ + file://0013-libsp-modify-FFA-ABIs-with-supported-convention.patch \ + " + +PV = "1.0+git${SRCPV}" +SRCREV = "eff4b28b6ae461defb2d8c0f614965439ed19386" + +S = "${WORKDIR}/git" + +inherit python3native cmake + +DEPENDS = "python3-pycryptodome-native python3-pycryptodomex-native \ + python3-pyelftools-native python3-grpcio-tools-native \ + python3-protobuf-native protobuf-native nanopb-native \ + ts-mbedcrypto \ + " + +OECMAKE_SOURCEPATH = "${S}/deployments/libts/arm-linux" +OECMAKE_GENERATOR = "Unix Makefiles" +EXTRA_OECMAKE = "-DCMAKE_POSITION_INDEPENDENT_CODE=True \ + -DCMAKE_SYSTEM_NAME=Linux \ + -DCMAKE_SYSTEM_PROCESSOR=arm \ + " diff --git a/meta-arm/recipes-security/trusted-services/secure-storage_git.bb b/meta-arm/recipes-security/trusted-services/secure-storage_git.bb new file mode 100644 index 00000000..b93a80eb --- /dev/null +++ b/meta-arm/recipes-security/trusted-services/secure-storage_git.bb @@ -0,0 +1,14 @@ +SUMMARY = "Secure storage secure partition" + +require sp.inc + +TS_DEPLOYMENT = "${S}/deployments/secure-storage/shim" + +do_install () { + install -d -m 755 ${D}/firmware + install -m 0644 "${B}/secure-storage.bin" "${D}/firmware/secure-storage.bin" + install -m 0644 "${S}/deployments/secure-storage/shim/secure-storage.dts" \ + "${D}/firmware/secure-storage.dts" +} + +FILES_${PN} = "/firmware/secure-storage.bin /firmware/secure-storage.dts" diff --git a/meta-arm/recipes-security/trusted-services/sp.inc b/meta-arm/recipes-security/trusted-services/sp.inc new file mode 100644 index 00000000..d3f5034a --- /dev/null +++ b/meta-arm/recipes-security/trusted-services/sp.inc @@ -0,0 +1,68 @@ +HOMEPAGE = "https://trusted-services.readthedocs.io/en/latest/index.html" + +PACKAGE_ARCH = "${MACHINE_ARCH}" + +LICENSE = "Apache-2.0 & BSD-3-Clause & Zlib" +LIC_FILES_CHKSUM = "file://license.rst;md5=ea160bac7f690a069c608516b17997f4 \ + file://mbedcrypto/LICENSE;md5=302d50a6369f5f22efdb674db908167a \ + file://nanopb/LICENSE.txt;md5=9db4b73a55a3994384112efcdb37c01f \ + " +SRC_URI = "git://git.trustedfirmware.org/TS/trusted-services.git;protocol=https;branch=main;name=ts;destsuffix=git \ + git://github.com/ARMmbed/mbed-crypto.git;protocol=git;branch=development;name=mbed;destsuffix=git/mbedcrypto \ + git://github.com/nanopb/nanopb.git;name=nanopb;branch=master;destsuffix=git/nanopb \ + file://0001-Add-a-new-environment-to-run-TS-with-a-shim-layer-in.patch \ + file://0002-Change-instruction-access-permissions-of-shared-memo.patch \ + file://0003-Set-in_region_count-to-0-during-memory-retrieve.patch \ + file://0004-Release-rx-buffer-after-memory-retrieve-request.patch \ + file://0005-crypto-sp-Create-a-new-deployment-with-the-shim-envi.patch \ + file://0006-secure-storage-Create-a-new-deployment-with-the-shim.patch \ + file://0007-crypto-shim-Don-t-link-against-unrequired-libraries.patch \ + file://0008-libts-arm-linux-Add-version-to-libts.so.patch \ + file://0009-libts-Add-option-to-use-installed-libts.patch \ + file://0010-external-Add-option-to-use-local-source-or-installed.patch \ + file://0011-aarch64-Allow-the-stack-to-be-further-than-1MB-from-.patch \ + file://0012-libc-Add-missing-libc-function-declarations.patch \ + file://0013-libsp-modify-FFA-ABIs-with-supported-convention.patch \ + " + +PV = "1.0+git${SRCPV}" + +SRCREV_FORMAT = "ts" +SRCREV_ts = "eff4b28b6ae461defb2d8c0f614965439ed19386" +SRCREV_mbed = "cf4a40ba0a3086cabb5a8227245191161fd26383" +SRCREV_nanopb = "df0e92f474f9cca704fe2b31483f0b4d1b1715a4" + +S = "${WORKDIR}/git" +TS_DEPLOYMENTS_DIR := "${S}/deployments/" + +inherit deploy python3native + +DEPENDS = "python3-pycryptodome-native python3-pycryptodomex-native \ + python3-pyelftools-native python3-grpcio-tools-native \ + python3-protobuf-native protobuf-native cmake-native \ + " + +# Baremetal, just need a compiler +DEPENDS_remove = "virtual/${TARGET_PREFIX}compilerlibs virtual/libc" + +export CROSS_COMPILE = "${TARGET_PREFIX}" + +B = "${WORKDIR}/build" + +do_configure() { + cmake \ + -DMBEDCRYPTO_SOURCE_PATH=${S}/mbedcrypto \ + -DNANOPB_SOURCE_PATH=${S}/nanopb \ + -S ${TS_DEPLOYMENT} -B ${B} +} + +do_compile() { + cmake --build ${B} +} + +SYSROOT_DIRS = "/firmware" + +do_deploy() { + cp -rf ${D}/firmware/* ${DEPLOYDIR}/ +} +addtask deploy after do_install diff --git a/meta-arm/recipes-security/trusted-services/ts-cpputest/cpputest-cmake-fix.patch b/meta-arm/recipes-security/trusted-services/ts-cpputest/cpputest-cmake-fix.patch new file mode 100644 index 00000000..fb589b74 --- /dev/null +++ b/meta-arm/recipes-security/trusted-services/ts-cpputest/cpputest-cmake-fix.patch @@ -0,0 +1,59 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b1900bb..d9ca865 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -116,8 +116,13 @@ if(PkgHelpers_AVAILABLE) + ${CMAKE_CURRENT_BINARY_DIR}/CppUTestConfig.cmake + INSTALL_DESTINATION ${CMAKE_CURRENT_BINARY_DIR} + PATH_VARS INCLUDE_DIR CMAKE_CURRENT_BINARY_DIR) +- export(TARGETS CppUTest CppUTestExt ++ if(TARGET CppUTestExt) ++ export(TARGETS CppUTest + FILE "${CMAKE_CURRENT_BINARY_DIR}/CppUTestTargets.cmake") ++ else() ++ export(TARGETS CppUTest ++ FILE "${CMAKE_CURRENT_BINARY_DIR}/CppUTestTargets.cmake") ++ endif() + write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/CppUTestConfigVersion.cmake + VERSION ${CppUTest_version_major}.${CppUTest_version_minor} +diff --git a/cmake/Modules/CppUTestConfigurationOptions.cmake b/cmake/Modules/CppUTestConfigurationOptions.cmake +index 634482c..a00b5eb 100644 +--- a/cmake/Modules/CppUTestConfigurationOptions.cmake ++++ b/cmake/Modules/CppUTestConfigurationOptions.cmake +@@ -1,19 +1,19 @@ + if (MSVC) +- set(CPP_PLATFORM VisualCpp) ++ set(CPP_PLATFORM VisualCpp CACHE STRING "CppUTest platform.") + include_directories(${CppUTestRootDirectory}/include/Platforms/${CPP_PLATFORM}) + option(STDC_WANT_SECURE_LIB "Use MSVC safe functions" ON) + if(STDC_WANT_SECURE_LIB) + ADD_DEFINITIONS(-DSTDC_WANT_SECURE_LIB) + endif(STDC_WANT_SECURE_LIB) + elseif (STD_C) +- set(CPP_PLATFORM Gcc) ++ set(CPP_PLATFORM Gcc CACHE STRING "CppUTest platform.") + else (MSVC) + set(STD_CPP False) + set(MEMORY_LEAK_DETECTION False) + set(CPPUTEST_CXX_FLAGS "${CPPUTEST_CXX_FLAGS} -nostdinc") + set(CPPUTEST_LD_FLAGS "${CPPUTEST_LD_FLAGS} -nostdinc") + set(CPPUTEST_STD_C_LIB_DISABLED 1) +- set(CPP_PLATFORM GccNoStdC) ++ set(CPP_PLATFORM GccNoStdC CACHE STRING "CppUTest platform.") + endif (MSVC) + + include("${CppUTestRootDirectory}/cmake/Modules/CppUTestWarningFlags.cmake") +diff --git a/src/CppUTest/CMakeLists.txt b/src/CppUTest/CMakeLists.txt +index 736777f..d9a592f 100644 +--- a/src/CppUTest/CMakeLists.txt ++++ b/src/CppUTest/CMakeLists.txt +@@ -50,7 +50,7 @@ set(CppUTest_headers + + add_library(CppUTest STATIC ${CppUTest_src} ${CppUTest_headers}) + if (WIN32) +- target_link_libraries(CppUTest winmm.lib) ++ target_link_libraries(CppUTest winmm) + endif (WIN32) + install(FILES ${CppUTest_headers} DESTINATION include/CppUTest) + install(TARGETS CppUTest diff --git a/meta-arm/recipes-security/trusted-services/ts-cpputest_3.8.bb b/meta-arm/recipes-security/trusted-services/ts-cpputest_3.8.bb new file mode 100644 index 00000000..393eea36 --- /dev/null +++ b/meta-arm/recipes-security/trusted-services/ts-cpputest_3.8.bb @@ -0,0 +1,30 @@ +SUMMARY = "CppUTest for trusted services" +DESCRIPTION = "CppUTest unit testing and mocking framework for C/C++" +HOMEPAGE = "http://cpputest.github.io/" + +LICENSE = "BSD-3-Clause" +LIC_FILES_CHKSUM = "file://COPYING;md5=ce5d5f1fe02bcd1343ced64a06fd4177" + +SRC_URI = "git://github.com/cpputest/cpputest.git \ + file://cpputest-cmake-fix.patch \ + " +SRCREV = "e25097614e1c4856036366877a02346c4b36bb5b" + +PV = "3.8+git${SRCPV}" + +S = "${WORKDIR}/git" + +inherit cmake + +OECMAKE_GENERATOR = "Unix Makefiles" +EXTRA_OECMAKE = "-DCMAKE_POSITION_INDEPENDENT_CODE=True \ + -DMEMORY_LEAK_DETECTION=OFF \ + -DLONGLONG=ON \ + -DC++11=ON \ + -DTESTS=OFF \ + -DEXTENSIONS=OFF \ + -DHAVE_FORK=OFF \ + -DCPP_PLATFORM=armcc \ + -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \ + " +FILES_${PN} += "/usr/lib/CppUTest/* /usr/lib/CppUTest/cmake/*" diff --git a/meta-arm/recipes-security/trusted-services/ts-demo_git.bb b/meta-arm/recipes-security/trusted-services/ts-demo_git.bb new file mode 100644 index 00000000..ad0a8b91 --- /dev/null +++ b/meta-arm/recipes-security/trusted-services/ts-demo_git.bb @@ -0,0 +1,42 @@ +SUMMARY = "Trusted Services test application" +HOMEPAGE = "https://trusted-services.readthedocs.io/en/latest/index.html" + +LICENSE = "BSD-3-Clause" +LIC_FILES_CHKSUM = "file://license.rst;md5=ea160bac7f690a069c608516b17997f4" + +SRC_URI = "git://git.trustedfirmware.org/TS/trusted-services.git;protocol=ssh;branch=main \ + file://0001-Add-a-new-environment-to-run-TS-with-a-shim-layer-in.patch \ + file://0002-Change-instruction-access-permissions-of-shared-memo.patch \ + file://0003-Set-in_region_count-to-0-during-memory-retrieve.patch \ + file://0004-Release-rx-buffer-after-memory-retrieve-request.patch \ + file://0005-crypto-sp-Create-a-new-deployment-with-the-shim-envi.patch \ + file://0006-secure-storage-Create-a-new-deployment-with-the-shim.patch \ + file://0007-crypto-shim-Don-t-link-against-unrequired-libraries.patch \ + file://0008-libts-arm-linux-Add-version-to-libts.so.patch \ + file://0009-libts-Add-option-to-use-installed-libts.patch \ + file://0010-external-Add-option-to-use-local-source-or-installed.patch \ + file://0011-aarch64-Allow-the-stack-to-be-further-than-1MB-from-.patch \ + file://0012-libc-Add-missing-libc-function-declarations.patch \ + file://0013-libsp-modify-FFA-ABIs-with-supported-convention.patch \ + " + +PV = "1.0+git${SRCPV}" +SRCREV = "eff4b28b6ae461defb2d8c0f614965439ed19386" + +S = "${WORKDIR}/git" + +inherit python3native cmake + +DEPENDS = "python3-pycryptodome-native python3-pycryptodomex-native \ + python3-pyelftools-native python3-grpcio-tools-native \ + python3-protobuf-native protobuf-native nanopb nanopb-native \ + ts-mbedcrypto libts \ + " + +OECMAKE_SOURCEPATH = "${S}/deployments/ts-demo/arm-linux" +OECMAKE_GENERATOR = "Unix Makefiles" +EXTRA_OECMAKE = "-DCMAKE_POSITION_INDEPENDENT_CODE=True \ + -DMBEDCRYPTO_USE_INSTALLED=True \ + -DNANOPB_USE_INSTALLED=True \ + -DLIBTS_USE_INSTALLED=True \ + " diff --git a/meta-arm/recipes-security/trusted-services/ts-mbedcrypto_3.1.0.bb b/meta-arm/recipes-security/trusted-services/ts-mbedcrypto_3.1.0.bb new file mode 100644 index 00000000..a6b8b76a --- /dev/null +++ b/meta-arm/recipes-security/trusted-services/ts-mbedcrypto_3.1.0.bb @@ -0,0 +1,46 @@ +SUMMARY = "Mbedcrypto for trusted services" +DESCRIPTION = "A reference implementation of the cryptography \ +interface of the Arm Platform Security Architecture (PSA). Compiled \ +with the configuration for trusted services." +HOMEPAGE = "https://github.com/ARMmbed/mbed-crypto" + +LICENSE = "Apache-2.0 & BSD-3-Clause" +LIC_FILES_CHKSUM = "file://LICENSE;md5=302d50a6369f5f22efdb674db908167a \ + file://ts/license.rst;md5=ea160bac7f690a069c608516b17997f4 \ + " +SRC_URI = "git://github.com/ARMmbed/mbed-crypto.git;protocol=git;branch=development;name=mbed;destsuffix=git \ + git://git.trustedfirmware.org/TS/trusted-services.git;protocol=https;branch=main;name=ts;destsuffix=git/ts \ + file://0001-Add-a-new-environment-to-run-TS-with-a-shim-layer-in.patch;patchdir=${S}/ts \ + file://0002-Change-instruction-access-permissions-of-shared-memo.patch;patchdir=${S}/ts \ + file://0003-Set-in_region_count-to-0-during-memory-retrieve.patch;patchdir=${S}/ts \ + file://0004-Release-rx-buffer-after-memory-retrieve-request.patch;patchdir=${S}/ts \ + file://0005-crypto-sp-Create-a-new-deployment-with-the-shim-envi.patch;patchdir=${S}/ts \ + file://0006-secure-storage-Create-a-new-deployment-with-the-shim.patch;patchdir=${S}/ts \ + file://0007-crypto-shim-Don-t-link-against-unrequired-libraries.patch;patchdir=${S}/ts \ + file://0008-libts-arm-linux-Add-version-to-libts.so.patch;patchdir=${S}/ts \ + file://0009-libts-Add-option-to-use-installed-libts.patch;patchdir=${S}/ts \ + file://0010-external-Add-option-to-use-local-source-or-installed.patch;patchdir=${S}/ts \ + file://0011-aarch64-Allow-the-stack-to-be-further-than-1MB-from-.patch;patchdir=${S}/ts \ + file://0012-libc-Add-missing-libc-function-declarations.patch;patchdir=${S}/ts \ + file://0013-libsp-modify-FFA-ABIs-with-supported-convention.patch;patchdir=${S}/ts \ + " + +PV = "3.1.0+git" + +SRCREV_FORMAT = "mbed" +SRCREV_mbed = "cf4a40ba0a3086cabb5a8227245191161fd26383" +SRCREV_ts = "eff4b28b6ae461defb2d8c0f614965439ed19386" + +S = "${WORKDIR}/git" + +inherit cmake + +MBEDCRYPTO_CONFIG_FILE = "${S}/ts/components/service/crypto/client/cpp/config_mbed_crypto.h" + +OECMAKE_GENERATOR = "Unix Makefiles" +EXTRA_OECMAKE = "-DCMAKE_POSITION_INDEPENDENT_CODE=True \ + -DENABLE_PROGRAMS=OFF \ + -DENABLE_TESTING=OFF \ + -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \ + -Dthirdparty_def=-DMBEDTLS_CONFIG_FILE=\"${MBEDCRYPTO_CONFIG_FILE}\" \ + " diff --git a/meta-arm/recipes-security/trusted-services/ts-service-test_git.bb b/meta-arm/recipes-security/trusted-services/ts-service-test_git.bb new file mode 100644 index 00000000..4f1aa47c --- /dev/null +++ b/meta-arm/recipes-security/trusted-services/ts-service-test_git.bb @@ -0,0 +1,42 @@ +SUMMARY = "Trusted Services demo application" +HOMEPAGE = "https://trusted-services.readthedocs.io/en/latest/index.html" + +LICENSE = "BSD-3-Clause" +LIC_FILES_CHKSUM = "file://license.rst;md5=ea160bac7f690a069c608516b17997f4" + +SRC_URI = "git://git.trustedfirmware.org/TS/trusted-services.git;protocol=https;branch=main \ + file://0001-Add-a-new-environment-to-run-TS-with-a-shim-layer-in.patch \ + file://0002-Change-instruction-access-permissions-of-shared-memo.patch \ + file://0003-Set-in_region_count-to-0-during-memory-retrieve.patch \ + file://0004-Release-rx-buffer-after-memory-retrieve-request.patch \ + file://0005-crypto-sp-Create-a-new-deployment-with-the-shim-envi.patch \ + file://0006-secure-storage-Create-a-new-deployment-with-the-shim.patch \ + file://0007-crypto-shim-Don-t-link-against-unrequired-libraries.patch \ + file://0008-libts-arm-linux-Add-version-to-libts.so.patch \ + file://0009-libts-Add-option-to-use-installed-libts.patch \ + file://0010-external-Add-option-to-use-local-source-or-installed.patch \ + file://0011-aarch64-Allow-the-stack-to-be-further-than-1MB-from-.patch \ + file://0012-libc-Add-missing-libc-function-declarations.patch \ + file://0013-libsp-modify-FFA-ABIs-with-supported-convention.patch \ + " + +PV = "1.0+git${SRCPV}" +SRCREV = "eff4b28b6ae461defb2d8c0f614965439ed19386" + +S = "${WORKDIR}/git" + +inherit deploy python3native cmake + +DEPENDS = "python3-pycryptodome-native python3-pycryptodomex-native \ + python3-pyelftools-native python3-grpcio-tools-native \ + python3-protobuf-native protobuf-native nanopb nanopb-native \ + ts-mbedcrypto libts ts-cpputest" + +OECMAKE_SOURCEPATH = "${S}/deployments/ts-service-test/arm-linux" +OECMAKE_GENERATOR = "Unix Makefiles" +EXTRA_OECMAKE = "-DCMAKE_POSITION_INDEPENDENT_CODE=True \ + -DMBEDCRYPTO_USE_INSTALLED=True \ + -DNANOPB_USE_INSTALLED=True \ + -DLIBTS_USE_INSTALLED=True \ + -DCPPUTEST_USE_INSTALLED=True \ + " diff --git a/meta-gem5/conf/layer.conf b/meta-gem5/conf/layer.conf index 58242c32..a6448eb9 100644 --- a/meta-gem5/conf/layer.conf +++ b/meta-gem5/conf/layer.conf @@ -7,7 +7,7 @@ BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ BBFILE_COLLECTIONS += "meta-gem5" BBFILE_PATTERN_meta-gem5 = "^${LAYERDIR}/" -BBFILE_PRIORITY_meta-gem5 = "6" +BBFILE_PRIORITY_meta-gem5 = "5" LAYERDEPENDS_meta-gem5 = "core openembedded-layer" LAYERSERIES_COMPAT_meta-gem5 = "gatesgarth" diff --git a/meta-gem5/recipes-devtools/gem5/files/pyinit-threads.patch b/meta-gem5/recipes-devtools/gem5/files/pyinit-threads.patch new file mode 100644 index 00000000..ac0c8413 --- /dev/null +++ b/meta-gem5/recipes-devtools/gem5/files/pyinit-threads.patch @@ -0,0 +1,32 @@ +Upstream-Status: Backport +Signed-off-by: Ross Burton + +From ae2ee2a4a51914cf78deb5c253a3b03cbb53ce72 Mon Sep 17 00:00:00 2001 +From: Boris Staletic +Date: Mon, 15 Jun 2020 19:36:43 +0200 +Subject: [PATCH] Avoid using deprecated API in python 3.9 + +The PyEval_InitThreads() and PyEval_ThreadsInitialized() functions are +now deprecated and will be removed in Python 3.11. Calling +PyEval_InitThreads() now does nothing. The GIL is initialized by +Py_Initialize() since Python 3.7. +--- + include/pybind11/detail/internals.h | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/include/pybind11/detail/internals.h b/include/pybind11/detail/internals.h +index 6224dfb22..166a18a32 100644 +--- a/ext/pybind11/include/pybind11/detail/internals.h ++++ b/ext/pybind11/include/pybind11/detail/internals.h +@@ -273,7 +273,10 @@ PYBIND11_NOINLINE inline internals &get_internals() { + auto *&internals_ptr = *internals_pp; + internals_ptr = new internals(); + #if defined(WITH_THREAD) +- PyEval_InitThreads(); ++ ++ #if PY_VERSION_HEX < 0x03090000 ++ PyEval_InitThreads(); ++ #endif + PyThreadState *tstate = PyThreadState_Get(); + #if PY_VERSION_HEX >= 0x03070000 + internals_ptr->tstate = PyThread_tss_alloc(); diff --git a/meta-gem5/recipes-devtools/gem5/files/start-gem5.sh b/meta-gem5/recipes-devtools/gem5/files/start-gem5.sh index 4edc0e51..63354116 100644 --- a/meta-gem5/recipes-devtools/gem5/files/start-gem5.sh +++ b/meta-gem5/recipes-devtools/gem5/files/start-gem5.sh @@ -34,6 +34,6 @@ if [ -n "${GEM5_RUN_EXTRA}" ]; then args="$args ${GEM5_RUN_EXTRA}" fi -${STAGING_BINDIR_NATIVE}/${GEM5_RUN_CONFIG} \ +oe-run-native gem5-aarch64-native ${GEM5_RUN_CONFIG} \ ${STAGING_DATADIR_NATIVE}/gem5/${GEM5_RUN_PROFILE} ${args} "$@" diff --git a/meta-gem5/recipes-devtools/gem5/gem5-aarch64-bootloader_20.bb b/meta-gem5/recipes-devtools/gem5/gem5-aarch64-bootloader_20.bb index d960e6cd..67570f63 100644 --- a/meta-gem5/recipes-devtools/gem5/gem5-aarch64-bootloader_20.bb +++ b/meta-gem5/recipes-devtools/gem5/gem5-aarch64-bootloader_20.bb @@ -1,15 +1,6 @@ # gem5 custom bootloader -LIC_FILES_CHKSUM = "file://COPYING;md5=2d9514d69d8abf88b6e9125e759bf0ab \ - file://LICENSE;md5=a585e2893cee63d16a1d8bc16c6297ec" - -SRC_URI = "git://gem5.googlesource.com/public/gem5;protocol=https;nobranch=1" -RELEASE_TAG = "v20.0.0.1" -SRCREV = "332a9de33db603e0aefedae1e05134db4257ea3e" - -PV = "${RELEASE_TAG}" - -S = "${WORKDIR}/git" +require gem5-source_20.inc BPN = "gem5-aarch64-bootloader" diff --git a/meta-gem5/recipes-devtools/gem5/gem5-aarch64-dtb.bb b/meta-gem5/recipes-devtools/gem5/gem5-aarch64-dtb.bb index b97a1b28..50ac0300 100644 --- a/meta-gem5/recipes-devtools/gem5/gem5-aarch64-dtb.bb +++ b/meta-gem5/recipes-devtools/gem5/gem5-aarch64-dtb.bb @@ -11,7 +11,7 @@ do_configure[noexec] = "1" do_compile() { # generate a dtb using gem5 gem5.opt \ - ${STAGING_DATADIR_NATIVE}/gem5/configs/example/arm/baremetal.py \ + ${STAGING_DATADIR_NATIVE}/gem5/${GEM5_RUN_PROFILE} \ --dtb-gen if [ ! -f m5out/system.dtb ]; then diff --git a/meta-gem5/recipes-devtools/gem5/gem5-aarch64-native.inc b/meta-gem5/recipes-devtools/gem5/gem5-aarch64-native.inc index 898fa23c..0a8e34c1 100644 --- a/meta-gem5/recipes-devtools/gem5/gem5-aarch64-native.inc +++ b/meta-gem5/recipes-devtools/gem5/gem5-aarch64-native.inc @@ -1,8 +1,7 @@ # gem5 aarch64 specific configuration # Build arm64 gem5 -GEM5_BUILD_CONFIGS ?= "build/ARM/gem5.opt build/ARM/gem5.fast \ - build/ARM/gem5.debug" +GEM5_BUILD_CONFIGS ?= "build/ARM/gem5.${GEM5_BUILD_VARIANT}" SRC_URI += "file://start-gem5.sh" @@ -10,7 +9,7 @@ inherit deploy # Parameters for the start script -GEM5_RUN_CONFIG ?= "gem5.fast" +GEM5_RUN_CONFIG ?= "gem5.${GEM5_BUILD_VARIANT}" # Linux kernel file to boot GEM5_RUN_KERNEL ?= "vmlinux" diff --git a/meta-gem5/recipes-devtools/gem5/gem5-aarch64-native/0001-dev-arm-SMMUv3-enable-interrupt-interface.patch b/meta-gem5/recipes-devtools/gem5/gem5-aarch64-native/0001-dev-arm-SMMUv3-enable-interrupt-interface.patch new file mode 100644 index 00000000..6d00cc26 --- /dev/null +++ b/meta-gem5/recipes-devtools/gem5/gem5-aarch64-native/0001-dev-arm-SMMUv3-enable-interrupt-interface.patch @@ -0,0 +1,97 @@ +From be710c5657b03bc9a9ce18ecf7ce1956265bae47 Mon Sep 17 00:00:00 2001 +From: Adrian Herrera +Date: Thu, 10 Dec 2020 18:07:21 +0000 +Subject: [PATCH] dev-arm: SMMUv3, enable interrupt interface + +Users can set "irq_interface_enable" to allow software to program +SMMU_IRQ_CTRL and SMMU_IRQ_CTRLACK. This is required to boot Linux v5.4+ +in a reasonable time. Notice the model does not implement architectural +interrupt sources, so no assertions will happen. + +Change-Id: Ie138befdf5a204fe8fce961081c575c2166e22b9 +Signed-off-by: Adrian Herrera +Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/38555 +Tested-by: kokoro +Reviewed-by: Andreas Sandberg +Maintainer: Andreas Sandberg + +Upstream-Status: Accepted [https://gem5-review.googlesource.com/c/public/gem5/+/38555] +Expected version: v20.2 +--- + src/dev/arm/SMMUv3.py | 5 +++++ + src/dev/arm/smmu_v3.cc | 10 +++++++++- + src/dev/arm/smmu_v3.hh | 4 +++- + 3 files changed, 17 insertions(+), 2 deletions(-) + +diff --git a/src/dev/arm/SMMUv3.py b/src/dev/arm/SMMUv3.py +index 29c15682bf..f57be896f9 100644 +--- a/src/dev/arm/SMMUv3.py ++++ b/src/dev/arm/SMMUv3.py +@@ -91,6 +91,11 @@ class SMMUv3(ClockedObject): + reg_map = Param.AddrRange('Address range for control registers') + system = Param.System(Parent.any, "System this device is part of") + ++ irq_interface_enable = Param.Bool(False, ++ "This flag enables software to program SMMU_IRQ_CTRL and " ++ "SMMU_IRQ_CTRLACK as if the model implemented architectural " ++ "interrupt sources") ++ + device_interfaces = VectorParam.SMMUv3DeviceInterface([], + "Responder interfaces") + +diff --git a/src/dev/arm/smmu_v3.cc b/src/dev/arm/smmu_v3.cc +index f9bdc277c6..d73f270170 100644 +--- a/src/dev/arm/smmu_v3.cc ++++ b/src/dev/arm/smmu_v3.cc +@@ -1,5 +1,5 @@ + /* +- * Copyright (c) 2013, 2018-2019 ARM Limited ++ * Copyright (c) 2013, 2018-2020 ARM Limited + * All rights reserved + * + * The license below extends only to copyright in the software and shall +@@ -58,6 +58,7 @@ SMMUv3::SMMUv3(SMMUv3Params *params) : + requestPort(name() + ".request", *this), + tableWalkPort(name() + ".walker", *this), + controlPort(name() + ".control", *this, params->reg_map), ++ irqInterfaceEnable(params->irq_interface_enable), + tlb(params->tlb_entries, params->tlb_assoc, params->tlb_policy), + configCache(params->cfg_entries, params->cfg_assoc, params->cfg_policy), + ipaCache(params->ipa_entries, params->ipa_assoc, params->ipa_policy), +@@ -626,6 +627,13 @@ SMMUv3::writeControl(PacketPtr pkt) + assert(pkt->getSize() == sizeof(uint32_t)); + regs.cr0 = regs.cr0ack = pkt->getLE(); + break; ++ case offsetof(SMMURegs, irq_ctrl): ++ assert(pkt->getSize() == sizeof(uint32_t)); ++ if (irqInterfaceEnable) { ++ warn("SMMUv3::%s No support for interrupt sources", __func__); ++ regs.irq_ctrl = regs.irq_ctrlack = pkt->getLE(); ++ } ++ break; + + case offsetof(SMMURegs, cr1): + case offsetof(SMMURegs, cr2): +diff --git a/src/dev/arm/smmu_v3.hh b/src/dev/arm/smmu_v3.hh +index 6b3f3982b8..a001d71178 100644 +--- a/src/dev/arm/smmu_v3.hh ++++ b/src/dev/arm/smmu_v3.hh +@@ -1,5 +1,5 @@ + /* +- * Copyright (c) 2013, 2018-2019 ARM Limited ++ * Copyright (c) 2013, 2018-2020 ARM Limited + * All rights reserved + * + * The license below extends only to copyright in the software and shall +@@ -94,6 +94,8 @@ class SMMUv3 : public ClockedObject + SMMUTableWalkPort tableWalkPort; + SMMUControlPort controlPort; + ++ const bool irqInterfaceEnable; ++ + ARMArchTLB tlb; + ConfigCache configCache; + IPACache ipaCache; +-- +2.17.1 + diff --git a/meta-gem5/recipes-devtools/gem5/gem5-aarch64-native/0001-scons-Add-MARSHAL_XXFLAGS_EXTRA-for-the-marshal-object.patch b/meta-gem5/recipes-devtools/gem5/gem5-aarch64-native/0001-scons-Add-MARSHAL_XXFLAGS_EXTRA-for-the-marshal-object.patch deleted file mode 100644 index 4303a402..00000000 --- a/meta-gem5/recipes-devtools/gem5/gem5-aarch64-native/0001-scons-Add-MARSHAL_XXFLAGS_EXTRA-for-the-marshal-object.patch +++ /dev/null @@ -1,85 +0,0 @@ -From 1303d0497bad151f9389ee30c37dc5f9fe325f6e Mon Sep 17 00:00:00 2001 -From: Giacomo Travaglini -Date: Thu, 04 Jun 2020 12:45:52 +0100 -Subject: [PATCH] scons: Add MARSHAL_XXFLAGS_EXTRA for the marshal object - -We already provide to the user the CCFLAGS_EXTRA, LDFLAGS_EXTRA -variables to pass flags to scons when compiling/linking gem5. -Those variables are not passed to the marshal object. -We add an extra pair: - -MARSHAL_CCFLAGS_EXTRA, MARSHAL_LDFLAGS_EXTRA - -to add flag injection capabilities to the marshal object. - -The patch is also renaming base_py_env to marshal_env. -This happens for 2 reasons: - -1) At the moment the marshal compilation is the only task -making use of the base python environment. - -2) Consistency with the EXTRA variable names added with this patch. -I could have named them as BASE_XXFLAGS_EXTRA, but it seems too much -generic and users might be confused by that, as they might think -the BASE_XXFLAGS_EXTRA is a subset of the XXFLAGS_EXTRA so that -setting it will affect gem5 compilation as well. - -Change-Id: I3e420caa897059455ff8f35462db2b38da050e93 -Signed-off-by: Giacomo Travaglini ---- - -diff --git a/SConstruct b/SConstruct -index 3a03af4..5a66bba 100755 ---- a/SConstruct -+++ b/SConstruct -@@ -276,6 +276,8 @@ - ('CXX', 'C++ compiler', environ.get('CXX', main['CXX'])), - ('CCFLAGS_EXTRA', 'Extra C and C++ compiler flags', ''), - ('LDFLAGS_EXTRA', 'Extra linker flags', ''), -+ ('MARSHAL_CCFLAGS_EXTRA', 'Extra C and C++ marshal compiler flags', ''), -+ ('MARSHAL_LDFLAGS_EXTRA', 'Extra marshal linker flags', ''), - ('PYTHON_CONFIG', 'Python config binary to use', - [ 'python2.7-config', 'python-config', 'python3-config' ]), - ('PROTOC', 'protoc tool', environ.get('PROTOC', 'protoc')), -@@ -734,7 +736,9 @@ - - main.Prepend(CPPPATH=Dir('ext/pybind11/include/')) - # Bare minimum environment that only includes python --base_py_env = main.Clone() -+marshal_env = main.Clone() -+marshal_env.Append(CCFLAGS='$MARSHAL_CCFLAGS_EXTRA') -+marshal_env.Append(LINKFLAGS='$MARSHAL_LDFLAGS_EXTRA') - - # On Solaris you need to use libsocket for socket ops - if not conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'): -@@ -1285,7 +1289,7 @@ - # to the configured variables. It returns a list of environments, - # one for each variant build (debug, opt, etc.) - SConscript('src/SConscript', variant_dir=variant_path, -- exports=['env', 'base_py_env']) -+ exports=['env', 'marshal_env']) - - # base help text - Help(''' -diff --git a/src/SConscript b/src/SConscript -index 7cd628a..aa233c8 100644 ---- a/src/SConscript -+++ b/src/SConscript -@@ -1140,7 +1140,7 @@ - # Build a small helper that marshals the Python code using the same - # version of Python as gem5. This is in an unorthodox location to - # avoid building it for every variant. --py_marshal = base_py_env.Program('marshal', 'python/marshal.cc')[0] -+py_marshal = marshal_env.Program('marshal', 'python/marshal.cc')[0] - - # Embed python files. All .py files that have been indicated by a - # PySource() call in a SConscript need to be embedded into the M5 -@@ -1196,7 +1196,7 @@ - code.write(str(target[0])) - - for source in PySource.all: -- base_py_env.Command(source.cpp, [ py_marshal, source.tnode ], -+ marshal_env.Command(source.cpp, [ py_marshal, source.tnode ], - MakeAction(embedPyFile, Transform("EMBED PY"))) - Source(source.cpp, tags=source.tags, add_tags='python') - diff --git a/meta-gem5/recipes-devtools/gem5/gem5-aarch64-native/0002-arch-arm-Introduce-HavePACExt-helper.patch b/meta-gem5/recipes-devtools/gem5/gem5-aarch64-native/0002-arch-arm-Introduce-HavePACExt-helper.patch deleted file mode 100644 index 9d46f8a1..00000000 --- a/meta-gem5/recipes-devtools/gem5/gem5-aarch64-native/0002-arch-arm-Introduce-HavePACExt-helper.patch +++ /dev/null @@ -1,55 +0,0 @@ -Upstream-Status: Backport [https://gem5.googlesource.com/public/gem5/+/6d15745532df2dd306ecc15bd0e9f79914be1682] -Signed-off-by: Diego Sueiro - -From 6d15745532df2dd306ecc15bd0e9f79914be1682 Mon Sep 17 00:00:00 2001 -From: Giacomo Travaglini -Date: Tue, 25 Aug 2020 12:15:17 +0100 -Subject: [PATCH] arch-arm: Introduce HavePACExt helper - -This will check for presence of pointer authentication extension. -According to the reference manual, Pointer authentication is -implemented if the value of at least one of - -ID_AA64ISAR1_EL1.{APA, API, GPA, GPI} - -is not 0b0000. - -Change-Id: I4e98e65758e8edc953794e5b618d2c6c3f6000ae -Signed-off-by: Giacomo Travaglini -Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/33454 -Reviewed-by: Andreas Sandberg -Maintainer: Andreas Sandberg -Tested-by: kokoro ---- - -diff --git a/src/arch/arm/utility.cc b/src/arch/arm/utility.cc -index ad0a3da..a189c4a 100644 ---- a/src/arch/arm/utility.cc -+++ b/src/arch/arm/utility.cc -@@ -315,6 +315,14 @@ - } - - bool -+HavePACExt(ThreadContext *tc) -+{ -+ AA64ISAR1 id_aa64isar1 = tc->readMiscReg(MISCREG_ID_AA64ISAR1_EL1); -+ return id_aa64isar1.api | id_aa64isar1.apa | -+ id_aa64isar1.gpi | id_aa64isar1.gpa; -+} -+ -+bool - HaveVirtHostExt(ThreadContext *tc) - { - AA64MMFR1 id_aa64mmfr1 = tc->readMiscReg(MISCREG_ID_AA64MMFR1_EL1); -diff --git a/src/arch/arm/utility.hh b/src/arch/arm/utility.hh -index f00f606..f17ebc5 100644 ---- a/src/arch/arm/utility.hh -+++ b/src/arch/arm/utility.hh -@@ -151,6 +151,7 @@ - return opModeToEL((OperatingMode) (uint8_t)cpsr.mode); - } - -+bool HavePACExt(ThreadContext *tc); - bool HaveVirtHostExt(ThreadContext *tc); - bool HaveSecureEL2Ext(ThreadContext *tc); - bool IsSecureEL2Enabled(ThreadContext *tc); diff --git a/meta-gem5/recipes-devtools/gem5/gem5-aarch64-native/0003-arch-arm-Check-if-PAC-is-implemented-before-executing-insts.patch b/meta-gem5/recipes-devtools/gem5/gem5-aarch64-native/0003-arch-arm-Check-if-PAC-is-implemented-before-executing-insts.patch deleted file mode 100644 index 4410d97b..00000000 --- a/meta-gem5/recipes-devtools/gem5/gem5-aarch64-native/0003-arch-arm-Check-if-PAC-is-implemented-before-executing-insts.patch +++ /dev/null @@ -1,174 +0,0 @@ -Upstream-Status: Backport [https://gem5.googlesource.com/public/gem5/+/b50d61fb9ff5d94f401af98bb0b7f8e25d21d012] -Signed-off-by: Diego Sueiro - -From b50d61fb9ff5d94f401af98bb0b7f8e25d21d012 Mon Sep 17 00:00:00 2001 -From: Giacomo Travaglini -Date: Tue, 25 Aug 2020 13:10:23 +0100 -Subject: [PATCH] arch-arm: Check if PAC is implemented before executing insts - -If Armv8.3-PAuth (PAC) extension is not supported, most instrucions -will trigger an Undefined Instruction fault; except for a group of -them living in the HINT space; those should be treated as NOP. - -Change-Id: Idec920ed15e0310ec9132a3cb3701cdb7e7cf9d1 -Signed-off-by: Giacomo Travaglini -Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/33455 -Reviewed-by: Andreas Sandberg -Maintainer: Andreas Sandberg -Tested-by: kokoro ---- - -diff --git a/src/arch/arm/isa/insts/pauth.isa b/src/arch/arm/isa/insts/pauth.isa -index 4c5b371..4806e6a 100644 ---- a/src/arch/arm/isa/insts/pauth.isa -+++ b/src/arch/arm/isa/insts/pauth.isa -@@ -1,5 +1,6 @@ - // -*- mode:c++ -*- - -+// Copyright (c) 2020 ARM Limited - // Copyright (c) 2020 Metempsy Technology Consulting - // All rights reserved - // -@@ -41,20 +42,39 @@ - decoder_output = "" - exec_output = "" - -+ def pacEnabledCode(hint): -+ if hint: -+ code = """ -+ if (!HavePACExt(xc->tcBase())) { -+ return NoFault; -+ } -+ """ -+ else: -+ code = """ -+ if (!HavePACExt(xc->tcBase())) { -+ return std::make_shared( -+ machInst, true); -+ } -+ """ -+ return code - -- def buildPauthObject(mnem, templateBase, opcode, optArgs=[]): -+ def buildPauthObject(mnem, templateBase, opcode, hint, optArgs=[]): - global header_output, decoder_output, exec_output -- pac_code = '''//uint64_t val = 0; -- uint64_t res; -- fault = %(op)s(xc->tcBase(), %(op1)s, %(op2)s, &res); -- XDest = res; -- ''' -+ pac_code = ''' -+ %(enabled)s -+ -+ uint64_t res; -+ fault = %(op)s(xc->tcBase(), %(op1)s, %(op2)s, &res); -+ XDest = res; -+ ''' - if templateBase=='DataX2Reg': -- code = pac_code % {"op1": 'Op164', -+ code = pac_code % {"enabled": pacEnabledCode(hint), -+ "op1": 'Op164', - "op2": 'Op264', - "op": opcode } - else: -- code = pac_code % {"op1": 'XDest', -+ code = pac_code % {"enabled": pacEnabledCode(hint), -+ "op1": 'XDest', - "op2": 'Op164', - "op": opcode } - -@@ -63,13 +83,15 @@ - decoder_output += eval(templateBase + "Constructor").subst(iop) - exec_output += BasicExecute.subst(iop) - -- def buildXPauthObject(mnem, optArgs=[]): -+ def buildXPauthObject(mnem, hint, optArgs=[]): - global header_output, decoder_output, exec_output - templateBase = "XPauthOpRegReg" - -- code = 'uint64_t res;\n'\ -- 'fault = stripPAC(xc->tcBase(), XDest, data, &res);\n' -- code += 'XDest = res;' -+ code = pacEnabledCode(hint) + """ -+ uint64_t res; -+ fault = stripPAC(xc->tcBase(), XDest, data, &res); -+ XDest = res; -+ """ - regoptype = 'RegOp' - - iop = InstObjParams(mnem, mnem, regoptype, code, optArgs) -@@ -78,42 +100,42 @@ - exec_output += BasicExecute.subst(iop) - - -- buildPauthObject("Pacda", "DataX1Reg", 'addPACDA') -- buildPauthObject("Pacdza", "DataX1Reg", 'addPACDA') -- buildPauthObject("Pacdb", "DataX1Reg", 'addPACDB') -- buildPauthObject("Pacdzb", "DataX1Reg", 'addPACDB') -- buildPauthObject("Pacga", "DataX2Reg", 'addPACGA') -+ buildPauthObject("Pacda", "DataX1Reg", 'addPACDA', hint=False) -+ buildPauthObject("Pacdza", "DataX1Reg", 'addPACDA', hint=False) -+ buildPauthObject("Pacdb", "DataX1Reg", 'addPACDB', hint=False) -+ buildPauthObject("Pacdzb", "DataX1Reg", 'addPACDB', hint=False) -+ buildPauthObject("Pacga", "DataX2Reg", 'addPACGA', hint=False) - -- buildPauthObject("Pacia", "DataX1Reg", 'addPACIA') -- buildPauthObject("Pacia1716", "DataX1Reg", 'addPACIA') -- buildPauthObject("Paciasp", "DataX1Reg", 'addPACIA') -- buildPauthObject("Paciaz", "DataX1Reg", 'addPACIA') -- buildPauthObject("Paciza", "DataX1Reg", 'addPACIA') -+ buildPauthObject("Pacia", "DataX1Reg", 'addPACIA', hint=False) -+ buildPauthObject("Pacia1716", "DataX1Reg", 'addPACIA', hint=True) -+ buildPauthObject("Paciasp", "DataX1Reg", 'addPACIA', hint=True) -+ buildPauthObject("Paciaz", "DataX1Reg", 'addPACIA', hint=True) -+ buildPauthObject("Paciza", "DataX1Reg", 'addPACIA', hint=False) - -- buildPauthObject("Pacib", "DataX1Reg", 'addPACIB') -- buildPauthObject("Pacib1716", "DataX1Reg", 'addPACIB') -- buildPauthObject("Pacibsp", "DataX1Reg", 'addPACIB') -- buildPauthObject("Pacibz", "DataX1Reg", 'addPACIB') -- buildPauthObject("Pacizb", "DataX1Reg", 'addPACIB') -+ buildPauthObject("Pacib", "DataX1Reg", 'addPACIB', hint=False) -+ buildPauthObject("Pacib1716", "DataX1Reg", 'addPACIB', hint=True) -+ buildPauthObject("Pacibsp", "DataX1Reg", 'addPACIB', hint=True) -+ buildPauthObject("Pacibz", "DataX1Reg", 'addPACIB', hint=True) -+ buildPauthObject("Pacizb", "DataX1Reg", 'addPACIB', hint=False) - -- buildPauthObject("Autda", "DataX1Reg", 'authDA') -- buildPauthObject("Autdza", "DataX1Reg", 'authDA') -- buildPauthObject("Autdb", "DataX1Reg", 'authDB') -- buildPauthObject("Autdzb", "DataX1Reg", 'authDB') -+ buildPauthObject("Autda", "DataX1Reg", 'authDA', hint=False) -+ buildPauthObject("Autdza", "DataX1Reg", 'authDA', hint=False) -+ buildPauthObject("Autdb", "DataX1Reg", 'authDB', hint=False) -+ buildPauthObject("Autdzb", "DataX1Reg", 'authDB', hint=False) - -- buildPauthObject("Autia", "DataX1Reg", 'authIA') -- buildPauthObject("Autia1716", "DataX1Reg", 'authIA') -- buildPauthObject("Autiasp", "DataX1Reg", 'authIA') -- buildPauthObject("Autiaz", "DataX1Reg", 'authIA') -- buildPauthObject("Autiza", "DataX1Reg", 'authIA') -+ buildPauthObject("Autia", "DataX1Reg", 'authIA', hint=False) -+ buildPauthObject("Autia1716", "DataX1Reg", 'authIA', hint=True) -+ buildPauthObject("Autiasp", "DataX1Reg", 'authIA', hint=True) -+ buildPauthObject("Autiaz", "DataX1Reg", 'authIA', hint=True) -+ buildPauthObject("Autiza", "DataX1Reg", 'authIA', hint=False) - -- buildPauthObject("Autib", "DataX1Reg", 'authIB') -- buildPauthObject("Autib1716", "DataX1Reg", 'authIB') -- buildPauthObject("Autibsp", "DataX1Reg", 'authIB') -- buildPauthObject("Autibz", "DataX1Reg", 'authIB') -- buildPauthObject("Autizb", "DataX1Reg", 'authIB') -+ buildPauthObject("Autib", "DataX1Reg", 'authIB', hint=False) -+ buildPauthObject("Autib1716", "DataX1Reg", 'authIB', hint=True) -+ buildPauthObject("Autibsp", "DataX1Reg", 'authIB', hint=True) -+ buildPauthObject("Autibz", "DataX1Reg", 'authIB', hint=True) -+ buildPauthObject("Autizb", "DataX1Reg", 'authIB', hint=False) - -- buildXPauthObject("Xpacd") -- buildXPauthObject("Xpaci") -- buildXPauthObject("Xpaclri") -+ buildXPauthObject("Xpacd", hint=False) -+ buildXPauthObject("Xpaci", hint=False) -+ buildXPauthObject("Xpaclri", hint=True) - }}; diff --git a/meta-gem5/recipes-devtools/gem5/gem5-aarch64-native_20.bb b/meta-gem5/recipes-devtools/gem5/gem5-aarch64-native_20.bb index 101e6ef5..79cf9105 100644 --- a/meta-gem5/recipes-devtools/gem5/gem5-aarch64-native_20.bb +++ b/meta-gem5/recipes-devtools/gem5/gem5-aarch64-native_20.bb @@ -1,19 +1,6 @@ -# gem5 simulator source and checksum information +require gem5-source_20.inc -LIC_FILES_CHKSUM = "file://COPYING;md5=2d9514d69d8abf88b6e9125e759bf0ab \ - file://LICENSE;md5=a585e2893cee63d16a1d8bc16c6297ec" - -SRC_URI = "git://gem5.googlesource.com/public/gem5;protocol=https;nobranch=1 \ - file://0001-scons-Add-MARSHAL_XXFLAGS_EXTRA-for-the-marshal-object.patch \ - file://0002-arch-arm-Introduce-HavePACExt-helper.patch \ - file://0003-arch-arm-Check-if-PAC-is-implemented-before-executing-insts.patch \ - " -RELEASE_TAG = "v20.0.0.1" -SRCREV = "332a9de33db603e0aefedae1e05134db4257ea3e" - -PV = "${RELEASE_TAG}" - -S = "${WORKDIR}/git" +SRC_URI += "file://0001-dev-arm-SMMUv3-enable-interrupt-interface.patch" BPN = "gem5-aarch64-native" diff --git a/meta-gem5/recipes-devtools/gem5/gem5-m5ops/0001-util-m5ops-optional-extra-build-flags.patch b/meta-gem5/recipes-devtools/gem5/gem5-m5ops/0001-util-m5ops-optional-extra-build-flags.patch new file mode 100644 index 00000000..b446a2fe --- /dev/null +++ b/meta-gem5/recipes-devtools/gem5/gem5-m5ops/0001-util-m5ops-optional-extra-build-flags.patch @@ -0,0 +1,59 @@ +From 32e35a2f179d1b036d2eb699d77f869f7787f36b Mon Sep 17 00:00:00 2001 +From: Adrian Herrera +Date: Tue, 8 Dec 2020 20:12:55 +0000 +Subject: [PATCH] util: m5ops, optional extra build flags + +This increases compilation control for users. Main use case is building +m5ops as part of an image distribution. Specifying a different sysroot +or dynamic linker may be required when the cross toolchain is built as +part of the process. + +Change-Id: Icbd3faa92ea6e084fc4a9b2db83129bce73faf21 +Signed-off-by: Adrian Herrera +Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/38416 +Reviewed-by: Jason Lowe-Power +Reviewed-by: Gabe Black +Maintainer: Jason Lowe-Power +Tested-by: kokoro + +Upstream-Status: Accepted [https://gem5-review.googlesource.com/c/public/gem5/+/38416] +Expected version: v20.2 +--- + util/m5/SConstruct | 14 +++++++++++--- + 1 file changed, 11 insertions(+), 3 deletions(-) + +diff --git a/util/m5/SConstruct b/util/m5/SConstruct +index bbae8d9bbf..a37573d763 100644 +--- a/util/m5/SConstruct ++++ b/util/m5/SConstruct +@@ -136,16 +136,24 @@ for root, dirs, files in os.walk(abspath(src_dir)): + # + # This also considers scons command line settings which may look like + # environment variables, but are set after "scons" on the command line. +- def get_abi_opt(name, default): ++ def _extract_abi_opt_val(name, default): + var_name = env.subst('${ABI}.%s' % name) +- env[name] = os.environ.get( +- var_name, ARGUMENTS.get(var_name, default)) ++ return os.environ.get(var_name, ARGUMENTS.get(var_name, default)) ++ def get_abi_opt(name, default): ++ env[name] = _extract_abi_opt_val(name, default) ++ def append_abi_opt(name): ++ env.Append(**{ name: _extract_abi_opt_val(name, '') }) + + # Process the ABI's settings in the SConsopts file, storing them + # in a copy of the primary environment. + env.SConscript(Dir(root).File('SConsopts'), + exports=[ 'env', 'get_abi_opt' ]) + ++ # The user can pass extra build flags for each ABI ++ append_abi_opt('CCFLAGS') ++ append_abi_opt('CXXFLAGS') ++ append_abi_opt('LINKFLAGS') ++ + # Once all the options have been configured, set up build targets for + # this abi. + abi_dir = build_dir.Dir(env.subst('${ABI}')) +-- +2.17.1 + diff --git a/meta-gem5/recipes-devtools/gem5/gem5-m5ops_20.bb b/meta-gem5/recipes-devtools/gem5/gem5-m5ops_20.bb new file mode 100644 index 00000000..7b483445 --- /dev/null +++ b/meta-gem5/recipes-devtools/gem5/gem5-m5ops_20.bb @@ -0,0 +1,26 @@ +require gem5-source_20.inc +inherit scons package + +HOMEPAGE = "https://www.gem5.org/documentation/general_docs/m5ops" +SUMMARY = "m5ops provide pseudo-instructions to trigger gem5 functionality" +LICENSE = "BSD" + +M5OPS_DIR = "util/m5" + +SRC_URI += "file://0001-util-m5ops-optional-extra-build-flags.patch" + +OUT_DIR = "build/${TARGET_ARCH}/out" + +EXTRA_OESCONS += "${TARGET_ARCH}.CROSS_COMPILE=${TARGET_PREFIX} \ + ${TARGET_ARCH}.CCFLAGS=--sysroot=${STAGING_DIR_TARGET} \ + ${TARGET_ARCH}.LINKFLAGS=--sysroot=${STAGING_DIR_TARGET} \ + -C ${S}/${M5OPS_DIR} ${OUT_DIR}/m5" + +# The SConstruct file for m5ops does not provide a "install" target +# We do the install process within the recipe +do_install() { + install -d ${D}${bindir} ${D}${libdir} ${D}${includedir} + install -m 755 ${B}/${M5OPS_DIR}/${OUT_DIR}/m5 ${D}${bindir} + install -m 644 ${B}/${M5OPS_DIR}/${OUT_DIR}/libm5.a ${D}${libdir} + install -m 644 ${B}/include/gem5/m5ops.h ${D}${includedir} +} diff --git a/meta-gem5/recipes-devtools/gem5/gem5-m5term-native_20.bb b/meta-gem5/recipes-devtools/gem5/gem5-m5term-native_20.bb new file mode 100644 index 00000000..07faddbb --- /dev/null +++ b/meta-gem5/recipes-devtools/gem5/gem5-m5term-native_20.bb @@ -0,0 +1,24 @@ +require gem5-source_20.inc + +SUMMARY = "m5term allows users to connect to gem5's simulated console" +HOMEPAGE = "https://www.gem5.org/documentation/general_docs/fullsystem/m5term" +LICENSE = "BSD" + +inherit native + +M5TERM_DIR = "util/term" + +SRC_URI += "file://0001-add-makefile-flags.patch" + +do_compile() { + oe_runmake -C ${S}/${M5TERM_DIR} +} + +# The Makefile for m5term does not provide a "install" target +# We do the install process within the recipe +do_install() { + install -d ${D}${bindir} + install -m 755 ${B}/${M5TERM_DIR}/m5term ${D}${bindir} +} + +addtask addto_recipe_sysroot before do_build diff --git a/meta-gem5/recipes-devtools/gem5/gem5-m5term/0001-add-makefile-flags.patch b/meta-gem5/recipes-devtools/gem5/gem5-m5term/0001-add-makefile-flags.patch new file mode 100644 index 00000000..d13ef4ce --- /dev/null +++ b/meta-gem5/recipes-devtools/gem5/gem5-m5term/0001-add-makefile-flags.patch @@ -0,0 +1,34 @@ +From 688f7103e08318edbd48cf830c0ab3a048761bbb Mon Sep 17 00:00:00 2001 +From: Adrian Herrera +Date: Thu, 03 Dec 2020 16:45:59 +0000 +Subject: [PATCH] util: m5term, fix LDFLAGS, standard make variables + +Enables build systems to provide necessary flags to build m5term. +Useful specially if a different linker is intended to be used. + +Change-Id: If7f867cc0965d6ad4627b5421e00a99cc3d64989 +Signed-off-by: Adrian Herrera + +Upstream-Status: Accepted [https://gem5-review.googlesource.com/c/public/gem5/+/38256] +Expected version: v20.2 +--- + +diff --git a/util/term/Makefile b/util/term/Makefile +index 658b961..4aa1c52 100644 +--- a/util/term/Makefile ++++ b/util/term/Makefile +@@ -24,12 +24,12 @@ + # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-CCFLAGS= -g -O0 ++CFLAGS ?= -g -O0 + + default: m5term + + m5term: term.c +- $(CC) $(LFLAGS) -o $@ $^ ++ $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) + + install: m5term + $(SUDO) install -o root -m 555 m5term /usr/local/bin diff --git a/meta-gem5/recipes-devtools/gem5/gem5-native.inc b/meta-gem5/recipes-devtools/gem5/gem5-native.inc index 1df94d04..1462b4e1 100644 --- a/meta-gem5/recipes-devtools/gem5/gem5-native.inc +++ b/meta-gem5/recipes-devtools/gem5/gem5-native.inc @@ -6,11 +6,14 @@ LICENSE = "BSD & MIT & LGPLv2.1" # Gem5 build and run parameter +# See http://www.gem5.org/documentation/general_docs/building for the list of variants +GEM5_BUILD_VARIANT ?= "opt" + # What gem5 binary are we building -GEM5_BUILD_CONFIGS ?= "build/X86/gem5.opt" +GEM5_BUILD_CONFIGS ?= "build/X86/gem5.{GEM5_BUILD_VARIANT}" # Scons build arguments -GEM5_SCONS_ARGS ?= "-j ${BB_NUMBER_THREADS} CC=${BUILD_CC} CXX=${BUILD_CXX} \ +GEM5_SCONS_ARGS ?= "CC=${BUILD_CC} CXX=${BUILD_CXX} \ AS=${BUILD_AS} AR=${BUILD_AR} ${GEM5_BUILD_CONFIGS} \ PYTHON_CONFIG=python3-config" @@ -18,7 +21,7 @@ GEM5_SCONS_ARGS ?= "-j ${BB_NUMBER_THREADS} CC=${BUILD_CC} CXX=${BUILD_CXX} \ GEM5_RUN_PROFILE ?= "configs/example/fs.py" # We are building a native package and we need to use scons -inherit native scons +inherit scons native # the build is using several tools: # python3: scons and six @@ -38,14 +41,7 @@ do_install() { for f in ${GEM5_BUILD_CONFIGS}; do destname=$(basename $f) install -d ${D}${bindir} - install -m 755 $f ${D}${bindir}/$destname.real - cat < ${D}${bindir}/$destname -#!/bin/bash -basedir=\$(cd \$(dirname \$0)/../../; pwd) -export LD_LIBRARY_PATH="\$basedir/lib:\$basedir/usr/lib" -\$basedir/usr/bin/$destname.real "\$@" -EOF - chmod a+x ${D}${bindir}/$destname + install -m 755 $f ${D}${bindir}/$destname done } @@ -53,3 +49,4 @@ FILES_${PN} = "${datadir}/gem5/* ${bindir}/*" INSANE_SKIP_${PN} += "already-stripped" RDEPENDS_${PN} += "python3-native hdf5-native protobuf-native libpng-native" +addtask addto_recipe_sysroot before do_build diff --git a/meta-gem5/recipes-devtools/gem5/gem5-source_20.inc b/meta-gem5/recipes-devtools/gem5/gem5-source_20.inc new file mode 100644 index 00000000..c586308c --- /dev/null +++ b/meta-gem5/recipes-devtools/gem5/gem5-source_20.inc @@ -0,0 +1,13 @@ +# gem5 sources v20.1.0.3 + +LIC_FILES_CHKSUM = "file://COPYING;md5=2d9514d69d8abf88b6e9125e759bf0ab \ + file://LICENSE;md5=a585e2893cee63d16a1d8bc16c6297ec" + +SRC_URI = "git://gem5.googlesource.com/public/gem5;protocol=https;nobranch=1 \ + file://pyinit-threads.patch" +RELEASE_TAG = "v20.1.0.3" +SRCREV = "cd21b5a5519940a0fa9b9a2dde68f30403d17f7e" + +PV = "${RELEASE_TAG}" + +S = "${WORKDIR}/git"