All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/14] bsd-user: misc cleanup for aarch64 import
@ 2021-09-22  6:14 Warner Losh
  2021-09-22  6:14 ` [PATCH 01/14] bsd-user/target_os-user.h: Remove support for FreeBSD older than 12.0 Warner Losh
                   ` (13 more replies)
  0 siblings, 14 replies; 50+ messages in thread
From: Warner Losh @ 2021-09-22  6:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kyle Evans, richard.henderson, f4bug, Warner Losh

Prepare for aarch64 support (the next architecture to be upstreamed). As the
aarch64 emulation is more complete, it relies on a number of different items.
In some cases, I've pulled in the full support from bsd-user fork. In other
cases I've created a simple stub (as is the case for signals, which have
independent changes pending, so I wanted to be as minimal as possible.  Since
all pre-12.2 support was purged from the bsd-user fork, go ahead and remove it
here. FreeBSD 11.x goes ouft of support at the end of the month. Remove what
little multi-version support that's in upstream.

The aarch64 patch set will be published soon after some of the dust settles.

Stacey Son (1):
  bsd-user/errno_defs.h: Add internal error numbers

Warner Losh (13):
  bsd-user/target_os-user.h: Remove support for FreeBSD older than 12.0
  bsd-user/strace.list: Remove support for FreeBSD versions older than
    12.0
  bsd-user: TARGET_RESET define is unused, remove it
  bsd-user: export get_errno and is_error from syscall.c
  bsd-user: move TARGET_MC_GET_CLEAR_RET to target_os_signal.h
  bsd-user/target_os_elf.h: Remove fallback ELF_HWCAP and reorder
  bsd-user/target_os_elf: If ELF_HWCAP2 is defined, publish it
  bsd-user: Remove used from TaskState
  bsd-user: Add stop_all_tasks
  bsd-user/sysarch: Move to using do_freebsd_arch_sysarch interface
  bsd-user/sysarch: Provide a per-arch framework for sysarch syscall
  bsd-user: Rename sigqueue to qemu_sigqueue
  bsd-user/signal: Create a dummy signal queueing function

 bsd-user/errno_defs.h                |  14 +++-
 bsd-user/freebsd/meson.build         |   3 +
 bsd-user/freebsd/os-sys.c            |  28 ++++++++
 bsd-user/freebsd/strace.list         |  11 ---
 bsd-user/freebsd/target_os_elf.h     |  12 ++--
 bsd-user/freebsd/target_os_signal.h  |   3 +
 bsd-user/freebsd/target_os_user.h    | 100 +--------------------------
 bsd-user/i386/target_arch_cpu.h      |   2 -
 bsd-user/i386/target_arch_signal.h   |   2 -
 bsd-user/main.c                      |  10 ++-
 bsd-user/meson.build                 |   6 ++
 bsd-user/qemu.h                      |  24 ++++---
 bsd-user/signal.c                    |   8 +++
 bsd-user/syscall.c                   |  60 ++--------------
 bsd-user/x86_64/target_arch_cpu.h    |   2 -
 bsd-user/x86_64/target_arch_signal.h |   2 -
 16 files changed, 96 insertions(+), 191 deletions(-)
 create mode 100644 bsd-user/freebsd/meson.build
 create mode 100644 bsd-user/freebsd/os-sys.c

-- 
2.32.0



^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 01/14] bsd-user/target_os-user.h: Remove support for FreeBSD older than 12.0
  2021-09-22  6:14 [PATCH 00/14] bsd-user: misc cleanup for aarch64 import Warner Losh
@ 2021-09-22  6:14 ` Warner Losh
  2021-09-22  6:14 ` [PATCH 02/14] bsd-user/strace.list: Remove support for FreeBSD versions " Warner Losh
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 50+ messages in thread
From: Warner Losh @ 2021-09-22  6:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kyle Evans, richard.henderson, f4bug, Warner Losh

Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/freebsd/target_os_user.h | 100 +-----------------------------
 1 file changed, 1 insertion(+), 99 deletions(-)

