From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42563) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhomJ-0002iG-S1 for qemu-devel@nongnu.org; Wed, 07 Sep 2016 22:09:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhomH-00053H-BV for qemu-devel@nongnu.org; Wed, 07 Sep 2016 22:09:22 -0400 Date: Thu, 8 Sep 2016 12:04:23 +1000 From: David Gibson Message-ID: <20160908020423.GD3883@voom.fritz.box> References: <1473167877-2545-1-git-send-email-lvivier@redhat.com> <1473167877-2545-3-git-send-email-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="P+33d92oIH25kiaB" Content-Disposition: inline In-Reply-To: <1473167877-2545-3-git-send-email-lvivier@redhat.com> Subject: Re: [Qemu-devel] [PATCH v4 2/3] tests: make pc_alloc_init/init_flags/uninit generic List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laurent Vivier Cc: thuth@redhat.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org --P+33d92oIH25kiaB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Sep 06, 2016 at 03:17:56PM +0200, Laurent Vivier wrote: > And add support for ppc64. >=20 > Signed-off-by: Laurent Vivier Some of my coments may be obsoleted by the discussion with Greg. > --- > v2: > - remove useless parenthesis, inline >=20 > 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 >=20 > 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-b= lock.o $(test-crypto-obj-y) > =20 > libqos-obj-y =3D tests/libqos/pci.o tests/libqos/fw_cfg.o tests/libqos/m= alloc.o > libqos-obj-y +=3D tests/libqos/i2c.o tests/libqos/libqos.o > +libqos-obj-y +=3D tests/libqos/malloc-ppc64.o tests/libqos/malloc-pc.o > libqos-pc-obj-y =3D $(libqos-obj-y) tests/libqos/pci-pc.o > -libqos-pc-obj-y +=3D tests/libqos/malloc-pc.o tests/libqos/libqos-pc.o > +libqos-pc-obj-y +=3D tests/libqos/libqos-pc.o > libqos-pc-obj-y +=3D tests/libqos/ahci.o > libqos-omap-obj-y =3D $(libqos-obj-y) tests/libqos/i2c-omap.o > libqos-imx-obj-y =3D $(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 @@ > =20 > #include "libqtest.h" > #include "libqos/pci.h" > -#include "libqos/malloc-pc.h" > +#include "libqos/malloc.h" > =20 > 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 la= ter. > + * 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 So, this is really a "pseries" machine type fact rather than a ppc64 fact. Is there a way to make this dependent on machine type rather than target architecture? Naming this based on machine type would seem to better match the "pc" things these are based on ("pc" rather than "i386" or "x86_64"). > + > +void ppc64_alloc_uninit(QGuestAllocator *allocator) > +{ > + alloc_uninit(allocator); > +} > + > +QGuestAllocator *ppc64_alloc_init_flags(QAllocOpts flags) > +{ > + QGuestAllocator *s; > + > + s =3D 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 la= ter. > + * 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 @@ > =20 > #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" > =20 > @@ -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 =3D qtest_get_arch(); Maybe we need to add a qtest_get_machine_type(). > + if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0= ) { > + return pc_alloc_init(); > + } > + if (strcmp(arch, "ppc64") =3D=3D 0) { > + return ppc64_alloc_init(); > + } > + return NULL; > +} > + > +QGuestAllocator *machine_alloc_init_flags(QAllocOpts flags) > +{ > + const char *arch =3D qtest_get_arch(); > + > + if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0= ) { > + return pc_alloc_init_flags(flags); > + } > + if (strcmp(arch, "ppc64") =3D=3D 0) { > + return ppc64_alloc_init_flags(flags); > + } > + return NULL; > +} > + > +void machine_alloc_uninit(QGuestAllocator *allocator) > +{ > + const char *arch =3D qtest_get_arch(); > + > + if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0= ) { > + pc_alloc_uninit(allocator); > + return; > + } > + if (strcmp(arch, "ppc64") =3D=3D 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); > =20 > +QGuestAllocator *machine_alloc_init(void); > +QGuestAllocator *machine_alloc_init_flags(QAllocOpts flags); > +void machine_alloc_uninit(QGuestAllocator *allocator); > #endif --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --P+33d92oIH25kiaB Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBAgAGBQJX0McnAAoJEGw4ysog2bOSVXcP/0dQJzKvZsaHRuT3A1E/BdBf wh1coo4mW73R9HXf25XWa+r1M4vnhFvB3UjB3XSR2VB/bm0fgbNh50ubwLSBIOQf 0umyIgCoiW4L1tgBaDxlSEF+q6yr0knigjE4reuV8/uccI8sOTKo3lVENPePDwDs 7Xosl5QIhQOf+ze4dSX5/bXeMbL0dy9X/zuVXLngCTBK4I2q2hO926ugqyLwpBYW rW5n8+zcyJwg8LRPjzy2GGwbDhdwq+ZRQXWXglRHTkNieIZYJwAmP8EtXu9pL+/3 ZXLjEDm6cBfZkP16h5OyoBP1oYvK3i6Tc1KS5cS3ASGZW2HJ2PeatoIoqJhci94Z 4Fkox1JBgqift6B2ZedZWSBFhad0ebGpZHBi0Mivk9IdKJ1c2S5j7yQMFr/RW7yS ZVxnmOoWizZrunIXE+nwPEJmR3pMYnkeA4hlTetmhPPHGC/NHZjQIeeALzjQYXH+ faR9TuYYnS3GNJHba8x6wAByP3vD8oa6VAPdlIGYeLbtQiY40CQ7TEw7wud2KdtN w7msDdzRlzM8lUrSh0Iz0PY5YRLttDNhGzRJPQPwTHNfvOqG+Wlu6bm5Ag5NRL7i JZfoJzp91Lnx0sckugxhK4In8d5u0IJ0rHWsH4uFvbxs6/hbXE3V4ktcw3bHK5of NgvW3VmPAtZhLzoevrAf =E6a/ -----END PGP SIGNATURE----- --P+33d92oIH25kiaB--