qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/4] s390/kvm: Small fixes for 2.0
@ 2014-03-17 21:38 Christian Borntraeger
  2014-03-17 21:38 ` [Qemu-devel] [PULL 1/4] s390/ipl: Fix error path on BIOS loading Christian Borntraeger
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Christian Borntraeger @ 2014-03-17 21:38 UTC (permalink / raw)
  To: Anthony Liguori, Peter Maydell
  Cc: qemu-devel, Alexander Graf, Christian Borntraeger, Jens Freimann,
	Cornelia Huck, Richard Henderson

The following changes since commit 087edb503afebf184f07078900efc26c73035e98:

  Merge remote-tracking branch 'remotes/bonzini/fixes-for-2.0' into staging (2014-03-17 13:05:48 +0000)

are available in the git repository at:


  git://github.com/borntraeger/qemu.git tags/kvm-s390-20140317

for you to fetch changes up to 4f3ed190a673c0020c3ccebb4882ae4675cb5f4d:

  s390x/sclpconsole-lm: Fix and simplify irq setup (2014-03-17 22:01:19 +0100)

----------------------------------------------------------------
4 small patches:
- Fixing findings of valgrind regarding minor memory leaks:
  Currently we forget the pointer of qemu_allocate_irqs. Since we never
  free the irqs, this is not critical, but obviously not good programming
  style. While we are at it, we dont need the irq infrastructure for
  the sclp consoles.
- Handle new ELF error codes for BIOS loading

----------------------------------------------------------------
Christian Borntraeger (4):
      s390/ipl: Fix error path on BIOS loading
      s390x/cpu hotplug: Fix memory leak
      s390x/sclpconsole: Fix and simplify interrupt injection
      s390x/sclpconsole-lm: Fix and simplify irq setup

 hw/char/sclpconsole-lm.c | 27 ++++-----------------------
 hw/char/sclpconsole.c    | 30 ++++++------------------------
 hw/s390x/ipl.c           |  2 +-
 hw/s390x/sclpcpu.c       |  6 +++---
 4 files changed, 14 insertions(+), 51 deletions(-)

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

* [Qemu-devel] [PULL 1/4] s390/ipl: Fix error path on BIOS loading
  2014-03-17 21:38 [Qemu-devel] [PULL 0/4] s390/kvm: Small fixes for 2.0 Christian Borntraeger
@ 2014-03-17 21:38 ` Christian Borntraeger
  2014-03-17 21:38 ` [Qemu-devel] [PULL 2/4] s390x/cpu hotplug: Fix memory leak Christian Borntraeger
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Christian Borntraeger @ 2014-03-17 21:38 UTC (permalink / raw)
  To: Anthony Liguori, Peter Maydell
  Cc: Alexey Kardashevskiy, qemu-devel, Alexander Graf,
	Christian Borntraeger, Jens Freimann, Cornelia Huck,
	Richard Henderson

commit 18674b26788a9e47f1157170234e32ece2044367
(elf-loader: add more return codes) enabled the elf loader to return
other errors than -1.

Lets also handle that case for our "BIOS" on s390.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
CC: Alexey Kardashevskiy <aik@ozlabs.ru>
CC: Alexander Graf <agraf@suse.de>
---
 hw/s390x/ipl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index 32d38a0..4fa9cff 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -80,7 +80,7 @@ static int s390_ipl_init(SysBusDevice *dev)
 
         bios_size = load_elf(bios_filename, NULL, NULL, &ipl->start_addr, NULL,
                              NULL, 1, ELF_MACHINE, 0);
-        if (bios_size == -1) {
+        if (bios_size < 0) {
             bios_size = load_image_targphys(bios_filename, ZIPL_IMAGE_START,
                                             4096);
             ipl->start_addr = ZIPL_IMAGE_START;
-- 
1.8.4.2

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

* [Qemu-devel] [PULL 2/4] s390x/cpu hotplug: Fix memory leak
  2014-03-17 21:38 [Qemu-devel] [PULL 0/4] s390/kvm: Small fixes for 2.0 Christian Borntraeger
  2014-03-17 21:38 ` [Qemu-devel] [PULL 1/4] s390/ipl: Fix error path on BIOS loading Christian Borntraeger
@ 2014-03-17 21:38 ` Christian Borntraeger
  2014-03-17 21:38 ` [Qemu-devel] [PULL 3/4] s390x/sclpconsole: Fix and simplify interrupt injection Christian Borntraeger
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Christian Borntraeger @ 2014-03-17 21:38 UTC (permalink / raw)
  To: Anthony Liguori, Peter Maydell
  Cc: qemu-devel, Alexander Graf, Christian Borntraeger, Jens Freimann,
	Cornelia Huck, Richard Henderson

valgrind complains about the following:
==42117== 8 bytes in 1 blocks are definitely lost in loss record 88 of 833
==42117==    at 0x4031AFE: malloc (vg_replace_malloc.c:292)
==42117==    by 0x8022F855: malloc_and_trace (vl.c:2715)
==42117==    by 0x4145569: g_malloc (in /usr/lib64/libglib-2.0.so.0.3400.2)
==42117==    by 0x800F696D: qemu_extend_irqs (irq.c:51)
==42117==    by 0x800F6AF7: qemu_allocate_irqs (irq.c:68)
==42117==    by 0x8029FA4B: irq_cpu_hotplug_init (sclpcpu.c:84)
==42117==    by 0x80297C79: event_realize (event-facility.c:386)
==42117==    by 0x80105071: device_set_realized (qdev.c:693)
[...]

Right it is. Don't drop the pointer of the irq.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Jason J. Herne <jjherne@us.ibm.com>
---
 hw/s390x/sclpcpu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/s390x/sclpcpu.c b/hw/s390x/sclpcpu.c
index b9c238a..3600fe2 100644
--- a/hw/s390x/sclpcpu.c
+++ b/hw/s390x/sclpcpu.c
@@ -25,13 +25,13 @@ typedef struct ConfigMgtData {
     uint8_t event_qualifier;
 } QEMU_PACKED ConfigMgtData;
 
-static qemu_irq irq_cpu_hotplug; /* Only used in this file */
+static qemu_irq *irq_cpu_hotplug; /* Only used in this file */
 
 #define EVENT_QUAL_CPU_CHANGE  1
 
 void raise_irq_cpu_hotplug(void)
 {
-    qemu_irq_raise(irq_cpu_hotplug);
+    qemu_irq_raise(*irq_cpu_hotplug);
 }
 
 static unsigned int send_mask(void)
@@ -81,7 +81,7 @@ static void trigger_signal(void *opaque, int n, int level)
 
 static int irq_cpu_hotplug_init(SCLPEvent *event)
 {
-    irq_cpu_hotplug = *qemu_allocate_irqs(trigger_signal, event, 1);
+    irq_cpu_hotplug = qemu_allocate_irqs(trigger_signal, event, 1);
     return 0;
 }
 
-- 
1.8.4.2

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

* [Qemu-devel] [PULL 3/4] s390x/sclpconsole: Fix and simplify interrupt injection
  2014-03-17 21:38 [Qemu-devel] [PULL 0/4] s390/kvm: Small fixes for 2.0 Christian Borntraeger
  2014-03-17 21:38 ` [Qemu-devel] [PULL 1/4] s390/ipl: Fix error path on BIOS loading Christian Borntraeger
  2014-03-17 21:38 ` [Qemu-devel] [PULL 2/4] s390x/cpu hotplug: Fix memory leak Christian Borntraeger
@ 2014-03-17 21:38 ` Christian Borntraeger
  2014-03-17 21:38 ` [Qemu-devel] [PULL 4/4] s390x/sclpconsole-lm: Fix and simplify irq setup Christian Borntraeger
  2014-03-17 22:46 ` [Qemu-devel] [PULL 0/4] s390/kvm: Small fixes for 2.0 Peter Maydell
  4 siblings, 0 replies; 6+ messages in thread
From: Christian Borntraeger @ 2014-03-17 21:38 UTC (permalink / raw)
  To: Anthony Liguori, Peter Maydell
  Cc: qemu-devel, Alexander Graf, Christian Borntraeger, Jens Freimann,
	Cornelia Huck, Richard Henderson

valgrind complains about a memory leak in irq setup of sclpconsole:

==42117== 8 bytes in 1 blocks are definitely lost in loss record 89 of 833
==42117==    at 0x4031AFE: malloc (vg_replace_malloc.c:292)
==42117==    by 0x8022F855: malloc_and_trace (vl.c:2715)
==42117==    by 0x4145569: g_malloc (in /usr/lib64/libglib-2.0.so.0.3400.2)
==42117==    by 0x800F696D: qemu_extend_irqs (irq.c:51)
==42117==    by 0x800F6AF7: qemu_allocate_irqs (irq.c:68)
==42117==    by 0x800F5685: console_init (sclpconsole.c:235)
==42117==    by 0x80297C79: event_realize (event-facility.c:386)
==42117==    by 0x80105071: device_set_realized (qdev.c:693)
==42117==    by 0x801CDC4B: property_set_bool (object.c:1337)
==42117==    by 0x801CBD7F: object_property_set (object.c:819)
[...]

Turns out that we actually dont need the indirection, so trigger the
sclp interrupt directly.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Acked-by: Heinz Graalfs <graalfs@linux.vnet.ibm.com>
---
 hw/char/sclpconsole.c | 30 ++++++------------------------
 1 file changed, 6 insertions(+), 24 deletions(-)

diff --git a/hw/char/sclpconsole.c b/hw/char/sclpconsole.c
index 16d77c5..ce40673 100644
--- a/hw/char/sclpconsole.c
+++ b/hw/char/sclpconsole.c
@@ -36,7 +36,6 @@ typedef struct SCLPConsole {
     uint32_t iov_bs;        /* offset in buf for char layer read operation */
     uint32_t iov_data_len;  /* length of byte stream in buffer             */
     uint32_t iov_sclp_rest; /* length of byte stream not read via SCLP     */
-    qemu_irq irq_read_vt220;
 } SCLPConsole;
 
 /* character layer call-back functions */
@@ -49,11 +48,12 @@ static int chr_can_read(void *opaque)
     return SIZE_BUFFER_VT220 - scon->iov_data_len;
 }
 
-/* Receive n bytes from character layer, save in iov buffer,
- * and set event pending */
-static void receive_from_chr_layer(SCLPConsole *scon, const uint8_t *buf,
-                                   int size)
+/* Send data from a char device over to the guest */
+static void chr_read(void *opaque, const uint8_t *buf, int size)
 {
+    SCLPConsole *scon = opaque;
+
+    assert(scon);
     /* read data must fit into current buffer */
     assert(size <= SIZE_BUFFER_VT220 - scon->iov_data_len);
 
@@ -63,18 +63,7 @@ static void receive_from_chr_layer(SCLPConsole *scon, const uint8_t *buf,
     scon->iov_sclp_rest += size;
     scon->iov_bs += size;
     scon->event.event_pending = true;
-}
-
-/* Send data from a char device over to the guest */
-static void chr_read(void *opaque, const uint8_t *buf, int size)
-{
-    SCLPConsole *scon = opaque;
-
-    assert(scon);
-
-    receive_from_chr_layer(scon, buf, size);
-    /* trigger SCLP read operation */
-    qemu_irq_raise(scon->irq_read_vt220);
+    sclp_service_interrupt(0);
 }
 
 /* functions to be called by event facility */
@@ -192,11 +181,6 @@ static int write_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr)
     return rc;
 }
 
-static void trigger_ascii_console_data(void *opaque, int n, int level)
-{
-    sclp_service_interrupt(0);
-}
-
 static const VMStateDescription vmstate_sclpconsole = {
     .name = "sclpconsole",
     .version_id = 0,
@@ -232,8 +216,6 @@ static int console_init(SCLPEvent *event)
         qemu_chr_add_handlers(scon->chr, chr_can_read,
                               chr_read, NULL, scon);
     }
-    scon->irq_read_vt220 = *qemu_allocate_irqs(trigger_ascii_console_data,
-                                               NULL, 1);
 
     return 0;
 }
-- 
1.8.4.2

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

* [Qemu-devel] [PULL 4/4] s390x/sclpconsole-lm: Fix and simplify irq setup
  2014-03-17 21:38 [Qemu-devel] [PULL 0/4] s390/kvm: Small fixes for 2.0 Christian Borntraeger
                   ` (2 preceding siblings ...)
  2014-03-17 21:38 ` [Qemu-devel] [PULL 3/4] s390x/sclpconsole: Fix and simplify interrupt injection Christian Borntraeger
@ 2014-03-17 21:38 ` Christian Borntraeger
  2014-03-17 22:46 ` [Qemu-devel] [PULL 0/4] s390/kvm: Small fixes for 2.0 Peter Maydell
  4 siblings, 0 replies; 6+ messages in thread
From: Christian Borntraeger @ 2014-03-17 21:38 UTC (permalink / raw)
  To: Anthony Liguori, Peter Maydell
  Cc: qemu-devel, Alexander Graf, Christian Borntraeger, Jens Freimann,
	Cornelia Huck, Richard Henderson

valgrind complains about a memory leak in irq setup of sclpconsole:

==42117== 8 bytes in 1 blocks are definitely lost in loss record 89of 833
==42117==    at 0x4031AFE: malloc (vg_replace_malloc.c:292)
==42117==    by 0x8022F855: malloc_and_trace (vl.c:2715)
==42117==    by 0x4145569: g_malloc (in /usr/lib64/libglib-2.0.so.0.3400.2)
==42117==    by 0x800F696D: qemu_extend_irqs (irq.c:51)
==42117==    by 0x800F6AF7: qemu_allocate_irqs (irq.c:68)
==42117==    by 0x800F5685: console_init (sclpconsole.c:235)
==42117==    by 0x80297C79: event_realize (event-facility.c:386)
==42117==    by 0x80105071: device_set_realized (qdev.c:693)
==42117==    by 0x801CDC4B: property_set_bool (object.c:1337)
 ==42117==    by 0x801CBD7F: object_property_set (object.c:819)
[...]

We dont need the indirection of an qemu irq to inject an slcp interrupt.
Fixes a valgrind error and makes the code simpler.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Acked-by: Heinz Graalfs <graalfs@linux.vnet.ibm.com>
---
 hw/char/sclpconsole-lm.c | 27 ++++-----------------------
 1 file changed, 4 insertions(+), 23 deletions(-)

diff --git a/hw/char/sclpconsole-lm.c b/hw/char/sclpconsole-lm.c
index 9339067..a2dc1c6 100644
--- a/hw/char/sclpconsole-lm.c
+++ b/hw/char/sclpconsole-lm.c
@@ -41,7 +41,6 @@ typedef struct SCLPConsoleLM {
     uint32_t write_errors;      /* errors writing to char layer           */
     uint32_t length;            /* length of byte stream in buffer        */
     uint8_t buf[SIZE_CONSOLE_BUFFER];
-    qemu_irq irq_console_read;
 } SCLPConsoleLM;
 
 /*
@@ -68,13 +67,15 @@ static int chr_can_read(void *opaque)
     return 0;
 }
 
-static void receive_from_chr_layer(SCLPConsoleLM *scon, const uint8_t *buf,
-                                   int size)
+static void chr_read(void *opaque, const uint8_t *buf, int size)
 {
+    SCLPConsoleLM *scon = opaque;
+
     assert(size == 1);
 
     if (*buf == '\r' || *buf == '\n') {
         scon->event.event_pending = true;
+        sclp_service_interrupt(0);
         return;
     }
     scon->buf[scon->length] = *buf;
@@ -84,20 +85,6 @@ static void receive_from_chr_layer(SCLPConsoleLM *scon, const uint8_t *buf,
     }
 }
 
-/*
- * Send data from a char device over to the guest
- */
-static void chr_read(void *opaque, const uint8_t *buf, int size)
-{
-    SCLPConsoleLM *scon = opaque;
-
-    receive_from_chr_layer(scon, buf, size);
-    if (scon->event.event_pending) {
-        /* trigger SCLP read operation */
-        qemu_irq_raise(scon->irq_console_read);
-    }
-}
-
 /* functions to be called by event facility */
 
 static bool can_handle_event(uint8_t type)
@@ -298,11 +285,6 @@ static int write_event_data(SCLPEvent *event, EventBufferHeader *ebh)
     return SCLP_RC_NORMAL_COMPLETION;
 }
 
-static void trigger_console_data(void *opaque, int n, int level)
-{
-    sclp_service_interrupt(0);
-}
-
 /* functions for live migration */
 
 static const VMStateDescription vmstate_sclplmconsole = {
@@ -338,7 +320,6 @@ static int console_init(SCLPEvent *event)
     if (scon->chr) {
         qemu_chr_add_handlers(scon->chr, chr_can_read, chr_read, NULL, scon);
     }
-    scon->irq_console_read = *qemu_allocate_irqs(trigger_console_data, NULL, 1);
 
     return 0;
 }
-- 
1.8.4.2

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

* Re: [Qemu-devel] [PULL 0/4] s390/kvm: Small fixes for 2.0
  2014-03-17 21:38 [Qemu-devel] [PULL 0/4] s390/kvm: Small fixes for 2.0 Christian Borntraeger
                   ` (3 preceding siblings ...)
  2014-03-17 21:38 ` [Qemu-devel] [PULL 4/4] s390x/sclpconsole-lm: Fix and simplify irq setup Christian Borntraeger
@ 2014-03-17 22:46 ` Peter Maydell
  4 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2014-03-17 22:46 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: qemu-devel, Alexander Graf, Jens Freimann, Anthony Liguori,
	Cornelia Huck, Richard Henderson

On 17 March 2014 21:38, Christian Borntraeger <borntraeger@de.ibm.com> wrote:
> The following changes since commit 087edb503afebf184f07078900efc26c73035e98:
>
>   Merge remote-tracking branch 'remotes/bonzini/fixes-for-2.0' into staging (2014-03-17 13:05:48 +0000)
>
> are available in the git repository at:
>
>
>   git://github.com/borntraeger/qemu.git tags/kvm-s390-20140317
>
> for you to fetch changes up to 4f3ed190a673c0020c3ccebb4882ae4675cb5f4d:
>
>   s390x/sclpconsole-lm: Fix and simplify irq setup (2014-03-17 22:01:19 +0100)
>

Applied, thanks.

-- PMM

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

end of thread, other threads:[~2014-03-17 22:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-17 21:38 [Qemu-devel] [PULL 0/4] s390/kvm: Small fixes for 2.0 Christian Borntraeger
2014-03-17 21:38 ` [Qemu-devel] [PULL 1/4] s390/ipl: Fix error path on BIOS loading Christian Borntraeger
2014-03-17 21:38 ` [Qemu-devel] [PULL 2/4] s390x/cpu hotplug: Fix memory leak Christian Borntraeger
2014-03-17 21:38 ` [Qemu-devel] [PULL 3/4] s390x/sclpconsole: Fix and simplify interrupt injection Christian Borntraeger
2014-03-17 21:38 ` [Qemu-devel] [PULL 4/4] s390x/sclpconsole-lm: Fix and simplify irq setup Christian Borntraeger
2014-03-17 22:46 ` [Qemu-devel] [PULL 0/4] s390/kvm: Small fixes for 2.0 Peter Maydell

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).