All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Get tests/tcg building, fix unused variable warning due to wrong extended asm operand, fix the 'test' make target.
@ 2012-07-13  6:55 Catalin Patulea
  2012-07-13  8:44 ` 陳韋任 (Wei-Ren Chen)
  2012-07-16 19:08 ` Peter Maydell
  0 siblings, 2 replies; 31+ messages in thread
From: Catalin Patulea @ 2012-07-13  6:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: Catalin Patulea

Not all tests pass, but at least they can be run using 'make test'.

To build individual tests:
$ cd $BUILD_PATH/tests/tcg
$ SRC_PATH=path/to/qemu make <target>

Signed-off-by: Catalin Patulea <catalinp@google.com>
---
 tests/tcg/Makefile    |   16 ++++++++++------
 tests/tcg/test-i386.c |    3 ++-
 tests/tcg/test_path.c |   13 +++++++------
 3 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/tests/tcg/Makefile b/tests/tcg/Makefile
index 15e36a2..3256a98 100644
--- a/tests/tcg/Makefile
+++ b/tests/tcg/Makefile
@@ -1,13 +1,13 @@
--include ../config-host.mak
+-include ../../config-host.mak
 -include $(SRC_PATH)/rules.mak
 
-$(call set-vpath, $(SRC_PATH)/tests)
+$(call set-vpath, $(SRC_PATH)/tests/tcg)
 
-QEMU=../i386-linux-user/qemu-i386
-QEMU_X86_64=../x86_64-linux-user/qemu-x86_64
+QEMU=../../i386-linux-user/qemu-i386
+QEMU_X86_64=../../x86_64-linux-user/qemu-x86_64
 CC_X86_64=$(CC_I386) -m64
 
-QEMU_INCLUDES += -I..
+QEMU_INCLUDES += -I../..
 CFLAGS=-Wall -O2 -g -fno-strict-aliasing
 #CFLAGS+=-msse2
 LDFLAGS=
@@ -36,6 +36,7 @@ TESTS += $(I386_TESTS)
 endif
 
 all: $(patsubst %,run-%,$(TESTS))
+test: all
 
 # rules to run tests
 
@@ -74,7 +75,10 @@ run-test_path: test_path
 # rules to compile tests
 
 test_path: test_path.o
+	$(CC_I386) $(LDFLAGS) $(LIBS) -o $@ $^
+
 test_path.o: test_path.c
+	$(CC_I386) $(QEMU_INCLUDES) $(GLIB_CFLAGS) $(CFLAGS) $(LDFLAGS) -c -o $@ $^
 
 hello-i386: hello-i386.c
 	$(CC_I386) -nostdlib $(CFLAGS) -static $(LDFLAGS) -o $@ $<
@@ -86,7 +90,7 @@ testthread: testthread.c
 # i386/x86_64 emulation test (test various opcodes) */
 test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S \
            test-i386.h test-i386-shift.h test-i386-muldiv.h
-	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ \
+	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ \
               $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
 
 test-x86_64: test-i386.c \
diff --git a/tests/tcg/test-i386.c b/tests/tcg/test-i386.c
index 8e64bba..acbc9c9 100644
--- a/tests/tcg/test-i386.c
+++ b/tests/tcg/test-i386.c
@@ -17,6 +17,7 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 #define _GNU_SOURCE
+#include "compiler.h"  // QEMU_PACKED
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -784,7 +785,7 @@ void fpu_clear_exceptions(void)
         long double fpregs[8];
     } float_env32;
 
-    asm volatile ("fnstenv %0\n" : : "m" (float_env32));
+    asm volatile ("fnstenv %0\n" : "=m" (float_env32));
     float_env32.fpus &= ~0x7f;
     asm volatile ("fldenv %0\n" : : "m" (float_env32));
 }
diff --git a/tests/tcg/test_path.c b/tests/tcg/test_path.c
index 7265a94..a064eea 100644
--- a/tests/tcg/test_path.c
+++ b/tests/tcg/test_path.c
@@ -1,11 +1,12 @@
 /* Test path override code */
-#include "../config-host.h"
-#include "../qemu-malloc.c"
-#include "../cutils.c"
-#include "../path.c"
-#include "../trace.c"
+#define _GNU_SOURCE
+#include "config-host.h"
+#include "iov.c"
+#include "cutils.c"
+#include "path.c"
+#include "trace.c"
 #ifdef CONFIG_TRACE_SIMPLE
-#include "../simpletrace.c"
+#include "../trace/simple.c"
 #endif
 
 #include <stdarg.h>
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCH] Get tests/tcg building, fix unused variable warning due to wrong extended asm operand, fix the 'test' make target.
  2012-07-13  6:55 [Qemu-devel] [PATCH] Get tests/tcg building, fix unused variable warning due to wrong extended asm operand, fix the 'test' make target Catalin Patulea
@ 2012-07-13  8:44 ` 陳韋任 (Wei-Ren Chen)
  2012-07-16 18:17   ` Catalin Patulea
  2012-07-16 19:08 ` Peter Maydell
  1 sibling, 1 reply; 31+ messages in thread
From: 陳韋任 (Wei-Ren Chen) @ 2012-07-13  8:44 UTC (permalink / raw)
  To: Catalin Patulea; +Cc: qemu-devel

  Tested-by: Wei-Ren Chen

On Fri, Jul 13, 2012 at 02:55:13AM -0400, Catalin Patulea wrote:
> Not all tests pass, but at least they can be run using 'make test'.
> 
> To build individual tests:
> $ cd $BUILD_PATH/tests/tcg
> $ SRC_PATH=path/to/qemu make <target>

  [snip]

Regards,
chenwj

-- 
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCH] Get tests/tcg building, fix unused variable warning due to wrong extended asm operand, fix the 'test' make target.
  2012-07-13  8:44 ` 陳韋任 (Wei-Ren Chen)
@ 2012-07-16 18:17   ` Catalin Patulea
  0 siblings, 0 replies; 31+ messages in thread
From: Catalin Patulea @ 2012-07-16 18:17 UTC (permalink / raw)
  To: 陳韋任 (Wei-Ren Chen); +Cc: Peter Maydell, qemu-devel

Peter, do you have a second to look at this? I've got a new test in
tests/tcg that checks fprem correctness (or at least compares with
h/w...) that depends on this.

On Fri, Jul 13, 2012 at 4:44 AM, 陳韋任 (Wei-Ren Chen)
<chenwj@iis.sinica.edu.tw> wrote:
>   Tested-by: Wei-Ren Chen
>
> On Fri, Jul 13, 2012 at 02:55:13AM -0400, Catalin Patulea wrote:
>> Not all tests pass, but at least they can be run using 'make test'.
>>
>> To build individual tests:
>> $ cd $BUILD_PATH/tests/tcg
>> $ SRC_PATH=path/to/qemu make <target>
>
>   [snip]
>
> Regards,
> chenwj
>
> --
> Wei-Ren Chen (陳韋任)
> Computer Systems Lab, Institute of Information Science,
> Academia Sinica, Taiwan (R.O.C.)
> Tel:886-2-2788-3799 #1667
> Homepage: http://people.cs.nctu.edu.tw/~chenwj

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCH] Get tests/tcg building, fix unused variable warning due to wrong extended asm operand, fix the 'test' make target.
  2012-07-13  6:55 [Qemu-devel] [PATCH] Get tests/tcg building, fix unused variable warning due to wrong extended asm operand, fix the 'test' make target Catalin Patulea
  2012-07-13  8:44 ` 陳韋任 (Wei-Ren Chen)
@ 2012-07-16 19:08 ` Peter Maydell
  2012-07-16 20:00   ` Catalin Patulea
  1 sibling, 1 reply; 31+ messages in thread
From: Peter Maydell @ 2012-07-16 19:08 UTC (permalink / raw)
  To: Catalin Patulea; +Cc: Anthony Liguori, qemu-devel

On 13 July 2012 07:55, Catalin Patulea <catalinp@google.com> wrote:
> Not all tests pass, but at least they can be run using 'make test'.
>
> To build individual tests:
> $ cd $BUILD_PATH/tests/tcg
> $ SRC_PATH=path/to/qemu make <target>

I don't know enough about our test makefile structure to
know if this is right (try Anthony) but some comments below.

(It looks like some of this is fixing bustage from Anthony's
commit c09015dd.)

> Signed-off-by: Catalin Patulea <catalinp@google.com>
> ---
>  tests/tcg/Makefile    |   16 ++++++++++------
>  tests/tcg/test-i386.c |    3 ++-
>  tests/tcg/test_path.c |   13 +++++++------
>  3 files changed, 19 insertions(+), 13 deletions(-)
>
> diff --git a/tests/tcg/Makefile b/tests/tcg/Makefile
> index 15e36a2..3256a98 100644
> --- a/tests/tcg/Makefile
> +++ b/tests/tcg/Makefile
> @@ -1,13 +1,13 @@
> --include ../config-host.mak
> +-include ../../config-host.mak
>  -include $(SRC_PATH)/rules.mak
>
> -$(call set-vpath, $(SRC_PATH)/tests)
> +$(call set-vpath, $(SRC_PATH)/tests/tcg)
>
> -QEMU=../i386-linux-user/qemu-i386
> -QEMU_X86_64=../x86_64-linux-user/qemu-x86_64
> +QEMU=../../i386-linux-user/qemu-i386
> +QEMU_X86_64=../../x86_64-linux-user/qemu-x86_64
>  CC_X86_64=$(CC_I386) -m64
>
> -QEMU_INCLUDES += -I..
> +QEMU_INCLUDES += -I../..
>  CFLAGS=-Wall -O2 -g -fno-strict-aliasing
>  #CFLAGS+=-msse2
>  LDFLAGS=
> @@ -36,6 +36,7 @@ TESTS += $(I386_TESTS)
>  endif
>
>  all: $(patsubst %,run-%,$(TESTS))
> +test: all
>
>  # rules to run tests
>
> @@ -74,7 +75,10 @@ run-test_path: test_path
>  # rules to compile tests
>
>  test_path: test_path.o
> +       $(CC_I386) $(LDFLAGS) $(LIBS) -o $@ $^

This won't compile:
ccache gcc -m32  -lrt -pthread -lgthread-2.0 -lrt -lglib-2.0    -o
test_path test_path.o
test_path.o: In function `qemu_iovec_init':
/home/pm215/src/qemu/qemu/cutils.c:142: undefined reference to `g_malloc'
test_path.o: In function `qemu_iovec_add':
/home/pm215/src/qemu/qemu/cutils.c:166: undefined reference to `g_realloc'
test_path.o: In function `qemu_iovec_destroy':
/home/pm215/src/qemu/qemu/cutils.c:210: undefined reference to `g_free'
collect2: ld returned 1 exit status

You need to have the $(LIBS) after the $^.

> +
>  test_path.o: test_path.c
> +       $(CC_I386) $(QEMU_INCLUDES) $(GLIB_CFLAGS) $(CFLAGS) $(LDFLAGS) -c -o $@ $^

Ditto.

>  hello-i386: hello-i386.c
>         $(CC_I386) -nostdlib $(CFLAGS) -static $(LDFLAGS) -o $@ $<
> @@ -86,7 +90,7 @@ testthread: testthread.c
>  # i386/x86_64 emulation test (test various opcodes) */
>  test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S \
>             test-i386.h test-i386-shift.h test-i386-muldiv.h
> -       $(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ \
> +       $(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ \
>                $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
>
>  test-x86_64: test-i386.c \
> diff --git a/tests/tcg/test-i386.c b/tests/tcg/test-i386.c
> index 8e64bba..acbc9c9 100644
> --- a/tests/tcg/test-i386.c
> +++ b/tests/tcg/test-i386.c
> @@ -17,6 +17,7 @@
>   *  along with this program; if not, see <http://www.gnu.org/licenses/>.
>   */
>  #define _GNU_SOURCE
> +#include "compiler.h"  // QEMU_PACKED

checkpatch complains about this //-syntax comment;
might as well just drop it.

>  #include <stdlib.h>
>  #include <stdio.h>
>  #include <string.h>
> @@ -784,7 +785,7 @@ void fpu_clear_exceptions(void)
>          long double fpregs[8];
>      } float_env32;
>
> -    asm volatile ("fnstenv %0\n" : : "m" (float_env32));
> +    asm volatile ("fnstenv %0\n" : "=m" (float_env32));
>      float_env32.fpus &= ~0x7f;
>      asm volatile ("fldenv %0\n" : : "m" (float_env32));
>  }

This doesn't seem to be sufficient for test-i386 to compile
for me:
ccache gcc -m32 -I/home/pm215/src/qemu/qemu/slirp -I.
-I/home/pm215/src/qemu/qemu -I/home/pm215/src/qemu/qemu/fpu -I../..
-Wall -O2 -g -fno-strict-aliasing  -o test-i386 \
              ./test-i386.c ./test-i386-code16.S ./test-i386-vm86.S -lm
./test-i386.c: Assembler messages:
./test-i386.c:1831: Error: expecting lockable instruction after `lock'

Since 'lock nop' isn't valid we probably need to do this with
a .byte directive to emit the sequence we require.
(this is gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1 on x86.)

> diff --git a/tests/tcg/test_path.c b/tests/tcg/test_path.c
> index 7265a94..a064eea 100644
> --- a/tests/tcg/test_path.c
> +++ b/tests/tcg/test_path.c
> @@ -1,11 +1,12 @@
>  /* Test path override code */
> -#include "../config-host.h"
> -#include "../qemu-malloc.c"
> -#include "../cutils.c"
> -#include "../path.c"
> -#include "../trace.c"
> +#define _GNU_SOURCE
> +#include "config-host.h"
> +#include "iov.c"
> +#include "cutils.c"
> +#include "path.c"
> +#include "trace.c"
>  #ifdef CONFIG_TRACE_SIMPLE
> -#include "../simpletrace.c"
> +#include "../trace/simple.c"
>  #endif
>
>  #include <stdarg.h>

The whole way this test works looks pretty foul to me, so yeah, whatever :-)

-- PMM

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCH] Get tests/tcg building, fix unused variable warning due to wrong extended asm operand, fix the 'test' make target.
  2012-07-16 19:08 ` Peter Maydell