diff --git a/bsd-user/freebsd/target_os_user.h b/bsd-user/freebsd/target_os_user.h
index 95b1fa9f99..19892c5071 100644
--- a/bsd-user/freebsd/target_os_user.h
+++ b/bsd-user/freebsd/target_os_user.h
@@ -61,15 +61,7 @@ struct target_sockaddr_storage {
 /*
  * from sys/user.h
  */
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
 #define TARGET_KI_NSPARE_INT        2
-#elif defined(__FreeBSD_version) && __FreeBSD_version >= 1100000
-#define TARGET_KI_NSPARE_INT        4
-#elif defined(__FreeBSD_version) && __FreeBSD_version >= 1000000
-#define TARGET_KI_NSPARE_INT        7
-#else
-#define TARGET_KI_NSPARE_INT        9
-#endif /* ! __FreeBSD_version >= 1000000 */
 #define TARGET_KI_NSPARE_LONG       12
 #define TARGET_KI_NSPARE_PTR        6
 
@@ -116,11 +108,7 @@ struct target_kinfo_proc {
     int32_t     ki_tsid;            /* Terminal session ID */
     int16_t     ki_jobc;            /* job control counter */
     int16_t     ki_spare_short1;    /* unused (just here for alignment) */
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
     int32_t     ki_tdev__freebsd11; /* controlling tty dev */
-#else
-    int32_t     ki_tdev;            /* controlling tty dev */
-#endif
     target_sigset_t ki_siglist;     /* Signals arrived but not delivered */
     target_sigset_t ki_sigmask;     /* Current signal mask */
     target_sigset_t ki_sigignore;   /* Signals being ignored */
@@ -164,45 +152,24 @@ struct target_kinfo_proc {
     int8_t      ki_nice;            /* Process "nice" value */
     char        ki_lock;            /* Process lock (prevent swap) count */
     char        ki_rqindex;         /* Run queue index */
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 1100000
     u_char      ki_oncpu_old;       /* Which cpu we are on (legacy) */
     u_char      ki_lastcpu_old;     /* Last cpu we were on (legacy) */
-#else
-    u_char      ki_oncpu;           /* Which cpu we are on */
-    u_char      ki_lastcpu;         /* Last cpu we were on */
-#endif /* ! __FreeBSD_version >= 1100000 */
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900000
     char        ki_tdname[TARGET_TDNAMLEN + 1];  /* thread name */
-#else
-    char        ki_ocomm[TARGET_TDNAMLEN + 1];   /* thread name */
-#endif /* ! __FreeBSD_version >= 900000 */
     char        ki_wmesg[TARGET_WMESGLEN + 1];   /* wchan message */
     char        ki_login[TARGET_LOGNAMELEN + 1]; /* setlogin name */
     char        ki_lockname[TARGET_LOCKNAMELEN + 1]; /* lock name */
     char        ki_comm[TARGET_COMMLEN + 1];     /* command name */
     char        ki_emul[TARGET_KI_EMULNAMELEN + 1];  /* emulation name */
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900000
     char        ki_loginclass[TARGET_LOGINCLASSLEN + 1]; /* login class */
-#endif /* ! __FreeBSD_version >= 900000 */
 
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900000
     char        ki_sparestrings[50];    /* spare string space */
-#else
-    char        ki_sparestrings[68];    /* spare string space */
-#endif /* ! __FreeBSD_version >= 900000 */
     int32_t     ki_spareints[TARGET_KI_NSPARE_INT]; /* spare room for growth */
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
- uint64_t ki_tdev;  /* controlling tty dev */
-#endif
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 1100000
+    uint64_t ki_tdev;  /* controlling tty dev */
     int32_t     ki_oncpu;           /* Which cpu we are on */
     int32_t     ki_lastcpu;         /* Last cpu we were on */
     int32_t     ki_tracer;          /* Pid of tracing process */
-#endif /* __FreeBSD_version >= 1100000 */
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900000
     int32_t     ki_flag2;           /* P2_* flags */
     int32_t     ki_fibnum;          /* Default FIB number */
-#endif /* ! __FreeBSD_version >= 900000 */
     uint32_t    ki_cr_flags;        /* Credential flags */
     int32_t     ki_jid;             /* Process jail ID */
     int32_t     ki_numthreads;      /* XXXKSE number of threads in total */
@@ -234,18 +201,8 @@ struct target_kinfo_file {
     int32_t  kf_flags;  /* Flags. */
     int32_t  kf_pad0;  /* Round to 64 bit alignment. */
     int64_t  kf_offset;  /* Seek location. */
-#if defined(__FreeBSD_version) && __FreeBSD_version < 1200031
-    int32_t  kf_vnode_type;  /* Vnode type. */
-    int32_t  kf_sock_domain;  /* Socket domain. */
-    int32_t  kf_sock_type;  /* Socket type. */
-    int32_t  kf_sock_protocol; /* Socket protocol. */
-    struct target_sockaddr_storage kf_sa_local; /* Socket address. */
-    struct target_sockaddr_storage kf_sa_peer; /* Peer address. */
-#endif
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900000
     union {
         struct {
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
             uint32_t kf_spareint;
             /* Socket domain. */
             int  kf_sock_domain0;
@@ -257,7 +214,6 @@ struct target_kinfo_file {
             struct sockaddr_storage kf_sa_local;
             /* Peer address. */
             struct sockaddr_storage kf_sa_peer;
-#endif
             /* Address of so_pcb. */
             uint64_t kf_sock_pcb;
             /* Address of inp_ppcb. */
@@ -272,7 +228,6 @@ struct target_kinfo_file {
             uint32_t kf_sock_pad0;
         } kf_sock;
         struct {
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
             /* Vnode type. */
             int  kf_file_type;
             /* Space for future use */
@@ -290,16 +245,6 @@ struct target_kinfo_file {
             uint32_t kf_file_fsid_freebsd11;
             /* File device, FreeBSD 11 compat. */
             uint32_t kf_file_rdev_freebsd11;
-#else
-            /* Global file id. */
-            uint64_t kf_file_fileid;
-            /* File size. */
-            uint64_t kf_file_size;
-            /* Vnode filesystem id. */
-            uint32_t kf_file_fsid;
-            /* File device. */
-            uint32_t kf_file_rdev;
-#endif
             /* File mode. */
             uint16_t kf_file_mode;
             /* Round to 64 bit alignment. */
@@ -307,18 +252,14 @@ struct target_kinfo_file {
             uint32_t kf_file_pad1;
         } kf_file;
         struct {
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
             uint32_t kf_spareint[4];
             uint64_t kf_spareint64[32];
-#endif
             uint32_t kf_sem_value;
             uint16_t kf_sem_mode;
         } kf_sem;
         struct {
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
             uint32_t kf_spareint[4];
             uint64_t kf_spareint64[32];
-#endif
             uint64_t kf_pipe_addr;
             uint64_t kf_pipe_peer;
             uint32_t kf_pipe_buffer_cnt;
@@ -326,7 +267,6 @@ struct target_kinfo_file {
             uint32_t kf_pipe_pad0[3];
         } kf_pipe;
         struct {
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
             uint32_t kf_spareint[4];
             uint64_t kf_spareint64[32];
             uint32_t kf_pts_dev_freebsd11;
@@ -334,34 +274,18 @@ struct target_kinfo_file {
             uint64_t kf_pts_dev;
             /* Round to 64 bit alignment. */
             uint32_t kf_pts_pad1[4];
-#else
-            uint32_t kf_pts_dev;
-            /* Round to 64 bit alignment. */
-            uint32_t kf_pts_pad0[7];
-#endif
         } kf_pts;
         struct {
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
             uint32_t kf_spareint[4];
             uint64_t kf_spareint64[32];
-#endif
             int32_t  kf_pid;
         } kf_proc;
     } kf_un;
     uint16_t kf_status;  /* Status flags. */
     uint16_t kf_pad1;  /* Round to 32 bit alignment. */
     int32_t  _kf_ispare0;  /* Space for more stuff. */
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 1000000
     target_cap_rights_t kf_cap_rights; /* Capability rights. */
     uint64_t _kf_cap_spare; /* Space for future cap_rights_t. */
-#else /* ! __FreeBSD_version >= 1000000 */
-    uint64_t        kf_cap_rights;
-    int  _kf_ispare[4];
-#endif /* ! __FreeBSD_version >= 1000000 */
-
-#else /* ! __FreeBSD_version >= 900000 */
-    int  _kf_ispare[16];
-#endif /* ! __FreeBSD_version >= 900000 */
     /* Truncated before copyout in sysctl */
     char  kf_path[PATH_MAX]; /* Path to file, if any. */
 };
@@ -372,34 +296,19 @@ struct target_kinfo_vmentry {
     uint64_t kve_start;   /* Starting address. */
     uint64_t kve_end;   /* Finishing address. */
     uint64_t kve_offset;   /* Mapping offset in object */
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900000
     uint64_t kve_vn_fileid;   /* inode number if vnode */
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
     uint32_t kve_vn_fsid_freebsd11;  /* dev_t of vnode location */
-#else
-    uint32_t kve_vn_fsid;   /* dev_t of vnode location */
-#endif
-#else /* !  __FreeBSD_version >= 900000 */
-    uint64_t kve_fileid;   /* inode number if vnode */
-    uint32_t kve_fsid;   /* dev_t of vnode location */
-#endif /* !  __FreeBSD_version >= 900000 */
     int32_t  kve_flags;   /* Flags on map entry. */
     int32_t  kve_resident;   /* Number of resident pages. */
     int32_t  kve_private_resident;  /* Number of private pages. */
     int32_t  kve_protection;  /* Protection bitmask. */
     int32_t  kve_ref_count;   /* VM obj ref count. */
     int32_t  kve_shadow_count;  /* VM obj shadow count. */
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900000
     int32_t  kve_vn_type;   /* Vnode type. */
     uint64_t kve_vn_size;   /* File size. */
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
     uint32_t kve_vn_rdev_freebsd11;  /* Device id if device. */
-#else
-    uint32_t kve_vn_rdev;   /* Device id if device. */
-#endif
     uint16_t kve_vn_mode;   /* File mode. */
     uint16_t kve_status;   /* Status flags. */
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
 #if (__FreeBSD_version >= 1300501 && __FreeBSD_version < 1400000) ||    \
     __FreeBSD_version >= 1400009
     union {
@@ -413,13 +322,6 @@ struct target_kinfo_vmentry {
 #endif
     uint64_t kve_vn_rdev;   /* Device id if device. */
     int  _kve_ispare[8];  /* Space for more stuff. */
-#else
-    int32_t  _kve_ispare[12];  /* Space for more stuff. */
-#endif
-#else /* !  __FreeBSD_version >= 900000 */
-    int  _kve_pad0;
-    int32_t  _kve_ispare[16];  /* Space for more stuff. */
-#endif /* !  __FreeBSD_version >= 900000 */
     /* Truncated before copyout in sysctl */
     char  kve_path[PATH_MAX];  /* Path to VM obj, if any. */
 };
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 02/14] bsd-user/strace.list: Remove support for FreeBSD versions older than 12.0
  2021-09-22  6:14 [PATCH 00/14] bsd-user: misc cleanup for aarch64 import Warner Losh
  2021-09-22  6:14 ` [PATCH 01/14] bsd-user/target_os-user.h: Remove support for FreeBSD older than 12.0 Warner Losh
@ 2021-09-22  6:14 ` Warner Losh
  2021-09-23 17:57   ` Richard Henderson
  2021-09-22  6:14 ` [PATCH 03/14] bsd-user: TARGET_RESET define is unused, remove it Warner Losh
                   ` (11 subsequent siblings)
  13 siblings, 1 reply; 50+ messages in thread
From: Warner Losh @ 2021-09-22  6:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kyle Evans, richard.henderson, f4bug, Warner Losh

Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/freebsd/strace.list | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/bsd-user/freebsd/strace.list b/bsd-user/freebsd/strace.list
index b01b5f36e8..275d2dbe27 100644
--- a/bsd-user/freebsd/strace.list
+++ b/bsd-user/freebsd/strace.list
@@ -33,10 +33,6 @@
 { TARGET_FREEBSD_NR___syscall, "__syscall", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR___sysctl, "__sysctl", NULL, print_sysctl, NULL },
 { TARGET_FREEBSD_NR__umtx_op, "_umtx_op", "%s(%#x, %d, %d, %#x, %#x)", NULL, NULL },
-#if defined(__FreeBSD_version) && __FreeBSD_version < 1000000
-{ TARGET_FREEBSD_NR__umtx_lock, "__umtx_lock", NULL, NULL, NULL },
-{ TARGET_FREEBSD_NR__umtx_unlock, "__umtx_unlock", NULL, NULL, NULL },
-#endif
 { TARGET_FREEBSD_NR_accept, "accept", "%s(%d,%#x,%#x)", NULL, NULL },
 { TARGET_FREEBSD_NR_accept4, "accept4", "%s(%d,%d,%#x,%#x)", NULL, NULL },
 { TARGET_FREEBSD_NR_access, "access", "%s(\"%s\",%#o)", NULL, NULL },
@@ -49,10 +45,6 @@
 { TARGET_FREEBSD_NR_cap_fcntls_get, "cap_fcntls_get", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_cap_fcntls_limit, "cap_fcntls_limit", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_cap_getmode, "cap_getmode", NULL, NULL, NULL },
-#if defined(__FreeBSD_version) && __FreeBSD_version < 1000000
-{ TARGET_FREEBSD_NR_cap_getrights, "cap_getrights", NULL, NULL, NULL },
-{ TARGET_FREEBSD_NR_cap_new, "cap_new", NULL, NULL, NULL },
-#endif
 { TARGET_FREEBSD_NR_cap_ioctls_get, "cap_ioctls_get", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_cap_ioctls_limit, "cap_ioctls_limit", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_cap_rights_limit, "cap_rights_limit", NULL, NULL, NULL },
@@ -146,9 +138,6 @@
 { TARGET_FREEBSD_NR_freebsd11_kevent, "freebsd11_kevent", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_kevent, "kevent", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_kill, "kill", NULL, NULL, NULL },
-#if defined(__FreeBSD_version) && __FreeBSD_version < 1000000
-{ TARGET_FREEBSD_NR_killpg, "killpg", NULL, NULL, NULL },
-#endif
 { TARGET_FREEBSD_NR_kqueue, "kqueue", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_ktrace, "ktrace", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_lchown, "lchown", NULL, NULL, NULL },
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 03/14] bsd-user: TARGET_RESET define is unused, remove it
  2021-09-22  6:14 [PATCH 00/14] bsd-user: misc cleanup for aarch64 import Warner Losh
  2021-09-22  6:14 ` [PATCH 01/14] bsd-user/target_os-user.h: Remove support for FreeBSD older than 12.0 Warner Losh
  2021-09-22  6:14 ` [PATCH 02/14] bsd-user/strace.list: Remove support for FreeBSD versions " Warner Losh
@ 2021-09-22  6:14 ` Warner Losh
  2021-09-23 17:57   ` Richard Henderson
  2021-09-25 10:30   ` Philippe Mathieu-Daudé
  2021-09-22  6:14 ` [PATCH 04/14] bsd-user: export get_errno and is_error from syscall.c Warner Losh
                   ` (10 subsequent siblings)
  13 siblings, 2 replies; 50+ messages in thread
From: Warner Losh @ 2021-09-22  6:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kyle Evans, richard.henderson, f4bug, Warner Losh

Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/i386/target_arch_cpu.h   | 2 --
 bsd-user/x86_64/target_arch_cpu.h | 2 --
 2 files changed, 4 deletions(-)

diff --git a/bsd-user/i386/target_arch_cpu.h b/bsd-user/i386/target_arch_cpu.h
index 978e8066af..b28602adbb 100644
--- a/bsd-user/i386/target_arch_cpu.h
+++ b/bsd-user/i386/target_arch_cpu.h
@@ -23,8 +23,6 @@
 
 #define TARGET_DEFAULT_CPU_MODEL "qemu32"
 
-#define TARGET_CPU_RESET(cpu)
-
 static inline void target_cpu_init(CPUX86State *env,
         struct target_pt_regs *regs)
 {
diff --git a/bsd-user/x86_64/target_arch_cpu.h b/bsd-user/x86_64/target_arch_cpu.h
index 5f5ee602f9..5172b230f0 100644
--- a/bsd-user/x86_64/target_arch_cpu.h
+++ b/bsd-user/x86_64/target_arch_cpu.h
@@ -23,8 +23,6 @@
 
 #define TARGET_DEFAULT_CPU_MODEL "qemu64"
 
-#define TARGET_CPU_RESET(cpu)
-
 static inline void target_cpu_init(CPUX86State *env,
         struct target_pt_regs *regs)
 {
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 04/14] bsd-user: export get_errno and is_error from syscall.c
  2021-09-22  6:14 [PATCH 00/14] bsd-user: misc cleanup for aarch64 import Warner Losh
                   ` (2 preceding siblings ...)
  2021-09-22  6:14 ` [PATCH 03/14] bsd-user: TARGET_RESET define is unused, remove it Warner Losh
@ 2021-09-22  6:14 ` Warner Losh
  2021-09-23 17:58   ` Richard Henderson
  2021-09-25 10:33   ` Philippe Mathieu-Daudé
  2021-09-22  6:14 ` [PATCH 05/14] bsd-user/errno_defs.h: Add internal error numbers Warner Losh
                   ` (9 subsequent siblings)
  13 siblings, 2 replies; 50+ messages in thread
From: Warner Losh @ 2021-09-22  6:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kyle Evans, richard.henderson, f4bug, Warner Losh

Make get_errno and is_error global so files other than syscall.c can use
them.

Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/qemu.h    |  4 ++++
 bsd-user/syscall.c | 10 +++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 522d6c4031..22fc3a6c30 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -235,6 +235,10 @@ extern unsigned long target_dflssiz;
 extern unsigned long target_maxssiz;
 extern unsigned long target_sgrowsiz;
 
+/* syscall.c */
+abi_long get_errno(abi_long ret);
+int is_error(abi_long ret);
+
 /* user access */
 
 #define VERIFY_READ  PAGE_READ
diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
index 372836d44d..a579d52ede 100644
--- a/bsd-user/syscall.c
+++ b/bsd-user/syscall.c
@@ -33,18 +33,18 @@
 static abi_ulong target_brk;
 static abi_ulong target_original_brk;
 
-static inline abi_long get_errno(abi_long ret)
+abi_long get_errno(abi_long ret)
 {
-    if (ret == -1)
+    if (ret == -1) {
         /* XXX need to translate host -> target errnos here */
         return -(errno);
-    else
-        return ret;
+    }
+    return ret;
 }
 
 #define target_to_host_bitmask(x, tbl) (x)
 
-static inline int is_error(abi_long ret)
+int is_error(abi_long ret)
 {
     return (abi_ulong)ret >= (abi_ulong)(-4096);
 }
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 05/14] bsd-user/errno_defs.h: Add internal error numbers
  2021-09-22  6:14 [PATCH 00/14] bsd-user: misc cleanup for aarch64 import Warner Losh
                   ` (3 preceding siblings ...)
  2021-09-22  6:14 ` [PATCH 04/14] bsd-user: export get_errno and is_error from syscall.c Warner Losh
@ 2021-09-22  6:14 ` Warner Losh
  2021-09-23 17:59   ` Richard Henderson
  2021-09-22  6:14 ` [PATCH 06/14] bsd-user: move TARGET_MC_GET_CLEAR_RET to target_os_signal.h Warner Losh
                   ` (8 subsequent siblings)
  13 siblings, 1 reply; 50+ messages in thread
From: Warner Losh @ 2021-09-22  6:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kyle Evans, richard.henderson, f4bug, Warner Losh, Stacey Son

From: Stacey Son <sson@FreeBSD.org>

To emulate signals and interrupted system calls, we need to have the
same mechanisms we have in the kernel, including these errno values.

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/errno_defs.h | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/bsd-user/errno_defs.h b/bsd-user/errno_defs.h
index 1efa502a12..b538dd93da 100644
--- a/bsd-user/errno_defs.h
+++ b/bsd-user/errno_defs.h
@@ -1,6 +1,3 @@
-/*      $OpenBSD: errno.h,v 1.20 2007/09/03 14:37:52 millert Exp $      */
-/*      $NetBSD: errno.h,v 1.10 1996/01/20 01:33:53 jtc Exp $   */
-
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
  *      The Regents of the University of California.  All rights reserved.
@@ -37,6 +34,9 @@
  *      @(#)errno.h     8.5 (Berkeley) 1/21/94
  */
 
+#ifndef _ERRNO_DEFS_H_
+#define _ERRNO_DEFS_H_
+
 #define TARGET_EPERM            1               /* Operation not permitted */
 #define TARGET_ENOENT           2               /* No such file or directory */
 #define TARGET_ESRCH            3               /* No such process */
@@ -147,3 +147,11 @@
 #define TARGET_EIDRM            89              /* Identifier removed */
 #define TARGET_ENOMSG           90              /* No message of desired type */
 #define TARGET_ELAST            90              /* Must be equal largest errno */
+
+/* Internal errors: */
+#define TARGET_EJUSTRETURN      254             /* Just return without
+                                                   modifing regs */
+#define TARGET_ERESTART         255             /* Restart syscall */
+#define TARGET_ERESTARTSYS      TARGET_ERESTART /* Linux compat */
+
+#endif /* !  _ERRNO_DEFS_H_ */
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 06/14] bsd-user: move TARGET_MC_GET_CLEAR_RET to target_os_signal.h
  2021-09-22  6:14 [PATCH 00/14] bsd-user: misc cleanup for aarch64 import Warner Losh
                   ` (4 preceding siblings ...)
  2021-09-22  6:14 ` [PATCH 05/14] bsd-user/errno_defs.h: Add internal error numbers Warner Losh
@ 2021-09-22  6:14 ` Warner Losh
  2021-09-23 18:00   ` Richard Henderson
  2021-09-25 10:35   ` Philippe Mathieu-Daudé
  2021-09-22  6:14 ` [PATCH 07/14] bsd-user/target_os_elf.h: Remove fallback ELF_HWCAP and reorder Warner Losh
                   ` (7 subsequent siblings)
  13 siblings, 2 replies; 50+ messages in thread
From: Warner Losh @ 2021-09-22  6:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kyle Evans, richard.henderson, f4bug, Warner Losh

Move TARGET_MC_GET_CLEAR_RET to freebsd/target_os_signal.h since it's
FreeBSD-wide.

Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/freebsd/target_os_signal.h  | 3 +++
 bsd-user/i386/target_arch_signal.h   | 2 --
 bsd-user/x86_64/target_arch_signal.h | 2 --
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/bsd-user/freebsd/target_os_signal.h b/bsd-user/freebsd/target_os_signal.h
index 3ed454e086..9fcdfce003 100644
--- a/bsd-user/freebsd/target_os_signal.h
+++ b/bsd-user/freebsd/target_os_signal.h
@@ -1,6 +1,9 @@
 #ifndef _TARGET_OS_SIGNAL_H_
 #define _TARGET_OS_SIGNAL_H_
 
+/* FreeBSD's sys/ucontex.h defines this */
+#define TARGET_MC_GET_CLEAR_RET 0x0001
+
 #include "target_os_siginfo.h"
 #include "target_arch_signal.h"
 
diff --git a/bsd-user/i386/target_arch_signal.h b/bsd-user/i386/target_arch_signal.h
index 9812c6b034..a90750d602 100644
--- a/bsd-user/i386/target_arch_signal.h
+++ b/bsd-user/i386/target_arch_signal.h
@@ -27,8 +27,6 @@
 #define TARGET_MINSIGSTKSZ  (512 * 4)               /* min sig stack size */
 #define TARGET_SIGSTKSZ     (MINSIGSTKSZ + 32768)   /* recommended size */
 
-#define TARGET_MC_GET_CLEAR_RET 0x0001
-
 struct target_sigcontext {
     /* to be added */
 };
diff --git a/bsd-user/x86_64/target_arch_signal.h b/bsd-user/x86_64/target_arch_signal.h
index 4c1ff0e5ba..4bb753b08b 100644
--- a/bsd-user/x86_64/target_arch_signal.h
+++ b/bsd-user/x86_64/target_arch_signal.h
@@ -27,8 +27,6 @@
 #define TARGET_MINSIGSTKSZ  (512 * 4)               /* min sig stack size */
 #define TARGET_SIGSTKSZ     (MINSIGSTKSZ + 32768)   /* recommended size */
 
-#define TARGET_MC_GET_CLEAR_RET 0x0001
-
 struct target_sigcontext {
     /* to be added */
 };
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 07/14] bsd-user/target_os_elf.h: Remove fallback ELF_HWCAP and reorder
  2021-09-22  6:14 [PATCH 00/14] bsd-user: misc cleanup for aarch64 import Warner Losh
                   ` (5 preceding siblings ...)
  2021-09-22  6:14 ` [PATCH 06/14] bsd-user: move TARGET_MC_GET_CLEAR_RET to target_os_signal.h Warner Losh
@ 2021-09-22  6:14 ` Warner Losh
  2021-09-23 18:01   ` Richard Henderson
  2021-09-25 10:36   ` Philippe Mathieu-Daudé
  2021-09-22  6:14 ` [PATCH 08/14] bsd-user/target_os_elf: If ELF_HWCAP2 is defined, publish it Warner Losh
                   ` (6 subsequent siblings)
  13 siblings, 2 replies; 50+ messages in thread
From: Warner Losh @ 2021-09-22  6:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kyle Evans, richard.henderson, f4bug, Warner Losh

All architectures have a ELF_HWCAP, so remove the fallback ifdef.
Place ELF_HWCAP in the same order as on native FreeBSD.

Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/freebsd/target_os_elf.h | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/bsd-user/freebsd/target_os_elf.h b/bsd-user/freebsd/target_os_elf.h
index 2d03a883aa..adcffd1ddb 100644
--- a/bsd-user/freebsd/target_os_elf.h
+++ b/bsd-user/freebsd/target_os_elf.h
@@ -38,10 +38,6 @@
 #define ELF_PLATFORM (NULL)
 #endif
 
-#ifndef ELF_HWCAP
-#define ELF_HWCAP 0
-#endif
-
 /* XXX Look at the other conflicting AT_* values. */
 #define FREEBSD_AT_NCPUS     19
 #define FREEBSD_AT_HWCAP     25
@@ -114,12 +110,12 @@ static abi_ulong target_create_elf_tables(abi_ulong p, int argc, int envc,
         NEW_AUX_ENT(AT_FLAGS, (abi_ulong)0);
         NEW_AUX_ENT(FREEBSD_AT_NCPUS, (abi_ulong)bsd_get_ncpu());
         NEW_AUX_ENT(AT_ENTRY, load_bias + exec->e_entry);
+        features = ELF_HWCAP;
+        NEW_AUX_ENT(FREEBSD_AT_HWCAP, features);
         NEW_AUX_ENT(AT_UID, (abi_ulong)getuid());
         NEW_AUX_ENT(AT_EUID, (abi_ulong)geteuid());
         NEW_AUX_ENT(AT_GID, (abi_ulong)getgid());
         NEW_AUX_ENT(AT_EGID, (abi_ulong)getegid());
-        features = ELF_HWCAP;
-        NEW_AUX_ENT(FREEBSD_AT_HWCAP, features);
         target_auxents = sp; /* Note where the aux entries are in the target */
 #ifdef ARCH_DLINFO
         /*
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 08/14] bsd-user/target_os_elf: If ELF_HWCAP2 is defined, publish it
  2021-09-22  6:14 [PATCH 00/14] bsd-user: misc cleanup for aarch64 import Warner Losh
                   ` (6 preceding siblings ...)
  2021-09-22  6:14 ` [PATCH 07/14] bsd-user/target_os_elf.h: Remove fallback ELF_HWCAP and reorder Warner Losh
@ 2021-09-22  6:14 ` Warner Losh
  2021-09-23 18:01   ` Richard Henderson
  2021-09-25 10:37   ` Philippe Mathieu-Daudé
  2021-09-22  6:14 ` [PATCH 09/14] bsd-user: Remove used from TaskState Warner Losh
                   ` (5 subsequent siblings)
  13 siblings, 2 replies; 50+ messages in thread
From: Warner Losh @ 2021-09-22  6:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kyle Evans, richard.henderson, f4bug, Warner Losh

Some architecutres publish AT_HWCAP2 as well as AT_HWCAP. Those
architectures will define this in their target_arch_elf.h files.  If it
is defined, then publish it.

Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/freebsd/target_os_elf.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/bsd-user/freebsd/target_os_elf.h b/bsd-user/freebsd/target_os_elf.h
index adcffd1ddb..e5ac8e8e50 100644
--- a/bsd-user/freebsd/target_os_elf.h
+++ b/bsd-user/freebsd/target_os_elf.h
@@ -112,6 +112,10 @@ static abi_ulong target_create_elf_tables(abi_ulong p, int argc, int envc,
         NEW_AUX_ENT(AT_ENTRY, load_bias + exec->e_entry);
         features = ELF_HWCAP;
         NEW_AUX_ENT(FREEBSD_AT_HWCAP, features);
+#ifdef ELF_HWCAP2
+        features = ELF_HWCAP2;
+        NEW_AUX_ENT(FREEBSD_AT_HWCAP2, features);
+#endif
         NEW_AUX_ENT(AT_UID, (abi_ulong)getuid());
         NEW_AUX_ENT(AT_EUID, (abi_ulong)geteuid());
         NEW_AUX_ENT(AT_GID, (abi_ulong)getgid());
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 09/14] bsd-user: Remove used from TaskState
  2021-09-22  6:14 [PATCH 00/14] bsd-user: misc cleanup for aarch64 import Warner Losh
                   ` (7 preceding siblings ...)
  2021-09-22  6:14 ` [PATCH 08/14] bsd-user/target_os_elf: If ELF_HWCAP2 is defined, publish it Warner Losh
@ 2021-09-22  6:14 ` Warner Losh
  2021-09-23 18:02   ` Richard Henderson
  2021-09-25 10:38   ` Philippe Mathieu-Daudé
  2021-09-22  6:14 ` [PATCH 10/14] bsd-user: Add stop_all_tasks Warner Losh
                   ` (4 subsequent siblings)
  13 siblings, 2 replies; 50+ messages in thread
From: Warner Losh @ 2021-09-22  6:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kyle Evans, richard.henderson, f4bug, Warner Losh

The used field of TaskState is write only. Eliminate it.

Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/main.c | 1 -
 bsd-user/qemu.h | 1 -
 2 files changed, 2 deletions(-)

diff --git a/bsd-user/main.c b/bsd-user/main.c
index 48643eeabc..ee84554854 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -210,7 +210,6 @@ void init_task_state(TaskState *ts)
 {
     int i;
 
-    ts->used = 1;
     ts->first_free = ts->sigqueue_table;
     for (i = 0; i < MAX_SIGQUEUE_SIZE - 1; i++) {
         ts->sigqueue_table[i].next = &ts->sigqueue_table[i + 1];
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 22fc3a6c30..431c5cfc03 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -92,7 +92,6 @@ typedef struct TaskState {
 
     struct TaskState *next;
     struct bsd_binprm *bprm;
-    int used; /* non zero if used */
     struct image_info *info;
 
     struct emulated_sigtable sigtab[TARGET_NSIG];
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 10/14] bsd-user: Add stop_all_tasks
  2021-09-22  6:14 [PATCH 00/14] bsd-user: misc cleanup for aarch64 import Warner Losh
                   ` (8 preceding siblings ...)
  2021-09-22  6:14 ` [PATCH 09/14] bsd-user: Remove used from TaskState Warner Losh
@ 2021-09-22  6:14 ` Warner Losh
  2021-09-23 18:04   ` Richard Henderson
  2021-09-22  6:14 ` [PATCH 11/14] bsd-user/sysarch: Move to using do_freebsd_arch_sysarch interface Warner Losh
                   ` (3 subsequent siblings)
  13 siblings, 1 reply; 50+ messages in thread
From: Warner Losh @ 2021-09-22  6:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kyle Evans, richard.henderson, f4bug, Warner Losh, Stacey Son

Similar to the same function in linux-user: this stops all the current tasks.

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/main.c | 9 +++++++++
 bsd-user/qemu.h | 1 +
 2 files changed, 10 insertions(+)

diff --git a/bsd-user/main.c b/bsd-user/main.c
index ee84554854..cb5ea40236 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -195,6 +195,15 @@ static void usage(void)
 
 __thread CPUState *thread_cpu;
 
+void stop_all_tasks(void)
+{
+    /*
+     * We trust when using NPTL (pthreads) start_exclusive() handles thread
+     * stopping correctly.
+     */
+    start_exclusive();
+}
+
 bool qemu_cpu_is_self(CPUState *cpu)
 {
     return thread_cpu == cpu;
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 431c5cfc03..4ee57b91f0 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -103,6 +103,7 @@ typedef struct TaskState {
 } __attribute__((aligned(16))) TaskState;
 
 void init_task_state(TaskState *ts);
+void stop_all_tasks(void);
 extern const char *qemu_uname_release;
 
 /*
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 11/14] bsd-user/sysarch: Move to using do_freebsd_arch_sysarch interface
  2021-09-22  6:14 [PATCH 00/14] bsd-user: misc cleanup for aarch64 import Warner Losh
                   ` (9 preceding siblings ...)
  2021-09-22  6:14 ` [PATCH 10/14] bsd-user: Add stop_all_tasks Warner Losh
@ 2021-09-22  6:14 ` Warner Losh
  2021-09-23 18:07   ` Richard Henderson
  2021-09-22  6:14 ` [PATCH 12/14] bsd-user/sysarch: Provide a per-arch framework for sysarch syscall Warner Losh
                   ` (2 subsequent siblings)
  13 siblings, 1 reply; 50+ messages in thread
From: Warner Losh @ 2021-09-22  6:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kyle Evans, richard.henderson, f4bug, Warner Losh

Convert the #ifdef'd i386 code to calling the i386 sysarch code we have
living in i386,x86_64/target_arch_sysarch.h do_freebsd_arch_sysarch
rather than having a separate copy. This is in preparation to remove it
entirely.

Signed-Off-By: Warner Losh <imp@bsdimp.com>
---
 bsd-user/syscall.c | 45 +--------------------------------------------
 1 file changed, 1 insertion(+), 44 deletions(-)

diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
index a579d52ede..9bc72501b2 100644
--- a/bsd-user/syscall.c
+++ b/bsd-user/syscall.c
@@ -91,50 +91,7 @@ static abi_long do_obreak(abi_ulong new_brk)
 #if defined(TARGET_I386)
 static abi_long do_freebsd_sysarch(CPUX86State *env, int op, abi_ulong parms)
 {
-    abi_long ret = 0;
-    abi_ulong val;
-    int idx;
-
-    switch (op) {
-#ifdef TARGET_ABI32
-    case TARGET_FREEBSD_I386_SET_GSBASE:
-    case TARGET_FREEBSD_I386_SET_FSBASE:
-        if (op == TARGET_FREEBSD_I386_SET_GSBASE)
-#else
-    case TARGET_FREEBSD_AMD64_SET_GSBASE:
-    case TARGET_FREEBSD_AMD64_SET_FSBASE:
-        if (op == TARGET_FREEBSD_AMD64_SET_GSBASE)
-#endif
-            idx = R_GS;
-        else
-            idx = R_FS;
-        if (get_user(val, parms, abi_ulong))
-            return -TARGET_EFAULT;
-        cpu_x86_load_seg(env, idx, 0);
-        env->segs[idx].base = val;
-        break;
-#ifdef TARGET_ABI32
-    case TARGET_FREEBSD_I386_GET_GSBASE:
-    case TARGET_FREEBSD_I386_GET_FSBASE:
-        if (op == TARGET_FREEBSD_I386_GET_GSBASE)
-#else
-    case TARGET_FREEBSD_AMD64_GET_GSBASE:
-    case TARGET_FREEBSD_AMD64_GET_FSBASE:
-        if (op == TARGET_FREEBSD_AMD64_GET_GSBASE)
-#endif
-            idx = R_GS;
-        else
-            idx = R_FS;
-        val = env->segs[idx].base;
-        if (put_user(val, parms, abi_ulong))
-            return -TARGET_EFAULT;
-        break;
-    /* XXX handle the others... */
-    default:
-        ret = -TARGET_EINVAL;
-        break;
-    }
-    return ret;
+    do_freebsd_arch_sysarch(env, op, parms);
 }
 #endif
 
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 12/14] bsd-user/sysarch: Provide a per-arch framework for sysarch syscall
  2021-09-22  6:14 [PATCH 00/14] bsd-user: misc cleanup for aarch64 import Warner Losh
                   ` (10 preceding siblings ...)
  2021-09-22  6:14 ` [PATCH 11/14] bsd-user/sysarch: Move to using do_freebsd_arch_sysarch interface Warner Losh
@ 2021-09-22  6:14 ` Warner Losh
  2021-09-23 18:08   ` Richard Henderson
  2021-09-25 10:46   ` Philippe Mathieu-Daudé
  2021-09-22  6:14 ` [PATCH 13/14] bsd-user: Rename sigqueue to qemu_sigqueue Warner Losh
  2021-09-22  6:14 ` [PATCH 14/14] bsd-user/signal: Create a dummy signal queueing function Warner Losh
  13 siblings, 2 replies; 50+ messages in thread
From: Warner Losh @ 2021-09-22  6:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kyle Evans, richard.henderson, f4bug, Warner Losh, Stacey Son

Add the missing glue to pull in do_freebsd_sysarch to call
do_freebsd_arch_sysarch. Put it in os-sys.c, which will be used for
sysctl and sysarch system calls because they are mostly arch specific.

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/freebsd/meson.build |  3 +++
 bsd-user/freebsd/os-sys.c    | 28 ++++++++++++++++++++++++++++
 bsd-user/meson.build         |  6 ++++++
 bsd-user/qemu.h              |  3 +++
 bsd-user/syscall.c           |  7 -------
 5 files changed, 40 insertions(+), 7 deletions(-)
 create mode 100644 bsd-user/freebsd/meson.build
 create mode 100644 bsd-user/freebsd/os-sys.c

diff --git a/bsd-user/freebsd/meson.build b/bsd-user/freebsd/meson.build
new file mode 100644
index 0000000000..4b69cca7b9
--- /dev/null
+++ b/bsd-user/freebsd/meson.build
@@ -0,0 +1,3 @@
+bsd_user_ss.add(files(
+  'os-sys.c',
+))
diff --git a/bsd-user/freebsd/os-sys.c b/bsd-user/freebsd/os-sys.c
new file mode 100644
index 0000000000..756b024305
--- /dev/null
+++ b/bsd-user/freebsd/os-sys.c
@@ -0,0 +1,28 @@
+/*
+ *  FreeBSD sysctl() and sysarch() system call emulation
+ *
+ *  Copyright (c) 2013-15 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/>.
+ */
+
+#include "qemu.h"
+#include "target_arch_sysarch.h"
+
+/* sysarch() is architecture dependent. */
+abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2)
+{
+
+    return do_freebsd_arch_sysarch(cpu_env, arg1, arg2);
+}
diff --git a/bsd-user/meson.build b/bsd-user/meson.build
index 0369549340..561913de05 100644
--- a/bsd-user/meson.build
+++ b/bsd-user/meson.build
@@ -8,3 +8,9 @@ bsd_user_ss.add(files(
   'syscall.c',
   'uaccess.c',
 ))
+
+# Pull in the OS-specific build glue, if any
+if fs.exists(targetos)
+   subdir(targetos)
+endif
+
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 4ee57b91f0..3dde381d5d 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -239,6 +239,9 @@ extern unsigned long target_sgrowsiz;
 abi_long get_errno(abi_long ret);
 int is_error(abi_long ret);
 
+/* os-sys.c */
+abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2);
+
 /* user access */
 
 #define VERIFY_READ  PAGE_READ
diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
index 9bc72501b2..9f51563abd 100644
--- a/bsd-user/syscall.c
+++ b/bsd-user/syscall.c
@@ -88,13 +88,6 @@ static abi_long do_obreak(abi_ulong new_brk)
     return 0;
 }
 
-#if defined(TARGET_I386)
-static abi_long do_freebsd_sysarch(CPUX86State *env, int op, abi_ulong parms)
-{
-    do_freebsd_arch_sysarch(env, op, parms);
-}
-#endif
-
 #ifdef __FreeBSD__
 /*
  * XXX this uses the undocumented oidfmt interface to find the kind of
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 13/14] bsd-user: Rename sigqueue to qemu_sigqueue
  2021-09-22  6:14 [PATCH 00/14] bsd-user: misc cleanup for aarch64 import Warner Losh
                   ` (11 preceding siblings ...)
  2021-09-22  6:14 ` [PATCH 12/14] bsd-user/sysarch: Provide a per-arch framework for sysarch syscall Warner Losh
@ 2021-09-22  6:14 ` Warner Losh
  2021-09-23 18:09   ` Richard Henderson
  2021-09-25 10:46   ` Philippe Mathieu-Daudé
  2021-09-22  6:14 ` [PATCH 14/14] bsd-user/signal: Create a dummy signal queueing function Warner Losh
  13 siblings, 2 replies; 50+ messages in thread
From: Warner Losh @ 2021-09-22  6:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kyle Evans, richard.henderson, f4bug, Warner Losh

To avoid a name clash with FreeBSD's sigqueue data structure in
signalvar.h, rename sigqueue to qemu_sigqueue. This sturcture
is currently defined, but unused.

Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/qemu.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 3dde381d5d..5a2fd87e44 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -73,15 +73,15 @@ struct image_info {
 
 #define MAX_SIGQUEUE_SIZE 1024
 
-struct sigqueue {
-    struct sigqueue *next;
+struct qemu_sigqueue {
+    struct qemu_sigqueue *next;
+    target_siginfo_t info;
 };
 
 struct emulated_sigtable {
     int pending; /* true if signal is pending */
-    struct sigqueue *first;
-    /* in order to always have memory for the first signal, we put it here */
-    struct sigqueue info;
+    struct qemu_sigqueue *first;
+    struct qemu_sigqueue info;	/* Put first signal info here */
 };
 
 /*
@@ -95,8 +95,8 @@ typedef struct TaskState {
     struct image_info *info;
 
     struct emulated_sigtable sigtab[TARGET_NSIG];
-    struct sigqueue sigqueue_table[MAX_SIGQUEUE_SIZE]; /* siginfo queue */
-    struct sigqueue *first_free; /* first free siginfo queue entry */
+    struct qemu_sigqueue sigqueue_table[MAX_SIGQUEUE_SIZE]; /* siginfo queue */
+    struct qemu_sigqueue *first_free; /* first free siginfo queue entry */
     int signal_pending; /* non zero if a signal may be pending */
 
     uint8_t stack[];
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 14/14] bsd-user/signal: Create a dummy signal queueing function
  2021-09-22  6:14 [PATCH 00/14] bsd-user: misc cleanup for aarch64 import Warner Losh
                   ` (12 preceding siblings ...)
  2021-09-22  6:14 ` [PATCH 13/14] bsd-user: Rename sigqueue to qemu_sigqueue Warner Losh
@ 2021-09-22  6:14 ` Warner Losh
  2021-09-23 18:13   ` Richard Henderson
  2021-09-25 10:50   ` Philippe Mathieu-Daudé
  13 siblings, 2 replies; 50+ messages in thread
From: Warner Losh @ 2021-09-22  6:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kyle Evans, richard.henderson, f4bug, Warner Losh

Create dummy signal queueing function so we can start to integrate other
architectures (at the cost of signals remaining broken) to tame the
dependency graph a bit and to bring in signals in a more controlled
fashion.

Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/qemu.h   | 1 +
 bsd-user/signal.c | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 5a2fd87e44..85d1f8fd2a 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -209,6 +209,7 @@ void process_pending_signals(CPUArchState *cpu_env);
 void signal_init(void);
 long do_sigreturn(CPUArchState *env);
 long do_rt_sigreturn(CPUArchState *env);
+int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info);
 abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong sp);
 
 /* mmap.c */
diff --git a/bsd-user/signal.c b/bsd-user/signal.c
index ad6d935569..4e7f618944 100644
--- a/bsd-user/signal.c
+++ b/bsd-user/signal.c
@@ -19,6 +19,14 @@
 #include "qemu/osdep.h"
 
 #include "qemu.h"
+/*
+ * Queue a signal so that it will be send to the virtual CPU as soon as
+ * possible.
+ */
+int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info)
+{
+    return 1;
+}
 
 void signal_init(void)
 {
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 50+ messages in thread

* Re: [PATCH 02/14] bsd-user/strace.list: Remove support for FreeBSD versions older than 12.0
  2021-09-22  6:14 ` [PATCH 02/14] bsd-user/strace.list: Remove support for FreeBSD versions " Warner Losh
@ 2021-09-23 17:57   ` Richard Henderson
  0 siblings, 0 replies; 50+ messages in thread
From: Richard Henderson @ 2021-09-23 17:57 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, f4bug

On 9/21/21 11:14 PM, Warner Losh wrote:
> Signed-off-by: Warner Losh<imp@bsdimp.com>
> ---
>   bsd-user/freebsd/strace.list | 11 -----------
>   1 file changed, 11 deletions(-)

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

r~


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 03/14] bsd-user: TARGET_RESET define is unused, remove it
  2021-09-22  6:14 ` [PATCH 03/14] bsd-user: TARGET_RESET define is unused, remove it Warner Losh
@ 2021-09-23 17:57   ` Richard Henderson
  2021-09-25 10:30   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 50+ messages in thread
From: Richard Henderson @ 2021-09-23 17:57 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, f4bug

On 9/21/21 11:14 PM, Warner Losh wrote:
> Signed-off-by: Warner Losh<imp@bsdimp.com>
> ---
>   bsd-user/i386/target_arch_cpu.h   | 2 --
>   bsd-user/x86_64/target_arch_cpu.h | 2 --
>   2 files changed, 4 deletions(-)

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

r~


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 04/14] bsd-user: export get_errno and is_error from syscall.c
  2021-09-22  6:14 ` [PATCH 04/14] bsd-user: export get_errno and is_error from syscall.c Warner Losh
@ 2021-09-23 17:58   ` Richard Henderson
  2021-09-25 10:33   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 50+ messages in thread
From: Richard Henderson @ 2021-09-23 17:58 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, f4bug

On 9/21/21 11:14 PM, Warner Losh wrote:
> Make get_errno and is_error global so files other than syscall.c can use
> them.
> 
> Signed-off-by: Warner Losh<imp@bsdimp.com>
> ---
>   bsd-user/qemu.h    |  4 ++++
>   bsd-user/syscall.c | 10 +++++-----
>   2 files changed, 9 insertions(+), 5 deletions(-)

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

r~


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 05/14] bsd-user/errno_defs.h: Add internal error numbers
  2021-09-22  6:14 ` [PATCH 05/14] bsd-user/errno_defs.h: Add internal error numbers Warner Losh
@ 2021-09-23 17:59   ` Richard Henderson
  0 siblings, 0 replies; 50+ messages in thread
From: Richard Henderson @ 2021-09-23 17:59 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, Stacey Son, f4bug

On 9/21/21 11:14 PM, Warner Losh wrote:
> From: Stacey Son<sson@FreeBSD.org>
> 
> To emulate signals and interrupted system calls, we need to have the
> same mechanisms we have in the kernel, including these errno values.
> 
> Signed-off-by: Stacey Son<sson@FreeBSD.org>
> Signed-off-by: Warner Losh<imp@bsdimp.com>
> ---
>   bsd-user/errno_defs.h | 14 +++++++++++---
>   1 file changed, 11 insertions(+), 3 deletions(-)

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

r~


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 06/14] bsd-user: move TARGET_MC_GET_CLEAR_RET to target_os_signal.h
  2021-09-22  6:14 ` [PATCH 06/14] bsd-user: move TARGET_MC_GET_CLEAR_RET to target_os_signal.h Warner Losh
@ 2021-09-23 18:00   ` Richard Henderson
  2021-09-25 10:35   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 50+ messages in thread
From: Richard Henderson @ 2021-09-23 18:00 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, f4bug

On 9/21/21 11:14 PM, Warner Losh wrote:
> Move TARGET_MC_GET_CLEAR_RET to freebsd/target_os_signal.h since it's
> FreeBSD-wide.
> 
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>   bsd-user/freebsd/target_os_signal.h  | 3 +++
>   bsd-user/i386/target_arch_signal.h   | 2 --
>   bsd-user/x86_64/target_arch_signal.h | 2 --
>   3 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/bsd-user/freebsd/target_os_signal.h b/bsd-user/freebsd/target_os_signal.h
> index 3ed454e086..9fcdfce003 100644
> --- a/bsd-user/freebsd/target_os_signal.h
> +++ b/bsd-user/freebsd/target_os_signal.h
> @@ -1,6 +1,9 @@
>   #ifndef _TARGET_OS_SIGNAL_H_
>   #define _TARGET_OS_SIGNAL_H_
>   
> +/* FreeBSD's sys/ucontex.h defines this */

ucontext

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

r~


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 07/14] bsd-user/target_os_elf.h: Remove fallback ELF_HWCAP and reorder
  2021-09-22  6:14 ` [PATCH 07/14] bsd-user/target_os_elf.h: Remove fallback ELF_HWCAP and reorder Warner Losh
@ 2021-09-23 18:01   ` Richard Henderson
  2021-09-25 10:36   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 50+ messages in thread
From: Richard Henderson @ 2021-09-23 18:01 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, f4bug

On 9/21/21 11:14 PM, Warner Losh wrote:
> All architectures have a ELF_HWCAP, so remove the fallback ifdef.
> Place ELF_HWCAP in the same order as on native FreeBSD.
> 
> Signed-off-by: Warner Losh<imp@bsdimp.com>
> ---
>   bsd-user/freebsd/target_os_elf.h | 8 ++------
>   1 file changed, 2 insertions(+), 6 deletions(-)

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

r~


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 08/14] bsd-user/target_os_elf: If ELF_HWCAP2 is defined, publish it
  2021-09-22  6:14 ` [PATCH 08/14] bsd-user/target_os_elf: If ELF_HWCAP2 is defined, publish it Warner Losh
@ 2021-09-23 18:01   ` Richard Henderson
  2021-09-25 10:37   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 50+ messages in thread
From: Richard Henderson @ 2021-09-23 18:01 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, f4bug

On 9/21/21 11:14 PM, Warner Losh wrote:
> Some architecutres publish AT_HWCAP2 as well as AT_HWCAP. Those
> architectures will define this in their target_arch_elf.h files.  If it
> is defined, then publish it.
> 
> Signed-off-by: Warner Losh<imp@bsdimp.com>
> ---
>   bsd-user/freebsd/target_os_elf.h | 4 ++++
>   1 file changed, 4 insertions(+)

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

r~


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 09/14] bsd-user: Remove used from TaskState
  2021-09-22  6:14 ` [PATCH 09/14] bsd-user: Remove used from TaskState Warner Losh
@ 2021-09-23 18:02   ` Richard Henderson
  2021-09-25 10:38   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 50+ messages in thread
From: Richard Henderson @ 2021-09-23 18:02 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, f4bug

On 9/21/21 11:14 PM, Warner Losh wrote:
> The used field of TaskState is write only. Eliminate it.
> 
> Signed-off-by: Warner Losh<imp@bsdimp.com>
> ---
>   bsd-user/main.c | 1 -
>   bsd-user/qemu.h | 1 -
>   2 files changed, 2 deletions(-)

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

r~


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 10/14] bsd-user: Add stop_all_tasks
  2021-09-22  6:14 ` [PATCH 10/14] bsd-user: Add stop_all_tasks Warner Losh
@ 2021-09-23 18:04   ` Richard Henderson
  0 siblings, 0 replies; 50+ messages in thread
From: Richard Henderson @ 2021-09-23 18:04 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, Stacey Son, f4bug

On 9/21/21 11:14 PM, Warner Losh wrote:
> +void stop_all_tasks(void)
> +{
> +    /*
> +     * We trust when using NPTL (pthreads) start_exclusive() handles thread
> +     * stopping correctly.
> +     */
> +    start_exclusive();
> +}

Eh.  It begs the question of why this is present, as opposed to calling start_exclusive 
directly for the one (1) use.  Looks to me like we should remove it.


r~



^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 11/14] bsd-user/sysarch: Move to using do_freebsd_arch_sysarch interface
  2021-09-22  6:14 ` [PATCH 11/14] bsd-user/sysarch: Move to using do_freebsd_arch_sysarch interface Warner Losh
@ 2021-09-23 18:07   ` Richard Henderson
  2021-09-24 15:25     ` Warner Losh
  0 siblings, 1 reply; 50+ messages in thread
From: Richard Henderson @ 2021-09-23 18:07 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, f4bug

On 9/21/21 11:14 PM, Warner Losh wrote:
> Convert the #ifdef'd i386 code to calling the i386 sysarch code we have
> living in i386,x86_64/target_arch_sysarch.h do_freebsd_arch_sysarch
> rather than having a separate copy. This is in preparation to remove it
> entirely.
> 
> Signed-Off-By: Warner Losh<imp@bsdimp.com>
> ---
>   bsd-user/syscall.c | 45 +--------------------------------------------
>   1 file changed, 1 insertion(+), 44 deletions(-)

It wasn't clear to me that this target_arch_sysarch.h file already exists, and is already 
populated with the code being (re)"moved" here.  Perhaps the wording here can be improved?

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


r~


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 12/14] bsd-user/sysarch: Provide a per-arch framework for sysarch syscall
  2021-09-22  6:14 ` [PATCH 12/14] bsd-user/sysarch: Provide a per-arch framework for sysarch syscall Warner Losh
@ 2021-09-23 18:08   ` Richard Henderson
  2021-09-25 10:46   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 50+ messages in thread
From: Richard Henderson @ 2021-09-23 18:08 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, Stacey Son, f4bug

On 9/21/21 11:14 PM, Warner Losh wrote:
> +/* sysarch() is architecture dependent. */
> +abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2)
> +{
> +
> +    return do_freebsd_arch_sysarch(cpu_env, arg1, arg2);
> +}

Extra newline.  Otherwise,

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

r~


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 13/14] bsd-user: Rename sigqueue to qemu_sigqueue
  2021-09-22  6:14 ` [PATCH 13/14] bsd-user: Rename sigqueue to qemu_sigqueue Warner Losh
@ 2021-09-23 18:09   ` Richard Henderson
  2021-09-25 10:46   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 50+ messages in thread
From: Richard Henderson @ 2021-09-23 18:09 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, f4bug

On 9/21/21 11:14 PM, Warner Losh wrote:
> To avoid a name clash with FreeBSD's sigqueue data structure in
> signalvar.h, rename sigqueue to qemu_sigqueue. This sturcture
> is currently defined, but unused.
> 
> Signed-off-by: Warner Losh<imp@bsdimp.com>
> ---
>   bsd-user/qemu.h | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)

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

r~


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 14/14] bsd-user/signal: Create a dummy signal queueing function
  2021-09-22  6:14 ` [PATCH 14/14] bsd-user/signal: Create a dummy signal queueing function Warner Losh
@ 2021-09-23 18:13   ` Richard Henderson
  2021-09-24 20:11     ` Warner Losh
  2021-09-26 18:14     ` Warner Losh
  2021-09-25 10:50   ` Philippe Mathieu-Daudé
  1 sibling, 2 replies; 50+ messages in thread
From: Richard Henderson @ 2021-09-23 18:13 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, f4bug

On 9/21/21 11:14 PM, Warner Losh wrote:
> Create dummy signal queueing function so we can start to integrate other
> architectures (at the cost of signals remaining broken) to tame the
> dependency graph a bit and to bring in signals in a more controlled
> fashion.
> 
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>   bsd-user/qemu.h   | 1 +
>   bsd-user/signal.c | 8 ++++++++
>   2 files changed, 9 insertions(+)
> 
> diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
> index 5a2fd87e44..85d1f8fd2a 100644
> --- a/bsd-user/qemu.h
> +++ b/bsd-user/qemu.h
> @@ -209,6 +209,7 @@ void process_pending_signals(CPUArchState *cpu_env);
>   void signal_init(void);
>   long do_sigreturn(CPUArchState *env);
>   long do_rt_sigreturn(CPUArchState *env);
> +int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info);
>   abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong sp);
>   
>   /* mmap.c */
> diff --git a/bsd-user/signal.c b/bsd-user/signal.c
> index ad6d935569..4e7f618944 100644
> --- a/bsd-user/signal.c
> +++ b/bsd-user/signal.c
> @@ -19,6 +19,14 @@
>   #include "qemu/osdep.h"
>   
>   #include "qemu.h"
> +/*

Whacky whitespace.

> + * Queue a signal so that it will be send to the virtual CPU as soon as
> + * possible.
> + */
> +int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info)
> +{
> +    return 1;
> +}

Both here and in linux-user, there are no error conditions.  We should change the return 
to void.

Also, consider folding in the signal-common.h cleanup soon.
But don't let either hold you up too much with rebasing.

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

r~


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 11/14] bsd-user/sysarch: Move to using do_freebsd_arch_sysarch interface
  2021-09-23 18:07   ` Richard Henderson
@ 2021-09-24 15:25     ` Warner Losh
  0 siblings, 0 replies; 50+ messages in thread
From: Warner Losh @ 2021-09-24 15:25 UTC (permalink / raw)
  To: Richard Henderson
  Cc: Kyle Evans, QEMU Developers, Philippe Mathieu-Daudé

[-- Attachment #1: Type: text/plain, Size: 884 bytes --]

On Fri, Sep 24, 2021 at 6:00 AM Richard Henderson <
richard.henderson@linaro.org> wrote:

> On 9/21/21 11:14 PM, Warner Losh wrote:
> > Convert the #ifdef'd i386 code to calling the i386 sysarch code we have
> > living in i386,x86_64/target_arch_sysarch.h do_freebsd_arch_sysarch
> > rather than having a separate copy. This is in preparation to remove it
> > entirely.
> >
> > Signed-Off-By: Warner Losh<imp@bsdimp.com>
> > ---
> >   bsd-user/syscall.c | 45 +--------------------------------------------
> >   1 file changed, 1 insertion(+), 44 deletions(-)
>
> It wasn't clear to me that this target_arch_sysarch.h file already exists,
> and is already
> populated with the code being (re)"moved" here.  Perhaps the wording here
> can be improved?
>

Will do. Good suggestion.


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

Thanks

Warner


>
> r~
>

[-- Attachment #2: Type: text/html, Size: 1785 bytes --]

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 14/14] bsd-user/signal: Create a dummy signal queueing function
  2021-09-23 18:13   ` Richard Henderson
