Commit Graph

1646 Commits

Author SHA1 Message Date
Antonio Nino Diaz 55cdcf75df checkpatch: Fix regular expressions
When generating the list of files to check by checkpatch.pl, the list
generated by `git ls-files` is filtered by a regular expression with
grep. Due to a malformed regex, the dot of `.md` was considered a
wildcard instead of a dot. This patch fixes this so that it matches
only dots, thus allowing the two following files to be checked:

* tools/cert_create/include/cmd_opt.h
* tools/cert_create/src/cmd_opt.c

Also extended the list of library directories to check by checkpatch
to exclude any folder starting with libfdt.

Change-Id: Ie7bf18efe4df29e364e5d67ba1118515304ed9a4
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
2017-01-16 17:21:39 +00:00
danh-arm 9eb4d4dd93 Merge pull request #796 from masahir0y/build
Improve dependency file generation
2017-01-11 14:54:29 +00:00
danh-arm 236c27d21f Merge pull request #805 from Xilinx/zynqmp/addr_space_size
zynqmp: Migrate to new address space macros
2017-01-10 11:12:08 +00:00
danh-arm 3140d960c6 Merge pull request #803 from masahir0y/tbb
TBB: fix comment about MBEDTLS_KEY_ALG default
2017-01-10 11:11:54 +00:00
danh-arm 85dfa594ad Merge pull request #802 from pgeorgi/rk3399m0
rockchip: Build m0 firmware without standard libraries
2017-01-10 11:11:44 +00:00
Soren Brinkmann 7b2a268e53 zynqmp: Migrate to new address space macros
Commit 0029624fe2 ("Add
PLAT_xxx_ADDR_SPACE_SIZE definition") deprecates 'ADDR_SPACE_SIZE' in
favor of PLAT_(PHY|VIRT)_ADDRESS_SPACE_SIZE. Migrate the zynqmp platform
to use the new interface.

Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
2017-01-06 11:07:00 -08:00
Masahiro Yamada a56f87c8b9 TBB: fix comment about MBEDTLS_KEY_ALG default
This comment block says the default algorithm is ESDSA, while the
code obviously sets the default to RSA:

  ifeq (${MBEDTLS_KEY_ALG},)
      MBEDTLS_KEY_ALG            :=      rsa
  endif

The git log of commit 7d37aa1711 ("TBB: add mbedTLS authentication
related libraries") states available options are:

  * 'rsa' (for RSA-2048) (default option)
  * 'ecdsa' (for ECDSA-SECP256R1)

So, my best guess is the comment block is wrong.

The mismatch between the code and the comment is confusing. Fix it.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-01-06 16:58:34 +09:00
Masahiro Yamada 1d274ab00f Build: add -MP option to add dummy rules to *.d files
This adds a phony target for each dependency other than the main
file, causing each to depend on nothing.

Without this, the incremental build will fail when a header file
is removed.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-01-05 11:39:19 +09:00
Masahiro Yamada 710ea1d01a Build: generate .d file at the same time as object is created
Currently, .d files are generated before any objects are built.
So, IS_ANYTHING_TO_BUILD flag is needed to avoid such processing for
non-build targets.

There is a cleverer way; just create a .d file simultaneously when
the corresponding object is created.  No need to have separate rules
for .d files.

This commit will also fix a bug; -D$(IMAGE) is defined for $(OBJ),
but not for $(PREREQUISITES).  So, .d files are generated with
different macro sets from those for .o files, then wrong .d files
are generated.

For example, in lib/cpus/aarch64/cpu_helpers.S

  #if IMAGE_BL31
  #include <cpu_data.h>
  #endif

<cpu_data.h> is parsed for the object when built for BL31, but the
.d file does not pick up that dependency.

With this commit, the compiler will generate .o and .d at the same
time, guaranteeing they are generated under the same circumstances.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-01-05 11:39:16 +09:00
Masahiro Yamada 59de50963c Build: use CPP just for pre-processing
Using AS for pre-processing looks a bit weird, and some assembly
specific options are given for nothing.  Rather, use CPP.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-01-05 11:35:59 +09:00
Masahiro Yamada f2e1d57e43 Build: exclude -c flag from TF_CFLAGS
The -c flag should not be included in the global variable TF_CFLAGS;
it should be specified in the build rule only when its target is a
*.o file.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-01-05 11:25:13 +09:00
Patrick Georgi 742df4f614 rockchip: Build m0 firmware without standard libraries
Depending on the compiler used, it might try to link in libc even though
it's not required. Stop it from doing that.

Signed-off-by: Patrick Georgi <pgeorgi@google.com>
2017-01-04 19:06:14 +01:00
davidcunado-arm cef7b3ce8b Merge pull request #798 from douglas-raillard-arm/dr/fix_std_smc_after_suspend
Abort preempted TSP STD SMC after PSCI CPU suspend
2016-12-23 11:20:16 +00:00
Douglas Raillard 3df6012a3e Abort preempted TSP STD SMC after PSCI CPU suspend
Standard SMC requests that are handled in the secure-world by the Secure
Payload can be preempted by interrupts that must be handled in the
normal world. When the TSP is preempted the secure context is stored and
control is passed to the normal world to handle the non-secure
interrupt. Once completed the preempted secure context is restored. When
restoring the preempted context, the dispatcher assumes that the TSP
preempted context is still stored as the SECURE context by the context
management library.

However, PSCI power management operations causes synchronous entry into
TSP. This overwrites the preempted SECURE context in the context
management library. When restoring back the SECURE context, the Secure
Payload crashes because this context is not the preempted context
anymore.

This patch avoids corruption of the preempted SECURE context by aborting
any preempted SMC during PSCI power management calls. The
abort_std_smc_entry hook of the TSP is called when aborting the SMC
request.

It also exposes this feature as a FAST SMC callable from normal world to
abort preempted SMC with FID TSP_FID_ABORT.

Change-Id: I7a70347e9293f47d87b5de20484b4ffefb56b770
Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
2016-12-23 10:46:32 +00:00
danh-arm 153e5eb8f1 Merge pull request #794 from douglas-raillard-arm/dr/fix_TSP_STD_FID_macro
Fix TSP_STD_FID macro
2016-12-21 09:58:56 +00:00
Douglas Raillard 5388a58498 Fix TSP_STD_FID macro
Enforce valid FID input in TSP_STD_FID and TSP_FAST_FID macros.
Also remove an undefined behavior by using unsigned literals.

Change-Id: Id37e908da861980a4eaa3a70b37a729f416ce272
Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
2016-12-20 17:09:24 +00:00
danh-arm e60f189751 Merge pull request #792 from masahir0y/zynqmp
zynqmp: add "override" directive to mandatory options
2016-12-20 17:00:59 +00:00
danh-arm bd83b41a30 Merge pull request #791 from jeenu-arm/asm-assert-32
AArch32: Print ASM_ASSERT and panic messages
2016-12-20 17:00:32 +00:00
Masahiro Yamada 34071d6aec zynqmp: add "override" directive to mandatory options
The platform.mk sets build options required for ZynqMP, but users
can still change them from the command line, like:

  make PLAT=zynqmp RESET_TO_BL31=0 CROSS_COMPILE=...

Then, the makefile shows an error message in that case:
  Using BL31 as the reset vector is only one option supported on ZynqMP.
  Please set RESET_TO_BL31 to 1.

If the option is not user-configurable, the makefile can specify
"override" to prevent users from changing it.  We do not need the
error message for the case that never happens.

Likewise, ENABLE_PLAT_COMPAT := 0 and PROGRAMMABLE_RESET_ADDRESS := 1
are mandatory to avoid build error.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
2016-12-21 00:55:29 +09:00
danh-arm 67748e4827 Merge pull request #788 from jeenu-arm/cpuops-framework
Add provision to extend CPU operations at more levels
2016-12-20 12:27:58 +00:00
danh-arm 9acdafbccf Merge pull request #793 from jeenu-arm/gic-changes
GIC driver changes for extended power management
2016-12-20 12:26:23 +00:00
Dan Handley 9e75fddc3a Merge pull request #783 from danh-arm/sb/bl1-fwu-copy 2016-12-20 11:45:15 +00:00
Sandrine Bailleux 34ba298e09 Improve FWU documentation
- Clarify the documentation of the 'FWU_SMC_IMAGE_COPY' SMC in the
   Firmware Update guide. Also extend the list of pre-conditions to
   include the additional input validation implemented by previous
   patches.

 - Improve documentation of bl1_plat_mem_check() in the porting
   guide. It now specifies that the generic FWU code protects
   bl1_plat_mem_check() from integer overflows resulting from
   the addition of the base address and size passed in arguments.

Change-Id: I07b47a3778df7b9c089529b2dd2135707640a91c
Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
2016-12-20 11:43:10 +00:00
Sandrine Bailleux 949a52d24e Fix integer overflows in BL1 FWU code
Before adding a base address and a size to compute the end
address of an image to copy or authenticate, check this
won't result in an integer overflow. If it does then consider
the input arguments are invalid.

As a result, bl1_plat_mem_check() can now safely assume the
end address (computed as the sum of the base address and size
of the memory region) doesn't overflow, as the validation is
done upfront in bl1_fwu_image_copy/auth(). A debug assertion
has been added nonetheless in the ARM implementation in order
to help catching such problems, should bl1_plat_mem_check()
be called in a different context in the future.

Fixes TFV-1: Malformed Firmware Update SMC can result in copy
of unexpectedly large data into secure memory

Change-Id: I8b8f8dd4c8777705722c7bd0e8b57addcba07e25
Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
Signed-off-by: Dan Handley <dan.handley@arm.com>
2016-12-20 11:43:10 +00:00
Sandrine Bailleux 1bfb706851 Add some debug assertions in BL1 FWU copy code
These debug assertions sanity check the state of the internal
FWU state machine data when resuming an incomplete image copy
operation.

Change-Id: I38a125b0073658c3e2b4b1bdc623ec221741f43e
Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
2016-12-20 11:43:10 +00:00
Sandrine Bailleux b38a9e5cd7 bl1_fwu_image_copy() refactoring
This patch refactors the code of the function handling a FWU_AUTH_COPY
SMC in BL1. All input validation has been moved upfront so it is now
shared between the RESET and COPYING states.

Change-Id: I6a86576b9ce3243c401c2474fe06f06687a70e2f
Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
Signed-off-by: Dan Handley <dan.handley@arm.com>
2016-12-20 11:43:10 +00:00
Sandrine Bailleux 9f1489e445 Minor refactoring of BL1 FWU code
This patch introduces no functional change, it just changes
the serial console output.

 - Improve accuracy of error messages by decoupling some
   error cases;

 - Improve comments;

 - Move declaration of 'mem_layout' local variable closer to
   where it is used and make it const;

 - Rename a local variable to clarify whether it is a source
   or a destination address (base_addr -> dest_addr).

Change-Id: I349fcf053e233f316310892211d49e35ef2c39d9
Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
Signed-off-by: Dan Handley <dan.handley@arm.com>
2016-12-20 11:43:10 +00:00
Sandrine Bailleux 99c5ebafbe Export is_mem_free() function
The is_mem_free() function used to be local to bl_common.c.
This patch exports it so that it can be used outside of bl_common.c.

Change-Id: I01dcb4229f3a36f56a4724b567c5e6c416dc5e98
Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
2016-12-20 11:43:10 +00:00
Dan Handley 19d2595d41 Merge pull request #785 from dp-arm/dp/nvcounter 2016-12-20 11:36:54 +00:00
danh-arm 28076fad49 Merge pull request #781 from yatharth-arm/yk/aarch64_tbbr_load_img_v2
Enable TRUSTED_BOARD_BOOT support for LOAD_IMAGE_V2=1
2016-12-19 15:39:55 +00:00
danh-arm 5d93484ab5 Merge pull request #779 from dp-arm/dp/rtinstr-cache
Add two timestamps to measure PSCI cache flush overhead
2016-12-19 15:39:33 +00:00
danh-arm 78b4c5b078 Merge pull request #778 from antonio-nino-diaz-arm/an/xlat-fixes
Fixes and improvements to translation tables library
2016-12-19 15:39:01 +00:00
Jeenu Viswambharan e12cb61f0e AArch32: Print ASM_ASSERT and panic messages
ASM_ASSERT failure and panic messages are suppressed at present. This
patch enables printing the PC location for panic messages, and file name
and line number upon assembly assert failure.

Change-Id: I80cb715988e7ce766f64da1e1d7065a74a096a0c
Signed-off-by: Jeenu Viswambharan <jeenu.viswambharan@arm.com>
2016-12-19 11:57:12 +00:00
danh-arm 176129530e Merge pull request #786 from davidcunado-arm/dc/update_foundation_model
Update Foundation Model version
2016-12-15 17:49:49 +00:00
danh-arm decc625853 Merge pull request #782 from antonio-nino-diaz-arm/an/fix-copyright
Fix incorrect copyright notices
2016-12-15 17:49:21 +00:00
David Cunado 8434f76ff4 Update Foundation Model version
Foundation Model release 10.2 has been made available and Trusted
Firmware has been tested against that it as part of its CI system.

This patch updates the user guide documentation to reflect the version
of Foundation Model that Trusted Firmware has been tested against.

Change-Id: I8571e1027b24892b41d04b93b24245a371ca2cae
Signed-off-by: David Cunado <david.cunado@arm.com>
2016-12-15 15:53:50 +00:00
Jeenu Viswambharan 5dd9dbb5bf Add provision to extend CPU operations at more levels
Various CPU drivers in ARM Trusted Firmware register functions to handle
power-down operations. At present, separate functions are registered to
power down individual cores and clusters.

This scheme operates on the basis of core and cluster, and doesn't cater
for extending the hierarchy for power-down operations. For example,
future CPUs might support multiple threads which might need powering
down individually.

This patch therefore reworks the CPU operations framework to allow for
registering power down handlers on specific level basis. Henceforth:

  - Generic code invokes CPU power down operations by the level
    required.

  - CPU drivers explicitly mention CPU_NO_RESET_FUNC when the CPU has no
    reset function.

  - CPU drivers register power down handlers as a list: a mandatory
    handler for level 0, and optional handlers for higher levels.

All existing CPU drivers are adapted to the new CPU operations framework
without needing any functional changes within.

Also update firmware design guide.

Change-Id: I1826842d37a9e60a9e85fdcee7b4b8f6bc1ad043
Signed-off-by: Jeenu Viswambharan <jeenu.viswambharan@arm.com>
2016-12-15 15:41:40 +00:00
dp-arm d35dee23b6 tbbr: Fix updating of Non-Trusted NV counter
The previous code required that a certificate be signed with the ROT
key before the platform's NV counter could be updated with the value
in the certificate.  This implies that the Non-Trusted NV counter was
not being updated for Non-Trusted content certificates, as they cannot
be signed with the ROT key in the TBBR CoT scheme.

The code is reworked to only allow updating the platform's Trusted NV
counter when a certificate protected by the Trusted NV counter is
signed with the ROT key.

Content certificates protected by the Non-Trusted NV counter are
allowed to update the platform's Non-Trusted NV counter, assuming
that the certificate value is higher than the platform's value.

A new optional platform API has been introduced, named
plat_set_nv_ctr2().  Platforms may choose to implement it and perform
additional checks based on the authentication image descriptor before
modifying the NV counters.  A default weak implementation is available
that just calls into plat_set_nv_ctr().

Fixes ARM-software/tf-issues#426

Change-Id: I4fc978fd28a3007bc0cef972ff1f69ad0413b79c
Signed-off-by: dp-arm <dimitris.papastamos@arm.com>
2016-12-15 14:12:35 +00:00
Jeenu Viswambharan 74a9578c20 FVP: Avail GIC Redistributor power management
Earlier patches introduced GIC Redistributor power management for ARM
platforms. This patch modifies FVP power management to power down
Redistributor during CPU power on/off.

Change-Id: I2adb9c50a7dd750019fe3b4e576b5d5fc364bffb
Signed-off-by: Jeenu Viswambharan <jeenu.viswambharan@arm.com>
2016-12-15 14:08:26 +00:00
Jeenu Viswambharan d17b953ab3 Introduce ARM platform APIs for GICv3 Redistributor
As with other ARM platform GIC APIs, these directly invoke the GICv3
driver APIs for Redistributor power management.

For the sake of uniform GIC API, empty stubs are placed for those GIC
drivers that lack Redistributor component.

Change-Id: Iad0d760d4dbca790998f7768cda621ff3b15a864
Signed-off-by: Jeenu Viswambharan <jeenu.viswambharan@arm.com>
2016-12-15 14:08:26 +00:00
Jeenu Viswambharan d780699b5e GICv3: Introduce power management APIs for Redistributor
Some GICv3 implementations have provision for power management
operations at Redistributor level. This patch introduces and provides
place-holders for Redistributor power management. The default
implementations are empty stubs, but are weakly bound so as to enable
implementation-specific drivers to override them.

Change-Id: I4fec1358693d3603ca5dce242a2f7f0e730516d8
Signed-off-by: Jeenu Viswambharan <jeenu.viswambharan@arm.com>
2016-12-15 14:08:26 +00:00
danh-arm a4af0c2e84 Merge pull request #780 from douglas-raillard-arm/dr/fix_asm_signed_comparison
Fix integer comparison in memcpy16
2016-12-14 15:59:18 +00:00
Yatharth Kochar 53d703a555 Enable TRUSTED_BOARD_BOOT support for LOAD_IMAGE_V2=1
This patch enables TRUSTED_BOARD_BOOT (Authentication and FWU)
support, for AArch64, when LOAD_IMAGE_V2 is enabled.

This patch also enables LOAD_IMAGE_V2 for ARM platforms.

Change-Id: I294a2eebce7a30b6784c80c9d4ac7752808ee3ad
Signed-off-by: Yatharth Kochar <yatharth.kochar@arm.com>
2016-12-14 14:37:53 +00:00
Antonio Nino Diaz ede939f26d Fix incorrect copyright notices
Some files have incorrect copyright notices, this patch fixes all
files with deviations from the standard notice.

Change-Id: I66b73e78a50a235acb55f1e2ec2052a42c0570d2
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
2016-12-14 14:31:32 +00:00
Douglas Raillard ea926532c3 Fix integer comparison in memcpy16
Unsigned conditions should be used instead of signed ones when comparing
addresses or sizes in assembly.

Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
Change-Id: Id3bd9ccaf58c37037761af35ac600907c4bb0580
2016-12-14 10:44:20 +00:00
dp-arm 7941816a34 Add two timestamps to measure PSCI cache flush overhead
Testing showed that the time spent in a cluster power down
operation is dominated by cache flushes.  Add two more timestamps
in runtime instrumentation to keep track of the time spent
flushing the L1/L2 caches.

Change-Id: I4c5a04e7663543225a85d3c6b271d7b706deffc4
Signed-off-by: dp-arm <dimitris.papastamos@arm.com>
2016-12-14 09:53:14 +00:00
danh-arm 86450fe690 Merge pull request #777 from jeenu-arm/format-fix
Docs: Fix monospace formatting in user guide
2016-12-14 09:25:53 +00:00
danh-arm a6b25333e9 Merge pull request #776 from dp-arm/dp/memcmp-fix
stdlib: Fix signedness issue in memcmp()
2016-12-14 09:25:39 +00:00
danh-arm 9509f4f67a Merge pull request #775 from soby-mathew/sm/AArch32_stack_align
AArch32: Fix the stack alignment issue
2016-12-14 09:25:15 +00:00
Antonio Nino Diaz 2240f45b1a Forbid block descriptors in initial xlat table levels
In AArch64, depending on the granularity of the translation tables,
level 0 and/or level 1 of the translation tables may not support block
descriptors, only table descriptors.

This patch introduces a check to make sure that, even if theoretically
it could be possible to create a block descriptor to map a big memory
region, a new subtable will be created to describe its mapping.

Change-Id: Ieb9c302206bfa33fbaf0cdc6a5a82516d32ae2a7
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
2016-12-13 15:38:19 +00:00