From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3833C17BEC6; Wed, 28 Aug 2024 12:52:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=63.228.1.57 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724849524; cv=none; b=jSz6EkZDlHxNceCV9EcQwLrpy3i8naIecgXqAyOfjUhRpvnlixEeyw0uQIiH1FTz8GQcST+nNtkG8QLYXu5CFXVS2tf2UVumApj8rcamJ13ucx0qQ/OB6CbSGKerv2/wEx70ckh4XGytNjNIWaPDuoSQPPx/+YwT46TPmqF/6vg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724849524; c=relaxed/simple; bh=z7QBJwrDqdm5+RXcwT0mLKPUzajm3VYvAwjbZSHkH6w=; h=Date:From:To:Cc:Subject:Message-ID:References:Mime-Version: Content-Type:Content-Disposition:In-Reply-To; b=aFO2CmvpJwinSwXIJsYB9rfcswv3OoJYTT7f1eSGdkUtCMfhwBiRAUy0AEMd3FtHXfj9eR7zb3gNqUpzaUHCtU7QbDWyWWAmLPCjS/2YoPM63R7TUEQH+R5yl9QIvkSiZyXmSjke2RfZEt+N/F/QQ1HXH5igemFFwigUcfFcxuo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org; spf=pass smtp.mailfrom=kernel.crashing.org; arc=none smtp.client-ip=63.228.1.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 47SCjLrv031636; Wed, 28 Aug 2024 07:45:21 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 47SCjJbM031635; Wed, 28 Aug 2024 07:45:19 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Wed, 28 Aug 2024 07:45:19 -0500 From: Segher Boessenkool To: Arnd Bergmann Cc: "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: <20240828124519.GE29862@gate.crashing.org> References: <5deb67090b214f0e6eae96b7c406546d1a16f89b.1724309198.git.christophe.leroy@csgroup.eu> <20240827180819.GB2049@sol.localdomain> <20240827225330.GC29862@gate.crashing.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i On Wed, Aug 28, 2024 at 12:24:12PM +0000, Arnd Bergmann wrote: > On Wed, Aug 28, 2024, at 11:18, Jason A. Donenfeld wrote: > > On Tue, Aug 27, 2024 at 05:53:30PM -0500, Segher Boessenkool wrote: > >> On Tue, Aug 27, 2024 at 11:08:19AM -0700, Eric Biggers wrote: > >> > > >> > Is there a compiler flag that could be used to disable the generation of calls > >> > to memset? > >> > >> -fno-tree-loop-distribute-patterns . But, as always, read up on it, see > >> what it actually does (and how it avoids your problem, and mostly: learn > >> what the actual problem *was*!) > > > > This might help with various loops, but it doesn't help with the matter > > that this patch fixes, which is struct initialization. I just tried it > > with the arm64 patch to no avail. > > Maybe -ffreestanding can help here? That should cause the vdso to be built > with the assumption that there is no libc, so it would neither add nor > remove standard library calls. Not sure if that causes other problems, > e.g. if the calling conventions are different. "GCC requires the freestanding environment provide 'memcpy', 'memmove', 'memset' and 'memcmp'." This is precisely to implement things like struct initialisation. Maybe we should have a "-ffreeerstanding" or "-ffreefloating" or think of something funnier still environment as well, this problem has been there since the -ffreestanding flag has existed, but the problem is as old as the night. -fno-builtin might help a bit more, but just attack the problem at its root, like I suggested? (This isn't a new problem, originally it showed up as "GCC replaces (part of) my memcpy() implementation by a (recursive) call to memcpy()" and, well, that doesn't quite work!) Segher