@ 2021-09-24 20:11     ` Warner Losh
  2021-09-24 20:30       ` Kyle Evans
  2021-09-24 23:51       ` Richard Henderson
  2021-09-26 18:14     ` Warner Losh
  1 sibling, 2 replies; 50+ messages in thread
From: Warner Losh @ 2021-09-24 20:11 UTC (permalink / raw)
  To: Richard Henderson
  Cc: Kyle Evans, QEMU Developers, Philippe Mathieu-Daudé

[-- Attachment #1: Type: text/plain, Size: 2715 bytes --]

On Fri, Sep 24, 2021 at 6:00 AM Richard Henderson <
richard.henderson@linaro.org> wrote:

> On 9/21/21 11:14 PM, Warner Losh wrote:
> > Create dummy signal queueing function so we can start to integrate other
> > architectures (at the cost of signals remaining broken) to tame the
> > dependency graph a bit and to bring in signals in a more controlled
> > fashion.
> >
> > Signed-off-by: Warner Losh <imp@bsdimp.com>
> > ---
> >   bsd-user/qemu.h   | 1 +
> >   bsd-user/signal.c | 8 ++++++++
> >   2 files changed, 9 insertions(+)
> >
> > diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
> > index 5a2fd87e44..85d1f8fd2a 100644
> > --- a/bsd-user/qemu.h
> > +++ b/bsd-user/qemu.h
> > @@ -209,6 +209,7 @@ void process_pending_signals(CPUArchState *cpu_env);
> >   void signal_init(void);
> >   long do_sigreturn(CPUArchState *env);
> >   long do_rt_sigreturn(CPUArchState *env);
> > +int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info);
> >   abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr,
> abi_ulong sp);
> >
> >   /* mmap.c */
> > diff --git a/bsd-user/signal.c b/bsd-user/signal.c
> > index ad6d935569..4e7f618944 100644
> > --- a/bsd-user/signal.c
> > +++ b/bsd-user/signal.c
> > @@ -19,6 +19,14 @@
> >   #include "qemu/osdep.h"
> >
> >   #include "qemu.h"
> > +/*
>
> Whacky whitespace.
>

fixed.


> > + * Queue a signal so that it will be send to the virtual CPU as soon as
> > + * possible.
> > + */
> > +int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info)
> > +{
> > +    return 1;
> > +}
>
> Both here and in linux-user, there are no error conditions.  We should
> change the return
> to void.
>

