Commit Graph

3481 Commits

Author SHA1 Message Date
Jeenu Viswambharan cdb6ac94ec SDEI: Make dispatches synchronous
SDEI event dispatches currently only sets up the Non-secure context
before returning to the caller. The actual dispatch only happens upon
exiting EL3 next time.

However, for various error handling scenarios, it's beneficial to have
the dispatch happen synchronously. I.e. when receiving SDEI interrupt,
or for a successful sdei_dispatch_event() call, the event handler is
executed; and upon the event completion, dispatcher execution resumes
after the point of dispatch. The jump primitives introduced in the
earlier patch facilitates this feature.

With this patch:

  - SDEI interrupts and calls to sdei_dispatch_event prepares the NS
    context for event dispatch, then sets a jump point, and immediately
    exits EL3. This results in the client handler executing in
    Non-secure.

  - When the SDEI client completes the dispatched event, the SDEI
    dispatcher does a longjmp to the jump pointer created earlier. For
    the caller of the sdei_dispatch_event() in particular, this would
    appear as if call returned successfully.

The dynamic workaround for CVE_2018_3639 is slightly shifted around as
part of related minor refactoring. It doesn't affect the workaround
functionality.

Documentation updated.

NOTE: This breaks the semantics of the explicit dispatch API, and any
exiting usages should be carefully reviewed.

Change-Id: Ib9c876d27ea2af7fb22de49832e55a0da83da3f9
Signed-off-by: Jeenu Viswambharan <jeenu.viswambharan@arm.com>
2018-06-21 16:15:23 +01:00
Jeenu Viswambharan e7b9473e15 BL31: Introduce jump primitives
This patch introduces setjmp() and ongjmp() primitives to enable
standard setjmp/longjmp style execution. Both APIs parameters take a
pointer to struct jmpbuf type, which hosts CPU registers saved/restored
during jump.

As per the standard usage:

  - setjmp() return 0 when a jump is setup; and a non-zero value when
    returning from jump.

  - The caller of setjmp() must not return, or otherwise update stack
    pointer since.

Change-Id: I4af1d32e490cfa547979631b762b4cba188d0551
Signed-off-by: Jeenu Viswambharan <jeenu.viswambharan@arm.com>
2018-06-21 16:15:23 +01:00
Jeenu Viswambharan 2ccfcb2ea5 SDEI: Determine client EL from NS context's SCR_EL3
Currently, the dispatcher reads from SCR_EL3 register directly to
determine the EL of SDEI client. This is with the assumption that
SCR_EL3 is not modified throughout. However, with RAS work flows, it's
possible that SCR_EL3 register contains values corresponding to Secure
world, and therefore EL determination can go wrong. To mitigate this,
always read the register from the saved Non-secure context.

Change-Id: Ic85e4021deb18eb58757f676f9a001174998543a
Signed-off-by: Jeenu Viswambharan <jeenu.viswambharan@arm.com>
2018-06-21 16:15:23 +01:00
Jeenu Viswambharan af2c9ecdf1 SDEI: Allow platforms to define explicit events
The current macros only allow to define dynamic and statically-bound
SDEI events. However, there ought be a mechanism to define SDEI events
that are explicitly dispatched; i.e., events that are dispatched as a
result of a previous secure interrupt or other exception

This patch introduces SDEI_EXPLICIT_EVENT() macro to define an explicit
event. They must be placed under private mappings. Only the priority
flags are allowed to be additionally specified.

Documentation updated.

