Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Fix perf regs mask generation

On some architectures (powerpc in particular), the number of registers
exceeds what can be represented in an integer bitmask. Ensure we
generate the proper bitmask on such platforms.

Fixes: 71ad0f5e4 ("perf tools: Support for DWARF CFI unwinding on post processing")
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Naveen N. Rao and committed by
Michael Ellerman
f4782207 c4522469

+4 -4
+4 -4
tools/perf/util/perf_regs.c
··· 12 12 int i, idx = 0; 13 13 u64 mask = regs->mask; 14 14 15 - if (regs->cache_mask & (1 << id)) 15 + if (regs->cache_mask & (1ULL << id)) 16 16 goto out; 17 17 18 - if (!(mask & (1 << id))) 18 + if (!(mask & (1ULL << id))) 19 19 return -EINVAL; 20 20 21 21 for (i = 0; i < id; i++) { 22 - if (mask & (1 << i)) 22 + if (mask & (1ULL << i)) 23 23 idx++; 24 24 } 25 25 26 - regs->cache_mask |= (1 << id); 26 + regs->cache_mask |= (1ULL << id); 27 27 regs->cache_regs[id] = regs->regs[idx]; 28 28 29 29 out: