Skip to contentSkip to conversation

acpi,pc,pci,virtio,memory bug fixes

GIT PULL Michael S. Tsirkin 4 participants 20 messages Feb 17, 2014 – Feb 20, 2014

lore
Share & tools
lore
#0 lore raw

The following changes since commit 417c45ab2f847c0a47b1232f611aa886df6a97d5:

ACPI: Remove commented-out code from HPET._CRS (2014-02-10 11:09:33 +0200)

are available in the git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to 0217598857eaf0ceae137cdd71445118af2284cf:

PCIE: fix regression with coldplugged multifunction device (2014-02-17 16:17:31 +0200)

----------------------------------------------------------------
acpi,pc,pci,virtio,memory bug fixes

This collects several small fixes from all over the place.

----------------------------------------------------------------
Igor Mammedov (2):
memory_region_present: return false if address is not found in child MemoryRegion
PCIE: fix regression with coldplugged multifunction device

Joel Stanley (1):
virtio-net: remove function calls from assert

Michael S. Tsirkin (2):
acpi-build: append description for non-hotplug
acpi-test-data: update expected files

 include/exec/memory.h         |   6 +-
 hw/i386/acpi-build.c          | 140 ++++++++++++++++++++++++++++++++++--------
 hw/net/virtio-net.c           |   7 ++-
 hw/pci/pcie.c                 |  16 ++---
 memory.c                      |   2 +-
 tests/acpi-test.c             |   2 +-
 hw/i386/acpi-dsdt.dsl         |  41 +++----------
 hw/i386/q35-acpi-dsdt.dsl     |  29 ++-------
 hw/i386/ssdt-pcihp.dsl        |  56 +++++++++++++++++
 tests/acpi-test-data/pc/DSDT  | Bin 4582 -> 4461 bytes
 tests/acpi-test-data/pc/SSDT  | Bin 2200 -> 2299 bytes
 tests/acpi-test-data/q35/DSDT | Bin 7438 -> 7370 bytes
 tests/acpi-test-data/q35/SSDT | Bin 475 -> 588 bytes
 13 files changed, 201 insertions(+), 98 deletions(-)
#1 lore raw

[Qemu-devel] [PULL 1/5] acpi-build: append description for non-hotplug

As reported in
http://article.gmane.org/gmane.comp.emulators.qemu/253987
Mac OSX actually requires describing all occupied slots in ACPI - even if hotplug isn't enabled.

I didn't expect this so I dropped description of all
non hotpluggable slots from ACPI.
As a result: before
commit 99fd437dee468609de8218f0eb3b16621fb6a9c9 (enable hotplug for pci bridges), PCI cards show up in the "device tree" of OS X (System Information). E.g., on MountainLion users have:

Hardware -> PCI Cards:

  Card          Type                 Driver Installed  Slot
 *ethernet      Ethernet Controller  Yes               PCI Slot 2
  pci8086,2934  USB UHC              Yes               PCI Slot 29

ethernet:

    Type:                 Ethernet Controller
    Driver Installed:     Yes
    MSI:                  No
    Bus:                  PCI
    Slot                  PCI Slot 2
    Vendor ID:            0x8086
    Device ID:            0x100e
    Subsystem Vendor ID:  0x1af4
    Subsystem ID:         0x1100
    Revision ID:          0x0003

Hardware -> Ethernet Cards

ethernet:

    Type:                 Ethernet Controller
    Bus:                  PCI
    Slot                  PCI Slot 2
    Vendor ID:            0x8086
    Device ID:            0x100e
    Subsystem Vendor ID:  0x1af4
    Subsystem ID:         0x1100
    Revision ID:          0x0003
    BSD name:             en0
    Kext name:            AppleIntel8254XEthernet.kext
    Location:             /System/Library/Extensions/...
    Version:              3.1.1b1

After commit 99fd437dee468609de8218f0eb3b16621fb6a9c9, users get:

Hardware -> PCI Cards:

This computer doesn't contain any PCI cards. If you installed PCI cards, make sure they're properly installed.

Hardware -> Ethernet Cards

ethernet:

    Type:                 Ethernet Controller
    Bus:                  PCI
    Vendor ID:            0x8086
    Device ID:            0x100e
    Subsystem Vendor ID:  0x1af4
    Subsystem ID:         0x1100
    Revision ID:          0x0003
    BSD name:             en0
    Kext name:            AppleIntel8254XEthernet.kext
    Location:             /System/Library/Extensions/...
    Version:              3.1.1b1

Ethernet still works, but it's not showing up on the PCI bus, and it no longer thinks it's plugged in to slot #2, as it used to before the change.

To fix, append description for all occupied non hotpluggable PCI slots.

One need to be careful when doing this: VGA and ISA device were already described, so we need to drop description from DSDT.

---
 hw/i386/acpi-build.c      | 140 ++++++++++++++++++++++++++++++++++++++--------
 tests/acpi-test.c         |   2 +-
 hw/i386/acpi-dsdt.dsl     |  41 +++-----------
 hw/i386/q35-acpi-dsdt.dsl |  29 ++--------
 hw/i386/ssdt-pcihp.dsl    |  56 +++++++++++++++++++
 5 files changed, 184 insertions(+), 84 deletions(-)
hw/i386/acpi-build.c +116 -24
index b1a7ebb..5b0bb5a 100644
@@ -643,6 +643,24 @@ static inline char acpi_get_hex(uint32_t val)
 #define ACPI_PCIHP_SIZEOF (*ssdt_pcihp_end - *ssdt_pcihp_start)
 #define ACPI_PCIHP_AML (ssdp_pcihp_aml + *ssdt_pcihp_start)
 
+#define ACPI_PCINOHP_OFFSET_HEX (*ssdt_pcinohp_name - *ssdt_pcinohp_start + 1)
+#define ACPI_PCINOHP_OFFSET_ID (*ssdt_pcinohp_id - *ssdt_pcinohp_start)
+#define ACPI_PCINOHP_OFFSET_ADR (*ssdt_pcinohp_adr - *ssdt_pcinohp_start)
+#define ACPI_PCINOHP_SIZEOF (*ssdt_pcinohp_end - *ssdt_pcinohp_start)
+#define ACPI_PCINOHP_AML (ssdp_pcihp_aml + *ssdt_pcinohp_start)
+
+#define ACPI_PCIVGA_OFFSET_HEX (*ssdt_pcivga_name - *ssdt_pcivga_start + 1)
+#define ACPI_PCIVGA_OFFSET_ID (*ssdt_pcivga_id - *ssdt_pcivga_start)
+#define ACPI_PCIVGA_OFFSET_ADR (*ssdt_pcivga_adr - *ssdt_pcivga_start)
+#define ACPI_PCIVGA_SIZEOF (*ssdt_pcivga_end - *ssdt_pcivga_start)
+#define ACPI_PCIVGA_AML (ssdp_pcihp_aml + *ssdt_pcivga_start)
+
+#define ACPI_PCIQXL_OFFSET_HEX (*ssdt_pciqxl_name - *ssdt_pciqxl_start + 1)
+#define ACPI_PCIQXL_OFFSET_ID (*ssdt_pciqxl_id - *ssdt_pciqxl_start)
+#define ACPI_PCIQXL_OFFSET_ADR (*ssdt_pciqxl_adr - *ssdt_pciqxl_start)
+#define ACPI_PCIQXL_SIZEOF (*ssdt_pciqxl_end - *ssdt_pciqxl_start)
+#define ACPI_PCIQXL_AML (ssdp_pcihp_aml + *ssdt_pciqxl_start)
+
 #define ACPI_SSDT_SIGNATURE 0x54445353 /* SSDT */
 #define ACPI_SSDT_HEADER_LENGTH 36
 
@@ -677,6 +695,36 @@ static void patch_pcihp(int slot, uint8_t *ssdt_ptr)
     ssdt_ptr[ACPI_PCIHP_OFFSET_ADR + 2] = slot;
 }
 
+static void patch_pcinohp(int slot, uint8_t *ssdt_ptr)
+{
+    unsigned devfn = PCI_DEVFN(slot, 0);
+
+    ssdt_ptr[ACPI_PCINOHP_OFFSET_HEX] = acpi_get_hex(devfn >> 4);
+    ssdt_ptr[ACPI_PCINOHP_OFFSET_HEX + 1] = acpi_get_hex(devfn);
+    ssdt_ptr[ACPI_PCINOHP_OFFSET_ID] = slot;
+    ssdt_ptr[ACPI_PCINOHP_OFFSET_ADR + 2] = slot;
+}
+
+static void patch_pcivga(int slot, uint8_t *ssdt_ptr)
+{
+    unsigned devfn = PCI_DEVFN(slot, 0);
+
+    ssdt_ptr[ACPI_PCIVGA_OFFSET_HEX] = acpi_get_hex(devfn >> 4);
+    ssdt_ptr[ACPI_PCIVGA_OFFSET_HEX + 1] = acpi_get_hex(devfn);
+    ssdt_ptr[ACPI_PCIVGA_OFFSET_ID] = slot;
+    ssdt_ptr[ACPI_PCIVGA_OFFSET_ADR + 2] = slot;
+}
+
+static void patch_pciqxl(int slot, uint8_t *ssdt_ptr)
+{
+    unsigned devfn = PCI_DEVFN(slot, 0);
+
+    ssdt_ptr[ACPI_PCIQXL_OFFSET_HEX] = acpi_get_hex(devfn >> 4);
+    ssdt_ptr[ACPI_PCIQXL_OFFSET_HEX + 1] = acpi_get_hex(devfn);
+    ssdt_ptr[ACPI_PCIQXL_OFFSET_ID] = slot;
+    ssdt_ptr[ACPI_PCIQXL_OFFSET_ADR + 2] = slot;
+}
+
 /* Assign BSEL property to all buses.  In the future, this can be changed
  * to only assign to buses that support hotplug.
  */
@@ -737,6 +785,9 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state)
     AcpiBuildPciBusHotplugState *parent = child->parent;
     GArray *bus_table = build_alloc_array();
     DECLARE_BITMAP(slot_hotplug_enable, PCI_SLOT_MAX);
+    DECLARE_BITMAP(slot_device_present, PCI_SLOT_MAX);
+    DECLARE_BITMAP(slot_device_vga, PCI_SLOT_MAX);
+    DECLARE_BITMAP(slot_device_qxl, PCI_SLOT_MAX);
     uint8_t op;
     int i;
     QObject *bsel;
@@ -764,40 +815,74 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state)
         build_append_byte(bus_table, 0x08); /* NameOp */
         build_append_nameseg(bus_table, "BSEL");
         build_append_int(bus_table, qint_get_int(qobject_to_qint(bsel)));
-
         memset(slot_hotplug_enable, 0xff, sizeof slot_hotplug_enable);
+    } else {
+        /* No bsel - no slots are hot-pluggable */
+        memset(slot_hotplug_enable, 0x00, sizeof slot_hotplug_enable);
+    }
 
