}
 
 /*
- * The physical to logical package id mapping is initialized from the
- * acpi/mptables information. Make sure that CPUID actually agrees with
- * that.
+ * Validate that ACPI/mptables have the same information about the
+ * effective APIC id and update the package map.
  */
-static void sanitize_package_id(struct cpuinfo_x86 *c)
+static void validate_apic_and_package_id(struct cpuinfo_x86 *c)
 {
 #ifdef CONFIG_SMP
-       unsigned int pkg, apicid, cpu = smp_processor_id();
+       unsigned int apicid, cpu = smp_processor_id();
 
        apicid = apic->cpu_present_to_apicid(cpu);
-       pkg = apicid >> boot_cpu_data.x86_coreid_bits;
 
-       if (apicid != c->initial_apicid) {
-               pr_err(FW_BUG "CPU%u: APIC id mismatch. Firmware: %x CPUID: %x\n",
+       if (apicid != c->apicid) {
+               pr_err(FW_BUG "CPU%u: APIC id mismatch. Firmware: %x APIC: %x\n",
                       cpu, apicid, c->initial_apicid);
-               c->initial_apicid = apicid;
        }
-       if (pkg != c->phys_proc_id) {
-               pr_err(FW_BUG "CPU%u: Using firmware package id %u instead of %u\n",
-                      cpu, pkg, c->phys_proc_id);
-               c->phys_proc_id = pkg;
-       }
-       c->logical_proc_id = topology_phys_to_logical_pkg(pkg);
+       BUG_ON(topology_update_package_map(c->phys_proc_id, cpu));
 #else
        c->logical_proc_id = 0;
 #endif
 #ifdef CONFIG_NUMA
        numa_add_cpu(smp_processor_id());
 #endif
-       sanitize_package_id(c);
 }
 
 /*
        enable_sep_cpu();
 #endif
        mtrr_ap_init();
+       validate_apic_and_package_id(c);
 }
 
 static __init int setup_noclflush(char *arg)
 
 unsigned int __max_logical_packages __read_mostly;
 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 */
 int __max_smt_threads __read_mostly;
        cpu_startup_entry(CPUHP_AP_ONLINE_IDLE);
 }
 
-int topology_update_package_map(unsigned int apicid, unsigned int cpu)
+/**
+ * topology_update_package_map - Update the physical to logical package map
+ * @pkg:       The physical package id as retrieved via CPUID
+ * @cpu:       The cpu for which this is updated
+ */
+int topology_update_package_map(unsigned int pkg, unsigned int cpu)
 {
-       unsigned int new, pkg = apicid >> boot_cpu_data.x86_coreid_bits;
+       unsigned int new;
 
        /* Called from early boot ? */
        if (!physical_package_map)
        if (test_and_set_bit(pkg, physical_package_map))
                goto found;
 
-       if (logical_packages_frozen) {
-               physical_to_logical_pkg[pkg] = -1;
-               pr_warn("APIC(%x) Package %u exceeds logical package max\n",
-                       apicid, pkg);
+       if (logical_packages >= __max_logical_packages) {
+               pr_warn("Package %u of CPU %u exceeds BIOS package data %u.\n",
+                       logical_packages, cpu, __max_logical_packages);
                return -ENOSPC;
        }
 
        new = logical_packages++;
-       pr_info("APIC(%x) Converting physical %u to logical package %u\n",
-               apicid, pkg, new);
+       if (new != pkg) {
+               pr_info("CPU %u Converting physical %u to logical package %u\n",
+                       cpu, pkg, new);
+       }
        physical_to_logical_pkg[pkg] = new;
 
 found:
 }
 EXPORT_SYMBOL(topology_phys_to_logical_pkg);
 
-static void __init smp_init_package_map(void)
+static void __init smp_init_package_map(struct cpuinfo_x86 *c, unsigned int cpu)
 {
-       unsigned int ncpus, cpu;
+       unsigned int ncpus;
        size_t size;
 
        /*
        size = BITS_TO_LONGS(max_physical_pkg_id) * sizeof(unsigned long);
        physical_package_map = kzalloc(size, GFP_KERNEL);
 
-       for_each_present_cpu(cpu) {
-               unsigned int apicid = apic->cpu_present_to_apicid(cpu);
-
-               if (apicid == BAD_APICID || !apic->apic_id_valid(apicid))
-                       continue;
-               if (!topology_update_package_map(apicid, cpu))
-                       continue;
-               pr_warn("CPU %u APICId %x disabled\n", cpu, apicid);
-               per_cpu(x86_bios_cpu_apicid, cpu) = BAD_APICID;
-               set_cpu_possible(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);
+
+       topology_update_package_map(c->phys_proc_id, cpu);
 }
 
 void __init smp_store_boot_cpu_info(void)
 
        *c = boot_cpu_data;
        c->cpu_index = id;
-       smp_init_package_map();
+       smp_init_package_map(c, id);
 }
 
 /*