qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 1.0 0/7] ppc-stable-1.0 patch queue 2012-01-12
@ 2012-01-12 17:35 Alexander Graf
  2012-01-12 17:35 ` [Qemu-devel] [PATCH 1/7] console: Fix segfault on screendump without VGA adapter Alexander Graf
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Alexander Graf @ 2012-01-12 17:35 UTC (permalink / raw)
  To: qemu-devel Developers; +Cc: jmforbes, qemu-stable

Hi Justin,

This is my current patch queue for ppc in stable-1.0. Please pull.

Alex


The following changes since commit 85a4ca797dbe25f27df0a66aa4df1cab63245cd3:
  Justin M. Forbes (1):
        Merge branch 'master' of ssh://git.qemu.org/pub/git/qemu-stable-1.0

are available in the git repository at:

  git://repo.or.cz/qemu/agraf.git ppc-1.0

Alexander Graf (1):
      console: Fix segfault on screendump without VGA adapter

David Gibson (5):
      pseries: Fix array overrun bug in PCI code
      pseries: Emit device tree nodes in reg order
      pseries: Add a routine to find a stable "default" vty and use it
      pseries: Populate "/chosen/linux,stdout-path" in the FDT
      pseries: Don't try to munmap() a malloc()ed TCE table

Liu Yu-B13201 (1):
      kvm-ppc: halt secondary cpus when guest reset

 console.c         |    4 ++-
 hw/ppce500_spin.c |    1 +
 hw/spapr.c        |    2 +
 hw/spapr_pci.c    |    2 +-
 hw/spapr_vio.c    |   84 +++++++++++++++++++++++++++++++++++++++++++++++++---
 hw/spapr_vio.h    |    3 ++
 hw/spapr_vty.c    |   47 ++++++++++++++++++++++++------
 target-ppc/kvm.c  |   14 +++++++--
 8 files changed, 138 insertions(+), 19 deletions(-)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 1/7] console: Fix segfault on screendump without VGA adapter
  2012-01-12 17:35 [Qemu-devel] [PULL 1.0 0/7] ppc-stable-1.0 patch queue 2012-01-12 Alexander Graf
@ 2012-01-12 17:35 ` Alexander Graf
  2012-01-12 17:35 ` [Qemu-devel] [PATCH 2/7] pseries: Fix array overrun bug in PCI code Alexander Graf
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2012-01-12 17:35 UTC (permalink / raw)
  To: qemu-devel Developers; +Cc: jmforbes, qemu-stable

When trying to create a screen dump without having any VGA adapter
inside the guest, QEMU segfaults.

This is because it's trying to switch back to the "previous" screen
it was on before dumping the VGA screen. Unfortunately, in my case
there simply is no previous screen so it accesses a NULL pointer.

Fix it by checking if previous_active_console is actually available.

This is 1.0 material.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 console.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/console.c b/console.c
index f6fe441..ed6a653 100644
--- a/console.c
+++ b/console.c
@@ -186,7 +186,9 @@ void vga_hw_screen_dump(const char *filename)
         consoles[0]->hw_screen_dump(consoles[0]->hw, filename);
     }
 
-    console_select(previous_active_console->index);
+    if (previous_active_console) {
+        console_select(previous_active_console->index);
+    }
 }
 
 void vga_hw_text_update(console_ch_t *chardata)
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 2/7] pseries: Fix array overrun bug in PCI code
  2012-01-12 17:35 [Qemu-devel] [PULL 1.0 0/7] ppc-stable-1.0 patch queue 2012-01-12 Alexander Graf
  2012-01-12 17:35 ` [Qemu-devel] [PATCH 1/7] console: Fix segfault on screendump without VGA adapter Alexander Graf
@ 2012-01-12 17:35 ` Alexander Graf
  2012-01-12 17:35 ` [Qemu-devel] [PATCH 3/7] kvm-ppc: halt secondary cpus when guest reset Alexander Graf
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2012-01-12 17:35 UTC (permalink / raw)
  To: qemu-devel Developers; +Cc: jmforbes, qemu-stable, David Gibson

From: David Gibson <david@gibson.dropbear.id.au>