-        for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
-            DeviceClass *dc;
-            PCIDeviceClass *pc;
-            PCIDevice *pdev = bus->devices[i];
+    memset(slot_device_present, 0x00, sizeof slot_device_present);
+    memset(slot_device_vga, 0x00, sizeof slot_device_vga);
+    memset(slot_device_qxl, 0x00, sizeof slot_device_qxl);
 
-            if (!pdev) {
-                continue;
-            }
+    for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
+        DeviceClass *dc;
+        PCIDeviceClass *pc;
+        PCIDevice *pdev = bus->devices[i];
+        int slot = PCI_SLOT(i);
 
-            pc = PCI_DEVICE_GET_CLASS(pdev);
-            dc = DEVICE_GET_CLASS(pdev);
+        if (!pdev) {
+            continue;
+        }
 
-            if (!dc->hotpluggable || pc->is_bridge) {
-                int slot = PCI_SLOT(i);
+        set_bit(slot, slot_device_present);
+        pc = PCI_DEVICE_GET_CLASS(pdev);
+        dc = DEVICE_GET_CLASS(pdev);
 
-                clear_bit(slot, slot_hotplug_enable);
+        if (pc->class_id == PCI_CLASS_DISPLAY_VGA) {
+            set_bit(slot, slot_device_vga);
+
+            if (object_dynamic_cast(OBJECT(pdev), "qxl-vga")) {
+                set_bit(slot, slot_device_qxl);
             }
         }
 
-        /* Append Device object for each slot which supports eject */
-        for (i = 0; i < PCI_SLOT_MAX; i++) {
-            bool can_eject = test_bit(i, slot_hotplug_enable);
-            if (can_eject) {
-                void *pcihp = acpi_data_push(bus_table,
-                                             ACPI_PCIHP_SIZEOF);
-                memcpy(pcihp, ACPI_PCIHP_AML, ACPI_PCIHP_SIZEOF);
-                patch_pcihp(i, pcihp);
-                bus_hotplug_support = true;
-            }
+        if (!dc->hotpluggable || pc->is_bridge) {
+            clear_bit(slot, slot_hotplug_enable);
+        }
+    }
+
+    /* Append Device object for each slot which supports eject */
+    for (i = 0; i < PCI_SLOT_MAX; i++) {
+        bool can_eject = test_bit(i, slot_hotplug_enable);
+        bool present = test_bit(i, slot_device_present);
+        bool vga = test_bit(i, slot_device_vga);
+        bool qxl = test_bit(i, slot_device_qxl);
+        if (can_eject) {
+            void *pcihp = acpi_data_push(bus_table,
+                                         ACPI_PCIHP_SIZEOF);
+            memcpy(pcihp, ACPI_PCIHP_AML, ACPI_PCIHP_SIZEOF);
+            patch_pcihp(i, pcihp);
+            bus_hotplug_support = true;
+        } else if (qxl) {
+            void *pcihp = acpi_data_push(bus_table,
+                                         ACPI_PCIQXL_SIZEOF);
+            memcpy(pcihp, ACPI_PCIQXL_AML, ACPI_PCIQXL_SIZEOF);
+            patch_pciqxl(i, pcihp);
+        } else if (vga) {
+            void *pcihp = acpi_data_push(bus_table,
+                                         ACPI_PCIVGA_SIZEOF);
+            memcpy(pcihp, ACPI_PCIVGA_AML, ACPI_PCIVGA_SIZEOF);
+            patch_pcivga(i, pcihp);
+        } else if (present) {
+            void *pcihp = acpi_data_push(bus_table,
+                                         ACPI_PCINOHP_SIZEOF);
+            memcpy(pcihp, ACPI_PCINOHP_AML, ACPI_PCINOHP_SIZEOF);
+            patch_pcinohp(i, pcihp);
         }
+    }
 
+    if (bsel) {
         method = build_alloc_method("DVNT", 2);
 
         for (i = 0; i < PCI_SLOT_MAX; i++) {
@@ -976,7 +1061,14 @@ build_ssdt(GArray *table_data, GArray *linker,
 
         {
             AcpiBuildPciBusHotplugState hotplug_state;
-            PCIBus *bus = find_i440fx(); /* TODO: Q35 support */
+            Object *pci_host;
+            PCIBus *bus = NULL;
+            bool ambiguous;
+
+            pci_host = object_resolve_path_type("", TYPE_PCI_HOST_BRIDGE, &ambiguous);
+            if (!ambiguous && pci_host) {
+                bus = PCI_HOST_BRIDGE(pci_host)->bus;
+            }
 
             build_pci_bus_state_init(&hotplug_state, NULL);
 
tests/acpi-test.c +1 -1
index 31f5359..613dda8 100644
@@ -153,7 +153,7 @@ static void free_test_data(test_data *data)
             g_free(temp->aml);
         }
         if (temp->aml_file) {
-            if (g_strstr_len(temp->aml_file, -1, "aml-")) {
+            if (!temp->asl_file_retain && g_strstr_len(temp->aml_file, -1, "aml-")) {
                 unlink(temp->aml_file);
             }
             g_free(temp->aml_file);
hw/i386/acpi-dsdt.dsl +7 -34

64 lines not on this page · raw message

hw/i386/q35-acpi-dsdt.dsl +4 -25
index d618e9e..8e522a5 100644
@@ -72,6 +72,9 @@ DefinitionBlock (
             Name(_ADR, 0x00)
             Name(_UID, 1)
 
+#define ISA SF8_
+            External(ISA, DeviceObj)
+
             // _OSC: based on sample of ACPI3.0b spec
             Name(SUPP, 0) // PCI _OSC Support Field value
             Name(CTRL, 0) // PCI _OSC Control Field value
@@ -134,34 +137,11 @@ DefinitionBlock (
 
 
 /****************************************************************
- * VGA
- ****************************************************************/
-
-    Scope(\_SB.PCI0) {
-        Device(VGA) {
-            Name(_ADR, 0x00010000)
-            Method(_S1D, 0, NotSerialized) {
-                Return (0x00)
-            }
-            Method(_S2D, 0, NotSerialized) {
-                Return (0x00)
-            }
-            Method(_S3D, 0, NotSerialized) {
-                Return (0x00)
-            }
-        }
-    }
-
-
-/****************************************************************
  * LPC ISA bridge
  ****************************************************************/
 
-    Scope(\_SB.PCI0) {
+    Scope(\_SB.PCI0.ISA) {
         /* PCI D31:f0 LPC ISA bridge */
-        Device(ISA) {
-            /* PCI D31:f0 */
-            Name(_ADR, 0x001f0000)
 
             /* ICH9 PCI to ISA irq remapping */
             OperationRegion(PIRQ, PCI_Config, 0x60, 0x0C)
@@ -184,7 +164,6 @@ DefinitionBlock (
                 LPEN,   1,
                 FDEN,   1
             }
-        }
     }
 
 #define DSDT_APPLESMC_STA q35_dsdt_applesmc_sta
hw/i386/ssdt-pcihp.dsl +56 -0

61 lines not on this page · raw message

Signature · 1 line
MST
#2 lore raw

Re: [Qemu-devel] [PULL 1/5] acpi-build: append description for non-hotplug

Michael,

Quoted 20 lines · Michael S. Tsirkin

As reported in
http://article.gmane.org/gmane.comp.emulators.qemu/253987
Mac OSX actually requires describing all occupied slots in ACPI - even if hotplug isn't enabled.

I didn't expect this so I dropped description of all
non hotpluggable slots from ACPI.
As a result: before
commit 99fd437dee468609de8218f0eb3b16621fb6a9c9 (enable hotplug for pci bridges), PCI cards show up in the "device tree" of OS X (System Information). E.g., on MountainLion users have:

...

Ethernet still works, but it's not showing up on the PCI bus, and it no longer thinks it's plugged in to slot #2, as it used to before the change.

To fix, append description for all occupied non hotpluggable PCI slots.

Quoted 7 lines

One need to be careful when doing this: VGA and ISA device were already described, so we need to drop description from DSDT.

---
...

With this latest version of your patch, I crash during OS X boot with
"unable to find driver for this platform:\"ACPI\".\n"@/SourceCache/xnu/xnu-2050.48.12/iokit/Kernel/IOPlatformExpert.cpp:1514"

Your original patch (slightly doctored since it no longer applies cleanly to the current qemu git master) is included below, and still works for me.

Thanks,
--Gabriel

hw/i386/acpi-build.c +61 -25
index b1a7ebb..4cc8a92 100644
@@ -643,6 +643,13 @@ static inline char acpi_get_hex(uint32_t val)
 #define ACPI_PCIHP_SIZEOF (*ssdt_pcihp_end - *ssdt_pcihp_start)
 #define ACPI_PCIHP_AML (ssdp_pcihp_aml + *ssdt_pcihp_start)
 
+#define ACPI_PCINOHP_OFFSET_HEX (*ssdt_pcinohp_name - *ssdt_pcinohp_start + 1)
+#define ACPI_PCINOHP_OFFSET_ID (*ssdt_pcinohp_id - *ssdt_pcinohp_start)
+#define ACPI_PCINOHP_OFFSET_ADR (*ssdt_pcinohp_adr - *ssdt_pcinohp_start)
+#define ACPI_PCINOHP_OFFSET_EJ0 (*ssdt_pcinohp_ej0 - *ssdt_pcinohp_start)
+#define ACPI_PCINOHP_SIZEOF (*ssdt_pcinohp_end - *ssdt_pcinohp_start)
+#define ACPI_PCINOHP_AML (ssdp_pcihp_aml + *ssdt_pcinohp_start)
+
 #define ACPI_SSDT_SIGNATURE 0x54445353 /* SSDT */
 #define ACPI_SSDT_HEADER_LENGTH 36
 
@@ -677,6 +684,16 @@ static void patch_pcihp(int slot, uint8_t *ssdt_ptr)
     ssdt_ptr[ACPI_PCIHP_OFFSET_ADR + 2] = slot;
 }
 
+static void patch_pcinohp(int slot, uint8_t *ssdt_ptr)
+{
+    unsigned devfn = PCI_DEVFN(slot, 0);
+
+    ssdt_ptr[ACPI_PCINOHP_OFFSET_HEX] = acpi_get_hex(devfn >> 4);
+    ssdt_ptr[ACPI_PCINOHP_OFFSET_HEX + 1] = acpi_get_hex(devfn);
+    ssdt_ptr[ACPI_PCINOHP_OFFSET_ID] = slot;
+    ssdt_ptr[ACPI_PCINOHP_OFFSET_ADR + 2] = slot;
+}
+
 /* Assign BSEL property to all buses.  In the future, this can be changed
  * to only assign to buses that support hotplug.
  */
@@ -737,6 +754,7 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state)
     AcpiBuildPciBusHotplugState *parent = child->parent;
     GArray *bus_table = build_alloc_array();
     DECLARE_BITMAP(slot_hotplug_enable, PCI_SLOT_MAX);
+    DECLARE_BITMAP(slot_device_present, PCI_SLOT_MAX);
     uint8_t op;
     int i;
     QObject *bsel;
@@ -764,40 +782,51 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state)
         build_append_byte(bus_table, 0x08); /* NameOp */
         build_append_nameseg(bus_table, "BSEL");
         build_append_int(bus_table, qint_get_int(qobject_to_qint(bsel)));
+    }
 
-        memset(slot_hotplug_enable, 0xff, sizeof slot_hotplug_enable);
+    memset(slot_hotplug_enable, 0xff, sizeof slot_hotplug_enable);
+    memset(slot_device_present, 0x00, sizeof slot_device_present);
 
-        for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
-            DeviceClass *dc;
-            PCIDeviceClass *pc;
-            PCIDevice *pdev = bus->devices[i];
+    for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
+        DeviceClass *dc;
+        PCIDeviceClass *pc;
+        PCIDevice *pdev = bus->devices[i];
+        int slot = PCI_SLOT(i);
 
-            if (!pdev) {
-                continue;
-            }
+        if (!pdev) {
+            continue;
+        }
 
-            pc = PCI_DEVICE_GET_CLASS(pdev);
-            dc = DEVICE_GET_CLASS(pdev);
+        set_bit(slot, slot_device_present);
+        pc = PCI_DEVICE_GET_CLASS(pdev);
+        dc = DEVICE_GET_CLASS(pdev);
 
-            if (!dc->hotpluggable || pc->is_bridge) {
-                int slot = PCI_SLOT(i);
+        if (!dc->hotpluggable || pc->is_bridge) {
+            int slot = PCI_SLOT(i);
 
-                clear_bit(slot, slot_hotplug_enable);
-            }
+            clear_bit(slot, slot_hotplug_enable);
         }
+    }
 
-        /* Append Device object for each slot which supports eject */
-        for (i = 0; i < PCI_SLOT_MAX; i++) {
-            bool can_eject = test_bit(i, slot_hotplug_enable);
-            if (can_eject) {
-                void *pcihp = acpi_data_push(bus_table,
-                                             ACPI_PCIHP_SIZEOF);
-                memcpy(pcihp, ACPI_PCIHP_AML, ACPI_PCIHP_SIZEOF);
-                patch_pcihp(i, pcihp);
-                bus_hotplug_support = true;
-            }
+    /* Append Device object for each slot which supports eject */
+    for (i = 0; i < PCI_SLOT_MAX; i++) {
+        bool can_eject = test_bit(i, slot_hotplug_enable);
+        bool present = test_bit(i, slot_device_present);
+        if (can_eject) {
+            void *pcihp = acpi_data_push(bus_table,
+                                         ACPI_PCIHP_SIZEOF);
+            memcpy(pcihp, ACPI_PCIHP_AML, ACPI_PCIHP_SIZEOF);
+            patch_pcihp(i, pcihp);
+            bus_hotplug_support = true;
+        } else if (present) {
+            void *pcihp = acpi_data_push(bus_table,
+                                         ACPI_PCIHP_SIZEOF);
+            memcpy(pcihp, ACPI_PCINOHP_AML, ACPI_PCINOHP_SIZEOF);
+            patch_pcinohp(i, pcihp);
         }
+    }
 
+    if (bsel) {
         method = build_alloc_method("DVNT", 2);
 
         for (i = 0; i < PCI_SLOT_MAX; i++) {
@@ -976,7 +1005,14 @@ build_ssdt(GArray *table_data, GArray *linker,
 
         {
             AcpiBuildPciBusHotplugState hotplug_state;
-            PCIBus *bus = find_i440fx(); /* TODO: Q35 support */
+            Object *pci_host;
+            PCIBus *bus = NULL;
+            bool ambiguous;
+
+            pci_host = object_resolve_path_type("", TYPE_PCI_HOST_BRIDGE, &ambiguous);
+            if (!ambiguous && pci_host) {
+                bus = PCI_HOST_BRIDGE(pci_host)->bus;
+            }
 
             build_pci_bus_state_init(&hotplug_state, NULL);
 
hw/i386/ssdt-pcihp.dsl +12 -0
index cc245c3..ea4b9e1 100644
@@ -46,5 +46,17 @@ DefinitionBlock ("ssdt-pcihp.aml", "SSDT", 0x01, "BXPC", "BXSSDTPCIHP", 0x1)
             }
         }
 
+        ACPI_EXTRACT_DEVICE_START ssdt_pcinohp_start
+        ACPI_EXTRACT_DEVICE_END ssdt_pcinohp_end
+        ACPI_EXTRACT_DEVICE_STRING ssdt_pcinohp_name
+
+        // Extract the offsets of the device name, address dword and the slot
+        // name byte - we fill them in for each device.
+        Device(SBB) {
+            ACPI_EXTRACT_NAME_BYTE_CONST ssdt_pcinohp_id
+            Name(_SUN, 0xAA)
+            ACPI_EXTRACT_NAME_DWORD_CONST ssdt_pcinohp_adr
+            Name(_ADR, 0xAA0000)
+        }
     }
 }
#3 lore raw

Re: [Qemu-devel] [PULL 1/5] acpi-build: append description for non-hotplug

Quoted 31 lines · Gabriel L. Somlo

Michael,

Quoted 20 lines · Michael S. Tsirkin

As reported in
http://article.gmane.org/gmane.comp.emulators.qemu/253987
Mac OSX actually requires describing all occupied slots in ACPI - even if hotplug isn't enabled.

I didn't expect this so I dropped description of all
non hotpluggable slots from ACPI.
As a result: before
commit 99fd437dee468609de8218f0eb3b16621fb6a9c9 (enable hotplug for pci bridges), PCI cards show up in the "device tree" of OS X (System Information). E.g., on MountainLion users have:

...

Ethernet still works, but it's not showing up on the PCI bus, and it no longer thinks it's plugged in to slot #2, as it used to before the change.

To fix, append description for all occupied non hotpluggable PCI slots.

Quoted 7 lines

One need to be careful when doing this: VGA and ISA device were already described, so we need to drop description from DSDT.

---
...

Quoted 8 lines

With this latest version of your patch, I crash during OS X boot with
"unable to find driver for this platform:\"ACPI\".\n"@/SourceCache/xnu/xnu-2050.48.12/iokit/Kernel/IOPlatformExpert.cpp:1514"

Your original patch (slightly doctored since it no longer applies cleanly to the current qemu git master) is included below, and still works for me.

Thanks,
--Gabriel

Thanks for the report!

Peter, if not too late, pls don't pull until we figure it out.

Quoted 158 lines
hw/i386/acpi-build.c +61 -25
index b1a7ebb..4cc8a92 100644
@@ -643,6 +643,13 @@ static inline char acpi_get_hex(uint32_t val)
 #define ACPI_PCIHP_SIZEOF (*ssdt_pcihp_end - *ssdt_pcihp_start)
 #define ACPI_PCIHP_AML (ssdp_pcihp_aml + *ssdt_pcihp_start)
 
+#define ACPI_PCINOHP_OFFSET_HEX (*ssdt_pcinohp_name - *ssdt_pcinohp_start + 1)
+#define ACPI_PCINOHP_OFFSET_ID (*ssdt_pcinohp_id - *ssdt_pcinohp_start)
+#define ACPI_PCINOHP_OFFSET_ADR (*ssdt_pcinohp_adr - *ssdt_pcinohp_start)
+#define ACPI_PCINOHP_OFFSET_EJ0 (*ssdt_pcinohp_ej0 - *ssdt_pcinohp_start)
+#define ACPI_PCINOHP_SIZEOF (*ssdt_pcinohp_end - *ssdt_pcinohp_start)
+#define ACPI_PCINOHP_AML (ssdp_pcihp_aml + *ssdt_pcinohp_start)
+
 #define ACPI_SSDT_SIGNATURE 0x54445353 /* SSDT */
 #define ACPI_SSDT_HEADER_LENGTH 36
 
@@ -677,6 +684,16 @@ static void patch_pcihp(int slot, uint8_t *ssdt_ptr)
     ssdt_ptr[ACPI_PCIHP_OFFSET_ADR + 2] = slot;
 }
 
+static void patch_pcinohp(int slot, uint8_t *ssdt_ptr)
+{
+    unsigned devfn = PCI_DEVFN(slot, 0);
+
+    ssdt_ptr[ACPI_PCINOHP_OFFSET_HEX] = acpi_get_hex(devfn >> 4);
+    ssdt_ptr[ACPI_PCINOHP_OFFSET_HEX + 1] = acpi_get_hex(devfn);
+    ssdt_ptr[ACPI_PCINOHP_OFFSET_ID] = slot;
+    ssdt_ptr[ACPI_PCINOHP_OFFSET_ADR + 2] = slot;
+}
+
 /* Assign BSEL property to all buses.  In the future, this can be changed
  * to only assign to buses that support hotplug.
  */
@@ -737,6 +754,7 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state)
     AcpiBuildPciBusHotplugState *parent = child->parent;
     GArray *bus_table = build_alloc_array();
     DECLARE_BITMAP(slot_hotplug_enable, PCI_SLOT_MAX);
+    DECLARE_BITMAP(slot_device_present, PCI_SLOT_MAX);
     uint8_t op;
     int i;
     QObject *bsel;
@@ -764,40 +782,51 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state)
         build_append_byte(bus_table, 0x08); /* NameOp */
         build_append_nameseg(bus_table, "BSEL");
         build_append_int(bus_table, qint_get_int(qobject_to_qint(bsel)));
+    }
 
-        memset(slot_hotplug_enable, 0xff, sizeof slot_hotplug_enable);
+    memset(slot_hotplug_enable, 0xff, sizeof slot_hotplug_enable);
+    memset(slot_device_present, 0x00, sizeof slot_device_present);
 
-        for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
-            DeviceClass *dc;
-            PCIDeviceClass *pc;
-            PCIDevice *pdev = bus->devices[i];
+    for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
+        DeviceClass *dc;
+        PCIDeviceClass *pc;
+        PCIDevice *pdev = bus->devices[i];
+        int slot = PCI_SLOT(i);
 
-            if (!pdev) {
-                continue;
-            }
+        if (!pdev) {
+            continue;
+        }
 
-            pc = PCI_DEVICE_GET_CLASS(pdev);
-            dc = DEVICE_GET_CLASS(pdev);
+        set_bit(slot, slot_device_present);
+        pc = PCI_DEVICE_GET_CLASS(pdev);
+        dc = DEVICE_GET_CLASS(pdev);
 
-            if (!dc->hotpluggable || pc->is_bridge) {
-                int slot = PCI_SLOT(i);
+        if (!dc->hotpluggable || pc->is_bridge) {
+            int slot = PCI_SLOT(i);
 
-                clear_bit(slot, slot_hotplug_enable);
-            }
+            clear_bit(slot, slot_hotplug_enable);
         }
+    }
 
-        /* Append Device object for each slot which supports eject */
-        for (i = 0; i < PCI_SLOT_MAX; i++) {
-            bool can_eject = test_bit(i, slot_hotplug_enable);
-            if (can_eject) {
-                void *pcihp = acpi_data_push(bus_table,
-                                             ACPI_PCIHP_SIZEOF);
-                memcpy(pcihp, ACPI_PCIHP_AML, ACPI_PCIHP_SIZEOF);
-                patch_pcihp(i, pcihp);
-                bus_hotplug_support = true;
-            }
+    /* Append Device object for each slot which supports eject */
+    for (i = 0; i < PCI_SLOT_MAX; i++) {
+        bool can_eject = test_bit(i, slot_hotplug_enable);
+        bool present = test_bit(i, slot_device_present);
+        if (can_eject) {
+            void *pcihp = acpi_data_push(bus_table,
+                                         ACPI_PCIHP_SIZEOF);
+            memcpy(pcihp, ACPI_PCIHP_AML, ACPI_PCIHP_SIZEOF);
+            patch_pcihp(i, pcihp);
+            bus_hotplug_support = true;
+        } else if (present) {
+            void *pcihp = acpi_data_push(bus_table,
+                                         ACPI_PCIHP_SIZEOF);
+            memcpy(pcihp, ACPI_PCINOHP_AML, ACPI_PCINOHP_SIZEOF);
+            patch_pcinohp(i, pcihp);
         }
+    }
 
+    if (bsel) {
         method = build_alloc_method("DVNT", 2);
 
         for (i = 0; i < PCI_SLOT_MAX; i++) {
@@ -976,7 +1005,14 @@ build_ssdt(GArray *table_data, GArray *linker,
 
         {
             AcpiBuildPciBusHotplugState hotplug_state;
-            PCIBus *bus = find_i440fx(); /* TODO: Q35 support */
+            Object *pci_host;
+            PCIBus *bus = NULL;
+            bool ambiguous;
+
+            pci_host = object_resolve_path_type("", TYPE_PCI_HOST_BRIDGE, &ambiguous);
+            if (!ambiguous && pci_host) {
+                bus = PCI_HOST_BRIDGE(pci_host)->bus;
+            }
 
             build_pci_bus_state_init(&hotplug_state, NULL);
 
hw/i386/ssdt-pcihp.dsl +12 -0
index cc245c3..ea4b9e1 100644
@@ -46,5 +46,17 @@ DefinitionBlock ("ssdt-pcihp.aml", "SSDT", 0x01, "BXPC", "BXSSDTPCIHP", 0x1)
             }
         }
 
+        ACPI_EXTRACT_DEVICE_START ssdt_pcinohp_start
+        ACPI_EXTRACT_DEVICE_END ssdt_pcinohp_end
+        ACPI_EXTRACT_DEVICE_STRING ssdt_pcinohp_name
+
+        // Extract the offsets of the device name, address dword and the slot
+        // name byte - we fill them in for each device.
+        Device(SBB) {
+            ACPI_EXTRACT_NAME_BYTE_CONST ssdt_pcinohp_id
+            Name(_SUN, 0xAA)
+            ACPI_EXTRACT_NAME_DWORD_CONST ssdt_pcinohp_adr
+            Name(_ADR, 0xAA0000)
+        }
     }
 }
#4 lore raw

Re: [Qemu-devel] [PULL 1/5] acpi-build: append description for non-hotplug

Quoted 1 line · Michael S. Tsirkin

Peter, if not too late, pls don't pull until we figure it out.

If you want a pull request to not be applied you need to follow up to the 00/nn cover letter for the pull request to say so. Otherwise I am likely to either miss the request or not to remember it when I'm going through the folder of pull requests to be applied.

thanks
-- PMM

#5 lore raw

Re: [Qemu-devel] [PULL 1/5] acpi-build: append description for non-hotplug

Quoted 11 lines · Peter Maydell
Quoted 1 line · Michael S. Tsirkin

Peter, if not too late, pls don't pull until we figure it out.

If you want a pull request to not be applied you need to follow up to the 00/nn cover letter for the pull request to say so. Otherwise I am likely to either miss the request or not to remember it when I'm going through the folder of pull requests to be applied.

thanks
-- PMM

Good thing you noticed this time :)
Good to know, will do so in the future.

Thanks,

Signature · 1 line
MST
#6 lore raw

Re: [Qemu-devel] [PULL 1/5] acpi-build: append description for non-hotplug

In reply to Gabriel L. Somlo
Quoted 31 lines · Gabriel L. Somlo

Michael,

Quoted 20 lines · Michael S. Tsirkin

As reported in
http://article.gmane.org/gmane.comp.emulators.qemu/253987
Mac OSX actually requires describing all occupied slots in ACPI - even if hotplug isn't enabled.

I didn't expect this so I dropped description of all
non hotpluggable slots from ACPI.
As a result: before
commit 99fd437dee468609de8218f0eb3b16621fb6a9c9 (enable hotplug for pci bridges), PCI cards show up in the "device tree" of OS X (System Information). E.g., on MountainLion users have:

...

Ethernet still works, but it's not showing up on the PCI bus, and it no longer thinks it's plugged in to slot #2, as it used to before the change.

To fix, append description for all occupied non hotpluggable PCI slots.

Quoted 7 lines

One need to be careful when doing this: VGA and ISA device were already described, so we need to drop description from DSDT.

---
...

Quoted 8 lines

With this latest version of your patch, I crash during OS X boot with
"unable to find driver for this platform:\"ACPI\".\n"@/SourceCache/xnu/xnu-2050.48.12/iokit/Kernel/IOPlatformExpert.cpp:1514"

Your original patch (slightly doctored since it no longer applies cleanly to the current qemu git master) is included below, and still works for me.

Thanks,
--Gabriel

Any chance below helps on top?
Another alternative is that DSDT referencing
SSDT does not work for apple.
I hope it's not that, that would be annoying...

commit 12b48c660b8316b1e8ff633eb9f3f34bd4b78284

Author: Michael S. Tsirkin <[email protected]>
Date:   Wed Feb 19 15:47:03 2014 +0200

acpi-build: drop _SUN for non hotpluggable slots

Not needed there, let's not add it.

hw/i386/acpi-build.c +0 -6
index 5b0bb5a..226e59e 100644
@@ -644,19 +644,16 @@ static inline char acpi_get_hex(uint32_t val)
 #define ACPI_PCIHP_AML (ssdp_pcihp_aml + *ssdt_pcihp_start)
 
 #define ACPI_PCINOHP_OFFSET_HEX (*ssdt_pcinohp_name - *ssdt_pcinohp_start + 1)
-#define ACPI_PCINOHP_OFFSET_ID (*ssdt_pcinohp_id - *ssdt_pcinohp_start)
 #define ACPI_PCINOHP_OFFSET_ADR (*ssdt_pcinohp_adr - *ssdt_pcinohp_start)
 #define ACPI_PCINOHP_SIZEOF (*ssdt_pcinohp_end - *ssdt_pcinohp_start)
 #define ACPI_PCINOHP_AML (ssdp_pcihp_aml + *ssdt_pcinohp_start)
 
 #define ACPI_PCIVGA_OFFSET_HEX (*ssdt_pcivga_name - *ssdt_pcivga_start + 1)
-#define ACPI_PCIVGA_OFFSET_ID (*ssdt_pcivga_id - *ssdt_pcivga_start)
 #define ACPI_PCIVGA_OFFSET_ADR (*ssdt_pcivga_adr - *ssdt_pcivga_start)
 #define ACPI_PCIVGA_SIZEOF (*ssdt_pcivga_end - *ssdt_pcivga_start)
 #define ACPI_PCIVGA_AML (ssdp_pcihp_aml + *ssdt_pcivga_start)
 
 #define ACPI_PCIQXL_OFFSET_HEX (*ssdt_pciqxl_name - *ssdt_pciqxl_start + 1)
-#define ACPI_PCIQXL_OFFSET_ID (*ssdt_pciqxl_id - *ssdt_pciqxl_start)
 #define ACPI_PCIQXL_OFFSET_ADR (*ssdt_pciqxl_adr - *ssdt_pciqxl_start)
 #define ACPI_PCIQXL_SIZEOF (*ssdt_pciqxl_end - *ssdt_pciqxl_start)
 #define ACPI_PCIQXL_AML (ssdp_pcihp_aml + *ssdt_pciqxl_start)
@@ -701,7 +698,6 @@ static void patch_pcinohp(int slot, uint8_t *ssdt_ptr)
 
     ssdt_ptr[ACPI_PCINOHP_OFFSET_HEX] = acpi_get_hex(devfn >> 4);
     ssdt_ptr[ACPI_PCINOHP_OFFSET_HEX + 1] = acpi_get_hex(devfn);
-    ssdt_ptr[ACPI_PCINOHP_OFFSET_ID] = slot;
     ssdt_ptr[ACPI_PCINOHP_OFFSET_ADR + 2] = slot;
 }
 
@@ -711,7 +707,6 @@ static void patch_pcivga(int slot, uint8_t *ssdt_ptr)
 
     ssdt_ptr[ACPI_PCIVGA_OFFSET_HEX] = acpi_get_hex(devfn >> 4);
     ssdt_ptr[ACPI_PCIVGA_OFFSET_HEX + 1] = acpi_get_hex(devfn);
-    ssdt_ptr[ACPI_PCIVGA_OFFSET_ID] = slot;
     ssdt_ptr[ACPI_PCIVGA_OFFSET_ADR + 2] = slot;
 }
 
@@ -721,7 +716,6 @@ static void patch_pciqxl(int slot, uint8_t *ssdt_ptr)
 
     ssdt_ptr[ACPI_PCIQXL_OFFSET_HEX] = acpi_get_hex(devfn >> 4);
     ssdt_ptr[ACPI_PCIQXL_OFFSET_HEX + 1] = acpi_get_hex(devfn);
-    ssdt_ptr[ACPI_PCIQXL_OFFSET_ID] = slot;
     ssdt_ptr[ACPI_PCIQXL_OFFSET_ADR + 2] = slot;
 }
 
hw/i386/ssdt-pcihp.dsl +0 -6
index 69a0228..ac91c05 100644
@@ -53,8 +53,6 @@ DefinitionBlock ("ssdt-pcihp.aml", "SSDT", 0x01, "BXPC", "BXSSDTPCIHP", 0x1)
         // Extract the offsets of the device name, address dword and the slot
         // name byte - we fill them in for each device.
         Device(SBB) {
-            ACPI_EXTRACT_NAME_BYTE_CONST ssdt_pcinohp_id
-            Name(_SUN, 0xAA)
             ACPI_EXTRACT_NAME_DWORD_CONST ssdt_pcinohp_adr
             Name(_ADR, 0xAA0000)
         }
@@ -66,8 +64,6 @@ DefinitionBlock ("ssdt-pcihp.aml", "SSDT", 0x01, "BXPC", "BXSSDTPCIHP", 0x1)
         // Extract the offsets of the device name, address dword and the slot
         // name byte - we fill them in for each device.
         Device(SCC) {
-            ACPI_EXTRACT_NAME_BYTE_CONST ssdt_pcivga_id
-            Name(_SUN, 0xAA)
             ACPI_EXTRACT_NAME_DWORD_CONST ssdt_pcivga_adr
             Name(_ADR, 0xAA0000)
             Method(_S1D, 0, NotSerialized) {
@@ -88,8 +84,6 @@ DefinitionBlock ("ssdt-pcihp.aml", "SSDT", 0x01, "BXPC", "BXSSDTPCIHP", 0x1)
         // Extract the offsets of the device name, address dword and the slot
         // name byte - we fill them in for each device.
         Device(SDD) {
-            ACPI_EXTRACT_NAME_BYTE_CONST ssdt_pciqxl_id
-            Name(_SUN, 0xAA)
             ACPI_EXTRACT_NAME_DWORD_CONST ssdt_pciqxl_adr
             Name(_ADR, 0xAA0000)
             Method(_S1D, 0, NotSerialized) {
#7 lore raw

Re: [Qemu-devel] [PULL 1/5] acpi-build: append description for non-hotplug

Quoted 9 lines · Michael S. Tsirkin
Quoted 6 lines · Gabriel L. Somlo

With this latest version of your patch, I crash during OS X boot with
"unable to find driver for this platform:\"ACPI\".\n"@/SourceCache/xnu/xnu-2050.48.12/iokit/Kernel/IOPlatformExpert.cpp:1514"

Your original patch (slightly doctored since it no longer applies cleanly to the current qemu git master) is included below, and still works for me.

Any chance below helps on top?

Nope, sorry, I'm getting the same error :(

Quoted 3 lines

Another alternative is that DSDT referencing
SSDT does not work for apple.
I hope it's not that, that would be annoying...

I'm probably misunderstanding this in a major way, but when I try the following, just for grins:

hw/i386/acpi-dsdt-hpet.dsl +0 -0
index 44961b8..d4614e0 100644
@@ -36,6 +36,9 @@ Scope(\_SB) {
             If (LOr(LEqual(Local1, 0), LGreater(Local1, 100000000)))
{
                 Return (0x0)
             }
+            If (LEqual(\_SB.FOBR, 0x12)) {
+                Return (0x0)
+            }
             Return (0x0F)
         }
         Name(_CRS, ResourceTemplate() {
hw/i386/ssdt-misc.dsl +0 -0
index a4484b8..67d853a 100644
@@ -22,6 +22,10 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01,

"BXPC", "BXSS
* PCI memory ranges ****************************************************************/

+ Scope(\_SB) {
+ Name(FOBR, 0x12)
+ }
+

     Scope(\) {
        ACPI_EXTRACT_NAME_DWORD_CONST acpi_pci32_start
        Name(P0S, 0x12345678)

---

I get iasl compile errors, never even make it to the point where OS X would get a chance to be upset with me... :)

Thanks,
--Gabriel

Quoted 89 lines

commit 12b48c660b8316b1e8ff633eb9f3f34bd4b78284

Author: Michael S. Tsirkin <[email protected]>
Date:   Wed Feb 19 15:47:03 2014 +0200

acpi-build: drop _SUN for non hotpluggable slots

Not needed there, let's not add it.

hw/i386/acpi-build.c +0 -6
index 5b0bb5a..226e59e 100644
@@ -644,19 +644,16 @@ static inline char acpi_get_hex(uint32_t val)
 #define ACPI_PCIHP_AML (ssdp_pcihp_aml + *ssdt_pcihp_start)
 
 #define ACPI_PCINOHP_OFFSET_HEX (*ssdt_pcinohp_name - *ssdt_pcinohp_start + 1)
-#define ACPI_PCINOHP_OFFSET_ID (*ssdt_pcinohp_id - *ssdt_pcinohp_start)
 #define ACPI_PCINOHP_OFFSET_ADR (*ssdt_pcinohp_adr - *ssdt_pcinohp_start)
 #define ACPI_PCINOHP_SIZEOF (*ssdt_pcinohp_end - *ssdt_pcinohp_start)
 #define ACPI_PCINOHP_AML (ssdp_pcihp_aml + *ssdt_pcinohp_start)
 
 #define ACPI_PCIVGA_OFFSET_HEX (*ssdt_pcivga_name - *ssdt_pcivga_start + 1)
-#define ACPI_PCIVGA_OFFSET_ID (*ssdt_pcivga_id - *ssdt_pcivga_start)
 #define ACPI_PCIVGA_OFFSET_ADR (*ssdt_pcivga_adr - *ssdt_pcivga_start)
 #define ACPI_PCIVGA_SIZEOF (*ssdt_pcivga_end - *ssdt_pcivga_start)
 #define ACPI_PCIVGA_AML (ssdp_pcihp_aml + *ssdt_pcivga_start)
 
 #define ACPI_PCIQXL_OFFSET_HEX (*ssdt_pciqxl_name - *ssdt_pciqxl_start + 1)
-#define ACPI_PCIQXL_OFFSET_ID (*ssdt_pciqxl_id - *ssdt_pciqxl_start)
 #define ACPI_PCIQXL_OFFSET_ADR (*ssdt_pciqxl_adr - *ssdt_pciqxl_start)
 #define ACPI_PCIQXL_SIZEOF (*ssdt_pciqxl_end - *ssdt_pciqxl_start)
 #define ACPI_PCIQXL_AML (ssdp_pcihp_aml + *ssdt_pciqxl_start)
@@ -701,7 +698,6 @@ static void patch_pcinohp(int slot, uint8_t *ssdt_ptr)
 
     ssdt_ptr[ACPI_PCINOHP_OFFSET_HEX] = acpi_get_hex(devfn >> 4);
     ssdt_ptr[ACPI_PCINOHP_OFFSET_HEX + 1] = acpi_get_hex(devfn);
-    ssdt_ptr[ACPI_PCINOHP_OFFSET_ID] = slot;
     ssdt_ptr[ACPI_PCINOHP_OFFSET_ADR + 2] = slot;
 }
 
@@ -711,7 +707,6 @@ static void patch_pcivga(int slot, uint8_t *ssdt_ptr)
 
     ssdt_ptr[ACPI_PCIVGA_OFFSET_HEX] = acpi_get_hex(devfn >> 4);
     ssdt_ptr[ACPI_PCIVGA_OFFSET_HEX + 1] = acpi_get_hex(devfn);
-    ssdt_ptr[ACPI_PCIVGA_OFFSET_ID] = slot;
     ssdt_ptr[ACPI_PCIVGA_OFFSET_ADR + 2] = slot;
 }
 
@@ -721,7 +716,6 @@ static void patch_pciqxl(int slot, uint8_t *ssdt_ptr)
 
     ssdt_ptr[ACPI_PCIQXL_OFFSET_HEX] = acpi_get_hex(devfn >> 4);
     ssdt_ptr[ACPI_PCIQXL_OFFSET_HEX + 1] = acpi_get_hex(devfn);
-    ssdt_ptr[ACPI_PCIQXL_OFFSET_ID] = slot;
     ssdt_ptr[ACPI_PCIQXL_OFFSET_ADR + 2] = slot;
 }
 
hw/i386/ssdt-pcihp.dsl +0 -6
index 69a0228..ac91c05 100644
@@ -53,8 +53,6 @@ DefinitionBlock ("ssdt-pcihp.aml", "SSDT", 0x01, "BXPC", "BXSSDTPCIHP", 0x1)
         // Extract the offsets of the device name, address dword and the slot
         // name byte - we fill them in for each device.
         Device(SBB) {
-            ACPI_EXTRACT_NAME_BYTE_CONST ssdt_pcinohp_id
-            Name(_SUN, 0xAA)
             ACPI_EXTRACT_NAME_DWORD_CONST ssdt_pcinohp_adr
             Name(_ADR, 0xAA0000)
         }
@@ -66,8 +64,6 @@ DefinitionBlock ("ssdt-pcihp.aml", "SSDT", 0x01, "BXPC", "BXSSDTPCIHP", 0x1)
         // Extract the offsets of the device name, address dword and the slot
         // name byte - we fill them in for each device.
         Device(SCC) {
-            ACPI_EXTRACT_NAME_BYTE_CONST ssdt_pcivga_id
-            Name(_SUN, 0xAA)
             ACPI_EXTRACT_NAME_DWORD_CONST ssdt_pcivga_adr
             Name(_ADR, 0xAA0000)
             Method(_S1D, 0, NotSerialized) {
@@ -88,8 +84,6 @@ DefinitionBlock ("ssdt-pcihp.aml", "SSDT", 0x01, "BXPC", "BXSSDTPCIHP", 0x1)
         // Extract the offsets of the device name, address dword and the slot
         // name byte - we fill them in for each device.
         Device(SDD) {
-            ACPI_EXTRACT_NAME_BYTE_CONST ssdt_pciqxl_id
-            Name(_SUN, 0xAA)
             ACPI_EXTRACT_NAME_DWORD_CONST ssdt_pciqxl_adr
             Name(_ADR, 0xAA0000)
             Method(_S1D, 0, NotSerialized) {
#8 lore raw

Re: [Qemu-devel] [PULL 1/5] acpi-build: append description for non-hotplug

Quoted 53 lines · Gabriel L. Somlo
Quoted 9 lines · Michael S. Tsirkin
Quoted 6 lines · Gabriel L. Somlo

With this latest version of your patch, I crash during OS X boot with
"unable to find driver for this platform:\"ACPI\".\n"@/SourceCache/xnu/xnu-2050.48.12/iokit/Kernel/IOPlatformExpert.cpp:1514"

Your original patch (slightly doctored since it no longer applies cleanly to the current qemu git master) is included below, and still works for me.

Any chance below helps on top?

Nope, sorry, I'm getting the same error :(

Quoted 3 lines

Another alternative is that DSDT referencing
SSDT does not work for apple.
I hope it's not that, that would be annoying...

I'm probably misunderstanding this in a major way, but when I try the following, just for grins:

hw/i386/acpi-dsdt-hpet.dsl +3 -0
index 44961b8..d4614e0 100644
@@ -36,6 +36,9 @@ Scope(\_SB) {
             If (LOr(LEqual(Local1, 0), LGreater(Local1, 100000000)))
 {
                 Return (0x0)
             }
+            If (LEqual(\_SB.FOBR, 0x12)) {
+                Return (0x0)
+            }
             Return (0x0F)
         }
         Name(_CRS, ResourceTemplate() {
hw/i386/ssdt-misc.dsl +0 -0
index a4484b8..67d853a 100644
@@ -22,6 +22,10 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01,

"BXPC", "BXSS
* PCI memory ranges ****************************************************************/

hw/i386/ssdt-misc.dsl +4 -1
+    Scope(\_SB) {
+       Name(FOBR, 0x12)
+    }
+
     Scope(\) {
        ACPI_EXTRACT_NAME_DWORD_CONST acpi_pci32_start
        Name(P0S, 0x12345678)
---
Quoted 5 lines

I get iasl compile errors, never even make it to the point where OS X would get a chance to be upset with me... :)

Thanks,
--Gabriel

You will have to declare it with Extern in DSDT.

Quoted 89 lines
Quoted 89 lines

commit 12b48c660b8316b1e8ff633eb9f3f34bd4b78284

Author: Michael S. Tsirkin <[email protected]>
Date:   Wed Feb 19 15:47:03 2014 +0200

acpi-build: drop _SUN for non hotpluggable slots

Not needed there, let's not add it.

hw/i386/acpi-build.c +0 -6
index 5b0bb5a..226e59e 100644
@@ -644,19 +644,16 @@ static inline char acpi_get_hex(uint32_t val)
 #define ACPI_PCIHP_AML (ssdp_pcihp_aml + *ssdt_pcihp_start)
 
 #define ACPI_PCINOHP_OFFSET_HEX (*ssdt_pcinohp_name - *ssdt_pcinohp_start + 1)
-#define ACPI_PCINOHP_OFFSET_ID (*ssdt_pcinohp_id - *ssdt_pcinohp_start)
 #define ACPI_PCINOHP_OFFSET_ADR (*ssdt_pcinohp_adr - *ssdt_pcinohp_start)
 #define ACPI_PCINOHP_SIZEOF (*ssdt_pcinohp_end - *ssdt_pcinohp_start)
 #define ACPI_PCINOHP_AML (ssdp_pcihp_aml + *ssdt_pcinohp_start)
 
 #define ACPI_PCIVGA_OFFSET_HEX (*ssdt_pcivga_name - *ssdt_pcivga_start + 1)
-#define ACPI_PCIVGA_OFFSET_ID (*ssdt_pcivga_id - *ssdt_pcivga_start)
 #define ACPI_PCIVGA_OFFSET_ADR (*ssdt_pcivga_adr - *ssdt_pcivga_start)
 #define ACPI_PCIVGA_SIZEOF (*ssdt_pcivga_end - *ssdt_pcivga_start)
 #define ACPI_PCIVGA_AML (ssdp_pcihp_aml + *ssdt_pcivga_start)
 
 #define ACPI_PCIQXL_OFFSET_HEX (*ssdt_pciqxl_name - *ssdt_pciqxl_start + 1)
-#define ACPI_PCIQXL_OFFSET_ID (*ssdt_pciqxl_id - *ssdt_pciqxl_start)
 #define ACPI_PCIQXL_OFFSET_ADR (*ssdt_pciqxl_adr - *ssdt_pciqxl_start)
 #define ACPI_PCIQXL_SIZEOF (*ssdt_pciqxl_end - *ssdt_pciqxl_start)
 #define ACPI_PCIQXL_AML (ssdp_pcihp_aml + *ssdt_pciqxl_start)
@@ -701,7 +698,6 @@ static void patch_pcinohp(int slot, uint8_t *ssdt_ptr)
 
     ssdt_ptr[ACPI_PCINOHP_OFFSET_HEX] = acpi_get_hex(devfn >> 4);
     ssdt_ptr[ACPI_PCINOHP_OFFSET_HEX + 1] = acpi_get_hex(devfn);
-    ssdt_ptr[ACPI_PCINOHP_OFFSET_ID] = slot;
     ssdt_ptr[ACPI_PCINOHP_OFFSET_ADR + 2] = slot;
 }
 
@@ -711,7 +707,6 @@ static void patch_pcivga(int slot, uint8_t *ssdt_ptr)
 
     ssdt_ptr[ACPI_PCIVGA_OFFSET_HEX] = acpi_get_hex(devfn >> 4);
     ssdt_ptr[ACPI_PCIVGA_OFFSET_HEX + 1] = acpi_get_hex(devfn);
-    ssdt_ptr[ACPI_PCIVGA_OFFSET_ID] = slot;
     ssdt_ptr[ACPI_PCIVGA_OFFSET_ADR + 2] = slot;
 }
 
@@ -721,7 +716,6 @@ static void patch_pciqxl(int slot, uint8_t *ssdt_ptr)
 
     ssdt_ptr[ACPI_PCIQXL_OFFSET_HEX] = acpi_get_hex(devfn >> 4);
     ssdt_ptr[ACPI_PCIQXL_OFFSET_HEX + 1] = acpi_get_hex(devfn);
-    ssdt_ptr[ACPI_PCIQXL_OFFSET_ID] = slot;
     ssdt_ptr[ACPI_PCIQXL_OFFSET_ADR + 2] = slot;
 }
 
hw/i386/ssdt-pcihp.dsl +0 -6
index 69a0228..ac91c05 100644
@@ -53,8 +53,6 @@ DefinitionBlock ("ssdt-pcihp.aml", "SSDT", 0x01, "BXPC", "BXSSDTPCIHP", 0x1)
         // Extract the offsets of the device name, address dword and the slot
         // name byte - we fill them in for each device.
         Device(SBB) {
-            ACPI_EXTRACT_NAME_BYTE_CONST ssdt_pcinohp_id
-            Name(_SUN, 0xAA)
             ACPI_EXTRACT_NAME_DWORD_CONST ssdt_pcinohp_adr
             Name(_ADR, 0xAA0000)
         }
@@ -66,8 +64,6 @@ DefinitionBlock ("ssdt-pcihp.aml", "SSDT", 0x01, "BXPC", "BXSSDTPCIHP", 0x1)
         // Extract the offsets of the device name, address dword and the slot
         // name byte - we fill them in for each device.
         Device(SCC) {
-            ACPI_EXTRACT_NAME_BYTE_CONST ssdt_pcivga_id
-            Name(_SUN, 0xAA)
             ACPI_EXTRACT_NAME_DWORD_CONST ssdt_pcivga_adr
             Name(_ADR, 0xAA0000)
             Method(_S1D, 0, NotSerialized) {
@@ -88,8 +84,6 @@ DefinitionBlock ("ssdt-pcihp.aml", "SSDT", 0x01, "BXPC", "BXSSDTPCIHP", 0x1)
         // Extract the offsets of the device name, address dword and the slot
         // name byte - we fill them in for each device.
         Device(SDD) {
-            ACPI_EXTRACT_NAME_BYTE_CONST ssdt_pciqxl_id
-            Name(_SUN, 0xAA)
             ACPI_EXTRACT_NAME_DWORD_CONST ssdt_pciqxl_adr
             Name(_ADR, 0xAA0000)
             Method(_S1D, 0, NotSerialized) {
author Tested-by Gabriel L. Somlo
#9 lore raw

Re: [Qemu-devel] [PULL 1/5] acpi-build: append description for non-hotplug

In reply to Michael S. Tsirkin
Quoted 38 lines · Michael S. Tsirkin
Quoted 37 lines · Gabriel L. Somlo

Michael,

Quoted 20 lines · Michael S. Tsirkin

As reported in
http://article.gmane.org/gmane.comp.emulators.qemu/253987
Mac OSX actually requires describing all occupied slots in ACPI - even if hotplug isn't enabled.

I didn't expect this so I dropped description of all
non hotpluggable slots from ACPI.
As a result: before
commit 99fd437dee468609de8218f0eb3b16621fb6a9c9 (enable hotplug for pci bridges), PCI cards show up in the "device tree" of OS X (System Information). E.g., on MountainLion users have:

...

Ethernet still works, but it's not showing up on the PCI bus, and it no longer thinks it's plugged in to slot #2, as it used to before the change.

To fix, append description for all occupied non hotpluggable PCI slots.

Quoted 7 lines

One need to be careful when doing this: VGA and ISA device were already described, so we need to drop description from DSDT.

---
...

With this latest version of your patch, I crash during OS X boot with
"unable to find driver for this platform:\"ACPI\".\n"@/SourceCache/xnu/xnu-2050.48.12/iokit/Kernel/IOPlatformExpert.cpp:1514"

Your original patch (slightly doctored since it no longer applies cleanly to the current qemu git master) is included below, and still works for me.

Quoted 7 lines
Quoted 2 lines

Thanks,
--Gabriel

Any chance below helps on top?
Another alternative is that DSDT referencing
SSDT does not work for apple.
I hope it's not that, that would be annoying...

OK I think it's that unfortunately.
The following on top should help.
Can you confirm please?

Thanks a lot for the report!

commit a0ad25b1e5d0eb21cbba001799341bd6b557e995

Author: Michael S. Tsirkin <[email protected]>
Date:   Wed Feb 19 17:20:56 2014 +0200

Don't call SSDT from DSDT

Windows XP doesn't like this.
Apparently, neither does Mac OSX.

hw/i386/acpi-build.c +11 -2
index 5b0bb5a..cb7a65f 100644
@@ -786,6 +786,7 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state)
     GArray *bus_table = build_alloc_array();
     DECLARE_BITMAP(slot_hotplug_enable, PCI_SLOT_MAX);
     DECLARE_BITMAP(slot_device_present, PCI_SLOT_MAX);
+    DECLARE_BITMAP(slot_device_system, PCI_SLOT_MAX);
     DECLARE_BITMAP(slot_device_vga, PCI_SLOT_MAX);
     DECLARE_BITMAP(slot_device_qxl, PCI_SLOT_MAX);
     uint8_t op;
@@ -822,10 +823,11 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state)
     }
 
     memset(slot_device_present, 0x00, sizeof slot_device_present);
+    memset(slot_device_system, 0x00, sizeof slot_device_present);
     memset(slot_device_vga, 0x00, sizeof slot_device_vga);
     memset(slot_device_qxl, 0x00, sizeof slot_device_qxl);
 
-    for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
+    for (i = 0; i < ARRAY_SIZE(bus->devices); i += PCI_FUNC_MAX) {
         DeviceClass *dc;
         PCIDeviceClass *pc;
         PCIDevice *pdev = bus->devices[i];
@@ -839,6 +841,10 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state)
         pc = PCI_DEVICE_GET_CLASS(pdev);
         dc = DEVICE_GET_CLASS(pdev);
 
+        if (pc->class_id == PCI_CLASS_BRIDGE_ISA) {
+            set_bit(slot, slot_device_system);
+        }
+
         if (pc->class_id == PCI_CLASS_DISPLAY_VGA) {
             set_bit(slot, slot_device_vga);
 
@@ -852,12 +858,13 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state)
         }
     }
 
-    /* Append Device object for each slot which supports eject */
+    /* Append Device object for each slot */
     for (i = 0; i < PCI_SLOT_MAX; i++) {
         bool can_eject = test_bit(i, slot_hotplug_enable);
         bool present = test_bit(i, slot_device_present);
         bool vga = test_bit(i, slot_device_vga);
         bool qxl = test_bit(i, slot_device_qxl);
+        bool system = test_bit(i, slot_device_system);
         if (can_eject) {
             void *pcihp = acpi_data_push(bus_table,
                                          ACPI_PCIHP_SIZEOF);
@@ -874,6 +881,8 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state)
                                          ACPI_PCIVGA_SIZEOF);
             memcpy(pcihp, ACPI_PCIVGA_AML, ACPI_PCIVGA_SIZEOF);
             patch_pcivga(i, pcihp);
+        } else if (system) {
+            /* Nothing to do: system devices are in DSDT. */
         } else if (present) {
             void *pcihp = acpi_data_push(bus_table,
                                          ACPI_PCINOHP_SIZEOF);
hw/i386/acpi-dsdt.dsl +9 -5
index 6b5ab32..0a1e252 100644
@@ -80,8 +80,8 @@ DefinitionBlock (
             Name(_HID, EisaId("PNP0A03"))
             Name(_ADR, 0x00)
             Name(_UID, 1)
-#define PX13 S0B_
-            External(PX13, DeviceObj)
+//#define PX13 S0B_
+//            External(PX13, DeviceObj)
         }
     }
 
@@ -93,8 +93,11 @@ DefinitionBlock (
  * PIIX4 PM
  ****************************************************************/
 
-    Scope(\_SB.PCI0.PX13) {
+    Scope(\_SB.PCI0) {
+        Device(PX13) {
+            Name(_ADR, 0x00010003)
             OperationRegion(P13C, PCI_Config, 0x00, 0xff)
+        }
     }
 
 
@@ -104,10 +107,11 @@ DefinitionBlock (
 
     Scope(\_SB.PCI0) {
 
-#define ISA S08_
         External(ISA, DeviceObj)
 
-        Scope(ISA) {
+        Device(ISA) {
+            Name(_ADR, 0x00010000)
+
             /* PIIX PCI to ISA irq remapping */
             OperationRegion(P40C, PCI_Config, 0x60, 0x04)
 
#10 lore raw

Re: [Qemu-devel] [PULL 1/5] acpi-build: append description for non-hotplug

Quoted 20 lines · Michael S. Tsirkin
Quoted 8 lines · Michael S. Tsirkin
Quoted 3 lines · Gabriel L. Somlo

With this latest version of your patch, I crash during OS X boot with
"unable to find driver for this platform:\"ACPI\".\n"@/SourceCache/xnu/xnu-2050.48.12/iokit/Kernel/IOPlatformExpert.cpp:1514"

Any chance below helps on top?
Another alternative is that DSDT referencing
SSDT does not work for apple.
I hope it's not that, that would be annoying...

OK I think it's that unfortunately.
The following on top should help.
Can you confirm please?

Thanks a lot for the report!

commit a0ad25b1e5d0eb21cbba001799341bd6b557e995

Author: Michael S. Tsirkin <[email protected]>
Date:   Wed Feb 19 17:20:56 2014 +0200
Quoted 7 lines

Don't call SSDT from DSDT

Windows XP doesn't like this.
Apparently, neither does Mac OSX.

Sorry, still the same error :(

However, I think OS X can reference SSDT from DSDT just fine:

hw/i386/acpi-dsdt-isa.dsl +9 -1
index deb37de..06e37f5 100644
@@ -13,6 +13,8 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+External(\_SB.FOBR, IntObj)
+
 /* Common legacy ISA style devices. */
 Scope(\_SB.PCI0.ISA) {
 
@@ -20,7 +22,13 @@ Scope(\_SB.PCI0.ISA) {
         Name(_HID, EisaId("APP0001"))
         /* _STA will be patched to 0x0B if AppleSMC is present */
         ACPI_EXTRACT_NAME_BYTE_CONST DSDT_APPLESMC_STA
-        Name(_STA, 0xF0)
+        Name(_STF, 0xF0) /* get this out of the way temporarily */
+        Method(_STA, 0, NotSerialized) {
+            If (LGreater(\_SB.FOBR, Zero)) {
+                Return (0x0)
+            }
+            Return (0x0B)
+        }
         Name(_CRS, ResourceTemplate () {
             IO (Decode16, 0x0300, 0x0300, 0x01, 0x20)
             IRQNoFlags() { 6 }
hw/i386/ssdt-misc.dsl +4 -0
index a4484b8..a0be34b 100644
@@ -22,6 +22,10 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1)
  * PCI memory ranges
  ****************************************************************/
 
+    Scope(\_SB) {
+       Name(FOBR, Zero)
+    }
+
     Scope(\) {
        ACPI_EXTRACT_NAME_DWORD_CONST acpi_pci32_start
        Name(P0S, 0x12345678)

---

The above works great. If I set FOBR to e.g. 0x13, the boot process hangs due to the lack of an available SMC, but otherwise does not crash and burn (like, witha "can't find driver for platform" error). With FOBR set to Zero, OS X boots up all the way and works without any issues...

Thanks,
--Gabriel

#11 lore raw

Re: [Qemu-devel] [PULL 1/5] acpi-build: append description for non-hotplug

Quoted 23 lines · Gabriel L. Somlo
Quoted 22 lines · Michael S. Tsirkin
Quoted 8 lines · Michael S. Tsirkin
Quoted 3 lines · Gabriel L. Somlo

With this latest version of your patch, I crash during OS X boot with
"unable to find driver for this platform:\"ACPI\".\n"@/SourceCache/xnu/xnu-2050.48.12/iokit/Kernel/IOPlatformExpert.cpp:1514"

Any chance below helps on top?
Another alternative is that DSDT referencing
SSDT does not work for apple.
I hope it's not that, that would be annoying...

OK I think it's that unfortunately.
The following on top should help.
Can you confirm please?

Thanks a lot for the report!

commit a0ad25b1e5d0eb21cbba001799341bd6b557e995

Author: Michael S. Tsirkin <[email protected]>
Date:   Wed Feb 19 17:20:56 2014 +0200

Don't call SSDT from DSDT

Quoted 7 lines
Quoted 5 lines

Windows XP doesn't like this.
Apparently, neither does Mac OSX.

Sorry, still the same error :(

Oh yes, I forgot that Q35 has a separate DSDT.
Please add this on top:

commit ceb36090bf2054c8ad5c8cf441b690fad5581f4f

Author: Michael S. Tsirkin <[email protected]>
Date:   Thu Feb 20 07:10:56 2014 +0200

q35: fix up dsdt as well

hw/i386/q35-acpi-dsdt.dsl +4 -2
index 8e522a5..f4d2a2d 100644
@@ -72,7 +72,6 @@ DefinitionBlock (
             Name(_ADR, 0x00)
             Name(_UID, 1)
 
-#define ISA SF8_
             External(ISA, DeviceObj)
 
             // _OSC: based on sample of ACPI3.0b spec
@@ -140,8 +139,10 @@ DefinitionBlock (
  * LPC ISA bridge
  ****************************************************************/
 
-    Scope(\_SB.PCI0.ISA) {
+    Scope(\_SB.PCI0) {
         /* PCI D31:f0 LPC ISA bridge */
+        Device(ISA) {
+            Name (_ADR, 0x001F0000)  // _ADR: Address
 
             /* ICH9 PCI to ISA irq remapping */
             OperationRegion(PIRQ, PCI_Config, 0x60, 0x0C)
@@ -164,6 +165,7 @@ DefinitionBlock (
                 LPEN,   1,
                 FDEN,   1
             }
+        }
     }
 
 #define DSDT_APPLESMC_STA q35_dsdt_applesmc_sta
#12 lore raw

Re: [Qemu-devel] [PULL 1/5] acpi-build: append description for non-hotplug

Hi Michael,

Quoted 2 lines · Michael S. Tsirkin

Oh yes, I forgot that Q35 has a separate DSDT.
Please add this on top:

Thanks, I can confirm that this patch (ceb36090bf2054c8ad5c8cf441b690fad5581f4f) on top of a0ad25b1e5d0eb21cbba001799341bd6b557e995, on top of
the first patch you submitted ("acpi-build: append description for non-hotplug") fixes it for me !

Regards,
--Gabriel

Quoted 39 lines

commit ceb36090bf2054c8ad5c8cf441b690fad5581f4f

Author: Michael S. Tsirkin <[email protected]>
Date:   Thu Feb 20 07:10:56 2014 +0200

q35: fix up dsdt as well

hw/i386/q35-acpi-dsdt.dsl +4 -2
index 8e522a5..f4d2a2d 100644
@@ -72,7 +72,6 @@ DefinitionBlock (
             Name(_ADR, 0x00)
             Name(_UID, 1)
 
-#define ISA SF8_
             External(ISA, DeviceObj)
 
             // _OSC: based on sample of ACPI3.0b spec
@@ -140,8 +139,10 @@ DefinitionBlock (
  * LPC ISA bridge
  ****************************************************************/
 
-    Scope(\_SB.PCI0.ISA) {
+    Scope(\_SB.PCI0) {
         /* PCI D31:f0 LPC ISA bridge */
+        Device(ISA) {
+            Name (_ADR, 0x001F0000)  // _ADR: Address
 
             /* ICH9 PCI to ISA irq remapping */
             OperationRegion(PIRQ, PCI_Config, 0x60, 0x0C)
@@ -164,6 +165,7 @@ DefinitionBlock (
                 LPEN,   1,
                 FDEN,   1
             }
+        }
     }
 
 #define DSDT_APPLESMC_STA q35_dsdt_applesmc_sta
#13 lore raw

Re: [Qemu-devel] [PULL 1/5] acpi-build: append description for non-hotplug

Quoted 6 lines · Gabriel L. Somlo

Hi Michael,

Quoted 2 lines · Michael S. Tsirkin

Oh yes, I forgot that Q35 has a separate DSDT.
Please add this on top:

Quoted 8 lines

Thanks, I can confirm that this patch (ceb36090bf2054c8ad5c8cf441b690fad5581f4f) on top of a0ad25b1e5d0eb21cbba001799341bd6b557e995, on top of
the first patch you submitted ("acpi-build: append description for non-hotplug") fixes it for me !

Regards,
--Gabriel

Yay!
Okay will let it go through some testing and push hopefully early next week.
Thanks a lot for catching this in time!

Quoted 40 lines
Quoted 40 lines

commit ceb36090bf2054c8ad5c8cf441b690fad5581f4f

Author: Michael S. Tsirkin <[email protected]>
Date:   Thu Feb 20 07:10:56 2014 +0200

q35: fix up dsdt as well

hw/i386/q35-acpi-dsdt.dsl +4 -2
index 8e522a5..f4d2a2d 100644
@@ -72,7 +72,6 @@ DefinitionBlock (
             Name(_ADR, 0x00)
             Name(_UID, 1)
 
-#define ISA SF8_
             External(ISA, DeviceObj)
 
             // _OSC: based on sample of ACPI3.0b spec
@@ -140,8 +139,10 @@ DefinitionBlock (
  * LPC ISA bridge
  ****************************************************************/
 
-    Scope(\_SB.PCI0.ISA) {
+    Scope(\_SB.PCI0) {
         /* PCI D31:f0 LPC ISA bridge */
+        Device(ISA) {
+            Name (_ADR, 0x001F0000)  // _ADR: Address
 
             /* ICH9 PCI to ISA irq remapping */
             OperationRegion(PIRQ, PCI_Config, 0x60, 0x0C)
@@ -164,6 +165,7 @@ DefinitionBlock (
                 LPEN,   1,
                 FDEN,   1
             }
+        }
     }
 
 #define DSDT_APPLESMC_STA q35_dsdt_applesmc_sta
#14 lore raw

Re: [Qemu-devel] [PULL 1/5] acpi-build: append description for non-hotplug

In reply to Gabriel L. Somlo
Quoted 26 lines · Gabriel L. Somlo

Michael,

Quoted 23 lines · Michael S. Tsirkin

As reported in
http://article.gmane.org/gmane.comp.emulators.qemu/253987
Mac OSX actually requires describing all occupied slots in ACPI - even if hotplug isn't enabled.

I didn't expect this so I dropped description of all
non hotpluggable slots from ACPI.
As a result: before
commit 99fd437dee468609de8218f0eb3b16621fb6a9c9 (enable hotplug for pci bridges), PCI cards show up in the "device tree" of OS X (System Information). E.g., on MountainLion users have:

...

Ethernet still works, but it's not showing up on the PCI bus, and it no longer thinks it's plugged in to slot #2, as it used to before the change.

To fix, append description for all occupied non hotpluggable PCI slots.

One need to be careful when doing this: VGA and ISA device were already described, so we need to drop description from DSDT.

Quoted 7 lines
Quoted 4 lines

---
...

With this latest version of your patch, I crash during OS X boot with
"unable to find driver for this platform:\"ACPI\".\n"@/SourceCache/xnu/xnu-2050.48.12/iokit/Kernel/IOPlatformExpert.cpp:1514"

Also getting a STOP 0xA5 BSOD for win7x64 guest with this. Thanks,

Alex

#15 lore raw

[Qemu-devel] [PULL 2/5] acpi-test-data: update expected files

In reply to Michael S. Tsirkin
---
 tests/acpi-test-data/pc/DSDT  | Bin 4582 -> 4461 bytes
 tests/acpi-test-data/pc/SSDT  | Bin 2200 -> 2299 bytes
 tests/acpi-test-data/q35/DSDT | Bin 7438 -> 7370 bytes
 tests/acpi-test-data/q35/SSDT | Bin 475 -> 588 bytes
 4 files changed, 0 insertions(+), 0 deletions(-)
tests/acpi-test-data/pc/DSDT binary +0 -0
index fbf1c3e6e8f791f8e7bae95ad43ea11d0be64c72..cc3357d3fb76082f1086d0bb1285d08483c06833 100644
GIT binary patch
tests/acpi-test-data/pc/SSDT binary +0 -0
index a51c68e21b7f1556009331966c56eb7a563dd51e..a8940d19e303e72459dfc175bd347ef3de510d3a 100644
GIT binary patch
tests/acpi-test-data/q35/DSDT binary +0 -0
index 5086b839a6e11ee819af91e72f71efb3e8d97fe2..937fb710627e4af8c9a7a0a347746176dc4585ec 100644
GIT binary patch
tests/acpi-test-data/q35/SSDT binary +0 -0
index 9c6cad8b0b7e009d88232166112ed8877cfe11c0..8d29c19b0f23ce8344dbf3cb8338b9763e36dad1 100644
GIT binary patch
Signature · 1 line
MST
#16 lore raw

[Qemu-devel] [PULL 3/5] virtio-net: remove function calls from assert

In reply to Michael S. Tsirkin

From: Joel Stanley <[email protected]>

peer_{de,at}tach were called from inside assert(). We don't support building without NDEBUG but it's not tidy. Rearrange to attach peer outside assert calls.

---
 hw/net/virtio-net.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
hw/net/virtio-net.c +5 -2
index 3626608..535948d 100644
@@ -401,12 +401,15 @@ static int peer_detach(VirtIONet *n, int index)
 static void virtio_net_set_queues(VirtIONet *n)
 {
     int i;
+    int r;
 
     for (i = 0; i < n->max_queues; i++) {
         if (i < n->curr_queues) {
-            assert(!peer_attach(n, i));
+            r = peer_attach(n, i);
+            assert(!r);
         } else {
-            assert(!peer_detach(n, i));
+            r = peer_detach(n, i);
+            assert(!r);
         }
     }
 }
Signature · 1 line
MST
#17 lore raw

[Qemu-devel] [PULL 4/5] memory_region_present: return false if address is not found in child MemoryRegion

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

Windows XP shows COM2 port as non functional in "Device Manager" although no COM2 port backing device is present in QEMU.

This regression is really due to 3bb28b7208b349e7a1b326e3c6ef9efac1d462bf?
memory: Provide separate handling of unassigned io ports accesses

That is caused by the fact that QEMU reports to
OSPM that device is present by setting 5th bit in
PII4XPM.pci_conf[0x67] register when COM2 doesn't
exist.

It happens due to memory_region_present(io_as, 0x2f8) returning false positive since 0x2f8 address eventually translates into catchall io_as address space.

Fix memory_region_present(parent, addr) by returning true only if addr maps into a MemoryRegion within parent (excluding parent itself), to match its doc comment.

While at it fix copy/paste error in
memory_region_present() doc comment.

Note: this is a temporary hack: we really need better handling for unassigned regions, we should avoid fallback regions since they are bad for performance (breaking radix tree assumption that the data structure is sparsely populated); for memory we need to fix this to implement PCI master abort properly, anyway.

---
 include/exec/memory.h | 6 +++---
 memory.c              | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
include/exec/memory.h +3 -3
index 296d6ab..a5eb4c8 100644
@@ -838,13 +838,13 @@ void memory_region_set_alias_offset(MemoryRegion *mr,
                                     hwaddr offset);
 
 /**
- * memory_region_present: translate an address/size relative to a
- * MemoryRegion into a #MemoryRegionSection.
+ * memory_region_present: checks if an address relative to a @parent
+ * translates into #MemoryRegion within @parent
  *
  * Answer whether a #MemoryRegion within @parent covers the address
  * @addr.
  *
- * @parent: a MemoryRegion within which @addr is a relative address
+ * @parent: a #MemoryRegion within which @addr is a relative address
  * @addr: the area within @parent to be searched
  */
 bool memory_region_present(MemoryRegion *parent, hwaddr addr);
memory.c +1 -1
index 59ecc28..3f1df23 100644
@@ -1562,7 +1562,7 @@ static FlatRange *flatview_lookup(FlatView *view, AddrRange addr)
 bool memory_region_present(MemoryRegion *parent, hwaddr addr)
 {
     MemoryRegion *mr = memory_region_find(parent, addr, 1).mr;
-    if (!mr) {
+    if (!mr || (mr == parent)) {
         return false;
     }
     memory_region_unref(mr);
Signature · 1 line
MST
#18 lore raw

[Qemu-devel] [PULL 5/5] PCIE: fix regression with coldplugged multifunction device

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

PCIE is causing asserts each time a multifunction device is added on command line (coldplug).

This is caused by
commit a66e657e18cd9b70e9f57ae5512c07faf2bc508f
pci/pcie: convert PCIE hotplug to use hotplug-handler API
QEMU abort is caused by misplaced assertion, which should be checked only when device is hotplugged.

Reference to regression report:
http://www.mail-archive.com/[email protected]/msg216226.html

Fixes a66e657e18cd9b70e9f57ae5512c07faf2bc508f
---
 hw/pci/pcie.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
hw/pci/pcie.c +8 -8
index 8ecd11e..02cde6f 100644
@@ -221,29 +221,23 @@ static void pcie_cap_slot_hotplug_common(PCIDevice *hotplug_dev,
                                          DeviceState *dev,
                                          uint8_t **exp_cap, Error **errp)
 {
-    PCIDevice *pci_dev = PCI_DEVICE(dev);
     *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap;
     uint16_t sltsta = pci_get_word(*exp_cap + PCI_EXP_SLTSTA);
 
-    PCIE_DEV_PRINTF(pci_dev, "hotplug state: %d\n", state);
+    PCIE_DEV_PRINTF(PCI_DEVICE(dev), "hotplug state: %d\n", state);
     if (sltsta & PCI_EXP_SLTSTA_EIS) {
         /* the slot is electromechanically locked.
          * This error is propagated up to qdev and then to HMP/QMP.
          */
         error_setg_errno(errp, -EBUSY, "slot is electromechanically locked");
     }
-
-    /* TODO: multifunction hot-plug.
-     * Right now, only a device of function = 0 is allowed to be
-     * hot plugged/unplugged.
-     */
-    assert(PCI_FUNC(pci_dev->devfn) == 0);
 }
 
 void pcie_cap_slot_hotplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
                               Error **errp)
 {
     uint8_t *exp_cap;
+    PCIDevice *pci_dev = PCI_DEVICE(dev);
 
     pcie_cap_slot_hotplug_common(PCI_DEVICE(hotplug_dev), dev, &exp_cap, errp);
 
@@ -256,6 +250,12 @@ void pcie_cap_slot_hotplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
         return;
     }
 
+    /* TODO: multifunction hot-plug.
+     * Right now, only a device of function = 0 is allowed to be
+     * hot plugged/unplugged.
+     */
+    assert(PCI_FUNC(pci_dev->devfn) == 0);
+
     pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA,
                                PCI_EXP_SLTSTA_PDS);
     pcie_cap_slot_event(PCI_DEVICE(hotplug_dev), PCI_EXP_HP_EV_PDC);
Signature · 1 line
MST
#19 lore raw
In reply to Michael S. Tsirkin
Quoted 11 lines · Michael S. Tsirkin

The following changes since commit 417c45ab2f847c0a47b1232f611aa886df6a97d5:

ACPI: Remove commented-out code from HPET._CRS (2014-02-10 11:09:33 +0200)

are available in the git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to 0217598857eaf0ceae137cdd71445118af2284cf:

PCIE: fix regression with coldplugged multifunction device (2014-02-17 16:17:31 +0200)

Not applying this pullreq as per conversation in the other thread. Ping me if you want it applied later, or submit a fresh one.

thanks
-- PMM