linux-user/hppa: Allow PROT_GROWSUP and PROT_GROWSDOWN in mprotect()
commit4c184e70ad01289f89a9a780d154b00d6a86cccd
authorHelge Deller <deller@gmx.de>
Sat, 24 Sep 2022 11:45:00 +0000 (24 13:45 +0200)
committerLaurent Vivier <laurent@vivier.eu>
Tue, 27 Sep 2022 11:18:53 +0000 (27 13:18 +0200)
treed6f452ac3b3b6695e0cdff047ff376b79f595920
parent0a3346b5938530178e20abea5219e80130cf0204
linux-user/hppa: Allow PROT_GROWSUP and PROT_GROWSDOWN in mprotect()

The hppa platform uses an upwards-growing stack and required in Linux
kernels < 5.18 an executable stack for signal processing.  For that some
executables and libraries are marked to have an executable stack, for
which glibc uses the mprotect() syscall to mark the stack like this:
 mprotect(xfa000000,4096,PROT_EXEC|PROT_READ|PROT_WRITE|PROT_GROWSUP).

Currently qemu will return -TARGET_EINVAL for this syscall because of the
checks in validate_prot_to_pageflags(), which doesn't allow the
PROT_GROWSUP or PROT_GROWSDOWN flags and thus triggers this error in the
guest:
 error while loading shared libraries: libc.so.6: cannot enable executable stack as shared object requires: Invalid argument

Allow mprotect() to handle both flags and thus fix the guest.
The glibc tst-execstack testcase can be used to reproduce the issue.

Signed-off-by: Helge Deller <deller@gmx.de>
Message-Id: <20220924114501.21767-7-deller@gmx.de>
[lvivier: s/elif TARGET_HPPA/elif defined(TARGET_HPPA)/]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
linux-user/mmap.c