Commit 3408fef7 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 fixes from Ingo Molnar:
 "An initrd microcode loading fix, and an SMP bootup topology setup fix
  to resolve crashes on SGI/UV systems if the BIOS is configured in a
  certain way"

* 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/smp: Fix __max_logical_packages value setup
  x86/microcode/AMD: Fix initrd loading with CONFIG_RANDOMIZE_MEMORY=y
parents b061b4f3 7b0501b1
...@@ -355,6 +355,7 @@ void load_ucode_amd_ap(void) ...@@ -355,6 +355,7 @@ void load_ucode_amd_ap(void)
unsigned int cpu = smp_processor_id(); unsigned int cpu = smp_processor_id();
struct equiv_cpu_entry *eq; struct equiv_cpu_entry *eq;
struct microcode_amd *mc; struct microcode_amd *mc;
u8 *cont = container;
u32 rev, eax; u32 rev, eax;
u16 eq_id; u16 eq_id;
...@@ -371,8 +372,11 @@ void load_ucode_amd_ap(void) ...@@ -371,8 +372,11 @@ void load_ucode_amd_ap(void)
if (check_current_patch_level(&rev, false)) if (check_current_patch_level(&rev, false))
return; return;
/* Add CONFIG_RANDOMIZE_MEMORY offset. */
cont += PAGE_OFFSET - __PAGE_OFFSET_BASE;
eax = cpuid_eax(0x00000001); eax = cpuid_eax(0x00000001);
eq = (struct equiv_cpu_entry *)(container + CONTAINER_HDR_SZ); eq = (struct equiv_cpu_entry *)(cont + CONTAINER_HDR_SZ);
eq_id = find_equiv_id(eq, eax); eq_id = find_equiv_id(eq, eax);
if (!eq_id) if (!eq_id)
...@@ -434,6 +438,9 @@ int __init save_microcode_in_initrd_amd(void) ...@@ -434,6 +438,9 @@ int __init save_microcode_in_initrd_amd(void)
else else
container = cont_va; container = cont_va;
/* Add CONFIG_RANDOMIZE_MEMORY offset. */
container += PAGE_OFFSET - __PAGE_OFFSET_BASE;
eax = cpuid_eax(0x00000001); eax = cpuid_eax(0x00000001);
eax = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff); eax = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
......
...@@ -100,10 +100,11 @@ EXPORT_PER_CPU_SYMBOL(cpu_info); ...@@ -100,10 +100,11 @@ EXPORT_PER_CPU_SYMBOL(cpu_info);
/* Logical package management. We might want to allocate that dynamically */ /* Logical package management. We might want to allocate that dynamically */
static int *physical_to_logical_pkg __read_mostly; static int *physical_to_logical_pkg __read_mostly;
static unsigned long *physical_package_map __read_mostly;; static unsigned long *physical_package_map __read_mostly;;
static unsigned long *logical_package_map __read_mostly;
static unsigned int max_physical_pkg_id __read_mostly; static unsigned int max_physical_pkg_id __read_mostly;
unsigned int __max_logical_packages __read_mostly; unsigned int __max_logical_packages __read_mostly;
EXPORT_SYMBOL(__max_logical_packages); EXPORT_SYMBOL(__max_logical_packages);
static unsigned int logical_packages __read_mostly;
static bool logical_packages_frozen __read_mostly;
/* Maximum number of SMT threads on any online core */ /* Maximum number of SMT threads on any online core */
int __max_smt_threads __read_mostly; int __max_smt_threads __read_mostly;
...@@ -277,14 +278,14 @@ int topology_update_package_map(unsigned int apicid, unsigned int cpu) ...@@ -277,14 +278,14 @@ int topology_update_package_map(unsigned int apicid, unsigned int cpu)
if (test_and_set_bit(pkg, physical_package_map)) if (test_and_set_bit(pkg, physical_package_map))
goto found; goto found;
new = find_first_zero_bit(logical_package_map, __max_logical_packages); if (logical_packages_frozen) {
if (new >= __max_logical_packages) {
physical_to_logical_pkg[pkg] = -1; physical_to_logical_pkg[pkg] = -1;
pr_warn("APIC(%x) Package %u exceeds logical package map\n", pr_warn("APIC(%x) Package %u exceeds logical package max\n",
apicid, pkg); apicid, pkg);
return -ENOSPC; return -ENOSPC;
} }
set_bit(new, logical_package_map);
new = logical_packages++;
pr_info("APIC(%x) Converting physical %u to logical package %u\n", pr_info("APIC(%x) Converting physical %u to logical package %u\n",
apicid, pkg, new); apicid, pkg, new);
physical_to_logical_pkg[pkg] = new; physical_to_logical_pkg[pkg] = new;
...@@ -341,6 +342,7 @@ static void __init smp_init_package_map(void) ...@@ -341,6 +342,7 @@ static void __init smp_init_package_map(void)
} }
__max_logical_packages = DIV_ROUND_UP(total_cpus, ncpus); __max_logical_packages = DIV_ROUND_UP(total_cpus, ncpus);
logical_packages = 0;
/* /*
* Possibly larger than what we need as the number of apic ids per * Possibly larger than what we need as the number of apic ids per
...@@ -352,10 +354,6 @@ static void __init smp_init_package_map(void) ...@@ -352,10 +354,6 @@ static void __init smp_init_package_map(void)
memset(physical_to_logical_pkg, 0xff, size); memset(physical_to_logical_pkg, 0xff, size);
size = BITS_TO_LONGS(max_physical_pkg_id) * sizeof(unsigned long); size = BITS_TO_LONGS(max_physical_pkg_id) * sizeof(unsigned long);
physical_package_map = kzalloc(size, GFP_KERNEL); physical_package_map = kzalloc(size, GFP_KERNEL);
size = BITS_TO_LONGS(__max_logical_packages) * sizeof(unsigned long);
logical_package_map = kzalloc(size, GFP_KERNEL);
pr_info("Max logical packages: %u\n", __max_logical_packages);
for_each_present_cpu(cpu) { for_each_present_cpu(cpu) {
unsigned int apicid = apic->cpu_present_to_apicid(cpu); unsigned int apicid = apic->cpu_present_to_apicid(cpu);
...@@ -369,6 +367,15 @@ static void __init smp_init_package_map(void) ...@@ -369,6 +367,15 @@ static void __init smp_init_package_map(void)
set_cpu_possible(cpu, false); set_cpu_possible(cpu, false);
set_cpu_present(cpu, false); set_cpu_present(cpu, false);
} }
if (logical_packages > __max_logical_packages) {
pr_warn("Detected more packages (%u), then computed by BIOS data (%u).\n",
logical_packages, __max_logical_packages);
logical_packages_frozen = true;
__max_logical_packages = logical_packages;
}
pr_info("Max logical packages: %u\n", __max_logical_packages);
} }
void __init smp_store_boot_cpu_info(void) void __init smp_store_boot_cpu_info(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment