qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/15] acpi processor hotplug
@ 2008-02-26 19:56 Glauber Costa
  2008-02-26 19:56 ` [Qemu-devel] [PATCH 1/15] Make a GPE register block be acessible Glauber Costa
  2008-02-27 10:55 ` [Qemu-devel] Re: [kvm-devel] [PATCH 0/15] acpi processor hotplug Avi Kivity
  0 siblings, 2 replies; 19+ messages in thread
From: Glauber Costa @ 2008-02-26 19:56 UTC (permalink / raw)
  To: kvm-devel; +Cc: marcelo, glommer, qemu-devel, chrisw

Hi,

I'm resending the series with avi's few comments merged, and a couple
of others on my own:

* _STA returns 0xF instead of 0x1. According to the specification, it means
  that the device, besides present, is also functional, enabled, and a couple
  of other cool things.
* gpe_base and proc_base as #defines, not unsigned long
* _EJ method out. It's causing a lot of troubles, and I'm not even sure it
  makes sense for processors. We can live without it by now, and if it is needed,
  it can be added later.

Have a safe trip back home,

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

* [Qemu-devel] [PATCH 1/15] Make a GPE register block be acessible.
  2008-02-26 19:56 [Qemu-devel] [PATCH 0/15] acpi processor hotplug Glauber Costa
@ 2008-02-26 19:56 ` Glauber Costa
  2008-02-26 19:56   ` [Qemu-devel] [PATCH 2/15] mark extra cpus as present Glauber Costa
  2008-02-27 10:55 ` [Qemu-devel] Re: [kvm-devel] [PATCH 0/15] acpi processor hotplug Avi Kivity
  1 sibling, 1 reply; 19+ messages in thread
From: Glauber Costa @ 2008-02-26 19:56 UTC (permalink / raw)
  To: kvm-devel; +Cc: marcelo, glommer, qemu-devel, Glauber Costa, chrisw

gpe is acessible when its address listed by BIOS is !0.
This patch makes gpe blk 0 available, and 4 bytes in length

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
 bios/rombios32.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/bios/rombios32.c b/bios/rombios32.c
index 5365b5f..3ec85cb 100755
--- a/bios/rombios32.c
+++ b/bios/rombios32.c
@@ -1441,6 +1441,8 @@ #endif
     fadt->pm_tmr_len = 4;
     fadt->plvl2_lat = cpu_to_le16(0x0fff); // C2 state not supported
     fadt->plvl3_lat = cpu_to_le16(0x0fff); // C3 state not supported
+    fadt->gpe0_blk = cpu_to_le32(0xafe0);
+    fadt->gpe0_blk_len = 4;
     /* WBINVD + PROC_C1 + SLP_BUTTON + FIX_RTC */
     fadt->flags = cpu_to_le32((1 << 0) | (1 << 2) | (1 << 5) | (1 << 6));
     acpi_build_table_header((struct acpi_table_header *)fadt, "FACP",
-- 
1.4.2

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

* [Qemu-devel] [PATCH 2/15] mark extra cpus as present
  2008-02-26 19:56 ` [Qemu-devel] [PATCH 1/15] Make a GPE register block be acessible Glauber Costa
@ 2008-02-26 19:56   ` Glauber Costa
  2008-02-26 19:56     ` [Qemu-devel] [PATCH 3/15] introduce cpu_set to qemu monitor Glauber Costa
  0 siblings, 1 reply; 19+ messages in thread
From: Glauber Costa @ 2008-02-26 19:56 UTC (permalink / raw)
  To: kvm-devel; +Cc: marcelo, glommer, qemu-devel, Glauber Costa, chrisw

Mark cpus over smp_cpus as present, but disable.
The OS can then recognize it and make room for future hotplug

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
 bios/rombios.h   |    2 ++
 bios/rombios32.c |   21 +++++++++++++--------
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/bios/rombios.h b/bios/rombios.h
index 412c5e9..2cf2bb3 100644
--- a/bios/rombios.h
+++ b/bios/rombios.h
@@ -58,6 +58,8 @@ #define PM_IO_BASE        0xb000
 #define SMB_IO_BASE       0xb100
 #define CPU_COUNT_ADDR    0xf000
 
+#define MAX_CPUS 16
+
   // Define the application NAME
 #if defined(BX_QEMU)
 #  define BX_APPNAME "QEMU"
diff --git a/bios/rombios32.c b/bios/rombios32.c
index 3ec85cb..f2db740 100755
--- a/bios/rombios32.c
+++ b/bios/rombios32.c
@@ -948,20 +948,22 @@ #endif
     putstr(&q, "0.1         "); /* vendor id */
     putle32(&q, 0); /* OEM table ptr */
     putle16(&q, 0); /* OEM table size */
-    putle16(&q, smp_cpus + 18); /* entry count */
+    putle16(&q, MAX_CPUS + 18); /* entry count */
     putle32(&q, 0xfee00000); /* local APIC addr */
     putle16(&q, 0); /* ext table length */
     putb(&q, 0); /* ext table checksum */
     putb(&q, 0); /* reserved */
 
