Commit 8a9bd933 authored by Robert Richter's avatar Robert Richter Committed by Greg Kroah-Hartman

oprofile/x86: fix msr access to reserved counters

commit cfc9c0b4 upstream.

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.
Signed-off-by: default avatarRobert Richter <robert.richter@amd.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent daed3716
...@@ -85,7 +85,7 @@ static void op_mux_switch_ctrl(struct op_x86_model_spec const *model, ...@@ -85,7 +85,7 @@ static void op_mux_switch_ctrl(struct op_x86_model_spec const *model,
/* enable active counters */ /* enable active counters */
for (i = 0; i < NUM_COUNTERS; ++i) { for (i = 0; i < NUM_COUNTERS; ++i) {
int virt = op_x86_phys_to_virt(i); int virt = op_x86_phys_to_virt(i);
if (!counter_config[virt].enabled) if (!reset_value[virt])
continue; continue;
rdmsrl(msrs->controls[i].addr, val); rdmsrl(msrs->controls[i].addr, val);
val &= model->reserved; val &= model->reserved;
...@@ -121,7 +121,8 @@ static void op_amd_setup_ctrs(struct op_x86_model_spec const *model, ...@@ -121,7 +121,8 @@ static void op_amd_setup_ctrs(struct op_x86_model_spec const *model,
/* setup reset_value */ /* setup reset_value */
for (i = 0; i < NUM_VIRT_COUNTERS; ++i) { for (i = 0; i < NUM_VIRT_COUNTERS; ++i) {
if (counter_config[i].enabled) if (counter_config[i].enabled
&& msrs->counters[op_x86_virt_to_phys(i)].addr)
reset_value[i] = counter_config[i].count; reset_value[i] = counter_config[i].count;
else else
reset_value[i] = 0; reset_value[i] = 0;
...@@ -146,9 +147,7 @@ static void op_amd_setup_ctrs(struct op_x86_model_spec const *model, ...@@ -146,9 +147,7 @@ static void op_amd_setup_ctrs(struct op_x86_model_spec const *model,
/* enable active counters */ /* enable active counters */
for (i = 0; i < NUM_COUNTERS; ++i) { for (i = 0; i < NUM_COUNTERS; ++i) {
int virt = op_x86_phys_to_virt(i); int virt = op_x86_phys_to_virt(i);
if (!counter_config[virt].enabled) if (!reset_value[virt])
continue;
if (!msrs->counters[i].addr)
continue; continue;
/* setup counter registers */ /* setup counter registers */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment