1. 23 11月, 2022 9 次提交
  2. 18 11月, 2022 1 次提交
    • S
      coresight: Clear the connection field properly · e165baae
      Suzuki K Poulose 提交于
      stable inclusion
      from stable-v5.10.137
      commit 847b9273dd61567fb77617eabc5fa002594db062
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I60PLB
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=847b9273dd61567fb77617eabc5fa002594db062
      
      --------------------------------
      
      commit 2af89eba upstream.
      
      coresight devices track their connections (output connections) and
      hold a reference to the fwnode. When a device goes away, we walk through
      the devices on the coresight bus and make sure that the references
      are dropped. This happens both ways:
       a) For all output connections from the device, drop the reference to
          the target device via coresight_release_platform_data()
      
      b) Iterate over all the devices on the coresight bus and drop the
         reference to fwnode if *this* device is the target of the output
         connection, via coresight_remove_conns()->coresight_remove_match().
      
      However, the coresight_remove_match() doesn't clear the fwnode field,
      after dropping the reference, this causes use-after-free and
      additional refcount drops on the fwnode.
      
      e.g., if we have two devices, A and B, with a connection, A -> B.
      If we remove B first, B would clear the reference on B, from A
      via coresight_remove_match(). But when A is removed, it still has
      a connection with fwnode still pointing to B. Thus it tries to  drops
      the reference in coresight_release_platform_data(), raising the bells
      like :
      
      [   91.990153] ------------[ cut here ]------------
      [   91.990163] refcount_t: addition on 0; use-after-free.
      [   91.990212] WARNING: CPU: 0 PID: 461 at lib/refcount.c:25 refcount_warn_saturate+0xa0/0x144
      [   91.990260] Modules linked in: coresight_funnel coresight_replicator coresight_etm4x(-)
       crct10dif_ce coresight ip_tables x_tables ipv6 [last unloaded: coresight_cpu_debug]
      [   91.990398] CPU: 0 PID: 461 Comm: rmmod Tainted: G        W       T 5.19.0-rc2+ #53
      [   91.990418] Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Feb  1 2019
      [   91.990434] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
      [   91.990454] pc : refcount_warn_saturate+0xa0/0x144
      [   91.990476] lr : refcount_warn_saturate+0xa0/0x144
      [   91.990496] sp : ffff80000c843640
      [   91.990509] x29: ffff80000c843640 x28: ffff800009957c28 x27: ffff80000c8439a8
      [   91.990560] x26: ffff00097eff1990 x25: ffff8000092b6ad8 x24: ffff00097eff19a8
      [   91.990610] x23: ffff80000c8439a8 x22: 0000000000000000 x21: ffff80000c8439c2
      [   91.990659] x20: 0000000000000000 x19: ffff00097eff1a10 x18: ffff80000ab99c40
      [   91.990708] x17: 0000000000000000 x16: 0000000000000000 x15: ffff80000abf6fa0
      [   91.990756] x14: 000000000000001d x13: 0a2e656572662d72 x12: 657466612d657375
      [   91.990805] x11: 203b30206e6f206e x10: 6f69746964646120 x9 : ffff8000081aba28
      [   91.990854] x8 : 206e6f206e6f6974 x7 : 69646461203a745f x6 : 746e756f63666572
      [   91.990903] x5 : ffff00097648ec58 x4 : 0000000000000000 x3 : 0000000000000027
      [   91.990952] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff00080260ba00
      [   91.991000] Call trace:
      [   91.991012]  refcount_warn_saturate+0xa0/0x144
      [   91.991034]  kobject_get+0xac/0xb0
      [   91.991055]  of_node_get+0x2c/0x40
      [   91.991076]  of_fwnode_get+0x40/0x60
      [   91.991094]  fwnode_handle_get+0x3c/0x60
      [   91.991116]  fwnode_get_nth_parent+0xf4/0x110
      [   91.991137]  fwnode_full_name_string+0x48/0xc0
      [   91.991158]  device_node_string+0x41c/0x530
      [   91.991178]  pointer+0x320/0x3ec
      [   91.991198]  vsnprintf+0x23c/0x750
      [   91.991217]  vprintk_store+0x104/0x4b0
      [   91.991238]  vprintk_emit+0x8c/0x360
      [   91.991257]  vprintk_default+0x44/0x50
      [   91.991276]  vprintk+0xcc/0xf0
      [   91.991295]  _printk+0x68/0x90
      [   91.991315]  of_node_release+0x13c/0x14c
      [   91.991334]  kobject_put+0x98/0x114
      [   91.991354]  of_node_put+0x24/0x34
      [   91.991372]  of_fwnode_put+0x40/0x5c
      [   91.991390]  fwnode_handle_put+0x38/0x50
      [   91.991411]  coresight_release_platform_data+0x74/0xb0 [coresight]
      [   91.991472]  coresight_unregister+0x64/0xcc [coresight]
      [   91.991525]  etm4_remove_dev+0x64/0x78 [coresight_etm4x]
      [   91.991563]  etm4_remove_amba+0x1c/0x2c [coresight_etm4x]
      [   91.991598]  amba_remove+0x3c/0x19c
      
      Reproducible by: (Build all coresight components as modules):
      
        #!/bin/sh
        while true
        do
           for m in tmc stm cpu_debug etm4x replicator funnel
           do
           	modprobe coresight_${m}
           done
      
           for m in tmc stm cpu_debug etm4x replicator funnel
           do
           	rmmode coresight_${m}
           done
        done
      
      Cc: stable@vger.kernel.org
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Signed-off-by: NSuzuki K Poulose <suzuki.poulose@arm.com>
      Fixes: 37ea1ffd ("coresight: Use fwnode handle instead of device names")
      Link: https://lore.kernel.org/r/20220614214024.3005275-1-suzuki.poulose@arm.comSigned-off-by: NMathieu Poirier <mathieu.poirier@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      Reviewed-by: NWei Li <liwei391@huawei.com>
      e165baae
  3. 19 10月, 2022 1 次提交
  4. 29 9月, 2022 1 次提交
  5. 09 8月, 2022 1 次提交
    • J
      coresight: etm4x: Workaround CPU hung bug on HiSilicon ETM · 425154ed
      Junhao He 提交于
      driver inclusion
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I5EZY2
      
      ------------------------------------------------------------------
      
      In FIFO mode, when the state of sink buffer is full, the sink device will
      continuously backpressures the ETM, so that the ETM cannot switch to the
      idle state. In this case, the WFx instruction cannot be executed because
      the CPU detects that the ETM is not in the idle state which that will
      cause CPU hung.
      We workaround this issue on HiSilicon ETM by setting bit 13 of TRCAUXCTLR
      which is used to indicate that the ETM is in the idle state.
      
      The call trace is shown below:
       rcu: INFO: rcu_sched detected stalls on CPUs/tasks:
       rcu: 	10-...0: (1 ticks this GP) idle=5b6/1/0x4000000000000000 softirq=12309/12318 fqs=114196
       	(detected by 67, t=330041 jiffies, g=309253, q=453663)
       Task dump for CPU 10:
       task:ksoftirqd/10    state:R  running task     stack:    0 pid:   64 ppid:     2 flags:0x0000000a
       Call trace:
        __switch_to+0xbc/0xfc
       irqtime_account_irq+0x58/0xc4
       __do_softirq+0x6c/0x358
       run_ksoftirqd+0x68/0x90
       smpboot_thread_fn+0x15c/0x1a0
       kthread+0x108/0x13c
       ret_from_fork+0x10/0x18
      watchdog: BUG: soft lockup - CPU#35 stuck for 22s! [bash:133345]
      ...
      Call trace:
       smp_call_function_single+0x178/0x190
       etm4_disable_sysfs+0x74/0xfc [coresight_etm4x]
       etm4_disable+0x6c/0x70 [coresight_etm4x]
       coresight_disable_source+0x7c/0xa0 [coresight]
       coresight_disable+0x6c/0x13c [coresight]
       enable_source_store+0x88/0xa0 [coresight]
       dev_attr_store+0x20/0x34
       sysfs_kf_write+0x4c/0x5c
       kernfs_fop_write_iter+0x130/0x1c0
       new_sync_write+0xec/0x18c
       vfs_write+0x214/0x2ac
       ksys_write+0x70/0xfc
       __arm64_sys_write+0x24/0x30
       el0_svc_common.constprop.0+0x7c/0x1bc
       do_el0_svc+0x2c/0x94
       el0_svc+0x20/0x30
       el0_sync_handler+0xb0/0xb4
       el0_sync+0x160/0x180
      Signed-off-by: NQi Liu <liuqi115@huawei.com>
      Signed-off-by: NJunhao He <hejunhao3@huawei.com>
      Reviewed-by: NJay Fang <f.fangjian@huawei.com>
      Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      425154ed
  6. 06 7月, 2022 2 次提交
  7. 23 2月, 2022 2 次提交
  8. 06 12月, 2021 1 次提交
  9. 15 10月, 2021 2 次提交
  10. 13 10月, 2021 1 次提交
  11. 03 6月, 2021 1 次提交
  12. 09 4月, 2021 2 次提交
  13. 12 1月, 2021 1 次提交
    • A
      coresight: remove broken __exit annotations · 8ffe693a
      Arnd Bergmann 提交于
      stable inclusion
      from stable-5.10.4
      commit 939b32e18e8b6fd2435f1d02709ec872d795124f
      bugzilla: 46903
      
      --------------------------------
      
      [ Upstream commit 45fe7bef ]
      
      Functions that are annotated __exit are discarded for built-in drivers,
      but the .remove callback in a device driver must still be kept around
      to allow bind/unbind operations.
      
      There is now a linker warning for the discarded symbol references:
      
      `tmc_remove' referenced in section `.data' of drivers/hwtracing/coresight/coresight-tmc-core.o: defined in discarded section `.exit.text' of drivers/hwtracing/coresight/coresight-tmc-core.o
      `tpiu_remove' referenced in section `.data' of drivers/hwtracing/coresight/coresight-tpiu.o: defined in discarded section `.exit.text' of drivers/hwtracing/coresight/coresight-tpiu.o
      `etb_remove' referenced in section `.data' of drivers/hwtracing/coresight/coresight-etb10.o: defined in discarded section `.exit.text' of drivers/hwtracing/coresight/coresight-etb10.o
      `static_funnel_remove' referenced in section `.data' of drivers/hwtracing/coresight/coresight-funnel.o: defined in discarded section `.exit.text' of drivers/hwtracing/coresight/coresight-funnel.o
      `dynamic_funnel_remove' referenced in section `.data' of drivers/hwtracing/coresight/coresight-funnel.o: defined in discarded section `.exit.text' of drivers/hwtracing/coresight/coresight-funnel.o
      `static_replicator_remove' referenced in section `.data' of drivers/hwtracing/coresight/coresight-replicator.o: defined in discarded section `.exit.text' of drivers/hwtracing/coresight/coresight-replicator.o
      `dynamic_replicator_remove' referenced in section `.data' of drivers/hwtracing/coresight/coresight-replicator.o: defined in discarded section `.exit.text' of drivers/hwtracing/coresight/coresight-replicator.o
      `catu_remove' referenced in section `.data' of drivers/hwtracing/coresight/coresight-catu.o: defined in discarded section `.exit.text' of drivers/hwtracing/coresight/coresight-catu.o
      
      Remove all those annotations.
      
      Fixes: 8b0cf826 ("coresight: stm: Allow to build coresight-stm as a module")
      Reviewed-by: NStephen Boyd <swboyd@chromium.org>
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NMathieu Poirier <mathieu.poirier@linaro.org>
      Link: https://lore.kernel.org/r/20201208182651.1597945-3-mathieu.poirier@linaro.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NChen Jun <chenjun102@huawei.com>
      Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
      8ffe693a
  14. 07 1月, 2021 9 次提交
  15. 30 10月, 2020 2 次提交
    • S
      coresight: cti: Initialize dynamic sysfs attributes · 80624263
      Suzuki K Poulose 提交于
      With LOCKDEP enabled, CTI driver triggers the following splat due
      to uninitialized lock class for dynamically allocated attribute
      objects.
      
      [    5.372901] coresight etm0: CPU0: ETM v4.0 initialized
      [    5.376694] coresight etm1: CPU1: ETM v4.0 initialized
      [    5.380785] coresight etm2: CPU2: ETM v4.0 initialized
      [    5.385851] coresight etm3: CPU3: ETM v4.0 initialized
      [    5.389808] BUG: key ffff00000564a798 has not been registered!
      [    5.392456] ------------[ cut here ]------------
      [    5.398195] DEBUG_LOCKS_WARN_ON(1)
      [    5.398233] WARNING: CPU: 1 PID: 32 at kernel/locking/lockdep.c:4623 lockdep_init_map_waits+0x14c/0x260
      [    5.406149] Modules linked in:
      [    5.415411] CPU: 1 PID: 32 Comm: kworker/1:1 Not tainted 5.9.0-12034-gbbe85027 #51
      [    5.418553] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT)
      [    5.426453] Workqueue: events amba_deferred_retry_func
      [    5.433299] pstate: 40000005 (nZcv daif -PAN -UAO -TCO BTYPE=--)
      [    5.438252] pc : lockdep_init_map_waits+0x14c/0x260
      [    5.444410] lr : lockdep_init_map_waits+0x14c/0x260
      [    5.449007] sp : ffff800012bbb720
      ...
      
      [    5.531561] Call trace:
      [    5.536847]  lockdep_init_map_waits+0x14c/0x260
      [    5.539027]  __kernfs_create_file+0xa8/0x1c8
      [    5.543539]  sysfs_add_file_mode_ns+0xd0/0x208
      [    5.548054]  internal_create_group+0x118/0x3c8
      [    5.552307]  internal_create_groups+0x58/0xb8
      [    5.556733]  sysfs_create_groups+0x2c/0x38
      [    5.561160]  device_add+0x2d8/0x768
      [    5.565148]  device_register+0x28/0x38
      [    5.568537]  coresight_register+0xf8/0x320
      [    5.572358]  cti_probe+0x1b0/0x3f0
      
      ...
      
      Fix this by initializing the attributes when they are allocated.
      
      Fixes: 3c5597e3 ("coresight: cti: Add connection information to sysfs")
      Reported-by: NLeo Yan <leo.yan@linaro.org>
      Tested-by: NLeo Yan <leo.yan@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Signed-off-by: NSuzuki K Poulose <suzuki.poulose@arm.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NMathieu Poirier <mathieu.poirier@linaro.org>
      Link: https://lore.kernel.org/r/20201029164559.1268531-2-mathieu.poirier@linaro.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      80624263
    • M
      coresight: Fix uninitialised pointer bug in etm_setup_aux() · 39a7661d
      Mike Leach 提交于
      Commit [bb1860ef] changed the sink handling code introducing an
      uninitialised pointer bug. This results in the default sink selection
      failing.
      
      Prior to commit:
      
      static void etm_setup_aux(...)
      
      <snip>
              struct coresight_device *sink;
      <snip>
      
              /* First get the selected sink from user space. */
              if (event->attr.config2) {
                      id = (u32)event->attr.config2;
                      sink = coresight_get_sink_by_id(id);
              } else {
                      sink = coresight_get_enabled_sink(true);
              }
      <ctd>
      
      *sink always initialised - possibly to NULL which triggers the
      automatic sink selection.
      
      After commit:
      
      static void etm_setup_aux(...)
      
      <snip>
              struct coresight_device *sink;
      <snip>
      
              /* First get the selected sink from user space. */
              if (event->attr.config2) {
                      id = (u32)event->attr.config2;
                      sink = coresight_get_sink_by_id(id);
              }
      <ctd>
      
      *sink pointer uninitialised when not providing a sink on the perf command
      line. This breaks later checks to enable automatic sink selection.
      
      Fixes: bb1860ef ("coresight: etm: perf: Sink selection using sysfs is deprecated")
      Signed-off-by: NMike Leach <mike.leach@linaro.org>
      Signed-off-by: NMathieu Poirier <mathieu.poirier@linaro.org>
      Link: https://lore.kernel.org/r/20201029164559.1268531-3-mathieu.poirier@linaro.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      39a7661d
  16. 29 10月, 2020 1 次提交
  17. 29 9月, 2020 3 次提交