diff options
author | Robert Richter <robert.richter@amd.com> | 2010-02-26 07:45:24 -0500 |
---|---|---|
committer | Robert Richter <robert.richter@amd.com> | 2010-02-26 09:28:16 -0500 |
commit | cfc9c0b450176a077205ef39092f0dc1a04e020a (patch) | |
tree | 68e10fea2b2759458e6b955e8d2d24fe85bfbcdd /arch/x86/oprofile | |
parent | c17c8fbf349482e89b57d1b800e83e9f4cf40c47 (diff) |
oprofile/x86: fix msr access to reserved counters
During switching virtual counters there is access to perfctr msrs. If
the counter is not available this fails due to an invalid
address. This patch fixes this.
Cc: stable@kernel.org
Signed-off-by: Robert Richter <robert.richter@amd.com>
Diffstat (limited to 'arch/x86/oprofile')
-rw-r--r-- | arch/x86/oprofile/op_model_amd.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c index f4ebc4596da8..6a58256dce9f 100644 --- a/arch/x86/oprofile/op_model_amd.c +++ b/arch/x86/oprofile/op_model_amd.c | |||
@@ -127,7 +127,7 @@ static void op_mux_switch_ctrl(struct op_x86_model_spec const *model, | |||
127 | /* enable active counters */ | 127 | /* enable active counters */ |
128 | for (i = 0; i < NUM_COUNTERS; ++i) { | 128 | for (i = 0; i < NUM_COUNTERS; ++i) { |
129 | int virt = op_x86_phys_to_virt(i); | 129 | int virt = op_x86_phys_to_virt(i); |
130 | if (!counter_config[virt].enabled) | 130 | if (!reset_value[virt]) |
131 | continue; | 131 | continue; |
132 | rdmsrl(msrs->controls[i].addr, val); | 132 | rdmsrl(msrs->controls[i].addr, val); |
133 | val &= model->reserved; | 133 | val &= model->reserved; |
@@ -163,7 +163,8 @@ static void op_amd_setup_ctrs(struct op_x86_model_spec const *model, | |||
163 | 163 | ||
164 | /* setup reset_value */ | 164 | /* setup reset_value */ |
165 | for (i = 0; i < NUM_VIRT_COUNTERS; ++i) { | 165 | for (i = 0; i < NUM_VIRT_COUNTERS; ++i) { |
166 | if (counter_config[i].enabled) | 166 | if (counter_config[i].enabled |
167 | && msrs->counters[op_x86_virt_to_phys(i)].addr) | ||
167 | reset_value[i] = counter_config[i].count; | 168 | reset_value[i] = counter_config[i].count; |
168 | else | 169 | else |
169 | reset_value[i] = 0; | 170 | reset_value[i] = 0; |
@@ -197,9 +198,7 @@ static void op_amd_setup_ctrs(struct op_x86_model_spec const *model, | |||
197 | /* enable active counters */ | 198 | /* enable active counters */ |
198 | for (i = 0; i < NUM_COUNTERS; ++i) { | 199 | for (i = 0; i < NUM_COUNTERS; ++i) { |
199 | int virt = op_x86_phys_to_virt(i); | 200 | int virt = op_x86_phys_to_virt(i); |
200 | if (!counter_config[virt].enabled) | 201 | if (!reset_value[virt]) |
201 | continue; | ||
202 | if (!msrs->counters[i].addr) | ||
203 | continue; | 202 | continue; |
204 | 203 | ||
205 | /* setup counter registers */ | 204 | /* setup counter registers */ |