spapr_populate_pci_devices() containd a loop with PCI_NUM_REGIONS (7)
iterations.  However this overruns the 'bars' global array, which only has
6 elements. In fact we only want to run this loop for things listed in the
bars array, so this patch corrects the loop bounds to reflect that.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
(cherry picked from commit 135712de61dfa22368e98914d65b8b0860ec8505)
---
 hw/spapr_pci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/spapr_pci.c b/hw/spapr_pci.c
index 7162588..9b6a032 100644
--- a/hw/spapr_pci.c
+++ b/hw/spapr_pci.c
@@ -454,7 +454,7 @@ int spapr_populate_pci_devices(sPAPRPHBState *phb,
         reg[0].size = 0;
 
         n = 0;
-        for (i = 0; i < PCI_NUM_REGIONS; ++i) {
+        for (i = 0; i < ARRAY_SIZE(bars); ++i) {
             if (0 == dev->io_regions[i].size) {
                 continue;
             }
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 3/7] kvm-ppc: halt secondary cpus when guest reset
  2012-01-12 17:35 [Qemu-devel] [PULL 1.0 0/7] ppc-stable-1.0 patch queue 2012-01-12 Alexander Graf
  2012-01-12 17:35 ` [Qemu-devel] [PATCH 1/7] console: Fix segfault on screendump without VGA adapter Alexander Graf
  2012-01-12 17:35 ` [Qemu-devel] [PATCH 2/7] pseries: Fix array overrun bug in PCI code Alexander Graf
@ 2012-01-12 17:35 ` Alexander Graf
  2012-01-12 17:35 ` [Qemu-devel] [PATCH 4/7] pseries: Emit device tree nodes in reg order Alexander Graf
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2012-01-12 17:35 UTC (permalink / raw)
  To: qemu-devel Developers; +Cc: Liu Yu, jmforbes, qemu-stable

From: Liu Yu-B13201 <Yu.Liu@freescale.com>

When guest reset, we need to halt secondary cpus until guest kick them.
This already works for tcg. The patch add the support for kvm.

Signed-off-by: Liu Yu <yu.liu@freescale.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
[agraf: remove in-kernel irqchip code]
(cherry picked from commit 157feeadbaec09fe4dca539a24f6f6d327d6eeb6)
---
 hw/ppce500_spin.c |    1 +
 target-ppc/kvm.c  |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/hw/ppce500_spin.c b/hw/ppce500_spin.c
index cccd940..2b52728 100644
--- a/hw/ppce500_spin.c
+++ b/hw/ppce500_spin.c
@@ -112,6 +112,7 @@ static void spin_kick(void *data)
 
     env->halted = 0;
     env->exception_index = -1;
+    env->stopped = 0;
     qemu_cpu_kick(env);
 }
 
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 429349f..9b2e605 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -504,7 +504,7 @@ void kvm_arch_post_run(CPUState *env, struct kvm_run *run)
 
 int kvm_arch_process_async_events(CPUState *env)
 {
-    return 0;
+    return env->halted;
 }
 
 static int kvmppc_handle_halt(CPUState *env)
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 4/7] pseries: Emit device tree nodes in reg order
  2012-01-12 17:35 [Qemu-devel] [PULL 1.0 0/7] ppc-stable-1.0 patch queue 2012-01-12 Alexander Graf
                   ` (2 preceding siblings ...)
  2012-01-12 17:35 ` [Qemu-devel] [PATCH 3/7] kvm-ppc: halt secondary cpus when guest reset Alexander Graf
@ 2012-01-12 17:35 ` Alexander Graf
  2012-01-12 17:35 ` [Qemu-devel] [PATCH 5/7] pseries: Add a routine to find a stable "default" vty and use it Alexander Graf
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2012-01-12 17:35 UTC (permalink / raw)
  To: qemu-devel Developers
  Cc: Michael Ellerman, jmforbes, qemu-stable, David Gibson

From: David Gibson <david@gibson.dropbear.id.au>

Although in theory the device tree has no inherent ordering, in practice
the order of nodes in the device tree does effect the order that devices
are detected by software.

Currently the ordering is determined by the order the devices appear on
the QEMU command line. Although that does give the user control over the
ordering, it is fragile, especially when the user does not generate the
command line manually - eg. when using libvirt etc.

So order the device tree based on the reg value, ie. the address of on
the VIO bus of the devices. This gives us a sane and stable ordering.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>

[agraf] add braces
(cherry picked from commit 05c194384f836240ea4c2da5fa3be43a54bff021)
---
 hw/spapr_vio.c |   50 +++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 45 insertions(+), 5 deletions(-)

diff --git a/hw/spapr_vio.c b/hw/spapr_vio.c
index 2dcc036..8bd00ca 100644
--- a/hw/spapr_vio.c
+++ b/hw/spapr_vio.c
@@ -749,21 +749,61 @@ static void spapr_vio_register_devices(void)
 device_init(spapr_vio_register_devices)
 
 #ifdef CONFIG_FDT
+static int compare_reg(const void *p1, const void *p2)
+{
+    VIOsPAPRDevice const *dev1, *dev2;
+
+    dev1 = (VIOsPAPRDevice *)*(DeviceState **)p1;
+    dev2 = (VIOsPAPRDevice *)*(DeviceState **)p2;
+
+    if (dev1->reg < dev2->reg) {
+        return -1;
+    }
+    if (dev1->reg == dev2->reg) {
+        return 0;
+    }
+
+    /* dev1->reg > dev2->reg */
+    return 1;
+}
+
 int spapr_populate_vdevice(VIOsPAPRBus *bus, void *fdt)
 {
-    DeviceState *qdev;
-    int ret = 0;
+    DeviceState *qdev, **qdevs;
+    int i, num, ret = 0;
 
+    /* Count qdevs on the bus list */
+    num = 0;
     QTAILQ_FOREACH(qdev, &bus->bus.children, sibling) {
-        VIOsPAPRDevice *dev = (VIOsPAPRDevice *)qdev;
+        num++;
+    }
+
+    /* Copy out into an array of pointers */
+    qdevs = g_malloc(sizeof(qdev) * num);
+    num = 0;
+    QTAILQ_FOREACH(qdev, &bus->bus.children, sibling) {
+        qdevs[num++] = qdev;
+    }
+
+    /* Sort the array */
+    qsort(qdevs, num, sizeof(qdev), compare_reg);
+
+    /* Hack alert. Give the devices to libfdt in reverse order, we happen
+     * to know that will mean they are in forward order in the tree. */
+    for (i = num - 1; i >= 0; i--) {
+        VIOsPAPRDevice *dev = (VIOsPAPRDevice *)(qdevs[i]);
 
         ret = vio_make_devnode(dev, fdt);
 
         if (ret < 0) {
-            return ret;
+            goto out;
         }
     }
 
-    return 0;
+    ret = 0;
+out:
+    free(qdevs);
+
+    return ret;
 }
 #endif /* CONFIG_FDT */
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 5/7] pseries: Add a routine to find a stable "default" vty and use it
  2012-01-12 17:35 [Qemu-devel] [PULL 1.0 0/7] ppc-stable-1.0 patch queue 2012-01-12 Alexander Graf
                   ` (3 preceding siblings ...)
  2012-01-12 17:35 ` [Qemu-devel] [PATCH 4/7] pseries: Emit device tree nodes in reg order Alexander Graf
