qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: imp@bsdimp.com
To: qemu-devel@nongnu.org
Cc: Richard Henderson <richard.henderson@linaro.org>,
	Warner Losh <imp@bsdimp.com>
Subject: [PATCH v2 08/43] bsd-user: pass the bsd_param into loader_exec
Date: Thu, 26 Aug 2021 15:11:26 -0600	[thread overview]
Message-ID: <20210826211201.98877-9-imp@bsdimp.com> (raw)
In-Reply-To: <20210826211201.98877-1-imp@bsdimp.com>

From: Warner Losh <imp@bsdimp.com>

Pass the bsd_param into loader_exec, and adjust.

Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
 bsd-user/bsdload.c | 37 +++++++++++++++++++------------------
 bsd-user/main.c    |  7 ++++++-
 bsd-user/qemu.h    |  3 ++-
 3 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/bsd-user/bsdload.c b/bsd-user/bsdload.c
index ec71c5e923..5282a7c4f2 100644
--- a/bsd-user/bsdload.c
+++ b/bsd-user/bsdload.c
@@ -140,35 +140,36 @@ abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp,
 }
 
 int loader_exec(const char *filename, char **argv, char **envp,
-                struct target_pt_regs *regs, struct image_info *infop)
+                struct target_pt_regs *regs, struct image_info *infop,
+                struct bsd_binprm *bprm)
 {
-    struct bsd_binprm bprm;
     int retval;
     int i;
 
-    bprm.p = TARGET_PAGE_SIZE * MAX_ARG_PAGES - sizeof(unsigned int);
-    for (i = 0 ; i < MAX_ARG_PAGES ; i++) {     /* clear page-table */
-        bprm.page[i] = NULL;
+    bprm->p = TARGET_PAGE_SIZE * MAX_ARG_PAGES - sizeof(unsigned int);
+    for (i = 0; i < MAX_ARG_PAGES; i++) {       /* clear page-table */
+        bprm->page[i] = NULL;
     }
     retval = open(filename, O_RDONLY);
     if (retval < 0) {
         return retval;
     }
-    bprm.fd = retval;
-    bprm.filename = (char *)filename;
-    bprm.argc = count(argv);
-    bprm.argv = argv;
-    bprm.envc = count(envp);
-    bprm.envp = envp;
 
-    retval = prepare_binprm(&bprm);
+    bprm->fd = retval;
+    bprm->filename = (char *)filename;
+    bprm->argc = count(argv);
+    bprm->argv = argv;
+    bprm->envc = count(envp);
+    bprm->envp = envp;
+
+    retval = prepare_binprm(bprm);
 
     if (retval >= 0) {
-        if (bprm.buf[0] == 0x7f
-                && bprm.buf[1] == 'E'
-                && bprm.buf[2] == 'L'
-                && bprm.buf[3] == 'F') {
-            retval = load_elf_binary(&bprm, regs, infop);
+        if (bprm->buf[0] == 0x7f
+                && bprm->buf[1] == 'E'
+                && bprm->buf[2] == 'L'
+                && bprm->buf[3] == 'F') {
+            retval = load_elf_binary(bprm, regs, infop);
         } else {
             fprintf(stderr, "Unknown binary format\n");
             return -1;
@@ -183,7 +184,7 @@ int loader_exec(const char *filename, char **argv, char **envp,
 
     /* Something went wrong, return the inode and free the argument pages*/
     for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
-        g_free(bprm.page[i]);
+        g_free(bprm->page[i]);
     }
     return retval;
 }
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 39c4a0f33c..7e1284c368 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -343,6 +343,7 @@ int main(int argc, char **argv)
     const char *log_mask = NULL;
     struct target_pt_regs regs1, *regs = &regs1;
     struct image_info info1, *info = &info1;
+    struct bsd_binprm bprm;
     TaskState ts1, *ts = &ts1;
     CPUArchState *env;
     CPUState *cpu;
@@ -499,6 +500,9 @@ int main(int argc, char **argv)
     /* Zero out regs */
     memset(regs, 0, sizeof(struct target_pt_regs));
 
+    /* Zero bsd params */
+    memset(&bprm, 0, sizeof(bprm));
+
     /* Zero out image_info */
     memset(info, 0, sizeof(struct image_info));
 
@@ -566,7 +570,8 @@ int main(int argc, char **argv)
         }
     }
 
-    if (loader_exec(filename, argv + optind, target_environ, regs, info) != 0) {
+    if (loader_exec(filename, argv+optind, target_environ, regs, info,
+                    &bprm) != 0) {
         printf("Error loading %s\n", filename);
         _exit(1);
     }
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index c02e8a5ca1..5237e35f9c 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -131,7 +131,8 @@ void do_init_thread(struct target_pt_regs *regs, struct image_info *infop);
 abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp,
                               abi_ulong stringp, int push_ptr);
 int loader_exec(const char *filename, char **argv, char **envp,
-             struct target_pt_regs *regs, struct image_info *infop);
+                struct target_pt_regs *regs, struct image_info *infop,
+                struct bsd_binprm *bprm);
 
 int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
                     struct image_info *info);
-- 
2.32.0



  parent reply	other threads:[~2021-08-26 21:20 UTC|newest]

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

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=20210826211201.98877-9-imp@bsdimp.com \
    --to=imp@bsdimp.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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).