From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0A3BC4743C for ; Wed, 23 Jun 2021 09:48:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F4FE61164 for ; Wed, 23 Jun 2021 09:48:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230291AbhFWJu4 (ORCPT ); Wed, 23 Jun 2021 05:50:56 -0400 Received: from mailgate.ics.forth.gr ([139.91.1.2]:16257 "EHLO mailgate.ics.forth.gr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230083AbhFWJuz (ORCPT ); Wed, 23 Jun 2021 05:50:55 -0400 Received: from av3.ics.forth.gr (av3in.ics.forth.gr [139.91.1.77]) by mailgate.ics.forth.gr (8.15.2/ICS-FORTH/V10-1.8-GATE) with ESMTP id 15N9magR089297 for ; Wed, 23 Jun 2021 12:48:36 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; d=ics.forth.gr; s=av; c=relaxed/simple; q=dns/txt; i=@ics.forth.gr; t=1624441711; x=1627033711; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=MISFftgg2hIKWcEtfdZHWCPZ3XpVUN6O8IsMWxh6AwY=; b=b/R6w9sFXlUiHNOh4jO8lZEfd0LyYx5EYOhxNLwH25n/oaVEJ6HxNyNzIm8IjZ5B d22Gw5m5dGemQDvC9folwTeWWlsdmdDIvGkpi3uVMtriocxYSohf3QJbUMd5gfT4 rOP3w94LSTCaysDW0hx01zTbwlCdy66KGLfkyhaFK9qD2jpXo4g2y2utO3aZ2MkA MkRAHU07YP4ergQpl+7bxXTOiWOGZpcIWmTpBjgohV8DlvLQ8aTwuq6BezvSGkHc oPbWsoB5avF/211Yk9sTTPmIUz/4An0Ck22fAwV7dIoRjBNTcRsqj+IYgGbP5z4a UUU+GvulJgoH0/bCNQnTPw==; X-AuditID: 8b5b014d-96ef2700000067b6-fe-60d3036faf83 Received: from enigma.ics.forth.gr (enigma.ics.forth.gr [139.91.151.35]) by av3.ics.forth.gr (Symantec Messaging Gateway) with SMTP id 34.3E.26550.F6303D06; Wed, 23 Jun 2021 12:48:31 +0300 (EEST) X-ICS-AUTH-INFO: Authenticated user: at ics.forth.gr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Wed, 23 Jun 2021 12:48:30 +0300 From: Nick Kossifidis To: Matteo Croce Cc: Nick Kossifidis , linux-riscv , Linux Kernel Mailing List , linux-arch , Paul Walmsley , Palmer Dabbelt , Albert Ou , Atish Patra , Emil Renner Berthing , Akira Tsukamoto , Drew Fustini , Bin Meng , David Laight , Guo Ren Subject: Re: [PATCH v3 1/3] riscv: optimized memcpy Organization: FORTH In-Reply-To: References: <20210617152754.17960-1-mcroce@linux.microsoft.com> <20210617152754.17960-2-mcroce@linux.microsoft.com> <87f2cf0e98c5c5560cfb591b4f4b29c8@mailhost.ics.forth.gr> Message-ID: <6b35ec67ae580c64b4259e92ce21dc49@mailhost.ics.forth.gr> X-Sender: mick@mailhost.ics.forth.gr User-Agent: Roundcube Webmail/1.3.16 X-Brightmail-Tracker: H4sIAA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vger.kernel.org Στις 2021-06-23 02:35, Matteo Croce έγραψε: >> >> If you want to be compliant with memcpy you should check for >> overlapping >> regions here since "The memory areas must not overlap", and do nothing >> about it because according to POSIX this leads to undefined behavior. >> That's why recent libc implementations use memmove in any case (memcpy >> is an alias to memmove), which is the suggested approach. >> > > Mmm which memcpy arch implementation does this check? > I guess that noone is currently doing it. > Yup because even if they did the wouldn't know what to do about it since POSIX leaves this as undefined behavior. So instead of using memcpy it's suggested that people use memmove that can handle overlapping regions, and because we can't patch the rest of the kernel to only use memmove (or the rest of the programs if we were a libc), the idea is to just alias memcpy to memmove (BTW Torvalds also thinks this is a good idea: https://bugzilla.redhat.com/show_bug.cgi?id=638477#c132).