Skip to contentSkip to conversation

ACPI: don't call acpi_pcihp_device_plug_cb on xen

PATCH Superseded Bruce Rogers 3 participants 6 messages Apr 27, 2017 – Apr 28, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: don't call acpi_pcihp_device_plug_cb on xen

Commit f0c9d64a exposed the issue that with a xenfv machine using pci passthrough, acpi cpi hotplug code was being executed by mistake. Guard calls to acpi_pcihp_device_plug_cb (and corresponding acpi_pcihp_device_unplug_cb) with a check for xen_enabled(). Without this check I am seeing an error that the bus doesn't have the acpi-pcihp-bsel property set.

---
 hw/acpi/piix4.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
hw/acpi/piix4.c +8 -3
index a553a7e..c409374 100644
@@ -385,7 +385,10 @@ static void piix4_device_plug_cb(HotplugHandler *hotplug_dev,
                                 dev, errp);
         }
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
-        acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev, errp);
+        if (!xen_enabled()) {
+            acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,
+                                      errp);
+        }
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
         if (s->cpu_hotplug_legacy) {
             legacy_acpi_cpu_plug_cb(hotplug_dev, &s->gpe_cpu, dev, errp);
@@ -408,8 +411,10 @@ static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev,
         acpi_memory_unplug_request_cb(hotplug_dev, &s->acpi_memory_hotplug,
                                       dev, errp);
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
-        acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,
-                                    errp);
+        if (!xen_enabled()) {
+            acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,
+                                        errp);
+        }
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) &&
                !s->cpu_hotplug_legacy) {
         acpi_cpu_unplug_request_cb(hotplug_dev, &s->cpuhp_state, dev, errp);
Signature · 1 line
1.9.0
#1 lore raw
Quoted 31 lines · Bruce Rogers

Commit f0c9d64a exposed the issue that with a xenfv machine using pci passthrough, acpi cpi hotplug code was being executed by mistake. Guard calls to acpi_pcihp_device_plug_cb (and corresponding acpi_pcihp_device_unplug_cb) with a check for xen_enabled(). Without this check I am seeing an error that the bus doesn't have the acpi-pcihp-bsel property set.

---
 hw/acpi/piix4.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
hw/acpi/piix4.c +4 -1
index a553a7e..c409374 100644
@@ -385,7 +385,10 @@ static void piix4_device_plug_cb(HotplugHandler *hotplug_dev,
                                 dev, errp);
         }
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
-        acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev, errp);
+        if (!xen_enabled()) {
+            acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,
+                                      errp);
+        }
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
         if (s->cpu_hotplug_legacy) {
             legacy_acpi_cpu_plug_cb(hotplug_dev, &s->gpe_cpu, dev, errp);
@@ -408,8 +411,10 @@ static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev,
         acpi_memory_unplug_request_cb(hotplug_dev, &s->acpi_memory_hotplug,
                                       dev, errp);

hw/acpi/piix4.c static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev, · line 420

Quoted 10 lines
hw/acpi/piix4.c +4 -2
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
-        acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,
-                                    errp);
+        if (!xen_enabled()) {
+            acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,
+                                        errp);
+        }
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) &&
                !s->cpu_hotplug_legacy) {
         acpi_cpu_unplug_request_cb(hotplug_dev, &s->cpuhp_state, dev, errp);

Wouldn't it be better to simply turn the error_setg("Unsupported bus...) in acpi_pcihp_device_plug_cb and acpi_pcihp_device_unplug_cb into debug printfs? After all, from this description it is clear that they are not an error conditions. PCI Passthough works correctly, right?

I realize that I should have suggested this earlier, sorry about that.

#2 lore raw
Quoted 50 lines
Quoted 3 lines
Quoted 3 lines · Stefano Stabellini

hw/acpi/piix4.c static void piix4_device_plug_cb(HotplugHandler

Quoted 17 lines · Bruce Rogers

Commit f0c9d64a exposed the issue that with a xenfv machine using pci passthrough, acpi cpi hotplug code was being executed by mistake. Guard calls to acpi_pcihp_device_plug_cb (and corresponding acpi_pcihp_device_unplug_cb) with a check for xen_enabled(). Without this check I am seeing an error that the bus doesn't have the acpi-pcihp-bsel property set.

---
 hw/acpi/piix4.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
hw/acpi/piix4.c +0 -0
index a553a7e..c409374 100644
@@ -385,7 +385,10 @@ static void piix4_device_plug_cb(HotplugHandler 

*hotplug_dev,

hw/acpi/piix4.c static void piix4_device_plug_cb(HotplugHandler *hotplug_dev,

Quoted 4 lines
hw/acpi/piix4.c +0 -1
                                 dev, errp);
         }
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
-        acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev, 

errp);

hw/acpi/piix4.c static void

Quoted 8 lines
hw/acpi/piix4.c +4 -0
+        if (!xen_enabled()) {
+            acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,
+                                      errp);
+        }
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
         if (s->cpu_hotplug_legacy) {
             legacy_acpi_cpu_plug_cb(hotplug_dev, &s->gpe_cpu, dev, errp);
@@ -408,8 +411,10 @@ static void 

piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev,

hw/acpi/piix4.c static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev,

Quoted 7 lines
hw/acpi/piix4.c +2 -2
         acpi_memory_unplug_request_cb(hotplug_dev, &s->acpi_memory_hotplug,
                                       dev, errp);
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
-        acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,
-                                    errp);
+        if (!xen_enabled()) {
+            acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug, 

dev,

hw/acpi/piix4.c static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev, · line 420

Quoted 5 lines
hw/acpi/piix4.c +2 -0
+                                        errp);
+        }
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) &&
                !s->cpu_hotplug_legacy) {
         acpi_cpu_unplug_request_cb(hotplug_dev, &s->cpuhp_state, dev, errp);
Quoted 6 lines

Wouldn't it be better to simply turn the error_setg("Unsupported bus...) in acpi_pcihp_device_plug_cb and acpi_pcihp_device_unplug_cb into debug printfs? After all, from this description it is clear that they are not an error conditions. PCI Passthough works correctly, right?

I realize that I should have suggested this earlier, sorry about that.

I don't think we want to be running through qemu acpi code any more than is necessary when using xen hvm.

#3 lore raw
Quoted 53 lines · Bruce Rogers
Quoted 53 lines
Quoted 1 line
Quoted 1 line · Stefano Stabellini

hw/acpi/piix4.c static void piix4_device_plug_cb(HotplugHandler

Quoted 17 lines · Bruce Rogers

Commit f0c9d64a exposed the issue that with a xenfv machine using pci passthrough, acpi cpi hotplug code was being executed by mistake. Guard calls to acpi_pcihp_device_plug_cb (and corresponding acpi_pcihp_device_unplug_cb) with a check for xen_enabled(). Without this check I am seeing an error that the bus doesn't have the acpi-pcihp-bsel property set.

---
 hw/acpi/piix4.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
hw/acpi/piix4.c +0 -0
index a553a7e..c409374 100644
@@ -385,7 +385,10 @@ static void piix4_device_plug_cb(HotplugHandler 

*hotplug_dev,

hw/acpi/piix4.c static void piix4_device_plug_cb(HotplugHandler *hotplug_dev,

Quoted 4 lines
hw/acpi/piix4.c +0 -1
                                 dev, errp);
         }
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
-        acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev, 

errp);

hw/acpi/piix4.c static void

Quoted 8 lines
hw/acpi/piix4.c +4 -0
+        if (!xen_enabled()) {
+            acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,
+                                      errp);
+        }
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
         if (s->cpu_hotplug_legacy) {
             legacy_acpi_cpu_plug_cb(hotplug_dev, &s->gpe_cpu, dev, errp);
@@ -408,8 +411,10 @@ static void 

piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev,

hw/acpi/piix4.c static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev,

Quoted 7 lines
hw/acpi/piix4.c +2 -2
         acpi_memory_unplug_request_cb(hotplug_dev, &s->acpi_memory_hotplug,
                                       dev, errp);
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
-        acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,
-                                    errp);
+        if (!xen_enabled()) {
+            acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug, 

dev,

hw/acpi/piix4.c static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev, · line 420

Quoted 5 lines
hw/acpi/piix4.c +2 -0
+                                        errp);
+        }
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) &&
                !s->cpu_hotplug_legacy) {
         acpi_cpu_unplug_request_cb(hotplug_dev, &s->cpuhp_state, dev, errp);

Wouldn't it be better to simply turn the error_setg("Unsupported bus...) in acpi_pcihp_device_plug_cb and acpi_pcihp_device_unplug_cb into debug printfs? After all, from this description it is clear that they are not an error conditions. PCI Passthough works correctly, right?

Quoted 4 lines
Quoted 1 line

I realize that I should have suggested this earlier, sorry about that.

I don't think we want to be running through qemu acpi code any more than is necessary when using xen hvm.

Fair enough, but at the same time it is not good to disseminate if (!xen_enabled()) around. I am happy either way, I'll let Michael and Igor decide.

#4 lore raw
In reply to Stefano Stabellini
Quoted 39 lines · On Thu, 27 Apr 2017 14:09:11 -0700 (PDT) Stefano Stabellini…
Quoted 38 lines · Bruce Rogers

Commit f0c9d64a exposed the issue that with a xenfv machine using pci passthrough, acpi cpi hotplug code was being executed by mistake. Guard calls to acpi_pcihp_device_plug_cb (and corresponding acpi_pcihp_device_unplug_cb) with a check for xen_enabled(). Without this check I am seeing an error that the bus doesn't have the acpi-pcihp-bsel property set.

---
 hw/acpi/piix4.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
hw/acpi/piix4.c +8 -3
index a553a7e..c409374 100644
@@ -385,7 +385,10 @@ static void piix4_device_plug_cb(HotplugHandler *hotplug_dev,
                                 dev, errp);
         }
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
-        acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev, errp);
+        if (!xen_enabled()) {
+            acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,
+                                      errp);
+        }
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
         if (s->cpu_hotplug_legacy) {
             legacy_acpi_cpu_plug_cb(hotplug_dev, &s->gpe_cpu, dev, errp);
@@ -408,8 +411,10 @@ static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev,
         acpi_memory_unplug_request_cb(hotplug_dev, &s->acpi_memory_hotplug,
                                       dev, errp);
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
-        acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,
-                                    errp);
+        if (!xen_enabled()) {
+            acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,
+                                        errp);
+        }
Quoted 8 lines

