From c0cb758eec848dcbc779bf75a26b49727218e380 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Wed, 13 Jan 2021 13:56:00 -0800 Subject: [PATCH 01/14] osdep.h: Remove include Prior to 2a4b472c3c, sys/signal.h was only included on OpenBSD (apart from two .c files). The POSIX standard location for this header is just and in fact, OpenBSD's signal.h includes sys/signal.h itself. Unconditionally including on musl causes warnings for just about every source file: /usr/include/sys/signal.h:1:2: warning: #warning redirecting incorrect #include to [-Wcpp] 1 | #warning redirecting incorrect #include to | ^~~~~~~ Since there don't seem to be any platforms which require including in addition to , and some platforms like Haiku lack it completely, just remove it. Tested building on OpenBSD after removing this include. Signed-off-by: Michael Forney Tested-by: John Snow Reviewed-by: Eric Blake Reviewed-by: Thomas Huth Message-Id: <20210113215600.16100-1-mforney@mforney.org> Signed-off-by: Thomas Huth --- include/qemu/osdep.h | 4 ---- meson.build | 1 - 2 files changed, 5 deletions(-) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index f9ec8c84e903..a434382c58eb 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -104,10 +104,6 @@ extern int daemon(int, int); #include #include -#ifdef HAVE_SYS_SIGNAL_H -#include -#endif - #ifndef _WIN32 #include #else diff --git a/meson.build b/meson.build index 3d889857a096..af2bc8974111 100644 --- a/meson.build +++ b/meson.build @@ -1113,7 +1113,6 @@ config_host_data.set('HAVE_DRM_H', cc.has_header('libdrm/drm.h')) config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h')) config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h')) config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h')) -config_host_data.set('HAVE_SYS_SIGNAL_H', cc.has_header('sys/signal.h')) ignored = ['CONFIG_QEMU_INTERP_PREFIX'] # actually per-target arrays = ['CONFIG_AUDIO_DRIVERS', 'CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BDRV_RO_WHITELIST'] From cd5d20efa919fdeb06f4f2ce32e614db07d4ca39 Mon Sep 17 00:00:00 2001 From: Jiaxun Yang Date: Mon, 18 Jan 2021 14:38:00 +0800 Subject: [PATCH 02/14] configure: Add sys/timex.h to probe clock_adjtime It is not a part of standard time.h. Glibc put it under time.h however musl treat it as a sys timex extension. Signed-off-by: Jiaxun Yang Reviewed-by: Thomas Huth Message-Id: <20210118063808.12471-2-jiaxun.yang@flygoat.com> Signed-off-by: Thomas Huth --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index 9f016b06b54f..6f6a319c2f65 100755 --- a/configure +++ b/configure @@ -4039,6 +4039,7 @@ fi clock_adjtime=no cat > $TMPC < +#include int main(void) { From 29ce0d35e1b779afb3a34ee53e03f87f7028b376 Mon Sep 17 00:00:00 2001 From: Jiaxun Yang Date: Mon, 18 Jan 2021 14:38:01 +0800 Subject: [PATCH 03/14] libvhost-user: Include poll.h instead of sys/poll.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Musl libc complains about it's wrong usage. In file included from ../subprojects/libvhost-user/libvhost-user.h:20, from ../subprojects/libvhost-user/libvhost-user-glib.h:19, from ../subprojects/libvhost-user/libvhost-user-glib.c:15: /usr/include/sys/poll.h:1:2: error: #warning redirecting incorrect #include to [-Werror=cpp] 1 | #warning redirecting incorrect #include to | ^~~~~~~ Signed-off-by: Jiaxun Yang Reviewed-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20210118063808.12471-3-jiaxun.yang@flygoat.com> Signed-off-by: Thomas Huth --- subprojects/libvhost-user/libvhost-user.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/libvhost-user/libvhost-user.h b/subprojects/libvhost-user/libvhost-user.h index 7d47f1364a57..3d13dfadde47 100644 --- a/subprojects/libvhost-user/libvhost-user.h +++ b/subprojects/libvhost-user/libvhost-user.h @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include "standard-headers/linux/virtio_ring.h" From 9c57272507a95cde3c9c2c90af2312f92cb55422 Mon Sep 17 00:00:00 2001 From: Jiaxun Yang Date: Mon, 18 Jan 2021 14:38:03 +0800 Subject: [PATCH 04/14] hw/block/nand: Rename PAGE_SIZE to NAND_PAGE_SIZE As per POSIX specification of limits.h [1], OS libc may define PAGE_SIZE in limits.h. To prevent collosion of definition, we rename PAGE_SIZE here. [1]: https://pubs.opengroup.org/onlinepubs/7908799/xsh/limits.h.html Signed-off-by: Jiaxun Yang Reviewed-by: Thomas Huth Message-Id: <20210118063808.12471-5-jiaxun.yang@flygoat.com> Signed-off-by: Thomas Huth --- hw/block/nand.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/hw/block/nand.c b/hw/block/nand.c index 123020aebf09..913292ad1de5 100644 --- a/hw/block/nand.c +++ b/hw/block/nand.c @@ -115,24 +115,24 @@ static void mem_and(uint8_t *dest, const uint8_t *src, size_t n) # define NAND_IO # define PAGE(addr) ((addr) >> ADDR_SHIFT) -# define PAGE_START(page) (PAGE(page) * (PAGE_SIZE + OOB_SIZE)) +# define PAGE_START(page) (PAGE(page) * (NAND_PAGE_SIZE + OOB_SIZE)) # define PAGE_MASK ((1 << ADDR_SHIFT) - 1) # define OOB_SHIFT (PAGE_SHIFT - 5) # define OOB_SIZE (1 << OOB_SHIFT) # define SECTOR(addr) ((addr) >> (9 + ADDR_SHIFT - PAGE_SHIFT)) # define SECTOR_OFFSET(addr) ((addr) & ((511 >> PAGE_SHIFT) << 8)) -# define PAGE_SIZE 256 +# define NAND_PAGE_SIZE 256 # define PAGE_SHIFT 8 # define PAGE_SECTORS 1 # define ADDR_SHIFT 8 # include "nand.c" -# define PAGE_SIZE 512 +# define NAND_PAGE_SIZE 512 # define PAGE_SHIFT 9 # define PAGE_SECTORS 1 # define ADDR_SHIFT 8 # include "nand.c" -# define PAGE_SIZE 2048 +# define NAND_PAGE_SIZE 2048 # define PAGE_SHIFT 11 # define PAGE_SECTORS 4 # define ADDR_SHIFT 16 @@ -652,7 +652,7 @@ type_init(nand_register_types) #else /* Program a single page */ -static void glue(nand_blk_write_, PAGE_SIZE)(NANDFlashState *s) +static void glue(nand_blk_write_, NAND_PAGE_SIZE)(NANDFlashState *s) { uint64_t off, page, sector, soff; uint8_t iobuf[(PAGE_SECTORS + 2) * 0x200]; @@ -672,11 +672,11 @@ static void glue(nand_blk_write_, PAGE_SIZE)(NANDFlashState *s) return; } - mem_and(iobuf + (soff | off), s->io, MIN(s->iolen, PAGE_SIZE - off)); - if (off + s->iolen > PAGE_SIZE) { + mem_and(iobuf + (soff | off), s->io, MIN(s->iolen, NAND_PAGE_SIZE - off)); + if (off + s->iolen > NAND_PAGE_SIZE) { page = PAGE(s->addr); - mem_and(s->storage + (page << OOB_SHIFT), s->io + PAGE_SIZE - off, - MIN(OOB_SIZE, off + s->iolen - PAGE_SIZE)); + mem_and(s->storage + (page << OOB_SHIFT), s->io + NAND_PAGE_SIZE - off, + MIN(OOB_SIZE, off + s->iolen - NAND_PAGE_SIZE)); } if (blk_pwrite(s->blk, sector << BDRV_SECTOR_BITS, iobuf, @@ -704,7 +704,7 @@ static void glue(nand_blk_write_, PAGE_SIZE)(NANDFlashState *s) } /* Erase a single block */ -static void glue(nand_blk_erase_, PAGE_SIZE)(NANDFlashState *s) +static void glue(nand_blk_erase_, NAND_PAGE_SIZE)(NANDFlashState *s) { uint64_t i, page, addr; uint8_t iobuf[0x200] = { [0 ... 0x1ff] = 0xff, }; @@ -716,7 +716,7 @@ static void glue(nand_blk_erase_, PAGE_SIZE)(NANDFlashState *s) if (!s->blk) { memset(s->storage + PAGE_START(addr), - 0xff, (PAGE_SIZE + OOB_SIZE) << s->erase_shift); + 0xff, (NAND_PAGE_SIZE + OOB_SIZE) << s->erase_shift); } else if (s->mem_oob) { memset(s->storage + (PAGE(addr) << OOB_SHIFT), 0xff, OOB_SIZE << s->erase_shift); @@ -742,7 +742,7 @@ static void glue(nand_blk_erase_, PAGE_SIZE)(NANDFlashState *s) memset(iobuf, 0xff, 0x200); i = (addr & ~0x1ff) + 0x200; - for (addr += ((PAGE_SIZE + OOB_SIZE) << s->erase_shift) - 0x200; + for (addr += ((NAND_PAGE_SIZE + OOB_SIZE) << s->erase_shift) - 0x200; i < addr; i += 0x200) { if (blk_pwrite(s->blk, i, iobuf, BDRV_SECTOR_SIZE, 0) < 0) { printf("%s: write error in sector %" PRIu64 "\n", @@ -763,7 +763,7 @@ static void glue(nand_blk_erase_, PAGE_SIZE)(NANDFlashState *s) } } -static void glue(nand_blk_load_, PAGE_SIZE)(NANDFlashState *s, +static void glue(nand_blk_load_, NAND_PAGE_SIZE)(NANDFlashState *s, uint64_t addr, int offset) { if (PAGE(addr) >= s->pages) { @@ -777,7 +777,7 @@ static void glue(nand_blk_load_, PAGE_SIZE)(NANDFlashState *s, printf("%s: read error in sector %" PRIu64 "\n", __func__, SECTOR(addr)); } - memcpy(s->io + SECTOR_OFFSET(s->addr) + PAGE_SIZE, + memcpy(s->io + SECTOR_OFFSET(s->addr) + NAND_PAGE_SIZE, s->storage + (PAGE(s->addr) << OOB_SHIFT), OOB_SIZE); s->ioaddr = s->io + SECTOR_OFFSET(s->addr) + offset; @@ -791,23 +791,23 @@ static void glue(nand_blk_load_, PAGE_SIZE)(NANDFlashState *s, } } else { memcpy(s->io, s->storage + PAGE_START(s->addr) + - offset, PAGE_SIZE + OOB_SIZE - offset); + offset, NAND_PAGE_SIZE + OOB_SIZE - offset); s->ioaddr = s->io; } } -static void glue(nand_init_, PAGE_SIZE)(NANDFlashState *s) +static void glue(nand_init_, NAND_PAGE_SIZE)(NANDFlashState *s) { s->oob_shift = PAGE_SHIFT - 5; s->pages = s->size >> PAGE_SHIFT; s->addr_shift = ADDR_SHIFT; - s->blk_erase = glue(nand_blk_erase_, PAGE_SIZE); - s->blk_write = glue(nand_blk_write_, PAGE_SIZE); - s->blk_load = glue(nand_blk_load_, PAGE_SIZE); + s->blk_erase = glue(nand_blk_erase_, NAND_PAGE_SIZE); + s->blk_write = glue(nand_blk_write_, NAND_PAGE_SIZE); + s->blk_load = glue(nand_blk_load_, NAND_PAGE_SIZE); } -# undef PAGE_SIZE +# undef NAND_PAGE_SIZE # undef PAGE_SHIFT # undef PAGE_SECTORS # undef ADDR_SHIFT From 2d0fc797faaa73fbc1d30f5f9e90407bf3dd93f0 Mon Sep 17 00:00:00 2001 From: Jiaxun Yang Date: Mon, 18 Jan 2021 14:38:04 +0800 Subject: [PATCH 05/14] elf2dmp: Rename PAGE_SIZE to ELF2DMP_PAGE_SIZE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As per POSIX specification of limits.h [1], OS libc may define PAGE_SIZE in limits.h. To prevent collosion of definition, we rename PAGE_SIZE here. [1]: https://pubs.opengroup.org/onlinepubs/7908799/xsh/limits.h.html Signed-off-by: Jiaxun Yang Reviewed-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20210118063808.12471-6-jiaxun.yang@flygoat.com> Signed-off-by: Thomas Huth --- contrib/elf2dmp/addrspace.c | 4 ++-- contrib/elf2dmp/addrspace.h | 6 +++--- contrib/elf2dmp/main.c | 18 +++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/contrib/elf2dmp/addrspace.c b/contrib/elf2dmp/addrspace.c index 8a76069cb51f..53ded170618b 100644 --- a/contrib/elf2dmp/addrspace.c +++ b/contrib/elf2dmp/addrspace.c @@ -207,8 +207,8 @@ int va_space_rw(struct va_space *vs, uint64_t addr, void *buf, size_t size, int is_write) { while (size) { - uint64_t page = addr & PFN_MASK; - size_t s = (page + PAGE_SIZE) - addr; + uint64_t page = addr & ELF2DMP_PFN_MASK; + size_t s = (page + ELF2DMP_PAGE_SIZE) - addr; void *ptr; s = (s > size) ? size : s; diff --git a/contrib/elf2dmp/addrspace.h b/contrib/elf2dmp/addrspace.h index d87f6a18c684..00b44c121805 100644 --- a/contrib/elf2dmp/addrspace.h +++ b/contrib/elf2dmp/addrspace.h @@ -10,9 +10,9 @@ #include "qemu_elf.h" -#define PAGE_BITS 12 -#define PAGE_SIZE (1ULL << PAGE_BITS) -#define PFN_MASK (~(PAGE_SIZE - 1)) +#define ELF2DMP_PAGE_BITS 12 +#define ELF2DMP_PAGE_SIZE (1ULL << ELF2DMP_PAGE_BITS) +#define ELF2DMP_PFN_MASK (~(ELF2DMP_PAGE_SIZE - 1)) #define INVALID_PA UINT64_MAX diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c index ac746e49e097..20b477d582a4 100644 --- a/contrib/elf2dmp/main.c +++ b/contrib/elf2dmp/main.c @@ -244,8 +244,8 @@ static int fill_header(WinDumpHeader64 *hdr, struct pa_space *ps, WinDumpHeader64 h; size_t i; - QEMU_BUILD_BUG_ON(KUSD_OFFSET_SUITE_MASK >= PAGE_SIZE); - QEMU_BUILD_BUG_ON(KUSD_OFFSET_PRODUCT_TYPE >= PAGE_SIZE); + QEMU_BUILD_BUG_ON(KUSD_OFFSET_SUITE_MASK >= ELF2DMP_PAGE_SIZE); + QEMU_BUILD_BUG_ON(KUSD_OFFSET_PRODUCT_TYPE >= ELF2DMP_PAGE_SIZE); if (!suite_mask || !product_type) { return 1; @@ -281,14 +281,14 @@ static int fill_header(WinDumpHeader64 *hdr, struct pa_space *ps, }; for (i = 0; i < ps->block_nr; i++) { - h.PhysicalMemoryBlock.NumberOfPages += ps->block[i].size / PAGE_SIZE; + h.PhysicalMemoryBlock.NumberOfPages += ps->block[i].size / ELF2DMP_PAGE_SIZE; h.PhysicalMemoryBlock.Run[i] = (WinDumpPhyMemRun64) { - .BasePage = ps->block[i].paddr / PAGE_SIZE, - .PageCount = ps->block[i].size / PAGE_SIZE, + .BasePage = ps->block[i].paddr / ELF2DMP_PAGE_SIZE, + .PageCount = ps->block[i].size / ELF2DMP_PAGE_SIZE, }; } - h.RequiredDumpSpace += h.PhysicalMemoryBlock.NumberOfPages << PAGE_BITS; + h.RequiredDumpSpace += h.PhysicalMemoryBlock.NumberOfPages << ELF2DMP_PAGE_BITS; *hdr = h; @@ -379,7 +379,7 @@ static int pe_get_pdb_symstore_hash(uint64_t base, void *start_addr, size_t pdb_name_sz; size_t i; - QEMU_BUILD_BUG_ON(sizeof(*dos_hdr) >= PAGE_SIZE); + QEMU_BUILD_BUG_ON(sizeof(*dos_hdr) >= ELF2DMP_PAGE_SIZE); if (memcmp(&dos_hdr->e_magic, e_magic, sizeof(e_magic))) { return 1; @@ -509,10 +509,10 @@ int main(int argc, char *argv[]) } printf("CPU #0 IDT[0] -> 0x%016"PRIx64"\n", idt_desc_addr(first_idt_desc)); - KernBase = idt_desc_addr(first_idt_desc) & ~(PAGE_SIZE - 1); + KernBase = idt_desc_addr(first_idt_desc) & ~(ELF2DMP_PAGE_SIZE - 1); printf("Searching kernel downwards from 0x%016"PRIx64"...\n", KernBase); - for (; KernBase >= 0xfffff78000000000; KernBase -= PAGE_SIZE) { + for (; KernBase >= 0xfffff78000000000; KernBase -= ELF2DMP_PAGE_SIZE) { nt_start_addr = va_space_resolve(&vs, KernBase); if (!nt_start_addr) { continue; From d2c4f3841d1cba17c99f76812ffcb75a6c402202 Mon Sep 17 00:00:00 2001 From: Jiaxun Yang Date: Mon, 18 Jan 2021 14:38:05 +0800 Subject: [PATCH 06/14] tests: Rename PAGE_SIZE definitions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As per POSIX specification of limits.h [1], OS libc may define PAGE_SIZE in limits.h. Self defined PAGE_SIZE is frequently used in tests, to prevent collosion of definition, we give PAGE_SIZE definitons reasonable prefixs. [1]: https://pubs.opengroup.org/onlinepubs/7908799/xsh/limits.h.html Signed-off-by: Jiaxun Yang Reviewed-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20210118063808.12471-7-jiaxun.yang@flygoat.com> Signed-off-by: Thomas Huth --- tests/migration/stress.c | 10 ++--- tests/qtest/libqos/malloc-pc.c | 4 +- tests/qtest/libqos/malloc-spapr.c | 4 +- tests/qtest/m25p80-test.c | 54 +++++++++++----------- tests/tcg/multiarch/system/memory.c | 6 +-- tests/test-xbzrle.c | 70 ++++++++++++++--------------- 6 files changed, 74 insertions(+), 74 deletions(-) diff --git a/tests/migration/stress.c b/tests/migration/stress.c index de45e8e49082..b7240a15c808 100644 --- a/tests/migration/stress.c +++ b/tests/migration/stress.c @@ -27,7 +27,7 @@ const char *argv0; -#define PAGE_SIZE 4096 +#define RAM_PAGE_SIZE 4096 #ifndef CONFIG_GETTID static int gettid(void) @@ -158,11 +158,11 @@ static unsigned long long now(void) static void stressone(unsigned long long ramsizeMB) { - size_t pagesPerMB = 1024 * 1024 / PAGE_SIZE; + size_t pagesPerMB = 1024 * 1024 / RAM_PAGE_SIZE; g_autofree char *ram = g_malloc(ramsizeMB * 1024 * 1024); char *ramptr; size_t i, j, k; - g_autofree char *data = g_malloc(PAGE_SIZE); + g_autofree char *data = g_malloc(RAM_PAGE_SIZE); char *dataptr; size_t nMB = 0; unsigned long long before, after; @@ -174,7 +174,7 @@ static void stressone(unsigned long long ramsizeMB) * calloc instead :-) */ memset(ram, 0xfe, ramsizeMB * 1024 * 1024); - if (random_bytes(data, PAGE_SIZE) < 0) { + if (random_bytes(data, RAM_PAGE_SIZE) < 0) { return; } @@ -186,7 +186,7 @@ static void stressone(unsigned long long ramsizeMB) for (i = 0; i < ramsizeMB; i++, nMB++) { for (j = 0; j < pagesPerMB; j++) { dataptr = data; - for (k = 0; k < PAGE_SIZE; k += sizeof(long long)) { + for (k = 0; k < RAM_PAGE_SIZE; k += sizeof(long long)) { ramptr += sizeof(long long); dataptr += sizeof(long long); *(unsigned long long *)ramptr ^= *(unsigned long long *)dataptr; diff --git a/tests/qtest/libqos/malloc-pc.c b/tests/qtest/libqos/malloc-pc.c index 16ff9609ccc0..f1e3b392a53c 100644 --- a/tests/qtest/libqos/malloc-pc.c +++ b/tests/qtest/libqos/malloc-pc.c @@ -18,7 +18,7 @@ #include "qemu-common.h" -#define PAGE_SIZE (4096) +#define ALLOC_PAGE_SIZE (4096) void pc_alloc_init(QGuestAllocator *s, QTestState *qts, QAllocOpts flags) { @@ -26,7 +26,7 @@ void pc_alloc_init(QGuestAllocator *s, QTestState *qts, QAllocOpts flags) QFWCFG *fw_cfg = pc_fw_cfg_init(qts); ram_size = qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE); - alloc_init(s, flags, 1 << 20, MIN(ram_size, 0xE0000000), PAGE_SIZE); + alloc_init(s, flags, 1 << 20, MIN(ram_size, 0xE0000000), ALLOC_PAGE_SIZE); /* clean-up */ pc_fw_cfg_uninit(fw_cfg); diff --git a/tests/qtest/libqos/malloc-spapr.c b/tests/qtest/libqos/malloc-spapr.c index 84862e48768a..05b306c191d3 100644 --- a/tests/qtest/libqos/malloc-spapr.c +++ b/tests/qtest/libqos/malloc-spapr.c @@ -10,7 +10,7 @@ #include "qemu-common.h" -#define PAGE_SIZE 4096 +#define SPAPR_PAGE_SIZE 4096 /* Memory must be a multiple of 256 MB, * so we have at least 256MB @@ -19,5 +19,5 @@ void spapr_alloc_init(QGuestAllocator *s, QTestState *qts, QAllocOpts flags) { - alloc_init(s, flags, 1 << 20, SPAPR_MIN_SIZE, PAGE_SIZE); + alloc_init(s, flags, 1 << 20, SPAPR_MIN_SIZE, SPAPR_PAGE_SIZE); } diff --git a/tests/qtest/m25p80-test.c b/tests/qtest/m25p80-test.c index 50c6b79fb3ac..f860cef5f08f 100644 --- a/tests/qtest/m25p80-test.c +++ b/tests/qtest/m25p80-test.c @@ -62,7 +62,7 @@ enum { #define FLASH_JEDEC 0x20ba19 /* n25q256a */ #define FLASH_SIZE (32 * 1024 * 1024) -#define PAGE_SIZE 256 +#define FLASH_PAGE_SIZE 256 /* * Use an explicit bswap for the values read/wrote to the flash region @@ -165,7 +165,7 @@ static void read_page(uint32_t addr, uint32_t *page) writel(ASPEED_FLASH_BASE, make_be32(addr)); /* Continuous read are supported */ - for (i = 0; i < PAGE_SIZE / 4; i++) { + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { page[i] = make_be32(readl(ASPEED_FLASH_BASE)); } spi_ctrl_stop_user(); @@ -178,15 +178,15 @@ static void read_page_mem(uint32_t addr, uint32_t *page) /* move out USER mode to use direct reads from the AHB bus */ spi_ctrl_setmode(CTRL_READMODE, READ); - for (i = 0; i < PAGE_SIZE / 4; i++) { + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { page[i] = make_be32(readl(ASPEED_FLASH_BASE + addr + i * 4)); } } static void test_erase_sector(void) { - uint32_t some_page_addr = 0x600 * PAGE_SIZE; - uint32_t page[PAGE_SIZE / 4]; + uint32_t some_page_addr = 0x600 * FLASH_PAGE_SIZE; + uint32_t page[FLASH_PAGE_SIZE / 4]; int i; spi_conf(CONF_ENABLE_W0); @@ -200,14 +200,14 @@ static void test_erase_sector(void) /* Previous page should be full of zeroes as backend is not * initialized */ - read_page(some_page_addr - PAGE_SIZE, page); - for (i = 0; i < PAGE_SIZE / 4; i++) { + read_page(some_page_addr - FLASH_PAGE_SIZE, page); + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { g_assert_cmphex(page[i], ==, 0x0); } /* But this one was erased */ read_page(some_page_addr, page); - for (i = 0; i < PAGE_SIZE / 4; i++) { + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { g_assert_cmphex(page[i], ==, 0xffffffff); } @@ -216,8 +216,8 @@ static void test_erase_sector(void) static void test_erase_all(void) { - uint32_t some_page_addr = 0x15000 * PAGE_SIZE; - uint32_t page[PAGE_SIZE / 4]; + uint32_t some_page_addr = 0x15000 * FLASH_PAGE_SIZE; + uint32_t page[FLASH_PAGE_SIZE / 4]; int i; spi_conf(CONF_ENABLE_W0); @@ -225,7 +225,7 @@ static void test_erase_all(void) /* Check some random page. Should be full of zeroes as backend is * not initialized */ read_page(some_page_addr, page); - for (i = 0; i < PAGE_SIZE / 4; i++) { + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { g_assert_cmphex(page[i], ==, 0x0); } @@ -236,7 +236,7 @@ static void test_erase_all(void) /* Recheck that some random page */ read_page(some_page_addr, page); - for (i = 0; i < PAGE_SIZE / 4; i++) { + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { g_assert_cmphex(page[i], ==, 0xffffffff); } @@ -245,9 +245,9 @@ static void test_erase_all(void) static void test_write_page(void) { - uint32_t my_page_addr = 0x14000 * PAGE_SIZE; /* beyond 16MB */ - uint32_t some_page_addr = 0x15000 * PAGE_SIZE; - uint32_t page[PAGE_SIZE / 4]; + uint32_t my_page_addr = 0x14000 * FLASH_PAGE_SIZE; /* beyond 16MB */ + uint32_t some_page_addr = 0x15000 * FLASH_PAGE_SIZE; + uint32_t page[FLASH_PAGE_SIZE / 4]; int i; spi_conf(CONF_ENABLE_W0); @@ -259,20 +259,20 @@ static void test_write_page(void) writel(ASPEED_FLASH_BASE, make_be32(my_page_addr)); /* Fill the page with its own addresses */ - for (i = 0; i < PAGE_SIZE / 4; i++) { + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { writel(ASPEED_FLASH_BASE, make_be32(my_page_addr + i * 4)); } spi_ctrl_stop_user(); /* Check what was written */ read_page(my_page_addr, page); - for (i = 0; i < PAGE_SIZE / 4; i++) { + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { g_assert_cmphex(page[i], ==, my_page_addr + i * 4); } /* Check some other page. It should be full of 0xff */ read_page(some_page_addr, page); - for (i = 0; i < PAGE_SIZE / 4; i++) { + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { g_assert_cmphex(page[i], ==, 0xffffffff); } @@ -281,9 +281,9 @@ static void test_write_page(void) static void test_read_page_mem(void) { - uint32_t my_page_addr = 0x14000 * PAGE_SIZE; /* beyond 16MB */ - uint32_t some_page_addr = 0x15000 * PAGE_SIZE; - uint32_t page[PAGE_SIZE / 4]; + uint32_t my_page_addr = 0x14000 * FLASH_PAGE_SIZE; /* beyond 16MB */ + uint32_t some_page_addr = 0x15000 * FLASH_PAGE_SIZE; + uint32_t page[FLASH_PAGE_SIZE / 4]; int i; /* Enable 4BYTE mode for controller. This is should be strapped by @@ -300,13 +300,13 @@ static void test_read_page_mem(void) /* Check what was written */ read_page_mem(my_page_addr, page); - for (i = 0; i < PAGE_SIZE / 4; i++) { + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { g_assert_cmphex(page[i], ==, my_page_addr + i * 4); } /* Check some other page. It should be full of 0xff */ read_page_mem(some_page_addr, page); - for (i = 0; i < PAGE_SIZE / 4; i++) { + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { g_assert_cmphex(page[i], ==, 0xffffffff); } @@ -315,8 +315,8 @@ static void test_read_page_mem(void) static void test_write_page_mem(void) { - uint32_t my_page_addr = 0x15000 * PAGE_SIZE; - uint32_t page[PAGE_SIZE / 4]; + uint32_t my_page_addr = 0x15000 * FLASH_PAGE_SIZE; + uint32_t page[FLASH_PAGE_SIZE / 4]; int i; /* Enable 4BYTE mode for controller. This is should be strapped by @@ -334,14 +334,14 @@ static void test_write_page_mem(void) /* move out USER mode to use direct writes to the AHB bus */ spi_ctrl_setmode(CTRL_WRITEMODE, PP); - for (i = 0; i < PAGE_SIZE / 4; i++) { + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { writel(ASPEED_FLASH_BASE + my_page_addr + i * 4, make_be32(my_page_addr + i * 4)); } /* Check what was written */ read_page_mem(my_page_addr, page); - for (i = 0; i < PAGE_SIZE / 4; i++) { + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { g_assert_cmphex(page[i], ==, my_page_addr + i * 4); } diff --git a/tests/tcg/multiarch/system/memory.c b/tests/tcg/multiarch/system/memory.c index d124502d730a..eb0ec6f8ebe9 100644 --- a/tests/tcg/multiarch/system/memory.c +++ b/tests/tcg/multiarch/system/memory.c @@ -20,12 +20,12 @@ # error "Target does not specify CHECK_UNALIGNED" #endif -#define PAGE_SIZE 4096 /* nominal 4k "pages" */ -#define TEST_SIZE (PAGE_SIZE * 4) /* 4 pages */ +#define MEM_PAGE_SIZE 4096 /* nominal 4k "pages" */ +#define TEST_SIZE (MEM_PAGE_SIZE * 4) /* 4 pages */ #define ARRAY_SIZE(x) ((sizeof(x) / sizeof((x)[0]))) -__attribute__((aligned(PAGE_SIZE))) +__attribute__((aligned(MEM_PAGE_SIZE))) static uint8_t test_data[TEST_SIZE]; typedef void (*init_ufn) (int offset); diff --git a/tests/test-xbzrle.c b/tests/test-xbzrle.c index f5e08de91ecf..795d6f1cbabb 100644 --- a/tests/test-xbzrle.c +++ b/tests/test-xbzrle.c @@ -15,7 +15,7 @@ #include "qemu/cutils.h" #include "../migration/xbzrle.h" -#define PAGE_SIZE 4096 +#define XBZRLE_PAGE_SIZE 4096 static void test_uleb(void) { @@ -41,11 +41,11 @@ static void test_uleb(void) static void test_encode_decode_zero(void) { - uint8_t *buffer = g_malloc0(PAGE_SIZE); - uint8_t *compressed = g_malloc0(PAGE_SIZE); + uint8_t *buffer = g_malloc0(XBZRLE_PAGE_SIZE); + uint8_t *compressed = g_malloc0(XBZRLE_PAGE_SIZE); int i = 0; int dlen = 0; - int diff_len = g_test_rand_int_range(0, PAGE_SIZE - 1006); + int diff_len = g_test_rand_int_range(0, XBZRLE_PAGE_SIZE - 1006); for (i = diff_len; i > 0; i--) { buffer[1000 + i] = i; @@ -55,8 +55,8 @@ static void test_encode_decode_zero(void) buffer[1000 + diff_len + 5] = 105; /* encode zero page */ - dlen = xbzrle_encode_buffer(buffer, buffer, PAGE_SIZE, compressed, - PAGE_SIZE); + dlen = xbzrle_encode_buffer(buffer, buffer, XBZRLE_PAGE_SIZE, compressed, + XBZRLE_PAGE_SIZE); g_assert(dlen == 0); g_free(buffer); @@ -65,11 +65,11 @@ static void test_encode_decode_zero(void) static void test_encode_decode_unchanged(void) { - uint8_t *compressed = g_malloc0(PAGE_SIZE); - uint8_t *test = g_malloc0(PAGE_SIZE); + uint8_t *compressed = g_malloc0(XBZRLE_PAGE_SIZE); + uint8_t *test = g_malloc0(XBZRLE_PAGE_SIZE); int i = 0; int dlen = 0; - int diff_len = g_test_rand_int_range(0, PAGE_SIZE - 1006); + int diff_len = g_test_rand_int_range(0, XBZRLE_PAGE_SIZE - 1006); for (i = diff_len; i > 0; i--) { test[1000 + i] = i + 4; @@ -79,8 +79,8 @@ static void test_encode_decode_unchanged(void) test[1000 + diff_len + 5] = 109; /* test unchanged buffer */ - dlen = xbzrle_encode_buffer(test, test, PAGE_SIZE, compressed, - PAGE_SIZE); + dlen = xbzrle_encode_buffer(test, test, XBZRLE_PAGE_SIZE, compressed, + XBZRLE_PAGE_SIZE); g_assert(dlen == 0); g_free(test); @@ -89,21 +89,21 @@ static void test_encode_decode_unchanged(void) static void test_encode_decode_1_byte(void) { - uint8_t *buffer = g_malloc0(PAGE_SIZE); - uint8_t *test = g_malloc0(PAGE_SIZE); - uint8_t *compressed = g_malloc(PAGE_SIZE); + uint8_t *buffer = g_malloc0(XBZRLE_PAGE_SIZE); + uint8_t *test = g_malloc0(XBZRLE_PAGE_SIZE); + uint8_t *compressed = g_malloc(XBZRLE_PAGE_SIZE); int dlen = 0, rc = 0; uint8_t buf[2]; - test[PAGE_SIZE - 1] = 1; + test[XBZRLE_PAGE_SIZE - 1] = 1; - dlen = xbzrle_encode_buffer(buffer, test, PAGE_SIZE, compressed, - PAGE_SIZE); + dlen = xbzrle_encode_buffer(buffer, test, XBZRLE_PAGE_SIZE, compressed, + XBZRLE_PAGE_SIZE); g_assert(dlen == (uleb128_encode_small(&buf[0], 4095) + 2)); - rc = xbzrle_decode_buffer(compressed, dlen, buffer, PAGE_SIZE); - g_assert(rc == PAGE_SIZE); - g_assert(memcmp(test, buffer, PAGE_SIZE) == 0); + rc = xbzrle_decode_buffer(compressed, dlen, buffer, XBZRLE_PAGE_SIZE); + g_assert(rc == XBZRLE_PAGE_SIZE); + g_assert(memcmp(test, buffer, XBZRLE_PAGE_SIZE) == 0); g_free(buffer); g_free(compressed); @@ -112,18 +112,18 @@ static void test_encode_decode_1_byte(void) static void test_encode_decode_overflow(void) { - uint8_t *compressed = g_malloc0(PAGE_SIZE); - uint8_t *test = g_malloc0(PAGE_SIZE); - uint8_t *buffer = g_malloc0(PAGE_SIZE); + uint8_t *compressed = g_malloc0(XBZRLE_PAGE_SIZE); + uint8_t *test = g_malloc0(XBZRLE_PAGE_SIZE); + uint8_t *buffer = g_malloc0(XBZRLE_PAGE_SIZE); int i = 0, rc = 0; - for (i = 0; i < PAGE_SIZE / 2 - 1; i++) { + for (i = 0; i < XBZRLE_PAGE_SIZE / 2 - 1; i++) { test[i * 2] = 1; } /* encode overflow */ - rc = xbzrle_encode_buffer(buffer, test, PAGE_SIZE, compressed, - PAGE_SIZE); + rc = xbzrle_encode_buffer(buffer, test, XBZRLE_PAGE_SIZE, compressed, + XBZRLE_PAGE_SIZE); g_assert(rc == -1); g_free(buffer); @@ -133,13 +133,13 @@ static void test_encode_decode_overflow(void) static void encode_decode_range(void) { - uint8_t *buffer = g_malloc0(PAGE_SIZE); - uint8_t *compressed = g_malloc(PAGE_SIZE); - uint8_t *test = g_malloc0(PAGE_SIZE); + uint8_t *buffer = g_malloc0(XBZRLE_PAGE_SIZE); + uint8_t *compressed = g_malloc(XBZRLE_PAGE_SIZE); + uint8_t *test = g_malloc0(XBZRLE_PAGE_SIZE); int i = 0, rc = 0; int dlen = 0; - int diff_len = g_test_rand_int_range(0, PAGE_SIZE - 1006); + int diff_len = g_test_rand_int_range(0, XBZRLE_PAGE_SIZE - 1006); for (i = diff_len; i > 0; i--) { buffer[1000 + i] = i; @@ -153,12 +153,12 @@ static void encode_decode_range(void) test[1000 + diff_len + 5] = 109; /* test encode/decode */ - dlen = xbzrle_encode_buffer(test, buffer, PAGE_SIZE, compressed, - PAGE_SIZE); + dlen = xbzrle_encode_buffer(test, buffer, XBZRLE_PAGE_SIZE, compressed, + XBZRLE_PAGE_SIZE); - rc = xbzrle_decode_buffer(compressed, dlen, test, PAGE_SIZE); - g_assert(rc < PAGE_SIZE); - g_assert(memcmp(test, buffer, PAGE_SIZE) == 0); + rc = xbzrle_decode_buffer(compressed, dlen, test, XBZRLE_PAGE_SIZE); + g_assert(rc < XBZRLE_PAGE_SIZE); + g_assert(memcmp(test, buffer, XBZRLE_PAGE_SIZE) == 0); g_free(buffer); g_free(compressed); From eb8b1a797a86d72b0eddc6cfd5cc018849417e7a Mon Sep 17 00:00:00 2001 From: Jiaxun Yang Date: Mon, 18 Jan 2021 14:38:06 +0800 Subject: [PATCH 07/14] accel/kvm: avoid using predefined PAGE_SIZE As per POSIX specification of limits.h [1], OS libc may define PAGE_SIZE in limits.h. PAGE_SIZE is used in included kernel uapi headers. To prevent collosion of definition, we discard PAGE_SIZE from defined by libc and take QEMU's variable. [1]: https://pubs.opengroup.org/onlinepubs/7908799/xsh/limits.h.html Signed-off-by: Jiaxun Yang Message-Id: <20210118063808.12471-8-jiaxun.yang@flygoat.com> Signed-off-by: Thomas Huth --- accel/kvm/kvm-all.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 389eaace7289..3feb17d9651c 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -58,6 +58,9 @@ /* KVM uses PAGE_SIZE in its definition of KVM_COALESCED_MMIO_MAX. We * need to use the real host PAGE_SIZE, as that's what KVM will use. */ +#ifdef PAGE_SIZE +#undef PAGE_SIZE +#endif #define PAGE_SIZE qemu_real_host_page_size //#define DEBUG_KVM From 8df04b04ed1ea0e61b2c11129a8e73132a20c35c Mon Sep 17 00:00:00 2001 From: Jiaxun Yang Date: Mon, 18 Jan 2021 14:38:07 +0800 Subject: [PATCH 08/14] tests/docker: Add dockerfile for Alpine Linux Alpine Linux[1] is a security-oriented, lightweight Linux distribution based on musl libc and busybox. It it popular among Docker guests and embedded applications. Adding it to test against different libc. [1]: https://alpinelinux.org/ Signed-off-by: Jiaxun Yang Message-Id: <20210118063808.12471-9-jiaxun.yang@flygoat.com> [thuth: Dropped some unnecessary packages, replaced build-base with its deps] Signed-off-by: Thomas Huth --- tests/docker/dockerfiles/alpine.docker | 55 ++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/docker/dockerfiles/alpine.docker diff --git a/tests/docker/dockerfiles/alpine.docker b/tests/docker/dockerfiles/alpine.docker new file mode 100644 index 000000000000..d63a269aef79 --- /dev/null +++ b/tests/docker/dockerfiles/alpine.docker @@ -0,0 +1,55 @@ + +FROM alpine:edge + +RUN apk update +RUN apk upgrade + +# Please keep this list sorted alphabetically +ENV PACKAGES \ + alsa-lib-dev \ + bash \ + binutils \ + coreutils \ + curl-dev \ + g++ \ + gcc \ + git \ + glib-dev \ + glib-static \ + gnutls-dev \ + gtk+3.0-dev \ + libaio-dev \ + libcap-ng-dev \ + libjpeg-turbo-dev \ + libnfs-dev \ + libpng-dev \ + libseccomp-dev \ + libssh-dev \ + libusb-dev \ + libxml2-dev \ + lzo-dev \ + make \ + mesa-dev \ + mesa-egl \ + mesa-gbm \ + meson \ + ncurses-dev \ + ninja \ + perl \ + pulseaudio-dev \ + python3 \ + py3-sphinx \ + shadow \ + snappy-dev \ + spice-dev \ + texinfo \ + usbredir-dev \ + util-linux-dev \ + vde2-dev \ + virglrenderer-dev \ + vte3-dev \ + xfsprogs-dev \ + zlib-dev \ + zlib-static + +RUN apk add $PACKAGES From 872cda9c5e81e10e5e9c364a1a062c1ac536ec2a Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Tue, 19 Jan 2021 14:47:49 +0100 Subject: [PATCH 09/14] tests/check-block.sh: Refuse to run the iotests with BusyBox' sed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BusyBox' sed reports itself as "This is not GNU sed version 4.0" when being run with the --version parameter. However, the iotests really need GNU sed, they do not work with the BusyBox version. So let's make sure that we really have GNU sed and refuse to run the tests with BusyBox' sed. Signed-off-by: Thomas Huth Message-Id: <20210119134749.401311-1-thuth@redhat.com> Reviewed-by: Daniel P. Berrangé Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Thomas Huth --- tests/check-block.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/check-block.sh b/tests/check-block.sh index fb4c1baae98a..e4f37905befd 100755 --- a/tests/check-block.sh +++ b/tests/check-block.sh @@ -60,6 +60,13 @@ if ! (sed --version | grep 'GNU sed') > /dev/null 2>&1 ; then echo "GNU sed not available ==> Not running the qemu-iotests." exit 0 fi +else + # Double-check that we're not using BusyBox' sed which says + # that "This is not GNU sed version 4.0" ... + if sed --version | grep -q 'not GNU sed' ; then + echo "BusyBox sed not supported ==> Not running the qemu-iotests." + exit 0 + fi fi cd tests/qemu-iotests From b22786eab0f070a1981201ecbd952bafc371c615 Mon Sep 17 00:00:00 2001 From: Jiaxun Yang Date: Mon, 18 Jan 2021 14:38:08 +0800 Subject: [PATCH 10/14] gitlab-ci: Add alpine to pipeline [thuth: Enable "make check" tests, too, after tests/check-block.sh got fixed] Signed-off-by: Jiaxun Yang Message-Id: <20210118063808.12471-10-jiaxun.yang@flygoat.com> Signed-off-by: Thomas Huth --- .gitlab-ci.d/containers.yml | 5 +++++ .gitlab-ci.yml | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/.gitlab-ci.d/containers.yml b/.gitlab-ci.d/containers.yml index 910754a699f7..90fac85ce46d 100644 --- a/.gitlab-ci.d/containers.yml +++ b/.gitlab-ci.d/containers.yml @@ -28,6 +28,11 @@ - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' - if: '$CI_COMMIT_REF_NAME == "testing/next"' +amd64-alpine-container: + <<: *container_job_definition + variables: + NAME: alpine + amd64-centos7-container: <<: *container_job_definition variables: diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 203b1671c43a..de3a3d25b586 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -72,6 +72,39 @@ include: - cd build - du -chs ${CI_PROJECT_DIR}/avocado-cache +build-system-alpine: + <<: *native_build_job_definition + variables: + IMAGE: alpine + TARGETS: aarch64-softmmu alpha-softmmu cris-softmmu hppa-softmmu + moxie-softmmu microblazeel-softmmu mips64el-softmmu + MAKE_CHECK_ARGS: check-build + CONFIGURE_ARGS: --enable-docs + artifacts: + expire_in: 2 days + paths: + - .git-submodule-status + - build + +check-system-alpine: + <<: *native_test_job_definition + needs: + - job: build-system-alpine + artifacts: true + variables: + IMAGE: alpine + MAKE_CHECK_ARGS: check + +acceptance-system-alpine: + <<: *native_test_job_definition + needs: + - job: build-system-alpine + artifacts: true + variables: + IMAGE: alpine + MAKE_CHECK_ARGS: check-acceptance + <<: *acceptance_definition + build-system-ubuntu: <<: *native_build_job_definition variables: From 3e829c0468969274d53bba4cdab3b3fd68a38b45 Mon Sep 17 00:00:00 2001 From: Gan Qixin Date: Fri, 15 Jan 2021 15:56:34 +0800 Subject: [PATCH 11/14] qtest/npcm7xx_pwm-test: Fix memleak in pwm_qom_get MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pwm_qom_get function didn't free "response", which caused an indirect memory leak. So use qobject_unref() to fix it. ASAN shows memory leak stack: Indirect leak of 74160000 byte(s) in 18000 object(s) allocated from: #0 0x7f96e2f79d4e in __interceptor_calloc (/lib64/libasan.so.5+0x112d4e) #1 0x7f96e2d98a50 in g_malloc0 (/lib64/libglib-2.0.so.0+0x55a50) #2 0x556313112180 in qdict_new ../qobject/qdict.c:30 #3 0x556313115bca in parse_object ../qobject/json-parser.c:318 #4 0x556313117810 in parse_value ../qobject/json-parser.c:546 #5 0x556313117bda in json_parser_parse ../qobject/json-parser.c:580 #6 0x55631310fe67 in json_message_process_token ../qobject/json-streamer.c:92 #7 0x5563131210b7 in json_lexer_feed_char ../qobject/json-lexer.c:313 #8 0x556313121662 in json_lexer_feed ../qobject/json-lexer.c:350 #9 0x5563131101e9 in json_message_parser_feed ../qobject/json-streamer.c:121 #10 0x5563130cb81e in qmp_fd_receive ../tests/qtest/libqtest.c:614 #11 0x5563130cba2b in qtest_qmp_receive_dict ../tests/qtest/libqtest.c:636 #12 0x5563130cb939 in qtest_qmp_receive ../tests/qtest/libqtest.c:624 #13 0x5563130cbe0d in qtest_vqmp ../tests/qtest/libqtest.c:715 #14 0x5563130cc40f in qtest_qmp ../tests/qtest/libqtest.c:756 #15 0x5563130c5623 in pwm_qom_get ../tests/qtest/npcm7xx_pwm-test.c:180 #16 0x5563130c595e in pwm_get_duty ../tests/qtest/npcm7xx_pwm-test.c:210 #17 0x5563130c7529 in test_toggle ../tests/qtest/npcm7xx_pwm-test.c:447 Reported-by: Euler Robot Message-Id: <20210115075634.717909-1-ganqixin@huawei.com> Signed-off-by: Gan Qixin Reviewed-by: Havard Skinnemoen Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Hao Wu Signed-off-by: Thomas Huth --- tests/qtest/npcm7xx_pwm-test.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/qtest/npcm7xx_pwm-test.c b/tests/qtest/npcm7xx_pwm-test.c index 33fbdf5f5451..63557d2c061e 100644 --- a/tests/qtest/npcm7xx_pwm-test.c +++ b/tests/qtest/npcm7xx_pwm-test.c @@ -175,6 +175,7 @@ static int pwm_index(const PWM *pwm) static uint64_t pwm_qom_get(QTestState *qts, const char *path, const char *name) { QDict *response; + uint64_t val; g_test_message("Getting properties %s from %s", name, path); response = qtest_qmp(qts, "{ 'execute': 'qom-get'," @@ -182,7 +183,9 @@ static uint64_t pwm_qom_get(QTestState *qts, const char *path, const char *name) path, name); /* The qom set message returns successfully. */ g_assert_true(qdict_haskey(response, "return")); - return qnum_get_uint(qobject_to(QNum, qdict_get(response, "return"))); + val = qnum_get_uint(qobject_to(QNum, qdict_get(response, "return"))); + qobject_unref(response); + return val; } static uint64_t pwm_get_freq(QTestState *qts, int module_index, int pwm_index) From f8e3df09d2a13e9919edba4b4d54efd6369ae548 Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Fri, 15 Jan 2021 15:46:37 -0500 Subject: [PATCH 12/14] tests: Fix memory leak in tpm-util.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch fixes the following memory leak detected by asan: Indirect leak of 560320 byte(s) in 136 object(s) allocated from: #0 0x556b3b3f9b57 in calloc (/home/stefanb/tmp/qemu-tip/build/tests/qtest/tpm-crb-swtpm-test+0x23fb57) #1 0x152b0e96b9b0 in g_malloc0 (/lib64/libglib-2.0.so.0+0x589b0) #2 0x556b3b588f61 in parse_object /home/stefanb/tmp/qemu-tip/build/../qobject/json-parser.c:318:12 #3 0x556b3b588f61 in parse_value /home/stefanb/tmp/qemu-tip/build/../qobject/json-parser.c:546:16 #4 0x556b3b5886e8 in json_parser_parse /home/stefanb/tmp/qemu-tip/build/../qobject/json-parser.c:580:14 #5 0x556b3b52ff4a in json_message_process_token /home/stefanb/tmp/qemu-tip/build/../qobject/json-streamer.c:92:12 #6 0x556b3b59896f in json_lexer_feed_char /home/stefanb/tmp/qemu-tip/build/../qobject/json-lexer.c:313:13 #7 0x556b3b598443 in json_lexer_feed /home/stefanb/tmp/qemu-tip/build/../qobject/json-lexer.c:350:9 #8 0x556b3b436c70 in qmp_fd_receive /home/stefanb/tmp/qemu-tip/build/../tests/qtest/libqtest.c:614:9 #9 0x556b3b435871 in qtest_qmp_receive_dict /home/stefanb/tmp/qemu-tip/build/../tests/qtest/libqtest.c:636:12 #10 0x556b3b435871 in qtest_qmp_receive /home/stefanb/tmp/qemu-tip/build/../tests/qtest/libqtest.c:624:27 #11 0x556b3b435c59 in qtest_vqmp /home/stefanb/tmp/qemu-tip/build/../tests/qtest/libqtest.c:715:12 #12 0x556b3b435c59 in qtest_qmp /home/stefanb/tmp/qemu-tip/build/../tests/qtest/libqtest.c:756:16 #13 0x556b3b4328c7 in tpm_util_wait_for_migration_complete /home/stefanb/tmp/qemu-tip/build/../tests/qtest/tpm-util.c:245:15 #14 0x556b3b4333be in tpm_test_swtpm_migration_test /home/stefanb/tmp/qemu-tip/build/../tests/qtest/tpm-tests.c:117:5 #15 0x152b0e98e29d (/lib64/libglib-2.0.so.0+0x7b29d) Signed-off-by: Stefan Berger Cc: Philippe Mathieu-Daudé Message-Id: <20210115204637.3332555-1-stefanb@linux.vnet.ibm.com> Signed-off-by: Thomas Huth --- tests/qtest/tpm-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qtest/tpm-util.c b/tests/qtest/tpm-util.c index 5a33a6ef0f59..b70cc32d6006 100644 --- a/tests/qtest/tpm-util.c +++ b/tests/qtest/tpm-util.c @@ -250,7 +250,7 @@ void tpm_util_wait_for_migration_complete(QTestState *who) status = qdict_get_str(rsp_return, "status"); completed = strcmp(status, "completed") == 0; g_assert_cmpstr(status, !=, "failed"); - qobject_unref(rsp_return); + qobject_unref(rsp); if (completed) { return; } From 2b42989c04172c6bb6f990a9c6ac224b52faab53 Mon Sep 17 00:00:00 2001 From: John Snow Date: Fri, 30 Oct 2020 11:34:15 -0400 Subject: [PATCH 13/14] MAINTAINERS: Remove Ben Warren Ben's email bounces and he no longer works for Skyport Systems. I was unable to reach Ben, so mark this section as Orphaned for now. Signed-off-by: John Snow Message-Id: <20201030153416.429791-2-jsnow@redhat.com> Signed-off-by: Thomas Huth --- MAINTAINERS | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 3216387521da..778b3da4060f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1999,8 +1999,7 @@ F: include/hw/nvram/chrp_nvram.h F: tests/qtest/prom-env-test.c VM Generation ID -M: Ben Warren -S: Maintained +S: Orphan F: hw/acpi/vmgenid.c F: include/hw/acpi/vmgenid.h F: docs/specs/vmgenid.txt From 4251dfb082f6b81c382e69ccd2700fcfa7d7aa82 Mon Sep 17 00:00:00 2001 From: John Snow Date: Fri, 30 Oct 2020 11:34:16 -0400 Subject: [PATCH 14/14] MAINTAINERS: Make status spellings consistent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20201030153416.429791-3-jsnow@redhat.com> Signed-off-by: Thomas Huth --- MAINTAINERS | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 778b3da4060f..34359a99b8e7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1142,7 +1142,7 @@ F: tests/acceptance/machine_mips_malta.py Mipssim R: Aleksandar Rikalo -S: Orphaned +S: Orphan F: hw/mips/mipssim.c F: hw/net/mipsnet.c @@ -2443,7 +2443,7 @@ T: git https://gitlab.com/jsnow/qemu.git python Python scripts M: Eduardo Habkost M: Cleber Rosa -S: Odd fixes +S: Odd Fixes F: scripts/*.py F: tests/*.py @@ -2680,7 +2680,7 @@ F: tests/test-coroutine.c Buffers M: Daniel P. Berrange -S: Odd fixes +S: Odd Fixes F: util/buffer.c F: include/qemu/buffer.h @@ -2709,7 +2709,7 @@ F: qapi/sockets.json File monitor M: Daniel P. Berrange -S: Odd fixes +S: Odd Fixes F: util/filemonitor*.c F: include/qemu/filemonitor.h F: tests/test-util-filemonitor.c @@ -3263,7 +3263,7 @@ S: Odd Fixes F: scripts/git-submodule.sh UI translations -S: Orphaned +S: Orphan F: po/*.po Sphinx documentation configuration and build machinery