فهرست منبع

linux-user/hppa: Increase guest stack size to 80MB for hppa target

The hppa target requires a much bigger stack than many other targets,
and the Linux kernel allocates 80 MB by default for it.

This patch increases the guest stack for hppa to 80MB, and prevents
that this default stack size gets reduced by a lower stack limit on the
host.

Since the stack grows upwards on hppa, the stack_limit value marks the
upper boundary of the stack. Fix the output of /proc/self/maps (in the
guest) to show the [stack] marker on the correct memory area.

Signed-off-by: Helge Deller <deller@gmx.de>
Message-Id: <20220924114501.21767-6-deller@gmx.de>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Helge Deller 2 سال پیش
والد
کامیت
0a3346b593
3فایلهای تغییر یافته به همراه13 افزوده شده و 2 حذف شده
  1. 2 0
      linux-user/hppa/target_syscall.h
  2. 7 2
      linux-user/main.c
  3. 4 0
      linux-user/syscall.c

+ 2 - 0
linux-user/hppa/target_syscall.h

@@ -26,4 +26,6 @@ struct target_pt_regs {
 #define TARGET_MCL_FUTURE  2
 #define TARGET_MCL_FUTURE  2
 #define TARGET_MCL_ONFAULT 4
 #define TARGET_MCL_ONFAULT 4
 
 
+#define TARGET_DEFAULT_STACK_SIZE	80 * 1024 * 1024UL
+
 #endif /* HPPA_TARGET_SYSCALL_H */
 #endif /* HPPA_TARGET_SYSCALL_H */

+ 7 - 2
linux-user/main.c

@@ -124,10 +124,14 @@ static void usage(int exitcode);
 static const char *interp_prefix = CONFIG_QEMU_INTERP_PREFIX;
 static const char *interp_prefix = CONFIG_QEMU_INTERP_PREFIX;
 const char *qemu_uname_release;
 const char *qemu_uname_release;
 
 
+#if !defined(TARGET_DEFAULT_STACK_SIZE)
 /* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so
 /* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so
    we allocate a bigger stack. Need a better solution, for example
    we allocate a bigger stack. Need a better solution, for example
    by remapping the process stack directly at the right place */
    by remapping the process stack directly at the right place */
-unsigned long guest_stack_size = 8 * 1024 * 1024UL;
+#define TARGET_DEFAULT_STACK_SIZE	8 * 1024 * 1024UL
+#endif
+
+unsigned long guest_stack_size = TARGET_DEFAULT_STACK_SIZE;
 
 
 /***********************************************************/
 /***********************************************************/
 /* Helper routines for implementing atomic operations.  */
 /* Helper routines for implementing atomic operations.  */
@@ -668,7 +672,8 @@ int main(int argc, char **argv, char **envp)
         struct rlimit lim;
         struct rlimit lim;
         if (getrlimit(RLIMIT_STACK, &lim) == 0
         if (getrlimit(RLIMIT_STACK, &lim) == 0
             && lim.rlim_cur != RLIM_INFINITY
             && lim.rlim_cur != RLIM_INFINITY
-            && lim.rlim_cur == (target_long)lim.rlim_cur) {
+            && lim.rlim_cur == (target_long)lim.rlim_cur
+            && lim.rlim_cur > guest_stack_size) {
             guest_stack_size = lim.rlim_cur;
             guest_stack_size = lim.rlim_cur;
         }
         }
     }
     }

+ 4 - 0
linux-user/syscall.c

@@ -8036,7 +8036,11 @@ static int open_self_maps(CPUArchState *cpu_env, int fd)
                 continue;
                 continue;
             }
             }
 
 
+#ifdef TARGET_HPPA
+            if (h2g(max) == ts->info->stack_limit) {
+#else
             if (h2g(min) == ts->info->stack_limit) {
             if (h2g(min) == ts->info->stack_limit) {
+#endif
                 path = "[stack]";
                 path = "[stack]";
             } else {
             } else {
                 path = e->path;
                 path = e->path;