qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v8 10/17] linux-user: Define ELF_ET_DYN_BASE in $guest/target


From: Helge Deller
Subject: Re: [PATCH v8 10/17] linux-user: Define ELF_ET_DYN_BASE in $guest/target_mman.h
Date: Fri, 4 Aug 2023 11:50:50 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

On 8/4/23 03:45, Richard Henderson wrote:
Copy each guest kernel's default value, then bound it
against reserved_va or the host address space.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
  linux-user/aarch64/target_mman.h     |  3 +++
  linux-user/alpha/target_mman.h       |  3 +++
...

I've successfully tested the whole series on the following
chroots (on x86 host):
alpha, arm64, armhf, hppa, m68k, mips64el, mipsel
powerpc, ppc64, ppc64el, s390x, sh4, sparc64.
Both static and dynamically linked programs work as expected.

It's a big step forward compared to qemu v8.0, so feel free
to add to the whole series:
Tested-by: Helge Deller <deller@gmx.de>

For this patch:
Reviewed-by: Helge Deller <deller@gmx.de>

One thing to mention here is, that those values (ELF_ET_DYN_BASE)
reflects the legacy (standard) memory layout of the kernel only.
The process personality defines which layout should be used,
ADDR_COMPAT_LAYOUT means to use the legacy (standard) memory layout.

The Linux kernel on 390, parisc, sparc and x86 doesn't use by
default the legacy memory model, but instead allocates new mappings
from top downwards. This leaves much more space for heap.
Search for mmap_is_legacy() in the kernel sources.

That said, we should implement the top-downwards allocation
after qemu 8.1.
In this regard, could you please include my latest patch titled:

   linux-user: Show heap address in /proc/pid/maps

in your patch series? I sent an updated version today to the mailing
list, which applies to your series. .

If applied, the "[heap]" entry is visible in /proc/cpuinfo output, and
it's much easier to see potential future memory isses, e.g.

armhf-chroot:
-> heap is limited in region 21000 to 00400000.
-> 00421000 to 40000000 would give much more space for heap.
-> arm32 doesn't seem to support non-legacy memory model yet...
Linux p100 6.4.6-200.fc38.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jul 24 20:51:12 UTC 
2023 armv7l GNU/Linux
00021000-00042000 rw-p 00000000 00:00 0                                  [heap]
00400000-00406000 r-xp 00000000 fd:00 675877                             
/usr/bin/cat
00406000-0041f000 ---p 00000000 00:00 0
0041f000-00420000 r--p 0000f000 fd:00 675877                             
/usr/bin/cat
00420000-00421000 rw-p 00010000 fd:00 675877                             
/usr/bin/cat
40000000-40001000 ---p 00000000 00:00 0
40001000-40801000 rw-p 00000000 00:00 0                                  [stack]
40801000-4081d000 r-xp 00000000 fd:00 682674                             
/usr/lib/arm-linux-gnueabihf/ld-linux-armhf.so.3
4081d000-4081e000 r--p 0001c000 fd:00 682674                             
/usr/lib/arm-linux-gnueabihf/ld-linux-armhf.so.3
4081e000-4081f000 rw-p 0001d000 fd:00 682674                             
/usr/lib/arm-linux-gnueabihf/ld-linux-armhf.so.3
4081f000-40820000 r-xp 00000000 00:00 0
40820000-40822000 rw-p 00000000 00:00 0
40822000-4092b000 r-xp 00000000 fd:00 682677                             
/usr/lib/arm-linux-gnueabihf/libc.so.6
4092b000-4092d000 r--p 00108000 fd:00 682677                             
/usr/lib/arm-linux-gnueabihf/libc.so.6
4092d000-4092e000 rw-p 0010a000 fd:00 682677                             
/usr/lib/arm-linux-gnueabihf/libc.so.6
4092e000-40938000 rw-p 00000000 00:00 0
ffff0000-ffff1000 r-xp 00000000 00:00 0

mipsel-chroot
-> heap is locked in from 00021000 to 2aaab000
Linux p100 6.4.6-200.fc38.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jul 24 20:51:12 UTC 
2023 mips GNU/Linux
00021000-00042000 rw-p 00000000 00:00 0                                  [heap]
2aaab000-2aaac000 ---p 00000000 00:00 0
2aaac000-2b2ac000 rwxp 00000000 00:00 0                                  [stack]
2b2ac000-2b2d8000 r-xp 00000000 fd:00 816208                             
/usr/lib/mipsel-linux-gnu/ld.so.1
2b2d8000-2b2eb000 ---p 00000000 00:00 0
2b2eb000-2b2ec000 r--p 0002f000 fd:00 816208                             
/usr/lib/mipsel-linux-gnu/ld.so.1
2b2ec000-2b2ed000 rw-p 00030000 fd:00 816208                             
/usr/lib/mipsel-linux-gnu/ld.so.1
2b2ed000-2b2ee000 r-xp 00000000 00:00 0
2b2ee000-2b2f0000 rw-p 00000000 00:00 0
2b2f0000-2b4ae000 r-xp 00000000 fd:00 816216                             
/usr/lib/mipsel-linux-gnu/libc.so.6
2b4ae000-2b4bd000 ---p 001be000 fd:00 816216                             
/usr/lib/mipsel-linux-gnu/libc.so.6
2b4bd000-2b4c0000 r--p 001bd000 fd:00 816216                             
/usr/lib/mipsel-linux-gnu/libc.so.6
2b4c0000-2b4c3000 rw-p 001c0000 fd:00 816216                             
/usr/lib/mipsel-linux-gnu/libc.so.6
2b4c3000-2b4cd000 rw-p 00000000 00:00 0
55550000-55559000 r-xp 00000000 fd:00 818831                             
/usr/bin/cat
55559000-5556f000 ---p 00000000 00:00 0
5556f000-55570000 r--p 0000f000 fd:00 818831                             
/usr/bin/cat
55570000-55571000 rw-p 00010000 fd:00 818831                             
/usr/bin/cat


hppa-chroot
-> heap & stack is ok.
-> heap could greatly benefit if qemu later supports top-down mmap allocation,
   because then the shared libs will be mapped >fa000000 and heap&stack can grow
   from 0001a000 up to fa000000.
Linux p100 6.4.6-200.fc38.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jul 24 20:51:12 UTC 
2023 parisc GNU/Linux
00000000-00001000 --xp 00000000 00:00 0
00010000-00019000 r-xp 00000000 fd:00 1061893                            
/usr/bin/cat
00019000-0001a000 rwxp 00009000 fd:00 1061893                            
/usr/bin/cat
0001a000-0003b000 rw-p 00000000 00:00 0                                  [heap]
40000000-45000000 rwxp 00000000 00:00 0                                  [stack]
45000000-4502f000 r-xp 00000000 fd:00 1069300                            
/usr/lib/hppa-linux-gnu/ld.so.1
4502f000-45030000 r--p 0002f000 fd:00 1069300                            
/usr/lib/hppa-linux-gnu/ld.so.1
45030000-45034000 rwxp 00030000 fd:00 1069300                            
/usr/lib/hppa-linux-gnu/ld.so.1
45034000-45035000 r-xp 00000000 00:00 0
45037000-45039000 rw-p 00000000 00:00 0
45039000-451f5000 r-xp 00000000 fd:00 1069303                            
/usr/lib/hppa-linux-gnu/libc.so.6
451f5000-451f7000 r--p 001bc000 fd:00 1069303                            
/usr/lib/hppa-linux-gnu/libc.so.6
451f7000-451fc000 rwxp 001be000 fd:00 1069303                            
/usr/lib/hppa-linux-gnu/libc.so.6

Thanks!
Helge



reply via email to

[Prev in Thread] Current Thread [Next in Thread]