From: Greg Kroah-Hartman Date: Tue, 31 Oct 2017 08:35:05 +0000 (+0100) Subject: 4.13-stable patches X-Git-Tag: v3.18.79~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=27e10a001b9caf90f5985ee41ec850b04b53ad1e;p=thirdparty%2Fkernel%2Fstable-queue.git 4.13-stable patches added patches: powerpc-xive-fix-the-size-of-the-cpumask-used-in-xive_find_target_in_mask.patch --- diff --git a/queue-4.13/powerpc-xive-fix-the-size-of-the-cpumask-used-in-xive_find_target_in_mask.patch b/queue-4.13/powerpc-xive-fix-the-size-of-the-cpumask-used-in-xive_find_target_in_mask.patch new file mode 100644 index 00000000000..c27115b3c0b --- /dev/null +++ b/queue-4.13/powerpc-xive-fix-the-size-of-the-cpumask-used-in-xive_find_target_in_mask.patch @@ -0,0 +1,62 @@ +From a9dadc1c512807f955f0799e85830b420da47932 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= +Date: Tue, 8 Aug 2017 11:02:49 +0200 +Subject: powerpc/xive: Fix the size of the cpumask used in xive_find_target_in_mask() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Cédric Le Goater + +commit a9dadc1c512807f955f0799e85830b420da47932 upstream. + +When called from xive_irq_startup(), the size of the cpumask can be +larger than nr_cpu_ids. This can result in a WARN_ON such as: + + WARNING: CPU: 10 PID: 1 at ../arch/powerpc/sysdev/xive/common.c:476 xive_find_target_in_mask+0x110/0x2f0 + ... + NIP [c00000000008a310] xive_find_target_in_mask+0x110/0x2f0 + LR [c00000000008a2e4] xive_find_target_in_mask+0xe4/0x2f0 + Call Trace: + xive_find_target_in_mask+0x74/0x2f0 (unreliable) + xive_pick_irq_target.isra.1+0x200/0x230 + xive_irq_startup+0x60/0x180 + irq_startup+0x70/0xd0 + __setup_irq+0x7bc/0x880 + request_threaded_irq+0x14c/0x2c0 + request_event_sources_irqs+0x100/0x180 + __machine_initcall_pseries_init_ras_IRQ+0x104/0x134 + do_one_initcall+0x68/0x1d0 + kernel_init_freeable+0x290/0x374 + kernel_init+0x24/0x170 + ret_from_kernel_thread+0x5c/0x74 + +This happens because we're being called with our affinity mask set to +irq_default_affinity. That in turn was populated using +cpumask_setall(), which sets NR_CPUs worth of bits, not nr_cpu_ids +worth. Finally cpumask_weight() will return > nr_cpu_ids when passed a +mask which has > nr_cpu_ids bits set. + +Fix it by limiting the value returned by cpumask_weight(). + +Signed-off-by: Cédric Le Goater +[mpe: Add change log details on actual cause] +Signed-off-by: Michael Ellerman +Cc: Stewart Smith +Signed-off-by: Greg Kroah-Hartman + +--- + arch/powerpc/sysdev/xive/common.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/arch/powerpc/sysdev/xive/common.c ++++ b/arch/powerpc/sysdev/xive/common.c +@@ -447,7 +447,7 @@ static int xive_find_target_in_mask(cons + int cpu, first, num, i; + + /* Pick up a starting point CPU in the mask based on fuzz */ +- num = cpumask_weight(mask); ++ num = min_t(int, cpumask_weight(mask), nr_cpu_ids); + first = fuzz % num; + + /* Locate it */ diff --git a/queue-4.13/series b/queue-4.13/series index 3c059f4deb0..cb9c0ae2690 100644 --- a/queue-4.13/series +++ b/queue-4.13/series @@ -40,3 +40,4 @@ can-kvaser_usb-ignore-cmd_flush_queue_reply-messages.patch cfg80211-fix-connect-disconnect-edge-cases.patch ipsec-fix-aborted-xfrm-policy-dump-crash.patch regulator-fan53555-fix-i2c-device-ids.patch +powerpc-xive-fix-the-size-of-the-cpumask-used-in-xive_find_target_in_mask.patch