Skip to contentSkip to conversation

pc: CPU hotplug support for Q35

PATCH Applied Igor Mammedov 2 participants 13 messages Jan 9, 2014 – Feb 2, 2014

lore
Share & tools
lore
#0 lore raw

v3 cover pc: CPU hotplug support for Q35

Changes since v2:
* use dependency auto generation for *.dsl files
* hide DEVICE(PRES) from UI
* add comments to document holes punched in CRES
* reduce ifdeffenery by moving CPU hotplug defines to
a dedicated header shared between C and ASL files
* other odd changes requested by "Michael S. Tsirkin" <[email protected]>

Changes since v1:
* renamed hotplug.c/.h to cpu_hotplug.c/.h
* make all prefixes acpi_cpu_hotplug and AcpiCpuHotplug
* updated docs/specs/acpi_cpu_hotplug.txt with Q35's IO port range
* exclude CPU/PCI/GPE IO ranges from resources advertised in PCI bus _CRS
* advertise CPU hotplug IO range using ACPI Device(ACPI0004)._CRS object.
* change Q35 IO port ase from 0xa18 to 0xcd8, to avoid increasing fragmentation of PCI bus IO space
* replaced runtime IO port setting with compile time one, since port mapping is hadcoded and there is not real need to set it dynamically.
* Use the same headers for C and ASL code so that port/length values won't be duplicated.
* Fix deps for ACPI tables, so that thay would be rebuild when included files are touched. (Added only includes, I've touched, it's not complete but a good start anyway)

Tested with RHEL6, WS2012R2, WS2003

Series is based on mst/pci tree, git tree for testing:
https://github.com/imammedo/qemu/commits/q35_cpu_hp_v3

Igor Mammedov (9):
acpi: factor out common cpu hotplug code for PIIX4/Q35
acpi: ich9: add CPU hotplug handling to Q35 machine
pc: make: fix dependencies: rebuild when included file is changed
pc: set PRST base in DSDT depending on chipset
pc: PIIX DSDT: exclude CPU/PCI hotplug & GPE0 IO range from PCI bus
resources
pc: Q35 DSDT: exclude CPU hotplug IO range from PCI bus resources
pc: ACPI: expose PRST IO range via _CRS
pc: ACPI: unify source of CPU hotplug IO base/len
pc: ACPI: update acpi-dsdt.hex.generated q35-acpi-dsdt.hex.generated

 docs/specs/acpi_cpu_hotplug.txt     |    4 +-
 hw/acpi/Makefile.objs               |    2 +-
 hw/acpi/cpu_hotplug.c               |   64 +++++++
 hw/acpi/ich9.c                      |   14 ++
 hw/acpi/piix4.c                     |   80 +--------
 hw/i386/Makefile.objs               |    2 +-
 hw/i386/acpi-dsdt-cpu-hotplug.dsl   |   14 ++-
 hw/i386/acpi-dsdt-pci-crs.dsl       |   15 +--
 hw/i386/acpi-dsdt.dsl               |   41 +++++
 hw/i386/acpi-dsdt.hex.generated     |  333 +++++++++++++++++++++++++++--------
 hw/i386/q35-acpi-dsdt.dsl           |   18 ++
 hw/i386/q35-acpi-dsdt.hex.generated |  138 ++++++++++++--
 include/hw/acpi/cpu_hotplug.h       |   27 +++
 include/hw/acpi/cpu_hotplug_defs.h  |   24 +++
 include/hw/acpi/ich9.h              |    4 +
 15 files changed, 592 insertions(+), 188 deletions(-)
 create mode 100644 hw/acpi/cpu_hotplug.c
 create mode 100644 include/hw/acpi/cpu_hotplug.h
 create mode 100644 include/hw/acpi/cpu_hotplug_defs.h
#1 lore raw

PATCH v3 1/9 acpi: factor out common cpu hotplug code for PIIX4/Q35

.. so it could be used for adding CPU hotplug to Q35 machine

Add an additional header with that will be shared between C and ASL code: include/hw/acpi/cpu_hotplug_defs.h

---
 hw/acpi/Makefile.objs              |    2 +-
 hw/acpi/cpu_hotplug.c              |   64 ++++++++++++++++++++++++++++++
 hw/acpi/piix4.c                    |   77 +++---------------------------------
 include/hw/acpi/cpu_hotplug.h      |   27 ++++++++++++
 include/hw/acpi/cpu_hotplug_defs.h |   22 ++++++++++
 5 files changed, 120 insertions(+), 72 deletions(-)
 create mode 100644 hw/acpi/cpu_hotplug.c
 create mode 100644 include/hw/acpi/cpu_hotplug.h
 create mode 100644 include/hw/acpi/cpu_hotplug_defs.h
hw/acpi/Makefile.objs +1 -1
index 841eca2..397d32b 100644
@@ -1 +1 @@
-common-obj-$(CONFIG_ACPI) += core.o piix4.o ich9.o pcihp.o
+common-obj-$(CONFIG_ACPI) += core.o piix4.o ich9.o pcihp.o cpu_hotplug.o
hw/acpi/cpu_hotplug.c new file +64 -0

64 lines not on this page · raw message

hw/acpi/piix4.c +6 -71

131 lines not on this page · raw message

