Skip to contentSkip to conversation

Review: acpi processor hotplug

PATCH In review Glauber Costa 2 participants 22 messages Feb 22, 2008 – Feb 25, 2008 KVM

lore
Share & tools
lore
#0 lore raw

cover Review: acpi processor hotplug

Hi,

In this series, I'm sending the result-so-far of my work with acpi for processor hotplug. I'm able to put a cpu up and down (with the help of some udev scripts I wrote), but it still has some known bugs and issues. For x86_64 linux machines (because the kernel supports it), you can plug cpus that _were not_ listed initially in smp_cpus.

The usage is : cpu_set x (online/offline), in qemu monitor. It will then send the proper signals to the cpu #x.

However, it is important to note that:

* there's no way to know if it suceeded. (ex, if the udev scripts are not running, the cpu will not be put up, and you'll never know)
* there's no way to unconditionally send an add signal. (if you send BUS_CHECK again, and the cpu is already marked as present, it will offline it instead)

because of that, management gets a bit complicated. The ideal situation is to specify:
"I want Y cpus", and have it. Error reported in case it fails. Because of that, I _still_ advocate for an alternative virtio implementation. ACPI still plays its role in this scenario, but not the full role.

In my TODO list, you'll find:
* fix some more issues in this code, and merge the gently comments I'm sure you'll make
* device acpi hotplug
* virtio cpu hotplug for linux (meaning refactoring the existing patch)
* occupy 24 territories.
* conquer 18 territories with at least 2 battalions on each.

Besides a bunch of boring personal items I'm sure are not of interest to anybody here.

Thanks in advance

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

#1 lore raw

PATCH 1/15 Make a GPE register block be acessible.

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

---
 bios/rombios32.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
bios/rombios32.c +2 -0
index 5365b5f..3ec85cb 100755
@@ -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",
Signature · 7 lines
1.4.2


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

PATCH 2/15 mark extra cpus as present

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

---
 bios/rombios.h   |    2 ++
 bios/rombios32.c |   21 +++++++++++++--------
 2 files changed, 15 insertions(+), 8 deletions(-)
bios/rombios.h +2 -0
index 412c5e9..2cf2bb3 100644
@@ -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"
bios/rombios32.c +13 -8
index 3ec85cb..f2db740 100755
@@ -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);
 
Signature · 7 lines
1.4.2


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

PATCH 3/15 introduce cpu_set to qemu monitor

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.

---
 qemu/hw/acpi.c |    3 +++
 qemu/monitor.c |   16 ++++++++++++++++
 qemu/sysemu.h  |    3 +++
 3 files changed, 22 insertions(+), 0 deletions(-)
qemu/hw/acpi.c +3 -0
index e21ded0..18561e0 100644
@@ -533,3 +533,6 @@ void qemu_system_powerdown(void)
     }
 }
 #endif
+void qemu_system_cpu_hot_add(int cpu, int state)
+{
+}
qemu/monitor.c +16 -0
index e8022c8..09f84a9 100644
@@ -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, },
 };
 
qemu/sysemu.h +3 -0
index ffc468a..fe929b4 100644
@@ -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
Signature · 7 lines
1.4.2


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

PATCH 4/15 mark processors as presents

mark processors as present through the _STA method

---
 bios/acpi-dsdt.dsl |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
bios/acpi-dsdt.dsl +19 -0
index e900795..cd42e23 100755
@@ -25,9 +25,28 @@ DefinitionBlock (
     0x1                 // OEM Revision
     )
 {
+   Scope (\_PR)
+   {
+        Processor (CPU0, 0x00, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPU1, 0x01, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPU2, 0x02, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPU3, 0x03, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPU4, 0x04, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPU5, 0x05, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPU6, 0x06, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPU7, 0x07, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPU8, 0x08, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPU9, 0x09, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPUA, 0x0a, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPUB, 0x0b, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPUC, 0x0c, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPUD, 0x0d, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPUE, 0x0e, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+    }
 
     Scope (\)
     {
+
         /* CMOS memory access */
         OperationRegion (CMS, SystemIO, 0x70, 0x02)
         Field (CMS, ByteAcc, NoLock, Preserve)
Signature · 7 lines
1.4.2


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

PATCH 5/15 provide gpe _L0x methods

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

---
 bios/acpi-dsdt.dsl |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 51 insertions(+), 0 deletions(-)
bios/acpi-dsdt.dsl +51 -0
index cd42e23..7c954c3 100755
@@ -579,4 +579,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)
+        }
+    }
 }
