Skip to contentSkip to conversation

pci: irq_state vmstate breakage

PATCH In review Michael S. Tsirkin 2 participants 3 messages May 9, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pci: irq_state vmstate breakage

Code for saving irq_state got vm_state
macros wrong, passing in the wrong parameter.
As a result, we both saved a wrong value
and restored it to a wrong offset.

This leads to device and bus irq counts getting
out of sync, which in turn leads to interrupts getting lost or never cleared, such as
https://bugzilla.redhat.com/show_bug.cgi?id=588133

---

Juan, could you please take a look at this patch? I managed to catch this bug by looking at
a savevm image which already has a wrong value, but I could not reproduce it locally so I don't know for sure whether patch is enough, or there are other bugs.

Anthony, this is a regression introduced in
eea4acfa5c1ef26439a718375475fe468b7f2fba
so we need the fix on 0.12 branch as well.

 hw/pci.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hw/pci.c +2 -2
index 95bfa3d..5452b86 100644
@@ -325,7 +325,7 @@ static VMStateInfo vmstate_info_pci_config = {
 
 static int get_pci_irq_state(QEMUFile *f, void *pv, size_t size)
 {
-    PCIDevice *s = container_of(pv, PCIDevice, config);
+    PCIDevice *s = container_of(pv, PCIDevice, irq_state);
     uint32_t irq_state[PCI_NUM_PINS];
     int i;
     for (i = 0; i < PCI_NUM_PINS; ++i) {
@@ -347,7 +347,7 @@ static int get_pci_irq_state(QEMUFile *f, void *pv, size_t size)
 static void put_pci_irq_state(QEMUFile *f, void *pv, size_t size)
 {
     int i;
-    PCIDevice *s = container_of(pv, PCIDevice, config);
+    PCIDevice *s = container_of(pv, PCIDevice, irq_state);
 
     for (i = 0; i < PCI_NUM_PINS; ++i) {
         qemu_put_be32(f, pci_irq_state(s, i));
Signature · 1 line
1.7.1.12.g42b7f
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Michael S. Tsirkin

Code for saving irq_state got vm_state
macros wrong, passing in the wrong parameter.
As a result, we both saved a wrong value
and restored it to a wrong offset.

This leads to device and bus irq counts getting
out of sync, which in turn leads to interrupts getting lost or never cleared, such as
https://bugzilla.redhat.com/show_bug.cgi?id=588133

Code is "obviously" wrong (TM). I didn't catch it when it was introduced. How can it ever have worked since that commit?

Quoted 37 lines

---

Juan, could you please take a look at this patch? I managed to catch this bug by looking at
a savevm image which already has a wrong value, but I could not reproduce it locally so I don't know for sure whether patch is enough, or there are other bugs.

Anthony, this is a regression introduced in
eea4acfa5c1ef26439a718375475fe468b7f2fba
so we need the fix on 0.12 branch as well.

 hw/pci.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hw/pci.c +2 -2
index 95bfa3d..5452b86 100644
@@ -325,7 +325,7 @@ static VMStateInfo vmstate_info_pci_config = {
 
 static int get_pci_irq_state(QEMUFile *f, void *pv, size_t size)
 {
-    PCIDevice *s = container_of(pv, PCIDevice, config);
+    PCIDevice *s = container_of(pv, PCIDevice, irq_state);
     uint32_t irq_state[PCI_NUM_PINS];
     int i;
     for (i = 0; i < PCI_NUM_PINS; ++i) {
@@ -347,7 +347,7 @@ static int get_pci_irq_state(QEMUFile *f, void *pv, size_t size)
 static void put_pci_irq_state(QEMUFile *f, void *pv, size_t size)
 {
     int i;
-    PCIDevice *s = container_of(pv, PCIDevice, config);
+    PCIDevice *s = container_of(pv, PCIDevice, irq_state);
 
     for (i = 0; i < PCI_NUM_PINS; ++i) {
         qemu_put_be32(f, pci_irq_state(s, i));
#2 lore raw
Quoted 11 lines · Juan Quintela
Quoted 10 lines · Michael S. Tsirkin

Code for saving irq_state got vm_state
macros wrong, passing in the wrong parameter.
As a result, we both saved a wrong value
and restored it to a wrong offset.

This leads to device and bus irq counts getting
out of sync, which in turn leads to interrupts getting lost or never cleared, such as
https://bugzilla.redhat.com/show_bug.cgi?id=588133

Quoted 6 lines
Quoted 1 line

Code is "obviously" wrong (TM). I didn't catch it when it was introduced. How can it ever have worked since that commit?

irq_state is often 0, that's why.

Quoted 37 lines
Quoted 37 lines

---

Juan, could you please take a look at this patch? I managed to catch this bug by looking at
a savevm image which already has a wrong value, but I could not reproduce it locally so I don't know for sure whether patch is enough, or there are other bugs.

Anthony, this is a regression introduced in
eea4acfa5c1ef26439a718375475fe468b7f2fba
so we need the fix on 0.12 branch as well.

 hw/pci.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hw/pci.c +2 -2
index 95bfa3d..5452b86 100644
@@ -325,7 +325,7 @@ static VMStateInfo vmstate_info_pci_config = {
 
 static int get_pci_irq_state(QEMUFile *f, void *pv, size_t size)
 {
-    PCIDevice *s = container_of(pv, PCIDevice, config);
+    PCIDevice *s = container_of(pv, PCIDevice, irq_state);
     uint32_t irq_state[PCI_NUM_PINS];
     int i;
     for (i = 0; i < PCI_NUM_PINS; ++i) {
@@ -347,7 +347,7 @@ static int get_pci_irq_state(QEMUFile *f, void *pv, size_t size)
 static void put_pci_irq_state(QEMUFile *f, void *pv, size_t size)
 {
     int i;
-    PCIDevice *s = container_of(pv, PCIDevice, config);
+    PCIDevice *s = container_of(pv, PCIDevice, irq_state);
 
     for (i = 0; i < PCI_NUM_PINS; ++i) {
         qemu_put_be32(f, pci_irq_state(s, i));