qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 07/22] memory: add address_space_translate


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH 07/22] memory: add address_space_translate
Date: Thu, 20 Jun 2013 14:53:30 +0100

On 30 May 2013 22:03, Paolo Bonzini <address@hidden> wrote:
> +MemoryRegionSection *address_space_translate(AddressSpace *as, hwaddr addr,
> +                                             hwaddr *xlat, hwaddr *plen,
> +                                             bool is_write)
> +{
> +    MemoryRegionSection *section;
> +    Int128 diff;
> +
> +    section = phys_page_find(as->dispatch, addr >> TARGET_PAGE_BITS);
> +    /* Compute offset within MemoryRegionSection */
> +    addr -= section->offset_within_address_space;
> +
> +    /* Compute offset within MemoryRegion */
> +    *xlat = addr + section->offset_within_region;
> +
> +    diff = int128_sub(section->mr->size, int128_make64(addr));
> +    *plen = MIN(int128_get64(diff), *plen);

I've just run into a situation where the assertion in
int128_get64() that the value fits into a 64 bit integer
fires. This happened to me for an access to address zero
in the 'unassigned' region:
 * io_mem_init() sets the size of these to UINT64_MAX
 * memory_region_init() special-cases that size as meaning
   2^64, ie {hi=1,lo=0}
 * since the addr is zero diff is also {hi=1,lo=0}, and
   then int128_get64() asserts.

There are other places in memory.c which do an int128_get64()
on mr->size, which also look suspicious...

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]