UPSTREAM: coresight: tmc: Explicit type conversions to prevent integer overflow
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. Bug: 254441685 Fixes: 22f429f19c41 ("coresight: etm-perf: Add support for ETR backend") Fixes: 99443ea1 ("coresight: Add generic TMC sg table framework") Fixes: 2e499bbc ("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 (cherry picked from commit fd380097cdb305582b7a1f9476391330299d2c59) Signed-off-by:
Lee Jones <joneslee@google.com> Change-Id: I0ebd4afabf2b6bef525712416135ffb34d1f7cd3
Loading
Please register or sign in to comment