Home Home > GIT Browse > SLE15-SP1
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Tesarik <ptesarik@suse.cz>2019-07-19 17:10:24 +0200
committerPetr Tesarik <ptesarik@suse.cz>2019-07-19 22:49:01 +0200
commit06855697680e7e2d9a31cd22679758eb6562c9fc (patch)
tree07304c28f279bc1faad4dcadcb40227b943e4235
parenta9ad827e0157668327678009be16eabf7181eb5a (diff)
s390/cpumf: Fix warning from check_processor_id (jsc#SLE-6904
-rw-r--r--patches.suse/s390-cpumf-fix-warning-from-check_processor_id91
-rw-r--r--series.conf1
2 files changed, 92 insertions, 0 deletions
diff --git a/patches.suse/s390-cpumf-fix-warning-from-check_processor_id b/patches.suse/s390-cpumf-fix-warning-from-check_processor_id
new file mode 100644
index 0000000000..cd4253575f
--- /dev/null
+++ b/patches.suse/s390-cpumf-fix-warning-from-check_processor_id
@@ -0,0 +1,91 @@
+From: Thomas Richter <tmricht@linux.ibm.com>
+Date: Mon, 18 Mar 2019 15:50:27 +0100
+Subject: s390/cpumf: Fix warning from check_processor_id
+Git-commit: b6ffdf27f3d4f1e9af56effe6f86989170d71e95
+Patch-mainline: v5.1-rc3
+References: jsc#SLE-6904 FATE#327581
+
+Function __hw_perf_event_init() used a CPU variable without
+ensuring CPU preemption has been disabled. This caused the
+following warning in the kernel log:
+
+ [ 7.277085] BUG: using smp_processor_id() in preemptible
+ [00000000] code: cf-csdiag/1892
+ [ 7.277111] caller is cf_diag_event_init+0x13a/0x338
+ [ 7.277122] CPU: 10 PID: 1892 Comm: cf-csdiag Not tainted
+ 5.0.0-20190318.rc0.git0.9e1a11e0f602.300.fc29.s390x+debug #1
+ [ 7.277131] Hardware name: IBM 2964 NC9 712 (LPAR)
+ [ 7.277139] Call Trace:
+ [ 7.277150] ([<000000000011385a>] show_stack+0x82/0xd0)
+ [ 7.277161] [<0000000000b7a71a>] dump_stack+0x92/0xd0
+ [ 7.277174] [<00000000007b7e9c>] check_preemption_disabled+0xe4/0x100
+ [ 7.277183] [<00000000001228aa>] cf_diag_event_init+0x13a/0x338
+ [ 7.277195] [<00000000002cf3aa>] perf_try_init_event+0x72/0xf0
+ [ 7.277204] [<00000000002d0bba>] perf_event_alloc+0x6fa/0xce0
+ [ 7.277214] [<00000000002dc4a8>] __s390x_sys_perf_event_open+0x398/0xd50
+ [ 7.277224] [<0000000000b9e8f0>] system_call+0xdc/0x2d8
+ [ 7.277233] 2 locks held by cf-csdiag/1892:
+ [ 7.277241] #0: 00000000976f5510 (&sig->cred_guard_mutex){+.+.},
+ at: __s390x_sys_perf_event_open+0xd2e/0xd50
+ [ 7.277257] #1: 00000000363b11bd (&pmus_srcu){....},
+ at: perf_event_alloc+0x52e/0xce0
+
+The variable is now accessed in proper context. Use
+get_cpu_var()/put_cpu_var() pair to disable
+preemption during access.
+As the hardware authorization settings apply to all CPUs, it
+does not matter which CPU is used to check the authorization setting.
+
+Remove the event->count assignment. It is not needed as function
+perf_event_alloc() allocates memory for the event with kzalloc() and
+thus count is already set to zero.
+
+Fixes: fe5908bccc56 ("s390/cpum_cf_diag: Add support for s390 counter facility diagnostic trace")
+
+Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
+Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
+Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
+Acked-by: Petr Tesarik <ptesarik@suse.com>
+---
+ arch/s390/kernel/perf_cpum_cf_diag.c | 19 +++++++++++++------
+ 1 file changed, 13 insertions(+), 6 deletions(-)
+
+--- a/arch/s390/kernel/perf_cpum_cf_diag.c
++++ b/arch/s390/kernel/perf_cpum_cf_diag.c
+@@ -196,23 +196,30 @@ static void cf_diag_perf_event_destroy(s
+ */
+ static int __hw_perf_event_init(struct perf_event *event)
+ {
+- struct cpu_cf_events *cpuhw = this_cpu_ptr(&cpu_cf_events);
+ struct perf_event_attr *attr = &event->attr;
++ struct cpu_cf_events *cpuhw;
+ enum cpumf_ctr_set i;
+ int err = 0;
+
+- debug_sprintf_event(cf_diag_dbg, 5,
+- "%s event %p cpu %d authorized %#x\n", __func__,
+- event, event->cpu, cpuhw->info.auth_ctl);
++ debug_sprintf_event(cf_diag_dbg, 5, "%s event %p cpu %d\n", __func__,
++ event, event->cpu);
+
+ event->hw.config = attr->config;
+ event->hw.config_base = 0;
+- local64_set(&event->count, 0);
+
+- /* Add all authorized counter sets to config_base */
++ /* Add all authorized counter sets to config_base. The
++ * the hardware init function is either called per-cpu or just once
++ * for all CPUS (event->cpu == -1). This depends on the whether
++ * counting is started for all CPUs or on a per workload base where
++ * the perf event moves from one CPU to another CPU.
++ * Checking the authorization on any CPU is fine as the hardware
++ * applies the same authorization settings to all CPUs.
++ */
++ cpuhw = &get_cpu_var(cpu_cf_events);
+ for (i = CPUMF_CTR_SET_BASIC; i < CPUMF_CTR_SET_MAX; ++i)
+ if (cpuhw->info.auth_ctl & cpumf_ctr_ctl[i])
+ event->hw.config_base |= cpumf_ctr_ctl[i];
++ put_cpu_var(cpu_cf_events);
+
+ /* No authorized counter sets, nothing to count/sample */
+ if (!event->hw.config_base) {
diff --git a/series.conf b/series.conf
index 83c798eb1a..f546878955 100644
--- a/series.conf
+++ b/series.conf
@@ -46182,6 +46182,7 @@
patches.arch/ARM-imx6q-cpuidle-fix-bug-that-CPU-might-not-wake-up.patch
patches.fixes/s390-vtime-steal-time-exponential-moving-average.patch
patches.fixes/vfio-ccw-only-free-cp-on-final-interrupt
+ patches.suse/s390-cpumf-fix-warning-from-check_processor_id
patches.drm/drm-tegra-hub-Fix-dereference-before-check.patch
patches.drm/drm-Fix-drm_release-and-device-unplug.patch
patches.drm/drm-vgem-fix-use-after-free-when-drm_gem_handle_crea.patch