1. 13 Sep, 2021 2 commits
    • Vincenzo Frascino's avatar
      kasan: Extend KASAN mode kernel parameter · 9eab331f
      Vincenzo Frascino authored
      
      
      Architectures supported by KASAN_HW_TAGS can provide an asymmetric mode
      of execution. On an MTE enabled arm64 hw for example this can be
      identified with the asymmetric tagging mode of execution. In particular,
      when such a mode is present, the CPU triggers a fault on a tag mismatch
      during a load operation and asynchronously updates a register when a tag
      mismatch is detected during a store operation.
      
      Extend the KASAN HW execution mode kernel command line parameter to
      support asymmetric mode.
      
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Andrey Konovalov <andreyknvl@gmail.com>
      Signed-off-by: Vincenzo Frascino's avatarVincenzo Frascino <vincenzo.frascino@arm.com>
      9eab331f
    • Vincenzo Frascino's avatar
      kasan: Remove duplicate of kasan_flag_async · c8a85bc9
      Vincenzo Frascino authored
      
      
      After merging async mode for KASAN_HW_TAGS a duplicate of the
      kasan_flag_async flag was left erroneously inside the code.
      
      Remove the duplicate.
      
      Note: This change does not bring functional changes to the code
      base.
      
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Evgenii Stepanov <eugenis@google.com>
      Cc: Andrey Konovalov <andreyknvl@gmail.com>
      Signed-off-by: Vincenzo Frascino's avatarVincenzo Frascino <vincenzo.frascino@arm.com>
      c8a85bc9
  2. 03 Sep, 2021 1 commit
  3. 02 Aug, 2021 2 commits
    • Mark Rutland's avatar
      arm64: kasan: mte: remove redundant mte_report_once logic · 76721503
      Mark Rutland authored and Catalin Marinas's avatar Catalin Marinas committed
      
      
      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: Mark Rutland's avatarMark 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: Catalin Marinas's avatarCatalin Marinas <catalin.marinas@arm.com>
      Reviewed-by: default avatarAndrey Konovalov <andreyknvl@gmail.com>
      Tested-by: default avatarAndrey Konovalov <andreyknvl@gmail.com>
      Link: https://lore.kernel.org/r/20210714143843.56537-4-mark.rutland@arm.com
      
      
      Signed-off-by: Catalin Marinas's avatarCatalin Marinas <catalin.marinas@arm.com>
      76721503
    • Mark Rutland's avatar
      arm64: kasan: mte: use a constant kernel GCR_EL1 value · 82868247
      Mark Rutland authored and Catalin Marinas's avatar Catalin Marinas committed
      
      
      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: Mark Rutland's avatarMark 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: Catalin Marinas's avatarCatalin Marinas <catalin.marinas@arm.com>
      Reviewed-by: default avatarAndrey Konovalov <andreyknvl@gmail.com>
      Tested-by: default avatarAndrey Konovalov <andreyknvl@gmail.com>
      Link: https://lore.kernel.org/r/20210714143843.56537-3-mark.rutland@arm.com
      
      
      Signed-off-by: Catalin Marinas's avatarCatalin Marinas <catalin.marinas@arm.com>
      82868247
  4. 15 Jul, 2021 1 commit
  5. 29 Jun, 2021 3 commits
  6. 07 May, 2021 1 commit
  7. 30 Apr, 2021 4 commits
  8. 16 Apr, 2021 1 commit
  9. 11 Apr, 2021 3 commits
  10. 26 Feb, 2021 3 commits
  11. 24 Feb, 2021 4 commits
  12. 05 Feb, 2021 1 commit
  13. 22 Dec, 2020 14 commits