Re: [Qemu-devel] [PATCH] linux-user: Fix stale tbs after mmap

2012-05-11 Thread Peter Maydell
On 11 May 2012 09:40, Alexander Graf wrote: > If we execute linux-user code that does the following: > >  * A = mmap() >  * execute code in A >  * munmap(A) >  * B = mmap(), but mmap returns the same address as A >  * execute code in B > > we end up executing a stale cached tb that contains transl

Re: [Qemu-devel] [PATCH] linux-user: Fix stale tbs after mmap

2012-05-11 Thread Alexander Graf
On 11.05.2012, at 17:46, Peter Maydell wrote: > On 7 May 2012 12:38, Alexander Graf wrote: >> >> On 07.05.2012, at 13:32, Alexander Graf wrote: >> >>> >>> On 07.05.2012, at 12:37, Peter Maydell wrote: >>> On 7 May 2012 10:30, Alexander Graf wrote: > @@ -587,6 +587,7 @@ abi_long tar

[Qemu-devel] [PATCH] linux-user: Fix stale tbs after mmap

2012-05-11 Thread Alexander Graf
If we execute linux-user code that does the following: * A = mmap() * execute code in A * munmap(A) * B = mmap(), but mmap returns the same address as A * execute code in B we end up executing a stale cached tb that contains translated code from A, while we want new code from B. This p

Re: [Qemu-devel] [PATCH] linux-user: Fix stale tbs after mmap

2012-05-11 Thread Peter Maydell
On 7 May 2012 12:38, Alexander Graf wrote: > > On 07.05.2012, at 13:32, Alexander Graf wrote: > >> >> On 07.05.2012, at 12:37, Peter Maydell wrote: >> >>> On 7 May 2012 10:30, Alexander Graf wrote: @@ -587,6 +587,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,

Re: [Qemu-devel] [PATCH] linux-user: Fix stale tbs after mmap

2012-05-07 Thread Peter Maydell
On 7 May 2012 12:38, Alexander Graf wrote: > And the below patch on top of my revised patch fixes it. > The question is whether we still need to flush on mmap() then? IIRC the kernel will let you MAP_FIXED mmap a file to an address that's already mmap'd for something else without having to munmap

Re: [Qemu-devel] [PATCH] linux-user: Fix stale tbs after mmap

2012-05-07 Thread Alexander Graf
On 07.05.2012, at 13:32, Alexander Graf wrote: > > On 07.05.2012, at 12:37, Peter Maydell wrote: > >> On 7 May 2012 10:30, Alexander Graf wrote: >>> @@ -587,6 +587,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, >>> int prot, >>>page_dump(stdout); >>>printf("\n"); >>> #endif

Re: [Qemu-devel] [PATCH] linux-user: Fix stale tbs after mmap

2012-05-07 Thread Alexander Graf
On 07.05.2012, at 12:37, Peter Maydell wrote: > On 7 May 2012 10:30, Alexander Graf wrote: >> @@ -587,6 +587,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int >> prot, >> page_dump(stdout); >> printf("\n"); >> #endif >> +tb_invalidate_phys_page_range(start, start + len,

Re: [Qemu-devel] [PATCH] linux-user: Fix stale tbs after mmap

2012-05-07 Thread Alexander Graf
On 07.05.2012, at 12:37, Peter Maydell wrote: > On 7 May 2012 10:30, Alexander Graf wrote: >> @@ -587,6 +587,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int >> prot, >> page_dump(stdout); >> printf("\n"); >> #endif >> +tb_invalidate_phys_page_range(start, start + len,

Re: [Qemu-devel] [PATCH] linux-user: Fix stale tbs after mmap

2012-05-07 Thread Alexander Graf
On 07.05.2012, at 12:37, Peter Maydell wrote: > On 7 May 2012 10:30, Alexander Graf wrote: >> @@ -587,6 +587,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int >> prot, >> page_dump(stdout); >> printf("\n"); >> #endif >> +tb_invalidate_phys_page_range(start, start + len,

Re: [Qemu-devel] [PATCH] linux-user: Fix stale tbs after mmap

2012-05-07 Thread Peter Maydell
On 7 May 2012 10:30, Alexander Graf wrote: > @@ -587,6 +587,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int > prot, >     page_dump(stdout); >     printf("\n"); >  #endif > +    tb_invalidate_phys_page_range(start, start + len, 0); >     mmap_unlock(); >     return start; The comme

[Qemu-devel] [PATCH] linux-user: Fix stale tbs after mmap

2012-05-07 Thread Alexander Graf
If we execute linux-user code that does the following: * A = mmap() * execute code in A * munmap(A) * B = mmap(), but mmap returns the same address as A * execute code in B we end up executing a stale cached tb that contains translated code from A, while we want new code from B. This p