linux-user: Fix brk() to release pages
commit86f04735ac2088d5c069c3d1712212ec7428c562
authorHelge Deller <deller@gmx.de>
Sun, 25 Dec 2022 08:23:19 +0000 (25 09:23 +0100)
committerLaurent Vivier <laurent@vivier.eu>
Fri, 10 Mar 2023 19:42:00 +0000 (10 20:42 +0100)
tree7dffbd2e4f8081dbeeca902a72aec54d6b7b5922
parent25bb27c715f6ea7cd68561112cbfc1dba4ff46bd
linux-user: Fix brk() to release pages

The current brk() implementation does not de-allocate pages if a lower
address is given compared to earlier brk() calls.
But according to the manpage, brk() shall deallocate memory in this case
and currently it breaks a real-world application, specifically building
the debian gcl package in qemu-user.

Fix this issue by reworking the qemu brk() implementation.

Tested with the C-code testcase included in qemu commit 4d1de87c750, and
by building debian package of gcl in a hppa-linux guest on a x86-64
host.

Signed-off-by: Helge Deller <deller@gmx.de>
Message-Id: <Y6gId80ek49TK1xB@p100>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
linux-user/syscall.c