Skip to contentSkip to conversation

bsd-user cleanup

PATCH In review Warner Losh 4 participants 7 messages May 10, 2021 – May 11, 2021

lore
Share & tools
lore
#0 lore raw

cover bsd-user cleanup

Three more bsd-user cleanups.

The general plan after these patches is to get and keep i386 working as I flush out the loader, the basic system calls, system tracing, etc. I'll move files around so they are like the current bsd-user tree. Once that's all done, I'll add the different architectures we currently support. Sparc64 was removed from FreeBSD and never really worked in bsd-user, so would need to be deleted eventually anyway. If we do it at the start of the series, we'll reduce the burden on getting the other things in w/o ditching functionality we'll need in the end.

Short term, this just removes sparc from the build, deletes a file that's not in the final product and renames a bsd-specific structure to have a bsd name, not a linux one.

Warner Losh (3):
bsd-user: remove target_signal.h, it's unused
bsd-user: Stop building the sparc platforms
bsd-user: rename linux_binprm to bsd_binprm

 bsd-user/bsdload.c                           |  4 +--
 bsd-user/elfload.c                           |  4 +--
 bsd-user/i386/target_signal.h                | 20 ---------------
 bsd-user/qemu.h                              |  7 +++--
 bsd-user/signal.c                            |  1 -
 bsd-user/sparc/target_signal.h               | 27 --------------------
 bsd-user/sparc64/target_signal.h             | 27 --------------------
 bsd-user/x86_64/target_signal.h              | 19 --------------
 default-configs/targets/sparc-bsd-user.mak   |  3 ---
 default-configs/targets/sparc64-bsd-user.mak |  4 ---
 10 files changed, 7 insertions(+), 109 deletions(-)
 delete mode 100644 bsd-user/i386/target_signal.h
 delete mode 100644 bsd-user/sparc/target_signal.h
 delete mode 100644 bsd-user/sparc64/target_signal.h
 delete mode 100644 bsd-user/x86_64/target_signal.h
 delete mode 100644 default-configs/targets/sparc-bsd-user.mak
 delete mode 100644 default-configs/targets/sparc64-bsd-user.mak
Signature · 1 line
2.22.1
#1 lore raw

PATCH 1/3 bsd-user: remove target_signal.h, it's unused

Remove the target_signal.h file. None of its contents are currently used and the bsd-user fork doesn't use them (so this reduces the diffs there).

---
 bsd-user/i386/target_signal.h    | 20 --------------------
 bsd-user/qemu.h                  |  1 -
 bsd-user/signal.c                |  1 -
 bsd-user/sparc/target_signal.h   | 27 ---------------------------
 bsd-user/sparc64/target_signal.h | 27 ---------------------------
 bsd-user/x86_64/target_signal.h  | 19 -------------------
 6 files changed, 95 deletions(-)
 delete mode 100644 bsd-user/i386/target_signal.h
 delete mode 100644 bsd-user/sparc/target_signal.h
 delete mode 100644 bsd-user/sparc64/target_signal.h
 delete mode 100644 bsd-user/x86_64/target_signal.h
bsd-user/i386/target_signal.h deleted +0 -20
deleted file mode 100644
index 2ef36d1f98..0000000000
@@ -1,20 +0,0 @@
-#ifndef TARGET_SIGNAL_H
-#define TARGET_SIGNAL_H
-
-#include "cpu.h"
-
-/* this struct defines a stack used during syscall handling */
-
-typedef struct target_sigaltstack {
-	abi_ulong ss_sp;
-	abi_long ss_flags;
-	abi_ulong ss_size;
-} target_stack_t;
-
-
-static inline abi_ulong get_sp_from_cpustate(CPUX86State *state)
-{
-    return state->regs[R_ESP];
-}
-
-#endif /* TARGET_SIGNAL_H */
bsd-user/qemu.h +0 -1
index 5a82722281..369c649fe5 100644
@@ -38,7 +38,6 @@ extern enum BSDType bsd_type;
 
 #include "syscall_defs.h"
 #include "target_syscall.h"
-#include "target_signal.h"
 #include "exec/gdbstub.h"
 
 #if defined(CONFIG_USE_NPTL)
bsd-user/signal.c +0 -1
index f6f7aa2427..ad6d935569 100644
@@ -19,7 +19,6 @@
 #include "qemu/osdep.h"
 
 #include "qemu.h"
