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 77198C64EC4 for ; Tue, 28 Feb 2023 21:52:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 18D236B0072; Tue, 28 Feb 2023 16:52:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 13DEC6B0078; Tue, 28 Feb 2023 16:52:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 005106B007B; Tue, 28 Feb 2023 16:52:50 -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 E4BAD6B0072 for ; Tue, 28 Feb 2023 16:52:50 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 9E6F140569 for ; Tue, 28 Feb 2023 21:52:50 +0000 (UTC) X-FDA: 80518050900.20.5B867DA Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by imf16.hostedemail.com (Postfix) with ESMTP id ADA7D18001B for ; Tue, 28 Feb 2023 21:52:47 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=omA2S4Lj; spf=pass (imf16.hostedemail.com: domain of palmer@dabbelt.com designates 209.85.216.48 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=1677621167; 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=w+zwAHBnS5+TovEmhkYJhNFoHDMUmuJ8ck612nZS1t8=; b=r/jfhFAF6ivq1eKxn2V14USgDHx/ntqI192X2CbkgxjfRt2trLhIY8jhHPXF6JPylEFPNp dRkiC/N1mPb71UmfK9zMQftpy58iodrUKTP+oOYZ4IAQ2NLlwU3hrEREE1jlP9/SxgK+rm kIjdSYMsshEhDv43qTlLyIo83cGkJKA= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=omA2S4Lj; spf=pass (imf16.hostedemail.com: domain of palmer@dabbelt.com designates 209.85.216.48 as permitted sender) smtp.mailfrom=palmer@dabbelt.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677621167; a=rsa-sha256; cv=none; b=3eEIJxUeSLPcHAdd2LqJRioSRnd/0Tt1dZrL1qp8w5/bPZsFM1t1iOAzf+vJJfVyG5dczg HphM0FsgOmj1H9Onqfsp4/5/0I3nAyASw0vaQ6lTIMU/C1E4od4jZOHMr/IfgLwfNrcg9U 5B/OKFsJxf/QLWACmOxBTT7m2pSy/mk= Received: by mail-pj1-f48.google.com with SMTP id 6-20020a17090a190600b00237c5b6ecd7so10632527pjg.4 for ; Tue, 28 Feb 2023 13:52:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20210112.gappssmtp.com; s=20210112; t=1677621166; 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=w+zwAHBnS5+TovEmhkYJhNFoHDMUmuJ8ck612nZS1t8=; b=omA2S4LjqCtvzyGP293QcxTJ7Lo75f7JjOAJP3W5yp4CiKRAVuH5MtWpvo7ryDtMFz i4jDGzLy7aG5c07lAXorf7etqeUG4ti2THkpl4Pl5N4VjhCaAQvBh+zuvqBpue/ChW5q GPkiN80WRdLr/ITBQd4kPSb2Wp7rH42C3abAIZzxPmPdVZMnjCxDg7rbUbaOeiom2pjP BhZ8vn+XysK7S+6EWyghBcLpbo20XZl3pKYBT+y+773NB05P05laLT6RGZyuV0IwgejA cn3a/8Rb6R9Gl3jRiEUDxW+b9Ut/C2i9kNS1PvV+OEaP/Hp7CL/b+0dweVERR7XEfGGO ocxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677621166; 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=w+zwAHBnS5+TovEmhkYJhNFoHDMUmuJ8ck612nZS1t8=; b=kM/ObdNidMf17Vsg/zLEbD7mGcClhKZjFG0dkSZXByJuGGwF3E9Vjvxs1e3QGDLRpP gqvAnCJY6MWYFrDh5Qf/N+/AwblecqRp1p8iy5a7kDjWuOERtYc3xyc0QK7KZyMPzJ03 hGT4601BHeVvZl5H6wCCmCB73Zi3H9rHsqaBTUdhPVKEF/R62shu5e8GJE92Xz7mSI44 oL/9JmTzKl1dQUFSe2trDfPqflNzDAHV3sE5M9q+QHyvCFpFDsEpFPkqSDvyVfvAwfbt 54Th6PASD8SYhj3o7XZvjyr8+eEtWYqZjQ2fsHGx8JAb5PchRGBsGb0MyodhR0LCcNvw /6rA== X-Gm-Message-State: AO0yUKWFjNRR/i5M/4bIYw8HHcR4oLPstMNwWLiLIX23mCzP0tsdO3DL r0cBBPgpYZKBGfWsAd4RHf2isA== X-Google-Smtp-Source: AK7set/juip8p0MiLlYoPEIxqV9PMajgZBFayKyd5KvUfxhWs1VFVopVgOhH6LHgXjliJBQQwUAyQA== X-Received: by 2002:a17:902:e851:b0:19a:839f:435 with SMTP id t17-20020a170902e85100b0019a839f0435mr13658248plg.3.1677621166383; Tue, 28 Feb 2023 13:52:46 -0800 (PST) Received: from localhost ([50.221.140.188]) by smtp.gmail.com with ESMTPSA id jj13-20020a170903048d00b001967692d6f5sm6945909plb.227.2023.02.28.13.52.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 13:52:45 -0800 (PST) Date: Tue, 28 Feb 2023 13:52:45 -0800 (PST) X-Google-Original-Date: Tue, 28 Feb 2023 13:51:58 PST (-0800) Subject: Re: [PATCH 0/2] riscv: support ELF format binaries in nommu mode In-Reply-To: <20230228135126.1686427-1-gerg@kernel.org> CC: linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, gerg@kernel.org From: Palmer Dabbelt To: gerg@kernel.org, damien.lemoal@opensource.wdc.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: ADA7D18001B X-Stat-Signature: rksc1sza4buzihxtx3esj1n8aset77bj X-Rspam-User: X-HE-Tag: 1677621167-137509 X-HE-Meta: U2FsdGVkX19/+TMvyRVUf22ZNOqTdnu0GOlTWc5O3qqmYsczO+fuoI1wnZmQib+NnqUrprKtThGfNBr2crRAcnYM2pZA18hbtvCziygFysEloNyOKN6G4yiYTdnLMKo5nSJPMFXZ6om1e2xw6qVpoE+LfLSs63Bw3X5ZA0mpMWG8h46f+p0epLDkiGQW5qvmSKyfb1JVfL2buPqr6XxuX93Joi4aO0hDb+4N+FM7mM3fKDr79RneAP/IaC+CUtmlZY+gDZ9Qa0PYHzg9denUoM5K7ONfkXE9McWgJAPAFVFqfJ4db46HOdknA86wm8sR44AdEptuvNyTX5r8ivPlNt8e6Z+jkatFPKydz6ot3A4ZElX7HIXKP847pcRWR9lpFAVvWypXBTMxLOTruYPh3JI+bhcsf0DGd/0bRdUPZGGsnWbVo2lOUhkZ1UiW43zQujStp5v/pT4aQWybKKAcpQ2qHHTSn042yyrOtM5PXtW7pAxzJKzrDaLlXfZrahdvfCbKEr0o4ApXCPT1sdJq/7uIdqjCS97FgNpN5zsa2/6gi1sYDZpPMK4UCScYSVZZMQBCmbgLH/jKr1mkGMgbkSFeyNAnFpH5tPJ0yKeq3UEJYZ7R3ZrkTdnyEJBxbw/2605kQ6SmwUMO7WcUPSKh7e+XnMC1PipaX70qeH2QjaFGg5m13VkNP2ejgbhzb8cHf7zxnMUoLG9bQs7n2Bku94lmK2BFxanjE9Wcqkbb2t3e32Q4nUIVf8ookia/wFr0Kj4GpwvNY80PoQXlbD8lN6+u4fniB/tYEbYdQSr1iIJJZgGX93NHi3HV1KQl5Knmk3MccOEY9M05fABKEhQJ/t8Urty9vK9dLuTsqjp0U712I46ayW3PYGHXB3W6n6c7KM02VZjNc8Za0tfycB75g/woIY0nBK5AaelLz3mOZKG+cyqft3ggCtwIpqgI+VnSf+WjGtdN9x5+omCoDO0 IG7B0G+a JV2FgZ1vPoKZoHlCpBUcH4Sa9dO6CaRLtAerKBd8UpbDhD4A+ymwucc6QE1ivgxQSAVa7j2f1jtMf/38eFTQfDULJNLcWSBWT/eGi/U8Bn5gbEb1ghsXBSkrFPx9Kk07NA1dhFWPqAjANooxMQoEGcuGO3o8pmthqp5R9Sbh5WjMHDsKhuRRT9sRFwUmVO08FCtwUcOz6ebxWffm+3d9r+/DfSrA3YJ0SsjQeDcMzxHIxqc09NvlEAgy4I0x/ZucwGUnNzPsYBR7ySLdaDKmrvquXATlJCiWmSO65GMaRt3o77H1H1dz9+JdlmhAv5dLCdTcGmJ9pxK0kx4EW8SNBkbu75yThBxBcgaBTBtwiu0g7YMumzIt39Ufyg228yWMwjvaFWvtg4SNMdBGpWi5fpSpCxMjc193oPHwmRRvrNLgL6AVQIOAeR+K8l9HMNB/THQB+mfBljzXsw0Nb9wXm+eM2nNB2NYxaafyk3ZJnQmHT4B4I5oHJ7yTTYLcQ/v7dzFza 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 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). 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. Thanks!