From patchwork Tue Sep 6 13:17:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 9316981 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8AC48601C0 for ; Tue, 6 Sep 2016 13:57:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73282288B2 for ; Tue, 6 Sep 2016 13:57:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67D3A28BBB; Tue, 6 Sep 2016 13:57:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D33A528A4A for ; Tue, 6 Sep 2016 13:57:13 +0000 (UTC) Received: from localhost ([::1]:33626 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhGsC-0004Zk-Ma for patchwork-qemu-devel@patchwork.kernel.org; Tue, 06 Sep 2016 09:57:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhGGV-0004nA-17 for qemu-devel@nongnu.org; Tue, 06 Sep 2016 09:18:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhGGP-0003Vi-MO for qemu-devel@nongnu.org; Tue, 06 Sep 2016 09:18:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56942) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhGGP-0003Ve-Dt; Tue, 06 Sep 2016 09:18:09 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0FD6EC056792; Tue, 6 Sep 2016 13:18:09 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-112-33.ams2.redhat.com [10.36.112.33]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u86DI0JD026371; Tue, 6 Sep 2016 09:18:06 -0400 From: Laurent Vivier To: david@gibson.dropbear.id.au Date: Tue, 6 Sep 2016 15:17:56 +0200 Message-Id: <1473167877-2545-3-git-send-email-lvivier@redhat.com> In-Reply-To: <1473167877-2545-1-git-send-email-lvivier@redhat.com> References: <1473167877-2545-1-git-send-email-lvivier@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 06 Sep 2016 13:18:09 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 2/3] tests: make pc_alloc_init/init_flags/uninit generic X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, thuth@redhat.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP And add support for ppc64. Signed-off-by: Laurent Vivier Reviewed-by: Thomas Huth --- v2: - remove useless parenthesis, inline tests/Makefile.include | 3 ++- tests/libqos/libqos.h | 2 +- tests/libqos/malloc-ppc64.c | 38 ++++++++++++++++++++++++++++++++++++++ tests/libqos/malloc-ppc64.h | 17 +++++++++++++++++ tests/libqos/malloc.c | 42 ++++++++++++++++++++++++++++++++++++++++++ tests/libqos/malloc.h | 3 +++ 6 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 tests/libqos/malloc-ppc64.c create mode 100644 tests/libqos/malloc-ppc64.h diff --git a/tests/Makefile.include b/tests/Makefile.include index 14be491..a286848 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -557,8 +557,9 @@ tests/test-crypto-block$(EXESUF): tests/test-crypto-block.o $(test-crypto-obj-y) libqos-obj-y = tests/libqos/pci.o tests/libqos/fw_cfg.o tests/libqos/malloc.o libqos-obj-y += tests/libqos/i2c.o tests/libqos/libqos.o +libqos-obj-y += tests/libqos/malloc-ppc64.o tests/libqos/malloc-pc.o libqos-pc-obj-y = $(libqos-obj-y) tests/libqos/pci-pc.o -libqos-pc-obj-y += tests/libqos/malloc-pc.o tests/libqos/libqos-pc.o +libqos-pc-obj-y += tests/libqos/libqos-pc.o libqos-pc-obj-y += tests/libqos/ahci.o libqos-omap-obj-y = $(libqos-obj-y) tests/libqos/i2c-omap.o libqos-imx-obj-y = $(libqos-obj-y) tests/libqos/i2c-imx.o diff --git a/tests/libqos/libqos.h b/tests/libqos/libqos.h index 604980d..7b71607 100644 --- a/tests/libqos/libqos.h +++ b/tests/libqos/libqos.h @@ -3,7 +3,7 @@ #include "libqtest.h" #include "libqos/pci.h" -#include "libqos/malloc-pc.h" +#include "libqos/malloc.h" typedef struct QOSOps { QGuestAllocator *(*init_allocator)(QAllocOpts); diff --git a/tests/libqos/malloc-ppc64.c b/tests/libqos/malloc-ppc64.c new file mode 100644 index 0000000..1b31e33 --- /dev/null +++ b/tests/libqos/malloc-ppc64.c @@ -0,0 +1,38 @@ +/* + * libqos malloc support for PPC64 + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "libqos/malloc-ppc64.h" + +#include "qemu-common.h" + +#define PAGE_SIZE 4096 + +/* Memory must be a multiple of 256 MB, + * so we have at least 256MB + */ +#define PPC64_MIN_SIZE 0x10000000 + +void ppc64_alloc_uninit(QGuestAllocator *allocator) +{ + alloc_uninit(allocator); +} + +QGuestAllocator *ppc64_alloc_init_flags(QAllocOpts flags) +{ + QGuestAllocator *s; + + s = alloc_init_flags(flags, 1 << 20, PPC64_MIN_SIZE); + alloc_set_page_size(s, PAGE_SIZE); + + return s; +} + +QGuestAllocator *ppc64_alloc_init(void) +{ + return ppc64_alloc_init_flags(ALLOC_NO_FLAGS); +} diff --git a/tests/libqos/malloc-ppc64.h b/tests/libqos/malloc-ppc64.h new file mode 100644 index 0000000..c2b2dff --- /dev/null +++ b/tests/libqos/malloc-ppc64.h @@ -0,0 +1,17 @@ +/* + * libqos malloc support for PPC64 + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef LIBQOS_MALLOC_PPC64_H +#define LIBQOS_MALLOC_PPC64_H + +#include "libqos/malloc.h" + +QGuestAllocator *ppc64_alloc_init(void); +QGuestAllocator *ppc64_alloc_init_flags(QAllocOpts flags); +void ppc64_alloc_uninit(QGuestAllocator *allocator); + +#endif diff --git a/tests/libqos/malloc.c b/tests/libqos/malloc.c index b8eff5f..6a02345 100644 --- a/tests/libqos/malloc.c +++ b/tests/libqos/malloc.c @@ -12,6 +12,9 @@ #include "qemu/osdep.h" #include "libqos/malloc.h" +#include "libqos/malloc-pc.h" +#include "libqos/malloc-ppc64.h" +#include "libqtest.h" #include "qemu-common.h" #include "qemu/host-utils.h" @@ -375,3 +378,42 @@ void migrate_allocator(QGuestAllocator *src, QTAILQ_INSERT_HEAD(src->free, node, MLIST_ENTNAME); return; } + +QGuestAllocator *machine_alloc_init(void) +{ + const char *arch = qtest_get_arch(); + + if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { + return pc_alloc_init(); + } + if (strcmp(arch, "ppc64") == 0) { + return ppc64_alloc_init(); + } + return NULL; +} + +QGuestAllocator *machine_alloc_init_flags(QAllocOpts flags) +{ + const char *arch = qtest_get_arch(); + + if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { + return pc_alloc_init_flags(flags); + } + if (strcmp(arch, "ppc64") == 0) { + return ppc64_alloc_init_flags(flags); + } + return NULL; +} + +void machine_alloc_uninit(QGuestAllocator *allocator) +{ + const char *arch = qtest_get_arch(); + + if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { + pc_alloc_uninit(allocator); + return; + } + if (strcmp(arch, "ppc64") == 0) { + ppc64_alloc_uninit(allocator); + } +} diff --git a/tests/libqos/malloc.h b/tests/libqos/malloc.h index ae9dac8..a5f4c63 100644 --- a/tests/libqos/malloc.h +++ b/tests/libqos/malloc.h @@ -37,4 +37,7 @@ QGuestAllocator *alloc_init_flags(QAllocOpts flags, void alloc_set_page_size(QGuestAllocator *allocator, size_t page_size); void alloc_set_flags(QGuestAllocator *allocator, QAllocOpts opts); +QGuestAllocator *machine_alloc_init(void); +QGuestAllocator *machine_alloc_init_flags(QAllocOpts flags); +void machine_alloc_uninit(QGuestAllocator *allocator); #endif