14 Dec, 2020

8 commits

  • Add driver support for i.MX8DXL DB Perf, which supports AXI ID PORT
    CHANNEL filter.

    Reviewed-by: Fugang Duan
    Signed-off-by: Joakim Zhang

    Joakim Zhang
     
  • Add clock support for Perf in DB SS, since Perf LPCG has the clocks off
    by default.

    Reviewed-by: Fugang Duan
    Signed-off-by: Joakim Zhang

    Joakim Zhang
     
  • There is a PMU in DB(DRAM Block) which has the same function with PMU in DDR
    subsystem, the difference is PMU in DB only supports cycles, axid-read,
    axid-write events.
    The role of the DB is to route the read/write transaction from connected
    subsystems to either the DDR subsystem, or to any other subsystems. The AXI
    IDs used is the one seen at the PORT.

    e.g.
    perf stat -a -e imx8_db0/axid-read,axi_mask=0xMMMM,axi_id=0xDDDD,axi_port=0xPP,axi_channel=0xH/ cmd
    perf stat -a -e imx8_db0/axid-write,axi_mask=0xMMMM,axi_id=0xDDDD,axi_port=0xPP,axi_channel=0xH/ cmd

    Reviewed-by: Fugang Duan
    Signed-off-by: Joakim Zhang

    Joakim Zhang
     
  • Add driver support for i.MX8DXL DDR Perf, which supports AXI ID PORT
    CHANNEL filter.

    Reviewed-by: Fugang Duan
    Signed-off-by: Joakim Zhang

    Joakim Zhang
     
  • This is the extension of AXI ID filter.

    Filter is defined with 2 configuration registers per counter 1-3 (counter 0 is
    not used for filtering and lacks these registers).
    * Counter N MASK COMP register - AXI_ID and AXI_MASKING.
    * Counter N MUX CNTL register - AXI CHANNEL and AXI PORT.
    -- 0: address channel
    -- 1: data channel

    This filter is exposed to userspace as an additional (channel, port) pair. The
    definition of axi_channel is inverted in userspace, and it will be reverted in
    driver automatically.

    AXI filter of Perf Monitor in DDR Subsystem, only a single port0 exist, so
    axi_port is reserved which should be 0.

    e.g.
    perf stat -a -e imx8_ddr0/axid-read,axi_mask=0xMMMM,axi_id=0xDDDD,axi_channel=0xH/ cmd
    perf stat -a -e imx8_ddr0/axid-write,axi_mask=0xMMMM,axi_id=0xDDDD,axi_channel=0xH/ cmd

    Reviewed-by: Fugang Duan
    Signed-off-by: Joakim Zhang

    Joakim Zhang
     
  • Should give prev_count initial value for cycles event, since we initialize
    CP filed to shorten counter0 overflow time.

    Signed-off-by: Joakim Zhang

    Joakim Zhang
     
  • For i.MX8MP, we cannot ensure that cycle counter overflow occurs at
    least 4 times as often as other events. Due to byte counters will count for
    any event configured, it will overflow more often. And if byte counters
    oveflow that related counters would stop since they share the
    COUNTER_CNTL. We can speed up cycle counter overflow frequency by
    setting counter parameter(CP) field of cycle counter.

    Reviewed-by: Fugang Duan
    Signed-off-by: Joakim Zhang

    Joakim Zhang
     
  • DDR perf driver now only supports free-running event counters
    (counter1/2/3), which means that event counters will continue counting
    even they are overflow.

    However, the situation is changed on i.MX8MP, event counters are not
    free-running any more. Event counters would stop counting if they are
    overflow. So we need clear event counters when cycle counter overflow.

    The patch adds stop counter support which would be compatible to
    free-running counter.

    Signed-off-by: Joakim Zhang

    Joakim Zhang
     

02 Oct, 2020

2 commits

  • The node type field is an enum type, so print it as a 32-bit quantity
    rather than as an unsigned short.

    Link: https://lore.kernel.org/r/202009302350.QIzfkx62-lkp@intel.com
    Reported-by: kernel test robot
    Signed-off-by: Will Deacon

    Will Deacon
     
  • Ensure that the 'irq' field of 'struct arm_cmn_dtc' is a signed int
    so that it can be compared '< 0'.

    Link: https://lore.kernel.org/r/20200929170835.GA15956@embeddedor
    Addresses-Coverity-ID: 1497488 ("Unsigned compared against 0")
    Fixes: 0ba64770a2f2 ("perf: Add Arm CMN-600 PMU driver")
    Reported-by: Gustavo A. R. Silva
    Reviewed-by: Gustavo A. R. Silva
    Signed-off-by: Will Deacon

    Will Deacon
     

29 Sep, 2020

