diff mbox

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

Message ID CAFe8ug9EvDZkTLrCpQDYsi2rTHXEPRGKyCWc+jpHq3o4r2njVQ@mail.gmail.com
State New
Headers show

Commit Message

Jordan Justen Jan. 8, 2012, 5:14 a.m. UTC
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

Comments

Stefan Weil Jan. 8, 2012, 7:23 a.m. UTC | #1
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
diff mbox

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;
         }