Patchwork [2/2] vmstate, memory: decouple vmstate from memory API

login
register
mail settings
Submitter Jordan Justen
Date Jan. 8, 2012, 5:14 a.m.
Message ID <CAFe8ug9EvDZkTLrCpQDYsi2rTHXEPRGKyCWc+jpHq3o4r2njVQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/134891/
State New
Headers show

Comments

Jordan Justen - Jan. 8, 2012, 5:14 a.m.
On Tue, Dec 20, 2011 at 06:05, Avi Kivity <avi@redhat.com> wrote:
> +void qemu_ram_set_idstr(ram_addr_t addr, const char *name, DeviceState *dev)
>  {
>     RAMBlock *new_block, *block;
>
> -    size = TARGET_PAGE_ALIGN(size);
> -    new_block = g_malloc0(sizeof(*new_block));
> +    new_block = NULL;
> +    QLIST_FOREACH(block, &ram_list.blocks, next) {
> +        if (block->offset == addr) {
> +            new_block = block;
> +            break;
> +        }
> +    }
> +    assert(new_block);
> +    assert(!new_block->idstr[0]);

Avi,

When using pflash_cfi01, I hit the assert(new_block) added above.  It
seemed to be caused by the low bits of addr being 0x7.  This seems to
be come from cpu_register_io_memory in memory_region_init_rom_device.

Would this patch be an appropriate fix for this?


-Jordan
Stefan Weil - Jan. 8, 2012, 7:23 a.m.
Am 08.01.2012 06:14, schrieb Jordan Justen:
> Avi,
> When using pflash_cfi01, I hit the assert(new_block) added above.  It
> seemed to be caused by the low bits of addr being 0x7.  This seems to
> be come from cpu_register_io_memory in memory_region_init_rom_device.
>
> Would this patch be an appropriate fix for this?
>
> diff --git a/exec.c b/exec.c
> index b1d6602..b3ebc91 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -2777,7 +2777,7 @@ void qemu_ram_set_idstr(ram_addr_t addr, const char *name,
>
>       new_block = NULL;
>       QLIST_FOREACH(block,&ram_list.blocks, next) {
> -        if (block->offset == addr) {
> +        if (block->offset == (addr&  TARGET_PAGE_MASK)) {
>               new_block = block;
>               break;
>           }
>
> -Jordan


Hi,

latest QEMU has a different patch for memory.c which fixes the
same problem.

Regards,
Stefan

Patch

diff --git a/exec.c b/exec.c
index b1d6602..b3ebc91 100644
--- a/exec.c
+++ b/exec.c
@@ -2777,7 +2777,7 @@  void qemu_ram_set_idstr(ram_addr_t addr, const char *name,

     new_block = NULL;
     QLIST_FOREACH(block, &ram_list.blocks, next) {
-        if (block->offset == addr) {
+        if (block->offset == (addr & TARGET_PAGE_MASK)) {
             new_block = block;
             break;
         }