Change-Id: I2e12f5571381195d6234c9dfbd5904608ad41db3
Signed-off-by: Jeenu Viswambharan <jeenu.viswambharan@arm.com>
2018-06-21 16:15:23 +01:00
Dimitris Papastamos 6d769420b0
Merge pull request #1439 from dp-arm/dp/bl2_size
fvp: Increase BL2 size for TBBR builds
2018-06-21 16:03:05 +01:00
Dimitris Papastamos 7ae588277b fvp: Increase BL2 size for TBBR builds
Change-Id: I67e64bb79cc984ea3263f069e22738a42321c46d
Signed-off-by: Dimitris Papastamos <dimitris.papastamos@arm.com>
2018-06-21 16:02:23 +01:00
Dimitris Papastamos e960518854
Merge pull request #1428 from jeenu-arm/mbedtls
Move to mbedtls-2.10.0 tag
2018-06-21 14:35:54 +01:00
Dimitris Papastamos ec942295d2
Merge pull request #1434 from soby-mathew/sm/fix_cntfrq
ARM Platforms: Update CNTFRQ register in CNTCTLBase frame
2018-06-21 13:42:45 +01:00
Dimitris Papastamos bbf9f129be
Merge pull request #1435 from antonio-nino-diaz-arm/an/xlat-fix
xlat_v2: Fix descriptor debug print
2018-06-21 13:35:48 +01:00
Dimitris Papastamos 01460492fc
Merge pull request #1433 from sivadur/integration
xilinx: fix zynqmp build when tsp is enabled
2018-06-21 12:55:27 +01:00
Antonio Nino Diaz 7febd83e22 xlat_v2: Fix descriptor debug print
The XN, PXN and UXN bits are part of the upper attributes, not the
lower attributes.

Change-Id: Ia5e83f06f2a8de88b551f55f1d36d694918ccbc0
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
2018-06-21 10:53:39 +01:00
Siva Durga Prasad Paladugu 0435ba642d plat: xilinx: zynqmp: Get chipid from registers for BL32
This patch reads the chipid registers directly instead of making
pm call when running at BL32. User should ensure that these registers
should always be accessed from APU in their system configuration.

Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
2018-06-21 10:23:21 +05:30
Siva Durga Prasad Paladugu d37442f769 plat: xilinx: zynqmp: Build for DDR if SPD is enabled
This patch builds ATF to DDR if SPD is enabled as it cant fit in
On chip memory(OCM) with SPD enabled. This solves the issue
of build failure with SPD enabled for ZynqMP platform.

Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
2018-06-21 10:18:48 +05:30
Dimitris Papastamos 3caa841d9c
Merge pull request #1403 from glneo/for-upstream-k3
TI K3 platform support
2018-06-20 16:37:01 +01:00
Dimitris Papastamos bdd33afc10
Merge pull request #1421 from Yann-lms/cpp_dtc
Build: add cpp build processing for dtb
2018-06-20 16:36:00 +01:00
Dimitris Papastamos a125014bdb
Merge pull request #1413 from grandpaul/paulliu-rpi3-0
rpi3: BL32 optee support
2018-06-20 16:34:10 +01:00
Soby Mathew 342d6220e6 ARM Platforms: Update CNTFRQ register in CNTCTLBase frame
Currently TF-A doesn't initialise CNTFRQ register in CNTCTLBase
frame of the system timer. ARM ARM states that "The instance of
the register in the CNTCTLBase frame must be programmed with this
value as part of system initialization."

The psci_arch_setup() updates the CNTFRQ system register but
according to the ARM ARM, this instance of the register is
independent of the memory mapped instance. This is only an issue
for Normal world software which relies on the memory mapped
instance rather than the system register one.

This patch resolves the issue for ARM platforms.

The patch also solves a related issue on Juno, wherein
CNTBaseN.CNTFRQ can be written and does not reflect the value of
the register in CNTCTLBase frame. Hence this patch additionally
updates CNTFRQ register in the Non Secure frame of the CNTBaseN.

Fixes ARM-Software/tf-issues#593

Change-Id: I09cebb6633688b34d5b1bc349fbde4751025b350
Signed-off-by: Soby Mathew <soby.mathew@arm.com>
2018-06-20 13:09:30 +01:00
Dimitris Papastamos 0a665ed5d1
Merge pull request #1423 from chandnich/sgi-575/dyncfg
Sgi 575/dyncfg
2018-06-20 09:50:56 +01:00
Nishanth Menon 8d67515335 ti: k3: Introduce basic generic board support
While it would be useful to have a device tree based build, the
required components are not in place yet, so support just a simple
statically defined configuration to begin with.

Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Andrew F. Davis <afd@ti.com>
2018-06-19 12:42:37 -05:00
Benjamin Fair 2e9c9e8299 ti: k3: common: Add PSCI stubs
These functions are used for the PSCI implementation and are needed to
build BL31, but we cannot implement them until we add several more drivers
related to ti-sci so these are only stubs for now.

Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Benjamin Fair <b-fair@ti.com>
Signed-off-by: Andrew F. Davis <afd@ti.com>
2018-06-19 12:42:37 -05:00
Nishanth Menon 74e8cf48e1 ti: k3: common: Enable GICv3 support
Do proper initialization of GIC V3. This will allow CP15 access to GIC
from "normal world" (aka HLOS) via mrc/mcr calls.

