public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] passing smp cpu count from CMOS
@ 2007-09-10  3:00 He, Qing
       [not found] ` <37E52D09333DE2469A03574C88DBF40FA9C219-wq7ZOvIWXbM/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: He, Qing @ 2007-09-10  3:00 UTC (permalink / raw)
  To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

[-- Attachment #1: Type: text/plain, Size: 2756 bytes --]

As discussed previously, this patch directly passes SMP CPU count to the
guest BIOS from CMOS by qemu, instead of sending SIPI and wait. CMOS
offset 0x7f is used.

This is the last functional piece for in-kernel APIC merge in kvm-37.

Signed-off-by: Qing He <qing.he-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>


bios/BIOS-bochs-latest |  Bin
 bios/BIOS-bochs-legacy |  Bin
 bios/rombios32.c       |    7 +++++++
 qemu/hw/mc146818rtc.c  |    6 ++++++
 qemu/pc-bios/bios.bin  |  Bin
 5 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/bios/BIOS-bochs-latest b/bios/BIOS-bochs-latest
index eb76dc7..99b78bf 100644
Binary files a/bios/BIOS-bochs-latest and b/bios/BIOS-bochs-latest
differ
diff --git a/bios/BIOS-bochs-legacy b/bios/BIOS-bochs-legacy
index f5947f6..423ea50 100644
Binary files a/bios/BIOS-bochs-legacy and b/bios/BIOS-bochs-legacy
differ
diff --git a/bios/rombios32.c b/bios/rombios32.c
index faf771e..3bb5e00 100755
--- a/bios/rombios32.c
+++ b/bios/rombios32.c
@@ -41,6 +41,9 @@ typedef unsigned long long uint64_t;
 /* define it if the (emulated) hardware supports SMM mode */
 #define BX_USE_SMM
 
+/* read CPU count from CMOS directly instead of probing */
+#define BX_CMOS_CPU_COUNT
+
 #define cpuid(index, eax, ebx, ecx, edx) \
   asm volatile ("cpuid" \
                 : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) \
@@ -442,9 +445,13 @@ void smp_probe(void)
         sipi_vector = AP_BOOT_ADDR >> 12;
         writel(APIC_BASE + APIC_ICR_LOW, 0x000C4600 | sipi_vector);
         
+#ifdef BX_CMOS_CPU_COUNT
+        smp_cpus = cmos_readb(0x7f);
+#else
         delay_ms(10);
 
         smp_cpus = readw((void *)CPU_COUNT_ADDR);
+#endif
     }
     BX_INFO("Found %d cpu(s)\n", smp_cpus);
 }
diff --git a/qemu/hw/mc146818rtc.c b/qemu/hw/mc146818rtc.c
index bad4cbd..3c4c25d 100644
--- a/qemu/hw/mc146818rtc.c
+++ b/qemu/hw/mc146818rtc.c
@@ -33,6 +33,9 @@
 #define RTC_HOURS_ALARM         5
 #define RTC_ALARM_DONT_CARE    0xC0
 
+/* KVM specific extension: smp cpu count passing */
+#define RTC_CMOS_CPU_COUNT     0x7f
+
 #define RTC_DAY_OF_WEEK         6
 #define RTC_DAY_OF_MONTH        7
 #define RTC_MONTH               8
@@ -356,6 +359,9 @@ static uint32_t cmos_ioport_read(void *opaque,
uint32_t addr)
             pic_set_irq(s->irq, 0);
             s->cmos_data[RTC_REG_C] = 0x00; 
             break;
+        case RTC_CMOS_CPU_COUNT:
+            ret = smp_cpus;
+            break;
         default:
             ret = s->cmos_data[s->cmos_index];
             break;
diff --git a/qemu/pc-bios/bios.bin b/qemu/pc-bios/bios.bin
index eb76dc7..99b78bf 100644
Binary files a/qemu/pc-bios/bios.bin and b/qemu/pc-bios/bios.bin differ

[-- Attachment #2: bios-cmos-cpus-passing.patch --]
[-- Type: application/octet-stream, Size: 2367 bytes --]

 bios/BIOS-bochs-latest |  Bin
 bios/BIOS-bochs-legacy |  Bin
 bios/rombios32.c       |    7 +++++++
 qemu/hw/mc146818rtc.c  |    6 ++++++
 qemu/pc-bios/bios.bin  |  Bin
 5 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/bios/BIOS-bochs-latest b/bios/BIOS-bochs-latest
index eb76dc7..99b78bf 100644
Binary files a/bios/BIOS-bochs-latest and b/bios/BIOS-bochs-latest differ
diff --git a/bios/BIOS-bochs-legacy b/bios/BIOS-bochs-legacy
index f5947f6..423ea50 100644
Binary files a/bios/BIOS-bochs-legacy and b/bios/BIOS-bochs-legacy differ
diff --git a/bios/rombios32.c b/bios/rombios32.c
index faf771e..3bb5e00 100755
--- a/bios/rombios32.c
+++ b/bios/rombios32.c
@@ -41,6 +41,9 @@ typedef unsigned long long uint64_t;
 /* define it if the (emulated) hardware supports SMM mode */
 #define BX_USE_SMM
 
+/* read CPU count from CMOS directly instead of probing */
+#define BX_CMOS_CPU_COUNT
+
 #define cpuid(index, eax, ebx, ecx, edx) \
   asm volatile ("cpuid" \
                 : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) \
@@ -442,9 +445,13 @@ void smp_probe(void)
         sipi_vector = AP_BOOT_ADDR >> 12;
         writel(APIC_BASE + APIC_ICR_LOW, 0x000C4600 | sipi_vector);
         
+#ifdef BX_CMOS_CPU_COUNT
+        smp_cpus = cmos_readb(0x7f);
+#else
         delay_ms(10);
 
         smp_cpus = readw((void *)CPU_COUNT_ADDR);
+#endif
     }
     BX_INFO("Found %d cpu(s)\n", smp_cpus);
 }
diff --git a/qemu/hw/mc146818rtc.c b/qemu/hw/mc146818rtc.c
index bad4cbd..3c4c25d 100644
--- a/qemu/hw/mc146818rtc.c
+++ b/qemu/hw/mc146818rtc.c
@@ -33,6 +33,9 @@
 #define RTC_HOURS_ALARM         5
 #define RTC_ALARM_DONT_CARE    0xC0
 
+/* KVM specific extension: smp cpu count passing */
+#define RTC_CMOS_CPU_COUNT     0x7f
+
 #define RTC_DAY_OF_WEEK         6
 #define RTC_DAY_OF_MONTH        7
 #define RTC_MONTH               8
@@ -356,6 +359,9 @@ static uint32_t cmos_ioport_read(void *opaque, uint32_t addr)
             pic_set_irq(s->irq, 0);
             s->cmos_data[RTC_REG_C] = 0x00; 
             break;
+        case RTC_CMOS_CPU_COUNT:
+            ret = smp_cpus;
+            break;
         default:
             ret = s->cmos_data[s->cmos_index];
             break;
diff --git a/qemu/pc-bios/bios.bin b/qemu/pc-bios/bios.bin
index eb76dc7..99b78bf 100644
Binary files a/qemu/pc-bios/bios.bin and b/qemu/pc-bios/bios.bin differ

[-- Attachment #3: Type: text/plain, Size: 228 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

[-- Attachment #4: Type: text/plain, Size: 186 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-09-11  0:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-10  3:00 [PATCH] passing smp cpu count from CMOS He, Qing
     [not found] ` <37E52D09333DE2469A03574C88DBF40FA9C219-wq7ZOvIWXbM/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-09-10  8:00   ` Avi Kivity
     [not found]     ` <46E4F990.4070507-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-09-10 12:47       ` Avi Kivity
     [not found]         ` <46E53CFD.8070108-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-09-11  0:12           ` Dong, Eddie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox