All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/3] Fix VMSTATE_BUFFER_UNSAFE macro usage
@ 2013-03-10 13:47 Igor Mitsyanko
  2013-03-10 13:47 ` [Qemu-devel] [PATCH 1/3] vmstate.h: introduce VMSTATE_BUFFER_POINTER_UNSAFE macro Igor Mitsyanko
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Igor Mitsyanko @ 2013-03-10 13:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, i.mitsyanko, andrew, michael, paul, anthony

hw/sd.c and hw/onenand.c were wrongly using VMSTATE_BUFFER_UNSAFE for dynamically
allocated buffer migration, this was causing memory corruption. 
Use VMSTATE_BUFFER_POINTER_UNSAFE (wich has an additional VMS_POINTER flag set) instead.

Not sure what to do with vmstate version for his devices, should I bump it? Migration
was never working for them anyway.

Only tested hw/sd.c, by saving/loading a snapshot of VM while it was playing videofile
from SD card.

Igor Mitsyanko (3):
  vmstate.h: introduce VMSTATE_BUFFER_POINTER_UNSAFE macro
  hw/sd.c: fix migration of dynamically allocated buffer "buf"
  hw/onenand.c: fix migration of dynamically allocated buffer "otp"

 hw/onenand.c                |    3 ++-
 hw/sd.c                     |    2 +-
 include/migration/vmstate.h |    9 +++++++++
 3 files changed, 12 insertions(+), 2 deletions(-)

-- 
1.7.5.4

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

* [Qemu-devel] [PATCH 1/3] vmstate.h: introduce VMSTATE_BUFFER_POINTER_UNSAFE macro
  2013-03-10 13:47 [Qemu-devel] [PATCH 0/3] Fix VMSTATE_BUFFER_UNSAFE macro usage Igor Mitsyanko
@ 2013-03-10 13:47 ` Igor Mitsyanko
  2013-03-10 13:47 ` [Qemu-devel] [PATCH 2/3] hw/sd.c: fix migration of dynamically allocated buffer "buf" Igor Mitsyanko
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Igor Mitsyanko @ 2013-03-10 13:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, i.mitsyanko, andrew, michael, paul, anthony

Macro could be used to migrate a dynamically allocated buffer of known size.

Signed-off-by: Igor Mitsyanko <i.mitsyanko@gmail.com>
---
 include/migration/vmstate.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index f27276c..e127ed8 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -404,6 +404,15 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset     = offsetof(_state, _field),                          \
 }
 
+#define VMSTATE_BUFFER_POINTER_UNSAFE(_field, _state, _version, _size) { \
+    .name       = (stringify(_field)),                               \
+    .version_id = (_version),                                        \
+    .size       = (_size),                                           \
+    .info       = &vmstate_info_buffer,                              \
+    .flags      = VMS_BUFFER|VMS_POINTER,                            \
+    .offset     = offsetof(_state, _field),                          \
+}
+
 #define VMSTATE_UNUSED_BUFFER(_test, _version, _size) {              \
     .name         = "unused",                                        \
     .field_exists = (_test),                                         \
-- 
1.7.5.4

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

* [Qemu-devel] [PATCH 2/3] hw/sd.c: fix migration of dynamically allocated buffer "buf"
  2013-03-10 13:47 [Qemu-devel] [PATCH 0/3] Fix VMSTATE_BUFFER_UNSAFE macro usage Igor Mitsyanko
  2013-03-10 13:47 ` [Qemu-devel] [PATCH 1/3] vmstate.h: introduce VMSTATE_BUFFER_POINTER_UNSAFE macro Igor Mitsyanko
@ 2013-03-10 13:47 ` Igor Mitsyanko
  2013-03-18 18:33   ` Michael Walle
  2013-03-10 13:47 ` [Qemu-devel] [PATCH 3/3] hw/onenand.c: fix migration of dynamically allocated buffer "otp" Igor Mitsyanko
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Igor Mitsyanko @ 2013-03-10 13:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, i.mitsyanko, andrew, michael, paul, anthony

VMSTATE_BUFFER_UNSAFE should be used for buffers inlined in device state, not
for buffers allocated dynamically. Change to VMSTATE_BUFFER_POINTER_UNSAFE macro,
which will do migration right.

Signed-off-by: Igor Mitsyanko <i.mitsyanko@gmail.com>
---
 hw/sd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/sd.c b/hw/sd.c
index 428bd78..88eaaf8 100644
--- a/hw/sd.c
+++ b/hw/sd.c
@@ -478,7 +478,7 @@ static const VMStateDescription sd_vmstate = {
         VMSTATE_UINT64(data_start, SDState),
         VMSTATE_UINT32(data_offset, SDState),
         VMSTATE_UINT8_ARRAY(data, SDState, 512),
-        VMSTATE_BUFFER_UNSAFE(buf, SDState, 1, 512),
+        VMSTATE_BUFFER_POINTER_UNSAFE(buf, SDState, 1, 512),
         VMSTATE_BOOL(enable, SDState),
         VMSTATE_END_OF_LIST()
     }
-- 
1.7.5.4

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

* [Qemu-devel] [PATCH 3/3] hw/onenand.c: fix migration of dynamically allocated buffer "otp"
  2013-03-10 13:47 [Qemu-devel] [PATCH 0/3] Fix VMSTATE_BUFFER_UNSAFE macro usage Igor Mitsyanko
  2013-03-10 13:47 ` [Qemu-devel] [PATCH 1/3] vmstate.h: introduce VMSTATE_BUFFER_POINTER_UNSAFE macro Igor Mitsyanko
  2013-03-10 13:47 ` [Qemu-devel] [PATCH 2/3] hw/sd.c: fix migration of dynamically allocated buffer "buf" Igor Mitsyanko
@ 2013-03-10 13:47 ` Igor Mitsyanko
  2013-03-15 17:12 ` [Qemu-devel] [PATCH 0/3] Fix VMSTATE_BUFFER_UNSAFE macro usage Peter Maydell
  2013-03-18 16:19 ` Peter Maydell
  4 siblings, 0 replies; 8+ messages in thread
From: Igor Mitsyanko @ 2013-03-10 13:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, i.mitsyanko, andrew, michael, paul, anthony

VMSTATE_BUFFER_UNSAFE should be used for buffers inlined in device state, not
for buffers allocated dynamically. Change to VMSTATE_BUFFER_POINTER_UNSAFE macro,
which will do migration right.

Signed-off-by: Igor Mitsyanko <i.mitsyanko@gmail.com>
---
 hw/onenand.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/hw/onenand.c b/hw/onenand.c
index 00a8738..12ccb67f 100644
--- a/hw/onenand.c
+++ b/hw/onenand.c
@@ -185,7 +185,8 @@ static const VMStateDescription vmstate_onenand = {
         VMSTATE_UINT8(ecc.cp, OneNANDState),
         VMSTATE_UINT16_ARRAY(ecc.lp, OneNANDState, 2),
         VMSTATE_UINT16(ecc.count, OneNANDState),
-        VMSTATE_BUFFER_UNSAFE(otp, OneNANDState, 0, ((64 + 2) << PAGE_SHIFT)),
+        VMSTATE_BUFFER_POINTER_UNSAFE(otp, OneNANDState, 0,
+            ((64 + 2) << PAGE_SHIFT)),
         VMSTATE_END_OF_LIST()
     }
 };
-- 
1.7.5.4

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

* Re: [Qemu-devel] [PATCH 0/3] Fix VMSTATE_BUFFER_UNSAFE macro usage
  2013-03-10 13:47 [Qemu-devel] [PATCH 0/3] Fix VMSTATE_BUFFER_UNSAFE macro usage Igor Mitsyanko
                   ` (2 preceding siblings ...)
  2013-03-10 13:47 ` [Qemu-devel] [PATCH 3/3] hw/onenand.c: fix migration of dynamically allocated buffer "otp" Igor Mitsyanko
@ 2013-03-15 17:12 ` Peter Maydell
       [not found]   ` <51435829.5020106@gmail.com>
  2013-03-18 16:19 ` Peter Maydell
  4 siblings, 1 reply; 8+ messages in thread
From: Peter Maydell @ 2013-03-15 17:12 UTC (permalink / raw)
  To: Igor Mitsyanko; +Cc: Juan Quintela, qemu-devel, andrew, michael, paul, anthony

On 10 March 2013 13:47, Igor Mitsyanko <i.mitsyanko@gmail.com> wrote:
> hw/sd.c and hw/onenand.c were wrongly using VMSTATE_BUFFER_UNSAFE for dynamically
> allocated buffer migration, this was causing memory corruption.
> Use VMSTATE_BUFFER_POINTER_UNSAFE (wich has an additional VMS_POINTER flag set) instead.
>
> Not sure what to do with vmstate version for his devices, should I bump it? Migration
> was never working for them anyway.
>
> Only tested hw/sd.c, by saving/loading a snapshot of VM while it was playing videofile
> from SD card.

Cc'ing Juan in case he wants to comment on the vmstate changes.

-- PMM

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

* Re: [Qemu-devel] [PATCH 0/3] Fix VMSTATE_BUFFER_UNSAFE macro usage
       [not found]   ` <51435829.5020106@gmail.com>
@ 2013-03-15 17:23     ` Igor Mitsyanko
  0 siblings, 0 replies; 8+ messages in thread
From: Igor Mitsyanko @ 2013-03-15 17:23 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Juan Quintela, qemu-devel, michael, paul, anthony

[-- Attachment #1: Type: text/plain, Size: 861 bytes --]

> On 03/15/2013 09:12 PM, Peter Maydell wrote:
>
>> On 10 March 2013 13:47, Igor Mitsyanko <i.mitsyanko@gmail.com> wrote:
>>
>>> hw/sd.c and hw/onenand.c were wrongly using VMSTATE_BUFFER_UNSAFE for
>>> dynamically
>>> allocated buffer migration, this was causing memory corruption.
>>> Use VMSTATE_BUFFER_POINTER_UNSAFE (wich has an additional VMS_POINTER
>>> flag set) instead.
>>>
>>> Not sure what to do with vmstate version for his devices, should I bump
>>> it? Migration
>>> was never working for them anyway.
>>>
>>> Only tested hw/sd.c, by saving/loading a snapshot of VM while it was
>>> playing videofile
>>> from SD card.
>>>
>> Cc'ing Juan in case he wants to comment on the vmstate changes.
>>
>> -- PMM
>>
>
Thanks, Peter. Also cc'ing Andrzej Zaborowski using a (correct) address
from MAINTAINERS, because the one in hw/onenand.c is not working.

[-- Attachment #2: Type: text/html, Size: 1401 bytes --]

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

* Re: [Qemu-devel] [PATCH 0/3] Fix VMSTATE_BUFFER_UNSAFE macro usage
  2013-03-10 13:47 [Qemu-devel] [PATCH 0/3] Fix VMSTATE_BUFFER_UNSAFE macro usage Igor Mitsyanko
                   ` (3 preceding siblings ...)
  2013-03-15 17:12 ` [Qemu-devel] [PATCH 0/3] Fix VMSTATE_BUFFER_UNSAFE macro usage Peter Maydell
@ 2013-03-18 16:19 ` Peter Maydell
  4 siblings, 0 replies; 8+ messages in thread
From: Peter Maydell @ 2013-03-18 16:19 UTC (permalink / raw)
  To: Igor Mitsyanko
  Cc: Juan Quintela, qemu-devel, Andrzej Zaborowski, michael, paul, anthony

On 10 March 2013 13:47, Igor Mitsyanko <i.mitsyanko@gmail.com> wrote:
> hw/sd.c and hw/onenand.c were wrongly using VMSTATE_BUFFER_UNSAFE for dynamically
> allocated buffer migration, this was causing memory corruption.
> Use VMSTATE_BUFFER_POINTER_UNSAFE (wich has an additional VMS_POINTER flag set) instead.
>
> Not sure what to do with vmstate version for his devices, should I bump it? Migration
> was never working for them anyway.
>
> Only tested hw/sd.c, by saving/loading a snapshot of VM while it was playing videofile
> from SD card.
>
> Igor Mitsyanko (3):
>   vmstate.h: introduce VMSTATE_BUFFER_POINTER_UNSAFE macro
>   hw/sd.c: fix migration of dynamically allocated buffer "buf"
>   hw/onenand.c: fix migration of dynamically allocated buffer "otp"

Whole series:
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

-- PMM

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

* Re: [Qemu-devel] [PATCH 2/3] hw/sd.c: fix migration of dynamically allocated buffer "buf"
  2013-03-10 13:47 ` [Qemu-devel] [PATCH 2/3] hw/sd.c: fix migration of dynamically allocated buffer "buf" Igor Mitsyanko
@ 2013-03-18 18:33   ` Michael Walle
  0 siblings, 0 replies; 8+ messages in thread
From: Michael Walle @ 2013-03-18 18:33 UTC (permalink / raw)
  To: Igor Mitsyanko; +Cc: andrew, paul, qemu-devel, anthony, peter.maydell

Am Sonntag 10 März 2013, 14:47:57 schrieb Igor Mitsyanko:
> VMSTATE_BUFFER_UNSAFE should be used for buffers inlined in device state,
> not for buffers allocated dynamically. Change to
> VMSTATE_BUFFER_POINTER_UNSAFE macro, which will do migration right.
> 
> Signed-off-by: Igor Mitsyanko <i.mitsyanko@gmail.com>
> ---
>  hw/sd.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/hw/sd.c b/hw/sd.c
> index 428bd78..88eaaf8 100644
> --- a/hw/sd.c
> +++ b/hw/sd.c
> @@ -478,7 +478,7 @@ static const VMStateDescription sd_vmstate = {
>          VMSTATE_UINT64(data_start, SDState),
>          VMSTATE_UINT32(data_offset, SDState),
>          VMSTATE_UINT8_ARRAY(data, SDState, 512),
> -        VMSTATE_BUFFER_UNSAFE(buf, SDState, 1, 512),
> +        VMSTATE_BUFFER_POINTER_UNSAFE(buf, SDState, 1, 512),
>          VMSTATE_BOOL(enable, SDState),
>          VMSTATE_END_OF_LIST()
>      }

Tested-by: Michael Walle <michael@walle.cc>

-- 
michael

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

end of thread, other threads:[~2013-03-18 18:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-10 13:47 [Qemu-devel] [PATCH 0/3] Fix VMSTATE_BUFFER_UNSAFE macro usage Igor Mitsyanko
2013-03-10 13:47 ` [Qemu-devel] [PATCH 1/3] vmstate.h: introduce VMSTATE_BUFFER_POINTER_UNSAFE macro Igor Mitsyanko
2013-03-10 13:47 ` [Qemu-devel] [PATCH 2/3] hw/sd.c: fix migration of dynamically allocated buffer "buf" Igor Mitsyanko
2013-03-18 18:33   ` Michael Walle
2013-03-10 13:47 ` [Qemu-devel] [PATCH 3/3] hw/onenand.c: fix migration of dynamically allocated buffer "otp" Igor Mitsyanko
2013-03-15 17:12 ` [Qemu-devel] [PATCH 0/3] Fix VMSTATE_BUFFER_UNSAFE macro usage Peter Maydell
     [not found]   ` <51435829.5020106@gmail.com>
2013-03-15 17:23     ` Igor Mitsyanko
2013-03-18 16:19 ` Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.