hw/acpi/piix4.c static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev, · line 420

Quoted 3 lines
hw/acpi/piix4.c +0 -0
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) &&
                !s->cpu_hotplug_legacy) {
         acpi_cpu_unplug_request_cb(hotplug_dev, &s->cpuhp_state, dev, errp);  

Wouldn't it be better to simply turn the error_setg("Unsupported bus...) in acpi_pcihp_device_plug_cb and acpi_pcihp_device_unplug_cb into debug printfs? After all, from this description it is clear that they are not an error conditions. PCI Passthough works correctly, right?

it's error condition if acpi hotplug is in use, so we should keep it

Reviewed-by on v1 1/1
#5 lore raw
In reply to Bruce Rogers
Quoted 2 lines · On Thu, 27 Apr 2017 13:59:08 -0600 Bruce Rogers <[email protected]> wrote:

Commit f0c9d64a exposed the issue that with a xenfv machine using pci passthrough, acpi cpi hotplug code was being executed by mistake.

s/cpi/pci/

Quoted 4 lines

Guard calls to acpi_pcihp_device_plug_cb (and corresponding acpi_pcihp_device_unplug_cb) with a check for xen_enabled(). Without this check I am seeing an error that the bus doesn't have the acpi-pcihp-bsel property set.

it would be better to put actual error here.

Quoted 2 lines

with above fixed up

Quoted 33 lines
---
 hw/acpi/piix4.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
hw/acpi/piix4.c +8 -3
index a553a7e..c409374 100644
@@ -385,7 +385,10 @@ static void piix4_device_plug_cb(HotplugHandler *hotplug_dev,
                                 dev, errp);
         }
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
-        acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev, errp);
+        if (!xen_enabled()) {
+            acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,
+                                      errp);
+        }
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
         if (s->cpu_hotplug_legacy) {
             legacy_acpi_cpu_plug_cb(hotplug_dev, &s->gpe_cpu, dev, errp);
@@ -408,8 +411,10 @@ static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev,
         acpi_memory_unplug_request_cb(hotplug_dev, &s->acpi_memory_hotplug,
                                       dev, errp);
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
-        acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,
-                                    errp);
+        if (!xen_enabled()) {
+            acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,
+                                        errp);
+        }
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) &&
                !s->cpu_hotplug_legacy) {
         acpi_cpu_unplug_request_cb(hotplug_dev, &s->cpuhp_state, dev, errp);