Read max number of cpus from VM.
authorKevin O'Connor <kevin@koconnor.net>
Fri, 9 Oct 2009 02:13:15 +0000 (22:13 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Fri, 9 Oct 2009 02:13:15 +0000 (22:13 -0400)
Signed-off-by: Gleb Natapov <gleb@redhat.com>
src/paravirt.c
src/paravirt.h
src/smp.c
src/util.h

index 8fbeb9cf3ce4be0868e23edac7f939a028f17aa8..da5923bd6486330f4c8257bcc88695bf23a3dc80 100644 (file)
@@ -281,3 +281,15 @@ void qemu_cfg_get_numa_data(u64 *data, int n)
     for (i = 0; i < n; i++)
         qemu_cfg_read((u8*)(data + i), sizeof(u64));
 }
+
+u16 qemu_cfg_get_max_cpus(void)
+{
+    u16 cnt;
+
+    if (!qemu_cfg_present)
+        return 0;
+
+    qemu_cfg_read_entry(&cnt, QEMU_CFG_MAX_CPUS, sizeof(cnt));
+
+    return cnt;
+}
index 04a6907f739c0f46839a00b539810d3a7d324993..a3f9be4d3c77097355e2eefaf453b34e7c23fe05 100644 (file)
@@ -51,5 +51,6 @@ int qemu_cfg_smbios_load_external(int type, char **p, unsigned *nr_structs,
                                   unsigned *max_struct_size, char *end);
 int qemu_cfg_get_numa_nodes(void);
 void qemu_cfg_get_numa_data(u64 *data, int n);
+u16 qemu_cfg_get_max_cpus(void);
 
 #endif
index 44a7929b743e471d05f674e877da81c8cd2cae1d..687947293b38e953901dfe4bdf7da269c4292571 100644 (file)
--- a/src/smp.c
+++ b/src/smp.c
@@ -9,6 +9,7 @@
 #include "config.h" // CONFIG_*
 #include "cmos.h" // CMOS_BIOS_SMP_COUNT
 #include "farptr.h" // ASSERT32
+#include "paravirt.h"
 
 #define APIC_ICR_LOW ((u8*)BUILD_APIC_ADDR + 0x300)
 #define APIC_SVR     ((u8*)BUILD_APIC_ADDR + 0x0F0)
@@ -61,6 +62,7 @@ wrmsr_smp(u32 index, u64 val)
 }
 
 u32 CountCPUs VAR16VISIBLE;
+u32 MaxCountCPUs VAR16VISIBLE;
 extern void smp_ap_boot_code();
 ASM16(
     "  .global smp_ap_boot_code\n"
@@ -134,7 +136,12 @@ smp_probe(void)
     // Restore memory.
     *(u64*)BUILD_AP_BOOT_ADDR = old;
 
-    dprintf(1, "Found %d cpu(s)\n", readl(&CountCPUs));
+    MaxCountCPUs = qemu_cfg_get_max_cpus();
+    if (!MaxCountCPUs || MaxCountCPUs < CountCPUs)
+        MaxCountCPUs = CountCPUs;
+
+    dprintf(1, "Found %d cpu(s) max supported %d cpu(s)\n", readl(&CountCPUs),
+        MaxCountCPUs);
 }
 
 // Reset variables to zero
index ca16ac77186247667a5ad799785920ce9e35dac4..401e6ea9fc19dfd2e57fb3fa8f50cd95724d5a4b 100644 (file)
@@ -221,6 +221,7 @@ void smm_init();
 
 // smp.c
 extern u32 CountCPUs;
+extern u32 MaxCountCPUs;
 void wrmsr_smp(u32 index, u64 val);
 void smp_probe(void);
 void smp_probe_setup(void);