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 A09A8C64EC7 for ; Wed, 1 Mar 2023 00:20:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 067306B0071; Tue, 28 Feb 2023 19:20:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F33296B0072; Tue, 28 Feb 2023 19:20:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DFA246B0073; Tue, 28 Feb 2023 19:20:45 -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 CC1246B0071 for ; Tue, 28 Feb 2023 19:20:45 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 92DE6140A6D for ; Wed, 1 Mar 2023 00:20:45 +0000 (UTC) X-FDA: 80518423650.26.FFF9129 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf27.hostedemail.com (Postfix) with ESMTP id A2F6E40019 for ; Wed, 1 Mar 2023 00:20:42 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=smZrsxG0; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf27.hostedemail.com: domain of gerg@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=gerg@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677630042; 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=Rir8O5XChKESBZWYtrOFsOLoeLu+uW2aoTPH08UVn8A=; b=WfkfM4I27nkMfqfq2bV4Fa+h1RzEi5+v2L7jgMo47k5MtLEt6bSZ15YYRzUBp9QotL2xfm v3yFZV4Pz8YJsQbRrxfDr/nL4M2IoJVZQWSn2pzCa0iWdUd8EEvCFAoEdOCyQoJIbSZ4+T 5AuFBWiH4uYlHV0G2nShC8BVCm+KwMM= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=smZrsxG0; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf27.hostedemail.com: domain of gerg@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=gerg@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677630042; a=rsa-sha256; cv=none; b=bcCCCASDgrzru8hQ8l7nDYqTxjn3D/sR7QlkCwxtmYp1Os7YUXzclcKkyqye6db1HRvlc9 aPFdZclngnGHscVhUGcWNcLyAWiSR+lypFwkRky6rdGrs55cESZcrw5ZQiSyd2ZE+Y3/N0 OjKU3c5GcO2QYBI66XML6FVtRsf/icY= 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 DE861B80EE6; Wed, 1 Mar 2023 00:20:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60500C433D2; Wed, 1 Mar 2023 00:20:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677630039; bh=5PUYaVCUEIzlyFQ1PECX/TblYbIvQl2OaQqQ0Z1W70s=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=smZrsxG0SK/mfdR4SCQBaXISd6+Ry4n6tvEDzA4WRPcVYvNDcp3h/ZoYevCo1Qwqa w1X3qxiXPxAqvTMdbVw0EcDq4/UKzFSGtlf4Vqi43X2fbArJONFB/IGSVu5FgsIUZO rLM7MwvukCDCDhxxsv0Op2vyTFkQhfYZbo0sKh3tbE1bA6QeIECNaKpnTjnGywaap5 ttCWURiX6HEYEvuafotkHraIo+GXt1rvIAqYQhUGyWssn6MSKKd2ow6hLIZu2vkixP fqngkXSdWwVDs66Ev8jU3z1EdZcBUtwszeDwf+lKPAseQg0fSmS5weC55dYCS0clKO P1nM9CV4yAoKw== Message-ID: Date: Wed, 1 Mar 2023 10:20:35 +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: Palmer Dabbelt , damien.lemoal@opensource.wdc.com Cc: linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: From: Greg Ungerer In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: A2F6E40019 X-Stat-Signature: mecwk9n8mpesszwp6w9pi1owo54c8hza X-HE-Tag: 1677630042-603500 X-HE-Meta: U2FsdGVkX1/1PJfDYiCvaIHVBlujaolB5j8k9LeLS9u0ID9Ki28k0Gryp9dpgu6KdnUWdas305NqYMI8LsPvtG5SAt1mJY6KceK7qpe08B/+GqG30EI034N3jttHBT5WBMCxsPl2Q4lx7gpp0R0KwodAktWn7a3TFGO9DGuhHGXI27qicKZTEvjFFSKPLe/nZMKJ+ngEQpY9v7XtSKK7TqAKT8N7lGFyE/2zSubqi4BNGWkMrRkj1VMGjDVTFpJ3FJJPMGDAOG+v8bYXaCv8tDRnmhIWU3sS33c44/8x+H4pex95DQRfwn2HFa00Zl3xSsC9hLpUGcCKRpvsk0TjrzPuM0seR40ZfMKsaE8C+Zho13eY1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.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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. Regards Greg