anolis-cloud-kernel/drivers/hwtracing/coresight
Ruidong Tian 43d26d7cf6 coresight: tmc: Explicit type conversions to prevent integer overflow
ANBZ: #6180

commit fd380097cd upstream.

Perf cs_etm session executed unexpectedly when AUX buffer > 1G.

  perf record -C 0 -m ,2G -e cs_etm// -- <workload>
  [ perf record: Captured and wrote 2.615 MB perf.data ]

Perf only collect about 2M perf data rather than 2G. This is becasuse
the operation, "nr_pages << PAGE_SHIFT", in coresight tmc driver, will
overflow when nr_pages >= 0x80000(correspond to 1G AUX buffer). The
overflow cause buffer allocation to fail, and TMC driver will alloc
minimal buffer size(1M). You can just get about 2M perf data(1M AUX
buffer + perf data header) at least.

Explicit convert nr_pages to 64 bit to avoid overflow.

Fixes: 22f429f19c ("coresight: etm-perf: Add support for ETR backend")
Fixes: 99443ea19e ("coresight: Add generic TMC sg table framework")
Fixes: 2e499bbc1a ("coresight: tmc: implementing TMC-ETF AUX space API")
Signed-off-by: Ruidong Tian <tianruidong@linux.alibaba.com>
Reviewed-by: James Clark <james.clark@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20230804081514.120171-2-tianruidong@linux.alibaba.com
Signed-off-by: Ruidong Tian <tianruidong@linux.alibaba.com>
Reviewed-by: Shuai Xue <xueshuai@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/2059
2023-08-17 15:40:54 +08:00
..
Kconfig coresight: cpu-debug: Control default behavior via Kconfig 2023-02-09 12:35:18 +00:00
Makefile coresight: trace-id: Add API to dynamically assign Trace ID values 2023-08-17 03:43:42 +00:00
coresight-catu.c coresight: Re-use same function for similar sysfs register accessors 2023-02-21 11:22:53 +00:00
coresight-catu.h coresight: Make new csdev_access offsets unsigned 2023-02-21 11:22:53 +00:00
coresight-cfg-afdo.c coresight: config: Add preloaded configurations 2023-02-08 03:24:54 +00:00
coresight-cfg-preload.c coresight: configuration: Update API to introduce load owner concept 2023-02-16 11:34:58 +00:00
coresight-cfg-preload.h coresight: config: Add preloaded configurations 2023-02-08 03:24:54 +00:00
coresight-config.c coresight: config: Add configuration and feature generic functions 2023-02-08 03:24:54 +00:00
coresight-config.h coresight: syscfg: Update load and unload operations 2023-02-20 08:45:27 +00:00
coresight-core.c coresight: Fix uninitialised variable use in coresight_disable 2023-08-17 15:40:52 +08:00
coresight-cpu-debug.c coresight: cpu-debug: Control default behavior via Kconfig 2023-02-09 12:35:18 +00:00
coresight-cti-core.c coresight: cti: Remove atomic type from enable_req_count 2023-08-17 15:40:53 +08:00
coresight-cti-platform.c coresight: cti: Reduce scope for the variable 'cs_fwnode' in cti_plat_create_connection() 2022-08-01 12:16:29 +00:00
coresight-cti-sysfs.c coresight: cti: Remove atomic type from enable_req_count 2023-08-17 15:40:53 +08:00
coresight-cti.h coresight: cti: Remove atomic type from enable_req_count 2023-08-17 15:40:53 +08:00
coresight-etb10.c coresight: Re-use same function for similar sysfs register accessors 2023-02-21 11:22:53 +00:00
coresight-etm-cp14.c
coresight-etm-perf.c coresight: perf: Release Coresight path when alloc trace id failed 2023-08-17 15:40:53 +08:00
coresight-etm-perf.h coresight: perf: Output trace id only once 2023-08-17 15:40:52 +08:00
coresight-etm.h coresight: etmX.X: stm: Remove trace_id() callback 2023-08-17 03:43:42 +00:00
coresight-etm3x-core.c coresight: etmX.X: stm: Remove trace_id() callback 2023-08-17 03:43:42 +00:00
coresight-etm3x-sysfs.c coresight: etm3x: Update ETM3 driver to use Trace ID API 2023-08-17 03:43:42 +00:00
coresight-etm4x-cfg.c coresight: etm4x: Add complex configuration handlers to etmv4 2023-02-08 03:24:54 +00:00
coresight-etm4x-cfg.h coresight: config: Add preloaded configurations 2023-02-08 03:24:54 +00:00
coresight-etm4x-core.c coresight: etm4x: Fix accesses to TRCSEQRSTEVR and TRCSEQSTR 2023-08-17 15:40:53 +08:00
coresight-etm4x-sysfs.c coresight: etm4x: Update ETM4 driver to use Trace ID API 2023-08-17 03:43:42 +00:00
coresight-etm4x.h coresight: etm4x: Do not access TRCIDR1 for identification 2023-08-17 15:40:53 +08:00
coresight-funnel.c coresight: Convert claim/disclaim operations to use access wrappers 2022-08-01 12:16:29 +00:00
coresight-platform.c coresight: Do not scan for graph if none is present 2021-05-19 10:12:55 +02:00
coresight-priv.h coresight: Make new csdev_access offsets unsigned 2023-02-21 11:22:53 +00:00
coresight-replicator.c coresight: Re-use same function for similar sysfs register accessors 2023-02-21 11:22:53 +00:00
coresight-self-hosted-trace.h coresight: trbe: Prohibit trace before disabling TRBE 2023-02-16 02:35:37 +00:00
coresight-stm.c coresight: etmX.X: stm: Remove trace_id() callback 2023-08-17 03:43:42 +00:00
coresight-syscfg-configfs.c coresight: configfs: Allow configfs to activate configuration 2023-02-16 11:34:58 +00:00
coresight-syscfg-configfs.h coresight: configfs: Allow configfs to activate configuration 2023-02-16 11:34:58 +00:00
coresight-syscfg.c coresight: syscfg: Update load and unload operations 2023-02-20 08:45:27 +00:00
coresight-syscfg.h coresight: syscfg: Update load and unload operations 2023-02-20 08:45:27 +00:00
coresight-sysfs.c
coresight-tmc-core.c coresight: tmc: Don't enable TMC when it's not ready. 2023-08-17 15:40:52 +08:00
coresight-tmc-etf.c coresight: tmc: Explicit type conversions to prevent integer overflow 2023-08-17 15:40:54 +08:00
coresight-tmc-etr.c coresight: tmc: Explicit type conversions to prevent integer overflow 2023-08-17 15:40:54 +08:00
coresight-tmc.h coresight: tmc: Explicit type conversions to prevent integer overflow 2023-08-17 15:40:54 +08:00
coresight-tpiu.c coresight: Convert coresight_timeout to use access abstraction 2022-08-01 12:16:29 +00:00
coresight-trace-id.c coresight: trace-id: Add debug & test macros to Trace ID allocation 2023-08-17 03:43:42 +00:00
coresight-trace-id.h coresight: trace-id: Add API to dynamically assign Trace ID values 2023-08-17 03:43:42 +00:00
coresight-trbe.c coresight: trbe: Prohibit trace before disabling TRBE 2023-02-16 02:35:37 +00:00
coresight-trbe.h coresight: sink: Add TRBE driver 2023-02-03 08:26:00 +00:00