Signature · 7 lines
1.4.2


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

PATCH 6/15 provide operation region for pio to the gpes

---
 bios/acpi-dsdt.dsl |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
bios/acpi-dsdt.dsl +7 -0
index 7c954c3..d738b2f 100755
@@ -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(0x1)}}
         Processor (CPU1, 0x01, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
         Processor (CPU2, 0x02, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
Signature · 7 lines
1.4.2


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

PATCH 7/15 implement method _L00 for GPE0

This corresponds to the cpu hotplug functionality

---
 bios/acpi-dsdt.dsl |  114 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 114 insertions(+), 0 deletions(-)
bios/acpi-dsdt.dsl +114 -0
index d738b2f..bdb591a 100755
@@ -589,6 +589,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 */
+            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) {
Signature · 7 lines
1.4.2


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

PATCH 8/15 isolate cpu initialization function in hw/pc.c

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.

---
 qemu/hw/pc.c |   40 +++++++++++++++++++++++-----------------
 qemu/hw/pc.h |    1 +
 2 files changed, 24 insertions(+), 17 deletions(-)
qemu/hw/pc.c +23 -17
index 77a7d53..982377d 100644
@@ -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 */
qemu/hw/pc.h +1 -0
index f640395..f70ab55 100644
@@ -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;
Signature · 7 lines
1.4.2


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

PATCH 9/15 initialize hot add system.

Register the pios, and grab cpu_model for future usage.

---
 qemu/hw/acpi.c |   35 +++++++++++++++++++++++++++++++++++
 qemu/hw/pc.c   |    1 +
 2 files changed, 36 insertions(+), 0 deletions(-)
qemu/hw/acpi.c +35 -0
index 18561e0..02f6bab 100644
@@ -533,6 +533,41 @@ void qemu_system_powerdown(void)
     }
 }
 #endif
+unsigned long 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)
 {
 }
qemu/hw/pc.c +1 -0
index 982377d..ab69e5c 100644
@@ -1020,6 +1020,7 @@ #endif
         }
     }
 
+    qemu_system_hot_add_init(cpu_model);
 #define USE_HYPERCALL
 #ifdef USE_HYPERCALL
     pci_hypercall_init(pci_bus);
Signature · 7 lines
1.4.2


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

PATCH 10/15 handle gpe data for pio

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

---
 qemu/hw/acpi.c |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)
qemu/hw/acpi.c +36 -0
index 02f6bab..60d3094 100644
@@ -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 0xafe0:
+            val = g->sts & 0xFF;
+            break;
+        case 0xafe1:
+            val =  (g->sts >> 8) & 0xFF;
+            break;
+        case 0xafe2:
+            val =  g->en & 0xFF;
+            break;
+        case 0xafe3:
+            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 0xafe0:
+            g->sts = (g->sts & ~0xFFFF) | (val & 0xFFFF);
+            break;
+        case 0xafe1:
+            g->sts = (g->sts & 0xFFFF) | (val << 8);
+            break;
+        case 0xafe2:
+            g->en = (g->en & ~0xFFFF) | (val & 0xFFFF);
+            break;
+        case 0xafe3:
+            g->en = (g->en & 0xFFFF) | (val << 8);
+            break;
+        default:
+            break;
+   }
+
 #if defined(DEBUG)
     printf("gpe write %lx <== %d\n", addr, val);
 #endif
Signature · 7 lines
1.4.2


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

PATCH 11/15 manipulate the gpe bits and send sci up the os.

---
 qemu/hw/acpi.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)
qemu/hw/acpi.c +42 -0
index 60d3094..038e993 100644
@@ -534,10 +534,13 @@ void qemu_system_powerdown(void)
 }
 #endif
 unsigned long gpe_base = 0xafe0;
+unsigned long status_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 0xaf00:
+            val = g->up;
+            break;
+        case 0xaf01:
+            val = g->down;
+            break;
+
         case 0xafe0:
             val = g->sts & 0xFF;
             break;