@ 2012-07-16 20:00   ` Catalin Patulea
  2012-07-16 20:11     ` [Qemu-devel] [PATCH v2] Get tests/tcg building and fix an unused variable warning due to wrong extended asm operands Catalin Patulea
  2012-07-16 21:11     ` [Qemu-devel] [PATCH] Get tests/tcg building, fix unused variable warning due to wrong extended asm operand, fix the 'test' make target Peter Maydell
  0 siblings, 2 replies; 31+ messages in thread
From: Catalin Patulea @ 2012-07-16 20:00 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Anthony Liguori, qemu-devel

On Mon, Jul 16, 2012 at 3:08 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> You need to have the $(LIBS) after the $^.
Done.

>>  test_path.o: test_path.c
>> +       $(CC_I386) $(QEMU_INCLUDES) $(GLIB_CFLAGS) $(CFLAGS) $(LDFLAGS) -c -o $@ $^
>
> Ditto.
I don't think I meant to put $(LDFLAGS) in there. This is just a
compilation step, after all. I've taken it out, please let me know if
you still have any troubles building.

>> +#include "compiler.h"  // QEMU_PACKED
>
> checkpatch complains about this //-syntax comment;
> might as well just drop it.
Done.

>> -    asm volatile ("fnstenv %0\n" : : "m" (float_env32));
>> +    asm volatile ("fnstenv %0\n" : "=m" (float_env32));
>>      float_env32.fpus &= ~0x7f;
>>      asm volatile ("fldenv %0\n" : : "m" (float_env32));
>>  }
>
> This doesn't seem to be sufficient for test-i386 to compile
> for me:
> ccache gcc -m32 -I/home/pm215/src/qemu/qemu/slirp -I.
> -I/home/pm215/src/qemu/qemu -I/home/pm215/src/qemu/qemu/fpu -I../..
> -Wall -O2 -g -fno-strict-aliasing  -o test-i386 \
>               ./test-i386.c ./test-i386-code16.S ./test-i386-vm86.S -lm
> ./test-i386.c: Assembler messages:
> ./test-i386.c:1831: Error: expecting lockable instruction after `lock'

>
> Since 'lock nop' isn't valid we probably need to do this with
> a .byte directive to emit the sequence we require.
I don't understand why gcc would be generating a lock prefix here..

> (this is gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1 on x86.)
I'm on gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1) and it appears
unreasonably difficult to get 4.6 on my machine. I'll keep trying but
for now I'm shooting blind.

Wei-Ren, what version of gcc are you running? (and had success with?)

>>  #include <stdarg.h>
>
> The whole way this test works looks pretty foul to me, so yeah, whatever :-)
I agree that this is grotesque - I'm just trying to make the minimal
number of changes to unbreak things so that I can get on with my fprem
life ;-)

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [Qemu-devel] [PATCH v2] Get tests/tcg building and fix an unused variable warning due to wrong extended asm operands.
  2012-07-16 20:00   ` Catalin Patulea
@ 2012-07-16 20:11     ` Catalin Patulea
  2012-07-16 21:19       ` Peter Maydell
  2012-07-16 21:11     ` [Qemu-devel] [PATCH] Get tests/tcg building, fix unused variable warning due to wrong extended asm operand, fix the 'test' make target Peter Maydell
  1 sibling, 1 reply; 31+ messages in thread
From: Catalin Patulea @ 2012-07-16 20:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Anthony Liguori, chenwj, Catalin Patulea

To build/run the tests:
$ cd $BUILD_PATH/tests/tcg
$ SRC_PATH=path/to/qemu make <target>

Signed-off-by: Catalin Patulea <catalinp@google.com>
---
This should also fix the lock nop error. I just peeked at what bytes my gcc
(4.4.3) generates.

 tests/tcg/Makefile    |   16 ++++++++++------
 tests/tcg/test-i386.c |    5 +++--
 tests/tcg/test_path.c |   13 +++++++------
 3 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/tests/tcg/Makefile b/tests/tcg/Makefile
index 15e36a2..9ff47b8 100644
--- a/tests/tcg/Makefile
+++ b/tests/tcg/Makefile
@@ -1,13 +1,13 @@
--include ../config-host.mak
+-include ../../config-host.mak
 -include $(SRC_PATH)/rules.mak
 
-$(call set-vpath, $(SRC_PATH)/tests)
+$(call set-vpath, $(SRC_PATH)/tests/tcg)
 
-QEMU=../i386-linux-user/qemu-i386
-QEMU_X86_64=../x86_64-linux-user/qemu-x86_64
+QEMU=../../i386-linux-user/qemu-i386
+QEMU_X86_64=../../x86_64-linux-user/qemu-x86_64
 CC_X86_64=$(CC_I386) -m64
 
-QEMU_INCLUDES += -I..
+QEMU_INCLUDES += -I../..
 CFLAGS=-Wall -O2 -g -fno-strict-aliasing
 #CFLAGS+=-msse2
 LDFLAGS=
@@ -36,6 +36,7 @@ TESTS += $(I386_TESTS)
 endif
 
 all: $(patsubst %,run-%,$(TESTS))
+test: all
 
 # rules to run tests
 
@@ -74,7 +75,10 @@ run-test_path: test_path
 # rules to compile tests
 
 test_path: test_path.o
+	$(CC_I386) $(LDFLAGS) -o $@ $^ $(LIBS)
+
 test_path.o: test_path.c
+	$(CC_I386) $(QEMU_INCLUDES) $(GLIB_CFLAGS) $(CFLAGS) -c -o $@ $^
 
 hello-i386: hello-i386.c
 	$(CC_I386) -nostdlib $(CFLAGS) -static $(LDFLAGS) -o $@ $<
@@ -86,7 +90,7 @@ testthread: testthread.c
 # i386/x86_64 emulation test (test various opcodes) */
 test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S \
            test-i386.h test-i386-shift.h test-i386-muldiv.h
-	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ \
+	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ \
               $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
 
 test-x86_64: test-i386.c \
diff --git a/tests/tcg/test-i386.c b/tests/tcg/test-i386.c
index 8e64bba..40392ac 100644
--- a/tests/tcg/test-i386.c
+++ b/tests/tcg/test-i386.c
@@ -17,6 +17,7 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 #define _GNU_SOURCE
+#include "compiler.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -784,7 +785,7 @@ void fpu_clear_exceptions(void)
         long double fpregs[8];
     } float_env32;
 
-    asm volatile ("fnstenv %0\n" : : "m" (float_env32));
+    asm volatile ("fnstenv %0\n" : "=m" (float_env32));
     float_env32.fpus &= ~0x7f;
     asm volatile ("fldenv %0\n" : : "m" (float_env32));
 }
@@ -1827,7 +1828,7 @@ void test_exceptions(void)
     printf("lock nop exception:\n");
     if (setjmp(jmp_env) == 0) {
         /* now execute an invalid instruction */
-        asm volatile("lock nop");
+        asm volatile(".byte 0xf0, 0x90"); /* lock nop */
     }
 
     printf("INT exception:\n");
diff --git a/tests/tcg/test_path.c b/tests/tcg/test_path.c
index 7265a94..a064eea 100644
--- a/tests/tcg/test_path.c
+++ b/tests/tcg/test_path.c
@@ -1,11 +1,12 @@
 /* Test path override code */
-#include "../config-host.h"
-#include "../qemu-malloc.c"
-#include "../cutils.c"
-#include "../path.c"
-#include "../trace.c"
+#define _GNU_SOURCE
+#include "config-host.h"
+#include "iov.c"
+#include "cutils.c"
+#include "path.c"
+#include "trace.c"
 #ifdef CONFIG_TRACE_SIMPLE
-#include "../simpletrace.c"
+#include "../trace/simple.c"
 #endif
 
 #include <stdarg.h>
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCH] Get tests/tcg building, fix unused variable warning due to wrong extended asm operand, fix the 'test' make target.
  2012-07-16 20:00   ` Catalin Patulea
  2012-07-16 20:11     ` [Qemu-devel] [PATCH v2] Get tests/tcg building and fix an unused variable warning due to wrong extended asm operands Catalin Patulea
@ 2012-07-16 21:11     ` Peter Maydell
  2012-07-16 21:23       ` Catalin Patulea
  1 sibling, 1 reply; 31+ messages in thread
From: Peter Maydell @ 2012-07-16 21:11 UTC (permalink / raw)
  To: Catalin Patulea; +Cc: Anthony Liguori, qemu-devel

On 16 July 2012 21:00, Catalin Patulea <catalinp@google.com> wrote:
> On Mon, Jul 16, 2012 at 3:08 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
>> This doesn't seem to be sufficient for test-i386 to compile
>> for me:
>> ccache gcc -m32 -I/home/pm215/src/qemu/qemu/slirp -I.
>> -I/home/pm215/src/qemu/qemu -I/home/pm215/src/qemu/qemu/fpu -I../..
>> -Wall -O2 -g -fno-strict-aliasing  -o test-i386 \
>>               ./test-i386.c ./test-i386-code16.S ./test-i386-vm86.S -lm
>> ./test-i386.c: Assembler messages:
>> ./test-i386.c:1831: Error: expecting lockable instruction after `lock'
>
>>
>> Since 'lock nop' isn't valid we probably need to do this with
>> a .byte directive to emit the sequence we require.
> I don't understand why gcc would be generating a lock prefix here..

Have you looked at the code? We're specifically asking for one:
        asm volatile("lock nop");
(which we expect to be invalid). We just need to handle that the same
way we do for the case a bit later, by using
        asm volatile(".byte 0xsomething, 0xsomething");
to emit the sequence we want rather than asking gas to do something
it thinks is illegal.

Since you have an assembler that doesn't complain about "lock nop"
you should be able to disassemble the binary it creates to find out
what the byte sequence we need is.

>> (this is gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1 on x86.)
> I'm on gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1) and it appears
> unreasonably difficult to get 4.6 on my machine.

If you have the disk space then setting up a chroot environment of
a newer ubuntu is probably the easiest thing.

-- PMM

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCH v2] Get tests/tcg building and fix an unused variable warning due to wrong extended asm operands.
  2012-07-16 20:11     ` [Qemu-devel] [PATCH v2] Get tests/tcg building and fix an unused variable warning due to wrong extended asm operands Catalin Patulea
@ 2012-07-16 21:19       ` Peter Maydell
  2012-07-17  2:24         ` [Qemu-devel] [PATCH] tests/tcg: add test-i386-fprem and make target for comparing QEMU to h/w Catalin Patulea
  2012-07-20 23:23         ` [Qemu-devel] [PATCH v2] Get tests/tcg building and fix an unused variable warning due to wrong extended asm operands Catalin Patulea
  0 siblings, 2 replies; 31+ messages in thread
From: Peter Maydell @ 2012-07-16 21:19 UTC (permalink / raw)
  To: Catalin Patulea; +Cc: Anthony Liguori, qemu-devel, chenwj

On 16 July 2012 21:11, Catalin Patulea <catalinp@google.com> wrote:
> To build/run the tests:
> $ cd $BUILD_PATH/tests/tcg
> $ SRC_PATH=path/to/qemu make <target>
>
> Signed-off-by: Catalin Patulea <catalinp@google.com>
> ---
> This should also fix the lock nop error. I just peeked at what bytes my gcc
> (4.4.3) generates.

Yep, this all builds for me now.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

(Your Subject: is kinda long and veering close to violating the
'don't do two things in a patch' rule, but I've been picky enough
with other peoples' patches tonight, so I'll let it pass :-))

-- PMM

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCH] Get tests/tcg building, fix unused variable warning due to wrong extended asm operand, fix the 'test' make target.
  2012-07-16 21:11     ` [Qemu-devel] [PATCH] Get tests/tcg building, fix unused variable warning due to wrong extended asm operand, fix the 'test' make target Peter Maydell
@ 2012-07-16 21:23       ` Catalin Patulea
  0 siblings, 0 replies; 31+ messages in thread
From: Catalin Patulea @ 2012-07-16 21:23 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Anthony Liguori, qemu-devel

On Mon, Jul 16, 2012 at 5:11 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 16 July 2012 21:00, Catalin Patulea <catalinp@google.com> wrote:
>> On Mon, Jul 16, 2012 at 3:08 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
>>> ccache gcc -m32 -I/home/pm215/src/qemu/qemu/slirp -I.
>>> -I/home/pm215/src/qemu/qemu -I/home/pm215/src/qemu/qemu/fpu -I../..
>>> -Wall -O2 -g -fno-strict-aliasing  -o test-i386 \
>>>               ./test-i386.c ./test-i386-code16.S ./test-i386-vm86.S -lm
>>> ./test-i386.c: Assembler messages:
>>> ./test-i386.c:1831: Error: expecting lockable instruction after `lock'
> Since you have an assembler that doesn't complain about "lock nop"
> you should be able to disassemble the binary it creates to find out
> what the byte sequence we need is.
For the readers: PATCHv2 does exactly that, thanks for reviewing it.