K3 SoC family uses GICv3 compliant GIC500 without compatibility for
legacy GICv2.

Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Benjamin Fair <b-fair@ti.com>
Signed-off-by: Andrew F. Davis <afd@ti.com>
2018-06-19 12:42:37 -05:00
Nishanth Menon e9cb89cfca ti: k3: common: Program A53 arch timer frequency
Provide K3_TIMER_FREQUENCY for the platform configuration if the GTC
clock is selected statically and override option if the platform has a
different configuration.

Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Benjamin Fair <b-fair@ti.com>
2018-06-19 12:42:37 -05:00
Nishanth Menon fff6ffca5b ti: k3: common: Add console initialization base
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Benjamin Fair <b-fair@ti.com>
Signed-off-by: Andrew F. Davis <afd@ti.com>
2018-06-19 12:42:35 -05:00
Nishanth Menon e67bfcf344 ti: k3: common: Enable MMU using xlat_tables_v2 library
This library will be used to properly set up mappings from different
bootloaders at different exception levels. It ensures that memory mapped
devices such as UARTs are still accessible and memory regions have the
correct access permissions.

Signed-off-by: Benjamin Fair <b-fair@ti.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Andrew F. Davis <afd@ti.com>
2018-06-19 11:51:05 -05:00
Benjamin Fair 878bd5cebf ti: k3: common: Implement topology functions
These functions describe the layout of the cores and clusters in order to
support the PSCI framework.

Signed-off-by: Benjamin Fair <b-fair@ti.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Andrew F. Davis <afd@ti.com>
2018-06-19 11:50:32 -05:00
Benjamin Fair a546d25b1e ti: k3: common: Populate BL32 and BL33 entrypoint
Because there is no BL2, BL31 must determine the entrypoint and memory
location of BL32 and BL33 on its own.

BL32_BASE and PRELOADED_BL33_BASE will be set in the corresponding board
makefile. We also allow a DTB address to be specified for cases when BL33
is a Linux image.

NOTE: It is possible to pull in this information from device tree as
well, however libfdt does not contain the required hooks to make this
happen at this point in time.

Signed-off-by: Benjamin Fair <b-fair@ti.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Andrew F. Davis <afd@ti.com>
2018-06-19 11:48:42 -05:00
Benjamin Fair 8957471572 ti: k3: common: Add platform core management helpers
The K3 family of SoCs has multiple interconnects. The key interconnect
for high performance processors is the MSMC3 interconnect. This is
an io-coherent interconnect which exports multiple ports for each
processor cluster.

Sometimes, port 0 of the MSMC may not have an ARM cluster OR is isolated
such that the instance of ATF does not manage it. Define macros
in platform_def.h to help handle this.

Signed-off-by: Benjamin Fair <b-fair@ti.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Andrew F. Davis <afd@ti.com>
2018-06-19 11:45:31 -05:00
Nishanth Menon 1841c533c9 ti: k3: Setup initial files for platform
Create the baseline Makefile, platform definitions file and platform
specific assembly macros file. This includes first set of constants
for the platform including cache sizes and linker format and a stub for
BL31 and the basic memory layout

K3 SoC family of processors do not use require a BL1 or BL2 binary,
since such functions are provided by an system controller on the SoC.
This lowers the burden of ATF to purely managing the local ARM cores
themselves.

