Skip to contentSkip to conversation

qemu-kvm: routing table update thinko fix

PATCH Applied Michael S. Tsirkin 2 participants 2 messages Jul 23, 2009 KVM

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 qemu-kvm: routing table update thinko fix

When updating irq routing entries, we should memcpy the new entry over the old one. Current code gets it wrong, and only works because it's uncommon for guests to change tables.

---

Changes since v1:
updated irqchip case as well

 qemu-kvm.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
qemu-kvm.c +2 -2
index 60e5eac..b4de9c6 100644
@@ -1544,7 +1544,7 @@ int kvm_update_routing_entry(kvm_context_t kvm,
         case KVM_IRQ_ROUTING_IRQCHIP:
             if (e->u.irqchip.irqchip == entry->u.irqchip.irqchip &&
                 e->u.irqchip.pin == entry->u.irqchip.pin) {
-                memcpy(&e->u.irqchip, &entry->u.irqchip, sizeof e->u.irqchip);
+                memcpy(&e->u.irqchip, &newentry->u.irqchip, sizeof e->u.irqchip);
                 return 0;
             }
             break;
@@ -1552,7 +1552,7 @@ int kvm_update_routing_entry(kvm_context_t kvm,
             if (e->u.msi.address_lo == entry->u.msi.address_lo &&
                 e->u.msi.address_hi == entry->u.msi.address_hi &&
                 e->u.msi.data == entry->u.msi.data) {
-                memcpy(&e->u.msi, &entry->u.msi, sizeof e->u.msi);
+                memcpy(&e->u.msi, &newentry->u.msi, sizeof e->u.msi);
                 return 0;
             }
             break;
Signature · 1 line
1.6.2.5
#1 lore raw
Quoted 5 lines · Michael S. Tsirkin

When updating irq routing entries, we should memcpy the new entry over the old one. Current code gets it wrong, and only works because it's uncommon for guests to change tables.

Applied, thanks.

Quoted 36 lines

---

Changes since v1:
updated irqchip case as well

 qemu-kvm.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
qemu-kvm.c +2 -2
index 60e5eac..b4de9c6 100644
@@ -1544,7 +1544,7 @@ int kvm_update_routing_entry(kvm_context_t kvm,
         case KVM_IRQ_ROUTING_IRQCHIP:
             if (e->u.irqchip.irqchip == entry->u.irqchip.irqchip &&
                 e->u.irqchip.pin == entry->u.irqchip.pin) {
-                memcpy(&e->u.irqchip, &entry->u.irqchip, sizeof e->u.irqchip);
+                memcpy(&e->u.irqchip, &newentry->u.irqchip, sizeof e->u.irqchip);
                 return 0;
             }
             break;
@@ -1552,7 +1552,7 @@ int kvm_update_routing_entry(kvm_context_t kvm,
             if (e->u.msi.address_lo == entry->u.msi.address_lo &&
                 e->u.msi.address_hi == entry->u.msi.address_hi &&
                 e->u.msi.data == entry->u.msi.data) {
-                memcpy(&e->u.msi, &entry->u.msi, sizeof e->u.msi);
+                memcpy(&e->u.msi, &newentry->u.msi, sizeof e->u.msi);
                 return 0;
             }
             break;
Signature · 5 lines
1.6.2.5
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html