>>> (this is gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1 on x86.)
>> I'm on gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1) and it appears
>> unreasonably difficult to get 4.6 on my machine.
>
> If you have the disk space then setting up a chroot environment of
> a newer ubuntu is probably the easiest thing.
That is a really great idea, will do.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [Qemu-devel] [PATCH] tests/tcg: add test-i386-fprem and make target for comparing QEMU to h/w
  2012-07-16 21:19       ` Peter Maydell
@ 2012-07-17  2:24         ` Catalin Patulea
  2012-07-17  2:33           ` Catalin Patulea
  2012-07-17 12:23           ` Peter Maydell
  2012-07-20 23:23         ` [Qemu-devel] [PATCH v2] Get tests/tcg building and fix an unused variable warning due to wrong extended asm operands Catalin Patulea
  1 sibling, 2 replies; 31+ messages in thread
From: Catalin Patulea @ 2012-07-17  2:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Catalin Patulea

I'm just sending this in as a draft for now. There are two outstanding issues:

1) What is the recommended type for bitfields? A quick grep shows inconsistent
usage of unsigned int/signed int/uintNN_t across the codebase. Note that
mantissa must be 63 bits so int won't do on either 32 or 64-bit builds.

2) Intel says that FPREM can sometimes generate numeric underflow (#U). I've
been trying to come up with a concrete case, asked around, etc, for a few days
now and I haven't come up with anything. It comes down to, I don't think FPREM
can ever lose precision with respect to its operands. Can you come up with a
numeric underflow case?

--- draft commit message: ---
This test contains manual and automatically-generated test cases, in the style
of test-i386 (run on h/w, run on QEMU, diff the outputs), for the FPREM
instruction. For each test case, the input operands, result and FPU status word
are printed.

The manual cases are inspired from the instruction spec and get basic coverage
of all exceptions FPREM can generate. They also test some "special" exceptions
like stack underflow (when the FPU stack contains only one operand).

The automated cases are generated from all pairs of extreme values in the
bitfields that make up the input operands. This gives rise to a range of
numeric values, NaNs, infinities, and other special values. FPREM raises
either no exceptions, invalid or denormal, and these cases are intended to get
good code path coverage of the implementation.

Signed-off-by: Catalin Patulea <catalinp@google.com>
---
 tests/tcg/Makefile          |    9 ++
 tests/tcg/test-i386-fprem.c |  325 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 334 insertions(+), 0 deletions(-)
 create mode 100644 tests/tcg/test-i386-fprem.c

diff --git a/tests/tcg/Makefile b/tests/tcg/Makefile
index 9ff47b8..06cd563 100644
--- a/tests/tcg/Makefile
+++ b/tests/tcg/Makefile
@@ -22,6 +22,7 @@ I386_TESTS=hello-i386 \
 	   testthread \
 	   sha1-i386 \
 	   test-i386 \
+	   test-i386-fprem \
 	   test-mmap \
 	   # runcom
 
@@ -55,6 +56,11 @@ run-test-i386: test-i386
 	-$(QEMU) test-i386 > test-i386.out
 	@if diff -u test-i386.ref test-i386.out ; then echo "Auto Test OK"; fi
 
+run-test-i386-fprem: test-i386-fprem
+	./test-i386-fprem > test-i386-fprem.ref
+	-$(QEMU) test-i386-fprem > test-i386-fprem.out
+	@if diff -u test-i386-fprem.ref test-i386-fprem.out ; then echo "Auto Test OK"; fi
+
 run-test-x86_64: test-x86_64
 	./test-x86_64 > test-x86_64.ref
 	-$(QEMU_X86_64) test-x86_64 > test-x86_64.out
@@ -93,6 +99,9 @@ test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S \
 	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ \
               $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
 
+test-i386-fprem: test-i386-fprem.c
+	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ $^
+
 test-x86_64: test-i386.c \
            test-i386.h test-i386-shift.h test-i386-muldiv.h
 	$(CC_X86_64) $(CFLAGS) $(LDFLAGS) -o $@ $(<D)/test-i386.c -lm
diff --git a/tests/tcg/test-i386-fprem.c b/tests/tcg/test-i386-fprem.c
new file mode 100644
index 0000000..ed3cbaa
--- /dev/null
+++ b/tests/tcg/test-i386-fprem.c
@@ -0,0 +1,325 @@
+/*
+ *  x86 FPREM test - executes the FPREM instruction with various corner case
+ *  operands and prints the operands, result and FPU status word.
+ *
+ *  Run this on real hardware, and under QEMU, to verify QEMU correctness.
+ *
+ *  Copyright (c) 2003 Fabrice Bellard
+ *  Copyright (c) 2012 Catalin Patulea
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#include "compiler.h"
+#include "osdep.h"
+#include <stdio.h>
+#include <inttypes.h>
+
+/*
+ * Inspired by <ieee754.h>'s union ieee854_long_double, but with single
+ * long long mantissa fields and assuming little-endianness for simplicity.
+ */
+union float80u {
+    long double d;
+
+    /* This is the IEEE 854 double-extended-precision format.  */
+    struct {
+        unsigned long long mantissa:63;
+        unsigned int one:1;
+        unsigned int exponent:15;
+        unsigned int negative:1;
+        unsigned int empty:16;
+    } ieee;
+
+    /* This is for NaNs in the IEEE 854 double-extended-precision format.  */
+    struct {
+        unsigned long long mantissa:62;
+        unsigned int quiet_nan:1;
+        unsigned int one:1;
+        unsigned int exponent:15;
+        unsigned int negative:1;
+        unsigned int empty:16;
+    } ieee_nan;
+};
+
+#define IEEE854_LONG_DOUBLE_BIAS 0x3fff
+
+static const union float80u q_nan = {
+    .ieee_nan.negative = 0,  /* X */
+    .ieee_nan.exponent = 0x7fff,
+    .ieee_nan.one = 1,
+    .ieee_nan.quiet_nan = 1,
+    .ieee_nan.mantissa = 0,
+};
+
+static const union float80u s_nan = {
+    .ieee_nan.negative = 0,  /* X */
+    .ieee_nan.exponent = 0x7fff,
+    .ieee_nan.one = 1,
+    .ieee_nan.quiet_nan = 0,
+    .ieee_nan.mantissa = 1,  /* nonzero */
+};
+
+static const union float80u pos_inf = {
+    .ieee.negative = 0,
+    .ieee.exponent = 0x7fff,
+    .ieee.one = 1,
+    .ieee.mantissa = 0,
+};
+
+static const union float80u pseudo_pos_inf = {  /* "unsupported" */
+    .ieee.negative = 0,
+    .ieee.exponent = 0x7fff,
+    .ieee.one = 0,
+    .ieee.mantissa = 0,
+};
+
+static const union float80u pos_denorm = {
+    .ieee.negative = 0,
+    .ieee.exponent = 0,
+    .ieee.one = 0,
+    .ieee.mantissa = 1,
+};
+
+static const union float80u smallest_positive_norm = {
+    .ieee.negative = 0,
+    .ieee.exponent = 1,
+    .ieee.one = 1,
+    .ieee.mantissa = 0,
+};
+
+static void fninit()
+{
+    asm volatile ("fninit\n");
+}
+
+static long double fprem(long double a, long double b, uint16_t *sw)
+{
+    long double result;
+    asm volatile ("fprem\n"
+                  "fnstsw %1\n"
+                  : "=t" (result), "=m" (*sw)
+                  : "0" (a), "u" (b)
+                  : "st(1)");
+    return result;
+}
+
+#define FPUS_IE (1 << 0)
+#define FPUS_DE (1 << 1)
+#define FPUS_ZE (1 << 2)
+#define FPUS_OE (1 << 3)
+#define FPUS_UE (1 << 4)
+#define FPUS_PE (1 << 5)
+#define FPUS_SF (1 << 6)
+#define FPUS_SE (1 << 7)
+#define FPUS_C0 (1 << 8)
+#define FPUS_C1 (1 << 9)
+#define FPUS_C2 (1 << 10)
+#define FPUS_TOP 0x3800
+#define FPUS_C3 (1 << 14)
+#define FPUS_B  (1 << 15)
+
+#define FPUS_EMASK 0x007f
+
+#define FPUC_EM 0x3f
+
+static void psw(uint16_t sw)
+{
+    printf("SW:  C3 TopC2C1C0\n");
+    printf("SW: %c %d %3d %d %d %d %c %c %c %c %c %c %c %c\n",
+           sw & FPUS_B ? 'B' : 'b',
+           !!(sw & FPUS_C3),
+           (sw & FPUS_TOP) >> 11,
+           !!(sw & FPUS_C2),
+           !!(sw & FPUS_C1),
+           !!(sw & FPUS_C0),
+           (sw & FPUS_SE) ? 'S' : 's',
+           (sw & FPUS_SF) ? 'F' : 'f',
+           (sw & FPUS_PE) ? 'P' : 'p',
+           (sw & FPUS_UE) ? 'U' : 'u',
+           (sw & FPUS_OE) ? 'O' : 'o',
+           (sw & FPUS_ZE) ? 'Z' : 'z',
+           (sw & FPUS_DE) ? 'D' : 'd',
+           (sw & FPUS_IE) ? 'I' : 'i');
+}
+
+static void do_fprem(long double a, long double b)
+{
+    const union float80u au = {.d = a};
+    const union float80u bu = {.d = b};
+    union float80u ru;
+    uint16_t sw;
+
+    printf("A: S=%d Exp=%04x Int=%d (QNaN=%d) Sig=%016llx (%.06Le)\n",
+           au.ieee.negative, au.ieee.exponent, au.ieee.one,
+           au.ieee_nan.quiet_nan, (unsigned long long)au.ieee.mantissa,
+           a);
+    printf("B: S=%d Exp=%04x Int=%d (QNaN=%d) Sig=%016llx (%.06Le)\n",
+           bu.ieee.negative, bu.ieee.exponent, bu.ieee.one,
+           bu.ieee_nan.quiet_nan, (unsigned long long)bu.ieee.mantissa,
+           b);
+
+    fninit();
+    ru.d = fprem(a, b, &sw);
+    psw(sw);
+
+    printf("R: S=%d Exp=%04x Int=%d (QNaN=%d) Sig=%016llx (%.06Le)\n",
+           ru.ieee.negative, ru.ieee.exponent, ru.ieee.one,
+           ru.ieee_nan.quiet_nan, (unsigned long long)ru.ieee.mantissa,
+           ru.d);
+    printf("\n");
+}
+
+static void do_fprem_stack_underflow(void)
+{
+    const long double a = 1.0;
+    union float80u ru;
+    uint16_t sw;
+
+    fninit();
+    asm volatile ("fprem\n"
+                  "fnstsw %1\n"
+                  : "=t" (ru.d), "=m" (sw)
+                  : "0" (a)
+                  : "st(1)");
+    psw(sw);
+
+    printf("R: S=%d Exp=%04x Int=%d (QNaN=%d) Sig=%016llx (%.06Le)\n",
+           ru.ieee.negative, ru.ieee.exponent, ru.ieee.one,
+           ru.ieee_nan.quiet_nan, (unsigned long long)ru.ieee.mantissa,
+           ru.d);
+    printf("\n");
+}
+
+static void test_fprem_cases(void)
+{
+    printf("= stack underflow =\n");
+    do_fprem_stack_underflow();
+
+    printf("= invalid operation =\n");
+    do_fprem(s_nan.d, 1.0);
+    do_fprem(1.0, 0.0);
+    do_fprem(pos_inf.d, 1.0);
+    do_fprem(pseudo_pos_inf.d, 1.0);
+
+    printf("= denormal =\n");
+    do_fprem(pos_denorm.d, 1.0);
+    do_fprem(1.0, pos_denorm.d);
+
+    /* printf("= underflow =\n"); */
+    /* TODO(catalinp): Is there a case where FPREM raises underflow? */
+}
+
+static void test_fprem_pairs(void)
+{
+    unsigned int negative_index_a = 0;
+    unsigned int negative_index_b = 0;
+    static const unsigned int negative_values[] = {
+        0,
+        1,
+    };
+
+    unsigned int exponent_index_a = 0;
+    unsigned int exponent_index_b = 0;
+    static const unsigned int exponent_values[] = {
+        0,
+        1,
+        2,
+        IEEE854_LONG_DOUBLE_BIAS - 1,
+        IEEE854_LONG_DOUBLE_BIAS,
+        IEEE854_LONG_DOUBLE_BIAS + 1,
+        0x7ffd,
+        0x7ffe,
+        0x7fff,
+    };
+
+    unsigned int one_index_a = 0;
+    unsigned int one_index_b = 0;
+    static const unsigned int one_values[] = {
+        0,
+        1,
+    };
+
+    unsigned int quiet_nan_index_a = 0;
+    unsigned int quiet_nan_index_b = 0;
+    static const unsigned int quiet_nan_values[] = {
+        0,
+        1,
+    };
+
+    unsigned int mantissa_index_a = 0;
+    unsigned int mantissa_index_b = 0;
+    static const unsigned long long mantissa_values[] = {
+        0,
+        1,
+        2,
+        0x3ffffffffffffffdULL,
+        0x3ffffffffffffffeULL,
+        0x3fffffffffffffffULL,
+    };
+
+    for (;;) {
+#define INIT_FIELD(var, field) \
+            .ieee_nan.field = field##_values[field##_index_##var]
+        const union float80u a = {
+            INIT_FIELD(a, negative),
+            INIT_FIELD(a, exponent),
+            INIT_FIELD(a, one),
+            INIT_FIELD(a, quiet_nan),
+            INIT_FIELD(a, mantissa),
+        };
+        const union float80u b = {
+            INIT_FIELD(b, negative),
+            INIT_FIELD(b, exponent),
+            INIT_FIELD(b, one),
+            INIT_FIELD(b, quiet_nan),
+            INIT_FIELD(b, mantissa),
+        };
+#undef INIT_FIELD
+
+        do_fprem(a.d, b.d);
+
+        int carry = 1;
+#define CARRY_INTO(var, field) do { \
+            if (carry) { \
+                if (++field##_index_##var == ARRAY_SIZE(field##_values)) { \
+                    field##_index_##var = 0; \
+                } else { \
+                    carry = 0; \
+                } \
+            } \
+        } while (0)
+        CARRY_INTO(b, mantissa);
+        CARRY_INTO(b, quiet_nan);
+        CARRY_INTO(b, one);
+        CARRY_INTO(b, exponent);
+        CARRY_INTO(b, negative);
+        CARRY_INTO(a, mantissa);
+        CARRY_INTO(a, quiet_nan);
+        CARRY_INTO(a, one);
+        CARRY_INTO(a, exponent);
+        CARRY_INTO(a, negative);
+#undef CARRY_INTO
+
+        if (carry) {
+            break;
+        }
+    }
+}
+
+int main(int argc, char **argv)
+{
+    test_fprem_cases();
+    test_fprem_pairs();
+    return 0;
+}
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCH] tests/tcg: add test-i386-fprem and make target for comparing QEMU to h/w
  2012-07-17  2:24         ` [Qemu-devel] [PATCH] tests/tcg: add test-i386-fprem and make target for comparing QEMU to h/w Catalin Patulea
@ 2012-07-17  2:33           ` Catalin Patulea
  2012-07-17 12:23           ` Peter Maydell
  1 sibling, 0 replies; 31+ messages in thread
From: Catalin Patulea @ 2012-07-17  2:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Catalin Patulea

On Mon, Jul 16, 2012 at 10:24 PM, Catalin Patulea <catalinp@google.com> wrote:
> I don't think FPREM
> can ever lose precision with respect to its operands.
Sorry, this should be, "FPREM can't _gain_ precision" with respect to
its operands.

Think of the binary representation with infinite precision, where the
exponent determines the position of the binary point, the binary
points are aligned between the two inputs, and the stored mantissa is
padded to the right with 0s. I don't see how FPREM could inject bits
to the right of the least significant LSB between the two inputs.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCH] tests/tcg: add test-i386-fprem and make target for comparing QEMU to h/w
  2012-07-17  2:24         ` [Qemu-devel] [PATCH] tests/tcg: add test-i386-fprem and make target for comparing QEMU to h/w Catalin Patulea
  2012-07-17  2:33           ` Catalin Patulea
@ 2012-07-17 12:23           ` Peter Maydell
  2012-07-17 14:49             ` Catalin Patulea
  1 sibling, 1 reply; 31+ messages in thread
From: Peter Maydell @ 2012-07-17 12:23 UTC (permalink / raw)
  To: Catalin Patulea; +Cc: qemu-devel

