mptable - use the table's cpu_flags
authorAlex Hornung <alex@alexhornung.com>
Sun, 29 Jul 2012 15:28:00 +0000 (15:28 +0000)
committerAlex Hornung <alex@alexhornung.com>
Sun, 29 Jul 2012 15:56:12 +0000 (15:56 +0000)
 * Sometimes the CPUs are marked as disabled in the APIC table, and for
   good reason (e.g. a machine having only 24 cores, but 32 appearing in
   the APIC table, 8 of them disabled).

 * Just in case, provide an override that falls back to the old
   behaviour. This is the tunable hw.lapic_force_enable. It will force
   all lapic entries to be marked as enabled. It is however not the
   default.

 * When parsing, don't error out when a lapic id is invalid (255) but it
   is disabled.

Reported-by: Mihai Carabas, Francois Tigeot
sys/platform/pc32/acpica5/acpi_madt.c
sys/platform/pc32/i386/mptable.c
sys/platform/pc64/acpica5/acpi_madt.c
sys/platform/pc64/x86_64/mptable.c

index b7c3097..fa03da7 100644 (file)
@@ -393,13 +393,14 @@ madt_lapic_probe_callback(void *xarg, const struct acpi_madt_ent *ent)
                const struct acpi_madt_lapic *lapic_ent;
 
                lapic_ent = (const struct acpi_madt_lapic *)ent;
-               if (lapic_ent->ml_flags & MADT_LAPIC_ENABLED)
+               if (lapic_ent->ml_flags & MADT_LAPIC_ENABLED) {
                        arg->cpu_count++;
-               if (lapic_ent->ml_apic_id == APICID_MAX) {
-                       kprintf("madt_lapic_probe: "
-                           "invalid LAPIC apic id %d\n",
-                           lapic_ent->ml_apic_id);
-                       return EINVAL;
+                       if (lapic_ent->ml_apic_id == APICID_MAX) {
+                               kprintf("madt_lapic_probe: "
+                                   "invalid LAPIC apic id %d\n",
+                                   lapic_ent->ml_apic_id);
+                               return EINVAL;
+                       }
                }
        } else if (ent->me_type == MADT_ENT_LAPIC_ADDR) {
                const struct acpi_madt_lapic_addr *lapic_addr_ent;
index 5076266..745adee 100644 (file)
@@ -77,6 +77,9 @@ extern u_int  base_memory;
 extern int     imcr_present;
 extern int     naps;
 
+static int     force_enable = 0;
+TUNABLE_INT("hw.lapic_force_enable", &force_enable);
+
 #define BIOS_BASE              (0xf0000)
 #define BIOS_BASE2             (0xe0000)
 #define BIOS_SIZE              (0x10000)
@@ -701,7 +704,7 @@ mptable_lapic_pass2_callback(void *xarg, const void *pos, int type)
                 */
                bzero(&proc, sizeof(proc));
                proc.type = 0;
-               proc.cpu_flags = PROCENTRY_FLAG_EN;
+               proc.cpu_flags = (force_enable) ? PROCENTRY_FLAG_EN : ent->cpu_flags;
                proc.apic_id = ent->apic_id;
 
                for (i = 1; i < arg->logical_cpus; i++) {
index f1a7172..5c3d74a 100644 (file)
@@ -393,13 +393,14 @@ madt_lapic_probe_callback(void *xarg, const struct acpi_madt_ent *ent)
                const struct acpi_madt_lapic *lapic_ent;
 
                lapic_ent = (const struct acpi_madt_lapic *)ent;
-               if (lapic_ent->ml_flags & MADT_LAPIC_ENABLED)
+               if (lapic_ent->ml_flags & MADT_LAPIC_ENABLED) {
                        arg->cpu_count++;
-               if (lapic_ent->ml_apic_id == APICID_MAX) {
-                       kprintf("madt_lapic_probe: "
-                           "invalid LAPIC apic id %d\n",
-                           lapic_ent->ml_apic_id);
-                       return EINVAL;
+                       if (lapic_ent->ml_apic_id == APICID_MAX) {
+                               kprintf("madt_lapic_probe: "
+                                   "invalid LAPIC apic id %d\n",
+                                   lapic_ent->ml_apic_id);
+                               return EINVAL;
+                       }
                }
        } else if (ent->me_type == MADT_ENT_LAPIC_ADDR) {
                const struct acpi_madt_lapic_addr *lapic_addr_ent;
index 92eb052..088bee6 100644 (file)
@@ -77,6 +77,9 @@ extern u_long ebda_addr;
 extern int     imcr_present;
 extern int     naps;
 
+static int     force_enable = 0;
+TUNABLE_INT("hw.lapic_force_enable", &force_enable);
+
 #define BIOS_BASE              (0xf0000)
 #define BIOS_BASE2             (0xe0000)
 #define BIOS_SIZE              (0x10000)
@@ -702,7 +705,7 @@ mptable_lapic_pass2_callback(void *xarg, const void *pos, int type)
                 */
                bzero(&proc, sizeof(proc));
                proc.type = 0;
-               proc.cpu_flags = PROCENTRY_FLAG_EN;
+               proc.cpu_flags = (force_enable) ? PROCENTRY_FLAG_EN : ent->cpu_flags;
                proc.apic_id = ent->apic_id;
 
                for (i = 1; i < arg->logical_cpus; i++) {