Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1730828
| From | Geert Uytterhoeven <geert@linux-m68k.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: execve(NULL, argv, envp) for nommu? |
| Date | 2017-09-12 13:40 +0200 |
| Message-ID | <uoRHP-Fn-5@gated-at.bofh.it> (permalink) |
| References | (2 earlier) <umm5r-38R-5@gated-at.bofh.it> <umxay-2mO-5@gated-at.bofh.it> <unyQW-46I-15@gated-at.bofh.it> <uoyFc-57i-23@gated-at.bofh.it> <uoQVs-ah-21@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Hi Rob,
On Tue, Sep 12, 2017 at 12:48 PM, Rob Landley <rob@landley.net> wrote:
> A nommu system doesn't have a memory management unit, so all addresses
> are physical addresses. This means two processes can't see different
> things at the same address: either they see the same thing or one of
> them can't see that address (due to a range register making it).
>
> Conventional fork() creates copy on write mappings of all the existing
> writable memory of the parent process. So when the new PID dirties a
> page, the old page gets copied by the fault handler. The problem isn't
> the copies (that's just slow), the problem is two processes seeing
> different things at the same address. That requires an MMU with a TLB
> loaded from page tables.
>
> If you create _new_ mappings and copy the data over, they'll have
> different addresses. But any pointers you copied will point to the _old_
> addresses. Finding and adjusting all those pointers to point to the new
> addresses instead is basically the same problem as doing garbage
> collection in C.
>
> Your stack has pointers. Your heap has pointers. Your data and bss (once
> initialized) can have pointers. These pointers can be in the middle of
> malloc()'ed structures so no ELF table anywhere knows anything about
> them. A long variable containing a value that _could_ point into one of
> these ranges isn't guaranteed to _be_ a pointer, in which case adjusting
> it is breakage. Tracking them all down and fixing up just the right ones
> without missing any or changing data you shouldn't is REALLY HARD.
Hence (make the compiler) never store pointers, only offsets relative to a
base register. So after making copies of stack, data/bss, and heap, all you
need to do is adjust these base registers for the child process.
Nothing in main memory needs to be modified.
Text accesses can be PC-relative => nothing to adjust.
Local variable accesses are stack-relative => nothing to adjust.
Data/bss accesses can be relative to a reserved register that stores the
data base address => only adjust the base register, nothing in RAM to adjust.
Heap accesses can be relative to a reserved register that stores the heap
base address => only adjust the base register, nothing in RAM to adjust.
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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: execve(NULL, argv, envp) for nommu? Oleg Nesterov <oleg@redhat.com> - 2017-09-11 17:20 +0200
Re: execve(NULL, argv, envp) for nommu? Rob Landley <rob@landley.net> - 2017-09-12 12:50 +0200
Re: execve(NULL, argv, envp) for nommu? Geert Uytterhoeven <geert@linux-m68k.org> - 2017-09-12 13:40 +0200
Re: execve(NULL, argv, envp) for nommu? Rob Landley <rob@landley.net> - 2017-09-12 15:50 +0200
Re: execve(NULL, argv, envp) for nommu? Alan Cox <gnomes@lxorguk.ukuu.org.uk> - 2017-09-13 21:40 +0200
Re: execve(NULL, argv, envp) for nommu? Oleg Nesterov <oleg@redhat.com> - 2017-09-12 17:50 +0200
Re: execve(NULL, argv, envp) for nommu? Oleg Nesterov <oleg@redhat.com> - 2017-09-13 16:30 +0200
csiph-web