On 17 July 2012 03:24, Catalin Patulea <catalinp@google.com> wrote:
> I'm just sending this in as a draft for now. There are two outstanding issues:
>
> 1) What is the recommended type for bitfields? A quick grep shows inconsistent
> usage of unsigned int/signed int/uintNN_t across the codebase. Note that
> mantissa must be 63 bits so int won't do on either 32 or 64-bit builds.

I think our current position is "don't use bitfields for anything that
has to match an externally defined layout". This is because on Windows
we have to compile with -mms-bitfields [for compatibility with Windows
APIs], which can lead to different layouts for structs with bitfields.
For instance in your struct:

> +    struct {
> +        unsigned long long mantissa:63;
> +        unsigned int one:1;
> +        unsigned int exponent:15;
> +        unsigned int negative:1;
> +        unsigned int empty:16;
> +    } ieee;

the Windows build would not put the fields 'mantissa' and
'one' in the same 64 bit word, it would insert a padding bit.

-- PMM

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCH] tests/tcg: add test-i386-fprem and make target for comparing QEMU to h/w
  2012-07-17 12:23           ` Peter Maydell
@ 2012-07-17 14:49             ` Catalin Patulea
  2012-07-20 22:48               ` Catalin Patulea
  0 siblings, 1 reply; 31+ messages in thread
From: Catalin Patulea @ 2012-07-17 14:49 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel

On Tue, Jul 17, 2012 at 8:23 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
> I think our current position is "don't use bitfields for anything that
> has to match an externally defined layout". This is because on Windows
> we have to compile with -mms-bitfields [for compatibility with Windows
> APIs], which can lead to different layouts for structs with bitfields.
> For instance in your struct:
>
>> +    struct {
>> +        unsigned long long mantissa:63;
>> +        unsigned int one:1;
>> +        unsigned int exponent:15;
>> +        unsigned int negative:1;
>> +        unsigned int empty:16;
>> +    } ieee;
>
> the Windows build would not put the fields 'mantissa' and
> 'one' in the same 64 bit word, it would insert a padding bit.
Since floatx80 is not part of a Windows API (in fact, it's not part of
any API, it's in a test), could I give the structs an attribute of
"gcc_struct"?

http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html (under
"6.36.5 i386 Variable Attributes")

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCH] tests/tcg: add test-i386-fprem and make target for comparing QEMU to h/w
  2012-07-17 14:49             ` Catalin Patulea
@ 2012-07-20 22:48               ` Catalin Patulea
  2012-07-21  9:03                 ` Peter Maydell
  0 siblings, 1 reply; 31+ messages in thread
From: Catalin Patulea @ 2012-07-20 22:48 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Stefan Weil, qemu-devel

On Tue, Jul 17, 2012 at 10:49 AM, Catalin Patulea <catalinp@google.com> wrote:
> > the Windows build would not put the fields 'mantissa' and
> > 'one' in the same 64 bit word, it would insert a padding bit.
> Since floatx80 is not part of a Windows API (in fact, it's not part of
> any API, it's in a test), could I give the structs an attribute of
> "gcc_struct"?
I just noticed that QEMU_PACKED includes this attribute whenever it is
needed (#if defined(_WIN32)) since Stefan Weil's
0f7fdd347514ea97b24f5f658f3ae31f9b078397. Would making the float80u
structs QEMU_PACKED be a reasonable solution? Stefan, can you comment
on whether this is an appropriate use of QEMU_PACKED?

Are there any other issues with the patch? I would punt on the numeric
underflow issue (leaving a TODO), because I think even without it,
adding this test to the codebase is a significant improvement over
what's there currently.

Also, ultimately, this is just a safety net for my patch which changes
the FPREM implementation, so I would want to use the testing patch to
make progress there.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCH v2] Get tests/tcg building and fix an unused variable warning due to wrong extended asm operands.
  2012-07-16 21:19       ` Peter Maydell
  2012-07-17  2:24         ` [Qemu-devel] [PATCH] tests/tcg: add test-i386-fprem and make target for comparing QEMU to h/w Catalin Patulea
@ 2012-07-20 23:23         ` Catalin Patulea
  2012-07-21  9:05           ` Peter Maydell
  1 sibling, 1 reply; 31+ messages in thread
From: Catalin Patulea @ 2012-07-20 23:23 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Anthony Liguori, qemu-devel, chenwj

On Mon, Jul 16, 2012 at 5:19 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 16 July 2012 21:11, Catalin Patulea <catalinp@google.com> wrote:
>> To build/run the tests:
>> $ cd $BUILD_PATH/tests/tcg
>> $ SRC_PATH=path/to/qemu make <target>
>>
>> Signed-off-by: Catalin Patulea <catalinp@google.com>
>> ---
>> This should also fix the lock nop error. I just peeked at what bytes my gcc
>> (4.4.3) generates.
>
> Yep, this all builds for me now.
This this ever get committed? It may very well be in a branch
somewhere on its way in, I just did a git pull and had expected to see
it.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCH] tests/tcg: add test-i386-fprem and make target for comparing QEMU to h/w
  2012-07-20 22:48               ` Catalin Patulea
@ 2012-07-21  9:03                 ` Peter Maydell
  2012-07-25 17:06                   ` [Qemu-devel] [PATCH v2] " Catalin Patulea
  0 siblings, 1 reply; 31+ messages in thread
From: Peter Maydell @ 2012-07-21  9:03 UTC (permalink / raw)
  To: Catalin Patulea; +Cc: Stefan Weil, qemu-devel

On 20 July 2012 23:48, Catalin Patulea <catalinp@google.com> wrote:
> On Tue, Jul 17, 2012 at 10:49 AM, Catalin Patulea <catalinp@google.com> wrote:
>> > the Windows build would not put the fields 'mantissa' and
>> > 'one' in the same 64 bit word, it would insert a padding bit.
>> Since floatx80 is not part of a Windows API (in fact, it's not part of
>> any API, it's in a test), could I give the structs an attribute of
>> "gcc_struct"?
> I just noticed that QEMU_PACKED includes this attribute whenever it is
> needed (#if defined(_WIN32)) since Stefan Weil's
> 0f7fdd347514ea97b24f5f658f3ae31f9b078397. Would making the float80u
> structs QEMU_PACKED be a reasonable solution? Stefan, can you comment
> on whether this is an appropriate use of QEMU_PACKED?

I think the general rule would be "don't use bitfields at all where
you care about layout in memory". Since this is only test case code
we might be more relaxed about it, though.

I don't have any other issues with the patch and I'm happy to leave
TODOs about missing areas of testing; as you say, some testing is
better than none.

-- PMM

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCH v2] Get tests/tcg building and fix an unused variable warning due to wrong extended asm operands.
  2012-07-20 23:23         ` [Qemu-devel] [PATCH v2] Get tests/tcg building and fix an unused variable warning due to wrong extended asm operands Catalin Patulea
@ 2012-07-21  9:05           ` Peter Maydell
  0 siblings, 0 replies; 31+ messages in thread
From: Peter Maydell @ 2012-07-21  9:05 UTC (permalink / raw)
  To: Catalin Patulea; +Cc: Anthony Liguori, qemu-devel, chenwj

On 21 July 2012 00:23, Catalin Patulea <catalinp@google.com> wrote:
> On Mon, Jul 16, 2012 at 5:19 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
>> On 16 July 2012 21:11, Catalin Patulea <catalinp@google.com> wrote:
>>> To build/run the tests:
>>> $ cd $BUILD_PATH/tests/tcg
>>> $ SRC_PATH=path/to/qemu make <target>
>>>
>>> Signed-off-by: Catalin Patulea <catalinp@google.com>
>>> ---
>>> This should also fix the lock nop error. I just peeked at what bytes my gcc
>>> (4.4.3) generates.
>>
>> Yep, this all builds for me now.
> This this ever get committed? It may very well be in a branch
> somewhere on its way in, I just did a git pull and had expected to see
> it.

You need to wait for somebody with commit access to commit it (probably
Anthony or Blue). Patches can take a couple of weeks to get into git
master. Ping the patch every week or two if it seems to be getting forgotten.

-- PMM

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [Qemu-devel] [PATCH v2] tests/tcg: add test-i386-fprem and make target for comparing QEMU to h/w
  2012-07-21  9:03                 ` Peter Maydell
@ 2012-07-25 17:06                   ` Catalin Patulea
  2012-07-28  9:21                     ` Blue Swirl
  0 siblings, 1 reply; 31+ messages in thread
From: Catalin Patulea @ 2012-07-25 17:06 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Catalin Patulea

This test contains manual and automatically-generated test cases, in the style
of test-i386 (run on h/w, run on QEMU, diff the outputs), for the FPREM
instruction. For each test case, the input operands, result and FPU status word
are printed.

The manual cases are inspired from the instruction spec and get basic coverage
of all exceptions FPREM can generate. They also test some "special" exceptions
like stack underflow (when the FPU stack contains only one operand).

The automated cases are generated from all pairs of extreme values in the
bitfields that make up the input operands. This gives rise to a range of
numeric values, NaNs, infinities, and other special values. FPREM raises
either no exceptions, invalid or denormal, and these cases are intended to get
good code path coverage of the implementation.

Signed-off-by: Catalin Patulea <catalinp@google.com>
---
 tests/tcg/Makefile          |    9 ++
 tests/tcg/test-i386-fprem.c |  325 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 334 insertions(+), 0 deletions(-)
 create mode 100644 tests/tcg/test-i386-fprem.c

diff --git a/tests/tcg/Makefile b/tests/tcg/Makefile
index 9ff47b8..06cd563 100644
--- a/tests/tcg/Makefile
+++ b/tests/tcg/Makefile
@@ -22,6 +22,7 @@ I386_TESTS=hello-i386 \
 	   testthread \
 	   sha1-i386 \
 	   test-i386 \
+	   test-i386-fprem \
 	   test-mmap \
 	   # runcom
 
@@ -55,6 +56,11 @@ run-test-i386: test-i386
 	-$(QEMU) test-i386 > test-i386.out
 	@if diff -u test-i386.ref test-i386.out ; then echo "Auto Test OK"; fi
 
+run-test-i386-fprem: test-i386-fprem
+	./test-i386-fprem > test-i386-fprem.ref
+	-$(QEMU) test-i386-fprem > test-i386-fprem.out
+	@if diff -u test-i386-fprem.ref test-i386-fprem.out ; then echo "Auto Test OK"; fi
+
 run-test-x86_64: test-x86_64
 	./test-x86_64 > test-x86_64.ref
 	-$(QEMU_X86_64) test-x86_64 > test-x86_64.out
@@ -93,6 +99,9 @@ test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S \
 	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ \
               $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
 
+test-i386-fprem: test-i386-fprem.c
+	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ $^
+
 test-x86_64: test-i386.c \
            test-i386.h test-i386-shift.h test-i386-muldiv.h
 	$(CC_X86_64) $(CFLAGS) $(LDFLAGS) -o $@ $(<D)/test-i386.c -lm