I'll prep a patch to follow up for both linux and bsd user.


> Also, consider folding in the signal-common.h cleanup soon.
> But don't let either hold you up too much with rebasing.
>

It's on my list. This 'dummy' routine is just to get things linking to
help simplify the rather tangled dependency tree to get things
in, still have them compile and still have at least simple hello
world continue to work. Behind these reviews are three streams
of patches for 3 more architectures: arm, aarch64 and riscv64.

I'll create a patch for both linux-user and fix in bsd-user as part of the
signal.c upstreaming I'm working on.

It brings to mind something else... There's times it might be easier
to refactor between bsd-user and linux-user rather than upstream
something that's largely copied from linux-user. Is there a good
way to do that and talk about the design before I sink a ton of time
into something that's the wrong direction?

Thanks for the reviews and feedback.

Warner


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

[-- Attachment #2: Type: text/html, Size: 4236 bytes --]

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 14/14] bsd-user/signal: Create a dummy signal queueing function
  2021-09-24 20:11     ` Warner Losh
@ 2021-09-24 20:30       ` Kyle Evans
  2021-09-24 23:51       ` Richard Henderson
  1 sibling, 0 replies; 50+ messages in thread
From: Kyle Evans @ 2021-09-24 20:30 UTC (permalink / raw)
  To: Warner Losh
  Cc: Richard Henderson, QEMU Developers, Philippe Mathieu-Daudé

On Fri, Sep 24, 2021 at 3:11 PM Warner Losh <imp@bsdimp.com> wrote:
>
>
>
> On Fri, Sep 24, 2021 at 6:00 AM Richard Henderson <richard.henderson@linaro.org> wrote:
>>
>> On 9/21/21 11:14 PM, Warner Losh wrote:
>> > Create dummy signal queueing function so we can start to integrate other
>> > architectures (at the cost of signals remaining broken) to tame the
>> > dependency graph a bit and to bring in signals in a more controlled
>> > fashion.
>> >
>> > Signed-off-by: Warner Losh <imp@bsdimp.com>
>> > ---
>> >   bsd-user/qemu.h   | 1 +
>> >   bsd-user/signal.c | 8 ++++++++
>> >   2 files changed, 9 insertions(+)
>> >
>> > diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
>> > index 5a2fd87e44..85d1f8fd2a 100644
>> > --- a/bsd-user/qemu.h
>> > +++ b/bsd-user/qemu.h
>> > @@ -209,6 +209,7 @@ void process_pending_signals(CPUArchState *cpu_env);
>> >   void signal_init(void);
>> >   long do_sigreturn(CPUArchState *env);
>> >   long do_rt_sigreturn(CPUArchState *env);
>> > +int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info);
>> >   abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong sp);
>> >
>> >   /* mmap.c */
>> > diff --git a/bsd-user/signal.c b/bsd-user/signal.c
>> > index ad6d935569..4e7f618944 100644
>> > --- a/bsd-user/signal.c
>> > +++ b/bsd-user/signal.c
>> > @@ -19,6 +19,14 @@
>> >   #include "qemu/osdep.h"
>> >
>> >   #include "qemu.h"
>> > +/*
>>
>> Whacky whitespace.
>
>
> fixed.
>
>>
>> > + * Queue a signal so that it will be send to the virtual CPU as soon as
>> > + * possible.
>> > + */
>> > +int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info)
>> > +{
>> > +    return 1;
>> > +}
>>
>> Both here and in linux-user, there are no error conditions.  We should change the return
>> to void.
>
>
> I'll prep a patch to follow up for both linux and bsd user.
>
>>
>> Also, consider folding in the signal-common.h cleanup soon.
>> But don't let either hold you up too much with rebasing.
>
>
> It's on my list. This 'dummy' routine is just to get things linking to
> help simplify the rather tangled dependency tree to get things
> in, still have them compile and still have at least simple hello
> world continue to work. Behind these reviews are three streams
> of patches for 3 more architectures: arm, aarch64 and riscv64.
>
> I'll create a patch for both linux-user and fix in bsd-user as part of the
> signal.c upstreaming I'm working on.
>
> It brings to mind something else... There's times it might be easier
> to refactor between bsd-user and linux-user rather than upstream
> something that's largely copied from linux-user. Is there a good
> way to do that and talk about the design before I sink a ton of time
> into something that's the wrong direction?
>

I had a proposal on this list a long while back to refactor some stuff
into a top-level qemu-user that could be shared between the two,
starting with safe_syscall (which syscall can be substantially
shared), but it hadn't received any traction at that time.

Thanks,

Kyle Evans


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 14/14] bsd-user/signal: Create a dummy signal queueing function
  2021-09-24 20:11     ` Warner Losh
  2021-09-24 20:30       ` Kyle Evans
@ 2021-09-24 23:51       ` Richard Henderson
  1 sibling, 0 replies; 50+ messages in thread