-#include "target_signal.h"
 
 void signal_init(void)
 {
bsd-user/sparc/target_signal.h deleted +0 -27
deleted file mode 100644
index 5b2abba40f..0000000000
@@ -1,27 +0,0 @@
-#ifndef TARGET_SIGNAL_H
-#define TARGET_SIGNAL_H
-
-#include "cpu.h"
-
-/* this struct defines a stack used during syscall handling */
-
-typedef struct target_sigaltstack {
-	abi_ulong ss_sp;
-	abi_long ss_flags;
-	abi_ulong ss_size;
-} target_stack_t;
-
-
-#ifndef UREG_I6
-#define UREG_I6        6
-#endif
-#ifndef UREG_FP
-#define UREG_FP        UREG_I6
-#endif
-
-static inline abi_ulong get_sp_from_cpustate(CPUSPARCState *state)
-{
-    return state->regwptr[UREG_FP];
-}
-
-#endif /* TARGET_SIGNAL_H */
bsd-user/sparc64/target_signal.h deleted +0 -27
deleted file mode 100644
index 5b2abba40f..0000000000
@@ -1,27 +0,0 @@
-#ifndef TARGET_SIGNAL_H
-#define TARGET_SIGNAL_H
-
-#include "cpu.h"
-
-/* this struct defines a stack used during syscall handling */
-
-typedef struct target_sigaltstack {
-	abi_ulong ss_sp;
-	abi_long ss_flags;
-	abi_ulong ss_size;
-} target_stack_t;
-
-
-#ifndef UREG_I6
-#define UREG_I6        6
-#endif
-#ifndef UREG_FP
-#define UREG_FP        UREG_I6
-#endif
-
-static inline abi_ulong get_sp_from_cpustate(CPUSPARCState *state)
-{
-    return state->regwptr[UREG_FP];
-}
-
-#endif /* TARGET_SIGNAL_H */
bsd-user/x86_64/target_signal.h deleted +0 -19
deleted file mode 100644
index 659cd401b8..0000000000
@@ -1,19 +0,0 @@
-#ifndef TARGET_SIGNAL_H
-#define TARGET_SIGNAL_H
-
-#include "cpu.h"
-
-/* this struct defines a stack used during syscall handling */
-
-typedef struct target_sigaltstack {
-	abi_ulong ss_sp;
-	abi_long ss_flags;
-	abi_ulong ss_size;
-} target_stack_t;
-
-static inline abi_ulong get_sp_from_cpustate(CPUX86State *state)
-{
-    return state->regs[R_ESP];
-}
-
-#endif /* TARGET_SIGNAL_H */
Signature · 1 line
2.22.1
#2 lore raw

PATCH 2/3 bsd-user: Stop building the sparc platforms

In reply to Warner Losh

The forked bsd-user tree doesn't really support these platforms. They aren't functional at the moment anyway. Remove them from the build so that the major reorg patch series can focus on one platform (x86) before adding addition platforms once things are shuffled. This should make it easier to review and satisfy that all revisions of a patch series are buildable.

---
 default-configs/targets/sparc-bsd-user.mak   | 3 ---
 default-configs/targets/sparc64-bsd-user.mak | 4 ----
 2 files changed, 7 deletions(-)
 delete mode 100644 default-configs/targets/sparc-bsd-user.mak
 delete mode 100644 default-configs/targets/sparc64-bsd-user.mak
default-configs/targets/sparc-bsd-user.mak deleted +0 -3
deleted file mode 100644
index 9ba3d7b07f..0000000000
@@ -1,3 +0,0 @@
-TARGET_ARCH=sparc
-TARGET_ALIGNED_ONLY=y
-TARGET_WORDS_BIGENDIAN=y
default-configs/targets/sparc64-bsd-user.mak deleted +0 -4
deleted file mode 100644
index 8dd3217800..0000000000
@@ -1,4 +0,0 @@
-TARGET_ARCH=sparc64
-TARGET_BASE_ARCH=sparc
-TARGET_ALIGNED_ONLY=y
-TARGET_WORDS_BIGENDIAN=y
Signature · 1 line
2.22.1
#3 lore raw

Re: [PATCH 2/3] bsd-user: Stop building the sparc platforms

Quoted 5 lines · Warner Losh

The forked bsd-user tree doesn't really support these platforms. They aren't functional at the moment anyway. Remove them from the build so that the major reorg patch series can focus on one platform (x86) before adding addition platforms once things are shuffled. This should make it easier to review and satisfy that all revisions of a patch series are buildable.

I'd s/platform/target/ in subject and description to make it clearer.

Quoted 7 lines
---
 default-configs/targets/sparc-bsd-user.mak   | 3 ---
 default-configs/targets/sparc64-bsd-user.mak | 4 ----
 2 files changed, 7 deletions(-)
 delete mode 100644 default-configs/targets/sparc-bsd-user.mak
 delete mode 100644 default-configs/targets/sparc64-bsd-user.mak
#4 lore raw

PATCH 3/3 bsd-user: rename linux_binprm to bsd_binprm

In reply to Warner Losh

Rename linux_binprm to bsd_binprm to reflect that we're loading BSD binaries, not ELF ones.

---
 bsd-user/bsdload.c | 4 ++--
 bsd-user/elfload.c | 4 ++--
 bsd-user/qemu.h    | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)
