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 5689DC64EC4 for ; Wed, 1 Mar 2023 00:24:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C24C26B0071; Tue, 28 Feb 2023 19:24:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BD4C06B0072; Tue, 28 Feb 2023 19:24:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A9C4F6B0073; Tue, 28 Feb 2023 19:24:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 99B356B0071 for ; Tue, 28 Feb 2023 19:24:13 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6699FC02BA for ; Wed, 1 Mar 2023 00:24:13 +0000 (UTC) X-FDA: 80518432386.03.C5CEFB6 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf13.hostedemail.com (Postfix) with ESMTP id 7566720016 for ; Wed, 1 Mar 2023 00:24:11 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Ln9WdYox; spf=pass (imf13.hostedemail.com: domain of gerg@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=gerg@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677630251; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nXT7dUkZQB2/ZCOzV4p0btuIYRgGH4yuhNKKyEFK8iQ=; b=eDclMzEIRoVg0Ah/JkHE8WePyAEenVt1ZUdaRWJyar1AuuwJ9td1SJBdipQaroV5lLBKlh UV0geL1wnb2OqEZQNEu8H1c5qZzUCJa0B+ar7y9pEF6++46ZACmObRrEfBrjYtBRsvgcO7 UmSw2SwbSUi/RZMxsoWfQJCJqqgQ0OU= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Ln9WdYox; spf=pass (imf13.hostedemail.com: domain of gerg@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=gerg@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677630251; a=rsa-sha256; cv=none; b=5NMxQ+aYb1ARgQnHTOQD7eFawdo4UKMz/2zU7RYzf7J4eBSUgAEk5quHPelF+lglL+rCIG COFynpE0nyqRUFLy5Ro3CVlNaRodb1zWLt8Ot5/Fv685jtNSAT7R8nAEAZPvi3cMGPGyqi tA8Pj36IznqQrY9qKHagAd8T+BC0GGM= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D9CE4B80EE6; Wed, 1 Mar 2023 00:24:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35CE5C433D2; Wed, 1 Mar 2023 00:24:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677630248; bh=m4guPfJLUa8LmwPjtN0dbXYerTvJcpnOVu9CzY3no+U=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Ln9WdYoxjZoAiwJySwfPO+L2v7buBxftjBXhNQAVyCeyqTCSSukyiQ9rYjTgPIkCG OjHp6qmOFvjSIZ37hNCL8gPtBO8K+S+dBzN8+wtQ0j/POPUvpZAgGnKlOJcG2Zc9JW JE9Aa06X0egJzufhZyMZgY/Uo7wL1wtk3l9oHQYiz/OtpP4j15u7TGOizpEq/2sZJi W1RjezCmky98WvbG1SRtJuDsrs29HKCY5+hi5g5ZZ9cCuKAauhFD15hQ26GNBOjVCm O6P2tpeh/n+sfGQSvQm+H0wssokb+YVtMsdPsHlLJ0c8KaPzYQGJoNbVbEc6Y7OOmP MMv93wiezPWVA== Message-ID: Date: Wed, 1 Mar 2023 10:24:05 +1000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH 0/2] riscv: support ELF format binaries in nommu mode Content-Language: en-US To: Damien Le Moal , Palmer Dabbelt , Niklas Cassel Cc: linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <3719a4f0-1a5a-4661-a6d7-5d4f67d7b7e8@opensource.wdc.com> From: Greg Ungerer In-Reply-To: <3719a4f0-1a5a-4661-a6d7-5d4f67d7b7e8@opensource.wdc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 7566720016 X-Stat-Signature: zmqeoqo8kx6umdf37foje4catrb3oghh X-Rspam-User: X-HE-Tag: 1677630251-419848 X-HE-Meta: U2FsdGVkX1+l9Nsb7talOlmswivsVa5CJtOwHHw6sE/fOeYoAg78cbiooUIPv4QQc1OOLk9BQ7re9HApM2BFFe0/FuWNwc6ZbY/8Oqd2oSWIJAAQhv5iQomQM1C+rjeICAHVRTYSSYRdpKpmsuugqd+Ap0iTzr8e/A256LDfIID1s6/xLeBETJ9d3rVdoirNw5YuTplKOjuR7VfemoU9jlqJvPuexi8RQOLPfQjKjJ0WfEKpwH48uEOrDdhkmKli4XnIqLdEHY9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dOevBSvS4R7meP3UjnwJr57ODEVlc3BpodE5E+PxfnZjTNrTJn2Y54NMu 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: Hi Damien, On 1/3/23 08:49, Damien Le Moal wrote: > On 3/1/23 06:52, Palmer Dabbelt wrote: >> On Tue, 28 Feb 2023 05:51:24 PST (-0800), gerg@kernel.org wrote: >>> The following changes add the ability to run ELF format binaries when >>> running RISC-V in nommu mode. That support is actually part of the >>> ELF-FDPIC loader, so these changes are all about making that work on >>> RISC-V. >>> >>> The first issue to deal with is making the ELF-FDPIC loader capable of >>> handling 64-bit ELF files. As coded right now it only supports 32-bit >>> ELF files. >>> >>> Secondly some changes are required to enable and compile the ELF-FDPIC >>> loader on RISC-V and to pass the ELF-FDPIC mapping addresses through to >>> user space when execing the new program. >>> >>> These changes have not been used to run actual ELF-FDPIC binaries. >>> It is used to load and run normal ELF - compiled -pie format. Though the >>> underlying changes are expected to work with full ELF-FDPIC binaries if >>> or when that is supported on RISC-V in gcc. >>> >>> To avoid needing changes to the C-library (tested with uClibc-ng >>> currently) there is a simple runtime dynamic loader (interpreter) >>> available to do the final relocations, https://github.com/gregungerer/uldso. >>> The nice thing about doing it this way is that the same program >>> binary can also be loaded with the usual ELF loader in MMU linux. >>> >>> The motivation here is to provide an easy to use alternative to the >>> flat format binaries normally used for RISC-V nommu based systems. >>> >>> Signed-off-by: Greg Ungerer >>> --- >>> >>> arch/riscv/include/asm/elf.h | 11 +++++++++- >>> arch/riscv/include/asm/mmu.h | 4 +++ >>> arch/riscv/include/uapi/asm/ptrace.h | 5 ++++ >>> fs/Kconfig.binfmt | 2 - >>> fs/binfmt_elf_fdpic.c | 38 +++++++++++++++++------------------ >>> include/linux/elf-fdpic.h | 14 +++++++++++- >>> include/uapi/linux/elf-fdpic.h | 15 +++++++++++++ >>> 7 files changed, 67 insertions(+), 22 deletions(-) >> >> Adding Damien, as IIRC he's had some hacked up userspace bits for the >> K210. I'm yet to get anything running, but it'd be great if we get this >> to a point where I can actually boot test this on QEMU (I'm just doing >> builds now). > > +Niklas > > Niklas, didn't you add a nommu qemu build for buildroot ? Can't find the config > though... > >> >> Given that it's the second week of the merge window and this is a bunch >> of new uABI it seems best to hold off until the next cycle. I poked >> around and don't see anything wrong, but I'll try and take a more >> detailed look after the merge window. > > Does any riscv compiler support nommu fdpic now ? When doing the work on the > k210, there was no support at all, hence the statically linked user binaries > used (no shared text for libraries). I was wondering if anyone was working on it. Couldn't find anything. The way I use this support doesn't improve the statically linked situation. The -pie ELF files are still statically linked. But it does avoid the use of flat format binaries. That makes the toolchain generation a little simpler. Regards Greg