1. 03 Oct, 2018 1 commit
    • Daniel Boulby's avatar
      xlat: Change check in mmap_add and mmap_add_ctx() · 79621f00
      Daniel Boulby authored
      
      
      Depending on the build flags it is possible that some of the memory
      regions mapped in page table setup could have a size of 0. In this
      case we simply want to do nothing but still wish to map the other
      regions in the array. Therefore we cannot only use size == 0 as
      the termination logic for the loop.
      
      Since an attributes field with value 0 means that the region is
      device memory, read only, secure and executable. Device memory
      can't be executable, so this combination should never be used
      and it is safe to use as a terminator value.
      
      Therefore by changing the termination logic to use attributes
      instead of size we prevent terminating the loop when we don't
      intend to.
      
      Change-Id: I92fc7f689ab08543497be6be4896dace2ed7b66a
      Signed-off-by: default avatarDaniel Boulby <daniel.boulby@arm.com>
      79621f00
  2. 28 Sep, 2018 1 commit
  3. 22 Aug, 2018 2 commits
  4. 10 Aug, 2018 1 commit
    • Antonio Nino Diaz's avatar
      xlat v2: Support the EL2 translation regime · 1a92a0e0
      Antonio Nino Diaz authored
      
      
      The translation library is useful elsewhere. Even though this repository
      doesn't exercise the EL2 support of the library, it is better to have it
      here as well to make it easier to maintain.
      
      enable_mmu_secure() and enable_mmu_direct() have been deprecated. The
      functions are still present, but they are behind ERROR_DEPRECATED and
      they call the new functions enable_mmu_svc_mon() and
      enable_mmu_direct_svc_mon().
      
      Change-Id: I13ad10cd048d9cc2d55e0fff9a5133671b67dcba
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      1a92a0e0
  5. 02 Aug, 2018 1 commit
  6. 30 Jul, 2018 1 commit
  7. 15 Jul, 2018 1 commit
  8. 27 Jun, 2018 2 commits
    • Jeenu Viswambharan's avatar
      DynamIQ: Enable MMU without using stack · 64ee263e
      Jeenu Viswambharan authored
      
      
      Having an active stack while enabling MMU has shown coherency problems.
      This patch builds on top of translation library changes that introduces
      MMU-enabling without using stacks.
      
      Previously, with HW_ASSISTED_COHERENCY, data caches were disabled while
      enabling MMU only because of active stack. Now that we can enable MMU
      without using stack, we can enable both MMU and data caches at the same
      time.
      
      NOTE: Since this feature depends on using translation table library v2,
      disallow using translation table library v1 with HW_ASSISTED_COHERENCY.
      
      Fixes ARM-software/tf-issues#566
      
      Change-Id: Ie55aba0c23ee9c5109eb3454cb8fa45d74f8bbb2
      Signed-off-by: default avatarJeenu Viswambharan <jeenu.viswambharan@arm.com>
      64ee263e
    • Jeenu Viswambharan's avatar
      xlat v1: Provide direct MMU-enabling stubs · 92bec97f
      Jeenu Viswambharan authored
      
      
      An earlier patch split MMU-enabling function for translation library v2.
      Although we don't intend to introduce the exact same functionality for
      xlat v1, this patch introduces stubs for directly enabling MMU to
      maintain API-compatibility.
      
      Change-Id: Id7d56e124c80af71de999fcda10f1734b50bca97
      Signed-off-by: default avatarJeenu Viswambharan <jeenu.viswambharan@arm.com>
      92bec97f
  9. 22 Jun, 2018 1 commit
    • Antonio Nino Diaz's avatar
      xlat: Remove mmap_attr_t enum type · 3a1b7b10
      Antonio Nino Diaz authored
      
      
      The values defined in this type are used in logical operations, which
      goes against MISRA Rule 10.1: "Operands shall not be of an inappropriate
      essential type".
      
      Now, `unsigned int` is used instead. This also allows us to move the
      dynamic mapping bit from 30 to 31. It was an undefined behaviour in the
      past because an enum is signed by default, and bit 31 corresponds to the
      sign bit. It is undefined behaviour to modify the sign bit. Now, bit 31
      is free to use as it was originally meant to be.
      
      mmap_attr_t is now defined as an `unsigned int` for backwards
      compatibility.
      
      Change-Id: I6b31218c14b9c7fdabebe432de7fae6e90a97f34
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      3a1b7b10
  10. 02 May, 2018 1 commit
    • Antonio Nino Diaz's avatar
      xlat: Have all values of PARange for 8.x architectures · d3c4487c
      Antonio Nino Diaz authored
      
      
      In AArch64, the field ID_AA64MMFR0_EL1.PARange has a different set of
      allowed values depending on the architecture version.
      
      Previously, we only compiled the Trusted Firmware with the values that
      were allowed by the architecture. However, given that this field is
      read-only, it is easier to compile the code with all values regardless
      of the target architecture.
      
      Change-Id: I57597ed103dd0189b1fb738a9ec5497391c10dd1
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      d3c4487c
  11. 26 Apr, 2018 1 commit
    • Antonio Nino Diaz's avatar
      xlat: Set AP[1] to 1 when it is RES1 · 01c0a38e
      Antonio Nino Diaz authored
      
      
      According to the ARMv8 ARM issue C.a:
      
          AP[1] is valid only for stage 1 of a translation regime that can
          support two VA ranges. It is RES 1 when stage 1 translations can
          support only one VA range.
      
      This means that, even though this bit is ignored, it should be set to 1
      in the EL3 and EL2 translation regimes.
      
      For translation regimes consisting on EL0 and a higher regime this bit
      selects between control at EL0 or at the higher Exception level. The
      regimes that support two VA ranges are EL1&0 and EL2&0 (the later one
      is only available since ARMv8.1).
      
      This fix has to be applied to both versions of the translation tables
      library.
      
      Change-Id: If19aaf588551bac7aeb6e9a686cf0c2068e7c181
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      01c0a38e
  12. 27 Feb, 2018 1 commit
  13. 17 Nov, 2017 1 commit
  14. 08 Nov, 2017 1 commit
  15. 21 Sep, 2017 1 commit
    • Antonio Nino Diaz's avatar
      Set TCR_EL1.EPD1 bit to 1 · 3388b38d
      Antonio Nino Diaz authored
      
      
      In the S-EL1&0 translation regime we aren't using the higher VA range,
      whose translation table base address is held in TTBR1_EL1. The bit
      TCR_EL1.EPD1 can be used to disable translations using TTBR1_EL1, but
      the code wasn't setting it to 1. Additionally, other fields in TCR1_EL1
      associated with the higher VA range (TBI1, TG1, SH1, ORGN1, IRGN1 and
      A1) weren't set correctly as they were left as 0. In particular, 0 is a
      reserved value for TG1. Also, TBBR1_EL1 was not explicitly set and its
      reset value is UNKNOWN.
      
      Therefore memory accesses to the higher VA range would result in
      unpredictable behaviour as a translation table walk would be attempted
      using an UNKNOWN value in TTBR1_EL1.
      
      On the FVP and Juno platforms accessing the higher VA range resulted in
      a translation fault, but this may not always be the case on all
      platforms.
      
      This patch sets the bit TCR_EL1.EPD1 to 1 so that any kind of
      unpredictable behaviour is prevented.
      
      This bug only affects the AArch64 version of the code, the AArch32
      version sets this bit to 1 as expected.
      
      Change-Id: I481c000deda5bc33a475631301767b9e0474a303
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      3388b38d
  16. 26 Jul, 2017 1 commit
  17. 25 Jul, 2017 1 commit
    • 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
  18. 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
  19. 22 Jun, 2017 1 commit
    • 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
  20. 03 May, 2017 1 commit
  21. 02 May, 2017 2 commits
    • Antonio Nino Diaz's avatar
      Fix execute-never permissions in xlat tables libs · a5640252
      Antonio Nino Diaz authored
      
      
      Translation regimes that only support one virtual address space (such as
      the ones for EL2 and EL3) can flag memory regions as execute-never by
      setting to 1 the XN bit in the Upper Attributes field in the translation
      tables descriptors. Translation regimes that support two different
      virtual address spaces (such as the one shared by EL1 and EL0) use bits
      PXN and UXN instead.
      
      The Trusted Firmware runs at EL3 and EL1, it has to handle translation
      tables of both translation regimes, but the previous code handled both
      regimes the same way, as if both had only 1 VA range.
      
      When trying to set a descriptor as execute-never it would set the XN
      bit correctly in EL3, but it would set the XN bit in EL1 as well. XN is
      at the same bit position as UXN, which means that EL0 was being
      prevented from executing code at this region, not EL1 as the code
      intended. Therefore, the PXN bit was unset to 0 all the time. The result
      is that, in AArch64 mode, read-only data sections of BL2 weren't
      protected from being executed.
      
      This patch adds support of translation regimes with two virtual address
      spaces to both versions of the translation tables library, fixing the
      execute-never permissions for translation tables in EL1.
      
      The library currently does not support initializing translation tables
      for EL0 software, therefore it does not set/unset the UXN bit. If EL1
      software needs to initialize translation tables for EL0 software, it
      should use a different library instead.
      
      Change-Id: If27588f9820ff42988851d90dc92801c8ecbe0c9
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      a5640252
    • Nishanth Menon's avatar
      xlat lib: Don't set mmap_attr_t enum to be -1 · 7055e6fa
      Nishanth Menon authored
      -1 is not a defined mmap_attr_t type. Instead of using invalid enum
      types, we can either choose to define a INVALID type OR handle the
      condition specifically.
      
      Since the usage of mmap_region_attr is limited, it is easier to just
      handle the error condition specifically and return 0 or -1 depending
      on success or fail.
      
      Fixes: ARM-Software/tf-issues#473
      Fixes: 28fa2e9e
      
       ("xlat lib: Use mmap_attr_t type consistently")
      Signed-off-by: default avatarNishanth Menon <nm@ti.com>
      7055e6fa
  22. 29 Apr, 2017 1 commit
    • Scott Branden's avatar
      Move defines in utils.h to utils_def.h to fix shared header compile issues · 53d9c9c8
      Scott Branden authored
      
      
      utils.h is included in various header files for the defines in it.
      Some of the other header files only contain defines.  This allows the
      header files to be shared between host and target builds for shared defines.
      
      Recently types.h has been included in utils.h as well as some function
      prototypes.
      
      Because of the inclusion of types.h conflicts exist building host tools
      abd these header files now.  To solve this problem,
      move the defines to utils_def.h and have this included by utils.h and
      change header files to only include utils_def.h and not pick up the new
      types.h being introduced.
      
      Fixes ARM-software/tf-issues#461
      Signed-off-by: default avatarScott Branden <scott.branden@broadcom.com>
      
      Remove utils_def.h from utils.h
      
      This patch removes utils_def.h from utils.h as it is not required.
      And also makes a minor change to ensure Juno platform compiles.
      
      Change-Id: I10cf1fb51e44a8fa6dcec02980354eb9ecc9fa29
      53d9c9c8
  23. 20 Apr, 2017 2 commits
    • Sandrine Bailleux's avatar
      xlat lib: Use mmap_attr_t type consistently · 28fa2e9e
      Sandrine Bailleux authored
      
      
      This patch modifies both versions of the translation table library
      to use the mmap_attr_t type consistently wherever it is manipulating
      MT_* attributes variables. It used to use mmap_attr_t or plain integer
      types interchangeably, which compiles fine because an enumeration type
      can be silently converted to an integer, but which is semantically
      incorrect.
      
      This patch removes this assumption by using the abstract type
      'mmap_attr_t' all the time.
      
      Change-Id: Id1f099025d2cb962b275bb7e39ad2c4dbb4e366c
      Signed-off-by: default avatarSandrine Bailleux <sandrine.bailleux@arm.com>
      28fa2e9e
    • Antonio Nino Diaz's avatar
      Control inclusion of helper code used for asserts · aa61368e
      Antonio Nino Diaz authored
      
      
      Many asserts depend on code that is conditionally compiled based on the
      DEBUG define. This patch modifies the conditional inclusion of such code
      so that it is based on the ENABLE_ASSERTIONS build option.
      
      Change-Id: I6406674788aa7e1ad7c23d86ce94482ad3c382bd
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      aa61368e
  24. 28 Mar, 2017 1 commit
  25. 08 Mar, 2017 1 commit
    • Antonio Nino Diaz's avatar
      Apply workaround for errata 813419 of Cortex-A57 · ccbec91c
      Antonio Nino Diaz authored
      
      
      TLBI instructions for EL3 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.
      
      This errata has been enabled for Juno.
      
      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.
      
      Change-Id: Ifc1d70b79cb5e0d87e90d88d376a59385667d338
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      ccbec91c
  26. 13 Dec, 2016 3 commits
    • Antonio Nino Diaz's avatar
      Forbid block descriptors in initial xlat table levels · 2240f45b
      Antonio Nino Diaz authored
      
      
      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: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      2240f45b
    • Antonio Nino Diaz's avatar
      Add PLAT_xxx_ADDR_SPACE_SIZE definitions · 0029624f
      Antonio Nino Diaz authored
      
      
      Added the definitions `PLAT_PHY_ADDR_SPACE_SIZE` and
      `PLAT_VIRT_ADDR_SPACE_SIZE` which specify respectively the physical
      and virtual address space size a platform can use.
      
      `ADDR_SPACE_SIZE` is now deprecated. To maintain compatibility, if any
      of the previous defines aren't present, the value of `ADDR_SPACE_SIZE`
      will be used instead.
      
      For AArch64, register ID_AA64MMFR0_EL1 is checked to calculate the
      max PA supported by the hardware and to verify that the previously
      mentioned definition is valid. For AArch32, a 40 bit physical
      address space is considered.
      
      Added asserts to check for overflows.
      
      Porting guide updated.
      
      Change-Id: Ie8ce1da5967993f0c94dbd4eb9841fc03d5ef8d6
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      0029624f
    • Antonio Nino Diaz's avatar
      Assert correct granularity when mapping a PA · d3d6c6e3
      Antonio Nino Diaz authored
      
      
      Each translation table level entry can only map a given virtual
      address onto physical addresses of the same granularity. For example,
      with the current configuration, a level 2 entry maps blocks of 2 MB,
      so the physical address must be aligned to 2 MB. If the address is not
      aligned, the MMU will just ignore the lower bits.
      
      This patch adds an assertion to make sure that physical addresses are
      always aligned to the correct boundary.
      
      Change-Id: I0ab43df71829d45cdbe323301b3053e08ca99c2c
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      d3d6c6e3
  27. 23 Aug, 2016 1 commit
    • Antonio Nino Diaz's avatar
      Automatically select initial xlation lookup level · e8719552
      Antonio Nino Diaz authored
      Instead of hardcoding a level 1 table as the base translation level
      table, let the code decide which level is the most appropriate given
      the virtual address space size.
      
      As the table granularity is 4 KB, this allows the code to select
      level 0, 1 or 2 as base level for AArch64. This way, instead of
      limiting the virtual address space width to 39-31 bits, widths of
      48-25 bit can be used.
      
      For AArch32, this change allows the code to select level 1 or 2
      as the base translation level table and use virtual address space
      width of 32-25 bits.
      
      Also removed some unused definitions related to translation tables.
      
      Fixes ARM-software/tf-issues#362
      
      Change-Id: Ie3bb5d6d1a4730a26700b09827c79f37ca3cdb65
      e8719552
  28. 10 Aug, 2016 1 commit
    • Soby Mathew's avatar
      AArch32: Add translation table library support · b2bca61d
      Soby Mathew authored
      This patch adds translation library supports for AArch32 platforms.
      The library only supports long descriptor formats for AArch32.
      The `enable_mmu_secure()` enables the MMU for secure world with
      `TTBR0` pointing to the populated translation tables.
      
      Change-Id: I061345b1779391d098e35e7fe0c76e3ebf850e08
      b2bca61d
  29. 09 Aug, 2016 1 commit
    • Soby Mathew's avatar
      Fix the translation table library for wraparound cases · 20002655
      Soby Mathew authored
      This patch fixes the translation table library for wraparound cases. These
      cases are not expected to occur on AArch64 platforms because only the
      48 bits of the 64 bit address space are used. But it is a possibility for
      AArch32 platforms.
      
      Change-Id: Ie7735f7ba2977019381e1c124800381471381499
      20002655
  30. 18 Jul, 2016 1 commit
    • Soby Mathew's avatar
      Rework type usage in Trusted Firmware · 4c0d0390
      Soby Mathew authored
      This patch reworks type usage in generic code, drivers and ARM platform files
      to make it more portable. The major changes done with respect to
      type usage are as listed below:
      
      * Use uintptr_t for storing address instead of uint64_t or unsigned long.
      * Review usage of unsigned long as it can no longer be assumed to be 64 bit.
      * Use u_register_t for register values whose width varies depending on
        whether AArch64 or AArch32.
      * Use generic C types where-ever possible.
      
      In addition to the above changes, this patch also modifies format specifiers
      in print invocations so that they are AArch64/AArch32 agnostic. Only files
      related to upcoming feature development have been reworked.
      
      Change-Id: I9f8c78347c5a52ba7027ff389791f1dad63ee5f8
      4c0d0390
  31. 08 Jul, 2016 3 commits
    • Sandrine Bailleux's avatar
      Introduce utils.h header file · ed81f3eb
      Sandrine Bailleux authored
      This patch introduces a new header file: include/lib/utils.h.
      Its purpose is to provide generic macros and helper functions that
      are independent of any BL image, architecture, platform and even
      not specific to Trusted Firmware.
      
      For now, it contains only 2 macros: ARRAY_SIZE() and
      IS_POWER_OF_TWO(). These were previously defined in bl_common.h and
      xlat_tables.c respectively.
      
      bl_common.h includes utils.h to retain compatibility for platforms
      that relied on bl_common.h for the ARRAY_SIZE() macro. Upstream
      platform ports that use this macro have been updated to include
      utils.h.
      
      Change-Id: I960450f54134f25d1710bfbdc4184f12c049a9a9
      ed81f3eb
    • Sandrine Bailleux's avatar
      xlat lib: Introduce MT_EXECUTE/MT_EXECUTE_NEVER attributes · b9161469
      Sandrine Bailleux authored
      This patch introduces the MT_EXECUTE/MT_EXECUTE_NEVER memory mapping
      attributes in the translation table library to specify the
      access permissions for instruction execution of a memory region.
      These new attributes should be used only for normal, read-only
      memory regions. For other types of memory, the translation table
      library still enforces the following rules, regardless of the
      MT_EXECUTE/MT_EXECUTE_NEVER attribute:
      
       - Device memory is always marked as execute-never.
       - Read-write normal memory is always marked as execute-never.
      
      Change-Id: I8bd27800a8c1d8ac1559910caf4a4840cf25b8b0
      b9161469
    • Sandrine Bailleux's avatar
      xlat lib: Refactor mmap_desc() function · bcbe19af
      Sandrine Bailleux authored
      This patch clarifies the mmap_desc() function by adding some comments
      and reorganising its code. No functional change has been introduced.
      
      Change-Id: I873493be17b4e60a89c1dc087dd908b425065401
      bcbe19af
  32. 26 Apr, 2016 1 commit
    • Sandrine Bailleux's avatar
      Fix computation of L1 bitmask in the translation table lib · aa447b9c
      Sandrine Bailleux authored
      This patch fixes the computation of the bitmask used to isolate
      the level 1 field of a virtual address. The whole computation needs
      to work on 64-bit values to produce the correct bitmask value.
      XLAT_TABLE_ENTRIES_MASK being a C constant, it is a 32-bit value
      so it needs to be extended to a 64-bit value before it takes part
      in any other computation.
      
      This patch fixes this bug by casting XLAT_TABLE_ENTRIES_MASK as
      an unsigned long long.
      
      Note that this bug doesn't manifest itself in practice because
      address spaces larger than 39 bits are not yet supported in the
      Trusted Firmware.
      
      Change-Id: I955fd263ecb691ca94b29b9c9f576008ce1d87ee
      aa447b9c