]>
Commit | Line | Data |
---|---|---|
2cb7cef9 BS |
1 | Subject: Incorrect local array size in activate spu profiling function |
2 | From: Carl Love <carll@us.ibm.com> | |
3 | References: 439553 - LTC48925 | |
4 | ||
5 | Updated the patch to address comments by Michael Ellerman. | |
6 | Specifically, changed upper limit in for loop to | |
7 | ARRAY_SIZE() macro and added a check to make sure the | |
8 | number of events specified by the user, which is used as | |
9 | the max for indexing various arrays, is no bigger then the | |
10 | declared size of the arrays. | |
11 | ||
12 | The size of the pm_signal_local array should be equal to the | |
13 | number of SPUs being configured in the array. Currently, the | |
14 | array is of size 4 (NR_PHYS_CTRS) but being indexed by a for | |
15 | loop from 0 to 7 (NUM_SPUS_PER_NODE). | |
16 | ||
17 | Signed-off-by: Carl Love <carll@us.ibm.com> | |
18 | Signed-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)) { |