This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Fix i386 memmove issue [BZ #22644]
- From: Andrew Senkevich <andrew dot n dot senkevich at gmail dot com>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: Szabolcs Nagy <szabolcs dot nagy at arm dot com>, Andreas Schwab <schwab at suse dot de>, nd at arm dot com, "H.J. Lu" <hjl dot tools at gmail dot com>, libc-alpha <libc-alpha at sourceware dot org>, Max Horn <max at quendi dot de>, thomas at grindinggear dot com
- Date: Mon, 19 Mar 2018 18:52:00 +0100
- Subject: Re: [PATCH] Fix i386 memmove issue [BZ #22644]
- References: <CAMXFM3s5b2a6o_CMS0cJ35oE3SuJUHssqLAUY94LSZhEEtG71A@mail.gmail.com> <mvm606ts2w6.fsf@suse.de> <CAMXFM3vqw7eiUT1XYVZWyW=eJkgEpjNc74A8mbmdKuR_hywN3w@mail.gmail.com> <CAMe9rOo4Ys=ScEKKnuv5XvYqTHjvFxSkXjch8ya8sX7dfP+q4Q@mail.gmail.com> <CAMXFM3vA=-LSK5VtKhhbs0g9faBdG0GjoAbNb6OPEbSt8dAA7A@mail.gmail.com> <mvmlgeojjmi.fsf@suse.de> <597954a1-85da-e524-1454-27c46af57413@redhat.com> <e7d81f18-315c-4434-a734-41029c0d387f@arm.com> <8c8ab285-bddc-90e6-a50e-7be89703367a@redhat.com>
2018-03-19 16:33 GMT+01:00 Florian Weimer <fweimer@redhat.com>:
> On 03/19/2018 03:25 PM, Szabolcs Nagy wrote:
>>
>> i thought not using MAP_FIXED is the 'non-overriding MAP_FIXED variant'
Hmm, I tried so and had got much bigger address. But now I see it
works (with size just 0x20000000 and 0x70000000 as a hint) in both 64
and 32 bit cases, so proposing the following:
diff --git a/string/test-memmove.c b/string/test-memmove.c
index edc7a4c..fa4037d 100644
--- a/string/test-memmove.c
+++ b/string/test-memmove.c
@@ -24,6 +24,7 @@
# define TEST_NAME "memmove"
#endif
#include "test-string.h"
+#include <support/test-driver.h>
char *simple_memmove (char *, const char *, size_t);
@@ -245,6 +246,59 @@ do_random_tests (void)
}
}
+static void
+do_test2 (void)
+{
+ size_t size = 0x20000000;
+ uint32_t * large_buf;
+
+ large_buf = mmap ((void*)0x70000000, size, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANON, -1, 0);
+
+ if (large_buf == MAP_FAILED)
+ error (EXIT_UNSUPPORTED, errno, "Large mmap failed");
+
+ if ((uintptr_t)large_buf > 0x80000000 - 128)
+ {
+ error (0, 0,"Large mmap doesn't cross 0x80000000 boundary");
+ ret = EXIT_UNSUPPORTED;
+ munmap((void *)large_buf, size);
+ return;
+ }
+
+ uint32_t bytes_move = 0x80000000 - (uintptr_t)large_buf;
+ uint32_t arr_size = bytes_move / sizeof(uint32_t);
+ uint32_t i;
+
+ FOR_EACH_IMPL (impl, 0)
+ {
+ for (i = 0; i < arr_size; i++)
+ large_buf[i] = i;
+
+ uint32_t * dst = &large_buf[33];
+
+#ifdef TEST_BCOPY
+ CALL (impl, (char *)large_buf, (char *)dst, bytes_move);
+#else
+ CALL (impl, (char *)dst, (char *)large_buf, bytes_move);
+#endif
+
+ for (i = 0; i < arr_size; i++)
+ {
+ if (dst[i] != i)
+ {
+ error (0, 0,
+ "Wrong result in function %s dst \"%p\" src \"%p\" offset \"%d\"",
+ impl->name, dst, large_buf, i);
+ ret = 1;
+ break;
+ }
+ }
+ }
+
+ munmap((void *)large_buf, size);
+}
+
int
test_main (void)
{
@@ -284,6 +338,9 @@ test_main (void)
}
do_random_tests ();
+
+ do_test2 ();
+
return ret;
}
Ok?
--
WBR,
Andrew