diff --git a/tests/tcg/test-i386-fprem.c b/tests/tcg/test-i386-fprem.c
new file mode 100644
index 0000000..1042c06
--- /dev/null
+++ b/tests/tcg/test-i386-fprem.c
@@ -0,0 +1,325 @@
+/*
+ *  x86 FPREM test - executes the FPREM instruction with various corner case
+ *  operands and prints the operands, result and FPU status word.
+ *
+ *  Run this on real hardware, and under QEMU, to verify QEMU correctness.
+ *
+ *  Copyright (c) 2003 Fabrice Bellard
+ *  Copyright (c) 2012 Catalin Patulea
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#include "compiler.h"
+#include "osdep.h"
+#include <stdio.h>
+#include <inttypes.h>
+
+/*
+ * Inspired by <ieee754.h>'s union ieee854_long_double, but with single
+ * long long mantissa fields and assuming little-endianness for simplicity.
+ */
+union float80u {
+    long double d;
+
+    /* This is the IEEE 854 double-extended-precision format.  */
+    struct {
+        unsigned long long mantissa:63;
+        unsigned int one:1;
+        unsigned int exponent:15;
+        unsigned int negative:1;
+        unsigned int empty:16;
+    } QEMU_PACKED ieee;
+
+    /* This is for NaNs in the IEEE 854 double-extended-precision format.  */
+    struct {
+        unsigned long long mantissa:62;
+        unsigned int quiet_nan:1;
+        unsigned int one:1;
+        unsigned int exponent:15;
+        unsigned int negative:1;
+        unsigned int empty:16;
+    } QEMU_PACKED ieee_nan;
+};
+
+#define IEEE854_LONG_DOUBLE_BIAS 0x3fff
+
+static const union float80u q_nan = {
+    .ieee_nan.negative = 0,  /* X */
+    .ieee_nan.exponent = 0x7fff,
+    .ieee_nan.one = 1,
+    .ieee_nan.quiet_nan = 1,
+    .ieee_nan.mantissa = 0,
+};
+
+static const union float80u s_nan = {
+    .ieee_nan.negative = 0,  /* X */
+    .ieee_nan.exponent = 0x7fff,
+    .ieee_nan.one = 1,
+    .ieee_nan.quiet_nan = 0,
+    .ieee_nan.mantissa = 1,  /* nonzero */
+};
+
+static const union float80u pos_inf = {
+    .ieee.negative = 0,
+    .ieee.exponent = 0x7fff,
+    .ieee.one = 1,
+    .ieee.mantissa = 0,
+};
+
+static const union float80u pseudo_pos_inf = {  /* "unsupported" */
+    .ieee.negative = 0,
+    .ieee.exponent = 0x7fff,
+    .ieee.one = 0,
+    .ieee.mantissa = 0,
+};
+
+static const union float80u pos_denorm = {
+    .ieee.negative = 0,
+    .ieee.exponent = 0,
+    .ieee.one = 0,
+    .ieee.mantissa = 1,
+};
+
+static const union float80u smallest_positive_norm = {
+    .ieee.negative = 0,
+    .ieee.exponent = 1,
+    .ieee.one = 1,
+    .ieee.mantissa = 0,
+};
+
+static void fninit()
+{
+    asm volatile ("fninit\n");
+}
+
+static long double fprem(long double a, long double b, uint16_t *sw)
+{
+    long double result;
+    asm volatile ("fprem\n"
+                  "fnstsw %1\n"
+                  : "=t" (result), "=m" (*sw)
+                  : "0" (a), "u" (b)
+                  : "st(1)");
+    return result;
+}
+
+#define FPUS_IE (1 << 0)
+#define FPUS_DE (1 << 1)
+#define FPUS_ZE (1 << 2)
+#define FPUS_OE (1 << 3)
+#define FPUS_UE (1 << 4)
+#define FPUS_PE (1 << 5)
+#define FPUS_SF (1 << 6)
+#define FPUS_SE (1 << 7)
+#define FPUS_C0 (1 << 8)
+#define FPUS_C1 (1 << 9)
+#define FPUS_C2 (1 << 10)
+#define FPUS_TOP 0x3800
+#define FPUS_C3 (1 << 14)
+#define FPUS_B  (1 << 15)
+
+#define FPUS_EMASK 0x007f
+
+#define FPUC_EM 0x3f
+
+static void psw(uint16_t sw)
+{
+    printf("SW:  C3 TopC2C1C0\n");
+    printf("SW: %c %d %3d %d %d %d %c %c %c %c %c %c %c %c\n",
+           sw & FPUS_B ? 'B' : 'b',
+           !!(sw & FPUS_C3),
+           (sw & FPUS_TOP) >> 11,
+           !!(sw & FPUS_C2),
+           !!(sw & FPUS_C1),
+           !!(sw & FPUS_C0),
+           (sw & FPUS_SE) ? 'S' : 's',
+           (sw & FPUS_SF) ? 'F' : 'f',
+           (sw & FPUS_PE) ? 'P' : 'p',
+           (sw & FPUS_UE) ? 'U' : 'u',
+           (sw & FPUS_OE) ? 'O' : 'o',
+           (sw & FPUS_ZE) ? 'Z' : 'z',
+           (sw & FPUS_DE) ? 'D' : 'd',
+           (sw & FPUS_IE) ? 'I' : 'i');
+}
+
+static void do_fprem(long double a, long double b)
+{
+    const union float80u au = {.d = a};
+    const union float80u bu = {.d = b};
+    union float80u ru;
+    uint16_t sw;
+
+    printf("A: S=%d Exp=%04x Int=%d (QNaN=%d) Sig=%016llx (%.06Le)\n",
+           au.ieee.negative, au.ieee.exponent, au.ieee.one,
+           au.ieee_nan.quiet_nan, (unsigned long long)au.ieee.mantissa,
+           a);
+    printf("B: S=%d Exp=%04x Int=%d (QNaN=%d) Sig=%016llx (%.06Le)\n",
+           bu.ieee.negative, bu.ieee.exponent, bu.ieee.one,
+           bu.ieee_nan.quiet_nan, (unsigned long long)bu.ieee.mantissa,
+           b);
+
+    fninit();
+    ru.d = fprem(a, b, &sw);
+    psw(sw);
+
+    printf("R: S=%d Exp=%04x Int=%d (QNaN=%d) Sig=%016llx (%.06Le)\n",
+           ru.ieee.negative, ru.ieee.exponent, ru.ieee.one,
+           ru.ieee_nan.quiet_nan, (unsigned long long)ru.ieee.mantissa,
+           ru.d);
+    printf("\n");
+}
+
+static void do_fprem_stack_underflow(void)
+{
+    const long double a = 1.0;
+    union float80u ru;
+    uint16_t sw;
+
+    fninit();
+    asm volatile ("fprem\n"
+                  "fnstsw %1\n"
+                  : "=t" (ru.d), "=m" (sw)
+                  : "0" (a)
+                  : "st(1)");
+    psw(sw);
+
+    printf("R: S=%d Exp=%04x Int=%d (QNaN=%d) Sig=%016llx (%.06Le)\n",
+           ru.ieee.negative, ru.ieee.exponent, ru.ieee.one,
+           ru.ieee_nan.quiet_nan, (unsigned long long)ru.ieee.mantissa,
+           ru.d);
+    printf("\n");
+}
+
+static void test_fprem_cases(void)
+{
+    printf("= stack underflow =\n");
+    do_fprem_stack_underflow();
+
+    printf("= invalid operation =\n");
+    do_fprem(s_nan.d, 1.0);
+    do_fprem(1.0, 0.0);
+    do_fprem(pos_inf.d, 1.0);
+    do_fprem(pseudo_pos_inf.d, 1.0);
+
+    printf("= denormal =\n");
+    do_fprem(pos_denorm.d, 1.0);
+    do_fprem(1.0, pos_denorm.d);
+
+    /* printf("= underflow =\n"); */
+    /* TODO(catalinp): Is there a case where FPREM raises underflow? */
+}
+
+static void test_fprem_pairs(void)
+{
+    unsigned int negative_index_a = 0;
+    unsigned int negative_index_b = 0;
+    static const unsigned int negative_values[] = {
+        0,
+        1,
+    };
+
+    unsigned int exponent_index_a = 0;
+    unsigned int exponent_index_b = 0;
+    static const unsigned int exponent_values[] = {
+        0,
+        1,
+        2,
+        IEEE854_LONG_DOUBLE_BIAS - 1,
+        IEEE854_LONG_DOUBLE_BIAS,
+        IEEE854_LONG_DOUBLE_BIAS + 1,
+        0x7ffd,
+        0x7ffe,
+        0x7fff,
+    };
+
+    unsigned int one_index_a = 0;
+    unsigned int one_index_b = 0;
+    static const unsigned int one_values[] = {
+        0,
+        1,
+    };
+
+    unsigned int quiet_nan_index_a = 0;
+    unsigned int quiet_nan_index_b = 0;
+    static const unsigned int quiet_nan_values[] = {
+        0,
+        1,
+    };
+
+    unsigned int mantissa_index_a = 0;
+    unsigned int mantissa_index_b = 0;
+    static const unsigned long long mantissa_values[] = {
+        0,
+        1,
+        2,
+        0x3ffffffffffffffdULL,
+        0x3ffffffffffffffeULL,
+        0x3fffffffffffffffULL,
+    };
+
+    for (;;) {
+#define INIT_FIELD(var, field) \
+            .ieee_nan.field = field##_values[field##_index_##var]
+        const union float80u a = {
+            INIT_FIELD(a, negative),
+            INIT_FIELD(a, exponent),
+            INIT_FIELD(a, one),
+            INIT_FIELD(a, quiet_nan),
+            INIT_FIELD(a, mantissa),
+        };
+        const union float80u b = {
+            INIT_FIELD(b, negative),
+            INIT_FIELD(b, exponent),
+            INIT_FIELD(b, one),
+            INIT_FIELD(b, quiet_nan),
+            INIT_FIELD(b, mantissa),
+        };
+#undef INIT_FIELD
+
+        do_fprem(a.d, b.d);
+
+        int carry = 1;
+#define CARRY_INTO(var, field) do { \
+            if (carry) { \
+                if (++field##_index_##var == ARRAY_SIZE(field##_values)) { \
+                    field##_index_##var = 0; \
+                } else { \
+                    carry = 0; \
+                } \
+            } \
+        } while (0)
+        CARRY_INTO(b, mantissa);
+        CARRY_INTO(b, quiet_nan);
+        CARRY_INTO(b, one);
+        CARRY_INTO(b, exponent);
+        CARRY_INTO(b, negative);
+        CARRY_INTO(a, mantissa);
+        CARRY_INTO(a, quiet_nan);
+        CARRY_INTO(a, one);
+        CARRY_INTO(a, exponent);
+        CARRY_INTO(a, negative);
+#undef CARRY_INTO
+
+        if (carry) {
+            break;
+        }
+    }
+}
+
+int main(int argc, char **argv)
+{
+    test_fprem_cases();
+    test_fprem_pairs();
+    return 0;
+}
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCH v2] tests/tcg: add test-i386-fprem and make target for comparing QEMU to h/w
  2012-07-25 17:06                   ` [Qemu-devel] [PATCH v2] " Catalin Patulea
@ 2012-07-28  9:21                     ` Blue Swirl
  0 siblings, 0 replies; 31+ messages in thread
From: Blue Swirl @ 2012-07-28  9:21 UTC (permalink / raw)
  To: Catalin Patulea; +Cc: Peter Maydell, qemu-devel

On Wed, Jul 25, 2012 at 5:06 PM, Catalin Patulea <catalinp@google.com> wrote:
> This test contains manual and automatically-generated test cases, in the style
> of test-i386 (run on h/w, run on QEMU, diff the outputs), for the FPREM
> instruction. For each test case, the input operands, result and FPU status word
> are printed.
>
> The manual cases are inspired from the instruction spec and get basic coverage
> of all exceptions FPREM can generate. They also test some "special" exceptions
> like stack underflow (when the FPU stack contains only one operand).
>
> The automated cases are generated from all pairs of extreme values in the
> bitfields that make up the input operands. This gives rise to a range of
> numeric values, NaNs, infinities, and other special values. FPREM raises
> either no exceptions, invalid or denormal, and these cases are intended to get
> good code path coverage of the implementation.

Patch does not apply, is this against git master?