From: Richard Henderson @ 2021-09-24 23:51 UTC (permalink / raw)
  To: Warner Losh
  Cc: Kyle Evans, Laurent Vivier, QEMU Developers, Philippe Mathieu-Daudé

On 9/24/21 4:11 PM, Warner Losh wrote:
> It brings to mind something else... There's times it might be easier
> to refactor between bsd-user and linux-user rather than upstream
> something that's largely copied from linux-user. Is there a good
> way to do that and talk about the design before I sink a ton of time
> into something that's the wrong direction?

I certainly wouldn't mind a top-level user-only/ or posix-only/ in which we could share 
code between {linux,bsd}-user/, but I don't have a good idea of what that would look like.

Already you have code for MAP_EXCL that doesn't exist for linux (though there is a new, 
related, MAP_FIXED_NOREPLACE, which linux-user/ does not yet support).  So even with 
"obvious" routines I'm not sure how much real sharing we can get away with.

All I can say is: patches welcome, and we'll bike-shed them as they come.


r~


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 03/14] bsd-user: TARGET_RESET define is unused, remove it
  2021-09-22  6:14 ` [PATCH 03/14] bsd-user: TARGET_RESET define is unused, remove it Warner Losh
  2021-09-23 17:57   ` Richard Henderson
@ 2021-09-25 10:30   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 50+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 10:30 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, richard.henderson

On 9/22/21 08:14, Warner Losh wrote:
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>   bsd-user/i386/target_arch_cpu.h   | 2 --
>   bsd-user/x86_64/target_arch_cpu.h | 2 --
>   2 files changed, 4 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 04/14] bsd-user: export get_errno and is_error from syscall.c
  2021-09-22  6:14 ` [PATCH 04/14] bsd-user: export get_errno and is_error from syscall.c Warner Losh
  2021-09-23 17:58   ` Richard Henderson
@ 2021-09-25 10:33   ` Philippe Mathieu-Daudé
  2021-09-26 17:14     ` Warner Losh
  1 sibling, 1 reply; 50+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 10:33 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, richard.henderson

On 9/22/21 08:14, Warner Losh wrote:
> Make get_errno and is_error global so files other than syscall.c can use
> them.
> 
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>   bsd-user/qemu.h    |  4 ++++
>   bsd-user/syscall.c | 10 +++++-----
>   2 files changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
> index 522d6c4031..22fc3a6c30 100644
> --- a/bsd-user/qemu.h
> +++ b/bsd-user/qemu.h
> @@ -235,6 +235,10 @@ extern unsigned long target_dflssiz;
>   extern unsigned long target_maxssiz;
>   extern unsigned long target_sgrowsiz;
>   
> +/* syscall.c */
> +abi_long get_errno(abi_long ret);
> +int is_error(abi_long ret);
> +
>   /* user access */
>   
>   #define VERIFY_READ  PAGE_READ
> diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
> index 372836d44d..a579d52ede 100644
> --- a/bsd-user/syscall.c
> +++ b/bsd-user/syscall.c
> @@ -33,18 +33,18 @@
>   static abi_ulong target_brk;
>   static abi_ulong target_original_brk;
>   
> -static inline abi_long get_errno(abi_long ret)
> +abi_long get_errno(abi_long ret)
>   {
> -    if (ret == -1)
> +    if (ret == -1) {
>           /* XXX need to translate host -> target errnos here */
>           return -(errno);
> -    else
> -        return ret;
> +    }
> +    return ret;
>   }
>   
>   #define target_to_host_bitmask(x, tbl) (x)
>   
> -static inline int is_error(abi_long ret)
> +int is_error(abi_long ret)

Since you are modifying this, do you mind having it return
a boolean type instead?

>   {
>       return (abi_ulong)ret >= (abi_ulong)(-4096);
>   }
> 

Preferably having is_error() returning bool:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 06/14] bsd-user: move TARGET_MC_GET_CLEAR_RET to target_os_signal.h
  2021-09-22  6:14 ` [PATCH 06/14] bsd-user: move TARGET_MC_GET_CLEAR_RET to target_os_signal.h Warner Losh
  2021-09-23 18:00   ` Richard Henderson
@ 2021-09-25 10:35   ` Philippe Mathieu-Daudé
  2021-09-26 17:16     ` Warner Losh
  1 sibling, 1 reply; 50+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 10:35 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, richard.henderson

On 9/22/21 08:14, Warner Losh wrote:
> Move TARGET_MC_GET_CLEAR_RET to freebsd/target_os_signal.h since it's
> FreeBSD-wide.

"architecture agnostic (on FreeBSD)" instead?

> 
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>   bsd-user/freebsd/target_os_signal.h  | 3 +++
>   bsd-user/i386/target_arch_signal.h   | 2 --
>   bsd-user/x86_64/target_arch_signal.h | 2 --
>   3 files changed, 3 insertions(+), 4 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 07/14] bsd-user/target_os_elf.h: Remove fallback ELF_HWCAP and reorder
  2021-09-22  6:14 ` [PATCH 07/14] bsd-user/target_os_elf.h: Remove fallback ELF_HWCAP and reorder Warner Losh
  2021-09-23 18:01   ` Richard Henderson
@ 2021-09-25 10:36   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 50+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 10:36 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, richard.henderson

On 9/22/21 08:14, Warner Losh wrote:
> All architectures have a ELF_HWCAP, so remove the fallback ifdef.
> Place ELF_HWCAP in the same order as on native FreeBSD.
> 
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>   bsd-user/freebsd/target_os_elf.h | 8 ++------
>   1 file changed, 2 insertions(+), 6 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 08/14] bsd-user/target_os_elf: If ELF_HWCAP2 is defined, publish it
  2021-09-22  6:14 ` [PATCH 08/14] bsd-user/target_os_elf: If ELF_HWCAP2 is defined, publish it Warner Losh
  2021-09-23 18:01   ` Richard Henderson
@ 2021-09-25 10:37   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 50+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 10:37 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, richard.henderson

On 9/22/21 08:14, Warner Losh wrote:
> Some architecutres publish AT_HWCAP2 as well as AT_HWCAP. Those

Typo "architectures"

> architectures will define this in their target_arch_elf.h files.  If it
> is defined, then publish it.
> 
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>   bsd-user/freebsd/target_os_elf.h | 4 ++++
>   1 file changed, 4 insertions(+)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 09/14] bsd-user: Remove used from TaskState
  2021-09-22  6:14 ` [PATCH 09/14] bsd-user: Remove used from TaskState Warner Losh
  2021-09-23 18:02   ` Richard Henderson
@ 2021-09-25 10:38   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 50+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 10:38 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, richard.henderson

On 9/22/21 08:14, Warner Losh wrote:
> The used field of TaskState is write only. Eliminate it.

The 'used' field ...

> 
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>   bsd-user/main.c | 1 -
>   bsd-user/qemu.h | 1 -
>   2 files changed, 2 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 12/14] bsd-user/sysarch: Provide a per-arch framework for sysarch syscall
  2021-09-22  6:14 ` [PATCH 12/14] bsd-user/sysarch: Provide a per-arch framework for sysarch syscall Warner Losh
  2021-09-23 18:08   ` Richard Henderson
@ 2021-09-25 10:46   ` Philippe Mathieu-Daudé
  2021-09-26 17:21     ` Warner Losh
  1 sibling, 1 reply; 50+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 10:46 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, richard.henderson, Stacey Son

Hi Warner,

On 9/22/21 08:14, Warner Losh wrote:
> Add the missing glue to pull in do_freebsd_sysarch to call
> do_freebsd_arch_sysarch. Put it in os-sys.c, which will be used for
> sysctl and sysarch system calls because they are mostly arch specific.
> 
> Signed-off-by: Stacey Son <sson@FreeBSD.org>
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>   bsd-user/freebsd/meson.build |  3 +++
>   bsd-user/freebsd/os-sys.c    | 28 ++++++++++++++++++++++++++++
>   bsd-user/meson.build         |  6 ++++++
>   bsd-user/qemu.h              |  3 +++
>   bsd-user/syscall.c           |  7 -------
>   5 files changed, 40 insertions(+), 7 deletions(-)
>   create mode 100644 bsd-user/freebsd/meson.build
>   create mode 100644 bsd-user/freebsd/os-sys.c

> +/* sysarch() is architecture dependent. */
> +abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2)
> +{
> +
> +    return do_freebsd_arch_sysarch(cpu_env, arg1, arg2);
> +}
> diff --git a/bsd-user/meson.build b/bsd-user/meson.build
> index 0369549340..561913de05 100644
> --- a/bsd-user/meson.build
> +++ b/bsd-user/meson.build
> @@ -8,3 +8,9 @@ bsd_user_ss.add(files(
>     'syscall.c',
>     'uaccess.c',
>   ))
> +
> +# Pull in the OS-specific build glue, if any
> +if fs.exists(targetos)
> +   subdir(targetos)

I am a bit confused here, we have an optional implementation ...

> +endif
> +
> diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
> index 4ee57b91f0..3dde381d5d 100644
> --- a/bsd-user/qemu.h
> +++ b/bsd-user/qemu.h
> @@ -239,6 +239,9 @@ extern unsigned long target_sgrowsiz;
>   abi_long get_errno(abi_long ret);
>   int is_error(abi_long ret);
>   
> +/* os-sys.c */
> +abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2);

... that is declared as non-optional.

In fact it is called by do_freebsd_syscall(), not restricted to TARGET_I386.

This shouldn't be (meson) optional IMO.

> +
>   /* user access */
>   
>   #define VERIFY_READ  PAGE_READ
> diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
> index 9bc72501b2..9f51563abd 100644
> --- a/bsd-user/syscall.c
> +++ b/bsd-user/syscall.c
> @@ -88,13 +88,6 @@ static abi_long do_obreak(abi_ulong new_brk)
>       return 0;
>   }
>   
> -#if defined(TARGET_I386)
> -static abi_long do_freebsd_sysarch(CPUX86State *env, int op, abi_ulong parms)
> -{
> -    do_freebsd_arch_sysarch(env, op, parms);
> -}
> -#endif
> -
>   #ifdef __FreeBSD__
>   /*
>    * XXX this uses the undocumented oidfmt interface to find the kind of
> 


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 13/14] bsd-user: Rename sigqueue to qemu_sigqueue
  2021-09-22  6:14 ` [PATCH 13/14] bsd-user: Rename sigqueue to qemu_sigqueue Warner Losh
  2021-09-23 18:09   ` Richard Henderson
@ 2021-09-25 10:46   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 50+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 10:46 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, richard.henderson

On 9/22/21 08:14, Warner Losh wrote:
> To avoid a name clash with FreeBSD's sigqueue data structure in
> signalvar.h, rename sigqueue to qemu_sigqueue. This sturcture
> is currently defined, but unused.
> 
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>   bsd-user/qemu.h | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 14/14] bsd-user/signal: Create a dummy signal queueing function
  2021-09-22  6:14 ` [PATCH 14/14] bsd-user/signal: Create a dummy signal queueing function Warner Losh
  2021-09-23 18:13   ` Richard Henderson
@ 2021-09-25 10:50   ` Philippe Mathieu-Daudé
  2021-09-25 14:53     ` Warner Losh
  1 sibling, 1 reply; 50+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-25 10:50 UTC (permalink / raw)
  To: Warner Losh, qemu-devel; +Cc: Kyle Evans, richard.henderson

On 9/22/21 08:14, Warner Losh wrote:
> Create dummy signal queueing function so we can start to integrate other
> architectures (at the cost of signals remaining broken) to tame the
> dependency graph a bit and to bring in signals in a more controlled
> fashion.
> 
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>   bsd-user/qemu.h   | 1 +
>   bsd-user/signal.c | 8 ++++++++
>   2 files changed, 9 insertions(+)
> 
> diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
> index 5a2fd87e44..85d1f8fd2a 100644
> --- a/bsd-user/qemu.h
> +++ b/bsd-user/qemu.h
> @@ -209,6 +209,7 @@ void process_pending_signals(CPUArchState *cpu_env);
>   void signal_init(void);
>   long do_sigreturn(CPUArchState *env);
>   long do_rt_sigreturn(CPUArchState *env);
> +int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info);
>   abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong sp);
>   
>   /* mmap.c */
> diff --git a/bsd-user/signal.c b/bsd-user/signal.c
> index ad6d935569..4e7f618944 100644
> --- a/bsd-user/signal.c
> +++ b/bsd-user/signal.c
> @@ -19,6 +19,14 @@
>   #include "qemu/osdep.h"
>   
>   #include "qemu.h"
> +/*
> + * Queue a signal so that it will be send to the virtual CPU as soon as
> + * possible.
> + */
> +int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info)
> +{
> +    return 1;

Shouldn't we abort() here or at least call qemu_log_mask(LOG_UNIMP)?

> +}
>   
>   void signal_init(void)
>   {
> 


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 14/14] bsd-user/signal: Create a dummy signal queueing function
  2021-09-25 10:50   ` Philippe Mathieu-Daudé
@ 2021-09-25 14:53     ` Warner Losh
  2021-09-26  3:06       ` Warner Losh
  0 siblings, 1 reply; 50+ messages in thread
From: Warner Losh @ 2021-09-25 14:53 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Kyle Evans, Richard Henderson, QEMU Developers

[-- Attachment #1: Type: text/plain, Size: 2004 bytes --]

On Sat, Sep 25, 2021, 4:50 AM Philippe Mathieu-Daudé <f4bug@amsat.org>
wrote:

> On 9/22/21 08:14, Warner Losh wrote:
> > Create dummy signal queueing function so we can start to integrate other
> > architectures (at the cost of signals remaining broken) to tame the
> > dependency graph a bit and to bring in signals in a more controlled
> > fashion.
> >
> > Signed-off-by: Warner Losh <imp@bsdimp.com>
> > ---
> >   bsd-user/qemu.h   | 1 +
> >   bsd-user/signal.c | 8 ++++++++
> >   2 files changed, 9 insertions(+)
> >
> > diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
> > index 5a2fd87e44..85d1f8fd2a 100644
> > --- a/bsd-user/qemu.h
> > +++ b/bsd-user/qemu.h
> > @@ -209,6 +209,7 @@ void process_pending_signals(CPUArchState *cpu_env);
> >   void signal_init(void);
> >   long do_sigreturn(CPUArchState *env);
> >   long do_rt_sigreturn(CPUArchState *env);
> > +int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info);
> >   abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr,
> abi_ulong sp);
> >
> >   /* mmap.c */
> > diff --git a/bsd-user/signal.c b/bsd-user/signal.c
> > index ad6d935569..4e7f618944 100644
> > --- a/bsd-user/signal.c
> > +++ b/bsd-user/signal.c
> > @@ -19,6 +19,14 @@
> >   #include "qemu/osdep.h"
> >
> >   #include "qemu.h"
> > +/*
> > + * Queue a signal so that it will be send to the virtual CPU as soon as
> > + * possible.
> > + */
> > +int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info)
> > +{
> > +    return 1;
>
> Shouldn't we abort() here or at least call qemu_log_mask(LOG_UNIMP)?
>

Sure. This code is just a placeholder for the moment so that I can prepare
the full signal.c later, but still be able to submit my next 3 patch series
which add aarch64, arm and riscv64. It can be anything you'd like without
generating conflicts.

When I spin the next version I'll have at least an abort here.

Warner

> +}
> >
> >   void signal_init(void)
> >   {
> >
>

[-- Attachment #2: Type: text/html, Size: 2964 bytes --]

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 14/14] bsd-user/signal: Create a dummy signal queueing function
  2021-09-25 14:53     ` Warner Losh
