mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
accel/tcg: Use interval tree for user-only page tracking
Finish weaning user-only away from PageDesc. Using an interval tree to track page permissions means that we can represent very large regions efficiently. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/290 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/967 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1214 Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
@@ -24,9 +24,7 @@
|
||||
#endif
|
||||
|
||||
typedef struct PageDesc {
|
||||
#ifdef CONFIG_USER_ONLY
|
||||
unsigned long flags;
|
||||
#else
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
QemuSpin lock;
|
||||
/* list of TBs intersecting this ram page */
|
||||
uintptr_t first_tb;
|
||||
|
||||
+14
-6
@@ -68,15 +68,23 @@ static void tb_remove_all(void)
|
||||
/* Call with mmap_lock held. */
|
||||
static void tb_record(TranslationBlock *tb, PageDesc *p1, PageDesc *p2)
|
||||
{
|
||||
/* translator_loop() must have made all TB pages non-writable */
|
||||
assert(!(p1->flags & PAGE_WRITE));
|
||||
if (p2) {
|
||||
assert(!(p2->flags & PAGE_WRITE));
|
||||
}
|
||||
target_ulong addr;
|
||||
int flags;
|
||||
|
||||
assert_memory_lock();
|
||||
|
||||
tb->itree.last = tb->itree.start + tb->size - 1;
|
||||
|
||||
/* translator_loop() must have made all TB pages non-writable */
|
||||
addr = tb_page_addr0(tb);
|
||||
flags = page_get_flags(addr);
|
||||
assert(!(flags & PAGE_WRITE));
|
||||
|
||||
addr = tb_page_addr1(tb);
|
||||
if (addr != -1) {
|
||||
flags = page_get_flags(addr);
|
||||
assert(!(flags & PAGE_WRITE));
|
||||
}
|
||||
|
||||
interval_tree_insert(&tb->itree, &tb_root);
|
||||
}
|
||||
|
||||
|
||||
+414
-201
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Test very large vma allocations.
|
||||
* The qemu out-of-memory condition was within the mmap syscall itself.
|
||||
* If the syscall actually returns with MAP_FAILED, the test succeeded.
|
||||
*/
|
||||
#include <sys/mman.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int n = sizeof(size_t) == 4 ? 32 : 45;
|
||||
|
||||
for (int i = 28; i < n; i++) {
|
||||
size_t l = (size_t)1 << i;
|
||||
void *p = mmap(0, l, PROT_NONE,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0);
|
||||
if (p == MAP_FAILED) {
|
||||
break;
|
||||
}
|
||||
munmap(p, l);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user