|
|
9ae3a8 |
From 2dd33300d200746f86301516a7d04800ac96653d Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
Date: Mon, 19 May 2014 09:57:37 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 1/2] kvm: zero-initialize KVM_SET_GSI_ROUTING input
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1400493448-29146-2-git-send-email-mst@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 58948
|
|
|
9ae3a8 |
O-Subject: [PATCH qemu-kvm RHEL7.1 1/2] kvm: zero-initialize KVM_SET_GSI_ROUTING input
|
|
|
9ae3a8 |
Bugzilla: 1098976
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Alex Williamson <alex.williamson@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
kvm_add_routing_entry makes an attempt to
|
|
|
9ae3a8 |
zero-initialize any new routing entry.
|
|
|
9ae3a8 |
However, it fails to initialize padding
|
|
|
9ae3a8 |
within the u field of the structure
|
|
|
9ae3a8 |
kvm_irq_routing_entry.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Other functions like kvm_irqchip_update_msi_route
|
|
|
9ae3a8 |
also fail to initialize the padding field in
|
|
|
9ae3a8 |
kvm_irq_routing_entry.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
It's better to just make sure all input is initialized.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Once it is, we can also drop complex field by field assignment and just
|
|
|
9ae3a8 |
do the simple *a = *b to update a route entry.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Gleb Natapov <gleb@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 0fbc20740342713f282b118b4a446c4c43df3f4a)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
kvm-all.c | 19 +++++++------------
|
|
|
9ae3a8 |
1 file changed, 7 insertions(+), 12 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
kvm-all.c | 19 +++++++------------
|
|
|
9ae3a8 |
1 files changed, 7 insertions(+), 12 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/kvm-all.c b/kvm-all.c
|
|
|
9ae3a8 |
index adc0a8e..592301a 100644
|
|
|
9ae3a8 |
--- a/kvm-all.c
|
|
|
9ae3a8 |
+++ b/kvm-all.c
|
|
|
9ae3a8 |
@@ -988,11 +988,8 @@ static void kvm_add_routing_entry(KVMState *s,
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
n = s->irq_routes->nr++;
|
|
|
9ae3a8 |
new = &s->irq_routes->entries[n];
|
|
|
9ae3a8 |
- memset(new, 0, sizeof(*new));
|
|
|
9ae3a8 |
- new->gsi = entry->gsi;
|
|
|
9ae3a8 |
- new->type = entry->type;
|
|
|
9ae3a8 |
- new->flags = entry->flags;
|
|
|
9ae3a8 |
- new->u = entry->u;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ *new = *entry;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
set_gsi(s, entry->gsi);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -1011,9 +1008,7 @@ static int kvm_update_routing_entry(KVMState *s,
|
|
|
9ae3a8 |
continue;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- entry->type = new_entry->type;
|
|
|
9ae3a8 |
- entry->flags = new_entry->flags;
|
|
|
9ae3a8 |
- entry->u = new_entry->u;
|
|
|
9ae3a8 |
+ *entry = *new_entry;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
kvm_irqchip_commit_routes(s);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -1025,7 +1020,7 @@ static int kvm_update_routing_entry(KVMState *s,
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
void kvm_irqchip_add_irq_route(KVMState *s, int irq, int irqchip, int pin)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- struct kvm_irq_routing_entry e;
|
|
|
9ae3a8 |
+ struct kvm_irq_routing_entry e = {};
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
assert(pin < s->gsi_count);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -1138,7 +1133,7 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg)
|
|
|
9ae3a8 |
return virq;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- route = g_malloc(sizeof(KVMMSIRoute));
|
|
|
9ae3a8 |
+ route = g_malloc0(sizeof(KVMMSIRoute));
|
|
|
9ae3a8 |
route->kroute.gsi = virq;
|
|
|
9ae3a8 |
route->kroute.type = KVM_IRQ_ROUTING_MSI;
|
|
|
9ae3a8 |
route->kroute.flags = 0;
|
|
|
9ae3a8 |
@@ -1159,7 +1154,7 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- struct kvm_irq_routing_entry kroute;
|
|
|
9ae3a8 |
+ struct kvm_irq_routing_entry kroute = {};
|
|
|
9ae3a8 |
int virq;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (!kvm_gsi_routing_enabled()) {
|
|
|
9ae3a8 |
@@ -1185,7 +1180,7 @@ int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- struct kvm_irq_routing_entry kroute;
|
|
|
9ae3a8 |
+ struct kvm_irq_routing_entry kroute = {};
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (!kvm_irqchip_in_kernel()) {
|
|
|
9ae3a8 |
return -ENOSYS;
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|