[PULL 11/11] linux-user: Fix MADV_XXX constants on hppa target

deller@kernel.org posted 11 patches 1 day, 13 hours ago
Maintainers: Laurent Vivier <laurent@vivier.eu>
There is a newer version of this series
[PULL 11/11] linux-user: Fix MADV_XXX constants on hppa target
Posted by deller@kernel.org 1 day, 13 hours ago
From: Helge Deller <deller@gmx.de>

Older hppa binaries may still use the old MADV_XXX constants for the
madivise() syscall. Fix it up in the same manner as it's done in the
Linux kernel in the parisc_madvise() function.

Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
---
 linux-user/syscall.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 64a2f1cbb2..2788c3239e 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -12922,6 +12922,20 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
 
 #ifdef TARGET_NR_madvise
     case TARGET_NR_madvise:
+#ifdef TARGET_HPPA
+        /* Emulate old hppa mapping of MADV_xxx constants. */
+        switch (arg3) {
+        case 65: arg3 = MADV_MERGEABLE;     break;
+        case 66: arg3 = MADV_UNMERGEABLE;   break;
+        case 67: arg3 = MADV_HUGEPAGE;      break;
+        case 68: arg3 = MADV_NOHUGEPAGE;    break;
+        case 69: arg3 = MADV_DONTDUMP;      break;
+        case 70: arg3 = MADV_DODUMP;        break;
+        case 71: arg3 = MADV_WIPEONFORK;    break;
+        case 72: arg3 = MADV_KEEPONFORK;    break;
+        case 73: arg3 = MADV_COLLAPSE;      break;
+        }
+#endif /* TARGET_HPPA */
         return target_madvise(arg1, arg2, arg3);
 #endif
 #ifdef TARGET_NR_fcntl64
-- 
2.52.0
Re: [PULL 11/11] linux-user: Fix MADV_XXX constants on hppa target
Posted by Richard Henderson 1 day, 9 hours ago
On 1/24/26 07:52, deller@kernel.org wrote:
> From: Helge Deller <deller@gmx.de>
> 
> Older hppa binaries may still use the old MADV_XXX constants for the
> madivise() syscall. Fix it up in the same manner as it's done in the
> Linux kernel in the parisc_madvise() function.
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   linux-user/syscall.c | 14 ++++++++++++++
>   1 file changed, 14 insertions(+)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 64a2f1cbb2..2788c3239e 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -12922,6 +12922,20 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
>   
>   #ifdef TARGET_NR_madvise
>       case TARGET_NR_madvise:
> +#ifdef TARGET_HPPA
> +        /* Emulate old hppa mapping of MADV_xxx constants. */
> +        switch (arg3) {
> +        case 65: arg3 = MADV_MERGEABLE;     break;
> +        case 66: arg3 = MADV_UNMERGEABLE;   break;
> +        case 67: arg3 = MADV_HUGEPAGE;      break;
> +        case 68: arg3 = MADV_NOHUGEPAGE;    break;
> +        case 69: arg3 = MADV_DONTDUMP;      break;
> +        case 70: arg3 = MADV_DODUMP;        break;
> +        case 71: arg3 = MADV_WIPEONFORK;    break;
> +        case 72: arg3 = MADV_KEEPONFORK;    break;
> +        case 73: arg3 = MADV_COLLAPSE;      break;
> +        }
> +#endif /* TARGET_HPPA */

Build failure:

https://gitlab.com/qemu-project/qemu/-/jobs/12848016272

> ../linux-user/syscall.c: In function ‘do_syscall1’:
> ../linux-user/syscall.c:12936:25: error: ‘MADV_COLLAPSE’ undeclared (first use in this function); did you mean ‘MADV_COLD’?
> 12936 |         case 73: arg3 = MADV_COLLAPSE;      break;
>       |                         ^~~~~~~~~~~~~
>       |                         MADV_COLD


r~