Re: [Qemu-devel] [PATCH v5 13/35] tcg: Add atomic helpers

2016-10-11 Thread Alex Bennée

Richard Henderson  writes:

> On 10/11/2016 10:21 AM, Alex Bennée wrote:
>> Is this just using plain git tools or one of the
>> porcelain layers?
>
> Just plain git tools.
>
> In this case it appears I simply left the centos6-adjusted patch set on the 
> vm,
> without pushing them back to github.  So at least I don't have to
> regenerate them.

Good to know :-)

>
> Still, it's a breakdown in process that brings me back to losing my
> mind.

One advantage of the docker targets is they run the builds on the state
of your current source tree on your main developer machine. However its
not perfect, for example I still run classic VMs for things like 32 bit
builds and Free BSD stuff. However centos6 is a currently one of the
docker targets we have.

The end goal is to make it easy for developers to test all the various
compile compilations by just using slightly different make invocations
on their preferred machine.

--
Alex Bennée



Re: [Qemu-devel] [PATCH v5 13/35] tcg: Add atomic helpers

2016-10-11 Thread Richard Henderson

On 10/11/2016 10:21 AM, Alex Bennée wrote:

Is this just using plain git tools or one of the
porcelain layers?


Just plain git tools.

In this case it appears I simply left the centos6-adjusted patch set on the vm, 
without pushing them back to github.  So at least I don't have to regenerate them.


Still, it's a breakdown in process that brings me back to losing my mind.


r~



Re: [Qemu-devel] [PATCH v5 13/35] tcg: Add atomic helpers

2016-10-11 Thread Alex Bennée

Richard Henderson  writes:

> On 10/11/2016 01:47 AM, Alex Bennée wrote:
>>
>> Richard Henderson  writes:
>>
>>> Add all of cmpxchg, op_fetch, fetch_op, and xchg.
>>> Handle both endian-ness, and sizes up to 8.
>>> Handle expanding non-atomically, when emulating in serial.
>>>
>>> Signed-off-by: Richard Henderson 
>>
>> This still seems to be suffering expansion problems on Travis:
>
> I must be losing my mind.
>
>>>  include/qemu/atomic.h |  19 ++-
>
> I can tell at a glance that this is, for a second time, missing a patch that I
> know I applied twice.  Indeed, going back to look at the rest of the series,
> it's missing 4 other changes.
>
> Ho hum.  I'll prepare a v6, I suppose.

Do you keep change notes under --- in your commits and then strip them
off for review/posting? Is this just using plain git tools or one of the
porcelain layers?

>
>
> r~


--
Alex Bennée



Re: [Qemu-devel] [PATCH v5 13/35] tcg: Add atomic helpers

2016-10-11 Thread Richard Henderson

On 10/11/2016 01:47 AM, Alex Bennée wrote:


Richard Henderson  writes:


Add all of cmpxchg, op_fetch, fetch_op, and xchg.
Handle both endian-ness, and sizes up to 8.
Handle expanding non-atomically, when emulating in serial.

Signed-off-by: Richard Henderson 


This still seems to be suffering expansion problems on Travis:


I must be losing my mind.


 include/qemu/atomic.h |  19 ++-


I can tell at a glance that this is, for a second time, missing a patch that I 
know I applied twice.  Indeed, going back to look at the rest of the series, 
it's missing 4 other changes.


Ho hum.  I'll prepare a v6, I suppose.


r~



Re: [Qemu-devel] [PATCH v5 13/35] tcg: Add atomic helpers

2016-10-11 Thread Alex Bennée

Alex Bennée  writes:

> Richard Henderson  writes:
>
>> Add all of cmpxchg, op_fetch, fetch_op, and xchg.
>> Handle both endian-ness, and sizes up to 8.
>> Handle expanding non-atomically, when emulating in serial.
>>
>> Signed-off-by: Richard Henderson 
>
> This still seems to be suffering expansion problems on Travis:
>
>   https://travis-ci.org/stsquad/qemu/builds/166466729
>
> I'll see if I can come up with a reproducer with the docker targets.

So I haven't got the Travis target merged upstream yet. You can find
them here with your patches:

  https://github.com/stsquad/qemu/tree/review/cmpxchg-atomics-v5-travis-debug

With which:

  make docker-run-test-build@travis TARGET_LIST=aarch64-softmmu J=9

will show you the failure (modify J for cores ;-)

--
Alex Bennée



Re: [Qemu-devel] [PATCH v5 13/35] tcg: Add atomic helpers

2016-10-10 Thread Alex Bennée

Richard Henderson  writes:

> Add all of cmpxchg, op_fetch, fetch_op, and xchg.
> Handle both endian-ness, and sizes up to 8.
> Handle expanding non-atomically, when emulating in serial.
>
> Signed-off-by: Richard Henderson 

