]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/patches/suse-2.6.27.39/patches.arch/ppc-oprofile-spu.patch
Imported linux-2.6.27.39 suse/xen patches.
[people/pmueller/ipfire-2.x.git] / src / patches / suse-2.6.27.39 / patches.arch / ppc-oprofile-spu.patch
CommitLineData
2cb7cef9
BS
1Subject: Incorrect local array size in activate spu profiling function
2From: Carl Love <carll@us.ibm.com>
3References: 439553 - LTC48925
4
5Updated the patch to address comments by Michael Ellerman.
6Specifically, changed upper limit in for loop to
7ARRAY_SIZE() macro and added a check to make sure the
8number of events specified by the user, which is used as
9the max for indexing various arrays, is no bigger then the
10declared size of the arrays.
11
12The size of the pm_signal_local array should be equal to the
13number of SPUs being configured in the array. Currently, the
14array is of size 4 (NR_PHYS_CTRS) but being indexed by a for
15loop from 0 to 7 (NUM_SPUS_PER_NODE).
16
17Signed-off-by: Carl Love <carll@us.ibm.com>
18Signed-off-by: Olaf Hering <olh@suse.de>
19
20---
21 arch/powerpc/oprofile/op_model_cell.c | 13 ++++++++++---
22 1 file changed, 10 insertions(+), 3 deletions(-)
23
24--- a/arch/powerpc/oprofile/op_model_cell.c
25+++ b/arch/powerpc/oprofile/op_model_cell.c
26@@ -582,6 +582,13 @@ static int cell_reg_setup(struct op_coun
27
28 num_counters = num_ctrs;
29
30+ if (unlikely(num_ctrs > NR_PHYS_CTRS)) {
31+ printk(KERN_ERR
32+ "%s: Oprofile, number of specified events " \
33+ "exceeds number of physical counters\n",
34+ __func__);
35+ return -EIO;
36+ }
37 pm_regs.group_control = 0;
38 pm_regs.debug_bus_control = 0;
39
40@@ -830,13 +837,13 @@ static int calculate_lfsr(int n)
41 static int pm_rtas_activate_spu_profiling(u32 node)
42 {
43 int ret, i;
44- struct pm_signal pm_signal_local[NR_PHYS_CTRS];
45+ struct pm_signal pm_signal_local[NUM_SPUS_PER_NODE];
46
47 /*
48 * Set up the rtas call to configure the debug bus to
49 * route the SPU PCs. Setup the pm_signal for each SPU
50 */
51- for (i = 0; i < NUM_SPUS_PER_NODE; i++) {
52+ for (i = 0; i < ARRAY_SIZE(pm_signal_local); i++) {
53 pm_signal_local[i].cpu = node;
54 pm_signal_local[i].signal_group = 41;
55 /* spu i on word (i/2) */
56@@ -848,7 +855,7 @@ static int pm_rtas_activate_spu_profilin
57
58 ret = rtas_ibm_cbe_perftools(SUBFUNC_ACTIVATE,
59 PASSTHRU_ENABLE, pm_signal_local,
60- (NUM_SPUS_PER_NODE
61+ (ARRAY_SIZE(pm_signal_local)
62 * sizeof(struct pm_signal)));
63
64 if (unlikely(ret)) {