1. 02 Nov, 2018 1 commit
    • Victor Kamensky's avatar
      arm64: makefile fix build of .i file in external module case · 98356eb0
      Victor Kamensky authored
      After 'a66649da arm64: fix vdso-offsets.h dependency' if
      one will try to build .i file in case of external kernel module,
      build fails complaining that prepare0 target is missing. This
      issue came up with SystemTap when it tries to build variety
      of .i files for its own generated kernel modules trying to
      figure given kernel features/capabilities.
      
      The issue is that prepare0 is defined in top level Makefile
      only if KBUILD_EXTMOD is not defined. .i file rule depends
      on prepare and in case KBUILD_EXTMOD defined top level Makefile
      contains empty rule for prepare. But after mentioned commit
      arch/arm64/Makefile would introduce dependency on prepare0
      through its own prepare target.
      
      Fix it to put proper ifdef KBUILD_EXTMOD around code introduced
      by mentioned commit. It matches what top level Makefile does.
      Acked-by: default avatarKevin Brodsky <kevin.brodsky@arm.com>
      Signed-off-by: default avatarVictor Kamensky <kamensky@cisco.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      98356eb0
  2. 19 Oct, 2018 1 commit
  3. 16 Oct, 2018 3 commits
    • Suzuki K Poulose's avatar
      arm64: cpufeature: Trap CTR_EL0 access only where it is necessary · 4afe8e79
      Suzuki K Poulose authored
      When there is a mismatch in the CTR_EL0 field, we trap
      access to CTR from EL0 on all CPUs to expose the safe
      value. However, we could skip trapping on a CPU which
      matches the safe value.
      
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      4afe8e79
    • Suzuki K Poulose's avatar
      arm64: cpufeature: Fix handling of CTR_EL0.IDC field · 1602df02
      Suzuki K Poulose authored
      CTR_EL0.IDC reports the data cache clean requirements for instruction
      to data coherence. However, if the field is 0, we need to check the
      CLIDR_EL1 fields to detect the status of the feature. Currently we
      don't do this and generate a warning with tainting the kernel, when
      there is a mismatch in the field among the CPUs. Also the userspace
      doesn't have a reliable way to check the CLIDR_EL1 register to check
      the status.
      
      This patch fixes the problem by checking the CLIDR_EL1 fields, when
      (CTR_EL0.IDC == 0) and updates the kernel's copy of the CTR_EL0 for
      the CPU with the actual status of the feature. This would allow the
      sanity check infrastructure to do the proper checking of the fields
      and also allow the CTR_EL0 emulation code to supply the real status
      of the feature.
      
      Now, if a CPU has raw CTR_EL0.IDC == 0 and effective IDC == 1 (with
      overall system wide IDC == 1), we need to expose the real value to
      the user. So, we trap CTR_EL0 access on the CPU which reports incorrect
      CTR_EL0.IDC.
      
      Fixes: commit 6ae4b6e0 ("arm64: Add support for new control bits CTR_EL0.DIC and CTR_EL0.IDC")
      Cc: Shanker Donthineni <shankerd@codeaurora.org>
      Cc: Philip Elcan <pelcan@codeaurora.org>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      1602df02
    • Suzuki K Poulose's avatar
      arm64: cpufeature: ctr: Fix cpu capability check for late CPUs · 8ab66cbe
      Suzuki K Poulose authored
      The matches() routine for a capability must honor the "scope"
      passed to it and return the proper results.
      i.e, when passed with SCOPE_LOCAL_CPU, it should check the
      status of the capability on the current CPU. This is used by
      verify_local_cpu_capabilities() on a late secondary CPU to make
      sure that it's compliant with the established system features.
      However, ARM64_HAS_CACHE_{IDC/DIC} always checks the system wide
      registers and this could mean that a late secondary CPU could return
      "true" (since the CPU hasn't updated the system wide registers yet)
      and thus lead the system in an inconsistent state, where
      the system assumes it has IDC/DIC feature, while the new CPU
      doesn't.
      
      Fixes: commit 6ae4b6e0 ("arm64: Add support for new control bits CTR_EL0.DIC and CTR_EL0.IDC")
      Cc: Philip Elcan <pelcan@codeaurora.org>
      Cc: Shanker Donthineni <shankerd@codeaurora.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      8ab66cbe
  4. 10 Oct, 2018 4 commits
  5. 09 Oct, 2018 1 commit
  6. 05 Oct, 2018 3 commits
  7. 03 Oct, 2018 4 commits
  8. 01 Oct, 2018 20 commits
  9. 25 Sep, 2018 3 commits
    • Jun Yao's avatar
      arm64/mm: move runtime pgds to rodata · 8eb7e28d
      Jun Yao authored
      Now that deliberate writes to swapper_pg_dir are made via the fixmap, we
      can defend against errant writes by moving it into the rodata section.
      Since tramp_pg_dir and reserved_ttbr0 must be at a fixed offset from
      swapper_pg_dir, and are not modified at runtime, these are also moved
      into the rodata section. Likewise, idmap_pg_dir is not modified at
      runtime, and is moved into rodata.
      Signed-off-by: default avatarJun Yao <yaojun8558363@gmail.com>
      Reviewed-by: default avatarJames Morse <james.morse@arm.com>
      [Mark: simplify linker script, commit message]
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      8eb7e28d
    • Jun Yao's avatar
      arm64/mm: use fixmap to modify swapper_pg_dir · 2330b7ca
      Jun Yao authored
      Once swapper_pg_dir is in the rodata section, it will not be possible to
      modify it directly, but we will need to modify it in some cases.
      
      To enable this, we can use the fixmap when deliberately modifying
      swapper_pg_dir. As the pgd is only transiently mapped, this provides
      some resilience against illicit modification of the pgd, e.g. for
      Kernel Space Mirror Attack (KSMA).
      Signed-off-by: default avatarJun Yao <yaojun8558363@gmail.com>
      Reviewed-by: default avatarJames Morse <james.morse@arm.com>
      [Mark: simplify ifdeffery, commit message]
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      2330b7ca
    • Jun Yao's avatar
      arm64/mm: Separate boot-time page tables from swapper_pg_dir · 2b5548b6
      Jun Yao authored
      Since the address of swapper_pg_dir is fixed for a given kernel image,
      it is an attractive target for manipulation via an arbitrary write. To
      mitigate this we'd like to make it read-only by moving it into the
      rodata section.
      
      We require that swapper_pg_dir is at a fixed offset from tramp_pg_dir
      and reserved_ttbr0, so these will also need to move into rodata.
      However, swapper_pg_dir is allocated along with some transient page
      tables used for boot which we do not want to move into rodata.
      
      As a step towards this, this patch separates the boot-time page tables
      into a new init_pg_dir, and reduces swapper_pg_dir to the single page it
      needs to be. This allows us to retain the relationship between
      swapper_pg_dir, tramp_pg_dir, and swapper_pg_dir, while cleanly
      separating these from the boot-time page tables.
      
      The init_pg_dir holds all of the pgd/pud/pmd/pte levels needed during
      boot, and all of these levels will be freed when we switch to the
      swapper_pg_dir, which is initialized by the existing code in
      paging_init(). Since we start off on the init_pg_dir, we no longer need
      to allocate a transient page table in paging_init() in order to ensure
      that swapper_pg_dir isn't live while we initialize it.
      
      There should be no functional change as a result of this patch.
      Signed-off-by: default avatarJun Yao <yaojun8558363@gmail.com>
      Reviewed-by: default avatarJames Morse <james.morse@arm.com>
      [Mark: place init_pg_dir after BSS, fold mm changes, commit message]
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      2b5548b6