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 21694C64EC4 for ; Wed, 1 Mar 2023 01:14:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 40D486B0072; Tue, 28 Feb 2023 20:14:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3BDBA6B0073; Tue, 28 Feb 2023 20:14:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 287876B0074; Tue, 28 Feb 2023 20:14:43 -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 17EC36B0072 for ; Tue, 28 Feb 2023 20:14:43 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D6F6FA086C for ; Wed, 1 Mar 2023 01:14:42 +0000 (UTC) X-FDA: 80518559604.06.9461392 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by imf18.hostedemail.com (Postfix) with ESMTP id 2FCE11C000A for ; Wed, 1 Mar 2023 01:14:38 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=Ol4tu7zl; dkim=pass header.d=opensource.wdc.com header.s=dkim header.b=BzA5de2B; spf=pass (imf18.hostedemail.com: domain of "prvs=417be09c0=damien.lemoal@opensource.wdc.com" designates 216.71.154.42 as permitted sender) smtp.mailfrom="prvs=417be09c0=damien.lemoal@opensource.wdc.com"; dmarc=pass (policy=quarantine) header.from=opensource.wdc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677633279; 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=0TDf/t6rGrB+oVRlCqCVHpMNOjOYV9VmZDnWqGet7gk=; b=4UsP+8VemGt98ljqTrhOTNSTT79B2SGWCeJlHVUjCEP/HZ3eljl71QsW4a77LR17Eij8kK nSvtXTOXjNBuFm/INAJo1uf01dlESjlLg58ih7s8t2fL9h6EfPWazkCjeYt+hO5Sbwjcw4 +NzsOtzr6mdYfsTvojU9cBePvHuRAc0= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=Ol4tu7zl; dkim=pass header.d=opensource.wdc.com header.s=dkim header.b=BzA5de2B; spf=pass (imf18.hostedemail.com: domain of "prvs=417be09c0=damien.lemoal@opensource.wdc.com" designates 216.71.154.42 as permitted sender) smtp.mailfrom="prvs=417be09c0=damien.lemoal@opensource.wdc.com"; dmarc=pass (policy=quarantine) header.from=opensource.wdc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677633279; a=rsa-sha256; cv=none; b=LjssBQINapsUBnV2FPsgE3vHa/n3itD0MVP/jgD1AwtIU1BpZR+Nw61JZL+T+KTp+baZjX eCDUZx4IqFWfIGsFztqoPM860tlXMNJZCBB5n5vzuNz5/7nDdNw/IZfaJCyBj13H1g6uWS c/vXIYBCME+BtxC1sj706rChfu7BFmI= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1677633279; x=1709169279; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=N+aZAPK10DnzUaT0ayx2/pjO5bVYRfWI3HigiBUgzRM=; b=Ol4tu7zlJsO7e1pjrSEesLyp1UNNucXxqBLUYZRBFJqiAR1PL3lnHYry L2wUms4Jp5DWS1Hzx1TbdPsmId1respu1EP77p8u7QL/4AkJAlkNaSO1X 43LoxZZ3x7O+C6+FWiqTBr2IqhgF1IAwY0rU0xoKUoUddxryays+2Kgnm UWYBHxLugyOioF/+DDOgRPJLP653kQLwZswZoI1SHQrYi3u2Zj2++XjKw SgbUn6UBQK5UX80MeYn115olWfGyr6nzBs3Ph4pRLShy7/Ho9D86KAlBt CIWhu9fPwJ1afEAUew7xlxfnzK0VlhRZtnPjhU5LzfbdexlPELkyk0IXV A==; X-IronPort-AV: E=Sophos;i="5.98,223,1673884800"; d="scan'208";a="222762582" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 01 Mar 2023 09:14:37 +0800 IronPort-SDR: f6++WIGW+rXvf2rmFAedwdHqNYsUHR4LYyVPxvE5ploPnb/qXWaNUMox8+6ksbP9gzgunqf+UT dzvny7S1tkNZ0o/H6tKBdpiefDgGMeVS57ZotrCsD5LIM98o56+S49xkCVb8lh1bIpzJM8ip3D VGg/E2a5lYxufkTbW143C6ayFByOkTgc7EZ4xjaqZfrL2Ze1uu9aq0TfpcCgiyahid4s+7sfYV gvPUdVkrrC/njV1Le7/yrH5l98+qjBApavximxV+yYtdUYNm6LhmcLGVBYzdjDbI4SqW9bgL+q YSY= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Feb 2023 16:25:43 -0800 IronPort-SDR: lmIIfX3FkfBYXifeEWCqimLnrRx1iSVkIT1k/cEeBbbzrJqWn3EQNIAzAtnCW9amBGYa2QUKde 8f4QSqVthqshESx7W+rUXPQkJb/hNI+nCcJROzbzSJKdW0PeOypSfnF60j1R8rGU+oX79QptC/ GgjVqVIl374jaCoz/Lp1CGqkTb/fRoDR7H0GKWc2rJBGn2mnbu2+Q5fLIOKI3z0ZKQPCjWTGdr g2utom6TwJQkCsuTTGaZGCLK8190jNEYrMC+3zF1ZCqoJZJrYHWdX5/pDdlqgYu58wdrr8wH6e BNY= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Feb 2023 17:14:38 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4PRGVP2tKNz1RvTp for ; Tue, 28 Feb 2023 17:14:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :in-reply-to:organization:from:references:to:content-language :subject:user-agent:mime-version:date:message-id; s=dkim; t= 1677633276; x=1680225277; bh=N+aZAPK10DnzUaT0ayx2/pjO5bVYRfWI3Hi giBUgzRM=; b=BzA5de2BzcC2J0nyyXm1kFXIXN8O6e2COQlzWHxaM8ShOb56hqb hrtiuCFA8yToZlxLWS8w0CGKZyDPd8xoq0HN59FKDhZNob1yBpqt1eaXoKP+r3dr E6GMbERI4aYrhxVFOIqhmn18MAXjued0XjqPQV2k7597ADPU6n/sL+bLbO2P8fRS Ju5tkDHamRqULWBZ3RdmCdpiSlE7ZyMxv5rDpekUSuT1t6EBeJrqm3++EUs5r+BJ Zp+wYSlBrh/CGIBamR6rxo47G+EGALbSIJgDubLhTX3m168kaC0ndM6kvvoerrQv lGgIMmqLL/KQqBxU2Fn8kTvjIjvMnsfgUbg== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id fODhYho7KmV1 for ; Tue, 28 Feb 2023 17:14:36 -0800 (PST) Received: from [10.225.163.47] (unknown [10.225.163.47]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4PRGVM43hSz1RvLy; Tue, 28 Feb 2023 17:14:35 -0800 (PST) Message-ID: <9b48f4be-4060-2505-8028-95cfa6806f33@opensource.wdc.com> Date: Wed, 1 Mar 2023 10:14:34 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH 0/2] riscv: support ELF format binaries in nommu mode Content-Language: en-US To: Greg Ungerer , Palmer Dabbelt , Niklas Cassel Cc: linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Maciej W. Rozycki" References: <3719a4f0-1a5a-4661-a6d7-5d4f67d7b7e8@opensource.wdc.com> From: Damien Le Moal Organization: Western Digital Research In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Stat-Signature: thdzg9z1wmkzqtzz9wmq765tobdkgkxy X-Rspam-User: X-Rspamd-Queue-Id: 2FCE11C000A X-Rspamd-Server: rspam06 X-HE-Tag: 1677633278-3734 X-HE-Meta: U2FsdGVkX18RIFDUY0O+vCdWlL4DERjDJfPsnn+8MCHrSJi8HiDZrly9TMF7S58ydAOAtlNlzcO9CCSDlrpOs2Y82k1kJztnrIrMIHRnv3G8oen7/JfZ4RmAVR/nOGEC28SzJtDuwiV4w7DkY3+9+eQ9HWkRuqKKb0YBK0qrST6sa1dCZDnT522doit3W8Vw2to79c9c2Z1MWCrEjnDbooPleEVUWP9bvw3LUyDf1P7wJT6AjOcs2AlV2zgSPSTA54I/Z3QII2hNcr9N/sIaPvdyQMd9k6u0wDa7S1SUYd9xhZp8SoZ+79QXjiCc8bv5hIgGoldbyyY2G3KF04eU4C8bxlHS5FY4dyP7z3+9aXRZrED4qMI4VlYlmi9NSFJxH4W4IR7CUnkLmglGf3YpqdjE2mkT5kQVxMI2W0tPyhyYf6fAWO+FgFjcaS2fzJKYPbYOnYXh+YU6SaLfEvgHkPWKpNlWz5KNk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/jhgUW+1U2uhRwoWK16fNlFzXyhJZYQTBteEurmF4KnjFlYYT+qE6HslFuI0pTZ5BOY/Wljwfbq/5/cdLrCo/ZQK1vpNk9 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 3/1/23 09:24, Greg Ungerer wrote: > 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. Maciej (added to this thread) has done some work on gcc, but nothing that is upstream yet. > 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. Right. I was still thinking in terms of flat bin. The keyword here is "elf"... Need more coffe :) We could try this using either qemu or the k210 with buildroot, with the addition of your uldso loader. Will try to put that in the pipeline (pretty full as usual, so may take a while). > > Regards > Greg > -- Damien Le Moal Western Digital Research