Re: [Qemu-devel] [RFC v2 3/6] memory: support unmapping of MemoryRegion mapped into HVA parent

2015-06-17 Thread Michael S. Tsirkin
On Wed, Jun 17, 2015 at 06:15:14PM +0200, Paolo Bonzini wrote: > > > On 17/06/2015 17:10, Michael S. Tsirkin wrote: > > > Actually memory_region_add_subregion(cannot fail) will continue to casue > > > problems > > > in case one of the listeners fails and has no way to propagate error up > > > t

Re: [Qemu-devel] [RFC v2 3/6] memory: support unmapping of MemoryRegion mapped into HVA parent

2015-06-17 Thread Paolo Bonzini
On 17/06/2015 17:10, Michael S. Tsirkin wrote: > > Actually memory_region_add_subregion(cannot fail) will continue to casue > > problems > > in case one of the listeners fails and has no way to propagate error up the > > stack. > > It could be that vhost_set_memory() or kvm_set_memslots() aren'

Re: [Qemu-devel] [RFC v2 3/6] memory: support unmapping of MemoryRegion mapped into HVA parent

2015-06-17 Thread Michael S. Tsirkin
On Wed, Jun 17, 2015 at 05:04:37PM +0200, Igor Mammedov wrote: > On Wed, 17 Jun 2015 10:14:00 +0200 > Paolo Bonzini wrote: > > > > > > > On 09/06/2015 12:08, Igor Mammedov wrote: > > > > > > 3. until #2 is done we can't allow to map another memory region in > > >current flatview at the sam

Re: [Qemu-devel] [RFC v2 3/6] memory: support unmapping of MemoryRegion mapped into HVA parent

2015-06-17 Thread Igor Mammedov
On Wed, 17 Jun 2015 10:14:00 +0200 Paolo Bonzini wrote: > > > On 09/06/2015 12:08, Igor Mammedov wrote: > > > > 3. until #2 is done we can't allow to map another memory region in > >current flatview at the same range, hence need to keep list of > >still active HVA ranges so we could ch

Re: [Qemu-devel] [RFC v2 3/6] memory: support unmapping of MemoryRegion mapped into HVA parent

2015-06-17 Thread Paolo Bonzini
On 09/06/2015 12:08, Igor Mammedov wrote: > > 3. until #2 is done we can't allow to map another memory region in >current flatview at the same range, hence need to keep list of >still active HVA ranges so we could check at memory_region_add_subregion() >time that new mapping is allow

Re: [Qemu-devel] [RFC v2 3/6] memory: support unmapping of MemoryRegion mapped into HVA parent

2015-06-09 Thread Igor Mammedov
On Mon, 08 Jun 2015 19:06:39 +0200 Paolo Bonzini wrote: > > > On 08/06/2015 18:25, Michael S. Tsirkin wrote: > > > issue is that we have to re-reserve HVA region first so no other > > > allocation > > > would claim gap and the only way I found was just to call mmap() on it > > > which as side

Re: [Qemu-devel] [RFC v2 3/6] memory: support unmapping of MemoryRegion mapped into HVA parent

2015-06-08 Thread Paolo Bonzini
On 08/06/2015 18:25, Michael S. Tsirkin wrote: > > issue is that we have to re-reserve HVA region first so no other allocation > > would claim gap and the only way I found was just to call mmap() on it > > which as side effect invalidates MemoryRegion's backing RAM. > > Well the only point we ne

Re: [Qemu-devel] [RFC v2 3/6] memory: support unmapping of MemoryRegion mapped into HVA parent

2015-06-08 Thread Michael S. Tsirkin
On Mon, Jun 08, 2015 at 06:13:14PM +0200, Igor Mammedov wrote: > On Mon, 08 Jun 2015 17:32:27 +0200 > Paolo Bonzini wrote: > > > > > > > On 08/06/2015 17:19, Igor Mammedov wrote: > > > +void qemu_ram_unmap_hva(ram_addr_t addr) > > > +{ > > > +RAMBlock *block = find_ram_block(addr); > > > +

Re: [Qemu-devel] [RFC v2 3/6] memory: support unmapping of MemoryRegion mapped into HVA parent

2015-06-08 Thread Igor Mammedov
On Mon, 08 Jun 2015 17:32:27 +0200 Paolo Bonzini wrote: > > > On 08/06/2015 17:19, Igor Mammedov wrote: > > +void qemu_ram_unmap_hva(ram_addr_t addr) > > +{ > > +RAMBlock *block = find_ram_block(addr); > > + > > +assert(block); > > +mmap(block->host, block->used_length, PROT_NONE, >

Re: [Qemu-devel] [RFC v2 3/6] memory: support unmapping of MemoryRegion mapped into HVA parent

2015-06-08 Thread Paolo Bonzini
On 08/06/2015 17:19, Igor Mammedov wrote: > +void qemu_ram_unmap_hva(ram_addr_t addr) > +{ > +RAMBlock *block = find_ram_block(addr); > + > +assert(block); > +mmap(block->host, block->used_length, PROT_NONE, > + MAP_FIXED | MAP_NORESERVE | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);

Re: [Qemu-devel] [RFC v2 3/6] memory: support unmapping of MemoryRegion mapped into HVA parent

2015-06-08 Thread Paolo Bonzini
On 08/06/2015 17:19, Igor Mammedov wrote: > +assert(!subregion->hva_mapped); > if (rsvd_hva.mr) { > +subregion->hva_mapped = true; > qemu_ram_remap_hva(mr->ram_addr, > memory_region_get_ram_ptr(rsvd_hva.mr) + > rsvd_h

[Qemu-devel] [RFC v2 3/6] memory: support unmapping of MemoryRegion mapped into HVA parent

2015-06-08 Thread Igor Mammedov
due to need to preserve HVA reserved range continous (make it atomic), unmap subregion's host memory by placing reservation mapping on it's range and invalidate subregion since it can't be reused anymore. Also add memory_region_is_hva_mapped() to let backend check if MemoryRegion should be recreat