From patchwork Tue Dec 7 22:12:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noah Goldstein X-Patchwork-Id: 1564934 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=sDX4RoOK; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J7vhK38v0z9sR4 for ; Wed, 8 Dec 2021 09:13:37 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 716283858037 for ; Tue, 7 Dec 2021 22:13:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 716283858037 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1638915214; bh=5iYn4e0WdQszoQL6ZGL1/ZwCOYm1lj1emP2bvmfuq0I=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=sDX4RoOKDm28oyFdqlz43Y1+lsb4tBphd6FjHty/zyde1A5ACIEfnlUczvpeXWoDH BAN7OIGbN8AXNgwuwVlL0OPbQbsgzPe8wMAPUUYdDkpJt6KyEvpA2N6oZo5UlC2rc8 NsWVA3H/ICW0MpaY/ZSlO87NF9Wzv2rB6y6oU0/8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by sourceware.org (Postfix) with ESMTPS id DBD063858027 for ; Tue, 7 Dec 2021 22:13:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DBD063858027 Received: by mail-il1-x129.google.com with SMTP id t8so455950ilu.8 for ; Tue, 07 Dec 2021 14:13:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5iYn4e0WdQszoQL6ZGL1/ZwCOYm1lj1emP2bvmfuq0I=; b=dJriA2gSON/8NqMoMBAj6J5AgViggGgi/WD4AAf/OqCr7azl0/nupDxEmeUTvif4rv 70ifCT7QYCmbAtW6Hb3DLKkmS0Jfd9ORkdy0x6FeQ0HdIx839Gd2AD3lonaaKoVCqbs3 uXKAISyNS9RJs6gMm85IUOb6jiq34F8FdBsuawVjNvn//tGvqGElx8QN593d6m8tFuUf ZgWCrwBUVN8yntSgjf7liq8elVdWX6GzUw59mAJBRG62e+m4MsZQH5HIiboB/0qFoFiN T+sNW8I/ra+Dwip1M52t9fayWIxYfx3ai4rBUKAB3i3KrxM7rvnkIRsFuUUIkUEhyelj GaDQ== X-Gm-Message-State: AOAM5336p9ua7af3Ft1v7S/SMlTxUuvCulsdxG6GHaJ3Enp29uomVGOc VGd8z/J7LDnUdXBgB4IdJPH9gJqQg4Y= X-Google-Smtp-Source: ABdhPJwF3korvBlBtQY6Hqnz1tQEos2OKOph4Xsrt0oBhQh+0XCibd6QcpIeYEg6P4aF0k8NLv4iNg== X-Received: by 2002:a05:6e02:b2f:: with SMTP id e15mr2394865ilu.227.1638915199983; Tue, 07 Dec 2021 14:13:19 -0800 (PST) Received: from localhost.localdomain (node-17-161.flex.volo.net. [76.191.17.161]) by smtp.googlemail.com with ESMTPSA id c7sm630437iob.28.2021.12.07.14.13.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Dec 2021 14:13:19 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v1] String: test-memcpy used unaligned types for buffers [BZ 28572] Date: Tue, 7 Dec 2021 16:12:42 -0600 Message-Id: <20211207221241.3039518-1-goldstein.w.n@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Noah Goldstein via Libc-alpha From: Noah Goldstein Reply-To: Noah Goldstein Cc: John David Anglin Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" From: John David Anglin commit d585ba47fcda99fdf228e3e45a01b11a15efbc5a Author: Noah Goldstein Date: Mon Nov 1 00:49:48 2021 -0500 string: Make tests birdirectional test-memcpy.c Add tests that had src/dst non 4-byte aligned. Since src/dst are initialized/compared as uint32_t type which is 4-byte aligned this can break on some targets. Fix the issue by specifying a new non-aligned 4-byte `unaligned_uint32_t` for src/dst. Another alternative is to rely on memcpy/memcmp for initializing/testing src/dst. Using memcpy for initializing in memcpy tests, however, could lead to future bugs. Reviewed-by: Noah Goldstein Reviewed-by: H.J. Lu --- string/test-memcpy-support.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/string/test-memcpy-support.h b/string/test-memcpy-support.h index 419158a420..b6cc434905 100644 --- a/string/test-memcpy-support.h +++ b/string/test-memcpy-support.h @@ -51,6 +51,7 @@ builtin_memcpy (char *dst, const char *src, size_t n) } #endif typedef char *(*proto_t) (char *, const char *, size_t); +typedef uint32_t __attribute__ ((may_alias, aligned (1))) unaligned_uint32_t; static void do_one_test (impl_t *impl, char *dst, const char *src, size_t len) @@ -134,8 +135,8 @@ do_test1 (size_t align1, size_t align2, size_t size) error (EXIT_FAILURE, errno, "mprotect failed"); size_t array_size = size / sizeof (uint32_t); - uint32_t *dest = large_buf + align1; - uint32_t *src = large_buf + region_size + 2 * page_size + align2; + unaligned_uint32_t *dest = large_buf + align1; + unaligned_uint32_t *src = large_buf + region_size + 2 * page_size + align2; size_t i; size_t repeats; for (repeats = 0; repeats < 2; repeats++)