3 commits

  • Add required PMU interrupt operations for NMIs. Request interrupt lines as
    NMIs when possible, otherwise fall back to normal interrupts.

    NMIs are only supported on the arm64 architecture with a GICv3 irqchip.

    [Alexandru E.: Added that NMIs only work on arm64 + GICv3, print message
    when PMU is using NMIs]

    Signed-off-by: Julien Thierry
    Signed-off-by: Alexandru Elisei
    Tested-by: Sumit Garg (Developerbox)
    Cc: Julien Thierry
    Cc: Will Deacon
    Cc: Mark Rutland
    Link: https://lore.kernel.org/r/20200924110706.254996-8-alexandru.elisei@arm.com
    Signed-off-by: Will Deacon

    Julien Thierry
     
  • Currently the PMU interrupt can either be a normal irq or a percpu irq.
    Supporting NMI will introduce two cases for each existing one. It becomes
    a mess of 'if's when managing the interrupt.

    Define sets of callbacks for operations commonly done on the interrupt. The
    appropriate set of callbacks is selected at interrupt request time and
    simplifies interrupt enabling/disabling and freeing.

    Signed-off-by: Julien Thierry
    Signed-off-by: Alexandru Elisei
    Tested-by: Sumit Garg (Developerbox)
    Cc: Julien Thierry
    Cc: Will Deacon
    Cc: Mark Rutland
    Link: https://lore.kernel.org/r/20200924110706.254996-7-alexandru.elisei@arm.com
    Signed-off-by: Will Deacon

    Julien Thierry
     
  • Initial driver for PMU event counting on the Arm CMN-600 interconnect.
    CMN sports an obnoxiously complex distributed PMU system as part of
    its debug and trace features, which can do all manner of things like
    sampling, cross-triggering and generating CoreSight trace. This driver
    covers the PMU functionality, plus the relevant aspects of watchpoints
    for simply counting matching flits.

    Tested-by: Tsahi Zidenberg
    Tested-by: Tuan Phan
    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon

    Robin Murphy
     

18 Sep, 2020

2 commits

  • In tx2_uncore_pmu_init_dev(), a call to acpi_dev_get_resources() is used
    to create a list _CRS resources which is searched for the device base
    address. There is an error check following this:

    if (!rentry->res)
    return NULL

    In no case, will rentry->res be NULL, so the test is useless. Even
    if the test worked, it comes before the resource list memory is
    freed. None of this really matters as long as the ACPI table has
    the memory resource. Let's clean it up so that it makes sense and
    will give a meaningful error should firmware leave out the memory
    resource.

    Fixes: 69c32972d593 ("drivers/perf: Add Cavium ThunderX2 SoC UNCORE PMU driver")
    Signed-off-by: Mark Salter
    Link: https://lore.kernel.org/r/20200915204110.326138-2-msalter@redhat.com
    Signed-off-by: Will Deacon

    Mark Salter
     
  • This splat was reported on newer Fedora kernels booting on certain
    X-gene based machines:

    xgene-pmu APMC0D83:00: X-Gene PMU version 3
    Unable to handle kernel read from unreadable memory at virtual \
    address 0000000000004006
    ...
    Call trace:
    string+0x50/0x100
    vsnprintf+0x160/0x750
    devm_kvasprintf+0x5c/0xb4
    devm_kasprintf+0x54/0x60
    __devm_ioremap_resource+0xdc/0x1a0
    devm_ioremap_resource+0x14/0x20
    acpi_get_pmu_hw_inf.isra.0+0x84/0x15c
    acpi_pmu_dev_add+0xbc/0x21c
    acpi_ns_walk_namespace+0x16c/0x1e4
    acpi_walk_namespace+0xb4/0xfc
    xgene_pmu_probe_pmu_dev+0x7c/0xe0
    xgene_pmu_probe.part.0+0x2c0/0x310
    xgene_pmu_probe+0x54/0x64
    platform_drv_probe+0x60/0xb4
    really_probe+0xe8/0x4a0
    driver_probe_device+0xe4/0x100
    device_driver_attach+0xcc/0xd4
    __driver_attach+0xb0/0x17c
    bus_for_each_dev+0x6c/0xb0
    driver_attach+0x30/0x40
    bus_add_driver+0x154/0x250
    driver_register+0x84/0x140
    __platform_driver_register+0x54/0x60
    xgene_pmu_driver_init+0x28/0x34
    do_one_initcall+0x40/0x204
    do_initcalls+0x104/0x144
    kernel_init_freeable+0x198/0x210
    kernel_init+0x20/0x12c
    ret_from_fork+0x10/0x18
    Code: 91000400 110004e1 eb08009f 540000c0 (38646846)
    ---[ end trace f08c10566496a703 ]---

    This is due to use of an uninitialized local resource struct in the xgene
    pmu driver. The thunderx2_pmu driver avoids this by using the resource list
    constructed by acpi_dev_get_resources() rather than using a callback from
    that function. The callback in the xgene driver didn't fully initialize
    the resource. So get rid of the callback and search the resource list as
    done by thunderx2.

    Fixes: 832c927d119b ("perf: xgene: Add APM X-Gene SoC Performance Monitoring Unit driver")
    Signed-off-by: Mark Salter
    Link: https://lore.kernel.org/r/20200915204110.326138-1-msalter@redhat.com
    Signed-off-by: Will Deacon

    Mark Salter
     

