qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: imp@bsdimp.com
To: qemu-devel@nongnu.org
Cc: kevans@freebsd.org,
	Richard Henderson <richard.henderson@linaro.org>,
	Warner Losh <imp@FreeBSD.org>, Warner Losh <imp@bsdimp.com>,
	Stacey Son <sson@FreeBSD.org>
Subject: [PULL 24/42] bsd-user: Create target specific vmparam.h
Date: Tue,  7 Sep 2021 15:53:14 -0600	[thread overview]
Message-ID: <20210907215332.30737-25-imp@bsdimp.com> (raw)
In-Reply-To: <20210907215332.30737-1-imp@bsdimp.com>

From: Warner Losh <imp@FreeBSD.org>

Target specific values for vm parameters and details.

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
 bsd-user/freebsd/target_os_vmparam.h  | 38 ++++++++++++++++++++++
 bsd-user/i386/target_arch_vmparam.h   | 46 +++++++++++++++++++++++++++
 bsd-user/qemu.h                       |  1 +
 bsd-user/x86_64/target_arch_vmparam.h | 46 +++++++++++++++++++++++++++
 4 files changed, 131 insertions(+)
 create mode 100644 bsd-user/freebsd/target_os_vmparam.h
 create mode 100644 bsd-user/i386/target_arch_vmparam.h
 create mode 100644 bsd-user/x86_64/target_arch_vmparam.h

diff --git a/bsd-user/freebsd/target_os_vmparam.h b/bsd-user/freebsd/target_os_vmparam.h
new file mode 100644
index 0000000000..990300c619
--- /dev/null
+++ b/bsd-user/freebsd/target_os_vmparam.h
@@ -0,0 +1,38 @@
+/*
+ *  FreeBSD VM parameters definitions
+ *
+ *  Copyright (c) 2013 Stacey D. Son
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _TARGET_OS_VMPARAM_H_
+#define _TARGET_OS_VMPARAM_H_
+
+#include "target_arch_vmparam.h"
+
+/* Compare to sys/exec.h */
+struct target_ps_strings {
+    abi_ulong ps_argvstr;
+    uint32_t ps_nargvstr;
+    abi_ulong ps_envstr;
+    uint32_t ps_nenvstr;
+};
+
+extern abi_ulong target_stkbas;
+extern abi_ulong target_stksiz;
+
+#define TARGET_PS_STRINGS  ((target_stkbas + target_stksiz) - \
+                            sizeof(struct target_ps_strings))
+
+#endif /* !TARGET_OS_VMPARAM_H_ */
diff --git a/bsd-user/i386/target_arch_vmparam.h b/bsd-user/i386/target_arch_vmparam.h
new file mode 100644
index 0000000000..bb7718265b
--- /dev/null
+++ b/bsd-user/i386/target_arch_vmparam.h
@@ -0,0 +1,46 @@
+/*
+ *  i386 VM parameters definitions
+ *
+ *  Copyright (c) 2013 Stacey D. Son
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _TARGET_ARCH_VMPARAM_H_
+#define _TARGET_ARCH_VMPARAM_H_
+
+#include "cpu.h"
+
+/* compare to i386/include/vmparam.h */
+#define TARGET_MAXTSIZ  (128 * MiB)             /* max text size */
+#define TARGET_DFLDSIZ  (128 * MiB)             /* initial data size limit */
+#define TARGET_MAXDSIZ  (512 * MiB)             /* max data size */
+#define TARGET_DFLSSIZ  (8 * MiB)               /* initial stack size limit */
+#define TARGET_MAXSSIZ  (64 * MiB)              /* max stack size */
+#define TARGET_SGROWSIZ (128 * KiB)             /* amount to grow stack */
+
+#define TARGET_RESERVED_VA 0xf7000000
+
+#define TARGET_USRSTACK (0xbfc00000)
+
+static inline abi_ulong get_sp_from_cpustate(CPUX86State *state)
+{
+    return state->regs[R_ESP];
+}
+
+static inline void set_second_rval(CPUX86State *state, abi_ulong retval2)
+{
+    state->regs[R_EDX] = retval2;
+}
+
+#endif /* !_TARGET_ARCH_VMPARAM_H_ */
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index fea1a167e4..1b37757e06 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -41,6 +41,7 @@ extern enum BSDType bsd_type;
 #include "target_arch.h"
 #include "syscall_defs.h"
 #include "target_syscall.h"
