dimm: implement dimm device abstraction

Each hotplug-able memory slot is a DimmDevice. All DimmDevices are
attached to a new bus called DimmBus.

A hot-add operation for a DIMM:
- creates a new DimmDevice and attaches it to the DimmBus

Hotplug operations are done through normal device_add commands.
For migration case, all hotplugged DIMMs on source should be specified
on target's command line using '-device' option with properties set to
the same values as on target.

To simplify review, patch introduces only DimmDevice and DimmBus basic
QOM skeleton that will be extended by following patches to implement
actual memory hotplug and related functions.

Signed-off-by: Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v3:
  pc: compile memhotplug on i386 target too
v2:
  fix typo s/DimmBus/DimmDevice/ in doc comment
  s/klass/oc/;s/*/parent_obj/;a/gtk-doc markup/

dimm impl
dimm: map DimmDevice into DimBus provided address space

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
dimm: add busy slot check and slot auto-allocation

- if slot property is not specified on -device/device_add command,
treat default value as request for assigning DimmDevice to
the first free slot.

- if slot is provided with -device/device_add command, attempt to
use it or fail command if it's already occupied.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v2:
  s/dc/dbc/
dimm: add busy address check and address auto-allocation

- if 'start' property is not specified on -device/device_add command,
treat default value as request for assigning DimmDevice to
the first free memory region.

- if 'start' is provided with -device/device_add command, attempt to
use it or fail command if it's already occupied or falls inside
of an existing DimmDevice memory region.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v2:
  * s/dc/dbc/
  * if DimmBus is not initialized, report error "memory add is disabled"
dimm: add hotplug callback to DimmBus

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
acpi: factor out common pm_update_sci() into acpi core

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
acpi: memory hotplug ACPI hardware implementation

- implements QEMU hardware part of memory hotplug protocol
  described at "docs/specs/acpi_mem_hotplug.txt"
- handles only memory add notification event for now

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
acpi: initialize memory hotplug ACPI PIIX4 hardware

to be used by i440fx machine for handling hardware ACPI part of
memory hotplug interface with guest.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
acpi: piix4: add memory-hotplug-io-base property to piix4_pm

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
acpi: ich9: allow guest to clear SCI rised by GPE

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 <imammedo@redhat.com>
acpi: initialize memory hotplug ACPI ICH9 hardware

to be used by Q35 machine for handling hardware ACPI part of
memory hotplug interface with guest.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
acpi: ich9: add memory-hotplug-io-base property to ich9_pm

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
pc: piix: make PCII440FXState type public

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
pc: add memory hotplug 440fx machine

Add DimmBus for memory hotplug below 4Gb or above 4Gb depending
on initial memory size and hotplug memory size.

* if ram_size is less tha 32-bit PCI hole start, reserve
  hotplug memory region as [ram_size,32bit-PCIhole-start)
  if hotplug memory size fits there,
  otherwise reserve hotplug memory region after "0x100000000ULL
  + above_4g_mem_size"

* setup memory hotplug callback to pass event to ACPI hadware.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
pc: add memory hotplug Q35 machine

Add DimmBus to q35 machine, initialize memory hotplug window and plumb
ACPI callback (ich9_pm) for communicating hotplug event to guest.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
pc: ACPI BIOS: implement memory hotplug interface

- provides static DSDT object for memory hotplug
- SSDT template for memory devices and runtime generator
  of them in SSDT table.

Signed-off-by: Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>

use memory-hotplug-io-base to build ACPI tables

Signed-off-by: Igor Mammedov <imammedo@redhat.com>

ACPI BIOS: return 32 bit CRS for memory devices below 4G

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
pc: ACPI BIOS: add ssdt-mem.hex.generated and update ssdt-misc.hex.generated

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
pc: ACPI BIOS: use enum for defining memory affinity flags

replace magic numbers with enum describing Flags field of
memory affinity in SRAT table.

MemoryAffinityFlags enum will define flags decribed by:
 ACPI spec 5.0, "5.2.16.2 Memory Affinity Structure",
 "Table 5-69 Flags - Memory Affinity Structure"

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
pc: ACPI BIOS: reserve SRAT entry for hotplug mem hole

Needed for Windows to use hotplugged memory device, otherwise
it complains that server is not configured for memory hotplug.
Tests shows that aftewards it uses dynamically provided
proximity value from _PXM() method if available.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
pc: ACPI BIOS: make GPE.3 handle memory hotplug event on PIIX and Q35 machines

Signed-off-by: Igor Mammedov <imammedo@redhat.com>