@@ -573,6 +583,13 @@ static void gpe_writeb(void *opaque, uin
 {
     struct gpe_regs *g = opaque;
     switch (addr) {
+        case 0xaf00:
+            g->up = val;
+            break;
+        case 0xaf01:
+            g->down = val;
+            break;
+
         case 0xafe0:
             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(status_base, 4, 1, gpe_writeb, &gpe);
+    register_ioport_read(status_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);
 }
Signature · 7 lines
1.4.2


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

PATCH 12/15 isolate cpu thread creation in qemu-kvm.c

---
 qemu/qemu-kvm.c |    9 +++++++--
 qemu/qemu-kvm.h |    1 +
 2 files changed, 8 insertions(+), 2 deletions(-)
qemu/qemu-kvm.c +7 -2
index ffc59d5..59fe9df 100644
@@ -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;
 }
qemu/qemu-kvm.h +1 -0
index a637d71..8e45f30 100644
@@ -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);
Signature · 7 lines
1.4.2


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

PATCH 13/15 provide _MAT to acpi processor

---
 bios/acpi-dsdt.dsl |  154 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 140 insertions(+), 14 deletions(-)
bios/acpi-dsdt.dsl +140 -14
index bdb591a..4ce7b6a 100755
@@ -35,20 +35,146 @@ DefinitionBlock (
  	}
 
         Processor (CPU0, 0x00, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
-        Processor (CPU1, 0x01, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
-        Processor (CPU2, 0x02, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
-        Processor (CPU3, 0x03, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
-        Processor (CPU4, 0x04, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
-        Processor (CPU5, 0x05, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
-        Processor (CPU6, 0x06, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
-        Processor (CPU7, 0x07, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
-        Processor (CPU8, 0x08, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
-        Processor (CPU9, 0x09, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
-        Processor (CPUA, 0x0a, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
-        Processor (CPUB, 0x0b, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
-        Processor (CPUC, 0x0c, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
-        Processor (CPUD, 0x0d, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
-        Processor (CPUE, 0x0e, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        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(0x1)
+            }
+        }
+        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(0x1)
+            }
+        }
+        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(0x1)
+            }
+        }
+        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(0x1)
+            }
+        }
+        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(0x1)
+            }
+        }
+        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(0x1)
+            }
+        }
+        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(0x1)
+            }
+        }
+        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(0x1)
+            }
+        }
+        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(0x1)
+            }
+        }
+        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(0x1)
+            }
+        }
+        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(0x1)
+            }
+        }
+        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(0x1)
+            }
+        }
+        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(0x1)
+            }
+        }
+        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(0x1)
+            }
+        }
     }
 
     Scope (\)
Signature · 7 lines
1.4.2


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

PATCH 14/15 start a new cpu thread

spin up a new cpu thread if not yet running.

---
 qemu/hw/acpi.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
qemu/hw/acpi.c +16 -0
index 038e993..93cbc68 100644
@@ -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;
Signature · 7 lines
1.4.2


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

PATCH 15/15 provide _EJ0 method for processor removal

---
 bios/acpi-dsdt.dsl    |   14 ++++++++++++++
 qemu/pc-bios/bios.bin |  Bin
 2 files changed, 14 insertions(+), 0 deletions(-)