+#include "target_os_vmparam.h"
 #include "exec/gdbstub.h"
 
 /*
diff --git a/bsd-user/x86_64/target_arch_vmparam.h b/bsd-user/x86_64/target_arch_vmparam.h
new file mode 100644
index 0000000000..81a915f2e5
--- /dev/null
+++ b/bsd-user/x86_64/target_arch_vmparam.h
@@ -0,0 +1,46 @@
+/*
+ *  Intel x86_64 VM parameters definitions
+ *
+ *  Copyright (c) 2013 Stacey D. Son
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _TARGET_ARCH_VMPARAM_H_
+#define _TARGET_ARCH_VMPARAM_H_
+
+#include "cpu.h"
+
+/* compare to amd64/include/vmparam.h */
+#define TARGET_MAXTSIZ  (128 * MiB)             /* max text size */
+#define TARGET_DFLDSIZ  (32 * GiB)              /* initial data size limit */
+#define TARGET_MAXDSIZ  (32 * GiB)              /* max data size */
+#define TARGET_DFLSSIZ  (8 * MiB)               /* initial stack size limit */
+#define TARGET_MAXSSIZ  (512 * MiB)             /* max stack size */
+#define TARGET_SGROWSIZ (128 * KiB)             /* amount to grow stack */
+
+#define TARGET_VM_MAXUSER_ADDRESS   (0x00007fffff000000UL)
+
+#define TARGET_USRSTACK (TARGET_VM_MAXUSER_ADDRESS - TARGET_PAGE_SIZE)
+
+static inline abi_ulong get_sp_from_cpustate(CPUX86State *state)
+{
+    return state->regs[R_ESP];
+}
+
+static inline void set_second_rval(CPUX86State *state, abi_ulong retval2)
+{
+    state->regs[R_EDX] = retval2;
+}
+
+#endif /* !_TARGET_ARCH_VMPARAM_H_ */
-- 
2.32.0



  parent reply	other threads:[~2021-09-07 22:15 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-07 21:52 [PULL 00/42] bsd-user updates to run hello world imp
2021-09-07 21:52 ` [PULL 01/42] bsd-user: remove sparc and sparc64 imp
2021-09-07 21:52 ` [PULL 02/42] bsd-user: add copyright header to elfload.c imp
2021-09-07 21:52 ` [PULL 03/42] bsd-user: Add Stacey's copyright to main.c imp
2021-09-07 21:52 ` [PULL 04/42] bsd-user: add license to bsdload.c imp
2021-09-07 21:52 ` [PULL 05/42] bsd-user: style nits: bsdload.c whitespace to qemu standard imp
2021-09-07 21:52 ` [PULL 06/42] bsd-user: Remove all non-x86 code from elfload.c imp
2021-09-07 21:52 ` [PULL 07/42] bsd-user: move arch specific defines out of elfload.c imp
2021-09-07 21:52 ` [PULL 08/42] bsd-user: pass the bsd_param into loader_exec imp
2021-09-07 21:52 ` [PULL 09/42] bsd-user: Fix calculation of size to allocate imp
2021-09-07 21:53 ` [PULL 10/42] bsd-user: implement path searching imp
2021-09-07 21:53 ` [PULL 11/42] bsd-user: Eliminate elf personality imp
2021-09-07 21:53 ` [PULL 12/42] bsd-user: remove a.out support imp
2021-09-07 21:53 ` [PULL 13/42] bsd-user: TARGET_NGROUPS unused in this file, remove imp
2021-09-07 21:53 ` [PULL 14/42] bsd-user: elfload: simplify bswap a bit imp
2021-09-07 21:53 ` [PULL 15/42] bsd-user: assume pthreads and support of __thread imp
2021-09-07 21:53 ` [PULL 16/42] bsd-user: add host-os.h imp
2021-09-07 21:53 ` [PULL 17/42] bsd-user: Include host-os.h from main imp
2021-09-07 21:53 ` [PULL 18/42] bsd-user: save the path to the qemu emulator imp
2021-09-07 21:53 ` [PULL 19/42] bsd-user: start to move target CPU functions to target_arch* imp
2021-09-07 21:53 ` [PULL 20/42] bsd-user: Move per-cpu code into target_arch_cpu.h imp
2021-09-07 21:53 ` [PULL 21/42] bsd-user: pull in target_arch_thread.h update target_arch_elf.h imp
2021-09-07 21:53 ` [PULL 22/42] bsd-user: Include more things in qemu.h imp
2021-09-07 21:53 ` [PULL 23/42] bsd-user: define max args in terms of pages imp
2021-09-07 21:53 ` imp [this message]
2021-09-07 21:53 ` [PULL 25/42] bsd-user: Add system independent stack, data and text limiting imp
2021-09-07 21:53 ` [PULL 26/42] bsd-user: *BSD specific siginfo defintions imp
2021-09-07 21:53 ` [PULL 27/42] bsd-user: Implement --seed and initialize random state imp
2021-09-07 21:53 ` [PULL 28/42] bsd-user: Move stack initializtion into a per-os file imp
2021-09-07 21:53 ` [PULL 29/42] bsd-user: Add architecture specific signal tramp code imp
2021-09-07 21:53 ` [PULL 30/42] bsd-user: elf cleanup imp
2021-09-07 21:53 ` [PULL 31/42] bsd-user: Remove dead #ifdefs from elfload.c imp
2021-09-07 21:53 ` [PULL 32/42] bsd-user: Rewrite target system call definintion glue imp
2021-09-07 21:53 ` [PULL 33/42] bsd-user: update debugging in mmap.c imp
2021-09-07 21:53 ` [PULL 34/42] bsd-user: Add target_arch_reg to describe a target's register set imp
2021-09-07 21:53 ` [PULL 35/42] bsd-user: Add target_os_user.h to capture the user/kernel structures imp
2021-09-07 21:53 ` [PULL 36/42] bsd-user: add stubbed out core dump support imp
2021-09-07 21:53 ` [PULL 37/42] bsd-user: elfload.c style catch up patch imp
2021-09-07 21:53 ` [PULL 38/42] bsd-user: Refactor load_elf_sections and is_target_elf_binary imp
2021-09-07 21:53 ` [PULL 39/42] bsd-user: move gemu_log to later in the file imp
2021-09-07 21:53 ` [PULL 40/42] bsd-user: Implement interlock for atomic operations imp
2021-09-07 21:53 ` [PULL 41/42] bsd-user: Add '-0 argv0' option to bsd-user/main.c imp
2021-09-07 21:53 ` [PULL 42/42] bsd-user: Update mapping to handle reserved and starting conditions imp
2021-09-09 15:00 ` [PULL 00/42] bsd-user updates to run hello world Peter Maydell
2021-09-09 15:12   ` Warner Losh
2021-09-09 15:21     ` Daniel P. Berrangé
2021-09-09 16:31     ` Philippe Mathieu-Daudé
2021-09-10 20:35       ` Warner Losh
2021-09-09 16:29 ` Philippe Mathieu-Daudé
2021-09-10 20:31   ` Warner Losh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210907215332.30737-25-imp@bsdimp.com \
    --to=imp@bsdimp.com \
    --cc=imp@FreeBSD.org \
    --cc=kevans@freebsd.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=sson@FreeBSD.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).