1. 03 Jul, 2018 1 commit
    • Antonio Nino Diaz's avatar
      xlat v2: Split code into separate files · fd2299e6
      Antonio Nino Diaz authored
      
      
      Instead of having one big file with all the code, it's better to have
      a few smaller files that are more manageable:
      
      - xlat_tables_core.c: Code related to the core functionality of the
        library (map and unmap regions, initialize xlat context).
      - xlat_tables_context.c: Instantiation of the active image context
        as well as APIs to manipulate it.
      - xlat_tables_utils.c: Helper code that isn't part of the core
        functionality (change attributes, debug print messages).
      
      Change-Id: I3ea956fc1afd7473c0bb5e7c6aab3b2e5d88c711
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      fd2299e6
  2. 27 Jun, 2018 1 commit
    • Jeenu Viswambharan's avatar
      xlat v2: Split MMU setup and enable · 0cc7aa89
      Jeenu Viswambharan authored
      
      
      At present, the function provided by the translation library to enable
      MMU constructs appropriate values for translation library, and programs
      them to the right registers. The construction of initial values,
      however, is only required once as both the primary and secondaries
      program the same values.
      
      Additionally, the MMU-enabling function is written in C, which means
      there's an active stack at the time of enabling MMU. On some systems,
      like Arm DynamIQ, having active stack while enabling MMU during warm
      boot might lead to coherency problems.
      
      This patch addresses both the above problems by:
      
        - Splitting the MMU-enabling function into two: one that sets up
          values to be programmed into the registers, and another one that
          takes the pre-computed values and writes to the appropriate
          registers. With this, the primary effectively calls both functions
          to have the MMU enabled, but secondaries only need to call the
          latter.
      
        - Rewriting the function that enables MMU in assembly so that it
          doesn't use stack.
      
      This patch fixes a bunch of MISRA issues on the way.
      
      Change-Id: I0faca97263a970ffe765f0e731a1417e43fbfc45
      Signed-off-by: default avatarJeenu Viswambharan <jeenu.viswambharan@arm.com>
      0cc7aa89
  3. 13 Jun, 2018 1 commit
    • Antonio Nino Diaz's avatar
      xlat v2: Introduce xlat granule size helpers · a0b9bb79
      Antonio Nino Diaz authored
      
      
      The function xlat_arch_is_granule_size_supported() can be used to check
      if a specific granule size is supported. In Armv8, AArch32 only supports
      4 KiB pages. AArch64 supports 4 KiB, 16 KiB or 64 KiB depending on the
      implementation, which is detected at runtime.
      
      The function xlat_arch_get_max_supported_granule_size() returns the max
      granule size supported by the implementation.
      
      Even though right now they are only used by SPM, they may be useful in
      other places in the future. This patch moves the code currently in SPM
      to the xlat tables lib so that it can be reused.
      
      Change-Id: If54624a5ecf20b9b9b7f38861b56383a03bbc8a4
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      a0b9bb79
  4. 27 Feb, 2018 1 commit
  5. 08 Nov, 2017 1 commit
  6. 17 Oct, 2017 1 commit
  7. 05 Oct, 2017 2 commits
  8. 24 Aug, 2017 1 commit
    • 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
  9. 26 Jul, 2017 4 commits
    • 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
      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
  10. 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
  11. 03 May, 2017 1 commit
  12. 02 May, 2017 1 commit
    • 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
  13. 20 Apr, 2017 1 commit
  14. 28 Mar, 2017 1 commit
  15. 08 Mar, 2017 2 commits
    • Antonio Nino Diaz's avatar
      Add dynamic region support to xlat tables lib v2 · 0b64f4ef
      Antonio Nino Diaz authored
      
      
      Added APIs to add and remove regions to the translation tables
      dynamically while the MMU is enabled. Only static regions are allowed
      to overlap other static ones (for backwards compatibility).
      
      A new private attribute (MT_DYNAMIC / MT_STATIC) has been added to
      flag each region as such.
      
      The dynamic mapping functionality can be enabled or disabled when
      compiling by setting the build option PLAT_XLAT_TABLES_DYNAMIC to 1
      or 0. This can be done per-image.
      
      TLB maintenance code during dynamic table mapping and unmapping has
      also been added.
      
      Fixes ARM-software/tf-issues#310
      
      Change-Id: I19e8992005c4292297a382824394490c5387aa3b
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      0b64f4ef
    • Antonio Nino Diaz's avatar
      Add version 2 of xlat tables library · 7bb01fb2
      Antonio Nino Diaz authored
      
      
      The folder lib/xlat_tables_v2 has been created to store a new version
      of the translation tables library for further modifications in patches
      to follow. At the moment it only contains a basic implementation that
      supports static regions.
      
      This library allows different translation tables to be modified by
      using different 'contexts'. For now, the implementation defaults to
      the translation tables used by the current image, but it is possible
      to modify other tables than the ones in use.
      
      Added a new API to print debug information for the current state of
      the translation tables, rather than printing the information while
      the tables are being created. This allows subsequent debug printing
      of the xlat tables after they have been changed, which will be useful
      when dynamic regions are implemented in a patch to follow.
      
      The common definitions stored in `xlat_tables.h` header have been moved
      to a new file common to both versions, `xlat_tables_defs.h`.
      
      All headers related to the translation tables library have been moved to
      a the subfolder `xlat_tables`.
      
      Change-Id: Ia55962c33e0b781831d43a548e505206dffc5ea9
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      7bb01fb2
  16. 13 Dec, 2016 1 commit
    • 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
  17. 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
  18. 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