This still seems to be suffering expansion problems on Travis:

  https://travis-ci.org/stsquad/qemu/builds/166466729

I'll see if I can come up with a reproducer with the docker targets.

> ---
>  Makefile.objs |   2 +-
>  Makefile.target   |   1 +
>  atomic_template.h | 173 ++
>  cputlb.c  | 112 -
>  include/qemu/atomic.h |  19 ++-
>  tcg-runtime.c |  49 ++--
>  tcg/tcg-op.c  | 328 
> ++
>  tcg/tcg-op.h  |  44 +++
>  tcg/tcg-runtime.h |  75 
>  tcg/tcg.h |  53 
>  10 files changed, 836 insertions(+), 20 deletions(-)
>  create mode 100644 atomic_template.h
>
> diff --git a/Makefile.objs b/Makefile.objs
> index 02fb8e7..99d1f6d 100644
> --- a/Makefile.objs
> +++ b/Makefile.objs
> @@ -89,7 +89,7 @@ endif
>
>  ###
>  # Target-independent parts used in system and user emulation
> -common-obj-y += tcg-runtime.o cpus-common.o
> +common-obj-y += cpus-common.o
>  common-obj-y += hw/
>  common-obj-y += qom/
>  common-obj-y += disas/
> diff --git a/Makefile.target b/Makefile.target
> index 9968871..91b6fbd 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -94,6 +94,7 @@ obj-$(CONFIG_TCG_INTERPRETER) += disas/tci.o
>  obj-y += fpu/softfloat.o
>  obj-y += target-$(TARGET_BASE_ARCH)/
>  obj-y += disas.o
> +obj-y += tcg-runtime.o
>  obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o
>  obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
>
> diff --git a/atomic_template.h b/atomic_template.h
> new file mode 100644
> index 000..d2c8a08
> --- /dev/null
> +++ b/atomic_template.h
> @@ -0,0 +1,173 @@
> +/*
> + * Atomic helper templates
> + * Included from tcg-runtime.c and cputlb.c.
> + *
> + * Copyright (c) 2016 Red Hat, Inc
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, see 
> .
> + */
> +
> +#if DATA_SIZE == 8
> +# define SUFFIX q
> +# define DATA_TYPE  uint64_t
> +# define BSWAP  bswap64
> +#elif DATA_SIZE == 4
> +# define SUFFIX l
> +# define DATA_TYPE  uint32_t
> +# define BSWAP  bswap32
> +#elif DATA_SIZE == 2
> +# define SUFFIX w
> +# define DATA_TYPE  uint16_t
> +# define BSWAP  bswap16
> +#elif DATA_SIZE == 1
> +# define SUFFIX b
> +# define DATA_TYPE  uint8_t
> +# define BSWAP
> +#else
> +# error unsupported data size
> +#endif
> +
> +#if DATA_SIZE >= 4
> +# define ABI_TYPE  DATA_TYPE
> +#else
> +# define ABI_TYPE  uint32_t
> +#endif
> +
> +#if DATA_SIZE == 1
> +# define END
> +#elif defined(HOST_WORDS_BIGENDIAN)
> +# define END  _be
> +#else
> +# define END  _le
> +#endif
> +
> +ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
> +  ABI_TYPE cmpv, ABI_TYPE newv EXTRA_ARGS)
> +{
> +DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
> +return atomic_cmpxchg__nocheck(haddr, cmpv, newv);
> +}
> +
> +ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr,
> +   ABI_TYPE val EXTRA_ARGS)
> +{
> +DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
> +return atomic_xchg__nocheck(haddr, val);
> +}
> +
> +#define GEN_ATOMIC_HELPER(X)\
> +ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr,   \
> + ABI_TYPE val EXTRA_ARGS)   \
> +{   \
> +DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;   \
> +return atomic_##X(haddr, val);  \
> +}   \
> +
> +GEN_ATOMIC_HELPER(fetch_add)
> +GEN_ATOMIC_HELPER(fetch_and)
> +GEN_ATOMIC_HELPER(fetch_or)
> +GEN_ATOMIC_HELPER(fetch_xor)
> +GEN_ATOMIC_HELPER(add_fetch)
> +GEN_ATOMIC_HELPER(and_fetch)
> +GEN_ATOMIC_HELPER(or_fetch)
> +GEN_ATOMIC_HELPER(xor_fetch)
> +
> +#undef GEN_ATOMIC_HELPER
> +#undef END
> +
> +#if DATA_SIZE > 1
> +
> +#ifdef HOST_WORDS_BIGENDIAN
> +# define END  _le
> +#else
> +# define EN

[Qemu-devel] [PATCH v5 13/35] tcg: Add atomic helpers

