On 10 March 2013 22:21, Igor Mitsyanko <i.mitsya...@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?

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

Reply via email to