diff options
author | Prarit Bhargava <prarit@redhat.com> | 2009-12-09 13:36:45 -0500 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2009-12-10 20:19:03 -0500 |
commit | ebb682f522411abbe358059a256a8672ec0bd55b (patch) | |
tree | ff8ebb34f17ec3c3d445857be9da7fd35f4579a0 | |
parent | 9cf7826743e5c78dcfcfdc99d17f79ce6d3a2942 (diff) |
x86, AMD: Fix stale cpuid4_info shared_map data in shared_cpu_map cpumasks
The per_cpu cpuid4_info shared_map can contain stale data when CPUs are added
and removed.
The stale data can lead to a NULL pointer derefernce panic on a remove of a
CPU that has had siblings previously removed.
This patch resolves the panic by verifying a cpu is actually online before
adding it to the shared_cpu_map, only examining cpus that are part of
the same lower level cache, and by updating other siblings lowest level cache
maps when a cpu is added.
Signed-off-by: Prarit Bhargava <prarit@redhat.com>
LKML-Reference: <20091209183336.17855.98708.sendpatchset@prarit.bos.redhat.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | arch/x86/kernel/cpu/intel_cacheinfo.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c index 6c40f6b5b340..63ada177b40c 100644 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c | |||
@@ -507,18 +507,19 @@ static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index) | |||
507 | { | 507 | { |
508 | struct _cpuid4_info *this_leaf, *sibling_leaf; | 508 | struct _cpuid4_info *this_leaf, *sibling_leaf; |
509 | unsigned long num_threads_sharing; | 509 | unsigned long num_threads_sharing; |
510 | int index_msb, i; | 510 | int index_msb, i, sibling; |
511 | struct cpuinfo_x86 *c = &cpu_data(cpu); | 511 | struct cpuinfo_x86 *c = &cpu_data(cpu); |
512 | 512 | ||
513 | if ((index == 3) && (c->x86_vendor == X86_VENDOR_AMD)) { | 513 | if ((index == 3) && (c->x86_vendor == X86_VENDOR_AMD)) { |
514 | struct cpuinfo_x86 *d; | 514 | for_each_cpu(i, c->llc_shared_map) { |
515 | for_each_online_cpu(i) { | ||
516 | if (!per_cpu(cpuid4_info, i)) | 515 | if (!per_cpu(cpuid4_info, i)) |
517 | continue; | 516 | continue; |
518 | d = &cpu_data(i); | ||
519 | this_leaf = CPUID4_INFO_IDX(i, index); | 517 | this_leaf = CPUID4_INFO_IDX(i, index); |
520 | cpumask_copy(to_cpumask(this_leaf->shared_cpu_map), | 518 | for_each_cpu(sibling, c->llc_shared_map) { |
521 | d->llc_shared_map); | 519 | if (!cpu_online(sibling)) |
520 | continue; | ||
521 | set_bit(sibling, this_leaf->shared_cpu_map); | ||
522 | } | ||
522 | } | 523 | } |
523 | return; | 524 | return; |
524 | } | 525 | } |