From patchwork Tue May 22 16:33:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 27401 Received: (qmail 74842 invoked by alias); 22 May 2018 16:33:06 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 74791 invoked by uid 89); 22 May 2018 16:33:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-oi0-f68.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=o1t69Qd5tVGWeETI+8SU9vSXWq8QJ+N1/fP0kOQQHrk=; b=OrcyhCNdc+oqBYySNrrYCyQsO2GFRMI7rSYjsyzYMDnfE04MDkpiO3Fejevd0u5d8b ocO5/rCsw2tghRa9dy3rMj/iJkYQ5BdSlFvZ7hx7XLgheNy5UthvSyRv30ONAJU3WbGS lsTAxMQf/IhIrqoGVM5/UzgikRuF3VIzEBqnZEuDAviGJrxAn2SPy0zIKzIglWOep4eD qc5rX9MvvRW0VVIvaT+GA0+rG+TAyHNCdwVnUNGjop4+os9nKUmbD/AmDiyrxlD0foqg +IGngF/GDR6jSZo/zBeBtFrGVQuVmmXbtdpagQ3WktWoSuL05/Ut7QTC8KzmZus2a5rL GB1g== X-Gm-Message-State: ALKqPwcTYCnAlwi0igMEx800Bk7JtalEQbpBqQRwbM60bK7TbQwD6BBU rHnkMkvGp73ZtANMEPLU3TDJL4sC/dU4kOVF3xs= X-Google-Smtp-Source: AB8JxZq6W8UgMEsjY7GSvgHuNrERUf3m1eOzutiHhvFs6jXvUh/wsiJEH51srHsMjp8TfGQEYrzkNm30R7JBiRIyDXA= X-Received: by 2002:aca:2ec3:: with SMTP id u186-v6mr15087766oiu.104.1527006782357; Tue, 22 May 2018 09:33:02 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <3e10ac72-b5a3-f74c-45da-29d8fde75ac7@redhat.com> <0d694123-e9f9-9d4d-6ad0-71a6ff0fd44a@redhat.com> <7074c0e3-dfda-f527-baad-bd1734b496d3@redhat.com> <8cbc0054-edc3-b5bf-c6be-575a68eb9c6f@redhat.com> From: "H.J. Lu" Date: Tue, 22 May 2018 09:33:01 -0700 Message-ID: Subject: Re: [PATCH] Don't write beyond destination in __mempcpy_avx512_no_vzeroupper (bug 23196) To: Andreas Schwab Cc: Florian Weimer , Andrew Senkevich , GNU C Library On Tue, May 22, 2018 at 8:38 AM, Andreas Schwab wrote: > On Mai 22 2018, Florian Weimer wrote: > >> On 05/22/2018 05:06 PM, Andreas Schwab wrote: >>> On Mai 22 2018, Florian Weimer wrote: >>> >>>> And with the original reproducer, we wouldn't hit preloop_large, where the >>>> bug is. >>> Worksforme. >>> >>> $ string/test-mempcpy >> >> I don't doubt that. Our CPUs probably have different cache sizes, > > Same cache size. Here is the testcase. Since both memcpy and memcpy share the the same body of code, we can't use RAX to refer the beginning of destination. Please update your patch with this info together this tesrcase. Thanks. From d37944f542ff772b66634e6436865473b4f7b2fe Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 22 May 2018 09:14:37 -0700 Subject: [PATCH] Add a test case for BZ #23196 --- string/test-memcpy.c | 47 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/string/test-memcpy.c b/string/test-memcpy.c index 45f20a6d80..3c8066da52 100644 --- a/string/test-memcpy.c +++ b/string/test-memcpy.c @@ -212,6 +212,50 @@ do_random_tests (void) } } +static void +do_test1 (void) +{ + size_t size = 0x100000; + void *large_buf; + + large_buf = mmap (NULL, size * 2 + page_size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANON, -1, 0); + if (large_buf == MAP_FAILED) + { + puts ("Failed to allocat large_buf, skipping do_test1"); + return; + } + + if (mprotect (large_buf + size, page_size, PROT_NONE)) + error (EXIT_FAILURE, errno, "mprotect failed"); + + size_t arrary_size = size / sizeof (uint32_t); + uint32_t *dest = large_buf; + uint32_t *src = large_buf + size + page_size; + size_t i; + + for (i = 0; i < arrary_size; i++) + src[i] = (uint32_t) i; + + FOR_EACH_IMPL (impl, 0) + { + memset (dest, -1, size); + CALL (impl, (char *) dest, (char *) src, size); + for (i = 0; i < arrary_size; i++) + if (dest[i] != src[i]) + { + error (0, 0, + "Wrong result in function %s dst \"%p\" src \"%p\" offset \"%zd\"", + impl->name, dest, src, i); + ret = 1; + break; + } + } + + munmap ((void *) dest, size); + munmap ((void *) src, size); +} + int test_main (void) { @@ -253,6 +297,9 @@ test_main (void) do_test (0, 0, getpagesize ()); do_random_tests (); + + do_test1 (); + return ret; } -- 2.17.0