aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorStephane Eranian <eranian@google.com>2013-04-16 07:51:43 -0400
committerIngo Molnar <mingo@kernel.org>2013-04-16 09:02:06 -0400
commitf1923820c447e986a9da0fc6bf60c1dccdf0408e (patch)
tree9b7d9833a0e490ab21b5c887198b95a6912cc6be /arch
parent8176cced706b5e5d15887584150764894e94e02f (diff)
perf/x86: Fix offcore_rsp valid mask for SNB/IVB
The valid mask for both offcore_response_0 and offcore_response_1 was wrong for SNB/SNB-EP, IVB/IVB-EP. It was possible to write to reserved bit and cause a GP fault crashing the kernel. This patch fixes the problem by correctly marking the reserved bits in the valid mask for all the processors mentioned above. A distinction between desktop and server parts is introduced because bits 24-30 are only available on the server parts. This version of the patch is just a rebase to perf/urgent tree and should apply to older kernels as well. Signed-off-by: Stephane Eranian <eranian@google.com> Cc: peterz@infradead.org Cc: jolsa@redhat.com Cc: gregkh@linuxfoundation.org Cc: security@kernel.org Cc: ak@linux.intel.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index dab7580c47ae..cc45deb791b0 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -153,8 +153,14 @@ static struct event_constraint intel_gen_event_constraints[] __read_mostly =
153}; 153};
154 154
155static struct extra_reg intel_snb_extra_regs[] __read_mostly = { 155static struct extra_reg intel_snb_extra_regs[] __read_mostly = {
156 INTEL_EVENT_EXTRA_REG(0xb7, MSR_OFFCORE_RSP_0, 0x3fffffffffull, RSP_0), 156 INTEL_EVENT_EXTRA_REG(0xb7, MSR_OFFCORE_RSP_0, 0x3f807f8fffull, RSP_0),
157 INTEL_EVENT_EXTRA_REG(0xbb, MSR_OFFCORE_RSP_1, 0x3fffffffffull, RSP_1), 157 INTEL_EVENT_EXTRA_REG(0xbb, MSR_OFFCORE_RSP_1, 0x3f807f8fffull, RSP_1),
158 EVENT_EXTRA_END
159};
160
161static struct extra_reg intel_snbep_extra_regs[] __read_mostly = {
162 INTEL_EVENT_EXTRA_REG(0xb7, MSR_OFFCORE_RSP_0, 0x3fffff8fffull, RSP_0),
163 INTEL_EVENT_EXTRA_REG(0xbb, MSR_OFFCORE_RSP_1, 0x3fffff8fffull, RSP_1),
158 EVENT_EXTRA_END 164 EVENT_EXTRA_END
159}; 165};
160 166
@@ -2097,7 +2103,10 @@ __init int intel_pmu_init(void)
2097 x86_pmu.event_constraints = intel_snb_event_constraints; 2103 x86_pmu.event_constraints = intel_snb_event_constraints;
2098 x86_pmu.pebs_constraints = intel_snb_pebs_event_constraints; 2104 x86_pmu.pebs_constraints = intel_snb_pebs_event_constraints;
2099 x86_pmu.pebs_aliases = intel_pebs_aliases_snb; 2105 x86_pmu.pebs_aliases = intel_pebs_aliases_snb;
2100 x86_pmu.extra_regs = intel_snb_extra_regs; 2106 if (boot_cpu_data.x86_model == 45)
2107 x86_pmu.extra_regs = intel_snbep_extra_regs;
2108 else
2109 x86_pmu.extra_regs = intel_snb_extra_regs;
2101 /* all extra regs are per-cpu when HT is on */ 2110 /* all extra regs are per-cpu when HT is on */
2102 x86_pmu.er_flags |= ERF_HAS_RSP_1; 2111 x86_pmu.er_flags |= ERF_HAS_RSP_1;
2103 x86_pmu.er_flags |= ERF_NO_HT_SHARING; 2112 x86_pmu.er_flags |= ERF_NO_HT_SHARING;
@@ -2123,7 +2132,10 @@ __init int intel_pmu_init(void)
2123 x86_pmu.event_constraints = intel_ivb_event_constraints; 2132 x86_pmu.event_constraints = intel_ivb_event_constraints;
2124 x86_pmu.pebs_constraints = intel_ivb_pebs_event_constraints; 2133 x86_pmu.pebs_constraints = intel_ivb_pebs_event_constraints;
2125 x86_pmu.pebs_aliases = intel_pebs_aliases_snb; 2134 x86_pmu.pebs_aliases = intel_pebs_aliases_snb;
2126 x86_pmu.extra_regs = intel_snb_extra_regs; 2135 if (boot_cpu_data.x86_model == 62)
2136 x86_pmu.extra_regs = intel_snbep_extra_regs;
2137 else
2138 x86_pmu.extra_regs = intel_snb_extra_regs;
2127 /* all extra regs are per-cpu when HT is on */ 2139 /* all extra regs are per-cpu when HT is on */
2128 x86_pmu.er_flags |= ERF_HAS_RSP_1; 2140 x86_pmu.er_flags |= ERF_HAS_RSP_1;
2129 x86_pmu.er_flags |= ERF_NO_HT_SHARING; 2141 x86_pmu.er_flags |= ERF_NO_HT_SHARING;