bios/acpi-dsdt.dsl +14 -0
index 4ce7b6a..33adfce 100755
@@ -44,6 +44,7 @@ DefinitionBlock (
             Method (_STA) {
                 Return(0x1)
             }
+            Method (_EJ0, 1) { Return (0x0) }
         }
         Processor (CPU2, 0x02, 0x0000b010, 0x06) {
             Name (TMP, Buffer(0x8) {0x0, 0x8, 0x02, 0x02, 0x1, 0x0, 0x0, 0x0})
@@ -54,6 +55,7 @@ DefinitionBlock (
             Method (_STA) {
                 Return(0x1)
             }
+            Method (_EJ0,1) { Return (0x0) }
         }
         Processor (CPU3, 0x03, 0x0000b010, 0x06) {
             Name (TMP, Buffer(0x8) {0x0, 0x8, 0x03, 0x03, 0x1, 0x0, 0x0, 0x0})
@@ -64,6 +66,7 @@ DefinitionBlock (
             Method (_STA) {
                 Return(0x1)
             }
+            Method (_EJ0,1) { Return (0x0) }
         }
         Processor (CPU4, 0x04, 0x0000b010, 0x06) {
             Name (TMP, Buffer(0x8) {0x0, 0x8, 0x04, 0x04, 0x1, 0x0, 0x0, 0x0})
@@ -74,6 +77,7 @@ DefinitionBlock (
             Method (_STA) {
                 Return(0x1)
             }
+            Method (_EJ0,1) { Return (0x0) }
         }
         Processor (CPU5, 0x05, 0x0000b010, 0x06) {
             Name (TMP, Buffer(0x8) {0x0, 0x8, 0x05, 0x05, 0x1, 0x0, 0x0, 0x0})
@@ -84,6 +88,7 @@ DefinitionBlock (
             Method (_STA) {
                 Return(0x1)
             }
+            Method (_EJ0,1) { Return (0x0) }
         }
         Processor (CPU6, 0x06, 0x0000b010, 0x06) {
             Name (TMP, Buffer(0x8) {0x0, 0x8, 0x06, 0x06, 0x1, 0x0, 0x0, 0x0})
@@ -94,6 +99,7 @@ DefinitionBlock (
             Method (_STA) {
                 Return(0x1)
             }
+            Method (_EJ0,1) { Return (0x0) }
         }
         Processor (CPU7, 0x07, 0x0000b010, 0x06) {
             Name (TMP, Buffer(0x8) {0x0, 0x8, 0x07, 0x07, 0x1, 0x0, 0x0, 0x0})
@@ -104,6 +110,7 @@ DefinitionBlock (
             Method (_STA) {
                 Return(0x1)
             }
+            Method (_EJ0,1) { Return (0x0) }
         }
         Processor (CPU8, 0x08, 0x0000b010, 0x06) {
             Name (TMP, Buffer(0x8) {0x0, 0x8, 0x08, 0x08, 0x1, 0x0, 0x0, 0x0})
@@ -114,6 +121,7 @@ DefinitionBlock (
             Method (_STA) {
                 Return(0x1)
             }
+            Method (_EJ0,1) { Return (0x0) }
         }
         Processor (CPU9, 0x09, 0x0000b010, 0x06) {
             Name (TMP, Buffer(0x8) {0x0, 0x8, 0x09, 0x09, 0x1, 0x0, 0x0, 0x0})
@@ -124,6 +132,7 @@ DefinitionBlock (
             Method (_STA) {
                 Return(0x1)
             }
+            Method (_EJ0,1) { Return (0x0) }
         }
         Processor (CPUA, 0x0a, 0x0000b010, 0x06) {
             Name (TMP, Buffer(0x8) {0x0, 0x8, 0x0A, 0x0A, 0x1, 0x0, 0x0, 0x0})
@@ -134,6 +143,7 @@ DefinitionBlock (
             Method (_STA) {
                 Return(0x1)
             }
+            Method (_EJ0,1) { Return (0x0) }
         }
         Processor (CPUB, 0x0b, 0x0000b010, 0x06) {
             Name (TMP, Buffer(0x8) {0x0, 0x8, 0x0B, 0x0B, 0x1, 0x0, 0x0, 0x0})
@@ -144,6 +154,7 @@ DefinitionBlock (
             Method (_STA) {
                 Return(0x1)
             }
+            Method (_EJ0,1) { Return (0x0) }
         }
         Processor (CPUC, 0x0c, 0x0000b010, 0x06) {
             Name (TMP, Buffer(0x8) {0x0, 0x8, 0x0C, 0x0C, 0x1, 0x0, 0x0, 0x0})
@@ -154,6 +165,7 @@ DefinitionBlock (
             Method (_STA) {
                 Return(0x1)
             }
+            Method (_EJ0,1) { Return (0x0) }
         }
         Processor (CPUD, 0x0d, 0x0000b010, 0x06) {
             Name (TMP, Buffer(0x8) {0x0, 0x8, 0x0D, 0x0D, 0x1, 0x0, 0x0, 0x0})
@@ -164,6 +176,7 @@ DefinitionBlock (
             Method (_STA) {
                 Return(0x1)
             }
+            Method (_EJ0,1) { Return (0x0) }
         }
         Processor (CPUE, 0x0e, 0x0000b010, 0x06) {
             Name (TMP, Buffer(0x8) {0x0, 0x8, 0x0E, 0x0E, 0x1, 0x0, 0x0, 0x0})
@@ -174,6 +187,7 @@ DefinitionBlock (
             Method (_STA) {
                 Return(0x1)
             }
+            Method (_EJ0,1) { Return (0x0) }
         }
     }
 
qemu/pc-bios/bios.bin binary +0 -0
index 64b7abb..872f073 100644
Binary files a/qemu/pc-bios/bios.bin and b/qemu/pc-bios/bios.bin differ
Signature · 7 lines
1.4.2


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

Re: [PATCH 4/15] mark processors as presents

In reply to Glauber Costa
Quoted 24 lines · Glauber Costa

mark processors as present through the _STA method

---
 bios/acpi-dsdt.dsl |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
bios/acpi-dsdt.dsl +9 -0
index e900795..cd42e23 100755
@@ -25,9 +25,28 @@ DefinitionBlock (
     0x1                 // OEM Revision
     )
 {
+   Scope (\_PR)
+   {
+        Processor (CPU0, 0x00, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPU1, 0x01, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPU2, 0x02, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPU3, 0x03, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPU4, 0x04, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPU5, 0x05, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPU6, 0x06, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}

bios/acpi-dsdt.dsl DefinitionBlock ( · line 46

Quoted 10 lines
bios/acpi-dsdt.dsl +9 -0
+        Processor (CPU7, 0x07, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPU8, 0x08, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPU9, 0x09, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPUA, 0x0a, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPUB, 0x0b, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPUC, 0x0c, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPUD, 0x0d, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+        Processor (CPUE, 0x0e, 0x0000b010, 0x06) {Method (_STA) { Return(0x1)}}
+    }
 

There is now code in rombios32.c to do this. It needs to be removed. See acpi_build_processor_ssdt().

bios/acpi-dsdt.dsl DefinitionBlock ( · line 52

Quoted 8 lines
bios/acpi-dsdt.dsl +1 -0
     Scope (\)
     {
+
         /* CMOS memory access */
         OperationRegion (CMS, SystemIO, 0x70, 0x02)
         Field (CMS, ByteAcc, NoLock, Preserve)

-

Signature · 7 lines
error compiling committee.c: too many arguments to function


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

Re: [PATCH 4/15] mark processors as presents

Quoted 45 lines · Avi Kivity
Quoted 44 lines · Glauber Costa

mark processors as present through the _STA method

---
 bios/acpi-dsdt.dsl |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
bios/acpi-dsdt.dsl +9 -0
index e900795..cd42e23 100755
@@ -25,9 +25,28 @@ DefinitionBlock (
     0x1                 // OEM Revision
     )
 {
+   Scope (\_PR)
+   {
+        Processor (CPU0, 0x00, 0x0000b010, 0x06) {Method (_STA) { 
 Return(0x1)}}
+        Processor (CPU1, 0x01, 0x0000b010, 0x06) {Method (_STA) { 
 Return(0x1)}}
+        Processor (CPU2, 0x02, 0x0000b010, 0x06) {Method (_STA) { 
 Return(0x1)}}
+        Processor (CPU3, 0x03, 0x0000b010, 0x06) {Method (_STA) { 
 Return(0x1)}}
+        Processor (CPU4, 0x04, 0x0000b010, 0x06) {Method (_STA) { 
 Return(0x1)}}
+        Processor (CPU5, 0x05, 0x0000b010, 0x06) {Method (_STA) { 
 Return(0x1)}}
+        Processor (CPU6, 0x06, 0x0000b010, 0x06) {Method (_STA) { 

Return(0x1)}}
+ Processor (CPU7, 0x07, 0x0000b010, 0x06) {Method (_STA) {
Return(0x1)}}
+ Processor (CPU8, 0x08, 0x0000b010, 0x06) {Method (_STA) {
Return(0x1)}}
+ Processor (CPU9, 0x09, 0x0000b010, 0x06) {Method (_STA) {
Return(0x1)}}
+ Processor (CPUA, 0x0a, 0x0000b010, 0x06) {Method (_STA) {
Return(0x1)}}
+ Processor (CPUB, 0x0b, 0x0000b010, 0x06) {Method (_STA) {
Return(0x1)}}
+ Processor (CPUC, 0x0c, 0x0000b010, 0x06) {Method (_STA) {
Return(0x1)}}
+ Processor (CPUD, 0x0d, 0x0000b010, 0x06) {Method (_STA) {

Quoted 8 lines
Quoted 5 lines

Return(0x1)}}
+ Processor (CPUE, 0x0e, 0x0000b010, 0x06) {Method (_STA) {
Return(0x1)}}
+ }

There is now code in rombios32.c to do this. It needs to be removed. See acpi_build_processor_ssdt().

Building the table by hand is trivial in the case where the processors are just _listed_, and can be easily justified. This first patch just add the _STA method, but other follows, which turns the processor block into a quite complicated thing. Not to mention the operational region, the notifications that have to refer to the processor objects, etc.

So I can't see any valid justification for using the code in rombios32.c, instead of a high level language such as the one provided by acpi.

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

#18 lore raw

Re: [PATCH 4/15] mark processors as presents

Quoted 11 lines · Glauber Costa
Quoted 3 lines

There is now code in rombios32.c to do this. It needs to be removed. See acpi_build_processor_ssdt().

Building the table by hand is trivial in the case where the processors are just _listed_, and can be easily justified. This first patch just add the _STA method, but other follows, which turns the processor block into a quite complicated thing. Not to mention the operational region,
the notifications that have to refer to the processor objects, etc.

Quoted 3 lines

So I can't see any valid justification for using the code in rombios32.c, instead of a high level language such as the one provided by acpi.

I meant, remove the code in rombios32.c. Sorry about the confusion.

Signature · 7 lines
error compiling committee.c: too many arguments to function


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

Re: [PATCH 4/15] mark processors as presents

Quoted 12 lines · Avi Kivity
Quoted 11 lines · Glauber Costa
Quoted 3 lines

There is now code in rombios32.c to do this. It needs to be removed. See acpi_build_processor_ssdt().

Building the table by hand is trivial in the case where the processors are just _listed_, and can be easily justified. This first patch just add the _STA method, but other follows, which turns the processor block into a quite complicated thing. Not to mention the operational region,
the notifications that have to refer to the processor objects, etc.

Quoted 6 lines
Quoted 3 lines

So I can't see any valid justification for using the code in rombios32.c, instead of a high level language such as the one provided by acpi.

I meant, remove the code in rombios32.c. Sorry about the confusion.

Oh, so that's okay ;-)

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

#20 lore raw

Re: [PATCH 3/15] introduce cpu_set to qemu monitor

In reply to Glauber Costa
Quoted 13 lines · Glauber Costa

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.

index e21ded0..18561e0 100644

qemu/hw/acpi.c void qemu_system_powerdown(void) · line 538

Quoted 6 lines
qemu/hw/acpi.c +3 -0
@@ -533,3 +533,6 @@ void qemu_system_powerdown(void)
     }
 }
 #endif
+void qemu_system_cpu_hot_add(int cpu, int state)
+{
+}

Missing empty line.

Signature · 7 lines
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
#21 lore raw
In reply to Glauber Costa
Quoted 19 lines · Glauber Costa

Hi,

In this series, I'm sending the result-so-far of my work with acpi for processor hotplug. I'm able to put a cpu up and down (with the help of some udev scripts I wrote), but it still has some known bugs and issues. For x86_64 linux machines (because the kernel supports it), you can plug cpus that _were not_ listed initially in smp_cpus.

The usage is : cpu_set x (online/offline), in qemu monitor. It will then send the proper signals to the cpu #x.

However, it is important to note that:

* there's no way to know if it suceeded. (ex, if the udev scripts are not running, the cpu will not be put up, and you'll never know)
* there's no way to unconditionally send an add signal. (if you send BUS_CHECK again, and the cpu is already marked as present, it will offline it instead)

Quoted 6 lines

because of that, management gets a bit complicated. The ideal situation is to specify:
"I want Y cpus", and have it. Error reported in case it fails. Because of that, I _still_ advocate for an alternative virtio implementation. ACPI still plays its role in this scenario, but not the full role.

Perhaps this can be implemented in userspace; I don't see anything that needs to be in the kernel for this.

Since it needs to work independently of networking, maybe it's a good first use for an AF_VIRT protocol family (which can be implemented on top of virtio).

Quoted 3 lines

In my TODO list, you'll find:
* fix some more issues in this code, and merge the gently comments I'm sure you'll make

It's difficult with such near-perfect patchsets. You're reducing me to whitespace comments. Please post to qemu-devel as well so they can ignore it as usual.

Quoted 3 lines

* device acpi hotplug
* virtio cpu hotplug for linux (meaning refactoring the existing patch)

Slightly related to this would be a qemu monitor mechanism to set vcpu->cpu affinity.

Quoted 3 lines

* occupy 24 territories.
* conquer 18 territories with at least 2 battalions on each.

Sounds risky.

Signature · 7 lines
error compiling committee.c: too many arguments to function


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