Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit a777b7b9 authored by Ruidong Tian's avatar Ruidong Tian Committed by Lee Jones
Browse files

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: default avatarRuidong Tian <tianruidong@linux.alibaba.com>
Reviewed-by: default avatarJames Clark <james.clark@arm.com>
Signed-off-by: default avatarSuzuki 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: default avatarLee Jones <joneslee@google.com>
Change-Id: I0ebd4afabf2b6bef525712416135ffb34d1f7cd3
parent 4f6171eb
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment