From: Igor Mitsyanko <i.mitsyanko@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org,
anthony@codemonkey.ws, afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH 3/3] memory_region_init_ram_ptr: only allow n*TARGET_PAGE_SIZE memory sizes
Date: Sun, 10 Mar 2013 22:39:17 +0400 [thread overview]
Message-ID: <513CD355.7020906@gmail.com> (raw)
In-Reply-To: <CAFEAcA_8sw4EoX6+f+C-RxzASVmSQtPwcASE1iOEnPJ+9D1F0Q@mail.gmail.com>
On 10.03.2013 18:27, Peter Maydell wrote:
> On 10 March 2013 22:21, Igor Mitsyanko <i.mitsyanko@gmail.com> wrote:
>> Registering memory regions using preallocated memory which size is not a multiple of
>> target page size will result in inconsistency in QEMU memory system. Do not
>> allow to do that at all by checking for that case (and asserting) in
>> memory_region_init_ram_ptr().
> This is too vague. What exactly is the problem and why can't we
> just fix the memory system to correctly handle being passed
> small preallocated memory areas?
The problem I've personally encountered is the one I described in PATCH
1. When saving a VM state, QEMU is looping forever in ram_save_block()
trying to save chipid_and_omr memory region. This is because
migration_bitmap_find_and_reset_dirty() works on memory blocks of
TARGET_PAGE_SIZE length.
There could be other places where problem could occur I think. Its not
really related to an actual TARGET_PAGE_SIZE and its length, what
important is to be consistent in minimal memory length requirements. For
example, when we pass size=1 byte to memory_region_init_ram_ptr(), it
sets MemoryRegion::size to 1 byte, but at the same time, it sets
corresponding RAMBlock::size to TARGET_PAGE_ALIGN(1). And now we have a
situation when some parts of QEMU think that it can access the whole
TARGET_PAGE_SIZE region, while we actually allocated only 1 byte for it.
Same goes for migration, it operates on TARGET_PAGE_SIZE-length data
blocks only.
What I mean to say is, it looks like QEMU has an implicit assumption
that RAM length should be a multiple of page size length?
>
>> --- a/memory.c
>> +++ b/memory.c
>> @@ -949,6 +949,7 @@ void memory_region_init_ram_ptr(MemoryRegion *mr,
>> uint64_t size,
>> void *ptr)
>> {
>> + assert((size & (TARGET_PAGE_SIZE - 1)) == 0);
> This in particular seems like a bad idea, because TARGET_PAGE_SIZE
> is a per-CPU thing, and we shouldn't be adding more code to QEMU which
> will need to be fixed if/when we ever support multiple CPU types in
> a single binary. (Also TARGET_PAGE_SIZE isn't necessarily what you
> think it is: for instance on ARM it's actually only 1K even though
> the standard ARM setup is 4K pages.)
>
> thanks
> -- PMM
next prev parent reply other threads:[~2013-03-10 18:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-10 14:21 [Qemu-devel] [PATCH 0/3] Fix memory migration for exynos 4210 SoC Igor Mitsyanko
2013-03-10 14:21 ` [Qemu-devel] [PATCH 1/3] hw/exynos4210.c: set chipid_and_omr array size to TARGET_PAGE_SIZE Igor Mitsyanko
2013-03-10 14:21 ` [Qemu-devel] [PATCH 2/3] exynos4210.c: register chipid_mem and rom_mem with vmstate Igor Mitsyanko
2013-03-10 14:21 ` [Qemu-devel] [PATCH 3/3] memory_region_init_ram_ptr: only allow n*TARGET_PAGE_SIZE memory sizes Igor Mitsyanko
2013-03-10 14:27 ` Peter Maydell
2013-03-10 18:39 ` Igor Mitsyanko [this message]
2013-05-07 13:09 ` [Qemu-devel] [PATCH 0/3] Fix memory migration for exynos 4210 SoC Peter Maydell
2013-05-07 13:14 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=513CD355.7020906@gmail.com \
--to=i.mitsyanko@gmail.com \
--cc=afaerber@suse.de \
--cc=anthony@codemonkey.ws \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.