@ 2021-09-26  3:06       ` Warner Losh
  0 siblings, 0 replies; 50+ messages in thread
From: Warner Losh @ 2021-09-26  3:06 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Kyle Evans, Richard Henderson, QEMU Developers

[-- Attachment #1: Type: text/plain, Size: 2368 bytes --]

On Sat, Sep 25, 2021 at 8:53 AM Warner Losh <imp@bsdimp.com> wrote:

>
>
> On Sat, Sep 25, 2021, 4:50 AM Philippe Mathieu-Daudé <f4bug@amsat.org>
> wrote:
>
>> On 9/22/21 08:14, Warner Losh wrote:
>> > Create dummy signal queueing function so we can start to integrate other
>> > architectures (at the cost of signals remaining broken) to tame the
>> > dependency graph a bit and to bring in signals in a more controlled
>> > fashion.
>> >
>> > Signed-off-by: Warner Losh <imp@bsdimp.com>
>> > ---
>> >   bsd-user/qemu.h   | 1 +
>> >   bsd-user/signal.c | 8 ++++++++
>> >   2 files changed, 9 insertions(+)
>> >
>> > diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
>> > index 5a2fd87e44..85d1f8fd2a 100644
>> > --- a/bsd-user/qemu.h
>> > +++ b/bsd-user/qemu.h
>> > @@ -209,6 +209,7 @@ void process_pending_signals(CPUArchState *cpu_env);
>> >   void signal_init(void);
>> >   long do_sigreturn(CPUArchState *env);
>> >   long do_rt_sigreturn(CPUArchState *env);
>> > +int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info);
>> >   abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr,
>> abi_ulong sp);
>> >
>> >   /* mmap.c */
>> > diff --git a/bsd-user/signal.c b/bsd-user/signal.c
>> > index ad6d935569..4e7f618944 100644
>> > --- a/bsd-user/signal.c
>> > +++ b/bsd-user/signal.c
>> > @@ -19,6 +19,14 @@
>> >   #include "qemu/osdep.h"
>> >
>> >   #include "qemu.h"
>> > +/*
>> > + * Queue a signal so that it will be send to the virtual CPU as soon as
>> > + * possible.
>> > + */
>> > +int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info)
>> > +{
>> > +    return 1;
>>
>> Shouldn't we abort() here or at least call qemu_log_mask(LOG_UNIMP)?
>>
>
> Sure. This code is just a placeholder for the moment so that I can prepare
> the full signal.c later, but still be able to submit my next 3 patch series
> which add aarch64, arm and riscv64. It can be anything you'd like without
> generating conflicts.
>
> When I spin the next version I'll have at least an abort here.
>

I'll add the log_unimp stuff too. In debugging something else, I've learned
how to use qemu_log and will convert a few things as well (though I'm not
yet sure the sequencing of those upstream).

Warner


> Warner
>
> > +}
>> >
>> >   void signal_init(void)
>> >   {
>> >
>>
>

[-- Attachment #2: Type: text/html, Size: 3818 bytes --]

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 04/14] bsd-user: export get_errno and is_error from syscall.c
  2021-09-25 10:33   ` Philippe Mathieu-Daudé
@ 2021-09-26 17:14     ` Warner Losh
  0 siblings, 0 replies; 50+ messages in thread
From: Warner Losh @ 2021-09-26 17:14 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Kyle Evans, Richard Henderson, QEMU Developers

[-- Attachment #1: Type: text/plain, Size: 2043 bytes --]

On Sat, Sep 25, 2021 at 4:33 AM Philippe Mathieu-Daudé <f4bug@amsat.org>
wrote:

> On 9/22/21 08:14, Warner Losh wrote:
> > Make get_errno and is_error global so files other than syscall.c can use
> > them.
> >
> > Signed-off-by: Warner Losh <imp@bsdimp.com>
> > ---
> >   bsd-user/qemu.h    |  4 ++++
> >   bsd-user/syscall.c | 10 +++++-----
> >   2 files changed, 9 insertions(+), 5 deletions(-)
> >
> > diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
> > index 522d6c4031..22fc3a6c30 100644
> > --- a/bsd-user/qemu.h
> > +++ b/bsd-user/qemu.h
> > @@ -235,6 +235,10 @@ extern unsigned long target_dflssiz;
> >   extern unsigned long target_maxssiz;
> >   extern unsigned long target_sgrowsiz;
> >
> > +/* syscall.c */
> > +abi_long get_errno(abi_long ret);
> > +int is_error(abi_long ret);
> > +
> >   /* user access */
> >
> >   #define VERIFY_READ  PAGE_READ
> > diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
> > index 372836d44d..a579d52ede 100644
> > --- a/bsd-user/syscall.c
> > +++ b/bsd-user/syscall.c
> > @@ -33,18 +33,18 @@
> >   static abi_ulong target_brk;
> >   static abi_ulong target_original_brk;
> >
> > -static inline abi_long get_errno(abi_long ret)
> > +abi_long get_errno(abi_long ret)
> >   {
> > -    if (ret == -1)
> > +    if (ret == -1) {
> >           /* XXX need to translate host -> target errnos here */
> >           return -(errno);
> > -    else
> > -        return ret;
> > +    }
> > +    return ret;
> >   }
> >
> >   #define target_to_host_bitmask(x, tbl) (x)
> >
> > -static inline int is_error(abi_long ret)
> > +int is_error(abi_long ret)
>
> Since you are modifying this, do you mind having it return
> a boolean type instead?
>

Nah, don't mind. There were no problems caused by making that change.


> >   {
> >       return (abi_ulong)ret >= (abi_ulong)(-4096);
> >   }
> >
>
> Preferably having is_error() returning bool:
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>

Thanks for the suggestion.

Warner

[-- Attachment #2: Type: text/html, Size: 3043 bytes --]

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 06/14] bsd-user: move TARGET_MC_GET_CLEAR_RET to target_os_signal.h
  2021-09-25 10:35   ` Philippe Mathieu-Daudé
@ 2021-09-26 17:16     ` Warner Losh
  0 siblings, 0 replies; 50+ messages in thread
From: Warner Losh @ 2021-09-26 17:16 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Kyle Evans, Richard Henderson, QEMU Developers

[-- Attachment #1: Type: text/plain, Size: 674 bytes --]

On Sat, Sep 25, 2021 at 4:35 AM Philippe Mathieu-Daudé <f4bug@amsat.org>
wrote:

> On 9/22/21 08:14, Warner Losh wrote:
> > Move TARGET_MC_GET_CLEAR_RET to freebsd/target_os_signal.h since it's
> > FreeBSD-wide.
>
> "architecture agnostic (on FreeBSD)" instead?
>

I like that language better. Thanks for the suggestion.


> >
> > Signed-off-by: Warner Losh <imp@bsdimp.com>
> > ---
> >   bsd-user/freebsd/target_os_signal.h  | 3 +++
> >   bsd-user/i386/target_arch_signal.h   | 2 --
> >   bsd-user/x86_64/target_arch_signal.h | 2 --
> >   3 files changed, 3 insertions(+), 4 deletions(-)
>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>

[-- Attachment #2: Type: text/html, Size: 1332 bytes --]

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 12/14] bsd-user/sysarch: Provide a per-arch framework for sysarch syscall
  2021-09-25 10:46   ` Philippe Mathieu-Daudé
@ 2021-09-26 17:21     ` Warner Losh
  0 siblings, 0 replies; 50+ messages in thread
From: Warner Losh @ 2021-09-26 17:21 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Kyle Evans, Richard Henderson, QEMU Developers, Stacey Son

[-- Attachment #1: Type: text/plain, Size: 3083 bytes --]

On Sat, Sep 25, 2021 at 4:46 AM Philippe Mathieu-Daudé <f4bug@amsat.org>
wrote:

> Hi Warner,
>
> On 9/22/21 08:14, Warner Losh wrote:
> > Add the missing glue to pull in do_freebsd_sysarch to call
> > do_freebsd_arch_sysarch. Put it in os-sys.c, which will be used for
> > sysctl and sysarch system calls because they are mostly arch specific.
> >
> > Signed-off-by: Stacey Son <sson@FreeBSD.org>
> > Signed-off-by: Warner Losh <imp@bsdimp.com>
> > ---
> >   bsd-user/freebsd/meson.build |  3 +++
> >   bsd-user/freebsd/os-sys.c    | 28 ++++++++++++++++++++++++++++
> >   bsd-user/meson.build         |  6 ++++++
> >   bsd-user/qemu.h              |  3 +++
> >   bsd-user/syscall.c           |  7 -------
> >   5 files changed, 40 insertions(+), 7 deletions(-)
> >   create mode 100644 bsd-user/freebsd/meson.build
> >   create mode 100644 bsd-user/freebsd/os-sys.c
>
> > +/* sysarch() is architecture dependent. */
> > +abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2)
> > +{
> > +
> > +    return do_freebsd_arch_sysarch(cpu_env, arg1, arg2);
> > +}
> > diff --git a/bsd-user/meson.build b/bsd-user/meson.build
> > index 0369549340..561913de05 100644
> > --- a/bsd-user/meson.build
> > +++ b/bsd-user/meson.build
> > @@ -8,3 +8,9 @@ bsd_user_ss.add(files(
> >     'syscall.c',
> >     'uaccess.c',
> >   ))
> > +
> > +# Pull in the OS-specific build glue, if any
> > +if fs.exists(targetos)
> > +   subdir(targetos)
>
> I am a bit confused here, we have an optional implementation ...
>
> > +endif
> > +
> > diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
> > index 4ee57b91f0..3dde381d5d 100644
> > --- a/bsd-user/qemu.h
> > +++ b/bsd-user/qemu.h
> > @@ -239,6 +239,9 @@ extern unsigned long target_sgrowsiz;
> >   abi_long get_errno(abi_long ret);
> >   int is_error(abi_long ret);
> >
> > +/* os-sys.c */
> > +abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long
> arg2);
>
> ... that is declared as non-optional.
>
> In fact it is called by do_freebsd_syscall(), not restricted to
> TARGET_I386.
>
> This shouldn't be (meson) optional IMO.
>

I made it optional because we descend into this directory even
for linux targets when building linux-user on at least ubuntu (and
I think all linux targets).

Your comment suggests that I need to have a different meson fix
for this situation...

Warner


> > +
> >   /* user access */
> >
> >   #define VERIFY_READ  PAGE_READ
> > diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
> > index 9bc72501b2..9f51563abd 100644
> > --- a/bsd-user/syscall.c
> > +++ b/bsd-user/syscall.c
> > @@ -88,13 +88,6 @@ static abi_long do_obreak(abi_ulong new_brk)
> >       return 0;
> >   }
> >
> > -#if defined(TARGET_I386)
> > -static abi_long do_freebsd_sysarch(CPUX86State *env, int op, abi_ulong
> parms)
> > -{
> > -    do_freebsd_arch_sysarch(env, op, parms);
> > -}
> > -#endif
> > -
> >   #ifdef __FreeBSD__
> >   /*
> >    * XXX this uses the undocumented oidfmt interface to find the kind of
> >
>

[-- Attachment #2: Type: text/html, Size: 4152 bytes --]

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 14/14] bsd-user/signal: Create a dummy signal queueing function
  2021-09-23 18:13   ` Richard Henderson
  2021-09-24 20:11     ` Warner Losh
@ 2021-09-26 18:14     ` Warner Losh
  2021-09-26 18:34       ` Philippe Mathieu-Daudé
  1 sibling, 1 reply; 50+ messages in thread
From: Warner Losh @ 2021-09-26 18:14 UTC (permalink / raw)
  To: Richard Henderson
  Cc: Kyle Evans, QEMU Developers, Philippe Mathieu-Daudé

[-- Attachment #1: Type: text/plain, Size: 2346 bytes --]

On Fri, Sep 24, 2021 at 6:00 AM Richard Henderson <
richard.henderson@linaro.org> wrote:

> On 9/21/21 11:14 PM, Warner Losh wrote:
> > Create dummy signal queueing function so we can start to integrate other
> > architectures (at the cost of signals remaining broken) to tame the
> > dependency graph a bit and to bring in signals in a more controlled
> > fashion.
> >
> > Signed-off-by: Warner Losh <imp@bsdimp.com>
> > ---
> >   bsd-user/qemu.h   | 1 +
> >   bsd-user/signal.c | 8 ++++++++
> >   2 files changed, 9 insertions(+)
> >
> > diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
> > index 5a2fd87e44..85d1f8fd2a 100644
> > --- a/bsd-user/qemu.h
> > +++ b/bsd-user/qemu.h
> > @@ -209,6 +209,7 @@ void process_pending_signals(CPUArchState *cpu_env);
> >   void signal_init(void);
> >   long do_sigreturn(CPUArchState *env);
> >   long do_rt_sigreturn(CPUArchState *env);
> > +int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info);
> >   abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr,
> abi_ulong sp);
> >
> >   /* mmap.c */
> > diff --git a/bsd-user/signal.c b/bsd-user/signal.c
> > index ad6d935569..4e7f618944 100644
> > --- a/bsd-user/signal.c
> > +++ b/bsd-user/signal.c
> > @@ -19,6 +19,14 @@
> >   #include "qemu/osdep.h"
> >
> >   #include "qemu.h"
> > +/*
>
> Whacky whitespace.
>

Fixed.


> > + * Queue a signal so that it will be send to the virtual CPU as soon as
> > + * possible.
> > + */
> > +int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info)
> > +{
> > +    return 1;
> > +}
>
> Both here and in linux-user, there are no error conditions.  We should
> change the return
> to void.
>

In this stubbed out version, there's no errors. But bsd-user can return
-EAGAIN when
alloc_sigqueue fails (which it can if there are no free qemu_sigqueue
structures in
the preallocated list0. However, having said that, nothing checks the
return value
so it's as if it is void... So I'll change it to void here...


> Also, consider folding in the signal-common.h cleanup soon.
> But don't let either hold you up too much with rebasing.
>

I plan to. Once that's cleaned up and into the repo, I'll rebase bsd-user
in the
fork, fold in the changes needed and then look at how I'm going to upstream
things.

Warner


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

[-- Attachment #2: Type: text/html, Size: 3717 bytes --]

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 14/14] bsd-user/signal: Create a dummy signal queueing function
  2021-09-26 18:14     ` Warner Losh
