[PATCH for 6.2 25/49] bsd-user: define max args in terms of pages

Warner Losh posted 49 patches 4 years, 4 months ago
Maintainers: Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>
There is a newer version of this series
[PATCH for 6.2 25/49] bsd-user: define max args in terms of pages
Posted by Warner Losh 4 years, 4 months ago
From: Warner Losh <imp@FreeBSD.org>

For 32-bit platforms, pass in up to 256k of args. For 64-bit, bump that
to 512k.

Signed-off-by: Kyle Evans <kevans@freebsd.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/qemu.h | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 02e6e8327a..9322187891 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -107,11 +107,17 @@ extern const char *qemu_uname_release;
 extern unsigned long mmap_min_addr;
 
 /*
- * MAX_ARG_PAGES defines the number of pages allocated for arguments
- * and envelope for the new program. 32 should suffice, this gives
- * a maximum env+arg of 128kB w/4KB pages!
+ * TARGET_ARG_MAX defines the number of bytes allocated for arguments
+ * and envelope for the new program. 256k should suffice for a reasonable
+ * maxiumum env+arg in 32-bit environments, bump it up to 512k for !ILP32
+ * platforms.
  */
-#define MAX_ARG_PAGES 32
+#if TARGET_ABI_BITS > 32
+#define TARGET_ARG_MAX (512 * 1024)
+#else
+#define TARGET_ARG_MAX (256 * 1024)
+#endif
+#define MAX_ARG_PAGES (TARGET_ARG_MAX / TARGET_PAGE_SIZE)
 
 /*
  * This structure is used to hold the arguments that are
-- 
2.32.0


Re: [PATCH for 6.2 25/49] bsd-user: define max args in terms of pages
Posted by Richard Henderson 4 years, 4 months ago
On 8/7/21 11:42 AM, Warner Losh wrote:
> From: Warner Losh <imp@FreeBSD.org>
> 
> For 32-bit platforms, pass in up to 256k of args. For 64-bit, bump that
> to 512k.
> 
> Signed-off-by: Kyle Evans <kevans@freebsd.org>
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>   bsd-user/qemu.h | 14 ++++++++++----
>   1 file changed, 10 insertions(+), 4 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

> +#define TARGET_ARG_MAX (512 * 1024)
> +#else
> +#define TARGET_ARG_MAX (256 * 1024)

For the to-do list: qemu/units.h has KiB for clarity.


r~

Re: [PATCH for 6.2 25/49] bsd-user: define max args in terms of pages
Posted by Warner Losh 4 years, 4 months ago
On Mon, Aug 9, 2021 at 2:33 PM Richard Henderson <
richard.henderson@linaro.org> wrote:

> On 8/7/21 11:42 AM, Warner Losh wrote:
> > From: Warner Losh <imp@FreeBSD.org>
> >
> > For 32-bit platforms, pass in up to 256k of args. For 64-bit, bump that
> > to 512k.
> >
> > Signed-off-by: Kyle Evans <kevans@freebsd.org>
> > Signed-off-by: Warner Losh <imp@bsdimp.com>
> > ---
> >   bsd-user/qemu.h | 14 ++++++++++----
> >   1 file changed, 10 insertions(+), 4 deletions(-)
>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>
> > +#define TARGET_ARG_MAX (512 * 1024)
> > +#else
> > +#define TARGET_ARG_MAX (256 * 1024)
>
> For the to-do list: qemu/units.h has KiB for clarity.
>

OK. Will change. Thanks!

Warner