diff --git a/configure b/configure
index 43d87c5..82b9825 100755
--- a/configure
+++ b/configure
@@ -225,6 +225,7 @@ blobs="yes"
 pkgversion=""
 check_utests="no"
 user_pie="no"
+user_mode_stacksize="512*1024"

 # OS specific
 if check_define __linux__ ; then
@@ -517,6 +518,8 @@ for opt do
   ;;
   --disable-user-pie) user_pie="no"
   ;;
+  --user-mode-stacksize=*) user_mode_stacksize="$optarg"
+  ;;
   --enable-uname-release=*) uname_release="$optarg"
   ;;
   --sparc_cpu=*)
@@ -1841,6 +1844,7 @@ echo "uname -r          $uname_release"
 echo "NPTL support      $nptl"
 echo "GUEST_BASE        $guest_base"
 echo "PIE user targets  $user_pie"
+echo "User mode stacksize  $user_mode_stacksize"
 echo "vde support       $vde"
 echo "IO thread         $io_thread"
 echo "Linux AIO support $linux_aio"
@@ -2361,6 +2365,7 @@ if test "$target_user_only" = "yes" ; then
 fi
 if test "$target_linux_user" = "yes" ; then
   echo "CONFIG_LINUX_USER=y" >> $config_target_mak
+  echo "CONFIG_USER_MODE_STACKSIZE=$user_mode_stacksize" >> $config_target_mak
 fi
 if test "$target_darwin_user" = "yes" ; then
   echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
diff --git a/linux-user/main.c b/linux-user/main.c
index 81a1ada..5d0f849 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -51,7 +51,7 @@ const char *qemu_uname_release = CONFIG_UNAME_RELEASE;
 /* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so
    we allocate a bigger stack. Need a better solution, for example
    by remapping the process stack directly at the right place */
-unsigned long x86_stack_size = 512 * 1024;
+unsigned long x86_stack_size = CONFIG_USER_MODE_STACKSIZE;

 void gemu_log(const char *fmt, ...)
 {
