ltp.lists.linux.it archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Rob Landley <rob@landley.net>
Cc: Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Niklas Cassel <niklas.cassel@wdc.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Linux-sh list <linux-sh@vger.kernel.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-m68k@lists.linux-m68k.org"
	<linux-m68k@lists.linux-m68k.org>,
	Christophe Lyon <christophe.lyon@linaro.org>,
	John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>,
	linux-riscv <linux-riscv@lists.infradead.org>,
	"buildroot@buildroot.org" <buildroot@buildroot.org>,
	Greg Ungerer <gerg@linux-m68k.org>,
	"ltp@lists.linux.it" <ltp@lists.linux.it>,
	"automated-testing@lists.yoctoproject.org"
	<automated-testing@lists.yoctoproject.org>
Subject: Re: [LTP] [Automated-testing] Call for nommu LTP maintainer [was: Re: [PATCH 00/36] Remove UCLINUX from LTP]
Date: Thu, 11 Jan 2024 14:11:43 +0100	[thread overview]
Message-ID: <CAMuHMdX5ACKVBQvEwMi7KHZkSVGZPJoocEC1wosfB7zc0u2mbA@mail.gmail.com> (raw)
In-Reply-To: <40996ea1-3417-1c2f-ddd2-e6ed45cb6f4b@landley.net>

Hi Rob,

On Wed, Jan 10, 2024 at 8:17 PM Rob Landley <rob@landley.net> wrote:
> You can't fork() on nommu because copies of the mappings have different
> addresses, meaning any pointers in the copied mappings would point into the OLD
> mappings (belonging to the parent process), and fixing them up is 100%
> equivalent to the "garbage collection in C" problem. (It's AI-complete. Of the
> C3PO kind, not the "autocorrect with syntax checking" kind.) People get hung up
> on the "it would be very inefficient to do that because no copy-on-write"
> problem and miss the "the child couldn't FUNCTION because its pointer variables
> all contain parent addresses" problem.

Actually you can implement fork(), if you teach the compiler to use
separate stacks for return addresses and data:
  - The first stack would contain only absolute addresses, to be
    relocated after copying,
  - The second stack would contain integers and relative pointers
    (see FDPIC below), which do not need relocation after copying.

> The OTHER fun thing about nommu is you can't run conventional ELF binaries,
> because everything is linked at fixed address. So you might be able to run ONE
> instance of the program as your init task, assuming those addresses were
> available even then, but as soon as you try to run a second one it's a conflict.
>
> The quick and dirty work around is to make PIE binaries, which can relocate
> everything into available space, which works but doesn't scale. The problem with
> ELF PIE is that everything is linked contiguously from a single base pointer,
> meaning your text, rodata, data, and bss segments are all one linear blob. So if
> you run two instances of bash, you've loaded two copies of the test and the
> rodoata. This fills up your memory fast.
>
> AND PIE requires contiguous memory, which nommu is bad at providing because it
> has no page tables to remap stuff. With an mmu it can coalesce scattered
> physical pages into a virtually contiguous range, but without an mmu you can
> have plenty of memory free but in tiny chunks, none big enough to satisfy an
> allocation request.
>
> So they invented FDPIC, which is ELF with FOUR base pointers. Each major section
> (rodata, text, data, and bss) has its own base pointer, so you need to find
> smaller chunks of memory to load them into (and thus it can work on a more
> fragmented system), AND it means that two instances of the same program can
> share the read-only sections (rodata and text) so you only need new copies of
> the writeable segments (data and bss. And the heap. And the stack.)

Or Amiga LoadSeg() relocatable binaries and shared libraries ;-)
As this supported splitting code, data, and bss in lots of smaller
hunks, it could counter fragmented memory quite well.

BTW, can't you run and thus test nommu-binaries under normal Linux, too?

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  parent reply	other threads:[~2024-01-11 13:12 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-03  1:52 [LTP] [PATCH 00/36] Remove UCLINUX from LTP Petr Vorel
2024-01-03  7:58 ` Cyril Hrubis
2024-01-03  8:04   ` Cyril Hrubis
2024-01-03  8:39     ` Petr Vorel
2024-01-03  9:46 ` Geert Uytterhoeven
2024-01-03 11:49   ` Petr Vorel
2024-01-03 11:54     ` Geert Uytterhoeven
2024-01-03 12:09       ` Cyril Hrubis
2024-01-03 12:40         ` Petr Vorel
2024-01-05  3:52         ` Rob Landley
2024-01-05 13:11           ` [LTP] Call for nommu LTP maintainer [was: Re: [PATCH 00/36] Remove UCLINUX from LTP] Petr Vorel
2024-01-06  3:58             ` Rob Landley
2024-01-08  9:03               ` Petr Vorel
2024-01-08 10:07                 ` Cyril Hrubis
2024-01-09 22:37                   ` [LTP] [Automated-testing] " Bird, Tim
2024-01-10  5:01                     ` Rob Landley
2024-01-10 14:14                     ` Petr Vorel
2024-01-10 19:23                       ` Rob Landley
2024-01-10 21:17                         ` Niklas Cassel via ltp
2024-01-11  0:00                           ` Greg Ungerer
2024-01-11  9:21                             ` Niklas Cassel via ltp
2024-01-12 20:18                               ` Rob Landley
2024-01-11  2:25                         ` Greg Ungerer
2024-01-12 20:16                           ` Rob Landley
2024-01-14 13:01                             ` Greg Ungerer
2024-01-15 13:41                             ` [LTP] [Buildroot] " Waldemar Brodkorb
2024-01-15 14:22                               ` Cyril Hrubis
2024-01-11 13:11                         ` Geert Uytterhoeven [this message]
2024-01-11 13:19                           ` [LTP] " Greg Ungerer
2024-01-09 20:24                 ` [LTP] " Rob Landley
2024-01-09 23:17                   ` Greg Ungerer
2024-01-10  5:47                     ` Rob Landley
2024-01-10 14:46                       ` Greg Ungerer
2024-01-10 13:33                   ` Petr Vorel
2024-01-10 18:23                     ` Rob Landley
2024-01-10 22:33                       ` Petr Vorel
2024-01-08  8:33           ` [LTP] [PATCH 00/36] Remove UCLINUX from LTP Andrea Cervesato via ltp
2024-01-08  8:34           ` Andrea Cervesato via ltp
2024-01-05  3:50   ` Rob Landley

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=CAMuHMdX5ACKVBQvEwMi7KHZkSVGZPJoocEC1wosfB7zc0u2mbA@mail.gmail.com \
    --to=geert@linux-m68k.org \
    --cc=automated-testing@lists.yoctoproject.org \
    --cc=buildroot@buildroot.org \
    --cc=christophe.lyon@linaro.org \
    --cc=corbet@lwn.net \
    --cc=gerg@linux-m68k.org \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=ltp@lists.linux.it \
    --cc=niklas.cassel@wdc.com \
    --cc=rdunlap@infradead.org \
    --cc=rob@landley.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).