include/hw/acpi/cpu_hotplug.h new file +27 -0
new file mode 100644
index 0000000..4576400
@@ -0,0 +1,27 @@
+/*
+ * QEMU ACPI hotplug utilities
+ *
+ * Copyright (C) 2013 Red Hat Inc
+ *
+ * Authors:
+ *   Igor Mammedov <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef ACPI_HOTPLUG_H
+#define ACPI_HOTPLUG_H
+
+#include "hw/acpi/acpi.h"
+#include "hw/acpi/cpu_hotplug_defs.h"
+
+typedef struct AcpiCpuHotplug {
+    MemoryRegion io;
+    uint8_t sts[ACPI_GPE_PROC_LEN];
+} AcpiCpuHotplug;
+
+void AcpiCpuHotplug_add(ACPIGPE *gpe, AcpiCpuHotplug *g, CPUState *cpu);
+
+void AcpiCpuHotplug_init(MemoryRegion *parent, Object *owner,
+                         AcpiCpuHotplug *gpe_cpu, uint16_t base);
+#endif
include/hw/acpi/cpu_hotplug_defs.h new file +22 -0
new file mode 100644
index 0000000..c6c4f78
@@ -0,0 +1,22 @@
+/*
+ * QEMU ACPI hotplug utilities shared defines
+ *
+ * Copyright (C) 2013 Red Hat Inc
+ *
+ * Authors:
+ *   Igor Mammedov <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef ACPI_HOTPLUG_DEFS_H
+#define ACPI_HOTPLUG_DEFS_H
+
+/*
+ * ONLY DEFINEs are permited in this file since it's shared
+ * between C and ASL code.
+ */
+#define ACPI_CPU_HOTPLUG_STATUS 4
+#define ACPI_GPE_PROC_LEN 32
+
+#endif
Signature · 1 line
1.7.1
#2 lore raw

PATCH v3 2/9 acpi: ich9: add CPU hotplug handling to Q35 machine

In reply to Igor Mammedov

.. use IO port 0cd8-0xcf7 range for CPU present bitmap

---
 docs/specs/acpi_cpu_hotplug.txt    |    4 +++-
 hw/acpi/ich9.c                     |   14 ++++++++++++++
 include/hw/acpi/cpu_hotplug_defs.h |    1 +
 include/hw/acpi/ich9.h             |    4 ++++
 4 files changed, 22 insertions(+), 1 deletions(-)
docs/specs/acpi_cpu_hotplug.txt +3 -1
index f6f5774..340b751 100644
@@ -10,7 +10,9 @@ ACPI GPE block (IO ports 0xafe0-0xafe3, byte access):
 Generic ACPI GPE block. Bit 2 (GPE.2) used to notify CPU
 hot-add/remove event to ACPI BIOS, via SCI interrupt.
 
-CPU present bitmap (IO port 0xaf00-0xaf1f, 1-byte access):
+CPU present bitmap for:
+  ICH9-LPC (IO port 0x0cd8-0xcf7, 1-byte access)
+  PIIX-PM  (IO port 0xaf00-0xaf1f, 1-byte access)
 ---------------------------------------------------------------
 One bit per CPU. Bit position reflects corresponding CPU APIC ID.
 Read-only.
hw/acpi/ich9.c +14 -0
index 30f0df8..0afac42 100644
@@ -185,6 +185,15 @@ static void pm_powerdown_req(Notifier *n, void *opaque)
     acpi_pm1_evt_power_down(&pm->acpi_regs);
 }
 