@ 2012-01-12 17:35 ` Alexander Graf
  2012-01-12 17:35 ` [Qemu-devel] [PATCH 6/7] pseries: Populate "/chosen/linux, stdout-path" in the FDT Alexander Graf
  2012-01-12 17:35 ` [Qemu-devel] [PATCH 7/7] pseries: Don't try to munmap() a malloc()ed TCE table Alexander Graf
  6 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2012-01-12 17:35 UTC (permalink / raw)
  To: qemu-devel Developers
  Cc: Michael Ellerman, jmforbes, qemu-stable, David Gibson

From: David Gibson <david@gibson.dropbear.id.au>

In vty_lookup() we have a special case for supporting early debug in
the kernel. This accepts reg == 0 as a special case to mean "any vty".

We implement this by searching the vtys on the bus and returning the
first we find. This means that the vty we chose depends on the order
the vtys are specified on the QEMU command line - because that determines
the order of the vtys on the bus.

We'd rather the command line order was irrelevant, so instead return
the vty with the lowest reg value. This is still a guess as to what the
user really means, but it is at least stable WRT command line ordering.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>

[agraf] fix braces
(cherry picked from commit 98331f8ad6a3e2cfbb402d72e6be47eac7706251)
---
 hw/spapr_vty.c |   47 ++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 38 insertions(+), 9 deletions(-)

diff --git a/hw/spapr_vty.c b/hw/spapr_vty.c
index f23cc36..e2fec58 100644
--- a/hw/spapr_vty.c
+++ b/hw/spapr_vty.c
@@ -156,24 +156,53 @@ static VIOsPAPRDeviceInfo spapr_vty = {
     },
 };
 
+static VIOsPAPRDevice *spapr_vty_get_default(VIOsPAPRBus *bus)
+{
+    VIOsPAPRDevice *sdev, *selected;
+    DeviceState *iter;
+
+    /*
+     * To avoid the console bouncing around we want one VTY to be
+     * the "default". We haven't really got anything to go on, so
+     * arbitrarily choose the one with the lowest reg value.
+     */
+
+    selected = NULL;
+    QTAILQ_FOREACH(iter, &bus->bus.children, sibling) {
+        /* Only look at VTY devices */
+        if (iter->info != &spapr_vty.qdev) {
+            continue;
+        }
+
+        sdev = DO_UPCAST(VIOsPAPRDevice, qdev, iter);
+
+        /* First VTY we've found, so it is selected for now */
+        if (!selected) {
+            selected = sdev;
+            continue;
+        }
+
+        /* Choose VTY with lowest reg value */
+        if (sdev->reg < selected->reg) {
+            selected = sdev;
+        }
+    }
+
+    return selected;
+}
+
 static VIOsPAPRDevice *vty_lookup(sPAPREnvironment *spapr, target_ulong reg)
 {
     VIOsPAPRDevice *sdev;
 
     sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
     if (!sdev && reg == 0) {
-        DeviceState *qdev;
-
         /* Hack for kernel early debug, which always specifies reg==0.
-         * We search all VIO devices, and grab the first available vty
-         * device.  This attempts to mimic existing PowerVM behaviour
+         * We search all VIO devices, and grab the vty with the lowest
+         * reg.  This attempts to mimic existing PowerVM behaviour
          * (early debug does work there, despite having no vty with
          * reg==0. */
-        QTAILQ_FOREACH(qdev, &spapr->vio_bus->bus.children, sibling) {
-            if (qdev->info == &spapr_vty.qdev) {
-                return DO_UPCAST(VIOsPAPRDevice, qdev, qdev);
-            }
-        }
+        return spapr_vty_get_default(spapr->vio_bus);
     }
 
     return sdev;
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 6/7] pseries: Populate "/chosen/linux, stdout-path" in the FDT
  2012-01-12 17:35 [Qemu-devel] [PULL 1.0 0/7] ppc-stable-1.0 patch queue 2012-01-12 Alexander Graf
                   ` (4 preceding siblings ...)
  2012-01-12 17:35 ` [Qemu-devel] [PATCH 5/7] pseries: Add a routine to find a stable "default" vty and use it Alexander Graf
@ 2012-01-12 17:35 ` Alexander Graf
  2012-01-12 17:35 ` [Qemu-devel] [PATCH 7/7] pseries: Don't try to munmap() a malloc()ed TCE table Alexander Graf
  6 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2012-01-12 17:35 UTC (permalink / raw)
  To: qemu-devel Developers
  Cc: Michael Ellerman, jmforbes, qemu-stable, David Gibson

From: David Gibson <david@gibson.dropbear.id.au>

There is a device tree property "/chosen/linux,stdout-path" which indicates
which device should be used as stdout - ie. "the console".

Currently we don't specify anything, which means both firmware and Linux
choose something arbitrarily. Use the routine we added in the last patch
to pick a default vty and specify it as stdout.

Currently SLOF doesn't use the property, but we are hoping to update it
to do so.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
(cherry picked from commit 68f3a94c64bbaaf8c7f2daa70de1b5d87a432f86)
---
 hw/spapr.c     |    2 ++
 hw/spapr_vio.c |   34 ++++++++++++++++++++++++++++++++++
 hw/spapr_vio.h |    3 +++
 hw/spapr_vty.c |    2 +-
 4 files changed, 40 insertions(+), 1 deletions(-)

diff --git a/hw/spapr.c b/hw/spapr.c
index 2b901f1..5a98d86 100644
--- a/hw/spapr.c
+++ b/hw/spapr.c
@@ -351,6 +351,8 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr,
         fprintf(stderr, "Couldn't set up RTAS device tree properties\n");
     }
 
+    spapr_populate_chosen_stdout(fdt, spapr->vio_bus);
+
     _FDT((fdt_pack(fdt)));
 
     cpu_physical_memory_write(fdt_addr, fdt, fdt_totalsize(fdt));
diff --git a/hw/spapr_vio.c b/hw/spapr_vio.c
index 8bd00ca..464fe87 100644
--- a/hw/spapr_vio.c
+++ b/hw/spapr_vio.c
@@ -806,4 +806,38 @@ out:
 
     return ret;
 }
+
+int spapr_populate_chosen_stdout(void *fdt, VIOsPAPRBus *bus)
+{
+    VIOsPAPRDevice *dev;
+    char *name, *path;
+    int ret, offset;
+
+    dev = spapr_vty_get_default(bus);
+    if (!dev)
+        return 0;
+
+    offset = fdt_path_offset(fdt, "/chosen");
+    if (offset < 0) {
+        return offset;
+    }
+
+    name = vio_format_dev_name(dev);
+    if (!name) {
+        return -ENOMEM;
+    }
+
+    if (asprintf(&path, "/vdevice/%s", name) < 0) {
+        path = NULL;
+        ret = -ENOMEM;
+        goto out;
+    }
+
+    ret = fdt_setprop_string(fdt, offset, "linux,stdout-path", path);
+out:
+    free(name);
+    free(path);
+
+    return ret;
+}
 #endif /* CONFIG_FDT */
diff --git a/hw/spapr_vio.h b/hw/spapr_vio.h
index a325a5f..9fcd304 100644
--- a/hw/spapr_vio.h
+++ b/hw/spapr_vio.h
@@ -83,6 +83,7 @@ extern VIOsPAPRBus *spapr_vio_bus_init(void);
 extern VIOsPAPRDevice *spapr_vio_find_by_reg(VIOsPAPRBus *bus, uint32_t reg);
 extern void spapr_vio_bus_register_withprop(VIOsPAPRDeviceInfo *info);
 extern int spapr_populate_vdevice(VIOsPAPRBus *bus, void *fdt);
+extern int spapr_populate_chosen_stdout(void *fdt, VIOsPAPRBus *bus);
 
 extern int spapr_vio_signal(VIOsPAPRDevice *dev, target_ulong mode);
 
@@ -108,6 +109,8 @@ void spapr_vty_create(VIOsPAPRBus *bus, uint32_t reg, CharDriverState *chardev);
 void spapr_vlan_create(VIOsPAPRBus *bus, uint32_t reg, NICInfo *nd);
 void spapr_vscsi_create(VIOsPAPRBus *bus, uint32_t reg);
 
+VIOsPAPRDevice *spapr_vty_get_default(VIOsPAPRBus *bus);
+
 int spapr_tce_set_bypass(uint32_t unit, uint32_t enable);
 void spapr_vio_quiesce(void);
 
diff --git a/hw/spapr_vty.c b/hw/spapr_vty.c
index e2fec58..386ccf7 100644
--- a/hw/spapr_vty.c
+++ b/hw/spapr_vty.c
@@ -156,7 +156,7 @@ static VIOsPAPRDeviceInfo spapr_vty = {
     },
 };
 
-static VIOsPAPRDevice *spapr_vty_get_default(VIOsPAPRBus *bus)
+VIOsPAPRDevice *spapr_vty_get_default(VIOsPAPRBus *bus)
 {
     VIOsPAPRDevice *sdev, *selected;
     DeviceState *iter;
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 7/7] pseries: Don't try to munmap() a malloc()ed TCE table
  2012-01-12 17:35 [Qemu-devel] [PULL 1.0 0/7] ppc-stable-1.0 patch queue 2012-01-12 Alexander Graf
                   ` (5 preceding siblings ...)
  2012-01-12 17:35 ` [Qemu-devel] [PATCH 6/7] pseries: Populate "/chosen/linux, stdout-path" in the FDT Alexander Graf
@ 2012-01-12 17:35 ` Alexander Graf
  6 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2012-01-12 17:35 UTC (permalink / raw)
  To: qemu-devel Developers; +Cc: jmforbes, qemu-stable, David Gibson

From: David Gibson <david@gibson.dropbear.id.au>

For the pseries machine, TCE (IOMMU) tables can either be directly
malloc()ed in qemu or, when running on a KVM which supports it, mmap()ed
from a KVM ioctl.  The latter option is used when available, because it
allows the (frequent bottlenext) H_PUT_TCE hypercall to be KVM accelerated.
However, even when KVM is persent, TCE acceleration is not always possible.
Only KVM HV supports this ioctl(), not KVM PR, or the kernel could run out
of contiguous memory to allocate the new table.  In this case we need to
fall back on the malloc()ed table.

When a device is removed, and we need to remove the TCE table, we need to
either munmap() or free() the table as appropriate for how it was
allocated.  The code is supposed to do that, but we buggily fail to
initialize the tcet->fd variable in the malloc() case, which is used as a
flag to determine which is the right choice.

This patch fixes the bug, and cleans up error messages relating to this
path while we're at it.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 target-ppc/kvm.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 9b2e605..0410901 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -838,12 +838,18 @@ void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t window_size, int *pfd)
     int fd;
     void *table;
 
+    /* Must set fd to -1 so we don't try to munmap when called for
+     * destroying the table, which the upper layers -will- do
+     */
+    *pfd = -1;
     if (!cap_spapr_tce) {
         return NULL;
     }
 
     fd = kvm_vm_ioctl(kvm_state, KVM_CREATE_SPAPR_TCE, &args);
     if (fd < 0) {
+        fprintf(stderr, "KVM: Failed to create TCE table for liobn 0x%x\n",
+                liobn);
         return NULL;
     }
 
@@ -852,6 +858,8 @@ void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t window_size, int *pfd)
 
     table = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
     if (table == MAP_FAILED) {
+        fprintf(stderr, "KVM: Failed to map TCE table for liobn 0x%x\n",
+                liobn);
         close(fd);
         return NULL;
     }
@@ -871,8 +879,8 @@ int kvmppc_remove_spapr_tce(void *table, int fd, uint32_t window_size)
     len = (window_size / SPAPR_VIO_TCE_PAGE_SIZE)*sizeof(VIOsPAPR_RTCE);
     if ((munmap(table, len) < 0) ||
         (close(fd) < 0)) {
-        fprintf(stderr, "KVM: Unexpected error removing KVM SPAPR TCE "
-                "table: %s", strerror(errno));
+        fprintf(stderr, "KVM: Unexpected error removing TCE table: %s",
+                strerror(errno));
         /* Leak the table */
     }
 
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-01-12 17:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-12 17:35 [Qemu-devel] [PULL 1.0 0/7] ppc-stable-1.0 patch queue 2012-01-12 Alexander Graf
2012-01-12 17:35 ` [Qemu-devel] [PATCH 1/7] console: Fix segfault on screendump without VGA adapter Alexander Graf
2012-01-12 17:35 ` [Qemu-devel] [PATCH 2/7] pseries: Fix array overrun bug in PCI code Alexander Graf
2012-01-12 17:35 ` [Qemu-devel] [PATCH 3/7] kvm-ppc: halt secondary cpus when guest reset Alexander Graf
2012-01-12 17:35 ` [Qemu-devel] [PATCH 4/7] pseries: Emit device tree nodes in reg order Alexander Graf
2012-01-12 17:35 ` [Qemu-devel] [PATCH 5/7] pseries: Add a routine to find a stable "default" vty and use it Alexander Graf
2012-01-12 17:35 ` [Qemu-devel] [PATCH 6/7] pseries: Populate "/chosen/linux, stdout-path" in the FDT Alexander Graf
2012-01-12 17:35 ` [Qemu-devel] [PATCH 7/7] pseries: Don't try to munmap() a malloc()ed TCE table Alexander Graf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).