@ 2021-09-26 18:34       ` Philippe Mathieu-Daudé
  2021-09-26 19:00         ` Warner Losh
  0 siblings, 1 reply; 50+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-26 18:34 UTC (permalink / raw)
  To: Warner Losh; +Cc: Kyle Evans, Richard Henderson, QEMU Developers

On Sun, Sep 26, 2021 at 8:14 PM Warner Losh <imp@bsdimp.com> wrote:
> On Fri, Sep 24, 2021 at 6:00 AM Richard Henderson <richard.henderson@linaro.org> wrote:
>> On 9/21/21 11:14 PM, Warner Losh wrote:
>> > Create dummy signal queueing function so we can start to integrate other
>> > architectures (at the cost of signals remaining broken) to tame the
>> > dependency graph a bit and to bring in signals in a more controlled
>> > fashion.
>> >
>> > Signed-off-by: Warner Losh <imp@bsdimp.com>
>> > ---
>> >   bsd-user/qemu.h   | 1 +
>> >   bsd-user/signal.c | 8 ++++++++
>> >   2 files changed, 9 insertions(+)

>> > +int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info)
>> > +{
>> > +    return 1;
>> > +}
>>
>> Both here and in linux-user, there are no error conditions.  We should change the return
>> to void.
>
>
> In this stubbed out version, there's no errors. But bsd-user can return -EAGAIN when
> alloc_sigqueue fails (which it can if there are no free qemu_sigqueue structures in
> the preallocated list0. However, having said that, nothing checks the return value
> so it's as if it is void... So I'll change it to void here...

kinda related:
https://www.mail-archive.com/qemu-devel@nongnu.org/msg836833.html


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 14/14] bsd-user/signal: Create a dummy signal queueing function
  2021-09-26 18:34       ` Philippe Mathieu-Daudé
@ 2021-09-26 19:00         ` Warner Losh
  2021-09-26 19:13           ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 50+ messages in thread
From: Warner Losh @ 2021-09-26 19:00 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Kyle Evans, Richard Henderson, QEMU Developers

[-- Attachment #1: Type: text/plain, Size: 1815 bytes --]

On Sun, Sep 26, 2021 at 12:34 PM Philippe Mathieu-Daudé <f4bug@amsat.org>
wrote:

> On Sun, Sep 26, 2021 at 8:14 PM Warner Losh <imp@bsdimp.com> wrote:
> > On Fri, Sep 24, 2021 at 6:00 AM Richard Henderson <
> richard.henderson@linaro.org> wrote:
> >> On 9/21/21 11:14 PM, Warner Losh wrote:
> >> > Create dummy signal queueing function so we can start to integrate
> other
> >> > architectures (at the cost of signals remaining broken) to tame the
> >> > dependency graph a bit and to bring in signals in a more controlled
> >> > fashion.
> >> >
> >> > Signed-off-by: Warner Losh <imp@bsdimp.com>
> >> > ---
> >> >   bsd-user/qemu.h   | 1 +
> >> >   bsd-user/signal.c | 8 ++++++++
> >> >   2 files changed, 9 insertions(+)
>
> >> > +int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info)
> >> > +{
> >> > +    return 1;
> >> > +}
> >>
> >> Both here and in linux-user, there are no error conditions.  We should
> change the return
> >> to void.
> >
> >
> > In this stubbed out version, there's no errors. But bsd-user can return
> -EAGAIN when
> > alloc_sigqueue fails (which it can if there are no free qemu_sigqueue
> structures in
> > the preallocated list0. However, having said that, nothing checks the
> return value
> > so it's as if it is void... So I'll change it to void here...
>
> kinda related:
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg836833.html


Not sure how I missed this... too many filters I guess.

I've sent a reply, but the right thing to do is to eliminate *that* wart
too. I'm always
torn between 'oh, linux-user went in a different direction that I like
better' for something
and adopting it and 'oh, more churn in upstreaming, I'll never get done and
how do I make
sure I don't break anything'...

Warner

[-- Attachment #2: Type: text/html, Size: 2766 bytes --]

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 14/14] bsd-user/signal: Create a dummy signal queueing function
  2021-09-26 19:00         ` Warner Losh
@ 2021-09-26 19:13           ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 50+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-26 19:13 UTC (permalink / raw)
  To: Warner Losh; +Cc: Kyle Evans, Richard Henderson, QEMU Developers

On Sun, Sep 26, 2021 at 9:00 PM Warner Losh <imp@bsdimp.com> wrote:
> On Sun, Sep 26, 2021 at 12:34 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>> On Sun, Sep 26, 2021 at 8:14 PM Warner Losh <imp@bsdimp.com> wrote:
>> > On Fri, Sep 24, 2021 at 6:00 AM Richard Henderson <richard.henderson@linaro.org> wrote:
>> >> On 9/21/21 11:14 PM, Warner Losh wrote:
>> >> > Create dummy signal queueing function so we can start to integrate other
>> >> > architectures (at the cost of signals remaining broken) to tame the
>> >> > dependency graph a bit and to bring in signals in a more controlled
>> >> > fashion.
>> >> >
>> >> > Signed-off-by: Warner Losh <imp@bsdimp.com>
>> >> > ---
>> >> >   bsd-user/qemu.h   | 1 +
>> >> >   bsd-user/signal.c | 8 ++++++++
>> >> >   2 files changed, 9 insertions(+)
>>
>> >> > +int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info)
>> >> > +{
>> >> > +    return 1;
>> >> > +}
>> >>
>> >> Both here and in linux-user, there are no error conditions.  We should change the return
>> >> to void.
>> >
>> >
>> > In this stubbed out version, there's no errors. But bsd-user can return -EAGAIN when
>> > alloc_sigqueue fails (which it can if there are no free qemu_sigqueue structures in
>> > the preallocated list0. However, having said that, nothing checks the return value
>> > so it's as if it is void... So I'll change it to void here...
>>
>> kinda related:
>> https://www.mail-archive.com/qemu-devel@nongnu.org/msg836833.html
>
>
> Not sure how I missed this... too many filters I guess.
>
> I've sent a reply, but the right thing to do is to eliminate *that* wart too. I'm always
> torn between 'oh, linux-user went in a different direction that I like better' for something
> and adopting it and 'oh, more churn in upstreaming, I'll never get done and how do I make
> sure I don't break anything'...

Oh no worry. I have in my TODO to clean this, but got delayed by the
has_work() refactor series.


^ permalink raw reply	[flat|nested] 50+ messages in thread

end of thread, other threads:[~2021-09-26 19:14 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-22  6:14 [PATCH 00/14] bsd-user: misc cleanup for aarch64 import Warner Losh
2021-09-22  6:14 ` [PATCH 01/14] bsd-user/target_os-user.h: Remove support for FreeBSD older than 12.0 Warner Losh
2021-09-22  6:14 ` [PATCH 02/14] bsd-user/strace.list: Remove support for FreeBSD versions " Warner Losh
2021-09-23 17:57   ` Richard Henderson
2021-09-22  6:14 ` [PATCH 03/14] bsd-user: TARGET_RESET define is unused, remove it Warner Losh
2021-09-23 17:57   ` Richard Henderson
2021-09-25 10:30   ` Philippe Mathieu-Daudé
2021-09-22  6:14 ` [PATCH 04/14] bsd-user: export get_errno and is_error from syscall.c Warner Losh
2021-09-23 17:58   ` Richard Henderson
2021-09-25 10:33   ` Philippe Mathieu-Daudé
2021-09-26 17:14     ` Warner Losh
2021-09-22  6:14 ` [PATCH 05/14] bsd-user/errno_defs.h: Add internal error numbers Warner Losh
2021-09-23 17:59   ` Richard Henderson
2021-09-22  6:14 ` [PATCH 06/14] bsd-user: move TARGET_MC_GET_CLEAR_RET to target_os_signal.h Warner Losh
2021-09-23 18:00   ` Richard Henderson
2021-09-25 10:35   ` Philippe Mathieu-Daudé
2021-09-26 17:16     ` Warner Losh
2021-09-22  6:14 ` [PATCH 07/14] bsd-user/target_os_elf.h: Remove fallback ELF_HWCAP and reorder Warner Losh
2021-09-23 18:01   ` Richard Henderson
2021-09-25 10:36   ` Philippe Mathieu-Daudé
2021-09-22  6:14 ` [PATCH 08/14] bsd-user/target_os_elf: If ELF_HWCAP2 is defined, publish it Warner Losh
2021-09-23 18:01   ` Richard Henderson
2021-09-25 10:37   ` Philippe Mathieu-Daudé
2021-09-22  6:14 ` [PATCH 09/14] bsd-user: Remove used from TaskState Warner Losh
2021-09-23 18:02   ` Richard Henderson
2021-09-25 10:38   ` Philippe Mathieu-Daudé
2021-09-22  6:14 ` [PATCH 10/14] bsd-user: Add stop_all_tasks Warner Losh
2021-09-23 18:04   ` Richard Henderson
2021-09-22  6:14 ` [PATCH 11/14] bsd-user/sysarch: Move to using do_freebsd_arch_sysarch interface Warner Losh
2021-09-23 18:07   ` Richard Henderson
2021-09-24 15:25     ` Warner Losh
2021-09-22  6:14 ` [PATCH 12/14] bsd-user/sysarch: Provide a per-arch framework for sysarch syscall Warner Losh
2021-09-23 18:08   ` Richard Henderson
2021-09-25 10:46   ` Philippe Mathieu-Daudé
2021-09-26 17:21     ` Warner Losh
2021-09-22  6:14 ` [PATCH 13/14] bsd-user: Rename sigqueue to qemu_sigqueue Warner Losh
2021-09-23 18:09   ` Richard Henderson
2021-09-25 10:46   ` Philippe Mathieu-Daudé
2021-09-22  6:14 ` [PATCH 14/14] bsd-user/signal: Create a dummy signal queueing function Warner Losh
2021-09-23 18:13   ` Richard Henderson
2021-09-24 20:11     ` Warner Losh
2021-09-24 20:30       ` Kyle Evans
2021-09-24 23:51       ` Richard Henderson
2021-09-26 18:14     ` Warner Losh
2021-09-26 18:34       ` Philippe Mathieu-Daudé
2021-09-26 19:00         ` Warner Losh
2021-09-26 19:13           ` Philippe Mathieu-Daudé
2021-09-25 10:50   ` Philippe Mathieu-Daudé
2021-09-25 14:53     ` Warner Losh
2021-09-26  3:06       ` Warner Losh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.