[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] linux-user: Fix stale tbs after mmap
From: |
Alexander Graf |
Subject: |
Re: [Qemu-devel] [PATCH] linux-user: Fix stale tbs after mmap |
Date: |
Mon, 7 May 2012 13:38:23 +0200 |
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 <address@hidden> 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 comment at the top of tb_invalidate_phys_page_range() says
>> "start and end must refer to the same physical page" -- is it
>> out of date or does that not apply to user-mode?
>>
>> Do you need to also invalidate the range on munmap() and
>> mprotect-to-not-executable in order to correctly fault on
>> the case of:
>> map something
>> execute it
>> unmap it
>> try to execute it again
>>
>> ? (haven't tested that case but it seems like it might be an issue)
>
> Yeah, the issue does exist:
And the below patch on top of my revised patch fixes it. The question is
whether we still need to flush on mmap() then?
Alex
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 3611deb..bb4e752 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -690,8 +690,10 @@ int target_munmap(abi_ulong start, abi_ulong len)
}
}
- if (ret == 0)
+ if (ret == 0) {
page_set_flags(start, start + len, 0);
+ tb_invalidate_phys_range(start, start + len, 0);
+ }
mmap_unlock();
return ret;
}