[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 04/11] exec: introduce MemoryRegionCache
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH 04/11] exec: introduce MemoryRegionCache |
Date: |
Mon, 12 Dec 2016 14:06:55 +0000 |
User-agent: |
Mutt/1.7.1 (2016-10-04) |
On Mon, Dec 12, 2016 at 12:18:50PM +0100, Paolo Bonzini wrote:
> diff --git a/exec.c b/exec.c
> index d4b3656..8d4bb0e 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -3077,6 +3077,82 @@ void cpu_physical_memory_unmap(void *buffer, hwaddr
> len,
> #define RCU_READ_UNLOCK(...) rcu_read_unlock()
> #include "memory_ldst.inc.c"
>
> +int64_t address_space_cache_init(MemoryRegionCache *cache,
> + AddressSpace *as,
> + hwaddr addr,
> + hwaddr len,
> + bool is_write)
> +{
> + hwaddr l, xlat;
> + MemoryRegion *mr;
> + void *ptr;
> +
> + assert(len > 0);
> +
> + l = len;
> + mr = address_space_translate(as, addr, &xlat, &l, is_write);
> + if (!memory_access_is_direct(mr, is_write)) {
> + return -EINVAL;
> + }
> +
> + l = address_space_extend_translation(as, addr, len, mr, xlat, l,
> is_write);
> + ptr = qemu_ram_ptr_length(mr->ram_block, xlat, &l);
> +
> + cache->xlat = xlat;
> + cache->is_write = is_write;
> + cache->mr = mr;
> + cache->ptr = ptr;
> + cache->len = l;
> + memory_region_ref(cache->mr);
> +
> + return l;
> +}
What happens when [addr, addr + len) overlaps a MemoryRegion boundary?
It looks like this function silently truncates the MemoryRegionCache,
leading to an assertion failure in address_space_translate_cached().
Perhaps it would be better to fail address_space_cache_init() if the
length is truncated.
signature.asc
Description: PGP signature
- [Qemu-devel] [RFC PATCH 00/11] speedup vring processing with MemoryRegionCaches, Paolo Bonzini, 2016/12/12
- [Qemu-devel] [PATCH 06/11] virtio: add virtio_*_phys_cached, Paolo Bonzini, 2016/12/12
- [Qemu-devel] [PATCH 03/11] exec: introduce address_space_extend_translation, Paolo Bonzini, 2016/12/12
- [Qemu-devel] [PATCH 05/11] virtio: make virtio_should_notify static, Paolo Bonzini, 2016/12/12
- [Qemu-devel] [PATCH 04/11] exec: introduce MemoryRegionCache, Paolo Bonzini, 2016/12/12
- Re: [Qemu-devel] [PATCH 04/11] exec: introduce MemoryRegionCache,
Stefan Hajnoczi <=
- [Qemu-devel] [PATCH 07/11] virtio: use address_space_map/unmap to access descriptors, Paolo Bonzini, 2016/12/12
- [Qemu-devel] [PATCH 01/11] exec: optimize remaining address_space_* cases, Paolo Bonzini, 2016/12/12
- [Qemu-devel] [PATCH 08/11] virtio: use MemoryRegionCache to access descriptors, Paolo Bonzini, 2016/12/12
- [Qemu-devel] [PATCH 02/11] exec: introduce memory_ldst.inc.c, Paolo Bonzini, 2016/12/12