>
> Signed-off-by: Catalin Patulea <catalinp@google.com>
> ---
>  tests/tcg/Makefile          |    9 ++
>  tests/tcg/test-i386-fprem.c |  325 +++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 334 insertions(+), 0 deletions(-)
>  create mode 100644 tests/tcg/test-i386-fprem.c
>
> diff --git a/tests/tcg/Makefile b/tests/tcg/Makefile
> index 9ff47b8..06cd563 100644
> --- a/tests/tcg/Makefile
> +++ b/tests/tcg/Makefile
> @@ -22,6 +22,7 @@ I386_TESTS=hello-i386 \
>            testthread \
>            sha1-i386 \
>            test-i386 \
> +          test-i386-fprem \
>            test-mmap \
>            # runcom
>
> @@ -55,6 +56,11 @@ run-test-i386: test-i386
>         -$(QEMU) test-i386 > test-i386.out
>         @if diff -u test-i386.ref test-i386.out ; then echo "Auto Test OK"; fi
>
> +run-test-i386-fprem: test-i386-fprem
> +       ./test-i386-fprem > test-i386-fprem.ref
> +       -$(QEMU) test-i386-fprem > test-i386-fprem.out
> +       @if diff -u test-i386-fprem.ref test-i386-fprem.out ; then echo "Auto Test OK"; fi
> +
>  run-test-x86_64: test-x86_64
>         ./test-x86_64 > test-x86_64.ref
>         -$(QEMU_X86_64) test-x86_64 > test-x86_64.out
> @@ -93,6 +99,9 @@ test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S \
>         $(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ \
>                $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
>
> +test-i386-fprem: test-i386-fprem.c
> +       $(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ $^
> +
>  test-x86_64: test-i386.c \
>             test-i386.h test-i386-shift.h test-i386-muldiv.h
>         $(CC_X86_64) $(CFLAGS) $(LDFLAGS) -o $@ $(<D)/test-i386.c -lm
> diff --git a/tests/tcg/test-i386-fprem.c b/tests/tcg/test-i386-fprem.c
> new file mode 100644
> index 0000000..1042c06
> --- /dev/null
> +++ b/tests/tcg/test-i386-fprem.c
> @@ -0,0 +1,325 @@
> +/*
> + *  x86 FPREM test - executes the FPREM instruction with various corner case
> + *  operands and prints the operands, result and FPU status word.
> + *
> + *  Run this on real hardware, and under QEMU, to verify QEMU correctness.
> + *
> + *  Copyright (c) 2003 Fabrice Bellard
> + *  Copyright (c) 2012 Catalin Patulea
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; either version 2 of the License, or
> + *  (at your option) any later version.
> + *
> + *  This program 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 General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, see <http://www.gnu.org/licenses/>.
> + */
> +#include "compiler.h"
> +#include "osdep.h"
> +#include <stdio.h>
> +#include <inttypes.h>
> +
> +/*
> + * Inspired by <ieee754.h>'s union ieee854_long_double, but with single
> + * long long mantissa fields and assuming little-endianness for simplicity.
> + */
> +union float80u {
> +    long double d;
> +
> +    /* This is the IEEE 854 double-extended-precision format.  */
> +    struct {
> +        unsigned long long mantissa:63;
> +        unsigned int one:1;
> +        unsigned int exponent:15;
> +        unsigned int negative:1;
> +        unsigned int empty:16;
> +    } QEMU_PACKED ieee;
> +
> +    /* This is for NaNs in the IEEE 854 double-extended-precision format.  */
> +    struct {
> +        unsigned long long mantissa:62;
> +        unsigned int quiet_nan:1;
> +        unsigned int one:1;
> +        unsigned int exponent:15;
> +        unsigned int negative:1;
> +        unsigned int empty:16;
> +    } QEMU_PACKED ieee_nan;
> +};
> +
> +#define IEEE854_LONG_DOUBLE_BIAS 0x3fff
> +
> +static const union float80u q_nan = {
> +    .ieee_nan.negative = 0,  /* X */
> +    .ieee_nan.exponent = 0x7fff,
> +    .ieee_nan.one = 1,
> +    .ieee_nan.quiet_nan = 1,
> +    .ieee_nan.mantissa = 0,
> +};
> +
> +static const union float80u s_nan = {
> +    .ieee_nan.negative = 0,  /* X */
> +    .ieee_nan.exponent = 0x7fff,
> +    .ieee_nan.one = 1,
> +    .ieee_nan.quiet_nan = 0,
> +    .ieee_nan.mantissa = 1,  /* nonzero */
> +};
> +
> +static const union float80u pos_inf = {
> +    .ieee.negative = 0,
> +    .ieee.exponent = 0x7fff,
> +    .ieee.one = 1,
> +    .ieee.mantissa = 0,
> +};
> +
> +static const union float80u pseudo_pos_inf = {  /* "unsupported" */
> +    .ieee.negative = 0,
> +    .ieee.exponent = 0x7fff,
> +    .ieee.one = 0,
> +    .ieee.mantissa = 0,
> +};
> +
> +static const union float80u pos_denorm = {
> +    .ieee.negative = 0,
> +    .ieee.exponent = 0,
> +    .ieee.one = 0,
> +    .ieee.mantissa = 1,
> +};
> +
> +static const union float80u smallest_positive_norm = {
> +    .ieee.negative = 0,
> +    .ieee.exponent = 1,
> +    .ieee.one = 1,
> +    .ieee.mantissa = 0,
> +};
> +
> +static void fninit()
> +{
> +    asm volatile ("fninit\n");
> +}
> +
> +static long double fprem(long double a, long double b, uint16_t *sw)
> +{
> +    long double result;
> +    asm volatile ("fprem\n"
> +                  "fnstsw %1\n"
> +                  : "=t" (result), "=m" (*sw)
> +                  : "0" (a), "u" (b)
> +                  : "st(1)");
> +    return result;
> +}
> +
> +#define FPUS_IE (1 << 0)
> +#define FPUS_DE (1 << 1)
> +#define FPUS_ZE (1 << 2)
> +#define FPUS_OE (1 << 3)
> +#define FPUS_UE (1 << 4)
> +#define FPUS_PE (1 << 5)
> +#define FPUS_SF (1 << 6)
> +#define FPUS_SE (1 << 7)
> +#define FPUS_C0 (1 << 8)
> +#define FPUS_C1 (1 << 9)
> +#define FPUS_C2 (1 << 10)
> +#define FPUS_TOP 0x3800
> +#define FPUS_C3 (1 << 14)
> +#define FPUS_B  (1 << 15)
> +
> +#define FPUS_EMASK 0x007f
> +
> +#define FPUC_EM 0x3f
> +
> +static void psw(uint16_t sw)
> +{
> +    printf("SW:  C3 TopC2C1C0\n");
> +    printf("SW: %c %d %3d %d %d %d %c %c %c %c %c %c %c %c\n",
> +           sw & FPUS_B ? 'B' : 'b',
> +           !!(sw & FPUS_C3),
> +           (sw & FPUS_TOP) >> 11,
> +           !!(sw & FPUS_C2),
> +           !!(sw & FPUS_C1),
> +           !!(sw & FPUS_C0),
> +           (sw & FPUS_SE) ? 'S' : 's',
> +           (sw & FPUS_SF) ? 'F' : 'f',
> +           (sw & FPUS_PE) ? 'P' : 'p',
> +           (sw & FPUS_UE) ? 'U' : 'u',
> +           (sw & FPUS_OE) ? 'O' : 'o',
> +           (sw & FPUS_ZE) ? 'Z' : 'z',
> +           (sw & FPUS_DE) ? 'D' : 'd',
> +           (sw & FPUS_IE) ? 'I' : 'i');
> +}
> +
> +static void do_fprem(long double a, long double b)
> +{
> +    const union float80u au = {.d = a};
> +    const union float80u bu = {.d = b};
> +    union float80u ru;
> +    uint16_t sw;
> +
> +    printf("A: S=%d Exp=%04x Int=%d (QNaN=%d) Sig=%016llx (%.06Le)\n",
> +           au.ieee.negative, au.ieee.exponent, au.ieee.one,
> +           au.ieee_nan.quiet_nan, (unsigned long long)au.ieee.mantissa,
> +           a);
> +    printf("B: S=%d Exp=%04x Int=%d (QNaN=%d) Sig=%016llx (%.06Le)\n",
> +           bu.ieee.negative, bu.ieee.exponent, bu.ieee.one,
> +           bu.ieee_nan.quiet_nan, (unsigned long long)bu.ieee.mantissa,
> +           b);
> +
> +    fninit();
> +    ru.d = fprem(a, b, &sw);
> +    psw(sw);
> +
> +    printf("R: S=%d Exp=%04x Int=%d (QNaN=%d) Sig=%016llx (%.06Le)\n",
> +           ru.ieee.negative, ru.ieee.exponent, ru.ieee.one,
> +           ru.ieee_nan.quiet_nan, (unsigned long long)ru.ieee.mantissa,
> +           ru.d);
> +    printf("\n");
> +}
> +
> +static void do_fprem_stack_underflow(void)
> +{
> +    const long double a = 1.0;
> +    union float80u ru;
> +    uint16_t sw;
> +
> +    fninit();
> +    asm volatile ("fprem\n"
> +                  "fnstsw %1\n"
> +                  : "=t" (ru.d), "=m" (sw)
> +                  : "0" (a)
> +                  : "st(1)");
> +    psw(sw);
> +
> +    printf("R: S=%d Exp=%04x Int=%d (QNaN=%d) Sig=%016llx (%.06Le)\n",
> +           ru.ieee.negative, ru.ieee.exponent, ru.ieee.one,
> +           ru.ieee_nan.quiet_nan, (unsigned long long)ru.ieee.mantissa,
> +           ru.d);
> +    printf("\n");
> +}
> +
> +static void test_fprem_cases(void)
> +{
> +    printf("= stack underflow =\n");
> +    do_fprem_stack_underflow();
> +
> +    printf("= invalid operation =\n");
> +    do_fprem(s_nan.d, 1.0);
> +    do_fprem(1.0, 0.0);
> +    do_fprem(pos_inf.d, 1.0);
> +    do_fprem(pseudo_pos_inf.d, 1.0);
> +
> +    printf("= denormal =\n");
> +    do_fprem(pos_denorm.d, 1.0);
> +    do_fprem(1.0, pos_denorm.d);
> +
> +    /* printf("= underflow =\n"); */
> +    /* TODO(catalinp): Is there a case where FPREM raises underflow? */
> +}
> +
> +static void test_fprem_pairs(void)
> +{
> +    unsigned int negative_index_a = 0;
> +    unsigned int negative_index_b = 0;
> +    static const unsigned int negative_values[] = {
> +        0,
> +        1,
> +    };
> +
> +    unsigned int exponent_index_a = 0;
> +    unsigned int exponent_index_b = 0;
> +    static const unsigned int exponent_values[] = {
> +        0,
> +        1,
> +        2,
> +        IEEE854_LONG_DOUBLE_BIAS - 1,
> +        IEEE854_LONG_DOUBLE_BIAS,
> +        IEEE854_LONG_DOUBLE_BIAS + 1,
> +        0x7ffd,
> +        0x7ffe,
> +        0x7fff,
> +    };
> +
> +    unsigned int one_index_a = 0;
> +    unsigned int one_index_b = 0;
> +    static const unsigned int one_values[] = {
> +        0,
> +        1,
> +    };
> +
> +    unsigned int quiet_nan_index_a = 0;
> +    unsigned int quiet_nan_index_b = 0;
> +    static const unsigned int quiet_nan_values[] = {
> +        0,
> +        1,
> +    };
> +
> +    unsigned int mantissa_index_a = 0;
> +    unsigned int mantissa_index_b = 0;
> +    static const unsigned long long mantissa_values[] = {
> +        0,
> +        1,
> +        2,
> +        0x3ffffffffffffffdULL,
> +        0x3ffffffffffffffeULL,
> +        0x3fffffffffffffffULL,
> +    };
> +
> +    for (;;) {
> +#define INIT_FIELD(var, field) \
> +            .ieee_nan.field = field##_values[field##_index_##var]
> +        const union float80u a = {
> +            INIT_FIELD(a, negative),
> +            INIT_FIELD(a, exponent),
> +            INIT_FIELD(a, one),
> +            INIT_FIELD(a, quiet_nan),
> +            INIT_FIELD(a, mantissa),
> +        };
> +        const union float80u b = {
> +            INIT_FIELD(b, negative),
> +            INIT_FIELD(b, exponent),
> +            INIT_FIELD(b, one),
> +            INIT_FIELD(b, quiet_nan),
> +            INIT_FIELD(b, mantissa),
> +        };
> +#undef INIT_FIELD
> +
> +        do_fprem(a.d, b.d);
> +
> +        int carry = 1;
> +#define CARRY_INTO(var, field) do { \
> +            if (carry) { \
> +                if (++field##_index_##var == ARRAY_SIZE(field##_values)) { \
> +                    field##_index_##var = 0; \
> +                } else { \
> +                    carry = 0; \
> +                } \
> +            } \
> +        } while (0)
> +        CARRY_INTO(b, mantissa);
> +        CARRY_INTO(b, quiet_nan);
> +        CARRY_INTO(b, one);
> +        CARRY_INTO(b, exponent);
> +        CARRY_INTO(b, negative);
> +        CARRY_INTO(a, mantissa);
> +        CARRY_INTO(a, quiet_nan);
> +        CARRY_INTO(a, one);
> +        CARRY_INTO(a, exponent);
> +        CARRY_INTO(a, negative);
> +#undef CARRY_INTO
> +
> +        if (carry) {
> +            break;
> +        }
> +    }
> +}
> +
> +int main(int argc, char **argv)
> +{
> +    test_fprem_cases();
> +    test_fprem_pairs();
> +    return 0;
> +}
> --
> 1.7.7.3
>
>

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [Qemu-devel] [PATCHv3] tests/tcg: fix build
       [not found] <Message-ID: <CAFEAcA9=OY0VMzTbvjigDdOMt_4JoJeRds4_t9hni1Zq4ir9EA@mail.gmail.com>
@ 2012-10-16  6:53 ` Catalin Patulea
  2012-10-16 12:50   ` Peter Maydell
  0 siblings, 1 reply; 31+ messages in thread
From: Catalin Patulea @ 2012-10-16  6:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Anthony Liguori, chenwj, Catalin Patulea

Sorry this got abandoned.. here is a fresh (and slightly leaner) patch on top of master. Can anyone take a look?

---
This broke when the tests were moved from tests/ to tests/tcg/.

On x86_64 host/i386-linux-user non-kvm guest, test-i386 and test-mmap are broken, but at least they build.

To build/run the tests:
$ cd $BUILD_PATH/tests/tcg
$ SRC_PATH=path/to/qemu make <target>
---
 tests/tcg/Makefile     |   16 ++++++++++------
 tests/tcg/linux-test.c |    2 ++
 tests/tcg/test-i386.c  |    3 ++-
 tests/tcg/test_path.c  |   13 +++++++------
 4 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/tests/tcg/Makefile b/tests/tcg/Makefile
index 15e36a2..9ff47b8 100644
--- a/tests/tcg/Makefile
+++ b/tests/tcg/Makefile
@@ -1,13 +1,13 @@
--include ../config-host.mak
+-include ../../config-host.mak
 -include $(SRC_PATH)/rules.mak
 
-$(call set-vpath, $(SRC_PATH)/tests)
+$(call set-vpath, $(SRC_PATH)/tests/tcg)
 
-QEMU=../i386-linux-user/qemu-i386
-QEMU_X86_64=../x86_64-linux-user/qemu-x86_64
+QEMU=../../i386-linux-user/qemu-i386
+QEMU_X86_64=../../x86_64-linux-user/qemu-x86_64
 CC_X86_64=$(CC_I386) -m64
 
-QEMU_INCLUDES += -I..
+QEMU_INCLUDES += -I../..
 CFLAGS=-Wall -O2 -g -fno-strict-aliasing
 #CFLAGS+=-msse2
 LDFLAGS=
@@ -36,6 +36,7 @@ TESTS += $(I386_TESTS)
 endif
 
 all: $(patsubst %,run-%,$(TESTS))
+test: all
 
 # rules to run tests
 
@@ -74,7 +75,10 @@ run-test_path: test_path
 # rules to compile tests
 
 test_path: test_path.o
+	$(CC_I386) $(LDFLAGS) -o $@ $^ $(LIBS)
+
 test_path.o: test_path.c
+	$(CC_I386) $(QEMU_INCLUDES) $(GLIB_CFLAGS) $(CFLAGS) -c -o $@ $^
 
 hello-i386: hello-i386.c
 	$(CC_I386) -nostdlib $(CFLAGS) -static $(LDFLAGS) -o $@ $<
@@ -86,7 +90,7 @@ testthread: testthread.c
 # i386/x86_64 emulation test (test various opcodes) */
 test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S \
            test-i386.h test-i386-shift.h test-i386-muldiv.h
-	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ \
+	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ \
               $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
 
 test-x86_64: test-i386.c \
diff --git a/tests/tcg/linux-test.c b/tests/tcg/linux-test.c
index 2e4a746..83cb32d 100644
--- a/tests/tcg/linux-test.c
+++ b/tests/tcg/linux-test.c
@@ -16,6 +16,7 @@
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
+#define _GNU_SOURCE
 #include <stdarg.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -38,6 +39,7 @@
 #include <dirent.h>
 #include <setjmp.h>
 #include <sys/shm.h>
+#include <sched.h>
 
 #define TESTPATH "/tmp/linux-test.tmp"
 #define TESTPORT 7654
diff --git a/tests/tcg/test-i386.c b/tests/tcg/test-i386.c
index 8e64bba..64d929e 100644
--- a/tests/tcg/test-i386.c
+++ b/tests/tcg/test-i386.c
@@ -17,6 +17,7 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 #define _GNU_SOURCE
+#include "compiler.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -1827,7 +1828,7 @@ void test_exceptions(void)
     printf("lock nop exception:\n");
     if (setjmp(jmp_env) == 0) {
         /* now execute an invalid instruction */
-        asm volatile("lock nop");
+        asm volatile(".byte 0xf0, 0x90"); /* lock nop */
     }
 
     printf("INT exception:\n");
diff --git a/tests/tcg/test_path.c b/tests/tcg/test_path.c
index 7265a94..a064eea 100644
--- a/tests/tcg/test_path.c
+++ b/tests/tcg/test_path.c
@@ -1,11 +1,12 @@
 /* Test path override code */
-#include "../config-host.h"
-#include "../qemu-malloc.c"
-#include "../cutils.c"
-#include "../path.c"
-#include "../trace.c"
+#define _GNU_SOURCE
+#include "config-host.h"
+#include "iov.c"
+#include "cutils.c"
+#include "path.c"
+#include "trace.c"
 #ifdef CONFIG_TRACE_SIMPLE
-#include "../simpletrace.c"
+#include "../trace/simple.c"
 #endif
 
 #include <stdarg.h>
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCHv3] tests/tcg: fix build
  2012-10-16  6:53 ` [Qemu-devel] [PATCHv3] tests/tcg: fix build Catalin Patulea
@ 2012-10-16 12:50   ` Peter Maydell
  2012-10-16 18:09     ` Catalin Patulea
  2012-10-16 19:37     ` [Qemu-devel] [PATCHv4] " Catalin Patulea
  0 siblings, 2 replies; 31+ messages in thread
From: Peter Maydell @ 2012-10-16 12:50 UTC (permalink / raw)
  To: Catalin Patulea; +Cc: Anthony Liguori, qemu-devel, chenwj

On 16 October 2012 07:53, Catalin Patulea <catalinp@google.com> wrote:
> Sorry this got abandoned.. here is a fresh (and slightly leaner) patch on top of master. Can anyone take a look?
>
> ---
> This broke when the tests were moved from tests/ to tests/tcg/.
>
> On x86_64 host/i386-linux-user non-kvm guest, test-i386 and test-mmap are broken, but at least they build.
>
> To build/run the tests:
> $ cd $BUILD_PATH/tests/tcg
> $ SRC_PATH=path/to/qemu make <target>

