From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 89040 invoked by alias); 19 Mar 2018 19:38:39 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 89026 invoked by uid 89); 19 Mar 2018 19:38:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.1 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-ot0-f173.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=t0YJfJqQgVn8+sKoxV3sIVo8JZDVuyylS2eARsyC+Ng=; b=dlDW/CNDqgZZbo1OBDSq1c31UfI9aSTiG6+xpWCj3IXWSQxHqsvq8ZdtSMgW/72ydw +Y5C22b7ibu/6AsVuhxKh20qwiOLjbdbKRTIZtM5tmZjEiMEh18DXFf7t4WdNtntn/0S L+W7F0ndmus8SZzfB4ePbf1eLqzVamtVE/EMxC1vYVekX9ojI46+B6NrLlEysA0GAkN5 DTKZX2y9NLsaKnwSXQG/8ZxOupW6O2rNcAVgEkbFpSkduB0E5AxlAqhdHsqx7Zba4hSG dzoRmTYKNOjCnOB3PW9AvXdQZQw5zSMyTFpvUo/x/k2GtdGQLWeG3r3M3Wd+NrBATYqe zsOg== X-Gm-Message-State: AElRT7GPSPRbN5u36H6tTZ7vw2TNloqbEOp4Ax1k7WlVjfBEksEHrB8T LYs/cc48wp5RX/3gpi9KmC1Lp5HL6fMI1jpnEfQ= X-Google-Smtp-Source: AG47ELtinY6gdB/V2PkeqSrQMmd7qZK41Cbh30D0YEIw6c2272v2NLzzudZRawBR7vSW+wZ5ZX3HGEZYjJQXlmtO2gk= X-Received: by 2002:a9d:148e:: with SMTP id d14-v6mr8018496ote.204.1521488315898; Mon, 19 Mar 2018 12:38:35 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <597954a1-85da-e524-1454-27c46af57413@redhat.com> <8c8ab285-bddc-90e6-a50e-7be89703367a@redhat.com> From: "H.J. Lu" Date: Mon, 19 Mar 2018 19:38:00 -0000 Message-ID: Subject: Re: [PATCH] Fix i386 memmove issue [BZ #22644] To: Andrew Senkevich Cc: Florian Weimer , Szabolcs Nagy , Andreas Schwab , nd , libc-alpha , Max Horn , thomas@grindinggear.com Content-Type: text/plain; charset="UTF-8" X-SW-Source: 2018-03/txt/msg00477.txt.bz2 On Mon, Mar 19, 2018 at 12:29 PM, Andrew Senkevich wrote: > 2018-03-19 18:57 GMT+01:00 H.J. Lu : >> On Mon, Mar 19, 2018 at 10:52 AM, Andrew Senkevich >> wrote: >>> 2018-03-19 16:33 GMT+01:00 Florian Weimer : >>>> 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 >>> >>> 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) >> >> Don't you need to test if address is too low such that >> 0x80000000 - (uintptr_t)large_buf > 0x20000000? > > Indeed, thanks. Updated below. > > diff --git a/string/test-memmove.c b/string/test-memmove.c > index edc7a4c..9f1437d 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 > > char *simple_memmove (char *, const char *, size_t); > > @@ -245,6 +246,60 @@ 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 > + || 0x80000000 - (uintptr_t)large_buf > 0x20000000) > + { > + error (0, 0,"Large mmap allocated improperly"); > + ret = EXIT_UNSUPPORTED; > + munmap((void *)large_buf, size); > + return; > + } > + > + size_t bytes_move = 0x80000000 - (uintptr_t)large_buf; > + size_t arr_size = bytes_move / sizeof(uint32_t); > + size_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 +339,9 @@ test_main (void) > } > > do_random_tests (); > + > + do_test2 (); > + > return ret; > } > > Look good. Please submit the updated patch with the proper commit message. -- H.J.