From: Greg Ungerer <gerg@linux-m68k.org>
To: Geert Uytterhoeven <geert@linux-m68k.org>, Rob Landley <rob@landley.net>
Cc: Petr Vorel <pvorel@suse.cz>, Tim Bird <tim.bird@sony.com>,
Cyril Hrubis <chrubis@suse.cz>,
"ltp@lists.linux.it" <ltp@lists.linux.it>,
Li Wang <liwang@redhat.com>,
Andrea Cervesato <andrea.cervesato@suse.com>,
Jonathan Corbet <corbet@lwn.net>,
Randy Dunlap <rdunlap@infradead.org>,
John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>,
Christophe Lyon <christophe.lyon@linaro.org>,
"linux-m68k@lists.linux-m68k.org"
<linux-m68k@lists.linux-m68k.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Linux ARM <linux-arm-kernel@lists.infradead.org>,
linux-riscv <linux-riscv@lists.infradead.org>,
Linux-sh list <linux-sh@vger.kernel.org>,
"automated-testing@lists.yoctoproject.org"
<automated-testing@lists.yoctoproject.org>,
"buildroot@buildroot.org" <buildroot@buildroot.org>,
Niklas Cassel <niklas.cassel@wdc.com>
Subject: Re: [Automated-testing] Call for nommu LTP maintainer [was: Re: [PATCH 00/36] Remove UCLINUX from LTP]
Date: Thu, 11 Jan 2024 23:19:18 +1000 [thread overview]
Message-ID: <d602919e-2cfb-455a-8a90-76f649d92b39@linux-m68k.org> (raw)
In-Reply-To: <CAMuHMdX5ACKVBQvEwMi7KHZkSVGZPJoocEC1wosfB7zc0u2mbA@mail.gmail.com>
On 11/1/24 23:11, Geert Uytterhoeven wrote:
> 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?
Yes, you can. The flat format loader can be built for MMU arm and m68k Linux.
It will happily load and run flat format binaries on normal VM Linux.
I test that often on m68k (on ColdFire platforms).
Regards
Greg
next prev parent reply other threads:[~2024-01-11 13:19 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240103015240.1065284-1-pvorel@suse.cz>
2024-01-03 9:46 ` [PATCH 00/36] Remove UCLINUX from LTP 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 ` 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 ` [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
2024-01-11 0:00 ` Greg Ungerer
2024-01-11 9:21 ` Niklas Cassel
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 ` [Buildroot] " Waldemar Brodkorb
2024-01-15 14:22 ` Cyril Hrubis
2024-01-11 13:11 ` Geert Uytterhoeven
2024-01-11 13:19 ` Greg Ungerer [this message]
2024-01-09 20:24 ` 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 ` [PATCH 00/36] Remove UCLINUX from LTP Andrea Cervesato
2024-01-08 8:34 ` Andrea Cervesato
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=d602919e-2cfb-455a-8a90-76f649d92b39@linux-m68k.org \
--to=gerg@linux-m68k.org \
--cc=andrea.cervesato@suse.com \
--cc=automated-testing@lists.yoctoproject.org \
--cc=buildroot@buildroot.org \
--cc=christophe.lyon@linaro.org \
--cc=chrubis@suse.cz \
--cc=corbet@lwn.net \
--cc=geert@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=liwang@redhat.com \
--cc=ltp@lists.linux.it \
--cc=niklas.cassel@wdc.com \
--cc=pvorel@suse.cz \
--cc=rdunlap@infradead.org \
--cc=rob@landley.net \
--cc=tim.bird@sony.com \
/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).