Re: [Qemu-devel] [PATCH 2/5] exec.c: use refcnt to protect device during dispatching

2012-07-26 Thread Avi Kivity
On 07/26/2012 04:06 PM, liu ping fan wrote: > On Wed, Jul 25, 2012 at 8:27 PM, Avi Kivity wrote: >> On 07/25/2012 01:58 PM, Avi Kivity wrote: while (len > 0) { page = addr & TARGET_PAGE_MASK; l = (page + TARGET_PAGE_SIZE) - addr; if (l > len) >>>

Re: [Qemu-devel] [PATCH 2/5] exec.c: use refcnt to protect device during dispatching

2012-07-26 Thread liu ping fan
On Wed, Jul 25, 2012 at 8:27 PM, Avi Kivity wrote: > On 07/25/2012 01:58 PM, Avi Kivity wrote: >>> while (len > 0) { >>> page = addr & TARGET_PAGE_MASK; >>> l = (page + TARGET_PAGE_SIZE) - addr; >>> if (l > len) >>> l = len; >>> + >>> +qemu_rwlo

Re: [Qemu-devel] [PATCH 2/5] exec.c: use refcnt to protect device during dispatching

2012-07-26 Thread liu ping fan
On Wed, Jul 25, 2012 at 5:18 PM, Paolo Bonzini wrote: > Il 25/07/2012 10:12, liu ping fan ha scritto: >> +qemu_rwlock_rdlock_devtree(); >> section = phys_page_find(page >> TARGET_PAGE_BITS); >> +if (!(memory_region_is_ram(section->mr) || >> +

Re: [Qemu-devel] [PATCH 2/5] exec.c: use refcnt to protect device during dispatching

2012-07-25 Thread Avi Kivity
On 07/25/2012 01:58 PM, Avi Kivity wrote: >> while (len > 0) { >> page = addr & TARGET_PAGE_MASK; >> l = (page + TARGET_PAGE_SIZE) - addr; >> if (l > len) >> l = len; >> + >> +qemu_rwlock_rdlock_devtree(); >> section = phys_page_find(pag

Re: [Qemu-devel] [PATCH 2/5] exec.c: use refcnt to protect device during dispatching

2012-07-25 Thread Avi Kivity
On 07/25/2012 06:31 AM, Liu Ping Fan wrote: > From: Liu Ping Fan > > acquire device's refcnt with qemu_device_tree_mutex rwlock, so we > can safely handle it when mmio dispatch. > > If in radix-tree, leaf is subpage, then move further step to acquire > opaque which is the type --DeiveState. > >

Re: [Qemu-devel] [PATCH 2/5] exec.c: use refcnt to protect device during dispatching

2012-07-25 Thread Paolo Bonzini
Il 25/07/2012 10:12, liu ping fan ha scritto: >>> >> +qemu_rwlock_rdlock_devtree(); >>> >> section = phys_page_find(page >> TARGET_PAGE_BITS); >>> >> +if (!(memory_region_is_ram(section->mr) || >>> >> +memory_region_is_romd(section->mr)) && !is_write) { >>> >> +

Re: [Qemu-devel] [PATCH 2/5] exec.c: use refcnt to protect device during dispatching

2012-07-25 Thread liu ping fan
On Wed, Jul 25, 2012 at 3:43 PM, Stefan Hajnoczi wrote: > On Wed, Jul 25, 2012 at 4:31 AM, Liu Ping Fan wrote: >> @@ -3396,13 +3420,25 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, >> uint8_t *buf, >> uint32_t val; >> target_phys_addr_t page; >> MemoryRegionSection *sect

Re: [Qemu-devel] [PATCH 2/5] exec.c: use refcnt to protect device during dispatching

2012-07-25 Thread Stefan Hajnoczi
On Wed, Jul 25, 2012 at 4:31 AM, Liu Ping Fan wrote: > @@ -3396,13 +3420,25 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, > uint8_t *buf, > uint32_t val; > target_phys_addr_t page; > MemoryRegionSection *section; > +Object *bk; > > while (len > 0) { > pa

[Qemu-devel] [PATCH 2/5] exec.c: use refcnt to protect device during dispatching

2012-07-24 Thread Liu Ping Fan
From: Liu Ping Fan acquire device's refcnt with qemu_device_tree_mutex rwlock, so we can safely handle it when mmio dispatch. If in radix-tree, leaf is subpage, then move further step to acquire opaque which is the type --DeiveState. Signed-off-by: Liu Ping Fan --- exec.c | 38 +++