15 Sep, 2020

1 commit

  • Add support for probing device from ACPI node.
    Each DSU ACPI node and its associated cpus are inside a cluster node.

    Signed-off-by: Tuan Phan
    Reviewed-by: Suzuki K Poulose
    Link: https://lore.kernel.org/r/1600106656-9542-1-git-send-email-tuanphan@os.amperecomputing.com
    Signed-off-by: Will Deacon

    Tuan Phan
     

07 Sep, 2020

1 commit

  • MODULE_*** is used in HiSilicon uncore PMU drivers and is provided by
    linux/module.h, but the header file is not directly included. Add the
    missing include.

    Signed-off-by: Shaokun Zhang
    Cc: Will Deacon
    Cc: Mark Rutland
    Link: https://lore.kernel.org/r/1599186097-18599-1-git-send-email-zhangshaokun@hisilicon.com
    Signed-off-by: Will Deacon

    Shaokun Zhang
     

24 Aug, 2020

1 commit

  • Replace the existing /* fall through */ comments and its variants with
    the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
    fall-through markings when it is the case.

    [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

08 Aug, 2020

1 commit

  • Pull clk updates from Stephen Boyd:
    "It looks like a smaller batch of clk updates this time around.

    In the core framework we just have some minor tweaks and a debugfs
    feature, so not much to see there. The driver updates are fairly well
    split between AT91 and Qualcomm clk support. Adding those two drivers
    together equals about 50% of the diffstat.

    Otherwise, the big amount of work this time was on supporting
    Broadcom's Raspberry Pi firmware clks.

    Highlights:

    Core:
    - Document clk_hw_round_rate() so it gets some more use
    - Remove unused __clk_get_flags()
    - Add a prepare/enable debugfs feature similar to rate setting

    New Drivers:
    - Add support for SAMA7G5 SoC clks
    - Enable CPU clks on Qualcomm IPQ6018 SoCs
    - Enable CPU clks on Qualcomm MSM8996 SoCs
    - GPU clk support for Qualcomm SM8150 and SM8250 SoCs
    - Audio clks on Qualcomm SC7180 SoCs
    - Microchip Sparx5 DPLL clk
    - Add support for the new Renesas RZ/G2H (R8A774E1) SoC

    Updates:
    - Make defines for bcm63xx-gate clks to use in DT
    - Support BCM2711 SoC firmware clks
    - Add HDMI clks for BCM2711 SoCs
    - Add RTC related clks on Ingenic SoCs
    - Support USB PHY clks on Ingenic SoCs
    - Support gate clks on BCM6318 SoCs
    - RMU and DMAC/GPIO clock support for Actions Semi S500 SoCs
    - Use poll_timeout functions in Rockchip clk driver
    - Support Rockchip rk3288w SoC variant
    - Mark mac_lbtest critical on Rockchip rk3188
    - Add CAAM clock support for i.MX vf610 driver
    - Add MU root clock support for i.MX imx8mp driver
    - Amlogic g12: add neural network accelerator clock sources
    - Amlogic meson8: remove critical flag for main PLL divider
    - Amlogic meson8: add video decoder clock gates
    - Convert one more Renesas DT binding to json-schema
    - Enhance critical clock handling on Renesas platforms to only
    consider clocks that were enabled at boot time"

    * tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux: (79 commits)
    clk: qcom: gcc: Make disp gpll0 branch aon for sc7180/sdm845
    ipq806x: gcc: add support for child probe
    clk: qcom: msm8996: Make symbol 'cpu_msm8996_clks' static
    clk: qcom: ipq8074: Add correct index for PCIe clocks
    clk: : drop a duplicated word
    clk: renesas: cpg-mssr: Add r8a774e1 support
    dt-bindings: clock: renesas,cpg-mssr: Document r8a774e1
    clk: Drop duplicate selection in Kconfig
    clk: qcom: smd: Add support for MSM8992/4 rpm clocks
    clk: qcom: ipq8074: Add missing clocks for pcie
    dt-bindings: clock: qcom: ipq8074: Add missing bindings for PCIe
    Replace HTTP links with HTTPS ones: Common CLK framework
    clk: qcom: Add CPU clock driver for msm8996
    dt-bindings: clk: qcom: Add bindings for CPU clock for msm8996
    soc: qcom: Separate kryo l2 accessors from PMU driver
    clk: meson: meson8b: add the vclk2_en gate clock
    clk: meson: meson8b: add the vclk_en gate clock
    clk: qcom: Fix return value check in apss_ipq6018_probe()
    clk: bcm: dvp: Add missing module informations
    clk: meson: meson8b: Drop CLK_IS_CRITICAL from fclk_div2
    ...

    Linus Torvalds
     

04 Aug, 2020

1 commit

  • Pull arm64 and cross-arch updates from Catalin Marinas:
    "Here's a slightly wider-spread set of updates for 5.9.

    Going outside the usual arch/arm64/ area is the removal of
    read_barrier_depends() series from Will and the MSI/IOMMU ID
    translation series from Lorenzo.

    The notable arm64 updates include ARMv8.4 TLBI range operations and
    translation level hint, time namespace support, and perf.

    Summary:

    - Removal of the tremendously unpopular read_barrier_depends()
    barrier, which is a NOP on all architectures apart from Alpha, in
    favour of allowing architectures to override READ_ONCE() and do
    whatever dance they need to do to ensure address dependencies
    provide LOAD -> LOAD/STORE ordering.

    This work also offers a potential solution if compilers are shown
    to convert LOAD -> LOAD address dependencies into control
    dependencies (e.g. under LTO), as weakly ordered architectures will
    effectively be able to upgrade READ_ONCE() to smp_load_acquire().
    The latter case is not used yet, but will be discussed further at
    LPC.

    - Make the MSI/IOMMU input/output ID translation PCI agnostic,
    augment the MSI/IOMMU ACPI/OF ID mapping APIs to accept an input ID
    bus-specific parameter and apply the resulting changes to the
    device ID space provided by the Freescale FSL bus.

    - arm64 support for TLBI range operations and translation table level
    hints (part of the ARMv8.4 architecture version).

    - Time namespace support for arm64.

    - Export the virtual and physical address sizes in vmcoreinfo for
    makedumpfile and crash utilities.

    - CPU feature handling cleanups and checks for programmer errors
    (overlapping bit-fields).

    - ACPI updates for arm64: disallow AML accesses to EFI code regions
    and kernel memory.

    - perf updates for arm64.

    - Miscellaneous fixes and cleanups, most notably PLT counting
    optimisation for module loading, recordmcount fix to ignore
    relocations other than R_AARCH64_CALL26, CMA areas reserved for
    gigantic pages on 16K and 64K configurations.

    - Trivial typos, duplicate words"

    Link: http://lkml.kernel.org/r/20200710165203.31284-1-will@kernel.org
    Link: http://lkml.kernel.org/r/20200619082013.13661-1-lorenzo.pieralisi@arm.com

    * tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: (82 commits)
    arm64: use IRQ_STACK_SIZE instead of THREAD_SIZE for irq stack
    arm64/mm: save memory access in check_and_switch_context() fast switch path
    arm64: sigcontext.h: delete duplicated word
    arm64: ptrace.h: delete duplicated word
    arm64: pgtable-hwdef.h: delete duplicated words
    bus: fsl-mc: Add ACPI support for fsl-mc
    bus/fsl-mc: Refactor the MSI domain creation in the DPRC driver
    of/irq: Make of_msi_map_rid() PCI bus agnostic
    of/irq: make of_msi_map_get_device_domain() bus agnostic
    dt-bindings: arm: fsl: Add msi-map device-tree binding for fsl-mc bus
    of/device: Add input id to of_dma_configure()
    of/iommu: Make of_map_rid() PCI agnostic
    ACPI/IORT: Add an input ID to acpi_dma_configure()
    ACPI/IORT: Remove useless PCI bus walk
    ACPI/IORT: Make iort_msi_map_rid() PCI agnostic
    ACPI/IORT: Make iort_get_device_domain IRQ domain agnostic
    ACPI/IORT: Make iort_match_node_callback walk the ACPI namespace for NC
    arm64: enable time namespace support
    arm64/vdso: Restrict splitting VVAR VMA
    arm64/vdso: Handle faults on timens page
    ...

    Linus Torvalds
     

17 Jul, 2020

1 commit

  • Forcefully unbinding PMU drivers during perf sampling will lead to
    a kernel panic, because the perf upper-layer framework call a NULL
    pointer in this situation.

    To solve this issue, "suppress_bind_attrs" should be set to true, so
    that bind/unbind can be disabled via sysfs and prevent unbinding PMU
    drivers during perf sampling.

    Signed-off-by: Qi Liu
    Reviewed-by: John Garry
    Link: https://lore.kernel.org/r/1594975763-32966-1-git-send-email-liuqi115@huawei.com
    Signed-off-by: Will Deacon

    Qi Liu
     

16 Jul, 2020

1 commit

  • When users try to remove PMU modules during perf sampling, kernel panic
    will happen because the pmu->read() is a NULL pointer here.

    INFO on HiSilicon hip08 platform as follow:
    pc : hisi_uncore_pmu_event_update+0x30/0xa4 [hisi_uncore_pmu]
    lr : hisi_uncore_pmu_read+0x20/0x2c [hisi_uncore_pmu]
    sp : ffff800010103e90
    x29: ffff800010103e90 x28: ffff0027db0c0e40
    x27: ffffa29a76f129d8 x26: ffffa29a77ceb000
    x25: ffffa29a773a5000 x24: ffffa29a77392000
    x23: ffffddffe5943f08 x22: ffff002784285960
    x21: ffff002784285800 x20: ffff0027d2e76c80
    x19: ffff0027842859e0 x18: ffff80003498bcc8
    x17: ffffa29a76afe910 x16: ffffa29a7583f530
    x15: 16151a1512061a1e x14: 0000000000000000
    x13: ffffa29a76f1e238 x12: 0000000000000001
    x11: 0000000000000400 x10: 00000000000009f0
    x9 : ffff8000107b3e70 x8 : ffff0027db0c1890
    x7 : ffffa29a773a7000 x6 : 00000007f5131013
    x5 : 00000007f5131013 x4 : 09f257d417c00000
    x3 : 00000002187bd7ce x2 : ffffa29a38f0f0d8
    x1 : ffffa29a38eae268 x0 : ffff0027d2e76c80
    Call trace:
    hisi_uncore_pmu_event_update+0x30/0xa4 [hisi_uncore_pmu]
    hisi_uncore_pmu_read+0x20/0x2c [hisi_uncore_pmu]
    __perf_event_read+0x1a0/0x1f8
    flush_smp_call_function_queue+0xa0/0x160
    generic_smp_call_function_single_interrupt+0x18/0x20
    handle_IPI+0x31c/0x4dc
    gic_handle_irq+0x2c8/0x310
    el1_irq+0xcc/0x180
    arch_cpu_idle+0x4c/0x20c
    default_idle_call+0x20/0x30
    do_idle+0x1b4/0x270
    cpu_startup_entry+0x28/0x30
    secondary_start_kernel+0x1a4/0x1fc

    To solve the above issue, current module should be registered to kernel,
    so that try_module_get() can be invoked when perf sampling starts. This
    adds the reference counting of module and could prevent users from removing
    modules during sampling.

    Reported-by: Haifeng Wang
    Signed-off-by: Qi Liu
    Reviewed-by: John Garry
    Link: https://lore.kernel.org/r/1594891165-8228-1-git-send-email-liuqi115@huawei.com
    Signed-off-by: Will Deacon

    Qi Liu
     

13 Jul, 2020

1 commit


11 Jul, 2020

1 commit

  • The driver provides kernel level API for other drivers
    to access the MSM8996 L2 cache registers.
    Separating the L2 access code from the PMU driver and
    making it public to allow other drivers use it.
    The accesses must be separated with a single spinlock,
    maintained in this driver.

    Signed-off-by: Ilia Lin
    Signed-off-by: Loic Poulain
    Link: https://lore.kernel.org/r/1593766185-16346-2-git-send-email-loic.poulain@linaro.org
    Acked-by: Will Deacon
    Signed-off-by: Stephen Boyd

    Ilia Lin
     

12 Jun, 2020

1 commit

  • Pull arm64 fixes from Will Deacon:
    "arm64 fixes that came in during the merge window.

    There will probably be more to come, but it doesn't seem like it's
    worth me sitting on these in the meantime.

    - Fix SCS debug check to report max stack usage in bytes as advertised

    - Fix typo: CONFIG_FTRACE_WITH_REGS => CONFIG_DYNAMIC_FTRACE_WITH_REGS

    - Fix incorrect mask in HiSilicon L3C perf PMU driver

    - Fix compat vDSO compilation under some toolchain configurations

    - Fix false UBSAN warning from ACPI IORT parsing code

    - Fix booting under bootloaders that ignore TEXT_OFFSET

    - Annotate debug initcall function with '__init'"

    * tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux:
    arm64: warn on incorrect placement of the kernel by the bootloader
    arm64: acpi: fix UBSAN warning
    arm64: vdso32: add CONFIG_THUMB2_COMPAT_VDSO
    drivers/perf: hisi: Fix wrong value for all counters enable
    arm64: ftrace: Change CONFIG_FTRACE_WITH_REGS to CONFIG_DYNAMIC_FTRACE_WITH_REGS
    arm64: debug: mark a function as __init to save some memory
    scs: Report SCS usage in bytes rather than number of entries

    Linus Torvalds
     

08 Jun, 2020

1 commit

  • In L3C uncore PMU drivers, bit16 is used to control all counters enable &
    disable. Wrong value is given in the driver and its default value is 1'b1,
    it can work because each PMU counter has its own control bits too.
    Let's fix the wrong value.

    Fixes: 2940bc433370 ("perf: hisi: Add support for HiSilicon SoC L3C PMU driver")
    Signed-off-by: Shaokun Zhang
    Cc: Will Deacon
    Cc: Mark Rutland
    Link: https://lore.kernel.org/r/1591350221-32275-1-git-send-email-zhangshaokun@hisilicon.com
    Signed-off-by: Will Deacon

    Shaokun Zhang
     

02 Jun, 2020

1 commit

  • Pull arm64 updates from Will Deacon:
    "A sizeable pile of arm64 updates for 5.8.

    Summary below, but the big two features are support for Branch Target
    Identification and Clang's Shadow Call stack. The latter is currently
    arm64-only, but the high-level parts are all in core code so it could
    easily be adopted by other architectures pending toolchain support

    Branch Target Identification (BTI):

    - Support for ARMv8.5-BTI in both user- and kernel-space. This allows
    branch targets to limit the types of branch from which they can be
    called and additionally prevents branching to arbitrary code,
    although kernel support requires a very recent toolchain.

    - Function annotation via SYM_FUNC_START() so that assembly functions
    are wrapped with the relevant "landing pad" instructions.

    - BPF and vDSO updates to use the new instructions.

    - Addition of a new HWCAP and exposure of BTI capability to userspace
    via ID register emulation, along with ELF loader support for the
    BTI feature in .note.gnu.property.

    - Non-critical fixes to CFI unwind annotations in the sigreturn
    trampoline.

    Shadow Call Stack (SCS):

    - Support for Clang's Shadow Call Stack feature, which reserves
    platform register x18 to point at a separate stack for each task
    that holds only return addresses. This protects function return
    control flow from buffer overruns on the main stack.

    - Save/restore of x18 across problematic boundaries (user-mode,
    hypervisor, EFI, suspend, etc).

    - Core support for SCS, should other architectures want to use it
    too.

    - SCS overflow checking on context-switch as part of the existing
    stack limit check if CONFIG_SCHED_STACK_END_CHECK=y.

    CPU feature detection:

    - Removed numerous "SANITY CHECK" errors when running on a system
    with mismatched AArch32 support at EL1. This is primarily a concern
    for KVM, which disabled support for 32-bit guests on such a system.

    - Addition of new ID registers and fields as the architecture has
    been extended.

    Perf and PMU drivers:

    - Minor fixes and cleanups to system PMU drivers.

    Hardware errata:

    - Unify KVM workarounds for VHE and nVHE configurations.

    - Sort vendor errata entries in Kconfig.

    Secure Monitor Call Calling Convention (SMCCC):

    - Update to the latest specification from Arm (v1.2).

    - Allow PSCI code to query the SMCCC version.

    Software Delegated Exception Interface (SDEI):

    - Unexport a bunch of unused symbols.

    - Minor fixes to handling of firmware data.

    Pointer authentication:

    - Add support for dumping the kernel PAC mask in vmcoreinfo so that
    the stack can be unwound by tools such as kdump.

    - Simplification of key initialisation during CPU bringup.

    BPF backend:

    - Improve immediate generation for logical and add/sub instructions.

    vDSO:

    - Minor fixes to the linker flags for consistency with other
    architectures and support for LLVM's unwinder.

    - Clean up logic to initialise and map the vDSO into userspace.

    ACPI:

    - Work around for an ambiguity in the IORT specification relating to
    the "num_ids" field.

    - Support _DMA method for all named components rather than only PCIe
    root complexes.

    - Minor other IORT-related fixes.

    Miscellaneous:

    - Initialise debug traps early for KGDB and fix KDB cacheflushing
    deadlock.

    - Minor tweaks to early boot state (documentation update, set
    TEXT_OFFSET to 0x0, increase alignment of PE/COFF sections).

    - Refactoring and cleanup"

    * tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: (148 commits)
    KVM: arm64: Move __load_guest_stage2 to kvm_mmu.h
    KVM: arm64: Check advertised Stage-2 page size capability
    arm64/cpufeature: Add get_arm64_ftr_reg_nowarn()
    ACPI/IORT: Remove the unused __get_pci_rid()
    arm64/cpuinfo: Add ID_MMFR4_EL1 into the cpuinfo_arm64 context
    arm64/cpufeature: Add remaining feature bits in ID_AA64PFR1 register
    arm64/cpufeature: Add remaining feature bits in ID_AA64PFR0 register
    arm64/cpufeature: Add remaining feature bits in ID_AA64ISAR0 register
    arm64/cpufeature: Add remaining feature bits in ID_MMFR4 register
    arm64/cpufeature: Add remaining feature bits in ID_PFR0 register
    arm64/cpufeature: Introduce ID_MMFR5 CPU register
    arm64/cpufeature: Introduce ID_DFR1 CPU register
    arm64/cpufeature: Introduce ID_PFR2 CPU register
    arm64/cpufeature: Make doublelock a signed feature in ID_AA64DFR0
    arm64/cpufeature: Drop TraceFilt feature exposure from ID_DFR0 register
    arm64/cpufeature: Add explicit ftr_id_isar0[] for ID_ISAR0 register
    arm64: mm: Add asid_gen_match() helper
    firmware: smccc: Fix missing prototype warning for arm_smccc_version_init
    arm64: vdso: Fix CFI directives in sigreturn trampoline
    arm64: vdso: Don't prefix sigreturn trampoline with a BTI C instruction
    ...

    Linus Torvalds
     

19 May, 2020

2 commits

  • Currently when trying to remove the SMMUv3 PMU module we get a
    WARN_ON_ONCE from free_irq(), because the affinity hint set during probe
    hasn't been properly cleared.

    [ 238.878383] WARNING: CPU: 0 PID: 175 at kernel/irq/manage.c:1744 free_irq+0x324/0x358
    ...
    [ 238.897263] Call trace:
    [ 238.897998] free_irq+0x324/0x358
    [ 238.898792] devm_irq_release+0x18/0x28
    [ 238.899189] release_nodes+0x1b0/0x228
    [ 238.899984] devres_release_all+0x38/0x60
    [ 238.900779] device_release_driver_internal+0x10c/0x1d0
    [ 238.901574] driver_detach+0x50/0xe0
    [ 238.902368] bus_remove_driver+0x5c/0xd8
    [ 238.903448] driver_unregister+0x30/0x60
    [ 238.903958] platform_driver_unregister+0x14/0x20
    [ 238.905075] arm_smmu_pmu_exit+0x1c/0xecc [arm_smmuv3_pmu]
    [ 238.905547] __arm64_sys_delete_module+0x14c/0x260
    [ 238.906342] el0_svc_common.constprop.0+0x74/0x178
    [ 238.907355] do_el0_svc+0x24/0x90
    [ 238.907932] el0_sync_handler+0x11c/0x198
    [ 238.908979] el0_sync+0x158/0x180

    Just like the other perf drivers, clear the affinity hint before
    releasing the device.

    Fixes: 7d839b4b9e00 ("perf/smmuv3: Add arm64 smmuv3 pmu driver")
    Signed-off-by: Jean-Philippe Brucker
    Link: https://lore.kernel.org/r/20200422084805.237738-1-jean-philippe@linaro.org
    Signed-off-by: Will Deacon

    Jean-Philippe Brucker
     
  • This patch lets HiSilicon uncore PMU driver can be built as modules.
    A common module and three specific uncore PMU driver modules will be built.

    Export necessary functions in hisi_uncore_pmu module, and change
    irq_set_affinity to irq_set_affinity_hint to pass compile.

    Signed-off-by: Zhou Wang
    Tested-by: Qi Liu
    Reviewed-by: Shaokun Zhang
    Link: https://lore.kernel.org/r/1588820305-174479-1-git-send-email-wangzhou1@hisilicon.com
    Signed-off-by: Will Deacon

    Zhou Wang
     

01 May, 2020

3 commits


16 Apr, 2020

1 commit

  • Open access to monitoring for CAP_PERFMON privileged process. Providing
    the access under CAP_PERFMON capability singly, without the rest of
    CAP_SYS_ADMIN credentials, excludes chances to misuse the credentials
    and makes operation more secure.

    CAP_PERFMON implements the principle of least privilege for performance
    monitoring and observability operations (POSIX IEEE 1003.1e 2.2.2.39
    principle of least privilege: A security design principle that states
    that a process or program be granted only those privileges (e.g.,
    capabilities) necessary to accomplish its legitimate function, and only
    for the time that such privileges are actually required)

    For backward compatibility reasons access to the monitoring remains open
    for CAP_SYS_ADMIN privileged processes but CAP_SYS_ADMIN usage for
    secure monitoring is discouraged with respect to CAP_PERFMON capability.

    Signed-off-by: Alexey Budankov
    Reviewed-by: James Morris
    Acked-by: Will Deacon
    Cc: Alexei Starovoitov
    Cc: Andi Kleen
    Cc: Igor Lubashev
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Serge Hallyn
    Cc: Song Liu
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: intel-gfx@lists.freedesktop.org
    Cc: linux-doc@vger.kernel.org
    Cc: linux-man@vger.kernel.org
    Cc: linux-security-module@vger.kernel.org
    Cc: selinux@vger.kernel.org
    Link: http://lore.kernel.org/lkml/4ec1d6f7-548c-8d1c-f84a-cebeb9674e4e@linux.intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Alexey Budankov
     

01 Apr, 2020

1 commit

  • Pull arm64 updates from Catalin Marinas:
    "The bulk is in-kernel pointer authentication, activity monitors and
    lots of asm symbol annotations. I also queued the sys_mremap() patch
    commenting the asymmetry in the address untagging.

    Summary:

    - In-kernel Pointer Authentication support (previously only offered
    to user space).

    - ARM Activity Monitors (AMU) extension support allowing better CPU
    utilisation numbers for the scheduler (frequency invariance).

    - Memory hot-remove support for arm64.

    - Lots of asm annotations (SYM_*) in preparation for the in-kernel
    Branch Target Identification (BTI) support.

    - arm64 perf updates: ARMv8.5-PMU 64-bit counters, refactoring the
    PMU init callbacks, support for new DT compatibles.

    - IPv6 header checksum optimisation.

    - Fixes: SDEI (software delegated exception interface) double-lock on
    hibernate with shared events.

    - Minor clean-ups and refactoring: cpu_ops accessor,
    cpu_do_switch_mm() converted to C, cpufeature finalisation helper.

    - sys_mremap() comment explaining the asymmetric address untagging
    behaviour"

    * tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: (81 commits)
    mm/mremap: Add comment explaining the untagging behaviour of mremap()
    arm64: head: Convert install_el2_stub to SYM_INNER_LABEL
    arm64: Introduce get_cpu_ops() helper function
    arm64: Rename cpu_read_ops() to init_cpu_ops()
    arm64: Declare ACPI parking protocol CPU operation if needed
    arm64: move kimage_vaddr to .rodata
    arm64: use mov_q instead of literal ldr
    arm64: Kconfig: verify binutils support for ARM64_PTR_AUTH
    lkdtm: arm64: test kernel pointer authentication
    arm64: compile the kernel with ptrauth return address signing
    kconfig: Add support for 'as-option'
    arm64: suspend: restore the kernel ptrauth keys
    arm64: __show_regs: strip PAC from lr in printk
    arm64: unwind: strip PAC from kernel addresses
    arm64: mask PAC bits of __builtin_return_address
    arm64: initialize ptrauth keys for kernel booting task
    arm64: initialize and switch ptrauth kernel keys
    arm64: enable ptrauth earlier
    arm64: cpufeature: handle conflicts based on capability
    arm64: cpufeature: Move cpu capability helpers inside C file
    ...

    Linus Torvalds
     

18 Mar, 2020

1 commit

  • snprintf() is a hard-to-use function, it's especially difficult to use
    it for concatenating substrings in a buffer with a limited size.
    Since snprintf() returns the would-be-output size, not the actual
    size, the subsequent use of snprintf() may point to the incorrect
    position easily. Although the current code doesn't actually overflow
    the buffer, it's an incorrect usage.

    This patch replaces such snprintf() calls with a safer version,
    scnprintf().

    Acked-by: Mark Rutland
    Signed-off-by: Takashi Iwai
    Signed-off-by: Will Deacon

    Takashi Iwai
     

02 Mar, 2020

3 commits


11 Feb, 2020

1 commit

  • Even though a SMMUv3 PMCG implementation may use an MSI as the form of
    interrupt source, the kernel would still complain that it does not find
    the wired (GSIV) interrupt in this case:

    root@(none)$ dmesg | grep arm-smmu-v3-pmcg | grep "not found"
    [ 59.237219] arm-smmu-v3-pmcg arm-smmu-v3-pmcg.8.auto: IRQ index 0 not found
    [ 59.322841] arm-smmu-v3-pmcg arm-smmu-v3-pmcg.9.auto: IRQ index 0 not found
    [ 59.422155] arm-smmu-v3-pmcg arm-smmu-v3-pmcg.10.auto: IRQ index 0 not found
    [ 59.539014] arm-smmu-v3-pmcg arm-smmu-v3-pmcg.11.auto: IRQ index 0 not found
    [ 59.640329] arm-smmu-v3-pmcg arm-smmu-v3-pmcg.12.auto: IRQ index 0 not found
    [ 59.743112] arm-smmu-v3-pmcg arm-smmu-v3-pmcg.13.auto: IRQ index 0 not found
    [ 59.880577] arm-smmu-v3-pmcg arm-smmu-v3-pmcg.14.auto: IRQ index 0 not found
    [ 60.017528] arm-smmu-v3-pmcg arm-smmu-v3-pmcg.15.auto: IRQ index 0 not found

    Use platform_get_irq_optional() to silence the warning.

    If neither interrupt source is found, then the driver will still warn that
    IRQ setup errored and the probe will fail.

    Reviewed-by: Robin Murphy
    Signed-off-by: John Garry
    Signed-off-by: Will Deacon

    John Garry
     

15 Jan, 2020

1 commit

  • This driver allocates a dynamic cpu hotplug state but never releases it.
    If reloaded in a loop it will quickly trigger a WARN message:

    "No more dynamic states available for CPU hotplug"

    Fix by calling cpuhp_remove_multi_state on remove like several other
    perf pmu drivers.

    Also fix the cleanup logic on probe error paths: add the missing
    cpuhp_remove_multi_state call and properly check the return value from
    cpuhp_state_add_instant_nocalls.

    Fixes: 9a66d36cc7ac ("drivers/perf: imx_ddr: Add DDR performance counter support to perf")
    Acked-by: Joakim Zhang
    Signed-off-by: Leonard Crestez
    Signed-off-by: Will Deacon

    Leonard Crestez