1. 09 May, 2024 6 commits
    • Will Deacon's avatar
      Merge branch 'for-next/perf' into for-next/core · 42e7ddba
      Will Deacon authored
      * for-next/perf: (41 commits)
        arm64: Add USER_STACKTRACE support
        drivers/perf: hisi: hns3: Actually use devm_add_action_or_reset()
        drivers/perf: hisi: hns3: Fix out-of-bound access when valid event group
        drivers/perf: hisi_pcie: Fix out-of-bound access when valid event group
        perf/arm-spe: Assign parents for event_source device
        perf/arm-smmuv3: Assign parents for event_source device
        perf/arm-dsu: Assign parents for event_source device
        perf/arm-dmc620: Assign parents for event_source device
        perf/arm-ccn: Assign parents for event_source device
        perf/arm-cci: Assign parents for event_source device
        perf/alibaba_uncore: Assign parents for event_source device
        perf/arm_pmu: Assign parents for event_source devices
        perf/imx_ddr: Assign parents for event_source devices
        perf/qcom: Assign parents for event_source devices
        Documentation: qcom-pmu: Use /sys/bus/event_source/devices paths
        perf/riscv: Assign parents for event_source devices
        perf/thunderx2: Assign parents for event_source devices
        Documentation: thunderx2-pmu: Use /sys/bus/event_source/devices paths
        perf/xgene: Assign parents for event_source devices
        Documentation: xgene-pmu: Use /sys/bus/event_source/devices paths
        ...
      42e7ddba
    • Will Deacon's avatar
      Merge branch 'for-next/mm' into for-next/core · a5a5ce57
      Will Deacon authored
      * for-next/mm:
        arm64/mm: Fix pud_user_accessible_page() for PGTABLE_LEVELS <= 2
        arm64/mm: Add uffd write-protect support
        arm64/mm: Move PTE_PRESENT_INVALID to overlay PTE_NG
        arm64/mm: Remove PTE_PROT_NONE bit
        arm64/mm: generalize PMD_PRESENT_INVALID for all levels
        arm64: mm: Don't remap pgtables for allocate vs populate
        arm64: mm: Batch dsb and isb when populating pgtables
        arm64: mm: Don't remap pgtables per-cont(pte|pmd) block
      a5a5ce57
    • Will Deacon's avatar
      Merge branch 'for-next/misc' into for-next/core · 7a7f6045
      Will Deacon authored
      * for-next/misc:
        arm64: simplify arch_static_branch/_jump function
        arm64: Add the arm64.no32bit_el0 command line option
        arm64: defer clearing DAIF.D
        arm64: assembler: update stale comment for disable_step_tsk
        arm64/sysreg: Update PIE permission encodings
        arm64: Add Neoverse-V2 part
        arm64: Remove unnecessary irqflags alternative.h include
      7a7f6045
    • Will Deacon's avatar
      Merge branch 'for-next/kbuild' into for-next/core · d4ea881f
      Will Deacon authored
      * for-next/kbuild:
        arm64: boot: Support Flat Image Tree
        arm64: Add BOOT_TARGETS variable
      d4ea881f
    • Will Deacon's avatar
      Merge branch 'for-next/acpi' into for-next/core · b2b7cc6d
      Will Deacon authored
      * for-next/acpi:
        arm64: acpi: Honour firmware_signature field of FACS, if it exists
        ACPICA: Detect FACS even for hardware reduced platforms
      b2b7cc6d
    • Ryan Roberts's avatar
      arm64/mm: Fix pud_user_accessible_page() for PGTABLE_LEVELS <= 2 · cb67ea12
      Ryan Roberts authored
      The recent change to use pud_valid() as part of the implementation of
      pud_user_accessible_page() fails to build when PGTABLE_LEVELS <= 2
      because pud_valid() is not defined in that case.
      
      Fix this by defining pud_valid() to false for this case. This means that
      pud_user_accessible_page() will correctly always return false for this
      config.
      
      Fixes: f0f5863a ("arm64/mm: Remove PTE_PROT_NONE bit")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Closes: https://lore.kernel.org/oe-kbuild-all/202405082221.43rfWxz5-lkp@intel.com/Signed-off-by: default avatarRyan Roberts <ryan.roberts@arm.com>
      Link: https://lore.kernel.org/r/20240509122844.563320-1-ryan.roberts@arm.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      cb67ea12
  2. 03 May, 2024 7 commits
  3. 28 Apr, 2024 6 commits
    • Hao Chen's avatar
      drivers/perf: hisi: hns3: Actually use devm_add_action_or_reset() · 582c1aee
      Hao Chen authored
      pci_alloc_irq_vectors() allocates an irq vector. When devm_add_action()
      fails, the irq vector is not freed, which leads to a memory leak.
      
      Replace the devm_add_action with devm_add_action_or_reset to ensure
      the irq vector can be destroyed when it fails.
      
      Fixes: 66637ab1 ("drivers/perf: hisi: add driver for HNS3 PMU")
      Signed-off-by: default avatarHao Chen <chenhao418@huawei.com>
      Signed-off-by: default avatarJunhao He <hejunhao3@huawei.com>
      Reviewed-by: default avatarJijie Shao <shaojijie@huawei.com>
      Acked-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Link: https://lore.kernel.org/r/20240425124627.13764-4-hejunhao3@huawei.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      582c1aee
    • Junhao He's avatar
      drivers/perf: hisi: hns3: Fix out-of-bound access when valid event group · 81bdd60a
      Junhao He authored
      The perf tool allows users to create event groups through following
      cmd [1], but the driver does not check whether the array index is out
      of bounds when writing data to the event_group array. If the number of
      events in an event_group is greater than HNS3_PMU_MAX_HW_EVENTS, the
      memory write overflow of event_group array occurs.
      
      Add array index check to fix the possible array out of bounds violation,
      and return directly when write new events are written to array bounds.
      
      There are 9 different events in an event_group.
      [1] perf stat -e '{pmu/event1/, ... ,pmu/event9/}
      
      Fixes: 66637ab1 ("drivers/perf: hisi: add driver for HNS3 PMU")
      Signed-off-by: default avatarJunhao He <hejunhao3@huawei.com>
      Signed-off-by: default avatarHao Chen <chenhao418@huawei.com>
      Acked-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Reviewed-by: default avatarJijie Shao <shaojijie@huawei.com>
      Link: https://lore.kernel.org/r/20240425124627.13764-3-hejunhao3@huawei.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      81bdd60a
    • Junhao He's avatar
      drivers/perf: hisi_pcie: Fix out-of-bound access when valid event group · 77fce826
      Junhao He authored
      The perf tool allows users to create event groups through following
      cmd [1], but the driver does not check whether the array index is out of
      bounds when writing data to the event_group array. If the number of events
      in an event_group is greater than HISI_PCIE_MAX_COUNTERS, the memory write
      overflow of event_group array occurs.
      
      Add array index check to fix the possible array out of bounds violation,
      and return directly when write new events are written to array bounds.
      
      There are 9 different events in an event_group.
      [1] perf stat -e '{pmu/event1/, ... ,pmu/event9/}'
      
      Fixes: 8404b0fb ("drivers/perf: hisi: Add driver for HiSilicon PCIe PMU")
      Signed-off-by: default avatarJunhao He <hejunhao3@huawei.com>
      Reviewed-by: default avatarJijie Shao <shaojijie@huawei.com>
      Acked-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Link: https://lore.kernel.org/r/20240425124627.13764-2-hejunhao3@huawei.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      77fce826
    • Mark Rutland's avatar
      arm64: defer clearing DAIF.D · 080297be
      Mark Rutland authored
      For historical reasons we unmask debug exceptions in __cpu_setup(), but
      it's not necessary to unmask debug exceptions this early in the
      boot/idle entry paths. It would be better to unmask debug exceptions
      later in C code as this simplifies the current code and will make it
      easier to rework exception masking logic to handle non-DAIF bits in
      future (e.g. PSTATE.{ALLINT,PM}).
      
      We started clearing DAIF.D in __cpu_setup() in commit:
      
        2ce39ad1 ("arm64: debug: unmask PSTATE.D earlier")
      
      At the time, we needed to ensure that DAIF.D was clear on the primary
      CPU before scheduling and preemption were possible, and chose to do this
      in __cpu_setup() so that this occurred in the same place for primary and
      secondary CPUs. As we cannot handle debug exceptions this early, we
      placed an ISB between initializing MDSCR_EL1 and clearing DAIF.D so that
      no exceptions should be triggered.
      
      Subsequently we rewrote the return-from-{idle,suspend} paths to use
      __cpu_setup() in commit:
      
        cabe1c81 ("arm64: Change cpu_resume() to enable mmu early then access sleep_sp by va")
      
      ... which allowed for earlier use of the MMU and had the desirable
      property of using the same code to reset the CPU in the cold and warm
      boot paths. This introduced a bug: DAIF.D was clear while
      cpu_do_resume() restored MDSCR_EL1 and other control registers (e.g.
      breakpoint/watchpoint control/value registers), and so we could
      unexpectedly take debug exceptions.
      
      We fixed that in commit:
      
        744c6c37 ("arm64: kernel: Fix unmasked debug exceptions when restoring mdscr_el1")
      
      ... by having cpu_do_resume() use the `disable_dbg` macro to set DAIF.D
      before restoring MDSCR_EL1 and other control registers. This relies on
      DAIF.D being subsequently cleared again in cpu_resume().
      
      Subsequently we reworked DAIF masking in commit:
      
        0fbeb318 ("arm64: explicitly mask all exceptions")
      
      ... where we began enforcing a policy that DAIF.D being set implies all
      other DAIF bits are set, and so e.g. we cannot take an IRQ while DAIF.D
      is set. As part of this the use of `disable_dbg` in cpu_resume() was
      replaced with `disable_daif` for consistency with the rest of the
      kernel.
      
      These days, there's no need to clear DAIF.D early within __cpu_setup():
      
      * setup_arch() clears DAIF.DA before scheduling and preemption are
        possible on the primary CPU, avoiding the problem we we originally
        trying to work around.
      
        Note: DAIF.IF get cleared later when interrupts are enabled for the
        first time.
      
      * secondary_start_kernel() clears all DAIF bits before scheduling and
        preemption are possible on secondary CPUs.
      
        Note: with pseudo-NMI, the PMR is initialized here before any DAIF
        bits are cleared. Similar will be necessary for the architectural NMI.
      
      * cpu_suspend() restores all DAIF bits when returning from idle,
        ensuring that we don't unexpectedly leave DAIF.D clear or set.
      
        Note: with pseudo-NMI, the PMR is initialized here before DAIF is
        cleared. Similar will be necessary for the architectural NMI.
      
      This patch removes the unmasking of debug exceptions from __cpu_setup(),
      relying on the above locations to initialize DAIF. This allows some
      other cleanups:
      
      * It is no longer necessary for cpu_resume() to explicitly mask debug
        (or other) exceptions, as it is always called with all DAIF bits set.
        Thus we drop the use of `disable_daif`.
      
      * The `enable_dbg` macro is no longer used, and so is dropped.
      
      * It is no longer necessary to have an ISB immediately after
        initializing MDSCR_EL1 in __cpu_setup(), and we can revert to relying
        on the context synchronization that occurs when the MMU is enabled
        between __cpu_setup() and code which clears DAIF.D
      
      Comments are added to setup_arch() and secondary_start_kernel() to
      explain the initial unmasking of the DAIF bits.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20240422113523.4070414-3-mark.rutland@arm.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      080297be
    • Mark Rutland's avatar
      arm64: assembler: update stale comment for disable_step_tsk · 3a2d2ca4
      Mark Rutland authored
      A comment in the disable_step_tsk macro refers to synchronising with
      enable_dbg, as historically the entry used enable_dbg to unmask debug
      exceptions after disabling single-stepping.
      
      These days the unmasking happens in entry-common.c via
      local_daif_restore() or local_daif_inherit(), so the comment is stale.
      This logic is likely to chang in future, so it would be best to avoid
      referring to those macros specifically.
      
      Update the comment to take this into account, and describe it in terms
      of clearing DAIF.D so that it doesn't macro where this logic lives nor
      what it is called.
      
      There should be no functional change as a result of this patch.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Reviewed-by: default avatarMark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/20240422113523.4070414-2-mark.rutland@arm.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      3a2d2ca4
    • Shiqi Liu's avatar
      arm64/sysreg: Update PIE permission encodings · 12d712dc
      Shiqi Liu authored
      Fix left shift overflow issue when the parameter idx is greater than or
      equal to 8 in the calculation of perm in PIRx_ELx_PERM macro.
      
      Fix this by modifying the encoding to use a long integer type.
      Signed-off-by: default avatarShiqi Liu <shiqiliu@hust.edu.cn>
      Acked-by: default avatarMarc Zyngier <maz@kernel.org>
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Link: https://lore.kernel.org/r/20240421063328.29710-1-shiqiliu@hust.edu.cnSigned-off-by: default avatarWill Deacon <will@kernel.org>
      12d712dc
  4. 19 Apr, 2024 21 commits