From: Greg Kroah-Hartman Date: Wed, 22 Nov 2017 08:53:47 +0000 (+0100) Subject: 4.13-stable patches X-Git-Tag: v3.18.84~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d41aa6669290db7ec967c54b7089e40a32dd1b3d;p=thirdparty%2Fkernel%2Fstable-queue.git 4.13-stable patches added patches: x86-cpu-amd-derive-l3-shared_cpu_map-from-cpu_llc_shared_mask.patch --- diff --git a/queue-4.13/series b/queue-4.13/series index 6d84bf5888f..e99dc0bb619 100644 --- a/queue-4.13/series +++ b/queue-4.13/series @@ -32,3 +32,4 @@ ipmi-fix-unsigned-long-underflow.patch mm-swap-fix-false-error-message-in-__swp_swapcount.patch mm-page_alloc.c-broken-deferred-calculation.patch mm-page_ext.c-check-if-page_ext-is-not-prepared.patch +x86-cpu-amd-derive-l3-shared_cpu_map-from-cpu_llc_shared_mask.patch diff --git a/queue-4.13/x86-cpu-amd-derive-l3-shared_cpu_map-from-cpu_llc_shared_mask.patch b/queue-4.13/x86-cpu-amd-derive-l3-shared_cpu_map-from-cpu_llc_shared_mask.patch new file mode 100644 index 00000000000..f8e7f0cf176 --- /dev/null +++ b/queue-4.13/x86-cpu-amd-derive-l3-shared_cpu_map-from-cpu_llc_shared_mask.patch @@ -0,0 +1,79 @@ +From 2b83809a5e6d619a780876fcaf68cdc42b50d28c Mon Sep 17 00:00:00 2001 +From: Suravee Suthikulpanit +Date: Mon, 31 Jul 2017 10:51:59 +0200 +Subject: x86/cpu/amd: Derive L3 shared_cpu_map from cpu_llc_shared_mask + +From: Suravee Suthikulpanit + +commit 2b83809a5e6d619a780876fcaf68cdc42b50d28c upstream. + +For systems with X86_FEATURE_TOPOEXT, current logic uses the APIC ID +to calculate shared_cpu_map. However, APIC IDs are not guaranteed to +be contiguous for cores across different L3s (e.g. family17h system +w/ downcore configuration). This breaks the logic, and results in an +incorrect L3 shared_cpu_map. + +Instead, always use the previously calculated cpu_llc_shared_mask of +each CPU to derive the L3 shared_cpu_map. + +Signed-off-by: Suravee Suthikulpanit +Signed-off-by: Borislav Petkov +Cc: Linus Torvalds +Cc: Peter Zijlstra +Cc: Thomas Gleixner +Link: http://lkml.kernel.org/r/20170731085159.9455-3-bp@alien8.de +Signed-off-by: Ingo Molnar +Signed-off-by: Greg Kroah-Hartman + +--- + arch/x86/kernel/cpu/intel_cacheinfo.c | 32 ++++++++++++++++++-------------- + 1 file changed, 18 insertions(+), 14 deletions(-) + +--- a/arch/x86/kernel/cpu/intel_cacheinfo.c ++++ b/arch/x86/kernel/cpu/intel_cacheinfo.c +@@ -811,7 +811,24 @@ static int __cache_amd_cpumap_setup(unsi + struct cacheinfo *this_leaf; + int i, sibling; + +- if (boot_cpu_has(X86_FEATURE_TOPOEXT)) { ++ /* ++ * For L3, always use the pre-calculated cpu_llc_shared_mask ++ * to derive shared_cpu_map. ++ */ ++ if (index == 3) { ++ for_each_cpu(i, cpu_llc_shared_mask(cpu)) { ++ this_cpu_ci = get_cpu_cacheinfo(i); ++ if (!this_cpu_ci->info_list) ++ continue; ++ this_leaf = this_cpu_ci->info_list + index; ++ for_each_cpu(sibling, cpu_llc_shared_mask(cpu)) { ++ if (!cpu_online(sibling)) ++ continue; ++ cpumask_set_cpu(sibling, ++ &this_leaf->shared_cpu_map); ++ } ++ } ++ } else if (boot_cpu_has(X86_FEATURE_TOPOEXT)) { + unsigned int apicid, nshared, first, last; + + this_leaf = this_cpu_ci->info_list + index; +@@ -837,19 +854,6 @@ static int __cache_amd_cpumap_setup(unsi + continue; + cpumask_set_cpu(sibling, + &this_leaf->shared_cpu_map); +- } +- } +- } else if (index == 3) { +- for_each_cpu(i, cpu_llc_shared_mask(cpu)) { +- this_cpu_ci = get_cpu_cacheinfo(i); +- if (!this_cpu_ci->info_list) +- continue; +- this_leaf = this_cpu_ci->info_list + index; +- for_each_cpu(sibling, cpu_llc_shared_mask(cpu)) { +- if (!cpu_online(sibling)) +- continue; +- cpumask_set_cpu(sibling, +- &this_leaf->shared_cpu_map); + } + } + } else