-    for(i = 0; i < smp_cpus; i++) {
+    for(i = 0; i < MAX_CPUS ; i++) {
         putb(&q, 0); /* entry type = processor */
         putb(&q, i); /* APIC id */
         putb(&q, 0x11); /* local APIC version number */
         if (i == 0)
             putb(&q, 3); /* cpu flags: enabled, bootstrap cpu */
-        else
+        else if ( i < smp_cpus)
             putb(&q, 1); /* cpu flags: enabled */
+        else
+            putb(&q, 0); /* cpu flags: disabled */
         putb(&q, 0); /* cpu signature */
         putb(&q, 6);
         putb(&q, 0);
@@ -981,7 +983,7 @@ #endif
     putstr(&q, "ISA   ");
 
     /* ioapic */
-    ioapic_id = smp_cpus;
+    ioapic_id = MAX_CPUS;
     putb(&q, 2); /* entry type = I/O APIC */
     putb(&q, ioapic_id); /* apic ID */
     putb(&q, 0x11); /* I/O APIC version number */
@@ -1393,7 +1395,7 @@ #endif
     addr = (addr + 7) & ~7;
     madt_addr = addr;
     madt_size = sizeof(*madt) +
-        sizeof(struct madt_processor_apic) * smp_cpus +
+        sizeof(struct madt_processor_apic) * MAX_CPUS +
         sizeof(struct madt_io_apic);
     madt = (void *)(addr);
     addr += madt_size;
@@ -1466,18 +1468,21 @@ #endif
         madt->local_apic_address = cpu_to_le32(0xfee00000);
         madt->flags = cpu_to_le32(1);
         apic = (void *)(madt + 1);
-        for(i=0;i<smp_cpus;i++) {
+        for(i=0;i<MAX_CPUS;i++) {
             apic->type = APIC_PROCESSOR;
             apic->length = sizeof(*apic);
             apic->processor_id = i;
             apic->local_apic_id = i;
-            apic->flags = cpu_to_le32(1);
+            if (i < smp_cpus)
+                apic->flags = cpu_to_le32(1);
+            else
+                apic->flags = 0;
             apic++;
         }
         io_apic = (void *)apic;
         io_apic->type = APIC_IO;
         io_apic->length = sizeof(*io_apic);
-        io_apic->io_apic_id = smp_cpus;
+        io_apic->io_apic_id = MAX_CPUS;
         io_apic->address = cpu_to_le32(0xfec00000);
         io_apic->interrupt = cpu_to_le32(0);
 
-- 
1.4.2

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

* [Qemu-devel] [PATCH 3/15] introduce cpu_set to qemu monitor
  2008-02-26 19:56   ` [Qemu-devel] [PATCH 2/15] mark extra cpus as present Glauber Costa
@ 2008-02-26 19:56     ` Glauber Costa
  2008-02-26 19:56       ` [Qemu-devel] [PATCH 4/15] mark processors as presents Glauber Costa
  0 siblings, 1 reply; 19+ messages in thread
From: Glauber Costa @ 2008-02-26 19:56 UTC (permalink / raw)
  To: kvm-devel; +Cc: marcelo, glommer, qemu-devel, Glauber Costa, chrisw

in this patch, cpu_set is introduced to qemu monitor

semantics is : cpu_set x online|offline.

it will then tell the acpi backend to signal cpu x.

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
 qemu/hw/acpi.c |    4 ++++
 qemu/monitor.c |   16 ++++++++++++++++
 qemu/sysemu.h  |    3 +++
 3 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/qemu/hw/acpi.c b/qemu/hw/acpi.c
index e21ded0..d2e2e3e 100644
--- a/qemu/hw/acpi.c
+++ b/qemu/hw/acpi.c
@@ -533,3 +533,7 @@ void qemu_system_powerdown(void)
     }
 }
 #endif
+
+void qemu_system_cpu_hot_add(int cpu, int state)
+{
+}
diff --git a/qemu/monitor.c b/qemu/monitor.c
index e8022c8..09f84a9 100644
--- a/qemu/monitor.c
+++ b/qemu/monitor.c
@@ -345,6 +345,21 @@ static void do_cpu_set(int index)
         term_printf("Invalid CPU index\n");
 }
 
+static void do_cpu_set_nr(int value, const char *status)
+{
+    int state;
+
+    if (!strcmp(status, "online"))
+       state = 1;
+    else if (!strcmp(status, "offline"))
+       state = 0;
+    else {
+       term_printf("invalid status: %s\n", status);
+       return;
+    }
+    qemu_system_cpu_hot_add(value, state);
+}
+
 static void do_info_jit(void)
 {
     dump_exec_info(NULL, monitor_fprintf);
@@ -1338,6 +1353,7 @@ #endif
       "", "cancel the current VM migration" },
     { "migrate_set_speed", "s", do_migrate_set_speed,
       "value", "set maximum speed (in bytes) for migrations" },
+    { "cpu_set", "is", do_cpu_set_nr, "cpu [online|offline]", "change cpu state" },
     { NULL, NULL, },
 };
 
diff --git a/qemu/sysemu.h b/qemu/sysemu.h
index ffc468a..fe929b4 100644
--- a/qemu/sysemu.h
+++ b/qemu/sysemu.h
@@ -153,6 +153,9 @@ int extboot_drive;
 extern int drive_get_index(BlockInterfaceType type, int bus, int unit);
 extern int drive_get_max_bus(BlockInterfaceType type);
 
+/* acpi */
+void qemu_system_cpu_hot_add(int cpu, int state);
+
 /* vmchannel devices */
 
 #define MAX_VMCHANNEL_DEVICES 4
-- 
1.4.2

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

* [Qemu-devel] [PATCH 4/15] mark processors as presents
  2008-02-26 19:56     ` [Qemu-devel] [PATCH 3/15] introduce cpu_set to qemu monitor Glauber Costa
@ 2008-02-26 19:56       ` Glauber Costa
  2008-02-26 19:56         ` [Qemu-devel] [PATCH 5/15] provide gpe _L0x methods Glauber Costa
  2008-02-26 23:05         ` [Qemu-devel] Re: [kvm-devel] [PATCH 4/15] mark processors as presents Alexander Graf
  0 siblings, 2 replies; 19+ messages in thread
From: Glauber Costa @ 2008-02-26 19:56 UTC (permalink / raw)
  To: kvm-devel; +Cc: marcelo, glommer, qemu-devel, Glauber Costa, chrisw

mark processors as present through the _STA method

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
 bios/acpi-dsdt.dsl |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/bios/acpi-dsdt.dsl b/bios/acpi-dsdt.dsl
index e900795..244e906 100755
--- a/bios/acpi-dsdt.dsl
+++ b/bios/acpi-dsdt.dsl
@@ -25,6 +25,24 @@ DefinitionBlock (
     0x1                 // OEM Revision
     )
 {
+   Scope (\_PR)
+   {
+        Processor (CPU0, 0x00, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
+        Processor (CPU1, 0x01, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
+        Processor (CPU2, 0x02, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
+        Processor (CPU3, 0x03, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
+        Processor (CPU4, 0x04, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
+        Processor (CPU5, 0x05, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
+        Processor (CPU6, 0x06, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
+        Processor (CPU7, 0x07, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
+        Processor (CPU8, 0x08, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
+        Processor (CPU9, 0x09, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
+        Processor (CPUA, 0x0a, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
+        Processor (CPUB, 0x0b, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
+        Processor (CPUC, 0x0c, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
+        Processor (CPUD, 0x0d, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
+        Processor (CPUE, 0x0e, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
+    }
 
     Scope (\)
     {
-- 
1.4.2

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

* [Qemu-devel] [PATCH 5/15] provide gpe _L0x methods
  2008-02-26 19:56       ` [Qemu-devel] [PATCH 4/15] mark processors as presents Glauber Costa
@ 2008-02-26 19:56         ` Glauber Costa
  2008-02-26 19:56           ` [Qemu-devel] [PATCH 6/15] provide operation region for pio to the gpes Glauber Costa
  2008-02-26 23:05         ` [Qemu-devel] Re: [kvm-devel] [PATCH 4/15] mark processors as presents Alexander Graf
  1 sibling, 1 reply; 19+ messages in thread
From: Glauber Costa @ 2008-02-26 19:56 UTC (permalink / raw)
  To: kvm-devel; +Cc: marcelo, glommer, qemu-devel, Glauber Costa, chrisw

provide methods for gpe blk 0, even though they do nothing atm

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
 bios/acpi-dsdt.dsl |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/bios/acpi-dsdt.dsl b/bios/acpi-dsdt.dsl
index 244e906..392d402 100755
--- a/bios/acpi-dsdt.dsl
+++ b/bios/acpi-dsdt.dsl
@@ -578,4 +578,55 @@ DefinitionBlock (
         0x00, // reserved
         0x00, // reserved
     })
+    Scope (\_GPE)
+    {
+        Method(_L00) {
+            Return(0x01)
+        }
+        Method(_L01) {
+            Return(0x01)
+        }
+        Method(_L02) {
+            Return(0x01)
+        }
+        Method(_L03) {
+            Return(0x01)
+        }
+        Method(_L04) {
+            Return(0x01)
+        }
+        Method(_L05) {
+            Return(0x01)
+        }
+        Method(_L06) {
+            Return(0x01)
+        }
+        Method(_L07) {
+            Return(0x01)
+        }
+        Method(_L08) {
+            Return(0x01)
+        }
+        Method(_L09) {
+            Return(0x01)
+        }
+        Method(_L0A) {
+            Return(0x01)
+        }
+        Method(_L0B) {
+            Return(0x01)
+        }
+        Method(_L0C) {
+            Return(0x01)
+        }
+        Method(_L0D) {
+            Return(0x01)
+        }
+        Method(_L0E) {
+            Return(0x01)
+        }
+        Method(_L0F) {
+            Return(0x01)
+        }
+    }
 }
-- 
1.4.2

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

* [Qemu-devel] [PATCH 6/15] provide operation region for pio to the gpes
  2008-02-26 19:56         ` [Qemu-devel] [PATCH 5/15] provide gpe _L0x methods Glauber Costa
@ 2008-02-26 19:56           ` Glauber Costa
  2008-02-26 19:56             ` [Qemu-devel] [PATCH 7/15] implement method _L00 for GPE0 Glauber Costa
  0 siblings, 1 reply; 19+ messages in thread
From: Glauber Costa @ 2008-02-26 19:56 UTC (permalink / raw)
  To: kvm-devel; +Cc: marcelo, glommer, qemu-devel, Glauber Costa, chrisw

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
 bios/acpi-dsdt.dsl |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/bios/acpi-dsdt.dsl b/bios/acpi-dsdt.dsl
index 392d402..1dba157 100755
--- a/bios/acpi-dsdt.dsl
+++ b/bios/acpi-dsdt.dsl
@@ -27,6 +27,13 @@ DefinitionBlock (
 {
    Scope (\_PR)
    {
+ 	OperationRegion( PRST, SystemIO, 0xaf00, 0x02)
+ 	Field (PRST, ByteAcc, NoLock, WriteAsZeros)
+ 	{
+ 		PRU, 8,
+ 		PRD, 8,
+ 	}
+
         Processor (CPU0, 0x00, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
         Processor (CPU1, 0x01, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
         Processor (CPU2, 0x02, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
-- 
1.4.2

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

* [Qemu-devel] [PATCH 7/15] implement method _L00 for GPE0
  2008-02-26 19:56           ` [Qemu-devel] [PATCH 6/15] provide operation region for pio to the gpes Glauber Costa
@ 2008-02-26 19:56             ` Glauber Costa
  2008-02-26 19:56               ` [Qemu-devel] [PATCH 8/15] isolate cpu initialization function in hw/pc.c Glauber Costa
  0 siblings, 1 reply; 19+ messages in thread
From: Glauber Costa @ 2008-02-26 19:56 UTC (permalink / raw)
  To: kvm-devel; +Cc: marcelo, glommer, qemu-devel, Glauber Costa, chrisw

This corresponds to the cpu hotplug functionality

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
 bios/acpi-dsdt.dsl |  114 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 114 insertions(+), 0 deletions(-)

diff --git a/bios/acpi-dsdt.dsl b/bios/acpi-dsdt.dsl
index 1dba157..194a051 100755
--- a/bios/acpi-dsdt.dsl
+++ b/bios/acpi-dsdt.dsl
@@ -588,6 +588,120 @@ DefinitionBlock (
     Scope (\_GPE)
     {
         Method(_L00) {
+            /* Up status */
+            If (And(\_PR.PRU, 0x2)) {
+                Notify(\_PR.CPU1,1)
+            }
+
+            If (And(\_PR.PRU, 0x4)) {
+                Notify(\_PR.CPU2,1)
+            }
+
+            If (And(\_PR.PRU, 0x8)) {
+                Notify(\_PR.CPU3,1)
+            }
+
+            If (And(\_PR.PRU, 0x10)) {
+                Notify(\_PR.CPU4,1)
+            }
+
+            If (And(\_PR.PRU, 0x20)) {
+                Notify(\_PR.CPU5,1)
+            }
+
+            If (And(\_PR.PRU, 0x40)) {
+                Notify(\_PR.CPU6,1)
+            }
+
+            If (And(\_PR.PRU, 0x80)) {
+                Notify(\_PR.CPU7,1)
+            }
+
+            If (And(\_PR.PRU, 0x100)) {
+                Notify(\_PR.CPU8,1)
+            }
+
+            If (And(\_PR.PRU, 0x200)) {
+                Notify(\_PR.CPU9,1)
+            }
+
+            If (And(\_PR.PRU, 0x400)) {
+                Notify(\_PR.CPUA,1)
+            }
+
+            If (And(\_PR.PRU, 0x800)) {
+                Notify(\_PR.CPUB,1)
+            }
+
+            If (And(\_PR.PRU, 0x1000)) {
+                Notify(\_PR.CPUC,1)
+            }
+
+            If (And(\_PR.PRU, 0x2000)) {
+                Notify(\_PR.CPUD,1)
+            }
+
+            If (And(\_PR.PRU, 0x4000)) {
+                Notify(\_PR.CPUE,1)
+            }
+
+            /* Down status */
+            If (And(\_PR.PRD, 0x2)) {
+                Notify(\_PR.CPU1,3)
+            }
+
+            If (And(\_PR.PRD, 0x4)) {
+                Notify(\_PR.CPU2,3)
+            }
+
+            If (And(\_PR.PRD, 0x8)) {
+                Notify(\_PR.CPU3,3)
+            }
+
+            If (And(\_PR.PRD, 0x10)) {
+                Notify(\_PR.CPU4,3)
+            }
+
+            If (And(\_PR.PRD, 0x20)) {
+                Notify(\_PR.CPU5,3)
+            }
+
+            If (And(\_PR.PRD, 0x40)) {
+                Notify(\_PR.CPU6,3)
+            }
+
+            If (And(\_PR.PRD, 0x80)) {
+                Notify(\_PR.CPU7,3)
+            }
+
+            If (And(\_PR.PRD, 0x100)) {
+                Notify(\_PR.CPU8,3)
+            }
+
+            If (And(\_PR.PRD, 0x200)) {
+                Notify(\_PR.CPU9,3)
+            }
+
+            If (And(\_PR.PRD, 0x400)) {
+                Notify(\_PR.CPUA,3)
+            }
+
+            If (And(\_PR.PRD, 0x800)) {
+                Notify(\_PR.CPUB,3)
+            }
+
+            If (And(\_PR.PRD, 0x1000)) {
+                Notify(\_PR.CPUC,3)
+            }
+
+            If (And(\_PR.PRD, 0x2000)) {
+                Notify(\_PR.CPUD,3)
+            }
+
+            If (And(\_PR.PRD, 0x4000)) {
+                Notify(\_PR.CPUE,3)
+            }
+
             Return(0x01)
         }
         Method(_L01) {
-- 
1.4.2

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

* [Qemu-devel] [PATCH 8/15] isolate cpu initialization function in hw/pc.c
  2008-02-26 19:56             ` [Qemu-devel] [PATCH 7/15] implement method _L00 for GPE0 Glauber Costa
@ 2008-02-26 19:56               ` Glauber Costa
  2008-02-26 19:56                 ` [Qemu-devel] [PATCH 9/15] initialize hot add system Glauber Costa
  0 siblings, 1 reply; 19+ messages in thread
From: Glauber Costa @ 2008-02-26 19:56 UTC (permalink / raw)
  To: kvm-devel; +Cc: marcelo, glommer, qemu-devel, Glauber Costa, chrisw

This patch wraps up the piece of code in hw/pc.c that
actually allocates and initializates a cpu. After that,
plan is to be able to start it later on.

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
 qemu/hw/pc.c |   40 +++++++++++++++++++++++-----------------
 qemu/hw/pc.h |    1 +
 2 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
index 77a7d53..982377d 100644
--- a/qemu/hw/pc.c
+++ b/qemu/hw/pc.c
@@ -740,6 +740,28 @@ static int load_option_rom(const char *f
     return size;
 }
 
+CPUState *pc_new_cpu(int cpu, const char *cpu_model, int pci_enabled)
+{
+        CPUState *env = cpu_init(cpu_model);
+        if (!env) {
+            fprintf(stderr, "Unable to find x86 CPU definition\n");
+            exit(1);
+        }
+        if (cpu != 0)
+            env->hflags |= HF_HALTED_MASK;
+        if (smp_cpus > 1) {
+            /* XXX: enable it in all cases */
+            env->cpuid_features |= CPUID_APIC;
+        }
+        register_savevm("cpu", cpu, 4, cpu_save, cpu_load, env);
+        qemu_register_reset(main_cpu_reset, env);
+        if (pci_enabled) {
+            apic_init(env);
+        }
+        vmport_init(env);
+	return env;
+}
+
 /* PC hardware initialisation */
 static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
                      const char *boot_device, DisplayState *ds,
@@ -779,23 +801,7 @@ #endif
     }
     
     for(i = 0; i < smp_cpus; i++) {
-        env = cpu_init(cpu_model);
-        if (!env) {
-            fprintf(stderr, "Unable to find x86 CPU definition\n");
-            exit(1);
-        }
-        if (i != 0)
-            env->hflags |= HF_HALTED_MASK;
-        if (smp_cpus > 1) {
-            /* XXX: enable it in all cases */
-            env->cpuid_features |= CPUID_APIC;
-        }
-        register_savevm("cpu", i, 4, cpu_save, cpu_load, env);
-        qemu_register_reset(main_cpu_reset, env);
-        if (pci_enabled) {
-            apic_init(env);
-        }
-        vmport_init(env);
+    	env = pc_new_cpu(i, cpu_model, pci_enabled);
     }
 
     /* allocate RAM */
diff --git a/qemu/hw/pc.h b/qemu/hw/pc.h
index f640395..f70ab55 100644
--- a/qemu/hw/pc.h
+++ b/qemu/hw/pc.h
@@ -85,6 +85,7 @@ extern int fd_bootchk;
 
 void ioport_set_a20(int enable);
 int ioport_get_a20(void);
+CPUState *pc_new_cpu(int cpu, const char *cpu_model, int pci_enabled);
 
 /* acpi.c */
 extern int acpi_enabled;
-- 
1.4.2

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

* [Qemu-devel] [PATCH 9/15] initialize hot add system.
  2008-02-26 19:56               ` [Qemu-devel] [PATCH 8/15] isolate cpu initialization function in hw/pc.c Glauber Costa
@ 2008-02-26 19:56                 ` Glauber Costa
  2008-02-26 19:56                   ` [Qemu-devel] [PATCH 10/15] handle gpe data for pio Glauber Costa
  0 siblings, 1 reply; 19+ messages in thread
From: Glauber Costa @ 2008-02-26 19:56 UTC (permalink / raw)
  To: kvm-devel; +Cc: marcelo, glommer, qemu-devel, Glauber Costa, chrisw

Register the pios, and grab cpu_model for future usage.

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
 qemu/hw/acpi.c |   34 ++++++++++++++++++++++++++++++++++
 qemu/hw/pc.c   |    1 +
 qemu/sysemu.h  |    1 +
 3 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/qemu/hw/acpi.c b/qemu/hw/acpi.c
index d2e2e3e..119b59a 100644
--- a/qemu/hw/acpi.c
+++ b/qemu/hw/acpi.c
@@ -533,6 +533,40 @@ void qemu_system_powerdown(void)
     }
 }
 #endif
+#define GPE_BASE 0xafe0
+
+struct gpe_regs {
+    uint16_t sts; /* status */
+    uint16_t en;  /* enabled */
+};
+
+static struct gpe_regs gpe;
+
+static uint32_t gpe_readb(void *opaque, uint32_t addr)
+{
+    uint32_t val = 0;
+#if defined(DEBUG)
+    printf("gpe read %lx == %lx\n", addr, val);
+#endif
+    return val;
+}
+
+static void gpe_writeb(void *opaque, uint32_t addr, uint32_t val)
+{
+#if defined(DEBUG)
+    printf("gpe write %lx <== %d\n", addr, val);
+#endif
+}
+
+static char *model;
+
+void qemu_system_hot_add_init(char *cpu_model)
+{
+    register_ioport_write(GPE_BASE, 4, 1, gpe_writeb, &gpe);
+    register_ioport_read(GPE_BASE, 4, 1,  gpe_readb, &gpe);
+
+    model = cpu_model;
+}
 
 void qemu_system_cpu_hot_add(int cpu, int state)
 {
diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
index 982377d..ab69e5c 100644
--- a/qemu/hw/pc.c
+++ b/qemu/hw/pc.c
@@ -1020,6 +1020,7 @@ #endif
         }
     }
 
+    qemu_system_hot_add_init(cpu_model);
 #define USE_HYPERCALL
 #ifdef USE_HYPERCALL
     pci_hypercall_init(pci_bus);
diff --git a/qemu/sysemu.h b/qemu/sysemu.h
index fe929b4..5692114 100644
--- a/qemu/sysemu.h
+++ b/qemu/sysemu.h
@@ -155,6 +155,7 @@ extern int drive_get_max_bus(BlockInterf
 
 /* acpi */
 void qemu_system_cpu_hot_add(int cpu, int state);
+void qemu_system_hot_add_init(char *cpu_model);
 
 /* vmchannel devices */
 
-- 
1.4.2

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

* [Qemu-devel] [PATCH 10/15] handle gpe data for pio
  2008-02-26 19:56                 ` [Qemu-devel] [PATCH 9/15] initialize hot add system Glauber Costa
@ 2008-02-26 19:56                   ` Glauber Costa
  2008-02-26 19:56                     ` [Qemu-devel] [PATCH 11/15] manipulate the gpe bits and send sci up the os Glauber Costa
  0 siblings, 1 reply; 19+ messages in thread
From: Glauber Costa @ 2008-02-26 19:56 UTC (permalink / raw)
  To: kvm-devel; +Cc: marcelo, glommer, qemu-devel, Glauber Costa, chrisw

actually grab and return data, instead of just being two
bogus functions.

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
 qemu/hw/acpi.c |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/qemu/hw/acpi.c b/qemu/hw/acpi.c
index 119b59a..7340f15 100644
--- a/qemu/hw/acpi.c
+++ b/qemu/hw/acpi.c
@@ -545,6 +545,24 @@ static struct gpe_regs gpe;
 static uint32_t gpe_readb(void *opaque, uint32_t addr)
 {
     uint32_t val = 0;
+    struct gpe_regs *g = opaque;
+    switch (addr) {
+        case GPE_BASE:
+            val = g->sts & 0xFF;
+            break;
+        case GPE_BASE + 1:
+            val =  (g->sts >> 8) & 0xFF;
+            break;
+        case GPE_BASE + 2:
+            val =  g->en & 0xFF;
+            break;
+        case GPE_BASE + 3:
+            val =  (g->en >> 8) & 0xFF;
+            break;
+        default:
+            break;
+    }
+
 #if defined(DEBUG)
     printf("gpe read %lx == %lx\n", addr, val);
 #endif
@@ -553,6 +571,24 @@ #endif
 
 static void gpe_writeb(void *opaque, uint32_t addr, uint32_t val)
 {
+    struct gpe_regs *g = opaque;
+    switch (addr) {
+        case GPE_BASE:
+            g->sts = (g->sts & ~0xFFFF) | (val & 0xFFFF);
+            break;
+        case GPE_BASE + 1:
+            g->sts = (g->sts & 0xFFFF) | (val << 8);
+            break;
+        case GPE_BASE + 2:
+            g->en = (g->en & ~0xFFFF) | (val & 0xFFFF);
+            break;
+        case GPE_BASE + 3:
+            g->en = (g->en & 0xFFFF) | (val << 8);
+            break;
+        default:
+            break;
+   }
+
 #if defined(DEBUG)
     printf("gpe write %lx <== %d\n", addr, val);
 #endif
-- 
1.4.2

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

* [Qemu-devel] [PATCH 11/15] manipulate the gpe bits and send sci up the os.
  2008-02-26 19:56                   ` [Qemu-devel] [PATCH 10/15] handle gpe data for pio Glauber Costa
@ 2008-02-26 19:56                     ` Glauber Costa
  2008-02-26 19:56                       ` [Qemu-devel] [PATCH 12/15] isolate cpu thread creation in qemu-kvm.c Glauber Costa
  0 siblings, 1 reply; 19+ messages in thread
From: Glauber Costa @ 2008-02-26 19:56 UTC (permalink / raw)
  To: kvm-devel; +Cc: marcelo, glommer, qemu-devel, Glauber Costa, chrisw

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
 qemu/hw/acpi.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/qemu/hw/acpi.c b/qemu/hw/acpi.c
index 7340f15..5a6d1a8 100644
--- a/qemu/hw/acpi.c
+++ b/qemu/hw/acpi.c
@@ -534,10 +534,13 @@ void qemu_system_powerdown(void)
 }
 #endif
 #define GPE_BASE 0xafe0
+#define PROC_BASE 0xaf00
 
 struct gpe_regs {
     uint16_t sts; /* status */
     uint16_t en;  /* enabled */
+    uint8_t up;
+    uint8_t down;
 };
 
 static struct gpe_regs gpe;
@@ -547,6 +550,13 @@ static uint32_t gpe_readb(void *opaque, 
     uint32_t val = 0;
     struct gpe_regs *g = opaque;
     switch (addr) {
+        case PROC_BASE:
+            val = g->up;
+            break;
+        case PROC_BASE + 1:
+            val = g->down;
+            break;
+
         case GPE_BASE:
             val = g->sts & 0xFF;
             break;
@@ -573,6 +583,13 @@ static void gpe_writeb(void *opaque, uin
 {
     struct gpe_regs *g = opaque;
     switch (addr) {
+        case PROC_BASE:
+            g->up = val;
+            break;
+        case PROC_BASE + 1:
+            g->down = val;
+            break;
+
         case GPE_BASE:
             g->sts = (g->sts & ~0xFFFF) | (val & 0xFFFF);
             break;
@@ -601,9 +618,34 @@ void qemu_system_hot_add_init(char *cpu_
     register_ioport_write(GPE_BASE, 4, 1, gpe_writeb, &gpe);
     register_ioport_read(GPE_BASE, 4, 1,  gpe_readb, &gpe);
 
+    register_ioport_write(PROC_BASE, 4, 1, gpe_writeb, &gpe);
+    register_ioport_read(PROC_BASE, 4, 1,  gpe_readb, &gpe);
+
     model = cpu_model;
 }
 
+static void enable_processor(struct gpe_regs *g, int cpu)
+{
+    g->sts |= 1;
+    g->en |= 1;
+    g->up |= (1 << cpu);
+}
+
+static void disable_processor(struct gpe_regs *g, int cpu)
+{
+    g->sts |= 1;
+    g->en |= 1;
+    g->down |= (1 << cpu);
+}
+
 void qemu_system_cpu_hot_add(int cpu, int state)
 {
+    qemu_set_irq(pm_state->irq, 1);
+    gpe.up = 0;
+    gpe.down = 0;
+    if (state)
+        enable_processor(&gpe, cpu);
+    else
+        disable_processor(&gpe, cpu);
+    qemu_set_irq(pm_state->irq, 0);
 }
-- 
1.4.2

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

* [Qemu-devel] [PATCH 12/15] isolate cpu thread creation in qemu-kvm.c
  2008-02-26 19:56                     ` [Qemu-devel] [PATCH 11/15] manipulate the gpe bits and send sci up the os Glauber Costa
@ 2008-02-26 19:56                       ` Glauber Costa
  2008-02-26 19:56                         ` [Qemu-devel] [PATCH 13/15] provide _MAT to acpi processor Glauber Costa
  0 siblings, 1 reply; 19+ messages in thread
From: Glauber Costa @ 2008-02-26 19:56 UTC (permalink / raw)
  To: kvm-devel; +Cc: marcelo, glommer, qemu-devel, Glauber Costa, chrisw

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
 qemu/qemu-kvm.c |    9 +++++++--
 qemu/qemu-kvm.h |    1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index ffc59d5..59fe9df 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -351,6 +351,11 @@ static void kvm_add_signal(struct qemu_k
     sigdelset(&sigtab->negsigset, signum);
 }
 
+void kvm_init_new_ap(int cpu, CPUState *env)
+{
+    pthread_create(&vcpu_info[cpu].thread, NULL, ap_main_loop, env);
+}
+
 int kvm_init_ap(void)
 {
     CPUState *env = first_cpu->next_cpu;
@@ -371,8 +376,8 @@ #endif
     vcpu->env = first_cpu;
     signal(SIG_IPI, sig_ipi_handler);
     for (i = 1; i < smp_cpus; ++i) {
-	pthread_create(&vcpu_info[i].thread, NULL, ap_main_loop, env);
-	env = env->next_cpu;
+        kvm_init_new_ap(i, env);
+        env = env->next_cpu;
     }
     return 0;
 }
diff --git a/qemu/qemu-kvm.h b/qemu/qemu-kvm.h
index a637d71..8e45f30 100644
--- a/qemu/qemu-kvm.h
+++ b/qemu/qemu-kvm.h
@@ -13,6 +13,7 @@ #include "cpu.h"
 int kvm_main_loop(void);
 int kvm_qemu_init(void);
 int kvm_qemu_create_context(void);
+void kvm_init_new_ap(int cpu, CPUState *env);
 int kvm_init_ap(void);
 void kvm_qemu_destroy(void);
 void kvm_load_registers(CPUState *env);
-- 
1.4.2

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

* [Qemu-devel] [PATCH 13/15] provide _MAT to acpi processor
  2008-02-26 19:56                       ` [Qemu-devel] [PATCH 12/15] isolate cpu thread creation in qemu-kvm.c Glauber Costa
@ 2008-02-26 19:56                         ` Glauber Costa
  2008-02-26 19:56                           ` [Qemu-devel] [PATCH 14/15] start a new cpu thread Glauber Costa
  0 siblings, 1 reply; 19+ messages in thread
From: Glauber Costa @ 2008-02-26 19:56 UTC (permalink / raw)
  To: kvm-devel; +Cc: marcelo, glommer, qemu-devel, Glauber Costa, chrisw

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
 bios/acpi-dsdt.dsl |  154 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 140 insertions(+), 14 deletions(-)

diff --git a/bios/acpi-dsdt.dsl b/bios/acpi-dsdt.dsl
index 194a051..7dffb6d 100755
--- a/bios/acpi-dsdt.dsl
+++ b/bios/acpi-dsdt.dsl
@@ -35,20 +35,146 @@ DefinitionBlock (
  	}
 
         Processor (CPU0, 0x00, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
-        Processor (CPU1, 0x01, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
-        Processor (CPU2, 0x02, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
-        Processor (CPU3, 0x03, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
-        Processor (CPU4, 0x04, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
-        Processor (CPU5, 0x05, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
-        Processor (CPU6, 0x06, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
-        Processor (CPU7, 0x07, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
-        Processor (CPU8, 0x08, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
-        Processor (CPU9, 0x09, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
-        Processor (CPUA, 0x0a, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
-        Processor (CPUB, 0x0b, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
-        Processor (CPUC, 0x0c, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
-        Processor (CPUD, 0x0d, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
-        Processor (CPUE, 0x0e, 0x0000b010, 0x06) {Method (_STA) { Return(0xF)}}
+        Processor (CPU1, 0x01, 0x0000b010, 0x06) {
+            Name (TMP, Buffer(0x8) {0x0, 0x8, 0x01, 0x01, 0x1, 0x0, 0x0, 0x0})
+            Method(_MAT, 0) {
+                If (And(\_PR.PRU, 0x2)) { Return(TMP) }
+                Else { Return(0x0) }
+            }
+            Method (_STA) {
+                Return(0xF)
+            }
+        }
+        Processor (CPU2, 0x02, 0x0000b010, 0x06) {
+            Name (TMP, Buffer(0x8) {0x0, 0x8, 0x02, 0x02, 0x1, 0x0, 0x0, 0x0})
+            Method(_MAT, 0) {
+                If (And(\_PR.PRU, 0x4)) { Return(TMP) }
+                Else { Return(0x0) }
+            }
+            Method (_STA) {
+                Return(0xF)
+            }
+        }
+        Processor (CPU3, 0x03, 0x0000b010, 0x06) {
+            Name (TMP, Buffer(0x8) {0x0, 0x8, 0x03, 0x03, 0x1, 0x0, 0x0, 0x0})
+            Method(_MAT, 0) {
+                If (And(\_PR.PRU, 0x8)) { Return(TMP) }
+                Else { Return(0x0) }
+            }
+            Method (_STA) {
+                Return(0xF)
+            }
+        }
+        Processor (CPU4, 0x04, 0x0000b010, 0x06) {
+            Name (TMP, Buffer(0x8) {0x0, 0x8, 0x04, 0x04, 0x1, 0x0, 0x0, 0x0})
+            Method(_MAT, 0) {
+                If (And(\_PR.PRU, 0x10)) { Return(TMP) }
+                Else { Return(0x0) }
+            }
+            Method (_STA) {
+                Return(0xF)
+            }
+        }
+        Processor (CPU5, 0x05, 0x0000b010, 0x06) {
+            Name (TMP, Buffer(0x8) {0x0, 0x8, 0x05, 0x05, 0x1, 0x0, 0x0, 0x0})
+            Method(_MAT, 0) {
+                If (And(\_PR.PRU, 0x20)) { Return(TMP) }
+                Else { Return(0x0) }
+            }
+            Method (_STA) {
+                Return(0xF)
+            }
+        }
+        Processor (CPU6, 0x06, 0x0000b010, 0x06) {
+            Name (TMP, Buffer(0x8) {0x0, 0x8, 0x06, 0x06, 0x1, 0x0, 0x0, 0x0})
+            Method(_MAT, 0) {
+                If (And(\_PR.PRU, 0x40)) { Return(TMP) }
+                Else { Return(0x0) }
+            }
+            Method (_STA) {
+                Return(0xF)
+            }
+        }
+        Processor (CPU7, 0x07, 0x0000b010, 0x06) {
+            Name (TMP, Buffer(0x8) {0x0, 0x8, 0x07, 0x07, 0x1, 0x0, 0x0, 0x0})
+            Method(_MAT, 0) {
+                If (And(\_PR.PRU, 0x80)) { Return(TMP) }
+                Else { Return(0x0) }
+            }
+            Method (_STA) {
+                Return(0xF)
+            }
+        }
+        Processor (CPU8, 0x08, 0x0000b010, 0x06) {
+            Name (TMP, Buffer(0x8) {0x0, 0x8, 0x08, 0x08, 0x1, 0x0, 0x0, 0x0})
+            Method(_MAT, 0) {
+                If (And(\_PR.PRU, 0x100)) { Return(TMP) }
+                Else { Return(0x0) }
+            }
+            Method (_STA) {
+                Return(0xF)
+            }
+        }
+        Processor (CPU9, 0x09, 0x0000b010, 0x06) {
+            Name (TMP, Buffer(0x8) {0x0, 0x8, 0x09, 0x09, 0x1, 0x0, 0x0, 0x0})
+            Method(_MAT, 0) {
+                If (And(\_PR.PRU, 0x200)) { Return(TMP) }
+                Else { Return(0x0) }
+            }
+            Method (_STA) {
+                Return(0xF)
+            }
+        }
+        Processor (CPUA, 0x0a, 0x0000b010, 0x06) {
+            Name (TMP, Buffer(0x8) {0x0, 0x8, 0x0A, 0x0A, 0x1, 0x0, 0x0, 0x0})
+            Method(_MAT, 0) {
+                If (And(\_PR.PRU, 0x400)) { Return(TMP) }
+                Else { Return(0x0) }
+            }
+            Method (_STA) {
+                Return(0xF)
+            }
+        }
+        Processor (CPUB, 0x0b, 0x0000b010, 0x06) {
+            Name (TMP, Buffer(0x8) {0x0, 0x8, 0x0B, 0x0B, 0x1, 0x0, 0x0, 0x0})
+            Method(_MAT, 0) {
+                If (And(\_PR.PRU, 0x800)) { Return(TMP) }
+                Else { Return(0x0) }
+            }
+            Method (_STA) {
+                Return(0xF)
+            }
+        }
+        Processor (CPUC, 0x0c, 0x0000b010, 0x06) {
+            Name (TMP, Buffer(0x8) {0x0, 0x8, 0x0C, 0x0C, 0x1, 0x0, 0x0, 0x0})
+            Method(_MAT, 0) {
+                If (And(\_PR.PRU, 0x1000)) { Return(TMP) }
+                Else { Return(0x0) }
+            }
+            Method (_STA) {
+                Return(0xF)
+            }
+        }
+        Processor (CPUD, 0x0d, 0x0000b010, 0x06) {
+            Name (TMP, Buffer(0x8) {0x0, 0x8, 0x0D, 0x0D, 0x1, 0x0, 0x0, 0x0})
+            Method(_MAT, 0) {
+                If (And(\_PR.PRU, 0x2000)) { Return(TMP) }
+                Else { Return(0x0) }
+            }
+            Method (_STA) {
+                Return(0xF)
+            }
+        }
+        Processor (CPUE, 0x0e, 0x0000b010, 0x06) {
+            Name (TMP, Buffer(0x8) {0x0, 0x8, 0x0E, 0x0E, 0x1, 0x0, 0x0, 0x0})
+            Method(_MAT, 0) {
+                If (And(\_PR.PRU, 0x4000)) { Return(TMP) }
+                Else { Return(0x0) }
+            }
+            Method (_STA) {
+                Return(0xF)
+            }
+        }
     }
 
     Scope (\)
-- 
1.4.2

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

* [Qemu-devel] [PATCH 14/15] start a new cpu thread
  2008-02-26 19:56                         ` [Qemu-devel] [PATCH 13/15] provide _MAT to acpi processor Glauber Costa
@ 2008-02-26 19:56                           ` Glauber Costa
  2008-02-26 19:56                             ` [Qemu-devel] [PATCH 15/15] remove acpi_build_processor_ssdt Glauber Costa
  0 siblings, 1 reply; 19+ messages in thread
From: Glauber Costa @ 2008-02-26 19:56 UTC (permalink / raw)
  To: kvm-devel; +Cc: marcelo, glommer, qemu-devel, Glauber Costa, chrisw

spin up a new cpu thread if not yet running.

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
 qemu/hw/acpi.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/qemu/hw/acpi.c b/qemu/hw/acpi.c
index 5a6d1a8..e44c8b5 100644
--- a/qemu/hw/acpi.c
+++ b/qemu/hw/acpi.c
@@ -23,6 +23,9 @@ #include "qemu-timer.h"
 #include "sysemu.h"
 #include "i2c.h"
 #include "smbus.h"
+#ifdef USE_KVM
+#include "qemu-kvm.h"
+#endif
 
 //#define DEBUG
 
@@ -640,6 +643,19 @@ static void disable_processor(struct gpe
 
 void qemu_system_cpu_hot_add(int cpu, int state)
 {
+    CPUState *env;
+
+    if ((state) && (!qemu_kvm_cpu_env(cpu))) {
+        env = pc_new_cpu(cpu, model, 1);
+        if (!env) {
+            fprintf(stderr, "cpu %d creation failed\n", cpu);
+            return;
+        }
+#ifdef USE_KVM
+        kvm_init_new_ap(cpu, env);
+#endif
+    }
+
     qemu_set_irq(pm_state->irq, 1);
     gpe.up = 0;
     gpe.down = 0;
-- 
1.4.2

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

* [Qemu-devel] [PATCH 15/15] remove acpi_build_processor_ssdt
  2008-02-26 19:56                           ` [Qemu-devel] [PATCH 14/15] start a new cpu thread Glauber Costa
@ 2008-02-26 19:56                             ` Glauber Costa
  0 siblings, 0 replies; 19+ messages in thread
From: Glauber Costa @ 2008-02-26 19:56 UTC (permalink / raw)
  To: kvm-devel; +Cc: marcelo, glommer, qemu-devel, Glauber Costa, chrisw

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
 bios/rombios32.c |   55 ------------------------------------------------------
 1 files changed, 0 insertions(+), 55 deletions(-)

diff --git a/bios/rombios32.c b/bios/rombios32.c
index f2db740..77e71ac 100755
--- a/bios/rombios32.c
+++ b/bios/rombios32.c
@@ -1294,57 +1294,6 @@ #endif
     h->checksum = acpi_checksum((void *)h, len);
 }
 
-int acpi_build_processor_ssdt(uint8_t *ssdt)
-{
-    uint8_t *ssdt_ptr = ssdt;
-    int i, length;
-    int acpi_cpus = smp_cpus > 0xff ? 0xff : smp_cpus;
-
-    ssdt_ptr[9] = 0; // checksum;
-    ssdt_ptr += sizeof(struct acpi_table_header);
-
-    // caluculate the length of processor block and scope block excluding PkgLength
-    length = 0x0d * acpi_cpus + 4;
-
-    // build processor scope header
-    *(ssdt_ptr++) = 0x10; // ScopeOp
-    if (length <= 0x3e) {
-        *(ssdt_ptr++) = length + 1;
-    } else {
-        *(ssdt_ptr++) = 0x7F;
-        *(ssdt_ptr++) = (length + 2) >> 6;
-    }
-    *(ssdt_ptr++) = '_'; // Name
-    *(ssdt_ptr++) = 'P';
-    *(ssdt_ptr++) = 'R';
-    *(ssdt_ptr++) = '_';
-
-    // build object for each processor
-    for(i=0;i<acpi_cpus;i++) {
-        *(ssdt_ptr++) = 0x5B; // ProcessorOp
-        *(ssdt_ptr++) = 0x83;
-        *(ssdt_ptr++) = 0x0B; // Length
-        *(ssdt_ptr++) = 'C';  // Name (CPUxx)
-        *(ssdt_ptr++) = 'P';
-        if ((i & 0xf0) != 0)
-            *(ssdt_ptr++) = (i >> 4) < 0xa ? (i >> 4) + '0' : (i >> 4) + 'A' - 0xa;
-        else
-            *(ssdt_ptr++) = 'U';
-        *(ssdt_ptr++) = (i & 0xf) < 0xa ? (i & 0xf) + '0' : (i & 0xf) + 'A' - 0xa;
-        *(ssdt_ptr++) = i;
-        *(ssdt_ptr++) = 0x10; // Processor block address
-        *(ssdt_ptr++) = 0xb0;
-        *(ssdt_ptr++) = 0;
-        *(ssdt_ptr++) = 0;
-        *(ssdt_ptr++) = 6;    // Processor block length
-    }
-
-    acpi_build_table_header((struct acpi_table_header *)ssdt,
-                            "SSDT", ssdt_ptr - ssdt, 1);
-
-    return ssdt_ptr - ssdt;
-}
-
 /* base_addr must be a multiple of 4KB */
 void acpi_bios_init(void)
 {
@@ -1388,10 +1337,6 @@ #endif
     dsdt = (void *)(addr);
     addr += sizeof(AmlCode);
 
-    ssdt_addr = addr;
-    ssdt = (void *)(addr);
-    addr += acpi_build_processor_ssdt(ssdt);
-
     addr = (addr + 7) & ~7;
     madt_addr = addr;
     madt_size = sizeof(*madt) +
-- 
1.4.2

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

* [Qemu-devel] Re: [kvm-devel] [PATCH 4/15] mark processors as presents
  2008-02-26 19:56       ` [Qemu-devel] [PATCH 4/15] mark processors as presents Glauber Costa
  2008-02-26 19:56         ` [Qemu-devel] [PATCH 5/15] provide gpe _L0x methods Glauber Costa
@ 2008-02-26 23:05         ` Alexander Graf
  2008-02-26 23:07           ` Alexander Graf
  1 sibling, 1 reply; 19+ messages in thread
From: Alexander Graf @ 2008-02-26 23:05 UTC (permalink / raw)
  To: Glauber Costa; +Cc: kvm-devel, marcelo, chrisw, qemu-devel


On Feb 26, 2008, at 8:56 PM, Glauber Costa wrote:

> mark processors as present through the _STA method
>
> Signed-off-by: Glauber Costa <gcosta@redhat.com>
> ---
> bios/acpi-dsdt.dsl |   18 ++++++++++++++++++
> 1 files changed, 18 insertions(+), 0 deletions(-)
>
> diff --git a/bios/acpi-dsdt.dsl b/bios/acpi-dsdt.dsl
> index e900795..244e906 100755
> --- a/bios/acpi-dsdt.dsl
> +++ b/bios/acpi-dsdt.dsl
> @@ -25,6 +25,24 @@ DefinitionBlock (
>     0x1                 // OEM Revision
>     )
> {
> +   Scope (\_PR)
> +   {
> +        Processor (CPU0, 0x00, 0x0000b010, 0x06) {Method (_STA)  
> { Return(0xF)}}
> +        Processor (CPU1, 0x01, 0x0000b010, 0x06) {Method (_STA)  
> { Return(0xF)}}
> +        Processor (CPU2, 0x02, 0x0000b010, 0x06) {Method (_STA)  
> { Return(0xF)}}
> +        Processor (CPU3, 0x03, 0x0000b010, 0x06) {Method (_STA)  
> { Return(0xF)}}
> +        Processor (CPU4, 0x04, 0x0000b010, 0x06) {Method (_STA)  
> { Return(0xF)}}
> +        Processor (CPU5, 0x05, 0x0000b010, 0x06) {Method (_STA)  
> { Return(0xF)}}
> +        Processor (CPU6, 0x06, 0x0000b010, 0x06) {Method (_STA)  
> { Return(0xF)}}
> +        Processor (CPU7, 0x07, 0x0000b010, 0x06) {Method (_STA)  
> { Return(0xF)}}
> +        Processor (CPU8, 0x08, 0x0000b010, 0x06) {Method (_STA)  
> { Return(0xF)}}
> +        Processor (CPU9, 0x09, 0x0000b010, 0x06) {Method (_STA)  
> { Return(0xF)}}
> +        Processor (CPUA, 0x0a, 0x0000b010, 0x06) {Method (_STA)  
> { Return(0xF)}}
> +        Processor (CPUB, 0x0b, 0x0000b010, 0x06) {Method (_STA)  
> { Return(0xF)}}
> +        Processor (CPUC, 0x0c, 0x0000b010, 0x06) {Method (_STA)  
> { Return(0xF)}}
> +        Processor (CPUD, 0x0d, 0x0000b010, 0x06) {Method (_STA)  
> { Return(0xF)}}
> +        Processor (CPUE, 0x0e, 0x0000b010, 0x06) {Method (_STA)  
> { Return(0xF)}}

So if I understand this correctly, you set all possible CPUs on active  
and available. What exactly happens if one of these is not usable?
I know that Darwin broke on the _PR description quite badly, as it  
just allocates possible execution engines using the ACPI Processor  
specification and I do not know what happens if the engine is not  
available.

I have to admit that I have not tested it as I do not have the time to  
do so though, so maybe it works.

>
> +    }
>
>     Scope (\)
>     {
> -- 
> 1.4.2
>

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

* [Qemu-devel] Re: [kvm-devel] [PATCH 4/15] mark processors as presents
  2008-02-26 23:05         ` [Qemu-devel] Re: [kvm-devel] [PATCH 4/15] mark processors as presents Alexander Graf
@ 2008-02-26 23:07           ` Alexander Graf
  0 siblings, 0 replies; 19+ messages in thread
From: Alexander Graf @ 2008-02-26 23:07 UTC (permalink / raw)
  To: Alexander Graf; +Cc: kvm-devel, qemu-devel, Glauber Costa, chrisw, marcelo


On Feb 27, 2008, at 12:05 AM, Alexander Graf wrote:

>
> On Feb 26, 2008, at 8:56 PM, Glauber Costa wrote:
>
>> mark processors as present through the _STA method
>>
>> Signed-off-by: Glauber Costa <gcosta@redhat.com>
>> ---
>> bios/acpi-dsdt.dsl |   18 ++++++++++++++++++
>> 1 files changed, 18 insertions(+), 0 deletions(-)
>>
>> diff --git a/bios/acpi-dsdt.dsl b/bios/acpi-dsdt.dsl
>> index e900795..244e906 100755
>> --- a/bios/acpi-dsdt.dsl
>> +++ b/bios/acpi-dsdt.dsl
>> @@ -25,6 +25,24 @@ DefinitionBlock (
>>    0x1                 // OEM Revision
>>    )
>> {
>> +   Scope (\_PR)
>> +   {
>> +        Processor (CPU0, 0x00, 0x0000b010, 0x06) {Method (_STA)
>> { Return(0xF)}}
>> +        Processor (CPU1, 0x01, 0x0000b010, 0x06) {Method (_STA)
>> { Return(0xF)}}
>> +        Processor (CPU2, 0x02, 0x0000b010, 0x06) {Method (_STA)
>> { Return(0xF)}}
>> +        Processor (CPU3, 0x03, 0x0000b010, 0x06) {Method (_STA)
>> { Return(0xF)}}
>> +        Processor (CPU4, 0x04, 0x0000b010, 0x06) {Method (_STA)
>> { Return(0xF)}}
>> +        Processor (CPU5, 0x05, 0x0000b010, 0x06) {Method (_STA)
>> { Return(0xF)}}
>> +        Processor (CPU6, 0x06, 0x0000b010, 0x06) {Method (_STA)
>> { Return(0xF)}}
>> +        Processor (CPU7, 0x07, 0x0000b010, 0x06) {Method (_STA)
>> { Return(0xF)}}
>> +        Processor (CPU8, 0x08, 0x0000b010, 0x06) {Method (_STA)
>> { Return(0xF)}}
>> +        Processor (CPU9, 0x09, 0x0000b010, 0x06) {Method (_STA)
>> { Return(0xF)}}
>> +        Processor (CPUA, 0x0a, 0x0000b010, 0x06) {Method (_STA)
>> { Return(0xF)}}
>> +        Processor (CPUB, 0x0b, 0x0000b010, 0x06) {Method (_STA)
>> { Return(0xF)}}
>> +        Processor (CPUC, 0x0c, 0x0000b010, 0x06) {Method (_STA)
>> { Return(0xF)}}
>> +        Processor (CPUD, 0x0d, 0x0000b010, 0x06) {Method (_STA)
>> { Return(0xF)}}
>> +        Processor (CPUE, 0x0e, 0x0000b010, 0x06) {Method (_STA)
>> { Return(0xF)}}
>
> So if I understand this correctly, you set all possible CPUs on active
> and available. What exactly happens if one of these is not usable?
> I know that Darwin broke on the _PR description quite badly, as it
> just allocates possible execution engines using the ACPI Processor
> specification and I do not know what happens if the engine is not
> available.
>
> I have to admit that I have not tested it as I do not have the time to
> do so though, so maybe it works.

I just read patch 13 ... nevermind

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

* [Qemu-devel] Re: [kvm-devel] [PATCH 0/15] acpi processor hotplug
  2008-02-26 19:56 [Qemu-devel] [PATCH 0/15] acpi processor hotplug Glauber Costa
  2008-02-26 19:56 ` [Qemu-devel] [PATCH 1/15] Make a GPE register block be acessible Glauber Costa
@ 2008-02-27 10:55 ` Avi Kivity
  1 sibling, 0 replies; 19+ messages in thread
From: Avi Kivity @ 2008-02-27 10:55 UTC (permalink / raw)
  To: Glauber Costa; +Cc: kvm-devel, marcelo, qemu-devel, chrisw

Glauber Costa wrote:
> Hi,
>
> I'm resending the series with avi's few comments merged, and a couple
> of others on my own:
>
> * _STA returns 0xF instead of 0x1. According to the specification, it means
>   that the device, besides present, is also functional, enabled, and a couple
>   of other cool things.
> * gpe_base and proc_base as #defines, not unsigned long
> * _EJ method out. It's causing a lot of troubles, and I'm not even sure it
>   makes sense for processors. We can live without it by now, and if it is needed,
>   it can be added later.
>
>   

Applied all, thanks.


-- 
error compiling committee.c: too many arguments to function

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

end of thread, other threads:[~2008-02-27 10:55 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-26 19:56 [Qemu-devel] [PATCH 0/15] acpi processor hotplug Glauber Costa
2008-02-26 19:56 ` [Qemu-devel] [PATCH 1/15] Make a GPE register block be acessible Glauber Costa
2008-02-26 19:56   ` [Qemu-devel] [PATCH 2/15] mark extra cpus as present Glauber Costa
2008-02-26 19:56     ` [Qemu-devel] [PATCH 3/15] introduce cpu_set to qemu monitor Glauber Costa
2008-02-26 19:56       ` [Qemu-devel] [PATCH 4/15] mark processors as presents Glauber Costa
2008-02-26 19:56         ` [Qemu-devel] [PATCH 5/15] provide gpe _L0x methods Glauber Costa
2008-02-26 19:56           ` [Qemu-devel] [PATCH 6/15] provide operation region for pio to the gpes Glauber Costa
2008-02-26 19:56             ` [Qemu-devel] [PATCH 7/15] implement method _L00 for GPE0 Glauber Costa
2008-02-26 19:56               ` [Qemu-devel] [PATCH 8/15] isolate cpu initialization function in hw/pc.c Glauber Costa
2008-02-26 19:56                 ` [Qemu-devel] [PATCH 9/15] initialize hot add system Glauber Costa
2008-02-26 19:56                   ` [Qemu-devel] [PATCH 10/15] handle gpe data for pio Glauber Costa
2008-02-26 19:56                     ` [Qemu-devel] [PATCH 11/15] manipulate the gpe bits and send sci up the os Glauber Costa
2008-02-26 19:56                       ` [Qemu-devel] [PATCH 12/15] isolate cpu thread creation in qemu-kvm.c Glauber Costa
2008-02-26 19:56                         ` [Qemu-devel] [PATCH 13/15] provide _MAT to acpi processor Glauber Costa
2008-02-26 19:56                           ` [Qemu-devel] [PATCH 14/15] start a new cpu thread Glauber Costa
2008-02-26 19:56                             ` [Qemu-devel] [PATCH 15/15] remove acpi_build_processor_ssdt Glauber Costa
2008-02-26 23:05         ` [Qemu-devel] Re: [kvm-devel] [PATCH 4/15] mark processors as presents Alexander Graf
2008-02-26 23:07           ` Alexander Graf
2008-02-27 10:55 ` [Qemu-devel] Re: [kvm-devel] [PATCH 0/15] acpi processor hotplug Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).