perf intel-pt: Fix aux_watermark calculation for 64-bit size
authorAdrian Hunter <adrian.hunter@intel.com>
Tue, 25 Jun 2024 10:45:31 +0000 (13:45 +0300)
committerNamhyung Kim <namhyung@kernel.org>
Tue, 2 Jul 2024 22:24:01 +0000 (15:24 -0700)
aux_watermark is a u32. For a 64-bit size, cap the aux_watermark
calculation at UINT_MAX instead of truncating it to 32-bits.

Fixes: 874fc35cdd55 ("perf intel-pt: Use aux_watermark")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Link: https://lore.kernel.org/r/20240625104532.11990-2-adrian.hunter@intel.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/arch/x86/util/intel-pt.c

index 6de7e2d2107562f5efc287498e69f5c3aaa4e174..c8fa15f280d298d36eb96a7413230208e848bc24 100644 (file)
@@ -758,7 +758,8 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
        }
 
        if (!opts->auxtrace_snapshot_mode && !opts->auxtrace_sample_mode) {
-               u32 aux_watermark = opts->auxtrace_mmap_pages * page_size / 4;
+               size_t aw = opts->auxtrace_mmap_pages * (size_t)page_size / 4;
+               u32 aux_watermark = aw > UINT_MAX ? UINT_MAX : aw;
 
                intel_pt_evsel->core.attr.aux_watermark = aux_watermark;
        }