> @@ -86,7 +90,7 @@ testthread: testthread.c
>  # i386/x86_64 emulation test (test various opcodes) */
>  test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S \
>             test-i386.h test-i386-shift.h test-i386-muldiv.h
> -       $(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ \
> +       $(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ \
>                $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm

The compile line for the test-x86_64 target also needs
QEMU_INCLUDES added to it.

I can't work out how to get a working i386 compiler on my 64-bit Ubuntu system
but I think that's an Ubuntu issue :-) Tests run ok on a 32 bit native box
(there are some failures, as you say, but I'm unsurprised given how long it's
been since we ran them last.)

-- PMM

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCHv3] tests/tcg: fix build
  2012-10-16 12:50   ` Peter Maydell
@ 2012-10-16 18:09     ` Catalin Patulea
  2012-10-16 18:47       ` Peter Maydell
  2012-10-16 19:37     ` [Qemu-devel] [PATCHv4] " Catalin Patulea
  1 sibling, 1 reply; 31+ messages in thread
From: Catalin Patulea @ 2012-10-16 18:09 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Anthony Liguori, qemu-devel, 陳韋任

On Tue, Oct 16, 2012 at 8:50 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
> The compile line for the test-x86_64 target also needs
> QEMU_INCLUDES added to it.
Done.

> I can't work out how to get a working i386 compiler on my 64-bit Ubuntu system
> but I think that's an Ubuntu issue :-) Tests run ok on a 32 bit native box
> (there are some failures, as you say, but I'm unsurprised given how long it's
> been since we ran them last.)
I'm running x86_64 precise with CC_I386="gcc -m32" (autodetected by
configure) - does that not work for you? Is there anything wrong with
building 32-bit binaries this way?

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCHv3] tests/tcg: fix build
  2012-10-16 18:09     ` Catalin Patulea
@ 2012-10-16 18:47       ` Peter Maydell
  2012-10-16 19:34         ` Catalin Patulea
  0 siblings, 1 reply; 31+ messages in thread
From: Peter Maydell @ 2012-10-16 18:47 UTC (permalink / raw)
  To: Catalin Patulea; +Cc: Anthony Liguori, qemu-devel, 陳韋任

On 16 October 2012 19:09, Catalin Patulea <catalinp@google.com> wrote:
> On Tue, Oct 16, 2012 at 8:50 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
>> I can't work out how to get a working i386 compiler on my 64-bit Ubuntu system
>> but I think that's an Ubuntu issue :-) Tests run ok on a 32 bit native box
>> (there are some failures, as you say, but I'm unsurprised given how long it's
>> been since we ran them last.)
> I'm running x86_64 precise with CC_I386="gcc -m32" (autodetected by
> configure) - does that not work for you? Is there anything wrong with
> building 32-bit binaries this way?

I think that should work but my setup is broken somehow: it can't
find the 32 bit libgcc (and in passing finds and discards the 64 bit
version):

cam-vm-266:precise:tcg$ make linux-test
ccache gcc -m32 -Wall -O2 -g -fno-strict-aliasing  -o linux-test
linux-test.c -lm
/usr/bin/ld: skipping incompatible
/usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible
/usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc_s.so when searching for
-lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status
make: *** [linux-test] Error 1

I have a feeling that precise's mostly-working multiarch support
may be the issue...

-- PMM

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCHv3] tests/tcg: fix build
  2012-10-16 18:47       ` Peter Maydell
@ 2012-10-16 19:34         ` Catalin Patulea
  0 siblings, 0 replies; 31+ messages in thread
From: Catalin Patulea @ 2012-10-16 19:34 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Anthony Liguori, qemu-devel, 陳韋任

On Tue, Oct 16, 2012 at 2:47 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> I have a feeling that precise's mostly-working multiarch support
> may be the issue...
Seems I've got libgcc1:i386 and lib32gcc1 which provide libgcc_s.so*
in various forms. Not entirely sure what the 'right' setup is.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [Qemu-devel] [PATCHv4] tests/tcg: fix build
  2012-10-16 12:50   ` Peter Maydell
  2012-10-16 18:09     ` Catalin Patulea
@ 2012-10-16 19:37     ` Catalin Patulea
  2012-10-16 19:54       ` Peter Maydell
  1 sibling, 1 reply; 31+ messages in thread
From: Catalin Patulea @ 2012-10-16 19:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Anthony Liguori, chenwj, Catalin Patulea

Fixes compile line for test-x86_64 target as well.

---
This broke when the tests were moved from tests/ to tests/tcg/.

On x86_64 host/i386-linux-user non-kvm guest, test-i386 and test-mmap are broken, but at least they build.

To build/run the tests:
$ cd $BUILD_PATH/tests/tcg
$ SRC_PATH=path/to/qemu make <target>
---
 tests/tcg/Makefile     |   18 +++++++++++-------
 tests/tcg/linux-test.c |    2 ++
 tests/tcg/test-i386.c  |    3 ++-
 tests/tcg/test_path.c  |   13 +++++++------
 4 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/tests/tcg/Makefile b/tests/tcg/Makefile
index 15e36a2..80b1a4b 100644
--- a/tests/tcg/Makefile
+++ b/tests/tcg/Makefile
@@ -1,13 +1,13 @@
--include ../config-host.mak
+-include ../../config-host.mak
 -include $(SRC_PATH)/rules.mak
 
-$(call set-vpath, $(SRC_PATH)/tests)
+$(call set-vpath, $(SRC_PATH)/tests/tcg)
 
-QEMU=../i386-linux-user/qemu-i386
-QEMU_X86_64=../x86_64-linux-user/qemu-x86_64
+QEMU=../../i386-linux-user/qemu-i386
+QEMU_X86_64=../../x86_64-linux-user/qemu-x86_64
 CC_X86_64=$(CC_I386) -m64
 
-QEMU_INCLUDES += -I..
+QEMU_INCLUDES += -I../..
 CFLAGS=-Wall -O2 -g -fno-strict-aliasing
 #CFLAGS+=-msse2
 LDFLAGS=
@@ -36,6 +36,7 @@ TESTS += $(I386_TESTS)
 endif
 
 all: $(patsubst %,run-%,$(TESTS))
+test: all
 
 # rules to run tests
 
@@ -74,7 +75,10 @@ run-test_path: test_path
 # rules to compile tests
 
 test_path: test_path.o
+	$(CC_I386) $(LDFLAGS) -o $@ $^ $(LIBS)
+
 test_path.o: test_path.c
+	$(CC_I386) $(QEMU_INCLUDES) $(GLIB_CFLAGS) $(CFLAGS) -c -o $@ $^
 
 hello-i386: hello-i386.c
 	$(CC_I386) -nostdlib $(CFLAGS) -static $(LDFLAGS) -o $@ $<
@@ -86,12 +90,12 @@ testthread: testthread.c
 # i386/x86_64 emulation test (test various opcodes) */
 test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S \
            test-i386.h test-i386-shift.h test-i386-muldiv.h
-	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ \
+	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ \
               $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
 
 test-x86_64: test-i386.c \
            test-i386.h test-i386-shift.h test-i386-muldiv.h
-	$(CC_X86_64) $(CFLAGS) $(LDFLAGS) -o $@ $(<D)/test-i386.c -lm
+	$(CC_X86_64) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ $(<D)/test-i386.c -lm
 
 # generic Linux and CPU test
 linux-test: linux-test.c
diff --git a/tests/tcg/linux-test.c b/tests/tcg/linux-test.c
index 2e4a746..83cb32d 100644
--- a/tests/tcg/linux-test.c
+++ b/tests/tcg/linux-test.c
@@ -16,6 +16,7 @@
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
+#define _GNU_SOURCE
 #include <stdarg.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -38,6 +39,7 @@
 #include <dirent.h>
 #include <setjmp.h>
 #include <sys/shm.h>
+#include <sched.h>
 
 #define TESTPATH "/tmp/linux-test.tmp"
 #define TESTPORT 7654
diff --git a/tests/tcg/test-i386.c b/tests/tcg/test-i386.c
index 8e64bba..64d929e 100644
--- a/tests/tcg/test-i386.c
+++ b/tests/tcg/test-i386.c
@@ -17,6 +17,7 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 #define _GNU_SOURCE
+#include "compiler.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -1827,7 +1828,7 @@ void test_exceptions(void)
     printf("lock nop exception:\n");
     if (setjmp(jmp_env) == 0) {
         /* now execute an invalid instruction */
-        asm volatile("lock nop");
+        asm volatile(".byte 0xf0, 0x90"); /* lock nop */
     }
 
     printf("INT exception:\n");
diff --git a/tests/tcg/test_path.c b/tests/tcg/test_path.c
index 7265a94..a064eea 100644
--- a/tests/tcg/test_path.c
+++ b/tests/tcg/test_path.c
@@ -1,11 +1,12 @@
 /* Test path override code */
-#include "../config-host.h"
-#include "../qemu-malloc.c"
-#include "../cutils.c"
-#include "../path.c"
-#include "../trace.c"
+#define _GNU_SOURCE
+#include "config-host.h"
+#include "iov.c"
+#include "cutils.c"
+#include "path.c"
+#include "trace.c"
 #ifdef CONFIG_TRACE_SIMPLE
-#include "../simpletrace.c"
+#include "../trace/simple.c"
 #endif
 
 #include <stdarg.h>
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCHv4] tests/tcg: fix build
  2012-10-16 19:37     ` [Qemu-devel] [PATCHv4] " Catalin Patulea
@ 2012-10-16 19:54       ` Peter Maydell
  2012-10-16 19:57         ` Catalin Patulea
  2012-10-16 20:00         ` [Qemu-devel] [PATCHv5] " Catalin Patulea
  0 siblings, 2 replies; 31+ messages in thread
From: Peter Maydell @ 2012-10-16 19:54 UTC (permalink / raw)
  To: Catalin Patulea; +Cc: Anthony Liguori, qemu-devel, chenwj

On 16 October 2012 20:37, Catalin Patulea <catalinp@google.com> wrote:
> Fixes compile line for test-x86_64 target as well.
>
> ---
> This broke when the tests were moved from tests/ to tests/tcg/.
>
> On x86_64 host/i386-linux-user non-kvm guest, test-i386 and test-mmap are broken, but at least they build.
>
> To build/run the tests:
> $ cd $BUILD_PATH/tests/tcg
> $ SRC_PATH=path/to/qemu make <target>
> ---

This patch isn't in the right format to apply, I'm afraid.
Major problem:
 * missing signed-off-by line: we can't accept any patch
   without one
Minor problem:
 * the actual commit message is below the first '---' line,
   so 'git am' won't see it. Commit messages go above '---',
   "what I changed in this version' notes below.

'git format-patch' will produce things in the right format
(though you have to put the signed-off-by line in your commit
message yourself.)

thanks
-- PMM

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCHv4] tests/tcg: fix build
  2012-10-16 19:54       ` Peter Maydell
@ 2012-10-16 19:57         ` Catalin Patulea
  2012-10-16 20:09           ` Peter Maydell
  2012-10-16 20:00         ` [Qemu-devel] [PATCHv5] " Catalin Patulea
  1 sibling, 1 reply; 31+ messages in thread
From: Catalin Patulea @ 2012-10-16 19:57 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Anthony Liguori, qemu-devel, 陳韋任

On Tue, Oct 16, 2012 at 3:54 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> This patch isn't in the right format to apply, I'm afraid.
> Major problem:
>  * missing signed-off-by line: we can't accept any patch
>    without one
> Minor problem:
>  * the actual commit message is below the first '---' line,
>    so 'git am' won't see it. Commit messages go above '---',
>    "what I changed in this version' notes below.
I saw this format (notes, commit message, diffstat) on another list
and assumed git am could handle this properly.

It just seems strange to write the note somewhere *below* the commit
message - the notes should be the first thing people read, and below
them is the complete proposed patch. Is there any way to achieve that?

Meanwhile, I'll reformat and resend the patch.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [Qemu-devel] [PATCHv5] tests/tcg: fix build
  2012-10-16 19:54       ` Peter Maydell
  2012-10-16 19:57         ` Catalin Patulea
@ 2012-10-16 20:00         ` Catalin Patulea
  2012-10-16 20:11           ` Peter Maydell
  2012-10-19 19:30           ` Aurelien Jarno
  1 sibling, 2 replies; 31+ messages in thread
From: Catalin Patulea @ 2012-10-16 20:00 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Anthony Liguori, chenwj, Catalin Patulea

This broke when the tests were moved from tests/ to tests/tcg/.

On x86_64 host/i386-linux-user non-kvm guest, test-i386 and test-mmap are broken, but at least they build.

To build/run the tests:
$ cd $BUILD_PATH/tests/tcg
$ SRC_PATH=path/to/qemu make <target>

Signed-off-by: Catalin Patulea <catalinp@google.com>
---
This version adds Signed-off-by and should be compatible with git am.

 tests/tcg/Makefile     |   18 +++++++++++-------
 tests/tcg/linux-test.c |    2 ++
 tests/tcg/test-i386.c  |    3 ++-
 tests/tcg/test_path.c  |   13 +++++++------
 4 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/tests/tcg/Makefile b/tests/tcg/Makefile
index 15e36a2..80b1a4b 100644
--- a/tests/tcg/Makefile
+++ b/tests/tcg/Makefile
@@ -1,13 +1,13 @@
--include ../config-host.mak
+-include ../../config-host.mak
 -include $(SRC_PATH)/rules.mak
 
-$(call set-vpath, $(SRC_PATH)/tests)
+$(call set-vpath, $(SRC_PATH)/tests/tcg)
 
-QEMU=../i386-linux-user/qemu-i386
-QEMU_X86_64=../x86_64-linux-user/qemu-x86_64
+QEMU=../../i386-linux-user/qemu-i386
+QEMU_X86_64=../../x86_64-linux-user/qemu-x86_64
 CC_X86_64=$(CC_I386) -m64
 
-QEMU_INCLUDES += -I..
+QEMU_INCLUDES += -I../..
 CFLAGS=-Wall -O2 -g -fno-strict-aliasing
 #CFLAGS+=-msse2
 LDFLAGS=
@@ -36,6 +36,7 @@ TESTS += $(I386_TESTS)
 endif
 
 all: $(patsubst %,run-%,$(TESTS))
+test: all
 
 # rules to run tests
 
@@ -74,7 +75,10 @@ run-test_path: test_path
 # rules to compile tests
 
 test_path: test_path.o
+	$(CC_I386) $(LDFLAGS) -o $@ $^ $(LIBS)
+
 test_path.o: test_path.c
+	$(CC_I386) $(QEMU_INCLUDES) $(GLIB_CFLAGS) $(CFLAGS) -c -o $@ $^
 
 hello-i386: hello-i386.c
 	$(CC_I386) -nostdlib $(CFLAGS) -static $(LDFLAGS) -o $@ $<