Signed-off-by: Benjamin Fair <b-fair@ti.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Andrew F. Davis <afd@ti.com>
2018-06-19 11:41:25 -05:00
Dimitris Papastamos d135ad7884
Merge pull request #1410 from Anson-Huang/master
Add NXP's i.MX8QX and i.MX8QM SoC support
2018-06-19 15:10:23 +01:00
Dimitris Papastamos 73b4214bf5
Merge pull request #1425 from jts-arm/panic
Panic in BL1 when TB_FW_CONFIG is invalid
2018-06-19 15:09:43 +01:00
Dimitris Papastamos b8dc3f146d
Merge pull request #1430 from dp-arm/dp/cpulib
cpulib: Add ISBs or comment why they are unneeded
2018-06-19 15:07:30 +01:00
Dimitris Papastamos 7fb3a70bff
Merge pull request #1418 from antonio-nino-diaz-arm/an/arm-multi-console
plat/arm: Migrate AArch64 port to the multi console driver
2018-06-19 14:00:07 +01:00
Dimitris Papastamos c0b7606f91
Merge pull request #1420 from Yann-lms/mm_cursor_size_check
xlat_v2: add a check on mm_cursor->size to avoid infinite loop
2018-06-19 13:39:55 +01:00
Dimitris Papastamos bd5a76ac7c cpulib: Add ISBs or comment why they are unneeded
Change-Id: I18a41bb9fedda635c3c002a7f112578808410ef6
Signed-off-by: Dimitris Papastamos <dimitris.papastamos@arm.com>
2018-06-19 10:34:51 +01:00
Ying-Chun Liu (PaulLiu) 3d4642343f rpi3: update documentation for OP-TEE support
Describe how to use BL32 build variable to load OP-TEE into FIP.

Signed-off-by: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
2018-06-19 16:40:22 +08:00
Ying-Chun Liu (PaulLiu) 7812abac86 rpi3: add OPTEE support
Support for loading optee images as BL32 secure payload.

Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
2018-06-19 16:40:22 +08:00
Antonio Nino Diaz 88a0523e91 plat/arm: Migrate AArch64 port to the multi console driver
The old API is deprecated and will eventually be removed.

Arm platforms now use the multi console driver for boot and runtime
consoles. However, the crash console uses the direct console API because
it doesn't need any memory access to work. This makes it more robust
during crashes.

The AArch32 port of the Trusted Firmware doesn't support this new API
yet, so it is only enabled in AArch64 builds. Because of this, the
common code must maintain compatibility with both systems. SP_MIN
doesn't have to be updated because it's only used in AArch32 builds.
The TSP is only used in AArch64, so it only needs to support the new
API without keeping support for the old one.

Special care must be taken because of PSCI_SYSTEM_SUSPEND. In Juno, this
causes the UARTs to reset (except for the one used by the TSP). This
means that they must be unregistered when suspending and re-registered
when resuming. This wasn't a problem with the old driver because it just
restarted the UART, and there were no problems associated with
registering and unregistering consoles.

The size reserved for BL2 has been increased.

Change-Id: Icefd117dd1eb9c498921181a21318c2d2435c441
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
2018-06-19 09:29:36 +01:00
Dimitris Papastamos ac0197d9d5
Merge pull request #1400 from Andre-ARM/allwinner/v1
Allwinner platform support
2018-06-19 09:16:07 +01:00
Anson Huang baa7650bf8 Support for NXP's i.MX8QM SoC
NXP's i.MX8QM is an ARMv8 SoC with 2 clusters, 2 Cortex-A72
cores in one cluster and 4 Cortex-A53 in the other cluster,
and also has system controller (Cortex-M4) inside, documentation
can be found in below link:

https://www.nxp.com/products/processors-and-microcontrollers/
applications-processors/i.mx-applications-processors/i.mx-8-processors:IMX8-SERIES

This patch adds support for booting up SMP linux kernel (v4.9).

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
2018-06-19 10:24:32 +08:00
Anson Huang 0bc1830928 Support for NXP's i.MX8QX SoC
NXP's i.MX8QX is an ARMv8 SoC with 4 Cortex-A35 cores and
system controller (Cortex-M4) inside, documentation can
be found in below link:

https://www.nxp.com/products/processors-and-microcontrollers/
applications-processors/i.mx-applications-processors/i.mx-8-processors:IMX8-SERIES