+static void ich9_cpu_added_req(Notifier *n, void *opaque)
+{
+    ICH9LPCPMRegs *pm = container_of(n, ICH9LPCPMRegs, cpu_added_notifier);
+
+    assert(pm != NULL);
+    AcpiCpuHotplug_add(&pm->acpi_regs.gpe, &pm->gpe_cpu, CPU(opaque));
+    acpi_update_sci(&pm->acpi_regs, pm->irq);
+}
+
 void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
                   qemu_irq sci_irq)
 {
@@ -210,6 +219,11 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
     qemu_register_reset(pm_reset, pm);
     pm->powerdown_notifier.notify = pm_powerdown_req;
     qemu_register_powerdown_notifier(&pm->powerdown_notifier);
+
+    AcpiCpuHotplug_init(pci_address_space_io(lpc_pci), OBJECT(lpc_pci),
+                        &pm->gpe_cpu, ICH9_CPU_HOTPLUG_IO_BASE);
+    pm->cpu_added_notifier.notify = ich9_cpu_added_req;
+    qemu_register_cpu_added_notifier(&pm->cpu_added_notifier);
 }
 
 static void ich9_pm_get_gpe0_blk(Object *obj, Visitor *v,
include/hw/acpi/cpu_hotplug_defs.h +1 -0
index c6c4f78..47a35e3 100644
@@ -18,5 +18,6 @@
  */
 #define ACPI_CPU_HOTPLUG_STATUS 4
 #define ACPI_GPE_PROC_LEN 32
+#define ICH9_CPU_HOTPLUG_IO_BASE 0x0CD8
 
 #endif
include/hw/acpi/ich9.h +4 -0
index 82fcf9f..104f419 100644
@@ -22,6 +22,7 @@
 #define HW_ACPI_ICH9_H
 
 #include "hw/acpi/acpi.h"
+#include "hw/acpi/cpu_hotplug.h"
 
 typedef struct ICH9LPCPMRegs {
     /*
@@ -42,6 +43,9 @@ typedef struct ICH9LPCPMRegs {
 
     uint32_t pm_io_base;
     Notifier powerdown_notifier;
+
+    AcpiCpuHotplug gpe_cpu;
+    Notifier cpu_added_notifier;
 } ICH9LPCPMRegs;
 
 void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
Signature · 1 line
1.7.1
#3 lore raw

PATCH v3 3/9 pc: make: fix dependencies: rebuild when included file is changed

In reply to Igor Mammedov

some *.dsl files include another *.dsl files but there weren't any dependicies and when included file changed target table wasn't rebuild. Fix this by using the same auto dependency generation as for C files.

---
 hw/i386/Makefile.objs |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/i386/Makefile.objs +1 -1
index 09ac433..d58a103 100644
@@ -17,7 +17,7 @@ iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \
 ifdef IASL
 #IASL Present. Generate hex files from .dsl
 hw/i386/%.hex: $(SRC_PATH)/hw/i386/%.dsl $(SRC_PATH)/scripts/acpi_extract_preprocess.py $(SRC_PATH)/scripts/acpi_extract.py
-	$(call quiet-command, cpp -P $< -o $*.dsl.i.orig, "  CPP $(TARGET_DIR)$*.dsl.i.orig")
+	$(call quiet-command, cpp -P $(QEMU_DGFLAGS) $< -o $*.dsl.i.orig, "  CPP $(TARGET_DIR)$*.dsl.i.orig")
 	$(call quiet-command, $(PYTHON) $(SRC_PATH)/scripts/acpi_extract_preprocess.py $*.dsl.i.orig > $*.dsl.i, "  ACPI_PREPROCESS $(TARGET_DIR)$*.dsl.i")
 	$(call quiet-command, $(IASL) $(call iasl-option,$(IASL),-Pn,) -vs -l -tc -p $* $*.dsl.i $(if $(V), , > /dev/null) 2>&1 ,"  IASL $(TARGET_DIR)$*.dsl.i")
 	$(call quiet-command, $(PYTHON) $(SRC_PATH)/scripts/acpi_extract.py $*.lst > $*.off, "  ACPI_EXTRACT $(TARGET_DIR)$*.off")
Signature · 1 line
1.7.1
#4 lore raw

PATCH v3 4/9 pc: set PRST base in DSDT depending on chipset

In reply to Igor Mammedov
---
 hw/i386/acpi-dsdt-cpu-hotplug.dsl |    2 +-
 hw/i386/acpi-dsdt.dsl             |    1 +
 hw/i386/q35-acpi-dsdt.dsl         |    1 +
 3 files changed, 3 insertions(+), 1 deletions(-)
hw/i386/acpi-dsdt-cpu-hotplug.dsl +1 -1
index 995b415..1dfbb4f 100644
@@ -52,7 +52,7 @@ Scope(\_SB) {
         Sleep(200)
     }
 
-    OperationRegion(PRST, SystemIO, 0xaf00, 32)
+    OperationRegion(PRST, SystemIO, CPU_STATUS_BASE, 32)
     Field(PRST, ByteAcc, NoLock, Preserve) {
         PRS, 256
     }
hw/i386/acpi-dsdt.dsl +1 -0
index 6d76f30..3dc4789 100644
@@ -290,6 +290,7 @@ DefinitionBlock (
         }
     }
 
+#define CPU_STATUS_BASE 0xaf00
 #include "acpi-dsdt-cpu-hotplug.dsl"
 
 
hw/i386/q35-acpi-dsdt.dsl +1 -0
index ee38fd6..9a43947 100644
@@ -405,6 +405,7 @@ DefinitionBlock (
         define_gsi_link(GSIH, 0, 0x17)
     }
 
+#define CPU_STATUS_BASE 0x0CD8
 #include "acpi-dsdt-cpu-hotplug.dsl"
 
 
Signature · 1 line
1.7.1
#5 lore raw

PATCH v3 5/9 pc: PIIX DSDT: exclude CPU/PCI hotplug & GPE0 IO range from PCI bus resources

In reply to Igor Mammedov

.. so that they might not be used by PCI devices.

Note:
Resort to concatenating templates with preprocessor help, because 1.0b spec isn't supporting ConcatenateResTemplate, as result Windows XP fails to execute PCI0._CRS method if ConcatenateResTemplate() is used.

---
Follow up patch will expose them as motherboard resources

v2:
* add comments about holes origins for PCI/CPU hotplug and GPE0

---
 hw/i386/acpi-dsdt-pci-crs.dsl |    8 +-------
 hw/i386/acpi-dsdt.dsl         |   32 ++++++++++++++++++++++++++++++++
 hw/i386/q35-acpi-dsdt.dsl     |    8 ++++++++
 3 files changed, 41 insertions(+), 7 deletions(-)
hw/i386/acpi-dsdt-pci-crs.dsl +1 -7
index b375a19..8b631d1 100644
@@ -37,13 +37,7 @@ Scope(\_SB.PCI0) {
             0x0000,             // Address Translation Offset
             0x0CF8,             // Address Length
             ,, , TypeStatic)
-        WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
-            0x0000,             // Address Space Granularity
-            0x0D00,             // Address Range Minimum
-            0xFFFF,             // Address Range Maximum
-            0x0000,             // Address Translation Offset
-            0xF300,             // Address Length
-            ,, , TypeStatic)
+        BOARD_SPECIFIC_PCI_RESOURSES
         DWordMemory(ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite,
             0x00000000,         // Address Space Granularity
             0x000A0000,         // Address Range Minimum
hw/i386/acpi-dsdt.dsl +32 -0
index 3dc4789..f501c8d 100644
@@ -35,6 +35,38 @@ DefinitionBlock (
 /****************************************************************
  * PCI Bus definition
  ****************************************************************/
+#define BOARD_SPECIFIC_PCI_RESOURSES \
+     WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \
+         0x0000, \
+         0x0D00, \
+         0xADFF, \
+         0x0000, \
+         0xA100, \
+         ,, , TypeStatic) \
+     /* 0xae00-0xae0e hole for PCI hotplug, hw/acpi/piix4.c:PCI_HOTPLUG_ADDR */ \
+     WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \
+         0x0000, \
+         0xAE0F, \
+         0xAEFF, \
+         0x0000, \
+         0x00F1, \
+         ,, , TypeStatic) \
+     /* 0xaf00-0xaf1f hole for CPU hotplug, hw/acpi/piix4.c:PIIX4_PROC_BASE */ \
+     WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \
+         0x0000, \
+         0xAF20, \
+         0xAFDF, \
+         0x0000, \
+         0x00C0, \
+         ,, , TypeStatic) \
+     /* 0xafe0-0xafe3 hole for ACPI.GPE0, hw/acpi/piix4.c:GPE_BASE */ \
+     WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \
+         0x0000, \
+         0xAFE4, \
+         0xFFFF, \
+         0x0000, \
+         0x501C, \
+         ,, , TypeStatic)
 
     Scope(\_SB) {
         Device(PCI0) {
hw/i386/q35-acpi-dsdt.dsl +8 -0
index 9a43947..f3e5921 100644
@@ -48,6 +48,14 @@ DefinitionBlock (
 /****************************************************************
  * PCI Bus definition
  ****************************************************************/
+#define BOARD_SPECIFIC_PCI_RESOURSES \
+     WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \
+         0x0000, \
+         0x0D00, \
+         0xFFFF, \
+         0x0000, \
+         0xF300, \
+         ,, , TypeStatic)
 
     Scope(\_SB) {
         Device(PCI0) {
Signature · 1 line
1.7.1
#6 lore raw

PATCH v3 6/9 pc: Q35 DSDT: exclude CPU hotplug IO range from PCI bus resources

In reply to Igor Mammedov

... for range defined at hw/acpi/ich9.c:ICH9_PROC_BASE

---
v2:
* add comment about hole origin for CPU hotplug

---
 hw/i386/acpi-dsdt-pci-crs.dsl |    7 -------
 hw/i386/acpi-dsdt.dsl         |    7 +++++++
 hw/i386/q35-acpi-dsdt.dsl     |    8 ++++++++
 3 files changed, 15 insertions(+), 7 deletions(-)
hw/i386/acpi-dsdt-pci-crs.dsl +0 -7
index 8b631d1..4648e90 100644
@@ -30,13 +30,6 @@ Scope(\_SB.PCI0) {
             0x01,               // Address Alignment
             0x08,               // Address Length
             )
-        WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
-            0x0000,             // Address Space Granularity
-            0x0000,             // Address Range Minimum
-            0x0CF7,             // Address Range Maximum
-            0x0000,             // Address Translation Offset
-            0x0CF8,             // Address Length
-            ,, , TypeStatic)
         BOARD_SPECIFIC_PCI_RESOURSES
         DWordMemory(ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite,
             0x00000000,         // Address Space Granularity
hw/i386/acpi-dsdt.dsl +7 -0
index f501c8d..d89dcda 100644
@@ -38,6 +38,13 @@ DefinitionBlock (
 #define BOARD_SPECIFIC_PCI_RESOURSES \
      WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \
          0x0000, \
+         0x0000, \
+         0x0CF7, \
+         0x0000, \
+         0x0CF8, \
+         ,, , TypeStatic) \
+     WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \
+         0x0000, \
          0x0D00, \
          0xADFF, \
          0x0000, \
hw/i386/q35-acpi-dsdt.dsl +8 -0
index f3e5921..9e070ee 100644
@@ -51,6 +51,14 @@ DefinitionBlock (
 #define BOARD_SPECIFIC_PCI_RESOURSES \
      WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \
          0x0000, \
+         0x0000, \
+         0x0CD7, \
+         0x0000, \
+         0x0CD8, \
+         ,, , TypeStatic) \
+     /* 0xcd8-0xcf7 hole for CPU hotplug, hw/acpi/ich9.c:ICH9_PROC_BASE */ \
+     WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \
+         0x0000, \
          0x0D00, \
          0xFFFF, \
          0x0000, \
Signature · 1 line
1.7.1
#10 lore raw

PATCH v3 8/9 pc: ACPI: unify source of CPU hotplug IO base/len

In reply to Igor Mammedov

use C headers defines as source of IO base/len for respective values in ASL code.

---
v2:
* add cpu_hotplug_defs.h for sharing defines to reduce ifdeffenery

---
 hw/acpi/piix4.c                    |    5 ++---
 hw/i386/Makefile.objs              |    2 +-
 hw/i386/acpi-dsdt-cpu-hotplug.dsl  |    2 +-
 hw/i386/acpi-dsdt.dsl              |    3 ++-
 hw/i386/q35-acpi-dsdt.dsl          |    3 ++-
 include/hw/acpi/cpu_hotplug_defs.h |    1 +
 6 files changed, 9 insertions(+), 7 deletions(-)
hw/acpi/piix4.c +2 -3
index 9b7fe6b..4161d06 100644
@@ -51,8 +51,6 @@
 #define PCI_EJ_BASE 0xae08
 #define PCI_RMV_BASE 0xae0c
 
-#define PIIX4_PROC_BASE 0xaf00
-
 #define PIIX4_PCI_HOTPLUG_STATUS 2
 
 struct pci_status {
@@ -702,7 +700,8 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
         pci_bus_hotplug(bus, piix4_device_hotplug, DEVICE(s));
     }
 
-    AcpiCpuHotplug_init(parent, OBJECT(s), &s->gpe_cpu, PIIX4_PROC_BASE);
+    AcpiCpuHotplug_init(parent, OBJECT(s), &s->gpe_cpu,
+                        PIIX4_CPU_HOTPLUG_IO_BASE);
     s->cpu_added_notifier.notify = piix4_cpu_added_req;
     qemu_register_cpu_added_notifier(&s->cpu_added_notifier);
 }
hw/i386/Makefile.objs +1 -1
index d58a103..3df1612 100644
@@ -17,7 +17,7 @@ iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \
 ifdef IASL
 #IASL Present. Generate hex files from .dsl
 hw/i386/%.hex: $(SRC_PATH)/hw/i386/%.dsl $(SRC_PATH)/scripts/acpi_extract_preprocess.py $(SRC_PATH)/scripts/acpi_extract.py
-	$(call quiet-command, cpp -P $(QEMU_DGFLAGS) $< -o $*.dsl.i.orig, "  CPP $(TARGET_DIR)$*.dsl.i.orig")
+	$(call quiet-command, cpp -P $(QEMU_DGFLAGS) $(QEMU_INCLUDES) $< -o $*.dsl.i.orig, "  CPP $(TARGET_DIR)$*.dsl.i.orig")
 	$(call quiet-command, $(PYTHON) $(SRC_PATH)/scripts/acpi_extract_preprocess.py $*.dsl.i.orig > $*.dsl.i, "  ACPI_PREPROCESS $(TARGET_DIR)$*.dsl.i")
 	$(call quiet-command, $(IASL) $(call iasl-option,$(IASL),-Pn,) -vs -l -tc -p $* $*.dsl.i $(if $(V), , > /dev/null) 2>&1 ,"  IASL $(TARGET_DIR)$*.dsl.i")
 	$(call quiet-command, $(PYTHON) $(SRC_PATH)/scripts/acpi_extract.py $*.lst > $*.off, "  ACPI_EXTRACT $(TARGET_DIR)$*.off")
hw/i386/acpi-dsdt-cpu-hotplug.dsl +1 -1
index f91eafd..dee4843 100644
@@ -53,7 +53,7 @@ Scope(\_SB) {
         Sleep(200)
     }
 
-#define CPU_STATUS_LEN 32
+#define CPU_STATUS_LEN ACPI_GPE_PROC_LEN
     OperationRegion(PRST, SystemIO, CPU_STATUS_BASE, CPU_STATUS_LEN)
     Field(PRST, ByteAcc, NoLock, Preserve) {
         PRS, 256
hw/i386/acpi-dsdt.dsl +2 -1
index d89dcda..b23d5e0 100644
@@ -329,7 +329,8 @@ DefinitionBlock (
         }
     }
 
-#define CPU_STATUS_BASE 0xaf00
+#include "hw/acpi/cpu_hotplug_defs.h"
+#define CPU_STATUS_BASE PIIX4_CPU_HOTPLUG_IO_BASE
 #include "acpi-dsdt-cpu-hotplug.dsl"
 
 
hw/i386/q35-acpi-dsdt.dsl +2 -1
index 9e070ee..d618e9e 100644
@@ -421,7 +421,8 @@ DefinitionBlock (
         define_gsi_link(GSIH, 0, 0x17)
     }
 
-#define CPU_STATUS_BASE 0x0CD8
+#include "hw/acpi/cpu_hotplug_defs.h"
+#define CPU_STATUS_BASE ICH9_CPU_HOTPLUG_IO_BASE
 #include "acpi-dsdt-cpu-hotplug.dsl"
 
 
include/hw/acpi/cpu_hotplug_defs.h +1 -0
index 47a35e3..2725b50 100644
@@ -19,5 +19,6 @@
 #define ACPI_CPU_HOTPLUG_STATUS 4
 #define ACPI_GPE_PROC_LEN 32
 #define ICH9_CPU_HOTPLUG_IO_BASE 0x0CD8
+#define PIIX4_CPU_HOTPLUG_IO_BASE 0xaf00
 
 #endif
Signature · 1 line
1.7.1
#7 lore raw

PATCH v3 7/9 pc: ACPI: expose PRST IO range via _CRS

In reply to Igor Mammedov

.. so OSPM could notice resource conflict if there is any.

---
v2:
* use define for DEVICE name to make it more descriptive
* define _STA as present,functioning, decoding, not shown in UI

---
 hw/i386/acpi-dsdt-cpu-hotplug.dsl |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
hw/i386/acpi-dsdt-cpu-hotplug.dsl +13 -1
index 1dfbb4f..f91eafd 100644
@@ -16,6 +16,7 @@
 /****************************************************************
  * CPU hotplug
  ****************************************************************/
+#define CPU_HOTPLUG_RESOURCE_DEVICE PRES
 
 Scope(\_SB) {
     /* Objects filled in by run-time generated SSDT */
@@ -52,7 +53,8 @@ Scope(\_SB) {
         Sleep(200)
     }
 
-    OperationRegion(PRST, SystemIO, CPU_STATUS_BASE, 32)
+#define CPU_STATUS_LEN 32
+    OperationRegion(PRST, SystemIO, CPU_STATUS_BASE, CPU_STATUS_LEN)
     Field(PRST, ByteAcc, NoLock, Preserve) {
         PRS, 256
     }
@@ -89,4 +91,14 @@ Scope(\_SB) {
             Increment(Local0)
         }
     }
+
+    Device(CPU_HOTPLUG_RESOURCE_DEVICE) {
+        Name(_HID, "ACPI0004")
+
+        Name(_CRS, ResourceTemplate() {
+            IO(Decode16, CPU_STATUS_BASE, CPU_STATUS_BASE, 0, CPU_STATUS_LEN)
+        })
+
+        Name(_STA, 0xB) /* present, functioning, decoding, not shown in UI */
+    }
 }
Signature · 1 line
1.7.1
#11 lore raw

PATCH v3 9/9 pc: ACPI: update acpi-dsdt.hex.generated q35-acpi-dsdt.hex.generated

In reply to Igor Mammedov
---
 hw/i386/acpi-dsdt.hex.generated     |  333 +++++++++++++++++++++++++++--------
 hw/i386/q35-acpi-dsdt.hex.generated |  138 ++++++++++++--
 2 files changed, 374 insertions(+), 97 deletions(-)
hw/i386/acpi-dsdt.hex.generated +256 -77
index f8bd4ea..63b7e85 100644
@@ -3,12 +3,12 @@ static unsigned char AcpiDsdtAmlCode[] = {
 0x53,
 0x44,
 0x54,
-0x37,
+0xe7,
 0x11,
 0x0,
 0x0,
 0x1,
-0xd8,
+0x4d,
 0x42,
 0x58,
 0x50,
@@ -32,8 +32,8 @@ static unsigned char AcpiDsdtAmlCode[] = {
 0x54,
 0x4c,
 0x23,
-0x8,
-0x13,
+0x1,
+0x9,
 0x20,
 0x10,
 0x49,
@@ -146,7 +146,7 @@ static unsigned char AcpiDsdtAmlCode[] = {
 0x1,
 0x10,
 0x4e,
-0x15,
+0x18,
 0x2e,
 0x5f,
 0x53,
@@ -163,9 +163,9 @@ static unsigned char AcpiDsdtAmlCode[] = {
 0x53,
 0x11,
 0x42,
-0x7,
 0xa,
-0x6e,
+0xa,
+0x9e,
 0x88,
 0xd,
 0x0,
@@ -217,11 +217,59 @@ static unsigned char AcpiDsdtAmlCode[] = {
 0x0,
 0xd,
 0xff,
+0xad,
+0x0,
+0x0,
+0x0,
+0xa1,
+0x88,
+0xd,
+0x0,
+0x1,
+0xc,
+0x3,
+0x0,
+0x0,
+0xf,
+0xae,
 0xff,
+0xae,
+0x0,
+0x0,
+0xf1,
+0x0,
+0x88,
+0xd,
+0x0,
+0x1,
+0xc,
+0x3,
+0x0,
+0x0,
+0x20,
+0xaf,
+0xdf,
+0xaf,
+0x0,
 0x0,
+0xc0,
+0x0,
+0x88,
+0xd,
+0x0,
+0x1,
+0xc,
+0x3,
+0x0,
+0x0,
+0xe4,
+0xaf,
+0xff,
+0xff,
 0x0,
 0x0,
-0xf3,
+0x1c,
+0x50,
 0x87,
 0x17,
 0x0,
@@ -347,7 +395,7 @@ static unsigned char AcpiDsdtAmlCode[] = {
 0x45,
 0x53,
 0xa,
-0x5c,
+0x8c,
 0x50,
 0x53,
 0x33,
@@ -358,7 +406,7 @@ static unsigned char AcpiDsdtAmlCode[] = {
 0x45,
 0x53,
 0xa,
-0x60,
+0x90,
 0x50,
 0x45,
 0x33,
@@ -369,7 +417,7 @@ static unsigned char AcpiDsdtAmlCode[] = {
 0x45,
 0x53,
 0xa,
-0x68,
+0x98,
 0x50,
 0x4c,
 0x33,
@@ -860,8 +908,8 @@ static unsigned char AcpiDsdtAmlCode[] = {
 0x4e,
 0x1,
 0x10,
-0x4c,
-0x1b,
+0x4b,
+0x1e,
 0x2f,
 0x3,
 0x5f,
@@ -879,6 +927,53 @@ static unsigned char AcpiDsdtAmlCode[] = {
 0x5b,
 0x82,
 0x2d,
+0x53,
+0x4d,
+0x43,
+0x5f,
+0x8,
+0x5f,
+0x48,
+0x49,
+0x44,
+0xc,
+0x6,
+0x10,
+0x0,
+0x1,
+0x8,
+0x5f,
+0x53,
+0x54,
+0x41,
+0xb,
+0x0,
+0xff,
+0x8,
+0x5f,
+0x43,
+0x52,
+0x53,
+0x11,
+0x10,
+0xa,
+0xd,
+0x47,
+0x1,
+0x0,
+0x3,
+0x0,
+0x3,
+0x1,
+0x20,
+0x22,
+0x40,
+0x0,
+0x79,
+0x0,
+0x5b,
+0x82,
+0x2d,
 0x52,
 0x54,
 0x43,
@@ -1305,7 +1400,7 @@ static unsigned char AcpiDsdtAmlCode[] = {
 0x79,
 0x0,
 0x10,
-0x4b,
+0x48,
 0x8,
 0x2e,
 0x5f,
@@ -1371,79 +1466,76 @@ static unsigned char AcpiDsdtAmlCode[] = {
 0x45,
 0x4a,
 0x20,
+0x5b,
+0x80,
+0x42,
+0x4e,
+0x4d,
+0x52,
+0x1,
+0xb,
+0x10,
+0xae,
+0xa,
+0x4,
+0x5b,
+0x81,
+0xb,
+0x42,
+0x4e,
+0x4d,
+0x52,
+0x43,
+0x42,
+0x4e,
+0x55,
+0x4d,
+0x20,
+0x5b,
+0x1,
+0x42,
+0x4c,
+0x43,
+0x4b,
+0x0,
 0x14,
-0x11,
+0x25,
 0x50,
 0x43,
 0x45,
 0x4a,
-0x1,
+0x2,
+0x5b,
+0x23,
+0x42,
+0x4c,
+0x43,
+0x4b,
+0xff,
+0xff,
 0x70,
-0x79,
-0x1,
 0x68,
-0x0,
 0x42,
-0x30,
-0x45,
-0x4a,
-0xa4,
-0x0,
-0x14,
-0x36,
-0x50,
-0x43,
 0x4e,
-0x46,
-0x0,
-0x70,
-0x0,
-0x60,
-0xa2,
-0x2c,
-0x95,
-0x60,
-0xa,
-0x1f,
-0x75,
-0x60,
-0xa0,
-0x11,
-0x7b,
-0x50,
-0x43,
-0x49,
 0x55,
+0x4d,
+0x70,
 0x79,
 0x1,
-0x60,
+0x69,
 0x0,
-0x0,
-0x50,
-0x43,
-0x4e,
-0x54,
-0x60,
-0x1,
-0xa0,
-0x12,
-0x7b,
-0x50,
+0x42,
+0x30,
+0x45,
+0x4a,
+0x5b,
+0x27,
+0x42,
+0x4c,
 0x43,
-0x49,
-0x44,
-0x79,
-0x1,
-0x60,
-0x0,
+0x4b,
+0xa4,
 0x0,
-0x50,
-0x43,
-0x4e,
-0x54,
-0x60,
-0xa,
-0x3,
 0x10,
 0x4a,
 0xa0,
@@ -4017,7 +4109,7 @@ static unsigned char AcpiDsdtAmlCode[] = {
 0x1,
 0x10,
 0x47,
-0xe,
+0x11,
 0x5f,
 0x53,
 0x42,
@@ -4247,9 +4339,57 @@ static unsigned char AcpiDsdtAmlCode[] = {
 0x3,
 0x75,
 0x60,
+0x5b,
+0x82,
+0x2e,
+0x50,
+0x52,
+0x45,
+0x53,
+0x8,
+0x5f,
+0x48,
+0x49,
+0x44,
+0xd,
+0x41,
+0x43,
+0x50,
+0x49,
+0x30,
+0x30,
+0x30,
+0x34,
+0x0,
+0x8,
+0x5f,
+0x43,
+0x52,
+0x53,
+0x11,
+0xd,
+0xa,
+0xa,
+0x47,
+0x1,
+0x0,
+0xaf,
+0x0,
+0xaf,
+0x0,
+0x20,
+0x79,
+0x0,
+0x8,
+0x5f,
+0x53,
+0x54,
+0x41,
+0xa,
+0xb,
 0x10,
-0x4e,
-0x9,
+0x42,
+0xc,
 0x5f,
 0x47,
 0x50,
@@ -4277,12 +4417,31 @@ static unsigned char AcpiDsdtAmlCode[] = {
 0x30,
 0x0,
 0x14,
-0x15,
+0x39,
 0x5f,
 0x45,
 0x30,
 0x31,
 0x0,
+0x5b,
+0x23,
+0x5c,
+0x2f,
+0x3,
+0x5f,
+0x53,
+0x42,
+0x5f,
+0x50,
+0x43,
+0x49,
+0x30,
+0x42,
+0x4c,
+0x43,
+0x4b,
+0xff,
+0xff,
 0x5c,
 0x2f,
 0x3,
@@ -4297,7 +4456,24 @@ static unsigned char AcpiDsdtAmlCode[] = {
 0x50,
 0x43,
 0x4e,
-0x46,
+0x54,
+0x5b,
+0x27,
+0x5c,
+0x2f,
+0x3,
+0x5f,
+0x53,
+0x42,
+0x5f,
+0x50,
+0x43,
+0x49,
+0x30,
+0x42,
+0x4c,
+0x43,
+0x4b,
 0x14,
 0x10,
 0x5f,
@@ -4407,3 +4583,6 @@ static unsigned char AcpiDsdtAmlCode[] = {
 0x46,
 0x0
 };
+static unsigned short piix_dsdt_applesmc_sta[] = {
+0x3b4
+};
hw/i386/q35-acpi-dsdt.hex.generated +118 -20

212 lines not on this page · raw message

Signature · 1 line
1.7.1
#12 lore raw
In reply to Igor Mammedov
Quoted 27 lines · Igor Mammedov

Changes since v2:
* use dependency auto generation for *.dsl files
* hide DEVICE(PRES) from UI
* add comments to document holes punched in CRES
* reduce ifdeffenery by moving CPU hotplug defines to
a dedicated header shared between C and ASL files
* other odd changes requested by "Michael S. Tsirkin" <[email protected]>

Changes since v1:
* renamed hotplug.c/.h to cpu_hotplug.c/.h
* make all prefixes acpi_cpu_hotplug and AcpiCpuHotplug
* updated docs/specs/acpi_cpu_hotplug.txt with Q35's IO port range
* exclude CPU/PCI/GPE IO ranges from resources advertised in PCI bus _CRS
* advertise CPU hotplug IO range using ACPI Device(ACPI0004)._CRS object.
* change Q35 IO port ase from 0xa18 to 0xcd8, to avoid increasing fragmentation of PCI bus IO space
* replaced runtime IO port setting with compile time one, since port mapping is hadcoded and there is not real need to set it dynamically.
* Use the same headers for C and ASL code so that port/length values won't be duplicated.
* Fix deps for ACPI tables, so that thay would be rebuild when included files are touched. (Added only includes, I've touched, it's not complete but a good start anyway)

Quoted 4 lines

Tested with RHEL6, WS2012R2, WS2003

Series is based on mst/pci tree, git tree for testing:
https://github.com/imammedo/qemu/commits/q35_cpu_hp_v3

I have applied this, thanks!

Quoted 31 lines

Igor Mammedov (9):
acpi: factor out common cpu hotplug code for PIIX4/Q35
acpi: ich9: add CPU hotplug handling to Q35 machine
pc: make: fix dependencies: rebuild when included file is changed
pc: set PRST base in DSDT depending on chipset
pc: PIIX DSDT: exclude CPU/PCI hotplug & GPE0 IO range from PCI bus
resources
pc: Q35 DSDT: exclude CPU hotplug IO range from PCI bus resources
pc: ACPI: expose PRST IO range via _CRS
pc: ACPI: unify source of CPU hotplug IO base/len
pc: ACPI: update acpi-dsdt.hex.generated q35-acpi-dsdt.hex.generated

 docs/specs/acpi_cpu_hotplug.txt     |    4 +-
 hw/acpi/Makefile.objs               |    2 +-
 hw/acpi/cpu_hotplug.c               |   64 +++++++
 hw/acpi/ich9.c                      |   14 ++
 hw/acpi/piix4.c                     |   80 +--------
 hw/i386/Makefile.objs               |    2 +-
 hw/i386/acpi-dsdt-cpu-hotplug.dsl   |   14 ++-
 hw/i386/acpi-dsdt-pci-crs.dsl       |   15 +--
 hw/i386/acpi-dsdt.dsl               |   41 +++++
 hw/i386/acpi-dsdt.hex.generated     |  333 +++++++++++++++++++++++++++--------
 hw/i386/q35-acpi-dsdt.dsl           |   18 ++
 hw/i386/q35-acpi-dsdt.hex.generated |  138 ++++++++++++--
 include/hw/acpi/cpu_hotplug.h       |   27 +++
 include/hw/acpi/cpu_hotplug_defs.h  |   24 +++
 include/hw/acpi/ich9.h              |    4 +
 15 files changed, 592 insertions(+), 188 deletions(-)
 create mode 100644 hw/acpi/cpu_hotplug.c
 create mode 100644 include/hw/acpi/cpu_hotplug.h
 create mode 100644 include/hw/acpi/cpu_hotplug_defs.h
#8 lore raw

Re: [Qemu-devel] [PATCH 7/9] pc: ACPI: expose PRST IO range via _CRS

In reply to Igor Mammedov
Quoted 3 lines · Igor Mammedov

.. so OSPM could notice resource conflict if there is any.

Hi Igor,
I noticed an unpleasant side effect caused by this patch. Now, windows xp prompts me for a driver for this device every time I boot it.

If I click cancel it goes away, but it's annoying. I think ACPI0004 is too new for winxp to recognize it. I tried the following patch and it seems to work fine. What do you think?

hw/i386/acpi-dsdt-cpu-hotplug.dsl +1 -1
index dee4843..34aab5a 100644
@@ -93,7 +93,7 @@ Scope(\_SB) {
     }
 
     Device(CPU_HOTPLUG_RESOURCE_DEVICE) {
-        Name(_HID, "ACPI0004")
+        Name(_HID, EisaId("PNP0A06"))
 
         Name(_CRS, ResourceTemplate() {
             IO(Decode16, CPU_STATUS_BASE, CPU_STATUS_BASE, 0, CPU_STATUS_LEN)
Quoted 47 lines

---
v2:
* use define for DEVICE name to make it more descriptive
* define _STA as present,functioning, decoding, not shown in UI

---
 hw/i386/acpi-dsdt-cpu-hotplug.dsl |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
hw/i386/acpi-dsdt-cpu-hotplug.dsl +13 -1
index 1dfbb4f..f91eafd 100644
@@ -16,6 +16,7 @@
 /****************************************************************
  * CPU hotplug
  ****************************************************************/
+#define CPU_HOTPLUG_RESOURCE_DEVICE PRES
 
 Scope(\_SB) {
     /* Objects filled in by run-time generated SSDT */
@@ -52,7 +53,8 @@ Scope(\_SB) {
         Sleep(200)
     }
 
-    OperationRegion(PRST, SystemIO, CPU_STATUS_BASE, 32)
+#define CPU_STATUS_LEN 32
+    OperationRegion(PRST, SystemIO, CPU_STATUS_BASE, CPU_STATUS_LEN)
     Field(PRST, ByteAcc, NoLock, Preserve) {
         PRS, 256
     }
@@ -89,4 +91,14 @@ Scope(\_SB) {
             Increment(Local0)
         }
     }
+
+    Device(CPU_HOTPLUG_RESOURCE_DEVICE) {
+        Name(_HID, "ACPI0004")
+
+        Name(_CRS, ResourceTemplate() {
+            IO(Decode16, CPU_STATUS_BASE, CPU_STATUS_BASE, 0, CPU_STATUS_LEN)
+        })
+
+        Name(_STA, 0xB) /* present, functioning, decoding, not shown in UI */
+    }
 }
Signature · 1 line
1.7.1
#9 lore raw

Re: [Qemu-devel] [PATCH 7/9] pc: ACPI: expose PRST IO range via _CRS

Quoted 10 lines · On Sun, 2 Feb 2014 15:12:55 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 3 lines · Igor Mammedov

.. so OSPM could notice resource conflict if there is any.

Hi Igor,
I noticed an unpleasant side effect caused by this patch. Now, windows xp prompts me for a driver for this device every time I boot it.

Quoted 4 lines

If I click cancel it goes away, but it's annoying. I think ACPI0004 is too new for winxp to recognize it. I tried the following patch and it seems to work fine. What do you think?

I have patches that refactor static holes punching into dynamic one using PNP0A02 device on PCI0 bus, but I still testing it make sure all windows versions are happy with it, and it's on top of hotplug refactoring series.
So I'll hold it off until hotplug refactoring series is in.

Quoted 64 lines
hw/i386/acpi-dsdt-cpu-hotplug.dsl +1 -1
index dee4843..34aab5a 100644
@@ -93,7 +93,7 @@ Scope(\_SB) {
     }
 
     Device(CPU_HOTPLUG_RESOURCE_DEVICE) {
-        Name(_HID, "ACPI0004")
+        Name(_HID, EisaId("PNP0A06"))
 
         Name(_CRS, ResourceTemplate() {
             IO(Decode16, CPU_STATUS_BASE, CPU_STATUS_BASE, 0, CPU_STATUS_LEN)
Quoted 50 lines

---
v2:
* use define for DEVICE name to make it more descriptive
* define _STA as present,functioning, decoding, not shown in UI

---
 hw/i386/acpi-dsdt-cpu-hotplug.dsl |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
hw/i386/acpi-dsdt-cpu-hotplug.dsl +13 -1
index 1dfbb4f..f91eafd 100644
@@ -16,6 +16,7 @@
 /****************************************************************
  * CPU hotplug
  ****************************************************************/
+#define CPU_HOTPLUG_RESOURCE_DEVICE PRES
 
 Scope(\_SB) {
     /* Objects filled in by run-time generated SSDT */
@@ -52,7 +53,8 @@ Scope(\_SB) {
         Sleep(200)
     }
 
-    OperationRegion(PRST, SystemIO, CPU_STATUS_BASE, 32)
+#define CPU_STATUS_LEN 32
+    OperationRegion(PRST, SystemIO, CPU_STATUS_BASE, CPU_STATUS_LEN)
     Field(PRST, ByteAcc, NoLock, Preserve) {
         PRS, 256
     }
@@ -89,4 +91,14 @@ Scope(\_SB) {
             Increment(Local0)
         }
     }
+
+    Device(CPU_HOTPLUG_RESOURCE_DEVICE) {
+        Name(_HID, "ACPI0004")
+
+        Name(_CRS, ResourceTemplate() {
+            IO(Decode16, CPU_STATUS_BASE, CPU_STATUS_BASE, 0, CPU_STATUS_LEN)
+        })
+
+        Name(_STA, 0xB) /* present, functioning, decoding, not shown in UI */
+    }
 }
Signature · 1 line
1.7.1
Signature · 2 lines
Regards,
  Igor