bsd-user/bsdload.c +2 -2
index e1ed3b7b60..8d83f21eda 100644
@@ -32,7 +32,7 @@ static int count(char **vec)
     return i;
 }
 
-static int prepare_binprm(struct linux_binprm *bprm)
+static int prepare_binprm(struct bsd_binprm *bprm)
 {
     struct stat         st;
     int mode;
@@ -127,7 +127,7 @@ 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 linux_binprm bprm;
+    struct bsd_binprm bprm;
     int retval;
     int i;
 
bsd-user/elfload.c +2 -2
index 5f4d824d78..d658d722a5 100644
@@ -662,7 +662,7 @@ static abi_ulong copy_elf_strings(int argc,char ** argv, void **page,
     return p;
 }
 
-static abi_ulong setup_arg_pages(abi_ulong p, struct linux_binprm *bprm,
+static abi_ulong setup_arg_pages(abi_ulong p, struct bsd_binprm *bprm,
                                  struct image_info *info)
 {
     abi_ulong stack_base, size, error;
@@ -1143,7 +1143,7 @@ static void load_symbols(struct elfhdr *hdr, int fd)
     syminfos = s;
 }
 
-int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
+int load_elf_binary(struct bsd_binprm * bprm, struct target_pt_regs * regs,
                     struct image_info * info)
 {
     struct elfhdr elf_ex;
bsd-user/qemu.h +3 -3
index 369c649fe5..5c33b4279f 100644
@@ -114,7 +114,7 @@ extern unsigned long mmap_min_addr;
  * This structure is used to hold the arguments that are
  * used when loading binaries.
  */
-struct linux_binprm {
+struct bsd_binprm {
         char buf[128];
         void *page[MAX_ARG_PAGES];
         abi_ulong p;
@@ -132,9 +132,9 @@ 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);
 
-int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
+int load_elf_binary(struct bsd_binprm * bprm, struct target_pt_regs * regs,
                     struct image_info * info);
-int load_flt_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
+int load_flt_binary(struct bsd_binprm * bprm, struct target_pt_regs * regs,
                     struct image_info * info);
 
 abi_long memcpy_to_target(abi_ulong dest, const void *src,
Signature · 1 line
2.22.1
#5 lore raw
In reply to Warner Losh
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Type: series
Message-id: [email protected]
Subject: [PATCH 0/3] bsd-user cleanup

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
- [tag update] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
29436b2 bsd-user: rename linux_binprm to bsd_binprm 6dfc63b bsd-user: Stop building the sparc platforms 7664bfd bsd-user: remove target_signal.h, it's unused

=== OUTPUT BEGIN ===
1/3 Checking commit 7664bfde8daf (bsd-user: remove target_signal.h, it's unused) Use of uninitialized value $acpi_testexpected in string eq at ./scripts/checkpatch.pl line 1529.
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#22:
deleted file mode 100644

total: 0 errors, 1 warnings, 14 lines checked

Patch 1/3 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
2/3 Checking commit 6dfc63b98ef1 (bsd-user: Stop building the sparc platforms) Use of uninitialized value $acpi_testexpected in string eq at ./scripts/checkpatch.pl line 1529.
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#21:
deleted file mode 100644

total: 0 errors, 1 warnings, 0 lines checked

Patch 2/3 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
3/3 Checking commit 29436b2be985 (bsd-user: rename linux_binprm to bsd_binprm)
ERROR: "foo * bar" should be "foo *bar"
#58: FILE: bsd-user/elfload.c:1146:
+int load_elf_binary(struct bsd_binprm * bprm, struct target_pt_regs * regs,

ERROR: "foo * bar" should be "foo *bar"
#80: FILE: bsd-user/qemu.h:134:
+int load_elf_binary(struct bsd_binprm * bprm, struct target_pt_regs * regs,

ERROR: "foo * bar" should be "foo *bar"
#83: FILE: bsd-user/qemu.h:136:
+int load_flt_binary(struct bsd_binprm * bprm, struct target_pt_regs * regs,

total: 3 errors, 0 warnings, 51 lines checked

Patch 3/3 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]