1. 01 Sep, 2017 1 commit
    • Etienne Carriere's avatar
      cpu log buffer size depends on cache line size · 86606eb5
      Etienne Carriere authored
      
      
      Platform may use specific cache line sizes. Since CACHE_WRITEBACK_GRANULE
      defines the platform specific cache line size, it is used to define the
      size of the cpu data structure CPU_DATA_SIZE aligned on cache line size.
      
      Introduce assembly macro 'mov_imm' for AArch32 to simplify implementation
      of function '_cpu_data_by_index'.
      
      Change-Id: Ic2d49ffe0c3e51649425fd9c8c99559c582ac5a1
      Signed-off-by: default avatarEtienne Carriere <etienne.carriere@linaro.org>
      86606eb5
  2. 29 Aug, 2017 1 commit
  3. 24 Aug, 2017 2 commits
    • Isla Mitchell's avatar
      Enable CnP bit for ARMv8.2 CPUs · 9fce2725
      Isla Mitchell authored
      
      
      This patch enables the CnP (Common not Private) bit for secure page
      tables so that multiple PEs in the same Inner Shareable domain can use
      the same translation table entries for a given stage of translation in
      a particular translation regime. This only takes effect when ARM
      Trusted Firmware is built with ARM_ARCH_MINOR >= 2.
      
      ARM Trusted Firmware Design has been updated to include a description
      of this feature usage.
      
      Change-Id: I698305f047400119aa1900d34c65368022e410b8
      Signed-off-by: default avatarIsla Mitchell <isla.mitchell@arm.com>
      9fce2725
    • Jeenu Viswambharan's avatar
      Add macro to test for minimum architecture version · f45e232a
      Jeenu Viswambharan authored
      
      
      The macro concisely expresses and requires architecture version to be at
      least as required by its arguments. This would be useful when extending
      Trusted Firmware functionality for future architecture revisions.
      
      Replace similar usage in the current code base with the new macro.
      
      Change-Id: I9dcd0aa71a663eabd02ed9632b8ce87611fa5a57
      Signed-off-by: default avatarJeenu Viswambharan <jeenu.viswambharan@arm.com>
      f45e232a
  4. 23 Aug, 2017 2 commits
  5. 09 Aug, 2017 1 commit
    • Summer Qin's avatar
      Add Trusted OS extra image parsing support for ARM standard platforms · 54661cd2
      Summer Qin authored
      
      
      Trusted OS may have extra images to be loaded. Load them one by one
      and do the parsing. In this patch, ARM TF need to load up to 3 images
      for optee os: header, pager and paged images. Header image is the info
      about optee os and images. Pager image include pager code and data.
      Paged image include the paging parts using virtual memory.
      
      Change-Id: Ia3bcfa6d8a3ed7850deb5729654daca7b00be394
      Signed-off-by: default avatarSummer Qin <summer.qin@arm.com>
      54661cd2
  6. 01 Aug, 2017 1 commit
  7. 31 Jul, 2017 1 commit
    • Varun Wadekar's avatar
      lib: psci: early suspend handler for platforms · 1862d620
      Varun Wadekar authored
      
      
      This patch adds an early suspend handler, that executes with
      SMP and data cache enabled. This handler allows platforms to
      perform any early actions during the CPU suspend entry sequence.
      
      This handler is optional and platforms can choose to implement it
      depending on their needs. The `pwr_domain_suspend` handler still
      exists and platforms can keep on using it without any side effects.
      Signed-off-by: default avatarVarun Wadekar <vwadekar@nvidia.com>
      1862d620
  8. 26 Jul, 2017 7 commits
    • David Cunado's avatar
      Address edge case for stale PSCI CPU data in cache · 71341d23
      David Cunado authored
      
      
      There is a theoretical edge case during CPU_ON where the cache
      may contain stale data for the target CPU data - this can occur
      under the following conditions:
      
      - the target CPU is in another cluster from the current
      - the target CPU was the last CPU to shutdown on its cluster
      - the cluster was removed from coherency as part of the CPU shutdown
      
      In this case the cache maintenace that was performed as part of the
      target CPUs shutdown was not seen by the current CPU's cluster. And
      so the cache may contain stale data for the target CPU.
      
      This patch adds a cache maintenance operation (flush) for the
      cache-line containing the target CPU data - this ensures that the
      target CPU data is read from main memory.
      
      Change-Id: If8cfd42639b03174f60669429b7f7a757027d0fb
      Signed-off-by: default avatarDavid Cunado <david.cunado@arm.com>
      71341d23
    • Sandrine Bailleux's avatar
      xlat lib: Fix some types · 0044231d
      Sandrine Bailleux authored
      Fix the type length and signedness of some of the constants and
      variables used in the translation table library.
      
      This patch supersedes Pull Request #1018:
      https://github.com/ARM-software/arm-trusted-firmware/pull/1018
      
      
      
      Change-Id: Ibd45faf7a4fb428a0bf71c752551d35800212fb2
      Signed-off-by: default avatarSandrine Bailleux <sandrine.bailleux@arm.com>
      0044231d
    • Sandrine Bailleux's avatar
      Import ctzdi2.c from LLVM compiler-rt · 7bba6884
      Sandrine Bailleux authored
      
      
      When using __builtin_ctzll() in AArch32 code, the compiler may translate
      that into a call to the __ctzdi2() function. In this case, the linking
      phase fails because TF doesn't provide an implementation for it.
      
      This patch imports the implementation of the __ctzdi2() function from
      LLVM's compiler-rt project and hooks it into TF's build system. The
      ctzdi2.c file is an unmodified copy from the master branch as of
      July 19 2017 (SVN revision: 308480).
      
      Change-Id: I96766a025ba28e1afc6ef6a5c4ef91d85fc8f32b
      Signed-off-by: default avatarSandrine Bailleux <sandrine.bailleux@arm.com>
      7bba6884
    • Sandrine Bailleux's avatar
      xlat lib v2: Remove hard-coded virtual address space size · 347621bb
      Sandrine Bailleux authored
      
      
      Previous patches have made it possible to specify the physical and
      virtual address spaces sizes for each translation context. However,
      there are still some places in the code where the physical (resp.
      virtual) address space size is assumed to be PLAT_PHY_ADDR_SPACE_SIZE
      (resp. PLAT_VIRT_ADDR_SPACE_SIZE).
      
      This patch removes them and reads the relevant address space size
      from the translation context itself instead. This information is now
      passed in argument to the enable_mmu_arch() function, which needs it
      to configure the TCR_ELx.T0SZ field (in AArch64) or the TTBCR.T0SZ
      field (in AArch32) appropriately.
      
      Change-Id: I20b0e68b03a143e998695d42911d9954328a06aa
      Signed-off-by: default avatarSandrine Bailleux <sandrine.bailleux@arm.com>
      347621bb
    • Sandrine Bailleux's avatar
      xlat lib v2: Refactor the functions enabling the MMU · d83f3579
      Sandrine Bailleux authored
      
      
      This patch refactors both the AArch32 and AArch64 versions of the
      function enable_mmu_arch().
      
      In both versions, the code now computes the VMSA-related system
      registers upfront then program them in one go (rather than interleaving
      the 2).
      
      In the AArch64 version, this allows to reduce the amount of code
      generated by the C preprocessor and limits it to the actual differences
      between EL1 and EL3.
      
      In the AArch32 version, this patch also removes the function
      enable_mmu_internal_secure() and moves its code directly inside
      enable_mmu_arch(), as it was its only caller.
      
      Change-Id: I35c09b6db4404916cbb2e2fd3fda2ad59f935954
      Signed-off-by: default avatarSandrine Bailleux <sandrine.bailleux@arm.com>
      d83f3579
    • Sandrine Bailleux's avatar
      xlat lib v2: Remove init_xlat_tables_arch() function · 99f60798
      Sandrine Bailleux authored
      
      
      In both the AArch32 and AArch64 versions, this function used to check
      the sanity of the PLAT_PHY_ADDR_SPACE_SIZE in regard to the
      architectural maximum value. Instead, export the
      xlat_arch_get_max_supported_pa() function and move the debug
      assertion in AArch-agnostic code.
      
      The AArch64 used to also precalculate the TCR.PS field value, based
      on the size of the physical address space. This is now done directly
      by enable_mmu_arch(), which now receives the physical address space size
      in argument.
      
      Change-Id: Ie77ea92eb06db586f28784fdb479c6e27dd1acc1
      Signed-off-by: default avatarSandrine Bailleux <sandrine.bailleux@arm.com>
      99f60798
    • Sandrine Bailleux's avatar
      xlat lib v2: Expose *_ctx() APIs · a9ad848c
      Sandrine Bailleux authored
      
      
      In a previous patch, the xlat_ctx_t type has been made public.
      This patch now makes the *_ctx() APIs public.
      
      Each API now has a *_ctx() variant. Most of them were already implemented
      and this patch just makes them public. However, some of them were missing
      so this patch introduces them.
      
      Now that all these APIs are public, there's no good reason for splitting
      them accross 2 files (xlat_tables_internal.c and xlat_tables_common.c).
      Therefore, this patch moves all code into xlat_tables_internal.c and
      removes xlat_tables_common.c. It removes it from the library's makefile
      as well.
      
      This last change introduces a compatibility break for platform ports
      that specifically include the xlat_tables_common.c file instead of
      including the library's Makefile. The UniPhier platform makefile has
      been updated to now omit this file from the list of source files.
      
      The prototype of mmap_add_region_ctx() has been slightly changed. The
      mmap_region_t passed in argument needs to be constant because it gets
      called from map_add(), which receives a constant region. The former
      implementation of mmap_add() used to cast the const qualifier away,
      which is not a good practice.
      
      Also remove init_xlation_table(), which was a sub-function of
      init_xlat_tables(). Now there's just init_xlat_tables() (and
      init_xlat_tables_ctx()). Both names were too similar, which was
      confusing. Besides, now that all the code is in a single file,
      it's no longer needed to have 2 functions for that.
      
      Change-Id: I4ed88c68e44561c3902fbebb89cb197279c5293b
      Signed-off-by: default avatarSandrine Bailleux <sandrine.bailleux@arm.com>
      a9ad848c
  9. 25 Jul, 2017 3 commits
    • Sandrine Bailleux's avatar
      xlat lib v2: Export translation context as an opaque type · 55c84964
      Sandrine Bailleux authored
      
      
      At the moment, the translation context type (xlat_ctx_t) is a private
      type reserved for the internal usage of the translation table library.
      All exported APIs (implemented in xlat_tables_common.c) are wrappers
      over the internal implementations that use such a translation context.
      
      These wrappers unconditionally pass the current translation context
      representing the memory mappings of the executing BL image. This means
      that the caller has no control over which translation context the
      library functions act on.
      
      As a first step to make this code more flexible, this patch exports
      the 'xlat_ctx_t' type. Note that, although the declaration of this type
      is now public, its definition stays private. A macro is introduced to
      statically allocate and initialize such a translation context.
      
      The library now internally uses this macro to allocate the default
      translation context for the running BL image.
      
      Change-Id: Icece1cde4813fac19452c782b682c758142b1489
      Signed-off-by: default avatarSandrine Bailleux <sandrine.bailleux@arm.com>
      55c84964
    • Sandrine Bailleux's avatar
      xlat lib: Reorganize architectural defs · 8933c34b
      Sandrine Bailleux authored
      
      
      Move the header files that provide translation tables architectural
      definitions from the library v2 source files to the library include
      directory. This allows to share these definitions between both
      versions (v1 and v2) of the library.
      
      Create a new header file that includes the AArch32 or AArch64
      definitions based on the AARCH32 build flag, so that the library user
      doesn't have to worry about handling it on their side.
      
      Also repurpose some of the definitions the header files provide to
      concentrate on the things that differ between AArch32 and AArch64.
      As a result they now contain the following information:
       - the first table level that allows block descriptors;
       - the architectural limits of the virtual address space;
       - the initial lookup level to cover the entire address space.
      
      Additionally, move the XLAT_TABLE_LEVEL_MIN macro from
      xlat_tables_defs.h to the AArch32/AArch64 architectural definitions.
      
      This new organisation eliminates duplicated information in the AArch32
      and AArch64 versions. It also decouples these architectural files from
      any platform-specific information. Previously, they were dependent on
      the address space size, which is platform-specific.
      
      Finally, for the v2 of the library, move the compatibility code for
      ADDR_SPACE_SIZE into a C file as it is not needed outside of this
      file. For v1, this code hasn't been changed and stays in a header
      file because it's needed by several files.
      
      Change-Id: If746c684acd80eebf918abd3ab6e8481d004ac68
      Signed-off-by: default avatarSandrine Bailleux <sandrine.bailleux@arm.com>
      8933c34b
    • Sandrine Bailleux's avatar
      xlat lib v2: Print some debug statistics · 0350bc6d
      Sandrine Bailleux authored
      
      
      This patch adds some debug prints to display some statistics about page
      tables usage. They are printed only if the LOG_LEVEL is at least 50
      (i.e. VERBOSE).
      
      Sample output for BL1:
      
      VERBOSE:    Translation tables state:
      VERBOSE:      Max allowed PA:  0xffffffff
      VERBOSE:      Max allowed VA:  0xffffffff
      VERBOSE:      Max mapped PA:   0x7fffffff
      VERBOSE:      Max mapped VA:   0x7fffffff
      VERBOSE:      Initial lookup level: 1
      VERBOSE:      Entries @initial lookup level: 4
      VERBOSE:      Used 4 sub-tables out of 5 (spare: 1)
      
      Change-Id: If38956902e9616cdcd6065ecd140fe21482597ea
      Signed-off-by: default avatarSandrine Bailleux <sandrine.bailleux@arm.com>
      0350bc6d
  10. 19 Jul, 2017 1 commit
  11. 12 Jul, 2017 1 commit
    • Isla Mitchell's avatar
      Fix order of #includes · 2a4b4b71
      Isla Mitchell authored
      
      
      This fix modifies the order of system includes to meet the ARM TF coding
      standard. There are some exceptions in order to retain header groupings,
      minimise changes to imported headers, and where there are headers within
      the #if and #ifndef statements.
      
      Change-Id: I65085a142ba6a83792b26efb47df1329153f1624
      Signed-off-by: default avatarIsla Mitchell <isla.mitchell@arm.com>
      2a4b4b71
  12. 28 Jun, 2017 1 commit
    • Douglas Raillard's avatar
      Introduce TF_LDFLAGS · c2b8806f
      Douglas Raillard authored
      
      
      Use TF_LDFLAGS from the Makefiles, and still append LDFLAGS as well to
      the compiler's invocation. This allows passing extra options from the
      make command line using LDFLAGS.
      
      Document new LDFLAGS Makefile option.
      
      Change-Id: I88c5ac26ca12ac2b2d60a6f150ae027639991f27
      Signed-off-by: default avatarDouglas Raillard <douglas.raillard@arm.com>
      c2b8806f
  13. 27 Jun, 2017 1 commit
    • David Cunado's avatar
      Resolve signed-unsigned comparison issues · 0dd41951
      David Cunado authored
      A recent commit 030567e6
      
       added U()/ULL()
      macro to TF constants. This has caused some signed-unsigned comparison
      warnings / errors in the TF static analysis.
      
      This patch addresses these issues by migrating impacted variables from
      signed ints to unsigned ints and vice verse where applicable.
      
      Change-Id: I4b4c739a3fa64aaf13b69ad1702c66ec79247e53
      Signed-off-by: default avatarDavid Cunado <david.cunado@arm.com>
      0dd41951
  14. 23 Jun, 2017 1 commit
  15. 22 Jun, 2017 4 commits
    • Etienne Carriere's avatar
      psci: minor fixes in lib · c283e05a
      Etienne Carriere authored
      
      
      Call svc_suspend_finish if registered.
      psci_get_stat() is static to psci_stat.c
      Fix types used in comparison.
      Fix coding style (empty line between variable definition and instructions
      block).
      Signed-off-by: default avatarEtienne Carriere <etienne.carriere@st.com>
      c283e05a
    • Douglas Raillard's avatar
      Apply workarounds for A53 Cat A Errata 835769 and 843419 · a94cc374
      Douglas Raillard authored
      These errata are only applicable to AArch64 state. See the errata notice
      for more details:
      http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.epm048406/index.html
      
      
      
      Introduce the build options ERRATA_A53_835769 and ERRATA_A53_843419.
      Enable both of them for Juno.
      
      Apply the 835769 workaround as following:
      * Compile with -mfix-cortex-a53-835769
      * Link with --fix-cortex-a53-835769
      
      Apply the 843419 workaround as following:
      * Link with --fix-cortex-a53-843419
      
      The erratum 843419 workaround can lead the linker to create new sections
      suffixed with "*.stub*" and 4KB aligned. The erratum 835769 can lead the
      linker to create new "*.stub" sections with no particular alignment.
      
      Also add support for LDFLAGS_aarch32 and LDFLAGS_aarch64 in Makefile for
      architecture-specific linker options.
      
      Change-Id: Iab3337e338b7a0a16b0d102404d9db98c154f8f8
      Signed-off-by: default avatarDouglas Raillard <douglas.raillard@arm.com>
      a94cc374
    • Dimitris Papastamos's avatar
      aarch32: Apply workaround for errata 813419 of Cortex-A57 · 6f512a3d
      Dimitris Papastamos authored
      
      
      TLBI instructions for monitor mode won't have the desired effect under
      specific circumstances in Cortex-A57 r0p0. The workaround is to
      execute DSB and TLBI twice each time.
      
      Even though this errata is only needed in r0p0, the current errata
      framework is not prepared to apply run-time workarounds. The current one
      is always applied if compiled in, regardless of the CPU or its revision.
      
      The `DSB` instruction used when initializing the translation tables has
      been changed to `DSB ISH` as an optimization and to be consistent with
      the barriers used for the workaround.
      
      NOTE: This workaround is present in AArch64 TF and already enabled by
      default on Juno.
      
      Change-Id: I10b0baa304ed64b13b7b26ea766e61461e759dfa
      Signed-off-by: default avatarDimitris Papastamos <dimitris.papastamos@arm.com>
      6f512a3d
    • dp-arm's avatar
      aarch64: Enable Statistical Profiling Extensions for lower ELs · d832aee9
      dp-arm authored
      
      
      SPE is only supported in non-secure state.  Accesses to SPE specific
      registers from SEL1 will trap to EL3.  During a world switch, before
      `TTBR` is modified the SPE profiling buffers are drained.  This is to
      avoid a potential invalid memory access in SEL1.
      
      SPE is architecturally specified only for AArch64.
      
      Change-Id: I04a96427d9f9d586c331913d815fdc726855f6b0
      Signed-off-by: default avatardp-arm <dimitris.papastamos@arm.com>
      d832aee9
  16. 21 Jun, 2017 2 commits
    • David Cunado's avatar
      Fully initialise essential control registers · 18f2efd6
      David Cunado authored
      
      
      This patch updates the el3_arch_init_common macro so that it fully
      initialises essential control registers rather then relying on hardware
      to set the reset values.
      
      The context management functions are also updated to fully initialise
      the appropriate control registers when initialising the non-secure and
      secure context structures and when preparing to leave EL3 for a lower
      EL.
      
      This gives better alignement with the ARM ARM which states that software
      must initialise RES0 and RES1 fields with 0 / 1.
      
      This patch also corrects the following typos:
      
      "NASCR definitions" -> "NSACR definitions"
      
      Change-Id: Ia8940b8351dc27bc09e2138b011e249655041cfc
      Signed-off-by: default avatarDavid Cunado <david.cunado@arm.com>
      18f2efd6
    • Soby Mathew's avatar
      Exit early if size zero for cache helpers · 3ec5204c
      Soby Mathew authored
      
      
      This patch enables cache helper functions `flush_dcache_range`,
      `clean_dcache_range` and `invalidate_dcache_range` to exit early
      if the size argument specified is zero
      
      Change-Id: I0b63e8f4bd3d47ec08bf2a0b0b9a7ff8a269a9b0
      Signed-off-by: default avatarSoby Mathew <soby.mathew@arm.com>
      3ec5204c
  17. 20 Jun, 2017 4 commits
  18. 14 Jun, 2017 2 commits
  19. 01 Jun, 2017 1 commit
  20. 24 May, 2017 2 commits
  21. 18 May, 2017 1 commit