2016-10-09 Thread Richard Henderson
Add all of cmpxchg, op_fetch, fetch_op, and xchg.
Handle both endian-ness, and sizes up to 8.
Handle expanding non-atomically, when emulating in serial.

Signed-off-by: Richard Henderson 
---
 Makefile.objs |   2 +-
 Makefile.target   |   1 +
 atomic_template.h | 173 ++
 cputlb.c  | 112 -
 include/qemu/atomic.h |  19 ++-
 tcg-runtime.c |  49 ++--
 tcg/tcg-op.c  | 328 ++
 tcg/tcg-op.h  |  44 +++
 tcg/tcg-runtime.h |  75 
 tcg/tcg.h |  53 
 10 files changed, 836 insertions(+), 20 deletions(-)
 create mode 100644 atomic_template.h

diff --git a/Makefile.objs b/Makefile.objs
index 02fb8e7..99d1f6d 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -89,7 +89,7 @@ endif
 
 ###
 # Target-independent parts used in system and user emulation
-common-obj-y += tcg-runtime.o cpus-common.o
+common-obj-y += cpus-common.o
 common-obj-y += hw/
 common-obj-y += qom/
 common-obj-y += disas/
diff --git a/Makefile.target b/Makefile.target
index 9968871..91b6fbd 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -94,6 +94,7 @@ obj-$(CONFIG_TCG_INTERPRETER) += disas/tci.o
 obj-y += fpu/softfloat.o
 obj-y += target-$(TARGET_BASE_ARCH)/
 obj-y += disas.o
+obj-y += tcg-runtime.o
 obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o
 obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
 
diff --git a/atomic_template.h b/atomic_template.h
new file mode 100644
index 000..d2c8a08
--- /dev/null
+++ b/atomic_template.h
@@ -0,0 +1,173 @@
+/*
+ * Atomic helper templates
+ * Included from tcg-runtime.c and cputlb.c.
+ *
+ * Copyright (c) 2016 Red Hat, Inc
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see .
+ */
+
+#if DATA_SIZE == 8
+# define SUFFIX q
+# define DATA_TYPE  uint64_t
+# define BSWAP  bswap64
+#elif DATA_SIZE == 4
+# define SUFFIX l
+# define DATA_TYPE  uint32_t
+# define BSWAP  bswap32
+#elif DATA_SIZE == 2
+# define SUFFIX w
+# define DATA_TYPE  uint16_t
+# define BSWAP  bswap16
+#elif DATA_SIZE == 1
+# define SUFFIX b
+# define DATA_TYPE  uint8_t
+# define BSWAP
+#else
+# error unsupported data size
+#endif
+
+#if DATA_SIZE >= 4
+# define ABI_TYPE  DATA_TYPE
+#else
+# define ABI_TYPE  uint32_t
+#endif
+
+#if DATA_SIZE == 1
+# define END
+#elif defined(HOST_WORDS_BIGENDIAN)
+# define END  _be
+#else
+# define END  _le
+#endif
+
+ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
+  ABI_TYPE cmpv, ABI_TYPE newv EXTRA_ARGS)
+{
+DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
+return atomic_cmpxchg__nocheck(haddr, cmpv, newv);
+}
+
+ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr,
+   ABI_TYPE val EXTRA_ARGS)
+{
+DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
+return atomic_xchg__nocheck(haddr, val);
+}
+
+#define GEN_ATOMIC_HELPER(X)\
+ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr,   \
+ ABI_TYPE val EXTRA_ARGS)   \
+{   \
+DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;   \
+return atomic_##X(haddr, val);  \
+}   \
+
+GEN_ATOMIC_HELPER(fetch_add)
+GEN_ATOMIC_HELPER(fetch_and)
+GEN_ATOMIC_HELPER(fetch_or)
+GEN_ATOMIC_HELPER(fetch_xor)
+GEN_ATOMIC_HELPER(add_fetch)
+GEN_ATOMIC_HELPER(and_fetch)
+GEN_ATOMIC_HELPER(or_fetch)
+GEN_ATOMIC_HELPER(xor_fetch)
+
+#undef GEN_ATOMIC_HELPER
+#undef END
+
+#if DATA_SIZE > 1
+
+#ifdef HOST_WORDS_BIGENDIAN
+# define END  _le
+#else
+# define END  _be
+#endif
+
+ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
+  ABI_TYPE cmpv, ABI_TYPE newv EXTRA_ARGS)
+{
+DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
+return BSWAP(atomic_cmpxchg__nocheck(haddr, BSWAP(cmpv), BSWAP(newv)));
+}
+
+ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr,
+   ABI_TYPE val EXTRA_ARGS)
+{
+DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
+return BSWAP(atomic_xchg__nocheck(haddr, BSWAP(val)