diff options
author | tom <tom@a5019735-40e9-0310-863c-91ae7b9d1cf9> | 2011-08-12 15:43:31 +0000 |
---|---|---|
committer | tom <tom@a5019735-40e9-0310-863c-91ae7b9d1cf9> | 2011-08-12 15:43:31 +0000 |
commit | ce83509251bd1412552915f5d642a2ec503a5810 (patch) | |
tree | c3b7cbf2826fb603cf0eb49af43567672816d4ed /none | |
parent | 7aac06f9f033cc61aba2a62f68278a977765ff5a (diff) |
Add test for address size override prefixes for REP prefixed string
instructions on amd64. Fixes remaining issues from #211371.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11969 a5019735-40e9-0310-863c-91ae7b9d1cf9
Diffstat (limited to 'none')
-rw-r--r-- | none/tests/amd64/Makefile.am | 2 | ||||
-rw-r--r-- | none/tests/amd64/asorep.c | 77 | ||||
-rw-r--r-- | none/tests/amd64/asorep.stderr.exp | 2 | ||||
-rw-r--r-- | none/tests/amd64/asorep.stdout.exp | 0 | ||||
-rw-r--r-- | none/tests/amd64/asorep.vgtest | 1 |
5 files changed, 82 insertions, 0 deletions
diff --git a/none/tests/amd64/Makefile.am b/none/tests/amd64/Makefile.am index 215cc3f7..5f1b08e8 100644 --- a/none/tests/amd64/Makefile.am +++ b/none/tests/amd64/Makefile.am @@ -22,6 +22,7 @@ endif EXTRA_DIST = \ amd64locked.vgtest amd64locked.stdout.exp amd64locked.stderr.exp \ + asorep.stderr.exp asorep.stdout.exp asorep.vgtest \ bug127521-64.vgtest bug127521-64.stdout.exp bug127521-64.stderr.exp \ bug132813-amd64.vgtest bug132813-amd64.stdout.exp \ bug132813-amd64.stderr.exp \ @@ -66,6 +67,7 @@ EXTRA_DIST = \ check_PROGRAMS = \ amd64locked \ + asorep \ bug127521-64 bug132813-amd64 bug132918 \ clc \ cmpxchg \ diff --git a/none/tests/amd64/asorep.c b/none/tests/amd64/asorep.c new file mode 100644 index 00000000..e6af8cea --- /dev/null +++ b/none/tests/amd64/asorep.c @@ -0,0 +1,77 @@ +#include <stdint.h> +#include <string.h> +#include <stdio.h> + +char buf1[64], buf2[64]; + +int +main (void) +{ + unsigned long rdi, rsi, rcx, rax; + uintptr_t b1 = (uintptr_t) buf1, b2 = (uintptr_t) buf2; + + if (b1 > 0xffffffffULL || b2 > 0xffffffffULL) + return 0; + + b1 += 0x100000000ULL; + b2 += 0xfff00000000ULL; + memcpy (buf1, "abcde", 4); + asm volatile ("addr32 rep movsb" + : "=D" (rdi), "=S" (rsi), "=c" (rcx) + : "D" (b2), "S" (b1), "c" (0x100000004ULL) + : "memory"); + if (memcmp (buf2, "abcd", 5) != 0 + || rdi != (uintptr_t) buf2 + 4 + || rsi != (uintptr_t) buf1 + 4 + || rcx) + fprintf (stderr, "addr32 rep movsb wrong\n"); + + rax = 0x751234560000ULL + (' ' << 8) + '0'; + asm volatile ("addr32 rep stosw" + : "=D" (rdi), "=c" (rcx), "+a" (rax) + : "D" (b2), "c" (0x100000003ULL) + : "memory"); + if (memcmp (buf2, "0 0 0 ", 7) != 0 + || rdi != (uintptr_t) buf2 + 6 + || rcx + || rax != 0x751234560000ULL + (' ' << 8) + '0') + fprintf (stderr, "addr32 rep stosw wrong\n"); + + asm volatile ("addr32 lodsl" + : "=S" (rsi), "=a" (rax) + : "S" (b2), "a" (2ULL)); + if (rsi != (uintptr_t) buf2 + 4 + || rax != 0x20302030ULL) + fprintf (stderr, "addr32 lodsl wrong\n"); + + memcpy (buf1, "abcdefghijklmno", 16); + memcpy (buf2, "abcdefghijklmnO", 16); + asm volatile ("addr32 repe cmpsb" + : "=D" (rdi), "=S" (rsi), "=c" (rcx) + : "D" (b2), "S" (b1), "c" (0x100000020ULL)); + if (rdi != (uintptr_t) buf2 + 15 + || rsi != (uintptr_t) buf1 + 15 + || rcx != 17ULL) + fprintf (stderr, "addr32 repe cmpsb wrong\n"); + + memcpy (buf2, "ababababababababcdab", 20); + rax = 0x123450000ULL + ('d' << 8) + 'c'; + asm volatile ("addr32 repne scasw" + : "=D" (rdi), "=c" (rcx), "+a" (rax) + : "D" (b2), "c" (0x100000020ULL)); + if (rdi != (uintptr_t) buf2 + 18 + || rcx != 23ULL + || rax != 0x123450000ULL + ('d' << 8) + 'c') + fprintf (stderr, "addr32 repne scasw wrong\n"); + + rax = 0x543210000ULL + ('b' << 8) + 'a'; + asm volatile ("addr32 repe scasw" + : "=D" (rdi), "=c" (rcx), "+a" (rax) + : "D" (b2), "c" (0x100000020ULL)); + if (rdi != (uintptr_t) buf2 + 18 + || rcx != 23ULL + || rax != 0x543210000ULL + ('b' << 8) + 'a') + fprintf (stderr, "addr32 repe scasw wrong\n"); + + return 0; +} diff --git a/none/tests/amd64/asorep.stderr.exp b/none/tests/amd64/asorep.stderr.exp new file mode 100644 index 00000000..139597f9 --- /dev/null +++ b/none/tests/amd64/asorep.stderr.exp @@ -0,0 +1,2 @@ + + diff --git a/none/tests/amd64/asorep.stdout.exp b/none/tests/amd64/asorep.stdout.exp new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/none/tests/amd64/asorep.stdout.exp diff --git a/none/tests/amd64/asorep.vgtest b/none/tests/amd64/asorep.vgtest new file mode 100644 index 00000000..71f3d9d1 --- /dev/null +++ b/none/tests/amd64/asorep.vgtest @@ -0,0 +1 @@ +prog: asorep |