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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2F80C636ED for ; Wed, 28 Aug 2024 17:29:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7644A6B0089; Wed, 28 Aug 2024 13:29:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 713FA6B008A; Wed, 28 Aug 2024 13:29:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5DB876B008C; Wed, 28 Aug 2024 13:29:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 3F22F6B0089 for ; Wed, 28 Aug 2024 13:29:18 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E92D2C024A for ; Wed, 28 Aug 2024 17:29:17 +0000 (UTC) X-FDA: 82502340354.13.4DB7094 Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by imf23.hostedemail.com (Postfix) with ESMTP id E48E1140007 for ; Wed, 28 Aug 2024 17:29:14 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of segher@kernel.crashing.org designates 63.228.1.57 as permitted sender) smtp.mailfrom=segher@kernel.crashing.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724866067; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k8Qyj74CeDoUya9Vr744m4R8YvCdqIPmQGpZ2FOAWuw=; b=Nxizvrn499IlgO9N+6J4l+32KCAY+AEtQhZXjDRmuHFwT2IEb+JRhXBk6u9FGb9gh0wtR4 svW28cjjtAyC2sEUqzeMiBR6P87ei9jR0Ix1EjAXkV3dsHckvx0edK4Po6PWcoJMB2Iy83 1umbq1GS4y0txvwUiH2kSwMt0OpGEoA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724866067; a=rsa-sha256; cv=none; b=XgwSPwCIbhZg5rbaTZa/VBwzwhYOXNwSx8QlXuOC35Ei6CeonXoVvgK/kjD/qvAiyV4FW3 ftV1oSTxBywE819W0y7MOsuYqFH8PimPcKGiNmNAV+c4PwMArXVKR/ZMLjnjF1P40rOLSp CAifuv0M9a74zz9GKkW7qwU7+u/ZMak= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of segher@kernel.crashing.org designates 63.228.1.57 as permitted sender) smtp.mailfrom=segher@kernel.crashing.org; dmarc=none Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 47SHPeo9010804; Wed, 28 Aug 2024 12:25:40 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 47SHPc5F010803; Wed, 28 Aug 2024 12:25:38 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Wed, 28 Aug 2024 12:25:38 -0500 From: Segher Boessenkool To: Ard Biesheuvel Cc: Arnd Bergmann , "Jason A . Donenfeld" , Eric Biggers , Christophe Leroy , Michael Ellerman , Nicholas Piggin , Naveen N Rao , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , "Theodore Ts'o" , Andrew Morton , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Vincenzo Frascino , shuah , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Linux-Arch , linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH v2 05/17] vdso: Avoid call to memset() by getrandom Message-ID: <20240828172538.GI29862@gate.crashing.org> References: <5deb67090b214f0e6eae96b7c406546d1a16f89b.1724309198.git.christophe.leroy@csgroup.eu> <20240827180819.GB2049@sol.localdomain> <20240827225330.GC29862@gate.crashing.org> <20240828124519.GE29862@gate.crashing.org> <20240828162025.GG29862@gate.crashing.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Stat-Signature: tp4domm86nyu5szfpozedumm3aqou5rt X-Rspamd-Queue-Id: E48E1140007 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1724866154-510900 X-HE-Meta: U2FsdGVkX1/YaKFjk96FHP+WrNYua+zo+eMB0wHwIJYwZ5VtcUoQtkxt72NhXHUlQUm1n15lzkAnXux8+26Q0ee5jep3qYlMZYiGmXGGJeOp2+ZGF6DSByfcGLRWyF61e8QbWdG4T+WjBnaSavSj3bI4eaIEVYKS5pf1UpPfevXRj2z8hFwUqPcLJ4pzfstRRrt4AlwNF/JZ51yvuuAPv8DwxfeEkeZJJxkM+3UsSWNRc3Y2xc4jrhlE3paEMciKtoxgcfWot5sztWfC1ZqU7D/TFwU+UPqOWvfK3myPFDlQ+6CV8M+IRSc0mtroV99yyeQzw5nxGWw+UqJ2kRy/d2/eTSp2y0NVh4UKgloNZ8Yvir2T93M1QhtvYmkCbW1nfs3iJMqEnv5u9mNRwao/X+LlH25Wp+aSTYqs4MVVvrok3oGAjKEn6FQi2KAi6MO1q6BXR3AfQoBzpYZQ2OQNS8EUAXNT3aagd1CevATcQLYUCJ64fZz24NJ672uQwOduC5FLLGncx6JYfyrTU+yTt0nK2q6ux6r8wnb4Zv+Ez1GXj89WRYeliDvUSdMKci08w563VjsW9U6FnE1VsFEFBuG3IfaBIaadG1ECn6UTDUQrwPrSf6PrIBYivb8TjLAXvN9NxCcShjqvVBAO80sbI5DRRi7gjiRYX3Lw7wUzA8X1weaHMorzZQmw+YPUzdGwtReOKJ602MQGPSJ/aDrVE8xlL8lBSw45/LBlviDoV1k80Pzq9rGlU1OBYAlfFgGMMmHsGkYSthA8zkzqO+nlvFSZcWIqyFyEfkF7GWAKaHW9E+faX8TQcBzphHsg1gXjaK2Xx8SmJWrAChjBWryQsjpkdwlsXctT8TdbbOrGekQdbH4MGU1G6yxeokvRm6IrW3BnBd7HEGxnFJgl9r/PbWL4N/rOw0HlTfI6e396d1Y6fsXNr7xwm3VGkxdGljwLhU9Tox8ualQilORM3Gm 0GtVRUuB WP2hXgkAKu9g+X9iKwRiQ8TfXlmgt9d8Pq9fIjV0xsiXEkXgeVzuNd8vidPRXyXOKgUiCTiVaAAa4edYqiFDSWB9nc9o+boz4rBeQAajw3mJwKEN5YVKFBSA07cqDl09aFiWzb3P0FsEr3Ii4+SnfD19XS5EYgYf9M1zz X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Aug 28, 2024 at 07:12:55PM +0200, Ard Biesheuvel wrote: > On Wed, 28 Aug 2024 at 18:24, Segher Boessenkool > wrote: > > > In my experience, this is likely to do the opposite: it causes the > > > compiler to 'forget' the semantics of memcpy() and memset(), so that > > > explicit trivial calls will no longer be elided and replaced with > > > plain loads and stores (as it can no longer guarantee the equivalence) > > > > No, the compiler will never forget those semantics. But if you tell it > > your function named memset() is not the actual standard memset -- via > > -fno-builtin-memset for example -- the compiler won't optimise things > > involving it quite as much. You told it so eh? > > That is exactly the point I am making. So how would this help in this case? I think we agree? :-) > > > This needs to be fixed for Clang as well, so throwing GCC specific > > > flags at it will at best be a partial solution. > > > > clang says it is a 100% plug-in replacement for GCC, so they will have > > to accept all GCC flags. And in many cases they do. Cases where they > > don't are bugs. > > Even if this were true, we support Clang versions today that do not > support -fno-tree-loop-distribute-patterns so my point stands. It is true. Yes, this cause problems for their users. > > > It is not a complete solution, unfortunately, and I guess there may be > > > other situations (compiler/arch combinations) where this might pop up > > > again. > > > > Why do mem* not work in VDSOs? Fix that, and all these problems > > disappear, and you do not need workrarounds :-) > > Good point. We should just import memcpy and memset in the VDSO ELF metadata. Yeah. In many cases GCC will replace such calls by (faster and/or smaller) inline code anyway, but when it does leave a call, there needs to be an external function implementing it :-) > Not sure about static binaries, though: do those even use the VDSO? With "static binary" people usually mean "a binary not using any DSOs", I think the VDSO is a DSO, also in this respect? As always, -static builds are *way* less problematic (and faster and smaller :-) ) Segher