This patch adds support for booting up SMP linux kernel (v4.9).

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
2018-06-19 10:24:32 +08:00
Anson Huang bd08def3c9 Support for NXP's imx SoC common function
This patch adds support for NXP's imx SoC common
function support like topology, gic implementation.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
2018-06-19 10:24:32 +08:00
Anson Huang 27b9d5ead8 Support for NXP's imx SoC debug uart
Add NXP's imx SoC debug uart driver.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
2018-06-19 10:24:32 +08:00
Anson Huang ff2743e544 Support for NXP's i.MX8 SoCs IPC
NXP's i.MX8 SoCs have system controller (M4 core)
which takes control of clock management, power management,
partition management, PAD management etc., other
clusters like Cortex-A35 can send out command via MU
(Message Unit) to system controller for clock/power
management etc..

This patch adds basic IPC(inter-processor communication) support.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
2018-06-19 10:24:28 +08:00
Yann Gautier 01d237cb70 Build: add cpp build processing for dtb
This is an add-on feature that allows processing
device tree with external includes.

"-Iinclude" is also added to INCLUDES.
It allows inclusion of dt-bindings files either in dts files or drivers,
as those files will be in include/dt-bindings/.

"-i fdts" is added to the DTC command line.
As the pre-processed files are in build directory, the DT source directory
has to be explicitely included, to manages /include/ directives.

fixes arm-software/tf-issues#595

Signed-off-by: Lionel Debieve <lionel.debieve@st.com>
Signed-off-by: Yann Gautier <yann.gautier@st.com>
2018-06-18 16:05:16 +02:00
Dimitris Papastamos 841cb4f725
Merge pull request #1426 from antonio-nino-diaz-arm/an/spm-sync
SPM: Refactor entry and exit of the SP
2018-06-18 09:44:26 +01:00
Dimitris Papastamos db1f39b652
Merge pull request #1422 from Yann-lms/genmask
Genmask
2018-06-18 09:43:56 +01:00
Jeenu Viswambharan d25b527c88 Move to mbedtls-2.10.0 tag
To build with the new release, we pick couple of more files from mbedTLS
library.

Change-Id: I77dfe5723284cb26d4e5c717fb0e6f6dd803cb6b
Signed-off-by: Jeenu Viswambharan <jeenu.viswambharan@arm.com>
2018-06-18 09:35:29 +01:00
Antonio Nino Diaz 14fcc6e14e SPM: Refactor entry and exit of the SP
Only use synchronous calls to enter the Secure Partition in order to
simplify the SMC handling code.

Change-Id: Ia501a045585ee0836b9151141ad3bd11d0971be2
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
2018-06-15 16:21:01 +01:00
John Tsichritzis 355e096715 Panic in BL1 when TB_FW_CONFIG is invalid
In Arm platforms, when using dynamic configuration, the necessary
parameters are made available as a DTB. The DTB is loaded by BL1 and,
later on, is parsed by BL1, BL2 or even both, depending on when
information from the DTB is needed.

When the DTB is going to be parsed, it must be validated first, to
ensure that it is properly structured. If an invalid DTB is detected
then:
  - BL1 prints a diagnostic but allows execution to continue,
  - BL2 prints a diagnostic and panics.

Now the behaviour of BL1 is changed so for it also to panic. Thus, the
behaviour of BL1 and BL2 is now similar.

Keep in mind that if BL1 only loads the DTB but it doesn't need to
read/write it, then it doesn't validate it. The validation is done only
when the DTB is actually going to be accessed.

Change-Id: Idcae6092e6dbeab7248dd5e041d6cbb7784fe410
Signed-off-by: John Tsichritzis <john.tsichritzis@arm.com>
2018-06-15 16:01:35 +01:00
Andre Przywara acb8b3cabb allwinner: Add security setup
Some peripherals are TrustZone aware, so they need to be configured to
be accessible from non-secure world, as we don't need any of them being
exclusive to the secure world.
This affects some clocks, DMA channels and the Secure Peripheral
Controller (SPC). The latter controls access to most devices, but is not
active unless booting with the secure boot fuse burnt.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-06-15 11:45:24 +01:00