All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Ungerer <gerg@kernel.org>
To: linux-riscv@lists.infradead.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Cc: palmer@dabbelt.com, viro@zeniv.linux.org.uk,
	ebiederm@xmission.com, keescook@chromium.org, brauner@kernel.org,
	Greg Ungerer <gerg@kernel.org>
Subject: [PATCH v2 0/2] riscv: support ELF format binaries in nommu mode
Date: Tue, 11 Jul 2023 23:07:52 +1000	[thread overview]
Message-ID: <20230711130754.481209-1-gerg@kernel.org> (raw)


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 <gerg@kernel.org>
---
v1->v2: rebase onto 6.5-rc1

 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(-)



WARNING: multiple messages have this Message-ID (diff)
From: Greg Ungerer <gerg@kernel.org>
To: linux-riscv@lists.infradead.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Cc: palmer@dabbelt.com, viro@zeniv.linux.org.uk,
	ebiederm@xmission.com, keescook@chromium.org, brauner@kernel.org,
	Greg Ungerer <gerg@kernel.org>
Subject: [PATCH v2 0/2] riscv: support ELF format binaries in nommu mode
Date: Tue, 11 Jul 2023 23:07:52 +1000	[thread overview]
Message-ID: <20230711130754.481209-1-gerg@kernel.org> (raw)


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 <gerg@kernel.org>
---
v1->v2: rebase onto 6.5-rc1

 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(-)



_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

             reply	other threads:[~2023-07-11 13:08 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-11 13:07 Greg Ungerer [this message]
2023-07-11 13:07 ` [PATCH v2 0/2] riscv: support ELF format binaries in nommu mode Greg Ungerer
2023-07-11 13:07 ` [PATCH v2 1/2] binfmt_elf_fdpic: support 64-bit systems Greg Ungerer
2023-07-11 13:07   ` Greg Ungerer
2023-07-11 15:51   ` Kees Cook
2023-07-11 15:51     ` Kees Cook
2023-07-11 13:07 ` [PATCH v2 2/2] riscv: support the elf-fdpic binfmt loader Greg Ungerer
2023-07-11 13:07   ` Greg Ungerer
2023-07-11 15:53   ` Kees Cook
2023-07-11 15:53     ` Kees Cook
2023-07-12  1:42     ` Greg Ungerer
2023-07-12  1:42       ` Greg Ungerer
2023-07-12 15:12   ` Stefan O'Rear
2023-07-12 15:12     ` Stefan O'Rear
2023-07-13 13:17     ` Greg Ungerer
2023-07-13 13:17       ` Greg Ungerer
2023-07-13 14:26       ` Stefan O'Rear
2023-07-13 14:26         ` Stefan O'Rear
2023-07-14 13:51         ` Greg Ungerer
2023-07-14 13:51           ` Greg Ungerer
2023-07-14 16:40           ` Stefan O'Rear
2023-07-14 16:40             ` Stefan O'Rear
2023-08-30 13:20 ` [PATCH v2 0/2] riscv: support ELF format binaries in nommu mode patchwork-bot+linux-riscv
2023-08-30 13:20   ` patchwork-bot+linux-riscv

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230711130754.481209-1-gerg@kernel.org \
    --to=gerg@kernel.org \
    --cc=brauner@kernel.org \
    --cc=ebiederm@xmission.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.