pc: CPU hotplug support for Q35
PATCH 1/11 acpi: piix4: remove not needed GPE0 mask
In reply to Igor MammedovHardcoded GPE0 mask isn't really needed. Since GPE0_STS initialized with all bits cleared and only QEMU itself can set bits there (i.e. guest can only clear bits in it). So guest can't triger SCI by setting _STS & _EN bits and there is not reason to mask out not supported _STS bits since they shouldn't be set by QEMU in the first place.
--- hw/acpi/piix4.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
hw/acpi/piix4.c +1 -2
@@ -122,8 +122,7 @@ static void pm_update_sci(PIIX4PMState *s)ACPI_BITMASK_POWER_BUTTON_ENABLE |ACPI_BITMASK_GLOBAL_LOCK_ENABLE | ACPI_BITMASK_TIMER_ENABLE)) != 0) || - (((s->ar.gpe.sts[0 ] & s->ar.gpe.en[0 ]) & - (PIIX4_PCI_HOTPLUG_STATUS |PIIX4_CPU_HOTPLUG_STATUS )) !=0 ); + ((s->ar.gpe.sts[0 ] & s->ar.gpe.en[0 ]) !=0 );qemu_set_irq (s->irq, sci_level);/* schedule a timer interruption if needed */
Signature · 1 line
1.8.3.1
PATCH 4/11 acpi/piix4: add readonly "cpu-hotplug-io-base" property
In reply to Igor Mammedov--- hw/acpi/piix4.c | 11 +++++++++++ include/hw/acpi/hotplug.h | 1 + 2 files changed, 12 insertions(+)
hw/acpi/piix4.c +11 -0
@@ -31,6 +31,7 @@#include "exec/address-spaces.h" #include "hw/acpi/piix4.h" #include "hw/acpi/hotplug.h" +#include "qapi/visitor.h" //#define DEBUG
@@ -384,6 +385,14 @@ static void piix4_pm_machine_ready(Notifier *n, void *opaque) (memory_region_present (io_as,0x2f8 ) ?0x90 :0 ); } +static void piix4_get_cpu_io_base (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +PIIX4PMState *s =PIIX4_PM (obj); + +visit_type_uint16 (v, &s->gpe_cpu.io_base, name, errp); +} +static void piix4_pm_add_propeties (PIIX4PMState *s) {static const uint8_t acpi_enable_cmd =ACPI_ENABLE ;
@@ -404,6 +413,8 @@ static void piix4_pm_add_propeties(PIIX4PMState *s) &sci_int, NULL);object_property_add_uint32_ptr (OBJECT (s),ACPI_PM_PROP_PM_IO_BASE , &s->io_base,NULL ); +object_property_add (OBJECT (s),ACPI_CPU_HOTPLUG_IO_BASE_PROP ,"int" , + piix4_get_cpu_io_base,NULL ,NULL ,NULL ,NULL ); }static int piix4_pm_initfn (PCIDevice *dev)
include/hw/acpi/hotplug.h +1 -0
@@ -14,6 +14,7 @@#include "hw/acpi/acpi.h" +#define ACPI_CPU_HOTPLUG_IO_BASE_PROP "cpu-hotplug-io-base"#define ACPI_CPU_HOTPLUG_STATUS 4#define ACPI_GPE_PROC_LEN 32
Signature · 1 line
1.8.3.1
PATCH 6/11 acpi/ich9: add CPU hotplug handling to Q35 machine
In reply to Igor Mammedov.. including readonly 'cpu-hotplug-io-base' property
--- hw/acpi/ich9.c | 27 +++++++++++++++++++++++++++ include/hw/acpi/ich9.h | 4 ++++ 2 files changed, 31 insertions(+)
hw/acpi/ich9.c +27 -0
@@ -44,6 +44,8 @@ do { printf("%s "fmt, __func__, ## __VA_ARGS__); } while (0)#define ICH9_DEBUG (fmt, ...) do { } while (0)#endif +#define ICH9_PROC_BASE 0xa18 +static void ich9_pm_update_sci_fn (ACPIREGS *regs) {ICH9LPCPMRegs *pm =container_of (regs, ICH9LPCPMRegs, acpi_regs);
@@ -185,6 +187,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 ); +acpi_hotplug_cpu_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 +221,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); + +acpi_hotplug_cpu_init (pci_address_space_io (lpc_pci),OBJECT (lpc_pci), + &pm->gpe_cpu, pm->gpe_cpu.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,
@@ -222,6 +238,14 @@ static void ich9_pm_get_gpe0_blk(Object *obj, Visitor *v,visit_type_uint32 (v, &value, name, errp); } +static void ich9_pm_get_cpu_io_base (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +ICH9LPCState *s =ICH9_LPC_DEVICE (obj); + +visit_type_uint16 (v, &s->pm.gpe_cpu.io_base, name, errp); +} +void ich9_pm_add_properties (Object *obj,ICH9LPCPMRegs *pm,Error **errp) {static const uint32_t gpe0_len =ICH9_PMIO_GPE0_LEN ;
@@ -233,4 +257,7 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm, Error **errp) NULL, NULL, pm, NULL);object_property_add_uint32_ptr (obj,ACPI_PM_PROP_GPE0_BLK_LEN , &gpe0_len, errp); + pm->gpe_cpu.io_base =ICH9_PROC_BASE ; +object_property_add (obj,ACPI_CPU_HOTPLUG_IO_BASE_PROP ,"int" , + ich9_pm_get_cpu_io_base,NULL ,NULL ,NULL ,NULL ); }
include/hw/acpi/ich9.h +4 -0
@@ -22,6 +22,7 @@#define HW_ACPI_ICH9_H #include "hw/acpi/acpi.h" +#include "hw/acpi/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.8.3.1
PATCH 8/11 ACPI/DSDT-CPU: cleanup bogus comment
In reply to Igor Mammedov--- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 1 - 1 file changed, 1 deletion(-)
hw/i386/acpi-dsdt-cpu-hotplug.dsl +0 -1
@@ -52,7 +52,6 @@ Scope(\_SB) { Sleep(200) } - /* CPU hotplug notify method */ OperationRegion(PRST, SystemIO, 0xaf00, 32) Field(PRST, ByteAcc, NoLock, Preserve) { PRS, 256
Signature · 1 line
1.8.3.1
PATCH 9/11 ACPI: move PRST OperationRegion into SSDT
In reply to Igor Mammedov.. and report range used by it to OSPM via _CRS. PRST is needed in SSDT since its base will depend on chipset and will be dynamically set by QEMU. Also move PRSC() method along with PRST since cross table reference to PRST doesn't work.
--- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 39 +---------------------- hw/i386/acpi-dsdt.dsl | 2 +- hw/i386/q35-acpi-dsdt.dsl | 2 +- hw/i386/ssdt-misc.dsl | 65 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 40 deletions(-)
hw/i386/acpi-dsdt-cpu-hotplug.dsl +1 -38
@@ -20,6 +20,7 @@ Scope(\_SB) { /* Objects filled in by run-time generated SSDT */ External(NTFY, MethodObj) + External(\_SB.CPHD.PRSC, MethodObj) External(CPON, PkgObj) /* Methods called by run-time generated SSDT Processor objects */
@@ -51,42 +52,4 @@ Scope(\_SB) { // _EJ0 method - eject callback Sleep(200) } - - OperationRegion(PRST, SystemIO, 0xaf00, 32) - Field(PRST, ByteAcc, NoLock, Preserve) { - PRS, 256 - } - Method(PRSC, 0) { - // Local5 = active cpu bitmap - Store(PRS, Local5) - // Local2 = last read byte from bitmap - Store(Zero, Local2) - // Local0 = Processor ID / APIC ID iterator - Store(Zero, Local0) - While (LLess(Local0, SizeOf(CPON))) { - // Local1 = CPON flag for this cpu - Store(DerefOf(Index(CPON, Local0)), Local1) - If (And(Local0, 0x07)) { - // Shift down previously read bitmap byte - ShiftRight(Local2, 1, Local2) - } Else { - // Read next byte from cpu bitmap - Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) - } - // Local3 = active state for this cpu - Store(And(Local2, 1), Local3) - - If (LNotEqual(Local1, Local3)) { - // State change - update CPON with new state - Store(Local3, Index(CPON, Local0)) - // Do CPU notify - If (LEqual(Local3, 1)) { - NTFY(Local0, 1) - } Else { - NTFY(Local0, 3) - } - } - Increment(Local0) - } - } }
hw/i386/acpi-dsdt.dsl +1 -1
@@ -311,7 +311,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPHD.PRSC() } Method(_L03) { }
hw/i386/q35-acpi-dsdt.dsl +1 -1
@@ -420,7 +420,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPHD.PRSC() } Method(_L03) { }
hw/i386/ssdt-misc.dsl +65 -0
69 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 7/11 ACPI: Q35 DSDT: fix CPU hotplug GPE0.2 handler
In reply to Igor MammedovFix bogus CPU hotplug GPE handler.
Make Q35 CPU hotplug GPE handler match PIIX4 one, since CPU hotplug event is triggered by GPE0.2 register.
--- hw/i386/q35-acpi-dsdt.dsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/i386/q35-acpi-dsdt.dsl +2 -2
@@ -417,11 +417,11 @@ DefinitionBlock ( Method(_L00) { } Method(_L01) { + } + Method(_E02) { // CPU hotplug event \_SB.PRSC() } - Method(_L02) { - } Method(_L03) { } Method(_L04) {
Signature · 1 line
1.8.3.1
PATCH 11/11 ACPI: update ssdt-misc.hex.generated acpi-dsdt.hex.generated q35-acpi-dsdt.hex.generated
In reply to Igor Mammedov--- hw/i386/acpi-dsdt.hex.generated | 152 ++------------------- hw/i386/q35-acpi-dsdt.hex.generated | 168 +++-------------------- hw/i386/ssdt-misc.hex.generated | 262 +++++++++++++++++++++++++++++++++++- 3 files changed, 290 insertions(+), 292 deletions(-)
hw/i386/acpi-dsdt.hex.generated +12 -140
@@ -3,12 +3,12 @@ static unsigned char AcpiDsdtAmlCode[] = { 0x53, 0x44, 0x54, -0x37, -0x11, +0xb7, +0x10, 0x0, 0x0, 0x1, -0xe0, +0xfc, 0x42, 0x58, 0x50,
@@ -4016,8 +4016,8 @@ static unsigned char AcpiDsdtAmlCode[] = { 0x53, 0x1, 0x10, -0x47, -0xe, +0x42, +0x6, 0x5f, 0x53, 0x42,
@@ -4114,142 +4114,9 @@ static unsigned char AcpiDsdtAmlCode[] = { 0x22, 0xa, 0xc8, -0x5b, -0x80, -0x50, -0x52, -0x53, -0x54, -0x1, -0xb, -0x0, -0xaf, -0xa, -0x20, -0x5b, -0x81, -0xc, -0x50, -0x52, -0x53, -0x54, -0x1, -0x50, -0x52, -0x53, -0x5f, -0x40, 0x10, -0x14, -0x4a, -0x6, -0x50, -0x52, -0x53, -0x43, -0x0, -0x70, -0x50, -0x52, -0x53, -0x5f, -0x65, -0x70, -0x0, -0x62, -0x70, -0x0, -0x60, -0xa2, -0x46, -0x5, -0x95, -0x60, -0x87, -0x43, -0x50, -0x4f, -0x4e, -0x70, -0x83, -0x88, -0x43, -0x50, -0x4f, -0x4e, -0x60, -0x0, -0x61, -0xa0, -0xa, -0x7b, -0x60, -0xa, -0x7, -0x0, -0x7a, -0x62, -0x1, -0x62, -0xa1, -0xc, -0x70, -0x83, -0x88, -0x65, -0x7a, -0x60, -0xa, -0x3, -0x0, -0x0, -0x62, -0x70, -0x7b, -0x62, -0x1, -0x0, -0x63, -0xa0, -0x22, -0x92, -0x93, -0x61, -0x63, -0x70, -0x63, -0x88, 0x43, -0x50, -0x4f, -0x4e, -0x60, -0x0, -0xa0, 0xa, -0x93, -0x63, -0x1, -0x4e, -0x54, -0x46, -0x59, -0x60, -0x1, -0xa1, -0x8, -0x4e, -0x54, -0x46, -0x59, -0x60, -0xa, -0x3, -0x75, -0x60, -0x10, -0x4e, -0x9, 0x5f, 0x47, 0x50,
@@ -4299,18 +4166,23 @@ static unsigned char AcpiDsdtAmlCode[] = { 0x4e, 0x46, 0x14, -0x10, +0x15, 0x5f, 0x45, 0x30, 0x32, 0x0, 0x5c, -0x2e, +0x2f, +0x3, 0x5f, 0x53, 0x42, 0x5f, +0x43, +0x50, +0x48, +0x44, 0x50, 0x52, 0x53,
hw/i386/q35-acpi-dsdt.hex.generated +20 -148
213 lines not on this page · raw message
hw/i386/ssdt-misc.hex.generated +258 -4
283 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 3/11 acpi: factor out common cpu hotplug code for PIIX4/Q35
In reply to Igor Mammedov.. so it could be used for adding CPU hotplug to Q35 machine
--- hw/acpi/Makefile.objs | 2 +- hw/acpi/hotplug.c | 65 +++++++++++++++++++++++++++++++++++++++ hw/acpi/piix4.c | 78 +++++------------------------------------------ include/hw/acpi/hotplug.h | 31 +++++++++++++++++++ 4 files changed, 104 insertions(+), 72 deletions(-) create mode 100644 hw/acpi/hotplug.c create mode 100644 include/hw/acpi/hotplug.h
hw/acpi/Makefile.objs +1 -1
@@ -1,2 +1,2 @@ -common-obj-$(CONFIG_ACPI) += core.o piix4.o ich9.o +common-obj-$(CONFIG_ACPI) += core.o piix4.o ich9.o hotplug.o
hw/acpi/hotplug.c new file +65 -0
65 lines not on this page · raw message
hw/acpi/piix4.c +7 -71
132 lines not on this page · raw message
include/hw/acpi/hotplug.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* 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" + +#define ACPI_CPU_HOTPLUG_STATUS 4 + +#define ACPI_GPE_PROC_LEN 32 + +typedef struct AcpiCPUHotplug { +MemoryRegion io; +uint16_t io_base; +uint8_t sts[ACPI_GPE_PROC_LEN ]; +}AcpiCPUHotplug ; + +void acpi_hotplug_cpu_add (ACPIGPE *gpe,AcpiCPUHotplug *g,CPUState *cpu); + +void acpi_hotplug_cpu_init (MemoryRegion *parent,Object *owner, +AcpiCPUHotplug *gpe_cpu,uint16_t base); +#endif
Signature · 1 line
1.8.3.1
PATCH 5/11 acpi: ich9: allow guest to clear SCI rised by GPE
In reply to Igor Mammedovit fixes IRQ storm since guest isn't able to lower SCI IRQ after it has been handled when it clears GPE event.
--- hw/acpi/ich9.c | 1 + 1 file changed, 1 insertion(+)
hw/acpi/ich9.c +1 -0
@@ -61,6 +61,7 @@ static void ich9_gpe_writeb(void *opaque, hwaddr addr, uint64_t val, {ICH9LPCPMRegs *pm = opaque;acpi_gpe_ioport_writeb (&pm->acpi_regs, addr, val); +acpi_update_sci (&pm->acpi_regs, pm->irq); }static const MemoryRegionOps ich9_gpe_ops = {
Signature · 1 line
1.8.3.1
cover pc: CPU hotplug support for Q35
Tested with RHEL6 & WS2012R2
git tree for testing:
https://github.com/imammedo/qemu/commits/q35_cpu_hp_v1
Igor Mammedov (11):
acpi: piix4: remove not needed GPE0 mask
acpi: factor out common pm_update_sci() into acpi core
acpi: factor out common cpu hotplug code for PIIX4/Q35 acpi/piix4: add readonly "cpu-hotplug-io-base" property
acpi: ich9: allow guest to clear SCI rised by GPE acpi/ich9: add CPU hotplug handling to Q35 machine
ACPI: Q35 DSDT: fix CPU hotplug GPE0.2 handler ACPI/DSDT-CPU: cleanup bogus comment
ACPI: move PRST OperationRegion into SSDT
ACPI: set CPU hotplug io base dynamically
ACPI: update ssdt-misc.hex.generated acpi-dsdt.hex.generated
q35-acpi-dsdt.hex.generated
hw/acpi/Makefile.objs | 2 +- hw/acpi/core.c | 18 +++ hw/acpi/hotplug.c | 65 +++++++++ hw/acpi/ich9.c | 49 ++++--- hw/acpi/piix4.c | 114 +++------------- hw/i386/acpi-build.c | 6 + hw/i386/acpi-dsdt-cpu-hotplug.dsl | 40 +----- hw/i386/acpi-dsdt.dsl | 2 +- hw/i386/acpi-dsdt.hex.generated | 152 ++------------------- hw/i386/q35-acpi-dsdt.dsl | 6 +- hw/i386/q35-acpi-dsdt.hex.generated | 168 +++-------------------- hw/i386/ssdt-misc.dsl | 66 +++++++++ hw/i386/ssdt-misc.hex.generated | 262 +++++++++++++++++++++++++++++++++++- include/hw/acpi/acpi.h | 8 ++ include/hw/acpi/hotplug.h | 32 +++++ include/hw/acpi/ich9.h | 4 + 16 files changed, 545 insertions(+), 449 deletions(-) create mode 100644 hw/acpi/hotplug.c create mode 100644 include/hw/acpi/hotplug.h
Signature · 1 line
1.8.3.1
PATCH 2/11 acpi: factor out common pm_update_sci() into acpi core
... and rename it into acpi_update_sci() since it changes SCI on only on PM registers status.
---
--- hw/acpi/core.c | 18 ++++++++++++++++++ hw/acpi/ich9.c | 23 ++--------------------- hw/acpi/piix4.c | 26 ++++---------------------- include/hw/acpi/acpi.h | 8 ++++++++ 4 files changed, 32 insertions(+), 43 deletions(-)
hw/acpi/core.c +18 -0
@@ -662,3 +662,21 @@ uint32_t acpi_gpe_ioport_readb(ACPIREGS *ar, uint32_t addr)return val; } + +void acpi_update_sci (ACPIREGS *regs,qemu_irq irq) +{ +int sci_level, pm1a_sts; + + pm1a_sts =acpi_pm1_evt_get_sts (regs); + + sci_level = ((pm1a_sts & + regs->pm1.evt.en &ACPI_BITMASK_PM1_COMMON_ENABLED ) !=0 ) || + ((regs->gpe.sts[0 ] & regs->gpe.en[0 ]) !=0 ); + +qemu_set_irq (irq, sci_level); + +/* schedule a timer interruption if needed */ +acpi_pm_tmr_update (regs, + (regs->pm1.evt.en &ACPI_BITMASK_TIMER_ENABLE ) && + !(pm1a_sts &ACPI_BITMASK_TIMER_STATUS )); +}
hw/acpi/ich9.c +2 -21
@@ -44,29 +44,10 @@ do { printf("%s "fmt, __func__, ## __VA_ARGS__); } while (0)#define ICH9_DEBUG (fmt, ...) do { } while (0)#endif -static void pm_update_sci (ICH9LPCPMRegs *pm) -{ -int sci_level, pm1a_sts; - - pm1a_sts =acpi_pm1_evt_get_sts (&pm->acpi_regs); - - sci_level = (((pm1a_sts & pm->acpi_regs.pm1.evt.en) & - (ACPI_BITMASK_RT_CLOCK_ENABLE | -ACPI_BITMASK_POWER_BUTTON_ENABLE | -ACPI_BITMASK_GLOBAL_LOCK_ENABLE | -ACPI_BITMASK_TIMER_ENABLE )) !=0 ); -qemu_set_irq (pm->irq, sci_level); - -/* schedule a timer interruption if needed */ -acpi_pm_tmr_update (&pm->acpi_regs, - (pm->acpi_regs.pm1.evt.en &ACPI_BITMASK_TIMER_ENABLE ) && - !(pm1a_sts &ACPI_BITMASK_TIMER_STATUS )); -} -static void ich9_pm_update_sci_fn (ACPIREGS *regs) {ICH9LPCPMRegs *pm =container_of (regs, ICH9LPCPMRegs, acpi_regs); -pm_update_sci (pm); +acpi_update_sci (&pm->acpi_regs, pm->irq); }static uint64_t ich9_gpe_readb (void *opaque,hwaddr addr,unsigned width)
@@ -193,7 +174,7 @@ static void pm_reset(void *opaque) pm->smi_en |=ICH9_PMIO_SMI_EN_APMC_EN ; } -pm_update_sci (pm); +acpi_update_sci (&pm->acpi_regs, pm->irq); }static void pm_powerdown_req (Notifier *n,void *opaque)
hw/acpi/piix4.c +4 -22
@@ -112,28 +112,10 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,#define ACPI_ENABLE 0xf1#define ACPI_DISABLE 0xf0 -static void pm_update_sci (PIIX4PMState *s) -{ -int sci_level, pmsts; - - pmsts =acpi_pm1_evt_get_sts (&s->ar); - sci_level = (((pmsts & s->ar.pm1.evt.en) & - (ACPI_BITMASK_RT_CLOCK_ENABLE | -ACPI_BITMASK_POWER_BUTTON_ENABLE | -ACPI_BITMASK_GLOBAL_LOCK_ENABLE | -ACPI_BITMASK_TIMER_ENABLE )) !=0 ) || - ((s->ar.gpe.sts[0 ] & s->ar.gpe.en[0 ]) !=0 ); - -qemu_set_irq (s->irq, sci_level); -/* schedule a timer interruption if needed */ -acpi_pm_tmr_update (&s->ar, (s->ar.pm1.evt.en &ACPI_BITMASK_TIMER_ENABLE ) && - !(pmsts &ACPI_BITMASK_TIMER_STATUS )); -} -static void pm_tmr_timer (ACPIREGS *ar) {PIIX4PMState *s =container_of (ar, PIIX4PMState, ar); -pm_update_sci (s); +acpi_update_sci (&s->ar, s->irq); }static void apm_ctrl_changed (uint32_t val,void *arg)
@@ -577,7 +559,7 @@ static void gpe_writeb(void *opaque, hwaddr addr, uint64_t val,PIIX4PMState *s = opaque;acpi_gpe_ioport_writeb (&s->ar, addr, val); -pm_update_sci (s); +acpi_update_sci (&s->ar, s->irq);PIIX4_DPRINTF ("gpe write %" HWADDR_PRIx" <== %" PRIu64"\n" , addr, val); }
@@ -693,7 +675,7 @@ static void piix4_cpu_hotplug_req(PIIX4PMState *s, CPUState *cpu, }else { g->sts[cpu_id /8 ] &= ~(1 << (cpu_id %8 )); } -pm_update_sci (s); +acpi_update_sci (&s->ar, s->irq); }static void piix4_cpu_added_req (Notifier *n,void *opaque)
@@ -767,7 +749,7 @@ static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev,disable_device (s, slot); } -pm_update_sci (s); +acpi_update_sci (&s->ar, s->irq);return 0 ; }
include/hw/acpi/acpi.h +8 -0
@@ -69,6 +69,12 @@#define ACPI_BITMASK_RT_CLOCK_ENABLE 0x0400#define ACPI_BITMASK_PCIEXP_WAKE_DISABLE 0x4000/* ACPI 3.0 */ +#define ACPI_BITMASK_PM1_COMMON_ENABLED ( \ + ACPI_BITMASK_RT_CLOCK_ENABLE | \ + ACPI_BITMASK_POWER_BUTTON_ENABLE | \ + ACPI_BITMASK_GLOBAL_LOCK_ENABLE | \ + ACPI_BITMASK_TIMER_ENABLE) +/* PM1x_CNT */ #define ACPI_BITMASK_SCI_ENABLE 0x0001#define ACPI_BITMASK_BUS_MASTER_RLD 0x0002
@@ -160,6 +166,8 @@ void acpi_gpe_reset(ACPIREGS *ar);void acpi_gpe_ioport_writeb (ACPIREGS *ar,uint32_t addr,uint32_t val);uint32_t acpi_gpe_ioport_readb (ACPIREGS *ar,uint32_t addr); +void acpi_update_sci (ACPIREGS *acpi_regs,qemu_irq irq); +/* acpi.c */ extern int acpi_enabled;extern char unsigned *acpi_tables;
Signature · 1 line
1.8.3.1
PATCH 10/11 ACPI: set CPU hotplug io base dynamically
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 6 ++++++ hw/i386/ssdt-misc.dsl | 1 + 2 files changed, 7 insertions(+)
hw/i386/acpi-build.c +6 -0
@@ -68,6 +68,7 @@ typedef struct AcpiPmInfo {uint32_t gpe0_blk;uint32_t gpe0_blk_len;uint32_t io_base; +uint16_t io_cpu_base; } AcpiPmInfo; typedef struct AcpiMiscInfo {
@@ -169,6 +170,9 @@ static void acpi_get_pm_info(AcpiPmInfo *pm) NULL); pm->gpe0_blk_len =object_property_get_int (obj,ACPI_PM_PROP_GPE0_BLK_LEN ,NULL ); + pm->io_cpu_base =object_property_get_int (obj, +ACPI_CPU_HOTPLUG_IO_BASE_PROP , +NULL ); }static void acpi_get_hotplug_info (AcpiMiscInfo *misc)
@@ -712,6 +716,8 @@ build_ssdt(GArray *table_data, GArray *linker, *(uint16_t *)(ssdt_ptr + *ssdt_isa_pest) =cpu_to_le16 (misc->pvpanic_port); + *(uint16_t *)(ssdt_ptr + *ssdt_cpugpe_port) = +cpu_to_le16 (pm->io_cpu_base); {GArray *sb_scope =build_alloc_array ();
hw/i386/ssdt-misc.dsl +1 -0
@@ -123,6 +123,7 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) Device(CPHD) { Name(_HID, EISAID("PNP0C08")) Name(CPPL, 32) // cpu-gpe length + ACPI_EXTRACT_NAME_WORD_CONST ssdt_cpugpe_port Name(CPHP, 0xaf00) OperationRegion(PRST, SystemIO, CPHP, CPPL)
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 09/11] ACPI: move PRST OperationRegion into SSDT
In reply to Igor MammedovQuoted 5 lines · Igor Mammedov
.. and report range used by it to OSPM via
_CRS. PRST is needed in SSDT since its base will depend on chipset and will be dynamically set by QEMU. Also movePRSC()method along with PRST since cross table reference to PRST doesn't work.
Could you clarify this last sentence?
I don't mind where it is but I'd like to know
where does the limitation come from.
Quoted 166 lines
Signed-off-by Igor Mammedov <[email protected]>--- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 39 +---------------------- hw/i386/acpi-dsdt.dsl | 2 +- hw/i386/q35-acpi-dsdt.dsl | 2 +- hw/i386/ssdt-misc.dsl | 65 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 40 deletions(-)hw/i386/acpi-dsdt-cpu-hotplug.dsl +1
-38@@ -20,6 +20,7 @@ Scope(\_SB) { /* Objects filled in by run-time generated SSDT */ External(NTFY, MethodObj) + External(\_SB.CPHD.PRSC, MethodObj) External(CPON, PkgObj) /* Methods called by run-time generated SSDT Processor objects */@@ -51,42 +52,4 @@ Scope(\_SB) { // _EJ0 method - eject callback Sleep(200) } - - OperationRegion(PRST, SystemIO, 0xaf00, 32) - Field(PRST, ByteAcc, NoLock, Preserve) { - PRS, 256 - } - Method(PRSC, 0) { - // Local5 = active cpu bitmap - Store(PRS, Local5) - // Local2 = last read byte from bitmap - Store(Zero, Local2) - // Local0 = Processor ID / APIC ID iterator - Store(Zero, Local0) - While (LLess(Local0, SizeOf(CPON))) { - // Local1 = CPON flag for this cpu - Store(DerefOf(Index(CPON, Local0)), Local1) - If (And(Local0, 0x07)) { - // Shift down previously read bitmap byte - ShiftRight(Local2, 1, Local2) - } Else { - // Read next byte from cpu bitmap - Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) - } - // Local3 = active state for this cpu - Store(And(Local2, 1), Local3) - - If (LNotEqual(Local1, Local3)) { - // State change - update CPON with new state - Store(Local3, Index(CPON, Local0)) - // Do CPU notify - If (LEqual(Local3, 1)) { - NTFY(Local0, 1) - } Else { - NTFY(Local0, 3) - } - } - Increment(Local0) - } - } }hw/i386/acpi-dsdt.dsl +1
-1@@ -311,7 +311,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPHD.PRSC() } Method(_L03) { }hw/i386/q35-acpi-dsdt.dsl +1
-1@@ -420,7 +420,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPHD.PRSC() } Method(_L03) { }hw/i386/ssdt-misc.dsl +65
-0@@ -116,4 +116,69 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) } } } + Scope(\_SB) { + External(NTFY, MethodObj) + External(CPON, PkgObj) + + Device(CPHD) { + Name(_HID, EISAID("PNP0C08")) + Name(CPPL, 32) // cpu-gpe length + Name(CPHP, 0xaf00) + + OperationRegion(PRST, SystemIO, CPHP, CPPL) + Field(PRST, ByteAcc, NoLock, Preserve) { + PRS, 256 + } + + Method(PRSC, 0) { + // Local5 = active cpu bitmap + Store(PRS, Local5) + // Local2 = last read byte from bitmap + Store(Zero, Local2) + // Local0 = Processor ID / APIC ID iterator + Store(Zero, Local0) + While (LLess(Local0, SizeOf(CPON))) { + // Local1 = CPON flag for this cpu + Store(DerefOf(Index(CPON, Local0)), Local1) + If (And(Local0, 0x07)) { + // Shift down previously read bitmap byte + ShiftRight(Local2, 1, Local2) + } Else { + // Read next byte from cpu bitmap + Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) + } + // Local3 = active state for this cpu + Store(And(Local2, 1), Local3) + + If (LNotEqual(Local1, Local3)) { + // State change - update CPON with new state + Store(Local3, Index(CPON, Local0)) + // Do CPU notify + If (LEqual(Local3, 1)) { + NTFY(Local0, 1) + } Else { + NTFY(Local0, 3) + } + } + Increment(Local0) + } + } + + /* Leave bit 0 cleared to avoid Windows BSOD */ + Name(_STA, 0xA) + + Method(_CRS, 0) { + Store(ResourceTemplate() { + IO(Decode16, 0x00, 0x00, 0x01, 0x15, IO) + }, Local0) + + CreateWordField(Local0, IO._MIN, IOMN) + CreateWordField(Local0, IO._MAX, IOMX) + + Store(CPHP, IOMN) + Subtract(Add(CPHP, CPPL), 1, IOMX) + Return(Local0) + } + } // Device(CPHD) + } // Scope(\_SB) }Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 09/11] ACPI: move PRST OperationRegion into SSDT
In reply to Igor MammedovQuoted 143 lines · Igor Mammedov
.. and report range used by it to OSPM via
_CRS. PRST is needed in SSDT since its base will depend on chipset and will be dynamically set by QEMU. Also movePRSC()method along with PRST since cross table reference to PRST doesn't work.Signed-off-by Igor Mammedov <[email protected]>--- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 39 +---------------------- hw/i386/acpi-dsdt.dsl | 2 +- hw/i386/q35-acpi-dsdt.dsl | 2 +- hw/i386/ssdt-misc.dsl | 65 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 40 deletions(-)hw/i386/acpi-dsdt-cpu-hotplug.dsl +1
-38@@ -20,6 +20,7 @@ Scope(\_SB) { /* Objects filled in by run-time generated SSDT */ External(NTFY, MethodObj) + External(\_SB.CPHD.PRSC, MethodObj) External(CPON, PkgObj) /* Methods called by run-time generated SSDT Processor objects */@@ -51,42 +52,4 @@ Scope(\_SB) { // _EJ0 method - eject callback Sleep(200) } - - OperationRegion(PRST, SystemIO, 0xaf00, 32) - Field(PRST, ByteAcc, NoLock, Preserve) { - PRS, 256 - } - Method(PRSC, 0) { - // Local5 = active cpu bitmap - Store(PRS, Local5) - // Local2 = last read byte from bitmap - Store(Zero, Local2) - // Local0 = Processor ID / APIC ID iterator - Store(Zero, Local0) - While (LLess(Local0, SizeOf(CPON))) { - // Local1 = CPON flag for this cpu - Store(DerefOf(Index(CPON, Local0)), Local1) - If (And(Local0, 0x07)) { - // Shift down previously read bitmap byte - ShiftRight(Local2, 1, Local2) - } Else { - // Read next byte from cpu bitmap - Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) - } - // Local3 = active state for this cpu - Store(And(Local2, 1), Local3) - - If (LNotEqual(Local1, Local3)) { - // State change - update CPON with new state - Store(Local3, Index(CPON, Local0)) - // Do CPU notify - If (LEqual(Local3, 1)) { - NTFY(Local0, 1) - } Else { - NTFY(Local0, 3) - } - } - Increment(Local0) - } - } }hw/i386/acpi-dsdt.dsl +1
-1@@ -311,7 +311,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPHD.PRSC() } Method(_L03) { }hw/i386/q35-acpi-dsdt.dsl +1
-1@@ -420,7 +420,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPHD.PRSC() } Method(_L03) { }hw/i386/ssdt-misc.dsl +40
-0@@ -116,4 +116,69 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) } } } + Scope(\_SB) { + External(NTFY, MethodObj) + External(CPON, PkgObj) + + Device(CPHD) { + Name(_HID, EISAID("PNP0C08")) + Name(CPPL, 32) // cpu-gpe length + Name(CPHP, 0xaf00) + + OperationRegion(PRST, SystemIO, CPHP, CPPL) + Field(PRST, ByteAcc, NoLock, Preserve) { + PRS, 256 + } + + Method(PRSC, 0) { + // Local5 = active cpu bitmap + Store(PRS, Local5) + // Local2 = last read byte from bitmap + Store(Zero, Local2) + // Local0 = Processor ID / APIC ID iterator + Store(Zero, Local0) + While (LLess(Local0, SizeOf(CPON))) { + // Local1 = CPON flag for this cpu + Store(DerefOf(Index(CPON, Local0)), Local1) + If (And(Local0, 0x07)) { + // Shift down previously read bitmap byte + ShiftRight(Local2, 1, Local2) + } Else { + // Read next byte from cpu bitmap + Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) + } + // Local3 = active state for this cpu + Store(And(Local2, 1), Local3) + + If (LNotEqual(Local1, Local3)) { + // State change - update CPON with new state + Store(Local3, Index(CPON, Local0)) + // Do CPU notify + If (LEqual(Local3, 1)) { + NTFY(Local0, 1)
hw/i386/ssdt-misc.dsl DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) · line 168
Quoted 10 lines
hw/i386/ssdt-misc.dsl +10
-0+ } Else { + NTFY(Local0, 3) + } + } + Increment(Local0) + } + } + + /* Leave bit 0 cleared to avoid Windows BSOD */ + Name(_STA, 0xA)
This shared the problem you yourself pointed out with patch 'pc: ACPI BIOS: implement memory hotplug':
if we make device non present ospm can ignore our _CRS.
Can't we get a better handle on why windows crashes?
Quoted 18 lines
hw/i386/ssdt-misc.dsl +15
-0+ + Method(_CRS, 0) { + Store(ResourceTemplate() { + IO(Decode16, 0x00, 0x00, 0x01, 0x15, IO) + }, Local0) + + CreateWordField(Local0, IO._MIN, IOMN) + CreateWordField(Local0, IO._MAX, IOMX) + + Store(CPHP, IOMN) + Subtract(Add(CPHP, CPPL), 1, IOMX) + Return(Local0) + } + } // Device(CPHD) + } // Scope(\_SB) }Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 09/11] ACPI: move PRST OperationRegion into SSDT
In reply to Michael S. TsirkinQuoted 10 lines · On Mon, 16 Dec 2013 21:30:14 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
.. and report range used by it to OSPM via
_CRS. PRST is needed in SSDT since its base will depend on chipset and will be dynamically set by QEMU. Also movePRSC()method along with PRST since cross table reference to PRST doesn't work.Could you clarify this last sentence?
I don't mind where it is but I'd like to know
where does the limitation come from.
It's empiric deduction so far I haven't found such limitation in spec yet. iasl builds tables just fine but neither linux nor windows were able to find Operation region from SSDT when loading DSDT, failing whole table loading process. Decompiling DSDT/SSDT tables in guest shows that region is in expected scope but OSPM refuses to see it when referenced outside SSDT. Maybe there is some AML magic to make it work, I'm not aware of. The same thing I had to do for memory hotplug as well. So I've tried to play nicely 2 times and I have ended up with this solution both times.
Quoted 167 lines
Quoted 167 lines
Signed-off-by Igor Mammedov <[email protected]>--- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 39 +---------------------- hw/i386/acpi-dsdt.dsl | 2 +- hw/i386/q35-acpi-dsdt.dsl | 2 +- hw/i386/ssdt-misc.dsl | 65 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 40 deletions(-)hw/i386/acpi-dsdt-cpu-hotplug.dsl +1
-38@@ -20,6 +20,7 @@ Scope(\_SB) { /* Objects filled in by run-time generated SSDT */ External(NTFY, MethodObj) + External(\_SB.CPHD.PRSC, MethodObj) External(CPON, PkgObj) /* Methods called by run-time generated SSDT Processor objects */@@ -51,42 +52,4 @@ Scope(\_SB) { // _EJ0 method - eject callback Sleep(200) } - - OperationRegion(PRST, SystemIO, 0xaf00, 32) - Field(PRST, ByteAcc, NoLock, Preserve) { - PRS, 256 - } - Method(PRSC, 0) { - // Local5 = active cpu bitmap - Store(PRS, Local5) - // Local2 = last read byte from bitmap - Store(Zero, Local2) - // Local0 = Processor ID / APIC ID iterator - Store(Zero, Local0) - While (LLess(Local0, SizeOf(CPON))) { - // Local1 = CPON flag for this cpu - Store(DerefOf(Index(CPON, Local0)), Local1) - If (And(Local0, 0x07)) { - // Shift down previously read bitmap byte - ShiftRight(Local2, 1, Local2) - } Else { - // Read next byte from cpu bitmap - Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) - } - // Local3 = active state for this cpu - Store(And(Local2, 1), Local3) - - If (LNotEqual(Local1, Local3)) { - // State change - update CPON with new state - Store(Local3, Index(CPON, Local0)) - // Do CPU notify - If (LEqual(Local3, 1)) { - NTFY(Local0, 1) - } Else { - NTFY(Local0, 3) - } - } - Increment(Local0) - } - } }hw/i386/acpi-dsdt.dsl +1
-1@@ -311,7 +311,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPHD.PRSC() } Method(_L03) { }hw/i386/q35-acpi-dsdt.dsl +1
-1@@ -420,7 +420,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPHD.PRSC() } Method(_L03) { }hw/i386/ssdt-misc.dsl +65
-0@@ -116,4 +116,69 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) } } } + Scope(\_SB) { + External(NTFY, MethodObj) + External(CPON, PkgObj) + + Device(CPHD) { + Name(_HID, EISAID("PNP0C08")) + Name(CPPL, 32) // cpu-gpe length + Name(CPHP, 0xaf00) + + OperationRegion(PRST, SystemIO, CPHP, CPPL) + Field(PRST, ByteAcc, NoLock, Preserve) { + PRS, 256 + } + + Method(PRSC, 0) { + // Local5 = active cpu bitmap + Store(PRS, Local5) + // Local2 = last read byte from bitmap + Store(Zero, Local2) + // Local0 = Processor ID / APIC ID iterator + Store(Zero, Local0) + While (LLess(Local0, SizeOf(CPON))) { + // Local1 = CPON flag for this cpu + Store(DerefOf(Index(CPON, Local0)), Local1) + If (And(Local0, 0x07)) { + // Shift down previously read bitmap byte + ShiftRight(Local2, 1, Local2) + } Else { + // Read next byte from cpu bitmap + Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) + } + // Local3 = active state for this cpu + Store(And(Local2, 1), Local3) + + If (LNotEqual(Local1, Local3)) { + // State change - update CPON with new state + Store(Local3, Index(CPON, Local0)) + // Do CPU notify + If (LEqual(Local3, 1)) { + NTFY(Local0, 1) + } Else { + NTFY(Local0, 3) + } + } + Increment(Local0) + } + } + + /* Leave bit 0 cleared to avoid Windows BSOD */ + Name(_STA, 0xA) + + Method(_CRS, 0) { + Store(ResourceTemplate() { + IO(Decode16, 0x00, 0x00, 0x01, 0x15, IO) + }, Local0) + + CreateWordField(Local0, IO._MIN, IOMN) + CreateWordField(Local0, IO._MAX, IOMX) + + Store(CPHP, IOMN) + Subtract(Add(CPHP, CPPL), 1, IOMX) + Return(Local0) + } + } // Device(CPHD) + } // Scope(\_SB) }Signature · 1 line
1.8.3.1
Signature · 2 lines
Regards, Igor
Re: [Qemu-devel] [PATCH 09/11] ACPI: move PRST OperationRegion into SSDT
Quoted 10 lines · Igor Mammedov
Quoted 7 lines · On Mon, 16 Dec 2013 21:30:14 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
.. and report range used by it to OSPM via
_CRS. PRST is needed in SSDT since its base will depend on chipset and will be dynamically set by QEMU. Also movePRSC()method along with PRST since cross table reference to PRST doesn't work.
Quoted 8 lines
Quoted 3 lines
Could you clarify this last sentence?
I don't mind where it is but I'd like to know
where does the limitation come from.It's empiric deduction so far I haven't found such limitation in spec yet. iasl builds tables just fine but neither linux nor windows were able to find Operation region from SSDT when loading DSDT, failing whole table loading process. Decompiling DSDT/SSDT tables in guest shows that region is in expected scope but OSPM refuses to see it when referenced outside SSDT.
There seem to be four things here:
- the OperationRegion definition,
- its external declaration,
- the Field() declaration,
- use of fields.
I think referencing an OperationRegion defined in another table should work (by way of External). I suspect the tricky part is with Field():
The fields are parts of the object named by RegionName, but their names appear in the same scope as the Field term.
So,
- maybe moving PRST only, and leaving the definition of PRS (as part of Field()) together with PRSC would suffice,
- or, after moving the definition of PRS (as part of Field()) together with PRST to another table, all references to PRS (in the PRSC method) would have to be qualified. (But I guess this is what you tried.)
Laszlo
Re: [Qemu-devel] [PATCH 09/11] ACPI: move PRST OperationRegion into SSDT
Quoted 29 lines · Laszlo Ersek
Quoted 10 lines · Igor Mammedov
Quoted 7 lines · On Mon, 16 Dec 2013 21:30:14 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
.. and report range used by it to OSPM via
_CRS. PRST is needed in SSDT since its base will depend on chipset and will be dynamically set by QEMU. Also movePRSC()method along with PRST since cross table reference to PRST doesn't work.Quoted 8 lines
Quoted 3 lines
Could you clarify this last sentence?
I don't mind where it is but I'd like to know
where does the limitation come from.It's empiric deduction so far I haven't found such limitation in spec yet. iasl builds tables just fine but neither linux nor windows were able to find Operation region from SSDT when loading DSDT, failing whole table loading process. Decompiling DSDT/SSDT tables in guest shows that region is in expected scope but OSPM refuses to see it when referenced outside SSDT.
There seem to be four things here:
- the OperationRegion definition,
- its external declaration,
- theField()declaration,
- use of fields.I think referencing an OperationRegion defined in another table should work (by way of External). I suspect the tricky part is with
Field():
Quoted 6 lines
The fields are parts of the object named by RegionName, but their names appear in the same scope as the Field term.
So,
- maybe moving PRST only, and leaving the definition of PRS (as part ofField()) together with PRSC would suffice,
I think this might be exactly what we don in OVMF's builtin tables. (I could of course fully misinterpret the situation.)
In the DSDT we have a _CRS method that includes:
- External (FWDT, OpRegionObj)
- Field(FWDT, QWordAcc, NoLock, Preserve) { ... fields ... }
- accesses to these fields
In the SSDT we have:
- OperationRegion(FWDT, ...)
So I guess:
- you could put the PRST in the SSDT (this is the goal),
- you could keep the PRSC method in DSDT,
- but an External reference and the PRS field declaration would also have to remain in DSDT.
Laszlo
Re: [Qemu-devel] [PATCH 09/11] ACPI: move PRST OperationRegion into SSDT
In reply to Igor MammedovQuoted 13 lines · Igor Mammedov
Quoted 10 lines · On Mon, 16 Dec 2013 21:30:14 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
.. and report range used by it to OSPM via
_CRS. PRST is needed in SSDT since its base will depend on chipset and will be dynamically set by QEMU. Also movePRSC()method along with PRST since cross table reference to PRST doesn't work.Could you clarify this last sentence?
I don't mind where it is but I'd like to know
where does the limitation come from.
Quoted 8 lines
It's empiric deduction so far I haven't found such limitation in spec yet. iasl builds tables just fine but neither linux nor windows were able to find Operation region from SSDT when loading DSDT, failing whole table loading process. Decompiling DSDT/SSDT tables in guest shows that region is in expected scope but OSPM refuses to see it when referenced outside SSDT. Maybe there is some AML magic to make it work, I'm not aware of. The same thing I had to do for memory hotplug as well. So I've tried to play nicely 2 times and I have ended up with this solution both times.
Would this work?
hw/i386/acpi-dsdt-cpu-hotplug.dsl +2 -2
@@ -52,8 +52,8 @@ Scope(\_SB) { Sleep(200) } - OperationRegion(PRST, SystemIO, 0xaf00, 32) - Field(PRST, ByteAcc, NoLock, Preserve) { + External(\_SB.CPHD.PRST, OpRegionObj) + Field(\_SB.CPHD.PRST, ByteAcc, NoLock, Preserve) { PRS, 256 } Method(PRSC, 0) {
hw/i386/ssdt-misc.dsl +25 -0
@@ -116,4 +116,29 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) } } } + Scope(\_SB) { + Device(CPHD) { + Name(_HID, EISAID("PNP0C08")) + Name(CPPL, 32) // cpu-gpe length + Name(CPHP, 0xaf00) + + OperationRegion(PRST, SystemIO, CPHP, CPPL) + + /* Leave bit 0 cleared to avoid Windows BSOD */ + Name(_STA, 0xA) + + Method(_CRS, 0) { + Store(ResourceTemplate() { + IO(Decode16, 0x00, 0x00, 0x01, 0x15, IO) + }, Local0) + + CreateWordField(Local0, IO._MIN, IOMN) + CreateWordField(Local0, IO._MAX, IOMX) + + Store(CPHP, IOMN) + Subtract(Add(CPHP, CPPL), 1, IOMX) + Return(Local0) + } + } // Device(CPHD) + } // Scope(\_SB) }
Thanks
Laszlo
Re: [Qemu-devel] [PATCH 09/11] ACPI: move PRST OperationRegion into SSDT
In reply to Laszlo ErsekQuoted 20 lines · On Mon, 16 Dec 2013 22:13:30 +0100 Laszlo Ersek <[email protected]> wrote:
Quoted 10 lines · Igor Mammedov
Quoted 7 lines · On Mon, 16 Dec 2013 21:30:14 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
.. and report range used by it to OSPM via
_CRS. PRST is needed in SSDT since its base will depend on chipset and will be dynamically set by QEMU. Also movePRSC()method along with PRST since cross table reference to PRST doesn't work.Quoted 8 lines
Quoted 3 lines
Could you clarify this last sentence?
I don't mind where it is but I'd like to know
where does the limitation come from.It's empiric deduction so far I haven't found such limitation in spec yet. iasl builds tables just fine but neither linux nor windows were able to find Operation region from SSDT when loading DSDT, failing whole table loading process. Decompiling DSDT/SSDT tables in guest shows that region is in expected scope but OSPM refuses to see it when referenced outside SSDT.
Quoted 8 lines
There seem to be four things here:
- the OperationRegion definition,
- its external declaration,
- theField()declaration,
- use of fields.I think referencing an OperationRegion defined in another table should work (by way of External). I suspect the tricky part is with
Field():
^^^ it looks like it should work and decompiled tables
look fine as well but it unfortunately doesn't.
Quoted 7 lines
The fields are parts of the object named by RegionName, but their names appear in the same scope as the Field term.
So,
- maybe moving PRST only, and leaving the definition of PRS (as part ofField()) together with PRSC would suffice,
That was the first thing I've tried.
Quoted 3 lines
- or, after moving the definition of PRS (as part of
Field()) together with PRST to another table, all references to PRS (in the PRSC method) would have to be qualified. (But I guess this is what you tried.)
yep, that didn't work too.
I'm not fun of moving a bunch of code around, but looks like there is no other way. I'd be happy to try if there are any other suggestions.
Quoted 3 lines
Laszlo
Signature · 2 lines
Regards, Igor
Re: [Qemu-devel] [PATCH 09/11] ACPI: move PRST OperationRegion into SSDT
In reply to Laszlo ErsekQuoted 30 lines · On Mon, 16 Dec 2013 22:44:46 +0100 Laszlo Ersek <[email protected]> wrote:
Quoted 13 lines · Igor Mammedov
Quoted 10 lines · On Mon, 16 Dec 2013 21:30:14 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
.. and report range used by it to OSPM via
_CRS. PRST is needed in SSDT since its base will depend on chipset and will be dynamically set by QEMU. Also movePRSC()method along with PRST since cross table reference to PRST doesn't work.Could you clarify this last sentence?
I don't mind where it is but I'd like to know
where does the limitation come from.Quoted 8 lines
It's empiric deduction so far I haven't found such limitation in spec yet. iasl builds tables just fine but neither linux nor windows were able to find Operation region from SSDT when loading DSDT, failing whole table loading process. Decompiling DSDT/SSDT tables in guest shows that region is in expected scope but OSPM refuses to see it when referenced outside SSDT. Maybe there is some AML magic to make it work, I'm not aware of. The same thing I had to do for memory hotplug as well. So I've tried to play nicely 2 times and I have ended up with this solution both times.
Would this work?
hw/i386/acpi-dsdt-cpu-hotplug.dsl +0
-0
hw/i386/acpi-dsdt-cpu-hotplug.dsl Scope(\_SB) { · line 56
Quoted 7 lines
hw/i386/acpi-dsdt-cpu-hotplug.dsl +2
-2@@ -52,8 +52,8 @@ Scope(\_SB) { Sleep(200) } - OperationRegion(PRST, SystemIO, 0xaf00, 32) - Field(PRST, ByteAcc, NoLock, Preserve) { + External(\_SB.CPHD.PRST, OpRegionObj) + Field(\_SB.CPHD.PRST, ByteAcc, NoLock, Preserve) {
that was my first patch attempt :)
You have to be careful and touch [q35-]acpi-dsdt.dsl since make doesn't handle deps to acpi-dsdt-cpu-hotplug.dsl correctly.
After that RHEL6 guest fails to load ACPI tables.
Quoted 41 lines
hw/i386/acpi-dsdt-cpu-hotplug.dsl +0
-0PRS, 256 } Method(PRSC, 0) {hw/i386/ssdt-misc.dsl +25
-0@@ -116,4 +116,29 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) } } } + Scope(\_SB) { + Device(CPHD) { + Name(_HID, EISAID("PNP0C08")) + Name(CPPL, 32) // cpu-gpe length + Name(CPHP, 0xaf00) + + OperationRegion(PRST, SystemIO, CPHP, CPPL) + + /* Leave bit 0 cleared to avoid Windows BSOD */ + Name(_STA, 0xA) + + Method(_CRS, 0) { + Store(ResourceTemplate() { + IO(Decode16, 0x00, 0x00, 0x01, 0x15, IO) + }, Local0) + + CreateWordField(Local0, IO._MIN, IOMN) + CreateWordField(Local0, IO._MAX, IOMX) + + Store(CPHP, IOMN) + Subtract(Add(CPHP, CPPL), 1, IOMX) + Return(Local0) + } + } // Device(CPHD) + } // Scope(\_SB) }Thanks
Laszlo
Signature · 2 lines
Regards, Igor
Re: [Qemu-devel] [PATCH 09/11] ACPI: move PRST OperationRegion into SSDT
In reply to Michael S. TsirkinQuoted 150 lines · On Mon, 16 Dec 2013 21:53:07 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 149 lines · Igor Mammedov
.. and report range used by it to OSPM via
_CRS. PRST is needed in SSDT since its base will depend on chipset and will be dynamically set by QEMU. Also movePRSC()method along with PRST since cross table reference to PRST doesn't work.Signed-off-by Igor Mammedov <[email protected]>--- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 39 +---------------------- hw/i386/acpi-dsdt.dsl | 2 +- hw/i386/q35-acpi-dsdt.dsl | 2 +- hw/i386/ssdt-misc.dsl | 65 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 40 deletions(-)hw/i386/acpi-dsdt-cpu-hotplug.dsl +1
-38@@ -20,6 +20,7 @@ Scope(\_SB) { /* Objects filled in by run-time generated SSDT */ External(NTFY, MethodObj) + External(\_SB.CPHD.PRSC, MethodObj) External(CPON, PkgObj) /* Methods called by run-time generated SSDT Processor objects */@@ -51,42 +52,4 @@ Scope(\_SB) { // _EJ0 method - eject callback Sleep(200) } - - OperationRegion(PRST, SystemIO, 0xaf00, 32) - Field(PRST, ByteAcc, NoLock, Preserve) { - PRS, 256 - } - Method(PRSC, 0) { - // Local5 = active cpu bitmap - Store(PRS, Local5) - // Local2 = last read byte from bitmap - Store(Zero, Local2) - // Local0 = Processor ID / APIC ID iterator - Store(Zero, Local0) - While (LLess(Local0, SizeOf(CPON))) { - // Local1 = CPON flag for this cpu - Store(DerefOf(Index(CPON, Local0)), Local1) - If (And(Local0, 0x07)) { - // Shift down previously read bitmap byte - ShiftRight(Local2, 1, Local2) - } Else { - // Read next byte from cpu bitmap - Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) - } - // Local3 = active state for this cpu - Store(And(Local2, 1), Local3) - - If (LNotEqual(Local1, Local3)) { - // State change - update CPON with new state - Store(Local3, Index(CPON, Local0)) - // Do CPU notify - If (LEqual(Local3, 1)) { - NTFY(Local0, 1) - } Else { - NTFY(Local0, 3) - } - } - Increment(Local0) - } - } }hw/i386/acpi-dsdt.dsl +1
-1@@ -311,7 +311,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPHD.PRSC() } Method(_L03) { }hw/i386/q35-acpi-dsdt.dsl +1
-1@@ -420,7 +420,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPHD.PRSC() } Method(_L03) { }hw/i386/ssdt-misc.dsl +46
-0@@ -116,4 +116,69 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) } } } + Scope(\_SB) { + External(NTFY, MethodObj) + External(CPON, PkgObj) + + Device(CPHD) { + Name(_HID, EISAID("PNP0C08")) + Name(CPPL, 32) // cpu-gpe length + Name(CPHP, 0xaf00) + + OperationRegion(PRST, SystemIO, CPHP, CPPL) + Field(PRST, ByteAcc, NoLock, Preserve) { + PRS, 256 + } + + Method(PRSC, 0) { + // Local5 = active cpu bitmap + Store(PRS, Local5) + // Local2 = last read byte from bitmap + Store(Zero, Local2) + // Local0 = Processor ID / APIC ID iterator + Store(Zero, Local0) + While (LLess(Local0, SizeOf(CPON))) { + // Local1 = CPON flag for this cpu + Store(DerefOf(Index(CPON, Local0)), Local1) + If (And(Local0, 0x07)) { + // Shift down previously read bitmap byte + ShiftRight(Local2, 1, Local2) + } Else { + // Read next byte from cpu bitmap + Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) + } + // Local3 = active state for this cpu + Store(And(Local2, 1), Local3) + + If (LNotEqual(Local1, Local3)) { + // State change - update CPON with new state + Store(Local3, Index(CPON, Local0)) + // Do CPU notify + If (LEqual(Local3, 1)) { + NTFY(Local0, 1) + } Else { + NTFY(Local0, 3) + } + } + Increment(Local0) + }
Quoted 8 lines
hw/i386/ssdt-misc.dsl DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) · line 168
Quoted 4 lines
hw/i386/ssdt-misc.dsl +4
-0+ } + + /* Leave bit 0 cleared to avoid Windows BSOD */ + Name(_STA, 0xA)This shared the problem you yourself pointed out with patch 'pc: ACPI BIOS: implement memory hotplug':
if we make device non present ospm can ignore our_CRS.
I repeat my question is there need to expose it OperationRegion as _CRS?
Quoted 2 lines
Can't we get a better handle on why windows crashes?
Short of installing debug build and looking at crash dump and/or reverse engineering acpi.sys, might give a clue, I don't have any other idea. Are there any simpler suggestions?
Quoted 21 lines
Quoted 20 lines
hw/i386/ssdt-misc.dsl +15
-0+ + Method(_CRS, 0) { + Store(ResourceTemplate() { + IO(Decode16, 0x00, 0x00, 0x01, 0x15, IO) + }, Local0) + + CreateWordField(Local0, IO._MIN, IOMN) + CreateWordField(Local0, IO._MAX, IOMX) + + Store(CPHP, IOMN) + Subtract(Add(CPHP, CPPL), 1, IOMX) + Return(Local0) + } + } // Device(CPHD) + } // Scope(\_SB) }Signature · 1 line
1.8.3.1
Signature · 2 lines
Regards, Igor
Re: [Qemu-devel] [PATCH 09/11] ACPI: move PRST OperationRegion into SSDT
In reply to Igor MammedovQuoted 36 lines · Igor Mammedov
Quoted 33 lines · On Mon, 16 Dec 2013 22:44:46 +0100 Laszlo Ersek <[email protected]> wrote:
Quoted 13 lines · Igor Mammedov
Quoted 10 lines · On Mon, 16 Dec 2013 21:30:14 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
.. and report range used by it to OSPM via
_CRS. PRST is needed in SSDT since its base will depend on chipset and will be dynamically set by QEMU. Also movePRSC()method along with PRST since cross table reference to PRST doesn't work.Could you clarify this last sentence?
I don't mind where it is but I'd like to know
where does the limitation come from.Quoted 8 lines
It's empiric deduction so far I haven't found such limitation in spec yet. iasl builds tables just fine but neither linux nor windows were able to find Operation region from SSDT when loading DSDT, failing whole table loading process. Decompiling DSDT/SSDT tables in guest shows that region is in expected scope but OSPM refuses to see it when referenced outside SSDT. Maybe there is some AML magic to make it work, I'm not aware of. The same thing I had to do for memory hotplug as well. So I've tried to play nicely 2 times and I have ended up with this solution both times.
Would this work?
hw/i386/acpi-dsdt-cpu-hotplug.dsl +0
-0@@ -52,8 +52,8 @@ Scope(\_SB) { Sleep(200) }
Quoted 7 lines
hw/i386/acpi-dsdt-cpu-hotplug.dsl Scope(\_SB) { · line 56
Quoted 4 lines
hw/i386/acpi-dsdt-cpu-hotplug.dsl +2
-2- OperationRegion(PRST, SystemIO, 0xaf00, 32) - Field(PRST, ByteAcc, NoLock, Preserve) { + External(\_SB.CPHD.PRST, OpRegionObj) + Field(\_SB.CPHD.PRST, ByteAcc, NoLock, Preserve) {that was my first patch attempt :)
You have to be careful and touch [q35-]acpi-dsdt.dsl since make doesn't handle deps to acpi-dsdt-cpu-hotplug.dsl correctly.
Yeah I think I noticed from the "make" output :) I grepped it for this file's name.
Quoted 1 line
After that RHEL6 guest fails to load ACPI tables.
Could even be an ACPICA problem...
Thanks!
Laszlo
Re: [Qemu-devel] [PATCH 09/11] ACPI: move PRST OperationRegion into SSDT
Quoted 45 lines · On Mon, 16 Dec 2013 23:22:56 +0100 Laszlo Ersek <[email protected]> wrote:
Quoted 36 lines · Igor Mammedov
Quoted 33 lines · On Mon, 16 Dec 2013 22:44:46 +0100 Laszlo Ersek <[email protected]> wrote:
Quoted 13 lines · Igor Mammedov
Quoted 10 lines · On Mon, 16 Dec 2013 21:30:14 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
.. and report range used by it to OSPM via
_CRS. PRST is needed in SSDT since its base will depend on chipset and will be dynamically set by QEMU. Also movePRSC()method along with PRST since cross table reference to PRST doesn't work.Could you clarify this last sentence?
I don't mind where it is but I'd like to know
where does the limitation come from.Quoted 8 lines
It's empiric deduction so far I haven't found such limitation in spec yet. iasl builds tables just fine but neither linux nor windows were able to find Operation region from SSDT when loading DSDT, failing whole table loading process. Decompiling DSDT/SSDT tables in guest shows that region is in expected scope but OSPM refuses to see it when referenced outside SSDT. Maybe there is some AML magic to make it work, I'm not aware of. The same thing I had to do for memory hotplug as well. So I've tried to play nicely 2 times and I have ended up with this solution both times.
Would this work?
hw/i386/acpi-dsdt-cpu-hotplug.dsl +0
-0@@ -52,8 +52,8 @@ Scope(\_SB) { Sleep(200) }Quoted 7 lines
hw/i386/acpi-dsdt-cpu-hotplug.dsl Scope(\_SB) { · line 56
Quoted 4 lines
hw/i386/acpi-dsdt-cpu-hotplug.dsl +2
-2- OperationRegion(PRST, SystemIO, 0xaf00, 32) - Field(PRST, ByteAcc, NoLock, Preserve) { + External(\_SB.CPHD.PRST, OpRegionObj) + Field(\_SB.CPHD.PRST, ByteAcc, NoLock, Preserve) {that was my first patch attempt :)
You have to be careful and touch [q35-]acpi-dsdt.dsl since make doesn't handle deps to acpi-dsdt-cpu-hotplug.dsl correctly.
Quoted 6 lines
Yeah I think I noticed from the "make" output :) I grepped it for this file's name.
Quoted 1 line
After that RHEL6 guest fails to load ACPI tables.
Could even be an ACPICA problem...
Maybe it's iasl issue or linux&windows implementation is wrong (unlikely).
Quoted 5 lines
Thanks!
Laszlo
Signature · 2 lines
Regards, Igor
Re: [Qemu-devel] [PATCH 09/11] ACPI: move PRST OperationRegion into SSDT
In reply to Igor MammedovQuoted 43 lines · Igor Mammedov
Quoted 20 lines · On Mon, 16 Dec 2013 22:13:30 +0100 Laszlo Ersek <[email protected]> wrote:
Quoted 10 lines · Igor Mammedov
Quoted 7 lines · On Mon, 16 Dec 2013 21:30:14 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
.. and report range used by it to OSPM via
_CRS. PRST is needed in SSDT since its base will depend on chipset and will be dynamically set by QEMU. Also movePRSC()method along with PRST since cross table reference to PRST doesn't work.Quoted 8 lines
Quoted 3 lines
Could you clarify this last sentence?
I don't mind where it is but I'd like to know
where does the limitation come from.It's empiric deduction so far I haven't found such limitation in spec yet. iasl builds tables just fine but neither linux nor windows were able to find Operation region from SSDT when loading DSDT, failing whole table loading process. Decompiling DSDT/SSDT tables in guest shows that region is in expected scope but OSPM refuses to see it when referenced outside SSDT.
Quoted 8 lines
There seem to be four things here:
- the OperationRegion definition,
- its external declaration,
- theField()declaration,
- use of fields.I think referencing an OperationRegion defined in another table should work (by way of External). I suspect the tricky part is with
Field():^^^ it looks like it should work and decompiled tables
look fine as well but it unfortunately doesn't.Quoted 7 lines
The fields are parts of the object named by RegionName, but their names appear in the same scope as the Field term.
So,
- maybe moving PRST only, and leaving the definition of PRS (as part ofField()) together with PRSC would suffice,That was the first thing I've tried.
Quoted 7 lines
Quoted 3 lines
- or, after moving the definition of PRS (as part of
Field()) together with PRST to another table, all references to PRS (in the PRSC method) would have to be qualified. (But I guess this is what you tried.)yep, that didn't work too.
I'm not fun of moving a bunch of code around, but looks like there is no other way. I'd be happy to try if there are any other suggestions.
I'm not sure we need to spend too much time on it. Just clarifying that 'doesn't work' means 'builds but makes OSPM fail to resolve the OperationRegion, even though the spec makes it look like this should work' in the commit log should be enough.
Quoted 8 lines
Quoted 3 lines
Laszlo
Signature · 2 lines
Regards, Igor
Re: [Qemu-devel] [PATCH 03/11] acpi: factor out common cpu hotplug code for PIIX4/Q35
In reply to Igor MammedovQuoted 3 lines · Igor Mammedov
.. so it could be used for adding CPU hotplug to Q35 machine
Signed-off-by Igor Mammedov <[email protected]>
Sounds good but please call this file cpu_hotplug.c/.h or cpu-hotplug.c/h and make all prefixes acpi_cpu_hotplug and AcpiCpuHotplug.
Quoted 270 lines
--- hw/acpi/Makefile.objs | 2 +- hw/acpi/hotplug.c | 65 +++++++++++++++++++++++++++++++++++++++ hw/acpi/piix4.c | 78 +++++------------------------------------------ include/hw/acpi/hotplug.h | 31 +++++++++++++++++++ 4 files changed, 104 insertions(+), 72 deletions(-) create mode 100644 hw/acpi/hotplug.c create mode 100644 include/hw/acpi/hotplug.hhw/acpi/Makefile.objs +1
-1@@ -1,2 +1,2 @@ -common-obj-$(CONFIG_ACPI) += core.o piix4.o ich9.o +common-obj-$(CONFIG_ACPI) += core.o piix4.o ich9.o hotplug.ohw/acpi/hotplug.c new file +65
-0@@ -0,0 +1,65 @@ +/* +* 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. +*/ +#include "hw/hw.h" +#include "hw/acpi/hotplug.h" + +static uint64_t cpu_status_read (void *opaque,hwaddr addr,unsigned int size) +{ +AcpiCPUHotplug *cpus = opaque; +uint64_t val = cpus->sts[addr]; + +return val; +} + +static void cpu_status_write (void *opaque,hwaddr addr,uint64_t data, +unsigned int size) +{ +/* TODO: implement VCPU removal on guest signal that CPU can be removed */ +} + +static const MemoryRegionOps acpi_cpu_hotplug_ops = { + .read = cpu_status_read, + .write = cpu_status_write, + .endianness =DEVICE_LITTLE_ENDIAN , + .valid = { + .min_access_size =1 , + .max_access_size =1 , + }, +}; + +void acpi_hotplug_cpu_add (ACPIGPE *gpe,AcpiCPUHotplug *g,CPUState *cpu) +{ +CPUClass *k =CPU_GET_CLASS (cpu); +int64_t cpu_id; + + *gpe->sts = *gpe->sts |ACPI_CPU_HOTPLUG_STATUS ; + cpu_id = k->get_arch_id (CPU (cpu)); + g->sts[cpu_id /8 ] |= (1 << (cpu_id %8 )); +} + +void acpi_hotplug_cpu_init (MemoryRegion *parent,Object *owner, +AcpiCPUHotplug *gpe_cpu,uint16_t base) +{ +CPUState *cpu; + +CPU_FOREACH (cpu) { +CPUClass *cc =CPU_GET_CLASS (cpu); +int64_t id = cc->get_arch_id (cpu); + +g_assert ((id /8 ) <ACPI_GPE_PROC_LEN ); + gpe_cpu->sts[id /8 ] |= (1 << (id %8 )); + } + gpe_cpu->io_base = base; +memory_region_init_io (&gpe_cpu->io, owner, &acpi_cpu_hotplug_ops, + gpe_cpu,"acpi-cpu-hotplug" ,ACPI_GPE_PROC_LEN ); +memory_region_add_subregion (parent, gpe_cpu->io_base, &gpe_cpu->io); +}hw/acpi/piix4.c +7
-71@@ -30,6 +30,7 @@#include "hw/nvram/fw_cfg.h" #include "exec/address-spaces.h" #include "hw/acpi/piix4.h" +#include "hw/acpi/hotplug.h" //#define DEBUG @@ -50,20 +51,14 @@#define PCI_RMV_BASE 0xae0c#define PIIX4_PROC_BASE 0xaf00 -#define PIIX4_PROC_LEN 32#define PIIX4_PCI_HOTPLUG_STATUS 2 -#define PIIX4_CPU_HOTPLUG_STATUS 4struct pci_status {uint32_t up;/* deprecated, maintained for migration compatibility */ uint32_t down; }; -typedef struct CPUStatus { -uint8_t sts[PIIX4_PROC_LEN ]; -}CPUStatus ; - typedef struct PIIX4PMState { /*< private >*/ PCIDevice parent_obj;@@ -74,7 +69,6 @@ typedef struct PIIX4PMState {MemoryRegion io_gpe;MemoryRegion io_pci; -MemoryRegion io_cpu;ACPIREGS ar;APMState apm;@@ -97,7 +91,7 @@ typedef struct PIIX4PMState {uint8_t disable_s4;uint8_t s4_val; -CPUStatus gpe_cpu; +AcpiCPUHotplug gpe_cpu;Notifier cpu_added_notifier; } PIIX4PMState;@@ -628,61 +622,13 @@ static const MemoryRegionOps piix4_pci_ops = { }, }; -static uint64_t cpu_status_read (void *opaque,hwaddr addr,unsigned int size) -{ -PIIX4PMState *s = opaque; -CPUStatus *cpus = &s->gpe_cpu; -uint64_t val = cpus->sts[addr]; - -return val; -} - -static void cpu_status_write (void *opaque,hwaddr addr,uint64_t data, -unsigned int size) -{ -/* TODO: implement VCPU removal on guest signal that CPU can be removed */ -} - -static const MemoryRegionOps cpu_hotplug_ops = { - .read = cpu_status_read, - .write = cpu_status_write, - .endianness =DEVICE_LITTLE_ENDIAN , - .valid = { - .min_access_size =1 , - .max_access_size =1 , - }, -}; - -typedef enum { -PLUG , -UNPLUG , -}HotplugEventType ; - -static void piix4_cpu_hotplug_req (PIIX4PMState *s,CPUState *cpu, -HotplugEventType action) -{ -CPUStatus *g = &s->gpe_cpu; -ACPIGPE *gpe = &s->ar.gpe; -CPUClass *k =CPU_GET_CLASS (cpu); -int64_t cpu_id; - -assert (s !=NULL ); - - *gpe->sts = *gpe->sts |PIIX4_CPU_HOTPLUG_STATUS ; - cpu_id = k->get_arch_id (CPU (cpu)); -if (action ==PLUG ) { - g->sts[cpu_id /8 ] |= (1 << (cpu_id %8 )); - }else { - g->sts[cpu_id /8 ] &= ~(1 << (cpu_id %8 )); - } -acpi_update_sci (&s->ar, s->irq); -} -static void piix4_cpu_added_req (Notifier *n,void *opaque) {PIIX4PMState *s =container_of (n, PIIX4PMState, cpu_added_notifier); -piix4_cpu_hotplug_req (s,CPU (opaque),PLUG ); +assert (s !=NULL ); +acpi_hotplug_cpu_add (&s->ar.gpe, &s->gpe_cpu,CPU (opaque)); +acpi_update_sci (&s->ar, s->irq); } static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev,@@ -691,8 +637,6 @@ static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev,static void piix4_acpi_system_hot_add_init (MemoryRegion *parent,PCIBus *bus,PIIX4PMState *s) { -CPUState *cpu; -memory_region_init_io (&s->io_gpe,OBJECT (s), &piix4_gpe_ops, s,"acpi-gpe0" ,GPE_LEN );memory_region_add_subregion (parent,GPE_BASE , &s->io_gpe);@@ -703,16 +647,8 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent, &s->io_pci);pci_bus_hotplug (bus, piix4_device_hotplug,DEVICE (s)); -CPU_FOREACH (cpu) { -CPUClass *cc =CPU_GET_CLASS (cpu); -int64_t id = cc->get_arch_id (cpu); - -g_assert ((id /8 ) <PIIX4_PROC_LEN ); - s->gpe_cpu.sts[id /8 ] |= (1 << (id %8 )); - } -memory_region_init_io (&s->io_cpu,OBJECT (s), &cpu_hotplug_ops, s, -"acpi-cpu-hotplug" ,PIIX4_PROC_LEN ); -memory_region_add_subregion (parent,PIIX4_PROC_BASE , &s->io_cpu); +acpi_hotplug_cpu_init (parent,OBJECT (s), &s->gpe_cpu, +PIIX4_PROC_BASE ); s->cpu_added_notifier.notify = piix4_cpu_added_req;qemu_register_cpu_added_notifier (&s->cpu_added_notifier); }include/hw/acpi/hotplug.h new file +31
-0@@ -0,0 +1,31 @@ +/* +* 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" + +#define ACPI_CPU_HOTPLUG_STATUS 4 + +#define ACPI_GPE_PROC_LEN 32 + +typedef struct AcpiCPUHotplug { +MemoryRegion io; +uint16_t io_base; +uint8_t sts[ACPI_GPE_PROC_LEN ]; +}AcpiCPUHotplug ; + +void acpi_hotplug_cpu_add (ACPIGPE *gpe,AcpiCPUHotplug *g,CPUState *cpu); + +void acpi_hotplug_cpu_init (MemoryRegion *parent,Object *owner, +AcpiCPUHotplug *gpe_cpu,uint16_t base); +#endif Signature · 1 line
1.8.3.1
Michael S. Tsirkin
AppliedRe: [Qemu-devel] [PATCH 01/11] acpi: piix4: remove not needed GPE0 mask
In reply to Igor MammedovQuoted 8 lines · Igor Mammedov
Hardcoded GPE0 mask isn't really needed. Since
GPE0_STSinitialized with all bits cleared and only QEMU itself can set bits there (i.e. guest can only clear bits in it). So guest can't triger SCI by setting_STS&_ENbits and there is not reason to mask out not supported_STSbits since they shouldn't be set by QEMU in the first place.Signed-off-by Igor Mammedov <[email protected]>
Applied, thanks.
Quoted 20 lines
--- hw/acpi/piix4.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)hw/acpi/piix4.c +1
-2@@ -122,8 +122,7 @@ static void pm_update_sci(PIIX4PMState *s)ACPI_BITMASK_POWER_BUTTON_ENABLE |ACPI_BITMASK_GLOBAL_LOCK_ENABLE | ACPI_BITMASK_TIMER_ENABLE)) != 0) || - (((s->ar.gpe.sts[0 ] & s->ar.gpe.en[0 ]) & - (PIIX4_PCI_HOTPLUG_STATUS |PIIX4_CPU_HOTPLUG_STATUS )) !=0 ); + ((s->ar.gpe.sts[0 ] & s->ar.gpe.en[0 ]) !=0 );qemu_set_irq (s->irq, sci_level);/* schedule a timer interruption if needed */ Signature · 1 line
1.8.3.1
Michael S. Tsirkin
AppliedRe: [Qemu-devel] [PATCH 02/11] acpi: factor out common pm_update_sci() into acpi core
In reply to Igor MammedovQuoted 4 lines · Igor Mammedov
... and rename it into
acpi_update_sci()since it changes SCI on only on PM registers status.Signed-off-by Igor Mammedov <[email protected]>
Applied, thanks.
Quoted 167 lines
---
--- hw/acpi/core.c | 18 ++++++++++++++++++ hw/acpi/ich9.c | 23 ++--------------------- hw/acpi/piix4.c | 26 ++++---------------------- include/hw/acpi/acpi.h | 8 ++++++++ 4 files changed, 32 insertions(+), 43 deletions(-)hw/acpi/core.c +18
-0@@ -662,3 +662,21 @@ uint32_t acpi_gpe_ioport_readb(ACPIREGS *ar, uint32_t addr)return val; } + +void acpi_update_sci (ACPIREGS *regs,qemu_irq irq) +{ +int sci_level, pm1a_sts; + + pm1a_sts =acpi_pm1_evt_get_sts (regs); + + sci_level = ((pm1a_sts & + regs->pm1.evt.en &ACPI_BITMASK_PM1_COMMON_ENABLED ) !=0 ) || + ((regs->gpe.sts[0 ] & regs->gpe.en[0 ]) !=0 ); + +qemu_set_irq (irq, sci_level); + +/* schedule a timer interruption if needed */ +acpi_pm_tmr_update (regs, + (regs->pm1.evt.en &ACPI_BITMASK_TIMER_ENABLE ) && + !(pm1a_sts &ACPI_BITMASK_TIMER_STATUS )); +}hw/acpi/ich9.c +2
-21@@ -44,29 +44,10 @@ do { printf("%s "fmt, __func__, ## __VA_ARGS__); } while (0)#define ICH9_DEBUG (fmt, ...) do { } while (0)#endif -static void pm_update_sci (ICH9LPCPMRegs *pm) -{ -int sci_level, pm1a_sts; - - pm1a_sts =acpi_pm1_evt_get_sts (&pm->acpi_regs); - - sci_level = (((pm1a_sts & pm->acpi_regs.pm1.evt.en) & - (ACPI_BITMASK_RT_CLOCK_ENABLE | -ACPI_BITMASK_POWER_BUTTON_ENABLE | -ACPI_BITMASK_GLOBAL_LOCK_ENABLE | -ACPI_BITMASK_TIMER_ENABLE )) !=0 ); -qemu_set_irq (pm->irq, sci_level); - -/* schedule a timer interruption if needed */ -acpi_pm_tmr_update (&pm->acpi_regs, - (pm->acpi_regs.pm1.evt.en &ACPI_BITMASK_TIMER_ENABLE ) && - !(pm1a_sts &ACPI_BITMASK_TIMER_STATUS )); -} -static void ich9_pm_update_sci_fn (ACPIREGS *regs) {ICH9LPCPMRegs *pm =container_of (regs, ICH9LPCPMRegs, acpi_regs); -pm_update_sci (pm); +acpi_update_sci (&pm->acpi_regs, pm->irq); }static uint64_t ich9_gpe_readb (void *opaque,hwaddr addr,unsigned width)@@ -193,7 +174,7 @@ static void pm_reset(void *opaque) pm->smi_en |=ICH9_PMIO_SMI_EN_APMC_EN ; } -pm_update_sci (pm); +acpi_update_sci (&pm->acpi_regs, pm->irq); }static void pm_powerdown_req (Notifier *n,void *opaque)hw/acpi/piix4.c +4
-22@@ -112,28 +112,10 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,#define ACPI_ENABLE 0xf1#define ACPI_DISABLE 0xf0 -static void pm_update_sci (PIIX4PMState *s) -{ -int sci_level, pmsts; - - pmsts =acpi_pm1_evt_get_sts (&s->ar); - sci_level = (((pmsts & s->ar.pm1.evt.en) & - (ACPI_BITMASK_RT_CLOCK_ENABLE | -ACPI_BITMASK_POWER_BUTTON_ENABLE | -ACPI_BITMASK_GLOBAL_LOCK_ENABLE | -ACPI_BITMASK_TIMER_ENABLE )) !=0 ) || - ((s->ar.gpe.sts[0 ] & s->ar.gpe.en[0 ]) !=0 ); - -qemu_set_irq (s->irq, sci_level); -/* schedule a timer interruption if needed */ -acpi_pm_tmr_update (&s->ar, (s->ar.pm1.evt.en &ACPI_BITMASK_TIMER_ENABLE ) && - !(pmsts &ACPI_BITMASK_TIMER_STATUS )); -} -static void pm_tmr_timer (ACPIREGS *ar) {PIIX4PMState *s =container_of (ar, PIIX4PMState, ar); -pm_update_sci (s); +acpi_update_sci (&s->ar, s->irq); }static void apm_ctrl_changed (uint32_t val,void *arg)@@ -577,7 +559,7 @@ static void gpe_writeb(void *opaque, hwaddr addr, uint64_t val,PIIX4PMState *s = opaque;acpi_gpe_ioport_writeb (&s->ar, addr, val); -pm_update_sci (s); +acpi_update_sci (&s->ar, s->irq);PIIX4_DPRINTF ("gpe write %" HWADDR_PRIx" <== %" PRIu64"\n" , addr, val); }@@ -693,7 +675,7 @@ static void piix4_cpu_hotplug_req(PIIX4PMState *s, CPUState *cpu, }else { g->sts[cpu_id /8 ] &= ~(1 << (cpu_id %8 )); } -pm_update_sci (s); +acpi_update_sci (&s->ar, s->irq); }static void piix4_cpu_added_req (Notifier *n,void *opaque)@@ -767,7 +749,7 @@ static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev,disable_device (s, slot); } -pm_update_sci (s); +acpi_update_sci (&s->ar, s->irq);return 0 ; }include/hw/acpi/acpi.h +8
-0@@ -69,6 +69,12 @@#define ACPI_BITMASK_RT_CLOCK_ENABLE 0x0400#define ACPI_BITMASK_PCIEXP_WAKE_DISABLE 0x4000/* ACPI 3.0 */ +#define ACPI_BITMASK_PM1_COMMON_ENABLED ( \ + ACPI_BITMASK_RT_CLOCK_ENABLE | \ + ACPI_BITMASK_POWER_BUTTON_ENABLE | \ + ACPI_BITMASK_GLOBAL_LOCK_ENABLE | \ + ACPI_BITMASK_TIMER_ENABLE) +/* PM1x_CNT */ #define ACPI_BITMASK_SCI_ENABLE 0x0001#define ACPI_BITMASK_BUS_MASTER_RLD 0x0002@@ -160,6 +166,8 @@ void acpi_gpe_reset(ACPIREGS *ar);void acpi_gpe_ioport_writeb (ACPIREGS *ar,uint32_t addr,uint32_t val);uint32_t acpi_gpe_ioport_readb (ACPIREGS *ar,uint32_t addr); +void acpi_update_sci (ACPIREGS *acpi_regs,qemu_irq irq); +/* acpi.c */ extern int acpi_enabled;extern char unsigned *acpi_tables;Signature · 1 line
1.8.3.1
Michael S. Tsirkin
AppliedRe: [Qemu-devel] [PATCH 05/11] acpi: ich9: allow guest to clear SCI rised by GPE
In reply to Igor MammedovQuoted 4 lines · Igor Mammedov
it fixes IRQ storm since guest isn't able to lower SCI IRQ after it has been handled when it clears GPE event.
Signed-off-by Igor Mammedov <[email protected]>
Applied, thanks.
Quoted 18 lines
--- hw/acpi/ich9.c | 1 + 1 file changed, 1 insertion(+)hw/acpi/ich9.c +1
-0@@ -61,6 +61,7 @@ static void ich9_gpe_writeb(void *opaque, hwaddr addr, uint64_t val, {ICH9LPCPMRegs *pm = opaque;acpi_gpe_ioport_writeb (&pm->acpi_regs, addr, val); +acpi_update_sci (&pm->acpi_regs, pm->irq); }static const MemoryRegionOps ich9_gpe_ops = {Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 06/11] acpi/ich9: add CPU hotplug handling to Q35 machine
In reply to Igor MammedovQuoted 3 lines · Igor Mammedov
.. including readonly 'cpu-hotplug-io-base' property
Signed-off-by Igor Mammedov <[email protected]>
Is this documented in the Q35 spec? Could not find it there. If this is our PV code like PIIX, then we need to document this interface.
Quoted 93 lines
--- hw/acpi/ich9.c | 27 +++++++++++++++++++++++++++ include/hw/acpi/ich9.h | 4 ++++ 2 files changed, 31 insertions(+)hw/acpi/ich9.c +27
-0@@ -44,6 +44,8 @@ do { printf("%s "fmt, __func__, ## __VA_ARGS__); } while (0)#define ICH9_DEBUG (fmt, ...) do { } while (0)#endif +#define ICH9_PROC_BASE 0xa18 +static void ich9_pm_update_sci_fn (ACPIREGS *regs) {ICH9LPCPMRegs *pm =container_of (regs, ICH9LPCPMRegs, acpi_regs);@@ -185,6 +187,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 ); +acpi_hotplug_cpu_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 +221,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); + +acpi_hotplug_cpu_init (pci_address_space_io (lpc_pci),OBJECT (lpc_pci), + &pm->gpe_cpu, pm->gpe_cpu.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,@@ -222,6 +238,14 @@ static void ich9_pm_get_gpe0_blk(Object *obj, Visitor *v,visit_type_uint32 (v, &value, name, errp); } +static void ich9_pm_get_cpu_io_base (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +ICH9LPCState *s =ICH9_LPC_DEVICE (obj); + +visit_type_uint16 (v, &s->pm.gpe_cpu.io_base, name, errp); +} +void ich9_pm_add_properties (Object *obj,ICH9LPCPMRegs *pm,Error **errp) {static const uint32_t gpe0_len =ICH9_PMIO_GPE0_LEN ;@@ -233,4 +257,7 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm, Error **errp) NULL, NULL, pm, NULL);object_property_add_uint32_ptr (obj,ACPI_PM_PROP_GPE0_BLK_LEN , &gpe0_len, errp); + pm->gpe_cpu.io_base =ICH9_PROC_BASE ; +object_property_add (obj,ACPI_CPU_HOTPLUG_IO_BASE_PROP ,"int" , + ich9_pm_get_cpu_io_base,NULL ,NULL ,NULL ,NULL ); }include/hw/acpi/ich9.h +4
-0@@ -22,6 +22,7 @@#define HW_ACPI_ICH9_H #include "hw/acpi/acpi.h" +#include "hw/acpi/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.8.3.1
Re: [Qemu-devel] [PATCH 03/11] acpi: factor out common cpu hotplug code for PIIX4/Q35
In reply to Michael S. TsirkinQuoted 7 lines · On Thu, 19 Dec 2013 16:14:03 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 3 lines · Igor Mammedov
.. so it could be used for adding CPU hotplug to Q35 machine
Signed-off-by Igor Mammedov <[email protected]>Sounds good but please call this file cpu_hotplug.c/.h or cpu-hotplug.c/h and make all prefixes
acpi_cpu_hotplugand AcpiCpuHotplug.
sure
Quoted 272 lines
Quoted 272 lines
--- hw/acpi/Makefile.objs | 2 +- hw/acpi/hotplug.c | 65 +++++++++++++++++++++++++++++++++++++++ hw/acpi/piix4.c | 78 +++++------------------------------------------ include/hw/acpi/hotplug.h | 31 +++++++++++++++++++ 4 files changed, 104 insertions(+), 72 deletions(-) create mode 100644 hw/acpi/hotplug.c create mode 100644 include/hw/acpi/hotplug.hhw/acpi/Makefile.objs +1
-1@@ -1,2 +1,2 @@ -common-obj-$(CONFIG_ACPI) += core.o piix4.o ich9.o +common-obj-$(CONFIG_ACPI) += core.o piix4.o ich9.o hotplug.ohw/acpi/hotplug.c new file +65
-0@@ -0,0 +1,65 @@ +/* +* 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. +*/ +#include "hw/hw.h" +#include "hw/acpi/hotplug.h" + +static uint64_t cpu_status_read (void *opaque,hwaddr addr,unsigned int size) +{ +AcpiCPUHotplug *cpus = opaque; +uint64_t val = cpus->sts[addr]; + +return val; +} + +static void cpu_status_write (void *opaque,hwaddr addr,uint64_t data, +unsigned int size) +{ +/* TODO: implement VCPU removal on guest signal that CPU can be removed */ +} + +static const MemoryRegionOps acpi_cpu_hotplug_ops = { + .read = cpu_status_read, + .write = cpu_status_write, + .endianness =DEVICE_LITTLE_ENDIAN , + .valid = { + .min_access_size =1 , + .max_access_size =1 , + }, +}; + +void acpi_hotplug_cpu_add (ACPIGPE *gpe,AcpiCPUHotplug *g,CPUState *cpu) +{ +CPUClass *k =CPU_GET_CLASS (cpu); +int64_t cpu_id; + + *gpe->sts = *gpe->sts |ACPI_CPU_HOTPLUG_STATUS ; + cpu_id = k->get_arch_id (CPU (cpu)); + g->sts[cpu_id /8 ] |= (1 << (cpu_id %8 )); +} + +void acpi_hotplug_cpu_init (MemoryRegion *parent,Object *owner, +AcpiCPUHotplug *gpe_cpu,uint16_t base) +{ +CPUState *cpu; + +CPU_FOREACH (cpu) { +CPUClass *cc =CPU_GET_CLASS (cpu); +int64_t id = cc->get_arch_id (cpu); + +g_assert ((id /8 ) <ACPI_GPE_PROC_LEN ); + gpe_cpu->sts[id /8 ] |= (1 << (id %8 )); + } + gpe_cpu->io_base = base; +memory_region_init_io (&gpe_cpu->io, owner, &acpi_cpu_hotplug_ops, + gpe_cpu,"acpi-cpu-hotplug" ,ACPI_GPE_PROC_LEN ); +memory_region_add_subregion (parent, gpe_cpu->io_base, &gpe_cpu->io); +}hw/acpi/piix4.c +7
-71@@ -30,6 +30,7 @@#include "hw/nvram/fw_cfg.h" #include "exec/address-spaces.h" #include "hw/acpi/piix4.h" +#include "hw/acpi/hotplug.h" //#define DEBUG @@ -50,20 +51,14 @@#define PCI_RMV_BASE 0xae0c#define PIIX4_PROC_BASE 0xaf00 -#define PIIX4_PROC_LEN 32#define PIIX4_PCI_HOTPLUG_STATUS 2 -#define PIIX4_CPU_HOTPLUG_STATUS 4struct pci_status {uint32_t up;/* deprecated, maintained for migration compatibility */ uint32_t down; }; -typedef struct CPUStatus { -uint8_t sts[PIIX4_PROC_LEN ]; -}CPUStatus ; - typedef struct PIIX4PMState { /*< private >*/ PCIDevice parent_obj;@@ -74,7 +69,6 @@ typedef struct PIIX4PMState {MemoryRegion io_gpe;MemoryRegion io_pci; -MemoryRegion io_cpu;ACPIREGS ar;APMState apm;@@ -97,7 +91,7 @@ typedef struct PIIX4PMState {uint8_t disable_s4;uint8_t s4_val; -CPUStatus gpe_cpu; +AcpiCPUHotplug gpe_cpu;Notifier cpu_added_notifier; } PIIX4PMState;@@ -628,61 +622,13 @@ static const MemoryRegionOps piix4_pci_ops = { }, }; -static uint64_t cpu_status_read (void *opaque,hwaddr addr,unsigned int size) -{ -PIIX4PMState *s = opaque; -CPUStatus *cpus = &s->gpe_cpu; -uint64_t val = cpus->sts[addr]; - -return val; -} - -static void cpu_status_write (void *opaque,hwaddr addr,uint64_t data, -unsigned int size) -{ -/* TODO: implement VCPU removal on guest signal that CPU can be removed */ -} - -static const MemoryRegionOps cpu_hotplug_ops = { - .read = cpu_status_read, - .write = cpu_status_write, - .endianness =DEVICE_LITTLE_ENDIAN , - .valid = { - .min_access_size =1 , - .max_access_size =1 , - }, -}; - -typedef enum { -PLUG , -UNPLUG , -}HotplugEventType ; - -static void piix4_cpu_hotplug_req (PIIX4PMState *s,CPUState *cpu, -HotplugEventType action) -{ -CPUStatus *g = &s->gpe_cpu; -ACPIGPE *gpe = &s->ar.gpe; -CPUClass *k =CPU_GET_CLASS (cpu); -int64_t cpu_id; - -assert (s !=NULL ); - - *gpe->sts = *gpe->sts |PIIX4_CPU_HOTPLUG_STATUS ; - cpu_id = k->get_arch_id (CPU (cpu)); -if (action ==PLUG ) { - g->sts[cpu_id /8 ] |= (1 << (cpu_id %8 )); - }else { - g->sts[cpu_id /8 ] &= ~(1 << (cpu_id %8 )); - } -acpi_update_sci (&s->ar, s->irq); -} -static void piix4_cpu_added_req (Notifier *n,void *opaque) {PIIX4PMState *s =container_of (n, PIIX4PMState, cpu_added_notifier); -piix4_cpu_hotplug_req (s,CPU (opaque),PLUG ); +assert (s !=NULL ); +acpi_hotplug_cpu_add (&s->ar.gpe, &s->gpe_cpu,CPU (opaque)); +acpi_update_sci (&s->ar, s->irq); } static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev,@@ -691,8 +637,6 @@ static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev,static void piix4_acpi_system_hot_add_init (MemoryRegion *parent,PCIBus *bus,PIIX4PMState *s) { -CPUState *cpu; -memory_region_init_io (&s->io_gpe,OBJECT (s), &piix4_gpe_ops, s,"acpi-gpe0" ,GPE_LEN );memory_region_add_subregion (parent,GPE_BASE , &s->io_gpe);@@ -703,16 +647,8 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent, &s->io_pci);pci_bus_hotplug (bus, piix4_device_hotplug,DEVICE (s)); -CPU_FOREACH (cpu) { -CPUClass *cc =CPU_GET_CLASS (cpu); -int64_t id = cc->get_arch_id (cpu); - -g_assert ((id /8 ) <PIIX4_PROC_LEN ); - s->gpe_cpu.sts[id /8 ] |= (1 << (id %8 )); - } -memory_region_init_io (&s->io_cpu,OBJECT (s), &cpu_hotplug_ops, s, -"acpi-cpu-hotplug" ,PIIX4_PROC_LEN ); -memory_region_add_subregion (parent,PIIX4_PROC_BASE , &s->io_cpu); +acpi_hotplug_cpu_init (parent,OBJECT (s), &s->gpe_cpu, +PIIX4_PROC_BASE ); s->cpu_added_notifier.notify = piix4_cpu_added_req;qemu_register_cpu_added_notifier (&s->cpu_added_notifier); }include/hw/acpi/hotplug.h new file +31
-0@@ -0,0 +1,31 @@ +/* +* 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" + +#define ACPI_CPU_HOTPLUG_STATUS 4 + +#define ACPI_GPE_PROC_LEN 32 + +typedef struct AcpiCPUHotplug { +MemoryRegion io; +uint16_t io_base; +uint8_t sts[ACPI_GPE_PROC_LEN ]; +}AcpiCPUHotplug ; + +void acpi_hotplug_cpu_add (ACPIGPE *gpe,AcpiCPUHotplug *g,CPUState *cpu); + +void acpi_hotplug_cpu_init (MemoryRegion *parent,Object *owner, +AcpiCPUHotplug *gpe_cpu,uint16_t base); +#endif Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 06/11] acpi/ich9: add CPU hotplug handling to Q35 machine
In reply to Michael S. TsirkinQuoted 8 lines · On Thu, 19 Dec 2013 16:18:59 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 3 lines · Igor Mammedov
.. including readonly 'cpu-hotplug-io-base' property
Signed-off-by Igor Mammedov <[email protected]>Is this documented in the Q35 spec? Could not find it there. If this is our PV code like PIIX, then we need to document this interface.
It's PV code and I need to update docs/specs/acpi_cpu_hotplug.txt with Q35 io range.
I'll respin remained patches on top of PCI branch.
Quoted 94 lines
Quoted 94 lines
--- hw/acpi/ich9.c | 27 +++++++++++++++++++++++++++ include/hw/acpi/ich9.h | 4 ++++ 2 files changed, 31 insertions(+)hw/acpi/ich9.c +27
-0@@ -44,6 +44,8 @@ do { printf("%s "fmt, __func__, ## __VA_ARGS__); } while (0)#define ICH9_DEBUG (fmt, ...) do { } while (0)#endif +#define ICH9_PROC_BASE 0xa18 +static void ich9_pm_update_sci_fn (ACPIREGS *regs) {ICH9LPCPMRegs *pm =container_of (regs, ICH9LPCPMRegs, acpi_regs);@@ -185,6 +187,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 ); +acpi_hotplug_cpu_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 +221,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); + +acpi_hotplug_cpu_init (pci_address_space_io (lpc_pci),OBJECT (lpc_pci), + &pm->gpe_cpu, pm->gpe_cpu.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,@@ -222,6 +238,14 @@ static void ich9_pm_get_gpe0_blk(Object *obj, Visitor *v,visit_type_uint32 (v, &value, name, errp); } +static void ich9_pm_get_cpu_io_base (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +ICH9LPCState *s =ICH9_LPC_DEVICE (obj); + +visit_type_uint16 (v, &s->pm.gpe_cpu.io_base, name, errp); +} +void ich9_pm_add_properties (Object *obj,ICH9LPCPMRegs *pm,Error **errp) {static const uint32_t gpe0_len =ICH9_PMIO_GPE0_LEN ;@@ -233,4 +257,7 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm, Error **errp) NULL, NULL, pm, NULL);object_property_add_uint32_ptr (obj,ACPI_PM_PROP_GPE0_BLK_LEN , &gpe0_len, errp); + pm->gpe_cpu.io_base =ICH9_PROC_BASE ; +object_property_add (obj,ACPI_CPU_HOTPLUG_IO_BASE_PROP ,"int" , + ich9_pm_get_cpu_io_base,NULL ,NULL ,NULL ,NULL ); }include/hw/acpi/ich9.h +4
-0@@ -22,6 +22,7 @@#define HW_ACPI_ICH9_H #include "hw/acpi/acpi.h" +#include "hw/acpi/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.8.3.1
Re: [Qemu-devel] [PATCH 06/11] acpi/ich9: add CPU hotplug handling to Q35 machine
Quoted 6 lines · Igor Mammedov
Quoted 3 lines · On Thu, 19 Dec 2013 16:18:59 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 2 lines · Igor Mammedov
.. including readonly 'cpu-hotplug-io-base' property
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Igor Mammedov <[email protected]>Is this documented in the Q35 spec? Could not find it there. If this is our PV code like PIIX, then we need to document this interface.
It's PV code and I need to update
docs/specs/acpi_cpu_hotplug.txtwith Q35 io range.
BTW doesn't some system out there implement cpu hotplug? If yes would have been nice to reuse that, though not a must.
Quoted 96 lines
I'll respin remained patches on top of PCI branch.
Quoted 94 lines
Quoted 94 lines
--- hw/acpi/ich9.c | 27 +++++++++++++++++++++++++++ include/hw/acpi/ich9.h | 4 ++++ 2 files changed, 31 insertions(+)hw/acpi/ich9.c +27
-0@@ -44,6 +44,8 @@ do { printf("%s "fmt, __func__, ## __VA_ARGS__); } while (0)#define ICH9_DEBUG (fmt, ...) do { } while (0)#endif +#define ICH9_PROC_BASE 0xa18 +static void ich9_pm_update_sci_fn (ACPIREGS *regs) {ICH9LPCPMRegs *pm =container_of (regs, ICH9LPCPMRegs, acpi_regs);@@ -185,6 +187,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 ); +acpi_hotplug_cpu_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 +221,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); + +acpi_hotplug_cpu_init (pci_address_space_io (lpc_pci),OBJECT (lpc_pci), + &pm->gpe_cpu, pm->gpe_cpu.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,@@ -222,6 +238,14 @@ static void ich9_pm_get_gpe0_blk(Object *obj, Visitor *v,visit_type_uint32 (v, &value, name, errp); } +static void ich9_pm_get_cpu_io_base (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +ICH9LPCState *s =ICH9_LPC_DEVICE (obj); + +visit_type_uint16 (v, &s->pm.gpe_cpu.io_base, name, errp); +} +void ich9_pm_add_properties (Object *obj,ICH9LPCPMRegs *pm,Error **errp) {static const uint32_t gpe0_len =ICH9_PMIO_GPE0_LEN ;@@ -233,4 +257,7 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm, Error **errp) NULL, NULL, pm, NULL);object_property_add_uint32_ptr (obj,ACPI_PM_PROP_GPE0_BLK_LEN , &gpe0_len, errp); + pm->gpe_cpu.io_base =ICH9_PROC_BASE ; +object_property_add (obj,ACPI_CPU_HOTPLUG_IO_BASE_PROP ,"int" , + ich9_pm_get_cpu_io_base,NULL ,NULL ,NULL ,NULL ); }include/hw/acpi/ich9.h +4
-0@@ -22,6 +22,7 @@#define HW_ACPI_ICH9_H #include "hw/acpi/acpi.h" +#include "hw/acpi/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.8.3.1
Re: [Qemu-devel] [PATCH 09/11] ACPI: move PRST OperationRegion into SSDT
In reply to Michael S. TsirkinQuoted 159 lines · On Mon, 16 Dec 2013 21:53:07 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 143 lines · Igor Mammedov
.. and report range used by it to OSPM via
_CRS. PRST is needed in SSDT since its base will depend on chipset and will be dynamically set by QEMU. Also movePRSC()method along with PRST since cross table reference to PRST doesn't work.Signed-off-by Igor Mammedov <[email protected]>--- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 39 +---------------------- hw/i386/acpi-dsdt.dsl | 2 +- hw/i386/q35-acpi-dsdt.dsl | 2 +- hw/i386/ssdt-misc.dsl | 65 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 40 deletions(-)hw/i386/acpi-dsdt-cpu-hotplug.dsl +1
-38@@ -20,6 +20,7 @@ Scope(\_SB) { /* Objects filled in by run-time generated SSDT */ External(NTFY, MethodObj) + External(\_SB.CPHD.PRSC, MethodObj) External(CPON, PkgObj) /* Methods called by run-time generated SSDT Processor objects */@@ -51,42 +52,4 @@ Scope(\_SB) { // _EJ0 method - eject callback Sleep(200) } - - OperationRegion(PRST, SystemIO, 0xaf00, 32) - Field(PRST, ByteAcc, NoLock, Preserve) { - PRS, 256 - } - Method(PRSC, 0) { - // Local5 = active cpu bitmap - Store(PRS, Local5) - // Local2 = last read byte from bitmap - Store(Zero, Local2) - // Local0 = Processor ID / APIC ID iterator - Store(Zero, Local0) - While (LLess(Local0, SizeOf(CPON))) { - // Local1 = CPON flag for this cpu - Store(DerefOf(Index(CPON, Local0)), Local1) - If (And(Local0, 0x07)) { - // Shift down previously read bitmap byte - ShiftRight(Local2, 1, Local2) - } Else { - // Read next byte from cpu bitmap - Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) - } - // Local3 = active state for this cpu - Store(And(Local2, 1), Local3) - - If (LNotEqual(Local1, Local3)) { - // State change - update CPON with new state - Store(Local3, Index(CPON, Local0)) - // Do CPU notify - If (LEqual(Local3, 1)) { - NTFY(Local0, 1) - } Else { - NTFY(Local0, 3) - } - } - Increment(Local0) - } - } }hw/i386/acpi-dsdt.dsl +1
-1@@ -311,7 +311,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPHD.PRSC() } Method(_L03) { }hw/i386/q35-acpi-dsdt.dsl +1
-1@@ -420,7 +420,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPHD.PRSC() } Method(_L03) { }hw/i386/ssdt-misc.dsl +40
-0@@ -116,4 +116,69 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) } } } + Scope(\_SB) { + External(NTFY, MethodObj) + External(CPON, PkgObj) + + Device(CPHD) { + Name(_HID, EISAID("PNP0C08")) + Name(CPPL, 32) // cpu-gpe length + Name(CPHP, 0xaf00) + + OperationRegion(PRST, SystemIO, CPHP, CPPL) + Field(PRST, ByteAcc, NoLock, Preserve) { + PRS, 256 + } + + Method(PRSC, 0) { + // Local5 = active cpu bitmap + Store(PRS, Local5) + // Local2 = last read byte from bitmap + Store(Zero, Local2) + // Local0 = Processor ID / APIC ID iterator + Store(Zero, Local0) + While (LLess(Local0, SizeOf(CPON))) { + // Local1 = CPON flag for this cpu + Store(DerefOf(Index(CPON, Local0)), Local1) + If (And(Local0, 0x07)) { + // Shift down previously read bitmap byte + ShiftRight(Local2, 1, Local2) + } Else { + // Read next byte from cpu bitmap + Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) + } + // Local3 = active state for this cpu + Store(And(Local2, 1), Local3) + + If (LNotEqual(Local1, Local3)) { + // State change - update CPON with new state + Store(Local3, Index(CPON, Local0)) + // Do CPU notify + If (LEqual(Local3, 1)) { + NTFY(Local0, 1)hw/i386/ssdt-misc.dsl DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) · line 168
Quoted 10 lines
hw/i386/ssdt-misc.dsl +10
-0+ } Else { + NTFY(Local0, 3) + } + } + Increment(Local0) + } + } + + /* Leave bit 0 cleared to avoid Windows BSOD */ + Name(_STA, 0xA)This shared the problem you yourself pointed out with patch 'pc: ACPI BIOS: implement memory hotplug':
if we make device non present ospm can ignore our_CRS.
Quoted 1 line
Can't we get a better handle on why windows crashes?
Whenever _CRS with PRST IO range is exposed as part of PNP0A05/PNP0A06 or ACPI0004 device, it BSODs with INACCESSIBLE_BOOT_DEVICE with following stack:
: nt!PnpBootDeviceWait+0x181
: nt!IopInitializeBootDrivers+0xbd3
: nt!IoInitSystem+0xbb6
: nt!Phase1InitializationDiscard+0x16f6
: nt!Phase1Initialization+0x13
: nt!PspSystemThreadStartup+0x23d
: nt!KiStartSystemThread+0x16
However it works fine if containing device is PNP0C02 "Motherboard registers", so we probably should use it instead.
Quoted 21 lines
Quoted 20 lines
hw/i386/ssdt-misc.dsl +15
-0+ + Method(_CRS, 0) { + Store(ResourceTemplate() { + IO(Decode16, 0x00, 0x00, 0x01, 0x15, IO) + }, Local0) + + CreateWordField(Local0, IO._MIN, IOMN) + CreateWordField(Local0, IO._MAX, IOMX) + + Store(CPHP, IOMN) + Subtract(Add(CPHP, CPPL), 1, IOMX) + Return(Local0) + } + } // Device(CPHD) + } // Scope(\_SB) }Signature · 1 line
1.8.3.1
Signature · 2 lines
Regards, Igor
Re: [Qemu-devel] [PATCH 09/11] ACPI: move PRST OperationRegion into SSDT
Quoted 163 lines · Igor Mammedov
Quoted 159 lines · On Mon, 16 Dec 2013 21:53:07 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 143 lines · Igor Mammedov
.. and report range used by it to OSPM via
_CRS. PRST is needed in SSDT since its base will depend on chipset and will be dynamically set by QEMU. Also movePRSC()method along with PRST since cross table reference to PRST doesn't work.Signed-off-by Igor Mammedov <[email protected]>--- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 39 +---------------------- hw/i386/acpi-dsdt.dsl | 2 +- hw/i386/q35-acpi-dsdt.dsl | 2 +- hw/i386/ssdt-misc.dsl | 65 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 40 deletions(-)hw/i386/acpi-dsdt-cpu-hotplug.dsl +1
-38@@ -20,6 +20,7 @@ Scope(\_SB) { /* Objects filled in by run-time generated SSDT */ External(NTFY, MethodObj) + External(\_SB.CPHD.PRSC, MethodObj) External(CPON, PkgObj) /* Methods called by run-time generated SSDT Processor objects */@@ -51,42 +52,4 @@ Scope(\_SB) { // _EJ0 method - eject callback Sleep(200) } - - OperationRegion(PRST, SystemIO, 0xaf00, 32) - Field(PRST, ByteAcc, NoLock, Preserve) { - PRS, 256 - } - Method(PRSC, 0) { - // Local5 = active cpu bitmap - Store(PRS, Local5) - // Local2 = last read byte from bitmap - Store(Zero, Local2) - // Local0 = Processor ID / APIC ID iterator - Store(Zero, Local0) - While (LLess(Local0, SizeOf(CPON))) { - // Local1 = CPON flag for this cpu - Store(DerefOf(Index(CPON, Local0)), Local1) - If (And(Local0, 0x07)) { - // Shift down previously read bitmap byte - ShiftRight(Local2, 1, Local2) - } Else { - // Read next byte from cpu bitmap - Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) - } - // Local3 = active state for this cpu - Store(And(Local2, 1), Local3) - - If (LNotEqual(Local1, Local3)) { - // State change - update CPON with new state - Store(Local3, Index(CPON, Local0)) - // Do CPU notify - If (LEqual(Local3, 1)) { - NTFY(Local0, 1) - } Else { - NTFY(Local0, 3) - } - } - Increment(Local0) - } - } }hw/i386/acpi-dsdt.dsl +1
-1@@ -311,7 +311,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPHD.PRSC() } Method(_L03) { }hw/i386/q35-acpi-dsdt.dsl +1
-1@@ -420,7 +420,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPHD.PRSC() } Method(_L03) { }hw/i386/ssdt-misc.dsl +40
-0@@ -116,4 +116,69 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) } } } + Scope(\_SB) { + External(NTFY, MethodObj) + External(CPON, PkgObj) + + Device(CPHD) { + Name(_HID, EISAID("PNP0C08")) + Name(CPPL, 32) // cpu-gpe length + Name(CPHP, 0xaf00) + + OperationRegion(PRST, SystemIO, CPHP, CPPL) + Field(PRST, ByteAcc, NoLock, Preserve) { + PRS, 256 + } + + Method(PRSC, 0) { + // Local5 = active cpu bitmap + Store(PRS, Local5) + // Local2 = last read byte from bitmap + Store(Zero, Local2) + // Local0 = Processor ID / APIC ID iterator + Store(Zero, Local0) + While (LLess(Local0, SizeOf(CPON))) { + // Local1 = CPON flag for this cpu + Store(DerefOf(Index(CPON, Local0)), Local1) + If (And(Local0, 0x07)) { + // Shift down previously read bitmap byte + ShiftRight(Local2, 1, Local2) + } Else { + // Read next byte from cpu bitmap + Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) + } + // Local3 = active state for this cpu + Store(And(Local2, 1), Local3) + + If (LNotEqual(Local1, Local3)) { + // State change - update CPON with new state + Store(Local3, Index(CPON, Local0)) + // Do CPU notify + If (LEqual(Local3, 1)) { + NTFY(Local0, 1)hw/i386/ssdt-misc.dsl DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) · line 168
Quoted 10 lines
hw/i386/ssdt-misc.dsl +10
-0+ } Else { + NTFY(Local0, 3) + } + } + Increment(Local0) + } + } + + /* Leave bit 0 cleared to avoid Windows BSOD */ + Name(_STA, 0xA)This shared the problem you yourself pointed out with patch 'pc: ACPI BIOS: implement memory hotplug':
if we make device non present ospm can ignore our_CRS.Quoted 1 line
Can't we get a better handle on why windows crashes?
Quoted 9 lines
Whenever
_CRSwith PRST IO range is exposed as part of PNP0A05/PNP0A06 or ACPI0004 device, it BSODs withINACCESSIBLE_BOOT_DEVICEwith following stack:
: nt!PnpBootDeviceWait+0x181
: nt!IopInitializeBootDrivers+0xbd3
: nt!IoInitSystem+0xbb6
: nt!Phase1InitializationDiscard+0x16f6
: nt!Phase1Initialization+0x13
: nt!PspSystemThreadStartup+0x23d
: nt!KiStartSystemThread+0x16
Interesting. This seems to imply that it can't access IO port for the disk. Which boot disk type are you using? Is the _CRS resource overlapping any other resource by any chance?
Quoted 31 lines
However it works fine if containing device is PNP0C02 "Motherboard registers", so we probably should use it instead.
Quoted 21 lines
Quoted 20 lines
hw/i386/ssdt-misc.dsl +15
-0+ + Method(_CRS, 0) { + Store(ResourceTemplate() { + IO(Decode16, 0x00, 0x00, 0x01, 0x15, IO) + }, Local0) + + CreateWordField(Local0, IO._MIN, IOMN) + CreateWordField(Local0, IO._MAX, IOMX) + + Store(CPHP, IOMN) + Subtract(Add(CPHP, CPPL), 1, IOMX) + Return(Local0) + } + } // Device(CPHD) + } // Scope(\_SB) }Signature · 1 line
1.8.3.1Signature · 2 lines
Regards, Igor
Re: [Qemu-devel] [PATCH 09/11] ACPI: move PRST OperationRegion into SSDT
Quoted 175 lines · On Mon, 23 Dec 2013 13:26:37 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 163 lines · Igor Mammedov
Quoted 159 lines · On Mon, 16 Dec 2013 21:53:07 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 143 lines · Igor Mammedov
.. and report range used by it to OSPM via
_CRS. PRST is needed in SSDT since its base will depend on chipset and will be dynamically set by QEMU. Also movePRSC()method along with PRST since cross table reference to PRST doesn't work.Signed-off-by Igor Mammedov <[email protected]>--- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 39 +---------------------- hw/i386/acpi-dsdt.dsl | 2 +- hw/i386/q35-acpi-dsdt.dsl | 2 +- hw/i386/ssdt-misc.dsl | 65 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 40 deletions(-)hw/i386/acpi-dsdt-cpu-hotplug.dsl +1
-38@@ -20,6 +20,7 @@ Scope(\_SB) { /* Objects filled in by run-time generated SSDT */ External(NTFY, MethodObj) + External(\_SB.CPHD.PRSC, MethodObj) External(CPON, PkgObj) /* Methods called by run-time generated SSDT Processor objects */@@ -51,42 +52,4 @@ Scope(\_SB) { // _EJ0 method - eject callback Sleep(200) } - - OperationRegion(PRST, SystemIO, 0xaf00, 32) - Field(PRST, ByteAcc, NoLock, Preserve) { - PRS, 256 - } - Method(PRSC, 0) { - // Local5 = active cpu bitmap - Store(PRS, Local5) - // Local2 = last read byte from bitmap - Store(Zero, Local2) - // Local0 = Processor ID / APIC ID iterator - Store(Zero, Local0) - While (LLess(Local0, SizeOf(CPON))) { - // Local1 = CPON flag for this cpu - Store(DerefOf(Index(CPON, Local0)), Local1) - If (And(Local0, 0x07)) { - // Shift down previously read bitmap byte - ShiftRight(Local2, 1, Local2) - } Else { - // Read next byte from cpu bitmap - Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) - } - // Local3 = active state for this cpu - Store(And(Local2, 1), Local3) - - If (LNotEqual(Local1, Local3)) { - // State change - update CPON with new state - Store(Local3, Index(CPON, Local0)) - // Do CPU notify - If (LEqual(Local3, 1)) { - NTFY(Local0, 1) - } Else { - NTFY(Local0, 3) - } - } - Increment(Local0) - } - } }hw/i386/acpi-dsdt.dsl +1
-1@@ -311,7 +311,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPHD.PRSC() } Method(_L03) { }hw/i386/q35-acpi-dsdt.dsl +1
-1@@ -420,7 +420,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPHD.PRSC() } Method(_L03) { }hw/i386/ssdt-misc.dsl +40
-0@@ -116,4 +116,69 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) } } } + Scope(\_SB) { + External(NTFY, MethodObj) + External(CPON, PkgObj) + + Device(CPHD) { + Name(_HID, EISAID("PNP0C08")) + Name(CPPL, 32) // cpu-gpe length + Name(CPHP, 0xaf00) + + OperationRegion(PRST, SystemIO, CPHP, CPPL) + Field(PRST, ByteAcc, NoLock, Preserve) { + PRS, 256 + } + + Method(PRSC, 0) { + // Local5 = active cpu bitmap + Store(PRS, Local5) + // Local2 = last read byte from bitmap + Store(Zero, Local2) + // Local0 = Processor ID / APIC ID iterator + Store(Zero, Local0) + While (LLess(Local0, SizeOf(CPON))) { + // Local1 = CPON flag for this cpu + Store(DerefOf(Index(CPON, Local0)), Local1) + If (And(Local0, 0x07)) { + // Shift down previously read bitmap byte + ShiftRight(Local2, 1, Local2) + } Else { + // Read next byte from cpu bitmap + Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) + } + // Local3 = active state for this cpu + Store(And(Local2, 1), Local3) + + If (LNotEqual(Local1, Local3)) { + // State change - update CPON with new state + Store(Local3, Index(CPON, Local0)) + // Do CPU notify + If (LEqual(Local3, 1)) { + NTFY(Local0, 1)hw/i386/ssdt-misc.dsl DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) · line 168
Quoted 10 lines
hw/i386/ssdt-misc.dsl +10
-0+ } Else { + NTFY(Local0, 3) + } + } + Increment(Local0) + } + } + + /* Leave bit 0 cleared to avoid Windows BSOD */ + Name(_STA, 0xA)This shared the problem you yourself pointed out with patch 'pc: ACPI BIOS: implement memory hotplug':
if we make device non present ospm can ignore our_CRS.Quoted 1 line
Can't we get a better handle on why windows crashes?
Quoted 9 lines
Whenever
_CRSwith PRST IO range is exposed as part of PNP0A05/PNP0A06 or ACPI0004 device, it BSODs withINACCESSIBLE_BOOT_DEVICEwith following stack:
: nt!PnpBootDeviceWait+0x181
: nt!IopInitializeBootDrivers+0xbd3
: nt!IoInitSystem+0xbb6
: nt!Phase1InitializationDiscard+0x16f6
: nt!Phase1Initialization+0x13
: nt!PspSystemThreadStartup+0x23d
: nt!KiStartSystemThread+0x16
Quoted 4 lines
Interesting. This seems to imply that it can't access IO port for the disk. Which boot disk type are you using? Is the
_CRSresource overlapping any other resource by any chance?
Yes, I've dug in the issue more and it is indeed _CRS overlapping with PCI bus. PCI bus's IO ports are statically defined in acpi-dsdt-pci-crs.dsl and basically take all io ports except of 0xcf8-0xcff hole.
Since PIIX4_PM and ICH9 LPC are PCI devices, it appears that PRST already covered by bus CRS, the same applies to PCI hotplug as well.
So I was doing it wrong trying advertise bus resources out of bus scope.
What we need is to add PIIX4_PM/ICH9 LPC device definition with consumed IO ports CRS to PCI bus. Question is what PNP IDs they should use?
It looks pretty much out of scope of cpu_hotplug and should be done for pci hotplug as well. So I'm ditching ACPI device and CRS parts from this series as not directly related.
Adding PIIX4_PM/ICH9 LPC ACPI device could be done later and preferably for all resources consumed by it to make it right.
Quoted 32 lines
Quoted 32 lines
However it works fine if containing device is PNP0C02 "Motherboard registers", so we probably should use it instead.
Quoted 21 lines
Quoted 20 lines
hw/i386/ssdt-misc.dsl +15
-0+ + Method(_CRS, 0) { + Store(ResourceTemplate() { + IO(Decode16, 0x00, 0x00, 0x01, 0x15, IO) + }, Local0) + + CreateWordField(Local0, IO._MIN, IOMN) + CreateWordField(Local0, IO._MAX, IOMX) + + Store(CPHP, IOMN) + Subtract(Add(CPHP, CPPL), 1, IOMX) + Return(Local0) + } + } // Device(CPHD) + } // Scope(\_SB) }Signature · 1 line
1.8.3.1Signature · 2 lines
Regards, Igor
Signature · 2 lines
Regards, Igor
Re: [Qemu-devel] [PATCH 09/11] ACPI: move PRST OperationRegion into SSDT
Quoted 182 lines · Igor Mammedov
Quoted 175 lines · On Mon, 23 Dec 2013 13:26:37 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 163 lines · Igor Mammedov
Quoted 159 lines · On Mon, 16 Dec 2013 21:53:07 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 143 lines · Igor Mammedov
.. and report range used by it to OSPM via
_CRS. PRST is needed in SSDT since its base will depend on chipset and will be dynamically set by QEMU. Also movePRSC()method along with PRST since cross table reference to PRST doesn't work.Signed-off-by Igor Mammedov <[email protected]>--- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 39 +---------------------- hw/i386/acpi-dsdt.dsl | 2 +- hw/i386/q35-acpi-dsdt.dsl | 2 +- hw/i386/ssdt-misc.dsl | 65 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 40 deletions(-)hw/i386/acpi-dsdt-cpu-hotplug.dsl +1
-38@@ -20,6 +20,7 @@ Scope(\_SB) { /* Objects filled in by run-time generated SSDT */ External(NTFY, MethodObj) + External(\_SB.CPHD.PRSC, MethodObj) External(CPON, PkgObj) /* Methods called by run-time generated SSDT Processor objects */@@ -51,42 +52,4 @@ Scope(\_SB) { // _EJ0 method - eject callback Sleep(200) } - - OperationRegion(PRST, SystemIO, 0xaf00, 32) - Field(PRST, ByteAcc, NoLock, Preserve) { - PRS, 256 - } - Method(PRSC, 0) { - // Local5 = active cpu bitmap - Store(PRS, Local5) - // Local2 = last read byte from bitmap - Store(Zero, Local2) - // Local0 = Processor ID / APIC ID iterator - Store(Zero, Local0) - While (LLess(Local0, SizeOf(CPON))) { - // Local1 = CPON flag for this cpu - Store(DerefOf(Index(CPON, Local0)), Local1) - If (And(Local0, 0x07)) { - // Shift down previously read bitmap byte - ShiftRight(Local2, 1, Local2) - } Else { - // Read next byte from cpu bitmap - Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) - } - // Local3 = active state for this cpu - Store(And(Local2, 1), Local3) - - If (LNotEqual(Local1, Local3)) { - // State change - update CPON with new state - Store(Local3, Index(CPON, Local0)) - // Do CPU notify - If (LEqual(Local3, 1)) { - NTFY(Local0, 1) - } Else { - NTFY(Local0, 3) - } - } - Increment(Local0) - } - } }hw/i386/acpi-dsdt.dsl +1
-1@@ -311,7 +311,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPHD.PRSC() } Method(_L03) { }hw/i386/q35-acpi-dsdt.dsl +1
-1@@ -420,7 +420,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPHD.PRSC() } Method(_L03) { }hw/i386/ssdt-misc.dsl +40
-0@@ -116,4 +116,69 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) } } } + Scope(\_SB) { + External(NTFY, MethodObj) + External(CPON, PkgObj) + + Device(CPHD) { + Name(_HID, EISAID("PNP0C08")) + Name(CPPL, 32) // cpu-gpe length + Name(CPHP, 0xaf00) + + OperationRegion(PRST, SystemIO, CPHP, CPPL) + Field(PRST, ByteAcc, NoLock, Preserve) { + PRS, 256 + } + + Method(PRSC, 0) { + // Local5 = active cpu bitmap + Store(PRS, Local5) + // Local2 = last read byte from bitmap + Store(Zero, Local2) + // Local0 = Processor ID / APIC ID iterator + Store(Zero, Local0) + While (LLess(Local0, SizeOf(CPON))) { + // Local1 = CPON flag for this cpu + Store(DerefOf(Index(CPON, Local0)), Local1) + If (And(Local0, 0x07)) { + // Shift down previously read bitmap byte + ShiftRight(Local2, 1, Local2) + } Else { + // Read next byte from cpu bitmap + Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) + } + // Local3 = active state for this cpu + Store(And(Local2, 1), Local3) + + If (LNotEqual(Local1, Local3)) { + // State change - update CPON with new state + Store(Local3, Index(CPON, Local0)) + // Do CPU notify + If (LEqual(Local3, 1)) { + NTFY(Local0, 1)hw/i386/ssdt-misc.dsl DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) · line 168
Quoted 10 lines
hw/i386/ssdt-misc.dsl +10
-0+ } Else { + NTFY(Local0, 3) + } + } + Increment(Local0) + } + } + + /* Leave bit 0 cleared to avoid Windows BSOD */ + Name(_STA, 0xA)This shared the problem you yourself pointed out with patch 'pc: ACPI BIOS: implement memory hotplug':
if we make device non present ospm can ignore our_CRS.Quoted 1 line
Can't we get a better handle on why windows crashes?
Quoted 9 lines
Whenever
_CRSwith PRST IO range is exposed as part of PNP0A05/PNP0A06 or ACPI0004 device, it BSODs withINACCESSIBLE_BOOT_DEVICEwith following stack:
: nt!PnpBootDeviceWait+0x181
: nt!IopInitializeBootDrivers+0xbd3
: nt!IoInitSystem+0xbb6
: nt!Phase1InitializationDiscard+0x16f6
: nt!Phase1Initialization+0x13
: nt!PspSystemThreadStartup+0x23d
: nt!KiStartSystemThread+0x16Quoted 4 lines
Interesting. This seems to imply that it can't access IO port for the disk. Which boot disk type are you using? Is the
_CRSresource overlapping any other resource by any chance?
Quoted 6 lines
Yes, I've dug in the issue more and it is indeed
_CRSoverlapping with PCI bus. PCI bus's IO ports are statically defined in acpi-dsdt-pci-crs.dsl and basically take all io ports except of 0xcf8-0xcff hole.
SincePIIX4_PMand ICH9 LPC are PCI devices, it appears that PRST already covered by bus CRS, the same applies to PCI hotplug as well.
So I was doing it wrong trying advertise bus resources out of bus scope.
Yes, that's explicitly prohibited by the firmware specification.
Quoted 8 lines
What we need is to add PIIX4_PM/ICH9 LPC device definition with consumed IO ports CRS to PCI bus. Question is what PNP IDs they should use?
It looks pretty much out of scope of
cpu_hotplugand should be done for pci hotplug as well. So I'm ditching ACPI device and CRS parts from this series as not directly related.
Adding PIIX4_PM/ICH9 LPC ACPI device could be done later and preferably for all resources consumed by it to make it right.
Could be ok but are we using any new ports?
If yes then I think before doing that we should make sure _CRS for the host bridge does not include them, or consume them in some child device.
Otherwise we increase the chance of a conflict in case some guest uses that port.
Quoted 38 lines
Quoted 33 lines
Quoted 33 lines
However it works fine if containing device is PNP0C02 "Motherboard registers", so we probably should use it instead.
Quoted 21 lines
Quoted 20 lines
hw/i386/ssdt-misc.dsl +15
-0+ + Method(_CRS, 0) { + Store(ResourceTemplate() { + IO(Decode16, 0x00, 0x00, 0x01, 0x15, IO) + }, Local0) + + CreateWordField(Local0, IO._MIN, IOMN) + CreateWordField(Local0, IO._MAX, IOMX) + + Store(CPHP, IOMN) + Subtract(Add(CPHP, CPPL), 1, IOMX) + Return(Local0) + } + } // Device(CPHD) + } // Scope(\_SB) }Signature · 1 line
1.8.3.1Signature · 2 lines
Regards, IgorSignature · 2 lines
Regards, Igor
Re: [Qemu-devel] [PATCH 09/11] ACPI: move PRST OperationRegion into SSDT
Quoted 195 lines · On Mon, 23 Dec 2013 16:48:49 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 182 lines · Igor Mammedov
Quoted 175 lines · On Mon, 23 Dec 2013 13:26:37 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 163 lines · Igor Mammedov
Quoted 159 lines · On Mon, 16 Dec 2013 21:53:07 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 143 lines · Igor Mammedov
.. and report range used by it to OSPM via
_CRS. PRST is needed in SSDT since its base will depend on chipset and will be dynamically set by QEMU. Also movePRSC()method along with PRST since cross table reference to PRST doesn't work.Signed-off-by Igor Mammedov <[email protected]>--- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 39 +---------------------- hw/i386/acpi-dsdt.dsl | 2 +- hw/i386/q35-acpi-dsdt.dsl | 2 +- hw/i386/ssdt-misc.dsl | 65 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 40 deletions(-)hw/i386/acpi-dsdt-cpu-hotplug.dsl +1
-38@@ -20,6 +20,7 @@ Scope(\_SB) { /* Objects filled in by run-time generated SSDT */ External(NTFY, MethodObj) + External(\_SB.CPHD.PRSC, MethodObj) External(CPON, PkgObj) /* Methods called by run-time generated SSDT Processor objects */@@ -51,42 +52,4 @@ Scope(\_SB) { // _EJ0 method - eject callback Sleep(200) } - - OperationRegion(PRST, SystemIO, 0xaf00, 32) - Field(PRST, ByteAcc, NoLock, Preserve) { - PRS, 256 - } - Method(PRSC, 0) { - // Local5 = active cpu bitmap - Store(PRS, Local5) - // Local2 = last read byte from bitmap - Store(Zero, Local2) - // Local0 = Processor ID / APIC ID iterator - Store(Zero, Local0) - While (LLess(Local0, SizeOf(CPON))) { - // Local1 = CPON flag for this cpu - Store(DerefOf(Index(CPON, Local0)), Local1) - If (And(Local0, 0x07)) { - // Shift down previously read bitmap byte - ShiftRight(Local2, 1, Local2) - } Else { - // Read next byte from cpu bitmap - Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) - } - // Local3 = active state for this cpu - Store(And(Local2, 1), Local3) - - If (LNotEqual(Local1, Local3)) { - // State change - update CPON with new state - Store(Local3, Index(CPON, Local0)) - // Do CPU notify - If (LEqual(Local3, 1)) { - NTFY(Local0, 1) - } Else { - NTFY(Local0, 3) - } - } - Increment(Local0) - } - } }hw/i386/acpi-dsdt.dsl +1
-1@@ -311,7 +311,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPHD.PRSC() } Method(_L03) { }hw/i386/q35-acpi-dsdt.dsl +1
-1@@ -420,7 +420,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPHD.PRSC() } Method(_L03) { }hw/i386/ssdt-misc.dsl +40
-0@@ -116,4 +116,69 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) } } } + Scope(\_SB) { + External(NTFY, MethodObj) + External(CPON, PkgObj) + + Device(CPHD) { + Name(_HID, EISAID("PNP0C08")) + Name(CPPL, 32) // cpu-gpe length + Name(CPHP, 0xaf00) + + OperationRegion(PRST, SystemIO, CPHP, CPPL) + Field(PRST, ByteAcc, NoLock, Preserve) { + PRS, 256 + } + + Method(PRSC, 0) { + // Local5 = active cpu bitmap + Store(PRS, Local5) + // Local2 = last read byte from bitmap + Store(Zero, Local2) + // Local0 = Processor ID / APIC ID iterator + Store(Zero, Local0) + While (LLess(Local0, SizeOf(CPON))) { + // Local1 = CPON flag for this cpu + Store(DerefOf(Index(CPON, Local0)), Local1) + If (And(Local0, 0x07)) { + // Shift down previously read bitmap byte + ShiftRight(Local2, 1, Local2) + } Else { + // Read next byte from cpu bitmap + Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) + } + // Local3 = active state for this cpu + Store(And(Local2, 1), Local3) + + If (LNotEqual(Local1, Local3)) { + // State change - update CPON with new state + Store(Local3, Index(CPON, Local0)) + // Do CPU notify + If (LEqual(Local3, 1)) { + NTFY(Local0, 1)hw/i386/ssdt-misc.dsl DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) · line 168
Quoted 10 lines
hw/i386/ssdt-misc.dsl +10
-0+ } Else { + NTFY(Local0, 3) + } + } + Increment(Local0) + } + } + + /* Leave bit 0 cleared to avoid Windows BSOD */ + Name(_STA, 0xA)This shared the problem you yourself pointed out with patch 'pc: ACPI BIOS: implement memory hotplug':
if we make device non present ospm can ignore our_CRS.Quoted 1 line
Can't we get a better handle on why windows crashes?
Quoted 9 lines
Whenever
_CRSwith PRST IO range is exposed as part of PNP0A05/PNP0A06 or ACPI0004 device, it BSODs withINACCESSIBLE_BOOT_DEVICEwith following stack:
: nt!PnpBootDeviceWait+0x181
: nt!IopInitializeBootDrivers+0xbd3
: nt!IoInitSystem+0xbb6
: nt!Phase1InitializationDiscard+0x16f6
: nt!Phase1Initialization+0x13
: nt!PspSystemThreadStartup+0x23d
: nt!KiStartSystemThread+0x16Quoted 4 lines
Interesting. This seems to imply that it can't access IO port for the disk. Which boot disk type are you using? Is the
_CRSresource overlapping any other resource by any chance?Quoted 6 lines
Yes, I've dug in the issue more and it is indeed
_CRSoverlapping with PCI bus. PCI bus's IO ports are statically defined in acpi-dsdt-pci-crs.dsl and basically take all io ports except of 0xcf8-0xcff hole.
SincePIIX4_PMand ICH9 LPC are PCI devices, it appears that PRST already covered by bus CRS, the same applies to PCI hotplug as well.
So I was doing it wrong trying advertise bus resources out of bus scope.Yes, that's explicitly prohibited by the firmware specification.
Quoted 3 lines
What we need is to add PIIX4_PM/ICH9 LPC device definition with consumed IO ports CRS to PCI bus. Question is what PNP IDs they should use?
Quoted 7 lines
Quoted 5 lines
It looks pretty much out of scope of
cpu_hotplugand should be done for pci hotplug as well. So I'm ditching ACPI device and CRS parts from this series as not directly related.
Adding PIIX4_PM/ICH9 LPC ACPI device could be done later and preferably for all resources consumed by it to make it right.Could be ok but are we using any new ports?
yes, for q35. series adds 0xa18-0xa37 IO ports, it was requested by Gerd not to use 0xaf00-0xaf1f.
Quoted 2 lines
If yes then I think before doing that we should make sure
_CRSfor the host bridge does not include them, or consume them
I'm fine with making holes in PCI bus CRES template, I can do it for pci-hotplug as well while at it.
Quoted 1 line
in some child device.
that would be cleanest, but is there any suggestion what device(s) it would be for piix and ich9-lpc, i.e. which PNP IDs should we use?
Quoted 41 lines
Otherwise we increase the chance of a conflict in case some guest uses that port.
Quoted 38 lines
Quoted 33 lines
Quoted 33 lines
However it works fine if containing device is PNP0C02 "Motherboard registers", so we probably should use it instead.
Quoted 21 lines
Quoted 20 lines
hw/i386/ssdt-misc.dsl +15
-0+ + Method(_CRS, 0) { + Store(ResourceTemplate() { + IO(Decode16, 0x00, 0x00, 0x01, 0x15, IO) + }, Local0) + + CreateWordField(Local0, IO._MIN, IOMN) + CreateWordField(Local0, IO._MAX, IOMX) + + Store(CPHP, IOMN) + Subtract(Add(CPHP, CPPL), 1, IOMX) + Return(Local0) + } + } // Device(CPHD) + } // Scope(\_SB) }Signature · 1 line
1.8.3.1Signature · 2 lines
Regards, IgorSignature · 2 lines
Regards, Igor
Signature · 2 lines
Regards, Igor
Re: [Qemu-devel] [PATCH 09/11] ACPI: move PRST OperationRegion into SSDT
Quoted 204 lines · Igor Mammedov
Quoted 201 lines · On Mon, 23 Dec 2013 16:48:49 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 182 lines · Igor Mammedov
Quoted 175 lines · On Mon, 23 Dec 2013 13:26:37 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 163 lines · Igor Mammedov
Quoted 159 lines · On Mon, 16 Dec 2013 21:53:07 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 143 lines · Igor Mammedov
.. and report range used by it to OSPM via
_CRS. PRST is needed in SSDT since its base will depend on chipset and will be dynamically set by QEMU. Also movePRSC()method along with PRST since cross table reference to PRST doesn't work.Signed-off-by Igor Mammedov <[email protected]>--- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 39 +---------------------- hw/i386/acpi-dsdt.dsl | 2 +- hw/i386/q35-acpi-dsdt.dsl | 2 +- hw/i386/ssdt-misc.dsl | 65 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 40 deletions(-)hw/i386/acpi-dsdt-cpu-hotplug.dsl +1
-38@@ -20,6 +20,7 @@ Scope(\_SB) { /* Objects filled in by run-time generated SSDT */ External(NTFY, MethodObj) + External(\_SB.CPHD.PRSC, MethodObj) External(CPON, PkgObj) /* Methods called by run-time generated SSDT Processor objects */@@ -51,42 +52,4 @@ Scope(\_SB) { // _EJ0 method - eject callback Sleep(200) } - - OperationRegion(PRST, SystemIO, 0xaf00, 32) - Field(PRST, ByteAcc, NoLock, Preserve) { - PRS, 256 - } - Method(PRSC, 0) { - // Local5 = active cpu bitmap - Store(PRS, Local5) - // Local2 = last read byte from bitmap - Store(Zero, Local2) - // Local0 = Processor ID / APIC ID iterator - Store(Zero, Local0) - While (LLess(Local0, SizeOf(CPON))) { - // Local1 = CPON flag for this cpu - Store(DerefOf(Index(CPON, Local0)), Local1) - If (And(Local0, 0x07)) { - // Shift down previously read bitmap byte - ShiftRight(Local2, 1, Local2) - } Else { - // Read next byte from cpu bitmap - Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) - } - // Local3 = active state for this cpu - Store(And(Local2, 1), Local3) - - If (LNotEqual(Local1, Local3)) { - // State change - update CPON with new state - Store(Local3, Index(CPON, Local0)) - // Do CPU notify - If (LEqual(Local3, 1)) { - NTFY(Local0, 1) - } Else { - NTFY(Local0, 3) - } - } - Increment(Local0) - } - } }hw/i386/acpi-dsdt.dsl +1
-1@@ -311,7 +311,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPHD.PRSC() } Method(_L03) { }hw/i386/q35-acpi-dsdt.dsl +1
-1@@ -420,7 +420,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPHD.PRSC() } Method(_L03) { }hw/i386/ssdt-misc.dsl +40
-0@@ -116,4 +116,69 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) } } } + Scope(\_SB) { + External(NTFY, MethodObj) + External(CPON, PkgObj) + + Device(CPHD) { + Name(_HID, EISAID("PNP0C08")) + Name(CPPL, 32) // cpu-gpe length + Name(CPHP, 0xaf00) + + OperationRegion(PRST, SystemIO, CPHP, CPPL) + Field(PRST, ByteAcc, NoLock, Preserve) { + PRS, 256 + } + + Method(PRSC, 0) { + // Local5 = active cpu bitmap + Store(PRS, Local5) + // Local2 = last read byte from bitmap + Store(Zero, Local2) + // Local0 = Processor ID / APIC ID iterator + Store(Zero, Local0) + While (LLess(Local0, SizeOf(CPON))) { + // Local1 = CPON flag for this cpu + Store(DerefOf(Index(CPON, Local0)), Local1) + If (And(Local0, 0x07)) { + // Shift down previously read bitmap byte + ShiftRight(Local2, 1, Local2) + } Else { + // Read next byte from cpu bitmap + Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) + } + // Local3 = active state for this cpu + Store(And(Local2, 1), Local3) + + If (LNotEqual(Local1, Local3)) { + // State change - update CPON with new state + Store(Local3, Index(CPON, Local0)) + // Do CPU notify + If (LEqual(Local3, 1)) { + NTFY(Local0, 1)hw/i386/ssdt-misc.dsl DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) · line 168
Quoted 10 lines
hw/i386/ssdt-misc.dsl +10
-0+ } Else { + NTFY(Local0, 3) + } + } + Increment(Local0) + } + } + + /* Leave bit 0 cleared to avoid Windows BSOD */ + Name(_STA, 0xA)This shared the problem you yourself pointed out with patch 'pc: ACPI BIOS: implement memory hotplug':
if we make device non present ospm can ignore our_CRS.Quoted 1 line
Can't we get a better handle on why windows crashes?
Quoted 9 lines
Whenever
_CRSwith PRST IO range is exposed as part of PNP0A05/PNP0A06 or ACPI0004 device, it BSODs withINACCESSIBLE_BOOT_DEVICEwith following stack:
: nt!PnpBootDeviceWait+0x181
: nt!IopInitializeBootDrivers+0xbd3
: nt!IoInitSystem+0xbb6
: nt!Phase1InitializationDiscard+0x16f6
: nt!Phase1Initialization+0x13
: nt!PspSystemThreadStartup+0x23d
: nt!KiStartSystemThread+0x16Quoted 4 lines
Interesting. This seems to imply that it can't access IO port for the disk. Which boot disk type are you using? Is the
_CRSresource overlapping any other resource by any chance?Quoted 6 lines
Yes, I've dug in the issue more and it is indeed
_CRSoverlapping with PCI bus. PCI bus's IO ports are statically defined in acpi-dsdt-pci-crs.dsl and basically take all io ports except of 0xcf8-0xcff hole.
SincePIIX4_PMand ICH9 LPC are PCI devices, it appears that PRST already covered by bus CRS, the same applies to PCI hotplug as well.
So I was doing it wrong trying advertise bus resources out of bus scope.Yes, that's explicitly prohibited by the firmware specification.
Quoted 8 lines
What we need is to add PIIX4_PM/ICH9 LPC device definition with consumed IO ports CRS to PCI bus. Question is what PNP IDs they should use?
It looks pretty much out of scope of
cpu_hotplugand should be done for pci hotplug as well. So I'm ditching ACPI device and CRS parts from this series as not directly related.
Adding PIIX4_PM/ICH9 LPC ACPI device could be done later and preferably for all resources consumed by it to make it right.
Quoted 8 lines
Quoted 1 line
Could be ok but are we using any new ports?
yes, for q35. series adds 0xa18-0xa37 IO ports, it was requested by Gerd not to use 0xaf00-0xaf1f.
Quoted 2 lines
If yes then I think before doing that we should make sure
_CRSfor the host bridge does not include them, or consume themI'm fine with making holes in PCI bus CRES template, I can do it for pci-hotplug as well while at it.
Cool. We might need to make this conditional on using a new machine type.
Quoted 3 lines
Quoted 1 line
in some child device.
that would be cleanest, but is there any suggestion what device(s) it would be for piix and ich9-lpc, i.e. which PNP IDs should we use?
AFAIK if they are pci devices they don't need PNP IDs, they are matched by PCI bus address.
Quoted 47 lines
Quoted 42 lines
Otherwise we increase the chance of a conflict in case some guest uses that port.
Quoted 38 lines
Quoted 33 lines
Quoted 33 lines
However it works fine if containing device is PNP0C02 "Motherboard registers", so we probably should use it instead.
Quoted 21 lines
Quoted 20 lines
hw/i386/ssdt-misc.dsl +15
-0+ + Method(_CRS, 0) { + Store(ResourceTemplate() { + IO(Decode16, 0x00, 0x00, 0x01, 0x15, IO) + }, Local0) + + CreateWordField(Local0, IO._MIN, IOMN) + CreateWordField(Local0, IO._MAX, IOMX) + + Store(CPHP, IOMN) + Subtract(Add(CPHP, CPPL), 1, IOMX) + Return(Local0) + } + } // Device(CPHD) + } // Scope(\_SB) }Signature · 1 line
1.8.3.1Signature · 2 lines
Regards, IgorSignature · 2 lines
Regards, IgorSignature · 2 lines
Regards, Igor
Re: [Qemu-devel] [PATCH 09/11] ACPI: move PRST OperationRegion into SSDT
In reply to Igor MammedovQuoted 29 lines · Igor Mammedov
Quoted 26 lines · On Mon, 23 Dec 2013 16:48:49 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 7 lines · Igor Mammedov
Quoted 4 lines · On Mon, 23 Dec 2013 13:26:37 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Interesting. This seems to imply that it can't access IO port for the disk. Which boot disk type are you using? Is the
_CRSresource overlapping any other resource by any chance?Quoted 6 lines
Yes, I've dug in the issue more and it is indeed
_CRSoverlapping with PCI bus. PCI bus's IO ports are statically defined in acpi-dsdt-pci-crs.dsl and basically take all io ports except of 0xcf8-0xcff hole.
SincePIIX4_PMand ICH9 LPC are PCI devices, it appears that PRST already covered by bus CRS, the same applies to PCI hotplug as well.
So I was doing it wrong trying advertise bus resources out of bus scope.Yes, that's explicitly prohibited by the firmware specification.
Quoted 8 lines
What we need is to add PIIX4_PM/ICH9 LPC device definition with consumed IO ports CRS to PCI bus. Question is what PNP IDs they should use?
It looks pretty much out of scope of
cpu_hotplugand should be done for pci hotplug as well. So I'm ditching ACPI device and CRS parts from this series as not directly related.
Adding PIIX4_PM/ICH9 LPC ACPI device could be done later and preferably for all resources consumed by it to make it right.
Quoted 8 lines
Quoted 1 line
Could be ok but are we using any new ports?
yes, for q35. series adds 0xa18-0xa37 IO ports, it was requested by Gerd not to use 0xaf00-0xaf1f.
Quoted 2 lines
If yes then I think before doing that we should make sure
_CRSfor the host bridge does not include them, or consume themI'm fine with making holes in PCI bus CRES template, I can do it for pci-hotplug as well while at it.
Can you guys please summarize the problem? (Just so I can understand.)
\_SB.PCI0 consumes 0x0CF8..0x0CFF, and is a resource producer for all other IO ports (ie. it passes them on to child devices). Did we try to consume such a passed-on port in a device that is *not* a child of \_SB.PCI0?
And if so, what's the suggested solution? Make the new consumer a child of \_SB.PCI0, or punch out the new (non-child) consumer's port range from \_SB.PCI0's forwarding?
Quoted 3 lines
Quoted 1 line
in some child device.
that would be cleanest, but is there any suggestion what device(s) it would be for piix and ich9-lpc, i.e. which PNP IDs should we use?
You could browse
<http://www.plasma-online.de/english/identify/serial/pnp_id_pnp.html>.
One suggestion could be:
PNP0C02 -- General ID for reserving resources required by PnP motherboard registers. (Not device specific.)
(AFAICS this PNP ID has been mentioned earlier in the thread.)
PNP0C08 -- ACPI system board hardware
(Also used already, apparently.)
Laszlo
Re: [Qemu-devel] [PATCH 09/11] ACPI: move PRST OperationRegion into SSDT
Quoted 39 lines · On Mon, 23 Dec 2013 17:52:03 +0100 Laszlo Ersek <[email protected]> wrote:
Quoted 29 lines · Igor Mammedov
Quoted 26 lines · On Mon, 23 Dec 2013 16:48:49 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 7 lines · Igor Mammedov
Quoted 4 lines · On Mon, 23 Dec 2013 13:26:37 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Interesting. This seems to imply that it can't access IO port for the disk. Which boot disk type are you using? Is the
_CRSresource overlapping any other resource by any chance?Quoted 6 lines
Yes, I've dug in the issue more and it is indeed
_CRSoverlapping with PCI bus. PCI bus's IO ports are statically defined in acpi-dsdt-pci-crs.dsl and basically take all io ports except of 0xcf8-0xcff hole.
SincePIIX4_PMand ICH9 LPC are PCI devices, it appears that PRST already covered by bus CRS, the same applies to PCI hotplug as well.
So I was doing it wrong trying advertise bus resources out of bus scope.Yes, that's explicitly prohibited by the firmware specification.
Quoted 8 lines
What we need is to add PIIX4_PM/ICH9 LPC device definition with consumed IO ports CRS to PCI bus. Question is what PNP IDs they should use?
It looks pretty much out of scope of
cpu_hotplugand should be done for pci hotplug as well. So I'm ditching ACPI device and CRS parts from this series as not directly related.
Adding PIIX4_PM/ICH9 LPC ACPI device could be done later and preferably for all resources consumed by it to make it right.Quoted 8 lines
Quoted 1 line
Could be ok but are we using any new ports?
yes, for q35. series adds 0xa18-0xa37 IO ports, it was requested by Gerd not to use 0xaf00-0xaf1f.
Quoted 2 lines
If yes then I think before doing that we should make sure
_CRSfor the host bridge does not include them, or consume themI'm fine with making holes in PCI bus CRES template, I can do it for pci-hotplug as well while at it.
Quoted 6 lines
Can you guys please summarize the problem? (Just so I can understand.)
\_SB.PCI0 consumes 0x0CF8..0x0CFF, and is a resource producer for all other IO ports (ie. it passes them on to child devices). Did we try to consume such a passed-on port in a device that is *not* a child of \_SB.PCI0?
yep, and that was an error.
Quoted 4 lines
And if so, what's the suggested solution? Make the new consumer a child of \_SB.PCI0, or punch out the new (non-child) consumer's port range from \_SB.PCI0's forwarding?
I've tried to add bridge that uses hotplug ports as Device under PCI bus with respective _CRS so it would consume ports, unfortunately for PIIX bridge isn't visible under Windows and any other ways to confirm that _CRS was consumed failed. The same for linux. For Q35, Windows' device manager shows LPC bridge however there is no "Resources" tab with consumed ports. Due to lack of ways to confirm that _CRS was really consumed, I've switched to punching holes, and exposing hotplug IO region as \_SB.Device(ACPI0004)._CRS. It works rather stable with new and old versions Windows.
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
in some child device.
that would be cleanest, but is there any suggestion what device(s) it would be for piix and ich9-lpc, i.e. which PNP IDs should we use?
Quoted 7 lines
You could browse
<http://www.plasma-online.de/english/identify/serial/pnp_id_pnp.html>.One suggestion could be:
PNP0C02 -- General ID for reserving resources required by PnP motherboard registers. (Not device specific.)
I've chosen ACPI0004 instead, as the later we might wish to group CPU devices under it (when extending support for 1024 and more CPUs)
Quoted 4 lines
(AFAICS this PNP ID has been mentioned earlier in the thread.)
PNP0C08 -- ACPI system board hardware
it doesn't work.
Quoted 4 lines
(Also used already, apparently.)
Laszlo
Signature · 2 lines
Regards, Igor