1. 07 11月, 2021 4 次提交
  2. 04 9月, 2021 1 次提交
  3. 03 8月, 2021 2 次提交
    • M
      arm64: kasan: mte: remove redundant mte_report_once logic · 76721503
      Mark Rutland 提交于
      We have special logic to suppress MTE tag check fault reporting, based
      on a global `mte_report_once` and `reported` variables. These can be
      used to suppress calling kasan_report() when taking a tag check fault,
      but do not prevent taking the fault in the first place, nor does they
      affect the way we disable tag checks upon taking a fault.
      
      The core KASAN code already defaults to reporting a single fault, and
      has a `multi_shot` control to permit reporting multiple faults. The only
      place we transiently alter `mte_report_once` is in lib/test_kasan.c,
      where we also the `multi_shot` state as the same time. Thus
      `mte_report_once` and `reported` are redundant, and can be removed.
      
      When a tag check fault is taken, tag checking will be disabled by
      `do_tag_recovery` and must be explicitly re-enabled if desired. The test
      code does this by calling kasan_enable_tagging_sync().
      
      This patch removes the redundant mte_report_once() logic and associated
      variables.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Andrey Konovalov <andreyknvl@gmail.com>
      Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
      Reviewed-by: NCatalin Marinas <catalin.marinas@arm.com>
      Reviewed-by: NAndrey Konovalov <andreyknvl@gmail.com>
      Tested-by: NAndrey Konovalov <andreyknvl@gmail.com>
      Link: https://lore.kernel.org/r/20210714143843.56537-4-mark.rutland@arm.comSigned-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      76721503
    • M
      arm64: kasan: mte: use a constant kernel GCR_EL1 value · 82868247
      Mark Rutland 提交于
      When KASAN_HW_TAGS is selected, KASAN is enabled at boot time, and the
      hardware supports MTE, we'll initialize `kernel_gcr_excl` with a value
      dependent on KASAN_TAG_MAX. While the resulting value is a constant
      which depends on KASAN_TAG_MAX, we have to perform some runtime work to
      generate the value, and have to read the value from memory during the
      exception entry path. It would be better if we could generate this as a
      constant at compile-time, and use it as such directly.
      
      Early in boot within __cpu_setup(), we initialize GCR_EL1 to a safe
      value, and later override this with the value required by KASAN. If
      CONFIG_KASAN_HW_TAGS is not selected, or if KASAN is disabeld at boot
      time, the kernel will not use IRG instructions, and so the initial value
      of GCR_EL1 is does not matter to the kernel. Thus, we can instead have
      __cpu_setup() initialize GCR_EL1 to a value consistent with
      KASAN_TAG_MAX, and avoid the need to re-initialize it during hotplug and
      resume form suspend.
      
      This patch makes arem64 use a compile-time constant KERNEL_GCR_EL1
      value, which is compatible with KASAN_HW_TAGS when this is selected.
      This removes the need to re-initialize GCR_EL1 dynamically, and acts as
      an optimization to the entry assembly, which no longer needs to load
      this value from memory. The redundant initialization hooks are removed.
      
      In order to do this, KASAN_TAG_MAX needs to be visible outside of the
      core KASAN code. To do this, I've moved the KASAN_TAG_* values into
      <linux/kasan-tags.h>.
      
      There should be no functional change as a result of this patch.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Andrey Konovalov <andreyknvl@gmail.com>
      Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Peter Collingbourne <pcc@google.com>
      Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Reviewed-by: NCatalin Marinas <catalin.marinas@arm.com>
      Reviewed-by: NAndrey Konovalov <andreyknvl@gmail.com>
      Tested-by: NAndrey Konovalov <andreyknvl@gmail.com>
      Link: https://lore.kernel.org/r/20210714143843.56537-3-mark.rutland@arm.comSigned-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      82868247
  4. 16 7月, 2021 1 次提交
  5. 30 6月, 2021 7 次提交
  6. 05 6月, 2021 4 次提交
  7. 27 5月, 2021 1 次提交
    • P
      kasan: arm64: support specialized outlined tag mismatch checks · 1cbdf60b
      Peter Collingbourne 提交于
      By using outlined checks we can achieve a significant code size
      improvement by moving the tag-based ASAN checks into separate
      functions. Unlike the existing CONFIG_KASAN_OUTLINE mode these
      functions have a custom calling convention that preserves most
      registers and is specialized to the register containing the address
      and the type of access, and as a result we can eliminate the code
      size and performance overhead of a standard calling convention such
      as AAPCS for these functions.
      
      This change depends on a separate series of changes to Clang [1] to
      support outlined checks in the kernel, although the change works fine
      without them (we just don't get outlined checks). This is because the
      flag -mllvm -hwasan-inline-all-checks=0 has no effect until the Clang
      changes land. The flag was introduced in the Clang 9.0 timeframe as
      part of the support for outlined checks in userspace and because our
      minimum Clang version is 10.0 we can pass it unconditionally.
      
      Outlined checks require a new runtime function with a custom calling
      convention. Add this function to arch/arm64/lib.
      
      I measured the code size of defconfig + tag-based KASAN, as well
      as boot time (i.e. time to init launch) on a DragonBoard 845c with
      an Android arm64 GKI kernel. The results are below:
      
                                     code size    boot time
      CONFIG_KASAN_INLINE=y before    92824064      6.18s
      CONFIG_KASAN_INLINE=y after     38822400      6.65s
      CONFIG_KASAN_OUTLINE=y          39215616     11.48s
      
      We can see straight away that specialized outlined checks beat the
      existing CONFIG_KASAN_OUTLINE=y on both code size and boot time
      for tag-based ASAN.
      
      As for the comparison between CONFIG_KASAN_INLINE=y before and after
      we saw similar performance numbers in userspace [2] and decided
      that since the performance overhead is minimal compared to the
      overhead of tag-based ASAN itself as well as compared to the code
      size improvements we would just replace the inlined checks with the
      specialized outlined checks without the option to select between them,
      and that is what I have implemented in this patch.
      Signed-off-by: NPeter Collingbourne <pcc@google.com>
      Acked-by: NAndrey Konovalov <andreyknvl@gmail.com>
      Reviewed-by: NMark Rutland <mark.rutland@arm.com>
      Tested-by: NMark Rutland <mark.rutland@arm.com>
      Link: https://linux-review.googlesource.com/id/I1a30036c70ab3c3ee78d75ed9b87ef7cdc3fdb76
      Link: [1] https://reviews.llvm.org/D90426
      Link: [2] https://reviews.llvm.org/D56954
      Link: https://lore.kernel.org/r/20210526174927.2477847-3-pcc@google.comSigned-off-by: NWill Deacon <will@kernel.org>
      1cbdf60b
  8. 07 5月, 2021 1 次提交
  9. 01 5月, 2021 8 次提交
  10. 17 4月, 2021 1 次提交
  11. 11 4月, 2021 3 次提交
  12. 27 2月, 2021 7 次提交