diff options
-rw-r--r-- | block/blkdebug.c | 9 | ||||
-rw-r--r-- | block/mirror.c | 4 | ||||
-rw-r--r-- | block/qcow2-refcount.c | 2 | ||||
-rw-r--r-- | bsd-user/elfload.c | 3 | ||||
-rw-r--r-- | exec.c | 4 | ||||
-rw-r--r-- | include/exec/cpu-all.h | 8 | ||||
-rw-r--r-- | linux-user/elfload.c | 3 | ||||
-rw-r--r-- | linux-user/mmap.c | 4 | ||||
-rw-r--r-- | main-loop.c | 2 | ||||
-rw-r--r-- | qemu-char.c | 7 | ||||
-rw-r--r-- | stubs/qtest.c | 5 | ||||
-rw-r--r-- | translate-all.c | 6 | ||||
-rw-r--r-- | translate-common.c | 2 |
13 files changed, 39 insertions, 20 deletions
diff --git a/block/blkdebug.c b/block/blkdebug.c index 6860a2ba2f..dee3a0edfc 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -30,6 +30,7 @@ #include "qapi/qmp/qdict.h" #include "qapi/qmp/qint.h" #include "qapi/qmp/qstring.h" +#include "sysemu/qtest.h" typedef struct BDRVBlkdebugState { int state; @@ -583,9 +584,13 @@ static void suspend_request(BlockDriverState *bs, BlkdebugRule *rule) remove_rule(rule); QLIST_INSERT_HEAD(&s->suspended_reqs, &r, next); - printf("blkdebug: Suspended request '%s'\n", r.tag); + if (!qtest_enabled()) { + printf("blkdebug: Suspended request '%s'\n", r.tag); + } qemu_coroutine_yield(); - printf("blkdebug: Resuming request '%s'\n", r.tag); + if (!qtest_enabled()) { + printf("blkdebug: Resuming request '%s'\n", r.tag); + } QLIST_REMOVE(&r, next); g_free(r.tag); diff --git a/block/mirror.c b/block/mirror.c index 52c9abfe14..0e8f5565a5 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -388,6 +388,7 @@ static void mirror_exit(BlockJob *job, void *opaque) bdrv_unref(s->target); block_job_completed(&s->common, data->ret); g_free(data); + bdrv_drained_end(src); bdrv_unref(src); } @@ -607,6 +608,9 @@ immediate_exit: data = g_malloc(sizeof(*data)); data->ret = ret; + /* Before we switch to target in mirror_exit, make sure data doesn't + * change. */ + bdrv_drained_begin(s->common.bs); block_job_defer_to_main_loop(&s->common, mirror_exit, data); } diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 6e0e5bd9ae..820f412ab6 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1244,7 +1244,7 @@ fail: /* refcount checking functions */ -static size_t refcount_array_byte_size(BDRVQcow2State *s, uint64_t entries) +static uint64_t refcount_array_byte_size(BDRVQcow2State *s, uint64_t entries) { /* This assertion holds because there is no way we can address more than * 2^(64 - 9) clusters at once (with cluster size 512 = 2^9, and because diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c index 351aab12e7..59a7bdf0cc 100644 --- a/bsd-user/elfload.c +++ b/bsd-user/elfload.c @@ -740,8 +740,7 @@ static void padzero(abi_ulong elf_bss, abi_ulong last_bss) size must be known */ if (qemu_real_host_page_size < qemu_host_page_size) { abi_ulong end_addr, end_addr1; - end_addr1 = (elf_bss + qemu_real_host_page_size - 1) & - ~(qemu_real_host_page_size - 1); + end_addr1 = REAL_HOST_PAGE_ALIGN(elf_bss); end_addr = HOST_PAGE_ALIGN(elf_bss); if (end_addr1 < end_addr) { mmap((void *)g2h(end_addr1), end_addr - end_addr1, @@ -1064,9 +1064,11 @@ static uint16_t phys_section_add(PhysPageMap *map, static void phys_section_destroy(MemoryRegion *mr) { + bool have_sub_page = mr->subpage; + memory_region_unref(mr); - if (mr->subpage) { + if (have_sub_page) { subpage_t *subpage = container_of(mr, subpage_t, iomem); object_unref(OBJECT(&subpage->iomem)); g_free(subpage); diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index f9998b9732..83b1781afc 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -174,11 +174,13 @@ extern unsigned long reserved_va; #define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1) #define TARGET_PAGE_ALIGN(addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK) -/* ??? These should be the larger of uintptr_t and target_ulong. */ +/* Using intptr_t ensures that qemu_*_page_mask is sign-extended even + * when intptr_t is 32-bit and we are aligning a long long. + */ extern uintptr_t qemu_real_host_page_size; -extern uintptr_t qemu_real_host_page_mask; +extern intptr_t qemu_real_host_page_mask; extern uintptr_t qemu_host_page_size; -extern uintptr_t qemu_host_page_mask; +extern intptr_t qemu_host_page_mask; #define HOST_PAGE_ALIGN(addr) (((addr) + qemu_host_page_size - 1) & qemu_host_page_mask) #define REAL_HOST_PAGE_ALIGN(addr) (((addr) + qemu_real_host_page_size - 1) & \ diff --git a/linux-user/elfload.c b/linux-user/elfload.c index d68f5a16ca..8b17c0e94b 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1478,8 +1478,7 @@ static void zero_bss(abi_ulong elf_bss, abi_ulong last_bss, int prot) host_start = (uintptr_t) g2h(elf_bss); host_end = (uintptr_t) g2h(last_bss); - host_map_start = (host_start + qemu_real_host_page_size - 1); - host_map_start &= -qemu_real_host_page_size; + host_map_start = REAL_HOST_PAGE_ALIGN(host_start); if (host_map_start < host_end) { void *p = mmap((void *)host_map_start, host_end - host_map_start, diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 5606bcd164..7b459d5100 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -444,9 +444,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, /* If so, truncate the file map at eof aligned with the hosts real pagesize. Additional anonymous maps will be created beyond EOF. */ - len = (sb.st_size - offset); - len += qemu_real_host_page_size - 1; - len &= ~(qemu_real_host_page_size - 1); + len = REAL_HOST_PAGE_ALIGN(sb.st_size - offset); } } diff --git a/main-loop.c b/main-loop.c index df28670606..5877615387 100644 --- a/main-loop.c +++ b/main-loop.c @@ -230,7 +230,7 @@ static int os_host_main_loop_wait(int64_t timeout) if (!timeout && (spin_counter > MAX_MAIN_LOOP_SPIN)) { static bool notified; - if (!notified && !qtest_enabled()) { + if (!notified && !qtest_driver()) { fprintf(stderr, "main-loop: WARNING: I/O thread spun for %d iterations\n", MAX_MAIN_LOOP_SPIN); diff --git a/qemu-char.c b/qemu-char.c index 5448b0f30b..2969c44e84 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -1241,11 +1241,16 @@ static void pty_chr_update_read_handler_locked(CharDriverState *chr) { PtyCharDriver *s = chr->opaque; GPollFD pfd; + int rc; pfd.fd = g_io_channel_unix_get_fd(s->fd); pfd.events = G_IO_OUT; pfd.revents = 0; - g_poll(&pfd, 1, 0); + do { + rc = g_poll(&pfd, 1, 0); + } while (rc == -1 && errno == EINTR); + assert(rc >= 0); + if (pfd.revents & G_IO_HUP) { pty_chr_state(chr, 0); } else { diff --git a/stubs/qtest.c b/stubs/qtest.c index dc17594bb6..4dfde6104d 100644 --- a/stubs/qtest.c +++ b/stubs/qtest.c @@ -12,3 +12,8 @@ /* Needed for qtest_allowed() */ bool qtest_allowed; + +bool qtest_driver(void) +{ + return false; +} diff --git a/translate-all.c b/translate-all.c index a940bd2e5e..042a8576ac 100644 --- a/translate-all.c +++ b/translate-all.c @@ -118,7 +118,7 @@ typedef struct PageDesc { #define V_L1_SHIFT (L1_MAP_ADDR_SPACE_BITS - TARGET_PAGE_BITS - V_L1_BITS) uintptr_t qemu_host_page_size; -uintptr_t qemu_host_page_mask; +intptr_t qemu_host_page_mask; /* The bottom level has pointers to PageDesc */ static void *l1_map[V_L1_SIZE]; @@ -326,14 +326,14 @@ void page_size_init(void) /* NOTE: we can always suppose that qemu_host_page_size >= TARGET_PAGE_SIZE */ qemu_real_host_page_size = getpagesize(); - qemu_real_host_page_mask = ~(qemu_real_host_page_size - 1); + qemu_real_host_page_mask = -(intptr_t)qemu_real_host_page_size; if (qemu_host_page_size == 0) { qemu_host_page_size = qemu_real_host_page_size; } if (qemu_host_page_size < TARGET_PAGE_SIZE) { qemu_host_page_size = TARGET_PAGE_SIZE; } - qemu_host_page_mask = ~(qemu_host_page_size - 1); + qemu_host_page_mask = -(intptr_t)qemu_host_page_size; } static void page_init(void) diff --git a/translate-common.c b/translate-common.c index 619feb466e..171222d037 100644 --- a/translate-common.c +++ b/translate-common.c @@ -21,7 +21,7 @@ #include "qom/cpu.h" uintptr_t qemu_real_host_page_size; -uintptr_t qemu_real_host_page_mask; +intptr_t qemu_real_host_page_mask; #ifndef CONFIG_USER_ONLY /* mask must never be zero, except for A20 change call */ |