qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 19/21] Read max number of cpus from VM.


From: Gleb Natapov
Subject: [Qemu-devel] [PATCH 19/21] Read max number of cpus from VM.
Date: Thu, 8 Oct 2009 17:59:24 +0200

Signed-off-by: Gleb Natapov <address@hidden>
---
 src/paravirt.c |   12 ++++++++++++
 src/paravirt.h |    1 +
 src/smp.c      |    9 ++++++++-
 src/util.h     |    1 +
 4 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/src/paravirt.c b/src/paravirt.c
index 8fbeb9c..da5923b 100644
--- a/src/paravirt.c
+++ b/src/paravirt.c
@@ -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;
+}
diff --git a/src/paravirt.h b/src/paravirt.h
index 04a6907..a3f9be4 100644
--- a/src/paravirt.h
+++ b/src/paravirt.h
@@ -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
diff --git a/src/smp.c b/src/smp.c
index 44a7929..6879472 100644
--- 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
diff --git a/src/util.h b/src/util.h
index ca16ac7..401e6ea 100644
--- a/src/util.h
+++ b/src/util.h
@@ -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);
-- 
1.6.3.3





reply via email to

[Prev in Thread] Current Thread [Next in Thread]