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 38F4AC6FD1D for ; Wed, 15 Mar 2023 03:58:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 870B66B0072; Tue, 14 Mar 2023 23:58:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 820E76B0074; Tue, 14 Mar 2023 23:58:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6CE068E0001; Tue, 14 Mar 2023 23:58:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 57ADB6B0072 for ; Tue, 14 Mar 2023 23:58:37 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 25AC716100E for ; Wed, 15 Mar 2023 03:58:37 +0000 (UTC) X-FDA: 80569775874.20.923537D Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by imf12.hostedemail.com (Postfix) with ESMTP id 538084001D for ; Wed, 15 Mar 2023 03:58:34 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=EC97TzW0; spf=pass (imf12.hostedemail.com: domain of palmer@dabbelt.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=palmer@dabbelt.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678852714; 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:dkim-signature; bh=3HYuR6tFCyvgHrmckJ1l2C1M5Y1KFC1xHbhtrJS6kSw=; b=kfN1nM+bZJRTyUTztxU6kEBJxU798GXT5cWKzcB0bzy45IjHQ/aKKyLdRe6TaubDjXDE0Q 23enG3KsL49O0nhxS0BmbZNh7gNwnWaFyLW/OIi2ccqk68duGPT4eeZ+FrQsfpa6dv/4iv cxJWfE7f4+r34MBL6Iwqs8MqWvo7+zA= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=EC97TzW0; spf=pass (imf12.hostedemail.com: domain of palmer@dabbelt.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=palmer@dabbelt.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678852714; a=rsa-sha256; cv=none; b=Zh89GsvwbDqerJH/nRojxJ3LqQ2bnovdGmCyTrUvNym8K7dZ3IMH7yz2EObdFoE9M08vfX ntmBpVkYAjz6quon3Bfu6RXvtnkMe4Uio/s8hed0X3vT+Pgp/QhtmjsJP2IysNtj09I4L/ j2Zm/QycRTUf9caamSSm1m1T21nonTs= Received: by mail-pf1-f174.google.com with SMTP id bd34so10969790pfb.3 for ; Tue, 14 Mar 2023 20:58:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20210112.gappssmtp.com; s=20210112; t=1678852713; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:from:to:cc:subject:date:message-id :reply-to; bh=3HYuR6tFCyvgHrmckJ1l2C1M5Y1KFC1xHbhtrJS6kSw=; b=EC97TzW0CrEe5hSuqkySlThCvA6rC8OWWPnB07b8u+eFPQzG24z7QLN+nSl2Ol+Fpf y7ndCuRq3L5iY9cZSJkEEH4ef9/uRN8WXYZiHPwscaeosQengEA6jDmcQsqpW35ibkY9 Q9BoJ0wB+1ga3hkv5NC5zYwRApnaHXjlcLTDwnZiqrcWKk0Cox0+tUKYDeaOpvh1K75c /v14KaYuetjNlrxyFFq76zIgePJ8+O+WbnyB7hpqZp9zBAQ6w2Y1hwIrUUF52Qt36O3D N1dhqty7K6t1DM/1tLNAiPIXYbRJQcwqDDByltdDzCxTKMA6bjNOuj8QY/IqNwnOOWPb WMcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678852713; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=3HYuR6tFCyvgHrmckJ1l2C1M5Y1KFC1xHbhtrJS6kSw=; b=Zf8kYDk7ViwEevPRZV2LnofSErlOVxhe9oG3mRlkzyJD1NKwKhHb8s/R/kd9GAC9W6 S7FFVOY+M8nCvfC52eiueGRMedI0k1/bAggquqdZgWnJYpdBn9fk63D2vAgBgapIX0JC 1XNwjTMeqGYykSin/I7ZL56vgHA0fnmVGdzVkYwIHBtdhuLPrTQf+DKwr/VgkMqyFBo2 jLsjE0JHr1G82851rUFQpSbkKJwLPeJJsFsBYfJvbYa+z684OTwg2LnucwuceFGB+KQc 2p8mcujwuTbPO+HNrEZr4UCPWIeAbEQ7KBlDrjo9gCkWQTeZKJX0XKFfIWx+IV03h+b8 Wgyw== X-Gm-Message-State: AO0yUKXq6DR3VSVMsIS2zhG+FqgeICGtc/nq5WV+9IfLeajQy+fml3UY Lqgi2ZKm8EIIxSCy0zvUIzBqyA== X-Google-Smtp-Source: AK7set/f279w0PNYnzk8p6eaHIA+U2s7JSlU+MedS2TRqoMtPOHNLMkoP1Vc2Z7oekBIxmo0doQfaw== X-Received: by 2002:a62:8415:0:b0:625:500c:35bd with SMTP id k21-20020a628415000000b00625500c35bdmr6675421pfd.6.1678852712976; Tue, 14 Mar 2023 20:58:32 -0700 (PDT) Received: from localhost ([50.221.140.188]) by smtp.gmail.com with ESMTPSA id g21-20020aa78755000000b0059442ec49a2sm1143241pfo.146.2023.03.14.20.58.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 20:58:32 -0700 (PDT) Date: Tue, 14 Mar 2023 20:58:32 -0700 (PDT) X-Google-Original-Date: Tue, 14 Mar 2023 20:57:37 PDT (-0700) Subject: Re: [PATCH 0/2] riscv: support ELF format binaries in nommu mode In-Reply-To: CC: linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org From: Palmer Dabbelt To: gerg@kernel.org, damien.lemoal@opensource.wdc.com, macro@orcam.me.uk Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Stat-Signature: rqw5p4j3yr969ijzf548xf9rx61ze3hp X-Rspam-User: X-Rspamd-Queue-Id: 538084001D X-Rspamd-Server: rspam06 X-HE-Tag: 1678852714-164175 X-HE-Meta: U2FsdGVkX19+eXX3o8MqjqwjsslcQUIfjbtu3JTmaIU7MJsjvX3qJGU7kUAYzUh3b991jPfcbLay9fPF7vk352GvjMi+MtvdEfrer1YZURp6vchj7BZGCVzEH6ZvmPThzcT22MrueXDVUD1uTnqTQGhovqu6GKBVu3gF0eynvUbSx0C/ZMlOouflT1KqsOrTzQEkpMxKnljvzXCqO1Z8Mb5SKtj1sxLCAxQxPPt2EvqzVQrmLNFUxpIyh8Ncwe/caBdZd47GjdXIoJvRGjx7Hr0PggjCayeuk9vc0IkWMm2O6c29YvOS5Iu9uY47qPVRO4CyLaLWi6cvsPDttoVx8PgtEY/oShe2Bc9C6tm9aE02AziNZ2A4S+8by+Q1m26DmPi8yrSITLOjbIAfN6YyyMYEeRaXivmr317vBrPfkmjlcPx1dyzrsWTUr55LLIZK+dTtf93M74bcCFaXTxNJFf2DYsvspygfLqsoC2ze5AF0/aTMcUftC46mOD9L4W8wdOxZLCBIgPxkvzBoGUs9uKeTUrUrRDXv26WkW2vlNovmnmO789RbInQYA7ze7Mip0kvrGhryLS5CO3sx9OfAWcIa4GJpn0I+fOS8W6oM+eZjuzxuzS62Wf9bM3dS4KA07AiTRSJ7gPaIKEFJoaP/4aOfgXy7OAU6B/ULMcRXZa3Gr5OYq+nwLO6HXA0k8eJ/9ToTorzy+2ov7KxzNErZXTjGXid+TYCFcOgQ4pzWv58BtC5nML9qA1qOhHB5D+XxzBq7SZ6/e0/CoqzlzTUTKbD1bIKlczumAGp7PPl0kVIGWVnQmCrZnxJ4Ug0ft+uofBQHA88scT8PGLf76O2tmj/cRlcxdXLsilVhxCZ9ItBgV9bO0IdJo13oLSa69aZ1XdocgjJlHGDGREtaqzpBUaSYIAEtdfiJiPVYzWM2h+Wg2AAdf/G0IqANemq6OnunX+6m3I3tZau3L8/Ven/ JirSgwWx cWlu19DleW/AbwQegnVFwv7LzNH9u6W+nvWu2ka9pism07nLhU9YnVcp1UFB1i8RkvPrApe3kxEdIAqM8PmXPgnQVzPAMPQLkD7nET0N3l3Hmwsj0B8G/p2QB7wEmWheoQMH7xSy4wxeJy7HoCbTJemT3zD9yiCRwfoLJlPHGW11dQ197VtI8erpZn7WNlGwM2N9T8nUmwt3LUUS/398zJXzluELUW4iW5n01jmMAtY/NmJzpPjl1LDN8euh6Ju1iSu6HxP5dVW6qeOiBtZ2FG2A598jZB6y5IrZuCEgGgXZe6P40R7B13MVEgPXaIxDpGN9c5wLm3ccF3i+BxxUhmuscl3JflQ18Vm+O+YeYsL9X/w6xs2sV6lV5EkO51bpMUew/wnVsDZYmB6RtP7h9BvMw9aSIpMYP1DzKtn8E04Jf4wr2VMQN4p+WedfTk+o6zn9/JZkwythCxxdjI+efuigjUy6dnRYZKbsXmyQZf/RySPROUGMdo4UhSHnEEwjNsI7125xvmUzCAwGggODlxSTXu5E6zP3SCFln1eZ6t2kNTNxd3Yds+rDFqEyZ47xJchK2 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: On Tue, 28 Feb 2023 16:20:35 PST (-0800), gerg@kernel.org wrote: > Hi Palmer, > > On 1/3/23 07: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). > > This is a simple script I user to generate a working QEMU example: > > https://raw.githubusercontent.com/gregungerer/simple-linux/master/build-riscvnommu-linux-uclibc-elf.sh > > It does reference some configs here https://github.com/gregungerer/simple-linux/tree/master/configs > and this posted patchset as https://github.com/gregungerer/simple-linux/tree/master/patches (this is > just these 2 patches combined as a single patch). > > >> 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. > > Oh, yeah, no hurry. Maciej and Damien: I'm fine taking this, but not in any rush. I'd rather get the uABI right if things are still in flight, but if we're all just waiting for something to get merged first then I'm fine with that being Linux. > > Regards > Greg