@@ -86,12 +90,12 @@ testthread: testthread.c
 # i386/x86_64 emulation test (test various opcodes) */
 test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S \
            test-i386.h test-i386-shift.h test-i386-muldiv.h
-	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ \
+	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ \
               $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
 
 test-x86_64: test-i386.c \
            test-i386.h test-i386-shift.h test-i386-muldiv.h
-	$(CC_X86_64) $(CFLAGS) $(LDFLAGS) -o $@ $(<D)/test-i386.c -lm
+	$(CC_X86_64) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ $(<D)/test-i386.c -lm
 
 # generic Linux and CPU test
 linux-test: linux-test.c
diff --git a/tests/tcg/linux-test.c b/tests/tcg/linux-test.c
index 2e4a746..83cb32d 100644
--- a/tests/tcg/linux-test.c
+++ b/tests/tcg/linux-test.c
@@ -16,6 +16,7 @@
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
+#define _GNU_SOURCE
 #include <stdarg.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -38,6 +39,7 @@
 #include <dirent.h>
 #include <setjmp.h>
 #include <sys/shm.h>
+#include <sched.h>
 
 #define TESTPATH "/tmp/linux-test.tmp"
 #define TESTPORT 7654
diff --git a/tests/tcg/test-i386.c b/tests/tcg/test-i386.c
index 8e64bba..64d929e 100644
--- a/tests/tcg/test-i386.c
+++ b/tests/tcg/test-i386.c
@@ -17,6 +17,7 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 #define _GNU_SOURCE
+#include "compiler.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -1827,7 +1828,7 @@ void test_exceptions(void)
     printf("lock nop exception:\n");
     if (setjmp(jmp_env) == 0) {
         /* now execute an invalid instruction */
-        asm volatile("lock nop");
+        asm volatile(".byte 0xf0, 0x90"); /* lock nop */
     }
 
     printf("INT exception:\n");
diff --git a/tests/tcg/test_path.c b/tests/tcg/test_path.c
index 7265a94..a064eea 100644
--- a/tests/tcg/test_path.c
+++ b/tests/tcg/test_path.c
@@ -1,11 +1,12 @@
 /* Test path override code */
-#include "../config-host.h"
-#include "../qemu-malloc.c"
-#include "../cutils.c"
-#include "../path.c"
-#include "../trace.c"
+#define _GNU_SOURCE
+#include "config-host.h"
+#include "iov.c"
+#include "cutils.c"
+#include "path.c"
+#include "trace.c"
 #ifdef CONFIG_TRACE_SIMPLE
-#include "../simpletrace.c"
+#include "../trace/simple.c"
 #endif
 
 #include <stdarg.h>
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCHv4] tests/tcg: fix build
  2012-10-16 19:57         ` Catalin Patulea
@ 2012-10-16 20:09           ` Peter Maydell
  0 siblings, 0 replies; 31+ messages in thread
From: Peter Maydell @ 2012-10-16 20:09 UTC (permalink / raw)
  To: Catalin Patulea; +Cc: Anthony Liguori, qemu-devel, 陳韋任

On 16 October 2012 20:57, Catalin Patulea <catalinp@google.com> wrote:
> On Tue, Oct 16, 2012 at 3:54 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
>> This patch isn't in the right format to apply, I'm afraid.
>> Major problem:
>>  * missing signed-off-by line: we can't accept any patch
>>    without one
>> Minor problem:
>>  * the actual commit message is below the first '---' line,
>>    so 'git am' won't see it. Commit messages go above '---',
>>    "what I changed in this version' notes below.
> I saw this format (notes, commit message, diffstat) on another list
> and assumed git am could handle this properly.
>
> It just seems strange to write the note somewhere *below* the commit
> message - the notes should be the first thing people read, and below
> them is the complete proposed patch. Is there any way to achieve that?

I think there may be options that permit that, but the default 'git am'
doesn't. Since people usually just 'git am' patch mails, we've had
the odd case before where the commit message has got mangled because
the email was in the wrong order.

A lot of this is basically community convention, so it differs
from project to project; this is just how qemu-devel does things.

Personally I like the "commit message first" bit -- that's the important
part that will stay around in git and needs to be a self-contained
description. The below the '---' notes are more like footnotes :-)

> Meanwhile, I'll reformat and resend the patch.

Thanks!

-- PMM

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCHv5] tests/tcg: fix build
  2012-10-16 20:00         ` [Qemu-devel] [PATCHv5] " Catalin Patulea
@ 2012-10-16 20:11           ` Peter Maydell
  2012-10-19 19:30           ` Aurelien Jarno
  1 sibling, 0 replies; 31+ messages in thread
From: Peter Maydell @ 2012-10-16 20:11 UTC (permalink / raw)
  To: Catalin Patulea; +Cc: Anthony Liguori, qemu-devel, chenwj

On 16 October 2012 21:00, Catalin Patulea <catalinp@google.com> wrote:
> This broke when the tests were moved from tests/ to tests/tcg/.
>
> On x86_64 host/i386-linux-user non-kvm guest, test-i386 and test-mmap are broken, but at least they build.
>
> To build/run the tests:
> $ cd $BUILD_PATH/tests/tcg
> $ SRC_PATH=path/to/qemu make <target>
>
> Signed-off-by: Catalin Patulea <catalinp@google.com>

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

-- PMM

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [Qemu-devel] [PATCHv5] tests/tcg: fix build
  2012-10-16 20:00         ` [Qemu-devel] [PATCHv5] " Catalin Patulea
  2012-10-16 20:11           ` Peter Maydell
@ 2012-10-19 19:30           ` Aurelien Jarno
  1 sibling, 0 replies; 31+ messages in thread
From: Aurelien Jarno @ 2012-10-19 19:30 UTC (permalink / raw)
  To: Catalin Patulea; +Cc: Peter Maydell, Anthony Liguori, qemu-devel, chenwj

On Tue, Oct 16, 2012 at 04:00:23PM -0400, Catalin Patulea wrote:
> This broke when the tests were moved from tests/ to tests/tcg/.
> 
> On x86_64 host/i386-linux-user non-kvm guest, test-i386 and test-mmap are broken, but at least they build.
> 
> To build/run the tests:
> $ cd $BUILD_PATH/tests/tcg
> $ SRC_PATH=path/to/qemu make <target>
> 
> Signed-off-by: Catalin Patulea <catalinp@google.com>
> ---
> This version adds Signed-off-by and should be compatible with git am.
> 
>  tests/tcg/Makefile     |   18 +++++++++++-------
>  tests/tcg/linux-test.c |    2 ++
>  tests/tcg/test-i386.c  |    3 ++-
>  tests/tcg/test_path.c  |   13 +++++++------
>  4 files changed, 22 insertions(+), 14 deletions(-)
> 
> diff --git a/tests/tcg/Makefile b/tests/tcg/Makefile
> index 15e36a2..80b1a4b 100644
> --- a/tests/tcg/Makefile
> +++ b/tests/tcg/Makefile
> @@ -1,13 +1,13 @@
> --include ../config-host.mak
> +-include ../../config-host.mak
>  -include $(SRC_PATH)/rules.mak
>  
> -$(call set-vpath, $(SRC_PATH)/tests)
> +$(call set-vpath, $(SRC_PATH)/tests/tcg)
>  
> -QEMU=../i386-linux-user/qemu-i386
> -QEMU_X86_64=../x86_64-linux-user/qemu-x86_64
> +QEMU=../../i386-linux-user/qemu-i386
> +QEMU_X86_64=../../x86_64-linux-user/qemu-x86_64
>  CC_X86_64=$(CC_I386) -m64
>  
> -QEMU_INCLUDES += -I..
> +QEMU_INCLUDES += -I../..
>  CFLAGS=-Wall -O2 -g -fno-strict-aliasing
>  #CFLAGS+=-msse2
>  LDFLAGS=
> @@ -36,6 +36,7 @@ TESTS += $(I386_TESTS)
>  endif
>  
>  all: $(patsubst %,run-%,$(TESTS))
> +test: all
>  
>  # rules to run tests
>  
> @@ -74,7 +75,10 @@ run-test_path: test_path
>  # rules to compile tests
>  
>  test_path: test_path.o
> +	$(CC_I386) $(LDFLAGS) -o $@ $^ $(LIBS)
> +
>  test_path.o: test_path.c
> +	$(CC_I386) $(QEMU_INCLUDES) $(GLIB_CFLAGS) $(CFLAGS) -c -o $@ $^
>  
>  hello-i386: hello-i386.c
>  	$(CC_I386) -nostdlib $(CFLAGS) -static $(LDFLAGS) -o $@ $<
> @@ -86,12 +90,12 @@ testthread: testthread.c
>  # i386/x86_64 emulation test (test various opcodes) */
>  test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S \
>             test-i386.h test-i386-shift.h test-i386-muldiv.h
> -	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ \
> +	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ \
>                $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
>  
>  test-x86_64: test-i386.c \
>             test-i386.h test-i386-shift.h test-i386-muldiv.h
> -	$(CC_X86_64) $(CFLAGS) $(LDFLAGS) -o $@ $(<D)/test-i386.c -lm
> +	$(CC_X86_64) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ $(<D)/test-i386.c -lm
>  
>  # generic Linux and CPU test
>  linux-test: linux-test.c
> diff --git a/tests/tcg/linux-test.c b/tests/tcg/linux-test.c
> index 2e4a746..83cb32d 100644
> --- a/tests/tcg/linux-test.c
> +++ b/tests/tcg/linux-test.c
> @@ -16,6 +16,7 @@
>   *  You should have received a copy of the GNU General Public License
>   *  along with this program; if not, see <http://www.gnu.org/licenses/>.
>   */
> +#define _GNU_SOURCE
>  #include <stdarg.h>
>  #include <stdlib.h>
>  #include <stdio.h>
> @@ -38,6 +39,7 @@
>  #include <dirent.h>
>  #include <setjmp.h>
>  #include <sys/shm.h>
> +#include <sched.h>
>  
>  #define TESTPATH "/tmp/linux-test.tmp"
>  #define TESTPORT 7654
> diff --git a/tests/tcg/test-i386.c b/tests/tcg/test-i386.c
> index 8e64bba..64d929e 100644
> --- a/tests/tcg/test-i386.c
> +++ b/tests/tcg/test-i386.c
> @@ -17,6 +17,7 @@
>   *  along with this program; if not, see <http://www.gnu.org/licenses/>.
>   */
>  #define _GNU_SOURCE
> +#include "compiler.h"
>  #include <stdlib.h>
>  #include <stdio.h>
>  #include <string.h>
> @@ -1827,7 +1828,7 @@ void test_exceptions(void)
>      printf("lock nop exception:\n");
>      if (setjmp(jmp_env) == 0) {
>          /* now execute an invalid instruction */
> -        asm volatile("lock nop");
> +        asm volatile(".byte 0xf0, 0x90"); /* lock nop */
>      }
>  
>      printf("INT exception:\n");
> diff --git a/tests/tcg/test_path.c b/tests/tcg/test_path.c
> index 7265a94..a064eea 100644
> --- a/tests/tcg/test_path.c
> +++ b/tests/tcg/test_path.c
> @@ -1,11 +1,12 @@
>  /* Test path override code */
> -#include "../config-host.h"
> -#include "../qemu-malloc.c"
> -#include "../cutils.c"
> -#include "../path.c"
> -#include "../trace.c"
> +#define _GNU_SOURCE
> +#include "config-host.h"
> +#include "iov.c"
> +#include "cutils.c"
> +#include "path.c"
> +#include "trace.c"
>  #ifdef CONFIG_TRACE_SIMPLE
> -#include "../simpletrace.c"
> +#include "../trace/simple.c"
>  #endif
>  
>  #include <stdarg.h>
> -- 
> 1.7.7.3
> 

Thanks, applied.

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2012-10-19 19:30 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <Message-ID: <CAFEAcA9=OY0VMzTbvjigDdOMt_4JoJeRds4_t9hni1Zq4ir9EA@mail.gmail.com>
2012-10-16  6:53 ` [Qemu-devel] [PATCHv3] tests/tcg: fix build Catalin Patulea
2012-10-16 12:50   ` Peter Maydell
2012-10-16 18:09     ` Catalin Patulea
2012-10-16 18:47       ` Peter Maydell
2012-10-16 19:34         ` Catalin Patulea
2012-10-16 19:37     ` [Qemu-devel] [PATCHv4] " Catalin Patulea
2012-10-16 19:54       ` Peter Maydell
2012-10-16 19:57         ` Catalin Patulea
2012-10-16 20:09           ` Peter Maydell
2012-10-16 20:00         ` [Qemu-devel] [PATCHv5] " Catalin Patulea
2012-10-16 20:11           ` Peter Maydell
2012-10-19 19:30           ` Aurelien Jarno
2012-07-13  6:55 [Qemu-devel] [PATCH] Get tests/tcg building, fix unused variable warning due to wrong extended asm operand, fix the 'test' make target Catalin Patulea
2012-07-13  8:44 ` 陳韋任 (Wei-Ren Chen)
2012-07-16 18:17   ` Catalin Patulea
2012-07-16 19:08 ` Peter Maydell
2012-07-16 20:00   ` Catalin Patulea
2012-07-16 20:11     ` [Qemu-devel] [PATCH v2] Get tests/tcg building and fix an unused variable warning due to wrong extended asm operands Catalin Patulea
2012-07-16 21:19       ` Peter Maydell
2012-07-17  2:24         ` [Qemu-devel] [PATCH] tests/tcg: add test-i386-fprem and make target for comparing QEMU to h/w Catalin Patulea
2012-07-17  2:33           ` Catalin Patulea
2012-07-17 12:23           ` Peter Maydell
2012-07-17 14:49             ` Catalin Patulea
2012-07-20 22:48               ` Catalin Patulea
2012-07-21  9:03                 ` Peter Maydell
2012-07-25 17:06                   ` [Qemu-devel] [PATCH v2] " Catalin Patulea
2012-07-28  9:21                     ` Blue Swirl
2012-07-20 23:23         ` [Qemu-devel] [PATCH v2] Get tests/tcg building and fix an unused variable warning due to wrong extended asm operands Catalin Patulea
2012-07-21  9:05           ` Peter Maydell
2012-07-16 21:11     ` [Qemu-devel] [PATCH] Get tests/tcg building, fix unused variable warning due to wrong extended asm operand, fix the 'test' make target Peter Maydell
2012-07-16 21:23       ` Catalin Patulea

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.