All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] bsd-user: Generate system call numbers
@ 2026-04-13 15:31 Warner Losh
  2026-04-13 15:31 ` [PATCH 1/5] bsd-user: Add syscall header generator for FreeBSD Warner Losh
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Warner Losh @ 2026-04-13 15:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kyle Evans, Paolo Bonzini, Marc-André Lureau,
	Daniel P. Berrangé, Philippe Mathieu-Daudé, Warner Losh

FreeBSD has a system call number header, sys/syscall.h, that's installed
on every system that can compile qemu. Generate the system call numbers
from that table rather than re-regenerating it yet again.

To do this, I have to clean up a few stragglers for system calls we've
removed. But these returned not supported anyway, so there's no net
change.

I also tried to do this in a way that the other bsds can coexist with
should they show up again in the future. To that end, I moved the
definition of time_t into os-syscall.h, where I noticed it was wrong for
amd64 targets (which is little used and missing features, so it went
unnoticed for a long time).

More will be generated in the future, but this is the first steps.

Signed-off-by: Warner Losh <imp@bsdimp.com>
---
Warner Losh (5):
      bsd-user: Add syscall header generator for FreeBSD
      bsd-user: Generate the system call numbers in meson build.
      bsd-user: Conditionally use old system calls
      bsd-user: Create os-syscall.h
      bsd-user: Switch to generated syscall_nr.h

 bsd-user/bsd-mem.h             |   2 +
 bsd-user/freebsd/meson.build   |   4 +
 bsd-user/freebsd/os-syscall.c  |   4 +
 bsd-user/freebsd/os-syscall.h  |  21 ++
 bsd-user/freebsd/strace.list   |   4 +
 bsd-user/freebsd/syscall_nr.h  | 515 -----------------------------------------
 bsd-user/freebsd/syscallhdr.sh |   9 +
 bsd-user/syscall_defs.h        |  18 +-
 meson.build                    |   2 +
 9 files changed, 47 insertions(+), 532 deletions(-)
---
base-commit: becd22fdc2a071783d9e04421526633772b3b98c
change-id: 20260412-syscall-nr-a0a831fce9a0

Best regards,
-- 
Warner Losh <imp@bsdimp.com>



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

* [PATCH 1/5] bsd-user: Add syscall header generator for FreeBSD
  2026-04-13 15:31 [PATCH 0/5] bsd-user: Generate system call numbers Warner Losh
@ 2026-04-13 15:31 ` Warner Losh
  2026-04-13 22:20   ` Philippe Mathieu-Daudé
  2026-04-13 15:31 ` [PATCH 2/5] bsd-user: Generate the system call numbers in meson build Warner Losh
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 13+ messages in thread
From: Warner Losh @ 2026-04-13 15:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kyle Evans, Paolo Bonzini, Marc-André Lureau,
	Daniel P. Berrangé, Philippe Mathieu-Daudé, Warner Losh

Generate the syscall numbers from the installed header that has them.
Ideally, we'd use FreeBSD's lua infra for this, but that requires that
we have those files installed, and they aren't quite the same across
supported versions yet, so use this simple, but effective hack.

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

diff --git a/bsd-user/freebsd/syscallhdr.sh b/bsd-user/freebsd/syscallhdr.sh
new file mode 100644
index 0000000000..fa38500775
--- /dev/null
+++ b/bsd-user/freebsd/syscallhdr.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+# Copyright (c) 2026 Warner Losh <imp@bsdimp.com>
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+in="$1"
+out="$2"
+bsd="$3"
+
+awk -v bsd="$3" '{sub("SYS_", "TARGET_" bsd "_NR_", $0); print;}' < $in > $out

-- 
2.52.0



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

* [PATCH 2/5] bsd-user: Generate the system call numbers in meson build.
  2026-04-13 15:31 [PATCH 0/5] bsd-user: Generate system call numbers Warner Losh
  2026-04-13 15:31 ` [PATCH 1/5] bsd-user: Add syscall header generator for FreeBSD Warner Losh
@ 2026-04-13 15:31 ` Warner Losh
  2026-04-13 22:22   ` Philippe Mathieu-Daudé
  2026-04-13 15:31 ` [PATCH 3/5] bsd-user: Conditionally use old system calls Warner Losh
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 13+ messages in thread
From: Warner Losh @ 2026-04-13 15:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kyle Evans, Paolo Bonzini, Marc-André Lureau,
	Daniel P. Berrangé, Philippe Mathieu-Daudé, Warner Losh

Build glue to generate system call numbers with the meson build.

Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/freebsd/meson.build | 4 ++++
 meson.build                  | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/bsd-user/freebsd/meson.build b/bsd-user/freebsd/meson.build
index 8fd6c7cfb8..21d4bedb56 100644
--- a/bsd-user/freebsd/meson.build
+++ b/bsd-user/freebsd/meson.build
@@ -4,3 +4,7 @@ bsd_user_ss.add(files(
   'os-sys.c',
   'os-syscall.c',
 ))
+
+bsd_syscall_nr = generator(sh,
+			   arguments: [ meson.current_source_dir() / 'syscallhdr.sh', '@INPUT@', '@OUTPUT@', '@EXTRA_ARGS@'],
+			   output: '@BASENAME@_nr.h')
diff --git a/meson.build b/meson.build
index ab3e97eb9f..d42d5d47a7 100644
--- a/meson.build
+++ b/meson.build
@@ -4307,6 +4307,8 @@ foreach target : target_dirs
       target_inc += include_directories('bsd-user/host/' / host_arch)
       dir = base_dir / abi
       arch_srcs += files(dir / 'signal.c', dir / 'target_arch_cpu.c')
+      arch_srcs += bsd_syscall_nr.process('/usr/include/sys/syscall.h',
+					  extra_args : host_os.to_upper())
     endif
     target_inc += include_directories(
       base_dir,

-- 
2.52.0



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

* [PATCH 3/5] bsd-user: Conditionally use old system calls
  2026-04-13 15:31 [PATCH 0/5] bsd-user: Generate system call numbers Warner Losh
  2026-04-13 15:31 ` [PATCH 1/5] bsd-user: Add syscall header generator for FreeBSD Warner Losh
  2026-04-13 15:31 ` [PATCH 2/5] bsd-user: Generate the system call numbers in meson build Warner Losh
@ 2026-04-13 15:31 ` Warner Losh
  2026-04-13 22:12   ` Philippe Mathieu-Daudé
  2026-04-14  8:13   ` Daniel P. Berrangé
  2026-04-13 15:31 ` [PATCH 4/5] bsd-user: Create os-syscall.h Warner Losh
  2026-04-13 15:31 ` [PATCH 5/5] bsd-user: Switch to generated syscall_nr.h Warner Losh
  4 siblings, 2 replies; 13+ messages in thread
From: Warner Losh @ 2026-04-13 15:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kyle Evans, Paolo Bonzini, Marc-André Lureau,
	Daniel P. Berrangé, Philippe Mathieu-Daudé, Warner Losh

sbrk and sstk have been deprecated in FreeBSD for a while now, only
support them if the version of FreeBSD we're compiling on does. They've
returned not supported for a while anyway, so no net change.

Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/bsd-mem.h            | 2 ++
 bsd-user/freebsd/os-syscall.c | 4 ++++
 bsd-user/freebsd/strace.list  | 4 ++++
 3 files changed, 10 insertions(+)

diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h
index a118e57260..a20b703053 100644
--- a/bsd-user/bsd-mem.h
+++ b/bsd-user/bsd-mem.h
@@ -440,6 +440,7 @@ static inline abi_long do_bsd_vadvise(void)
     return -TARGET_EINVAL;
 }
 
+#ifdef TARGET_FREEBSD_NR_sbrk
 static inline abi_long do_bsd_sbrk(void)
 {
     /* see sys_sbrk() in vm_mmap.c */
@@ -451,5 +452,6 @@ static inline abi_long do_bsd_sstk(void)
     /* see sys_sstk() in vm_mmap.c */
     return -TARGET_EOPNOTSUPP;
 }
+#endif
 
 #endif /* BSD_USER_BSD_MEM_H */
diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c
index 85e5db19a3..ff6cbfc481 100644
--- a/bsd-user/freebsd/os-syscall.c
+++ b/bsd-user/freebsd/os-syscall.c
@@ -918,13 +918,17 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1,
         ret = do_bsd_vadvise();
         break;
 
+#ifdef TARGET_FREEBSD_NR_sbrk
     case TARGET_FREEBSD_NR_sbrk:
         ret = do_bsd_sbrk();
         break;
+#endif
 
+#ifdef TARGET_FREEBSD_NR_sstk
     case TARGET_FREEBSD_NR_sstk:
         ret = do_bsd_sstk();
         break;
+#endif
 
         /*
          * Misc
diff --git a/bsd-user/freebsd/strace.list b/bsd-user/freebsd/strace.list
index 275d2dbe27..d7f61f480e 100644
--- a/bsd-user/freebsd/strace.list
+++ b/bsd-user/freebsd/strace.list
@@ -194,7 +194,9 @@
 { TARGET_FREEBSD_NR_rfork, "rfork", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_rmdir, "rmdir", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_rtprio_thread, "rtprio_thread", "%s(%d, %d, %p)", NULL, NULL },
+#ifdef TARGET_FREEBSD_NR_sbrk
 { TARGET_FREEBSD_NR_sbrk, "sbrk", NULL, NULL, NULL },
+#endif
 { TARGET_FREEBSD_NR_sched_get_priority_max, "sched_get_priority_max", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_sched_get_priority_min, "sched_get_priority_min", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_sched_yield, "sched_yield", NULL, NULL, NULL },
@@ -234,7 +236,9 @@
 { TARGET_FREEBSD_NR_sigsuspend, "sigsuspend", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_socket, "socket", "%s(%d,%d,%d)", NULL, NULL },
 { TARGET_FREEBSD_NR_socketpair, "socketpair", NULL, NULL, NULL },
+#ifdef TARGET_FREEBSD_NR_sstk
 { TARGET_FREEBSD_NR_sstk, "sstk", NULL, NULL, NULL },
+#endif
 { TARGET_FREEBSD_NR_freebsd11_stat, "freebsd11_stat", "%s(\"%s\",%p)", NULL, NULL },
 { TARGET_FREEBSD_NR_freebsd11_statfs, "freebsd11_statfs", "%s(\"%s\",%p)", NULL, NULL },
 { TARGET_FREEBSD_NR_symlink, "symlink", "%s(\"%s\",\"%s\")", NULL, NULL },

-- 
2.52.0



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

* [PATCH 4/5] bsd-user: Create os-syscall.h
  2026-04-13 15:31 [PATCH 0/5] bsd-user: Generate system call numbers Warner Losh
                   ` (2 preceding siblings ...)
  2026-04-13 15:31 ` [PATCH 3/5] bsd-user: Conditionally use old system calls Warner Losh
@ 2026-04-13 15:31 ` Warner Losh
  2026-04-13 15:31 ` [PATCH 5/5] bsd-user: Switch to generated syscall_nr.h Warner Losh
  4 siblings, 0 replies; 13+ messages in thread
From: Warner Losh @ 2026-04-13 15:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kyle Evans, Paolo Bonzini, Marc-André Lureau,
	Daniel P. Berrangé, Philippe Mathieu-Daudé, Warner Losh

Create os-syscall.h. The purpose of this file is to define anything
that's different among the BSDs, like system call numbers and
time_t. While there's a lot more different between the BSDs, this is at
least a start at capturing it.

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

diff --git a/bsd-user/freebsd/os-syscall.h b/bsd-user/freebsd/os-syscall.h
new file mode 100644
index 0000000000..962adfa91a
--- /dev/null
+++ b/bsd-user/freebsd/os-syscall.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2023 Warner Losh <imp@bsdimp.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * OS-Specific portion of syscall_defs.h
+ */
+
+#include "syscall_nr.h"
+
+/*
+ * FreeBSD uses a 64bits time_t except on i386 so we have to add a special case
+ * here.
+ */
+#if defined(TARGET_I386) && !defined(TARGET_X86_64)
+typedef int32_t target_time_t;
+#else
+typedef int64_t target_time_t;
+#endif
+
+typedef abi_long target_suseconds_t;

-- 
2.52.0



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

* [PATCH 5/5] bsd-user: Switch to generated syscall_nr.h
  2026-04-13 15:31 [PATCH 0/5] bsd-user: Generate system call numbers Warner Losh
                   ` (3 preceding siblings ...)
  2026-04-13 15:31 ` [PATCH 4/5] bsd-user: Create os-syscall.h Warner Losh
@ 2026-04-13 15:31 ` Warner Losh
  4 siblings, 0 replies; 13+ messages in thread
From: Warner Losh @ 2026-04-13 15:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kyle Evans, Paolo Bonzini, Marc-André Lureau,
	Daniel P. Berrangé, Philippe Mathieu-Daudé, Warner Losh

Now that this will build and work, remove the old syscall_nr.h and
switch the include over to the generated file in syscall_defs.h.

To do this, I had to delete the old, wrong definition of time_t for
FreeBSD on amd64 since it stumbled over the fact that TARGET_i386 is
defined for both 32-bit and 64-bit builds (the new os-syscall.h had the
rigth definition). Rather than modify this file twice to fix it, rolled
the fix into using os-syscall.h since it's still easy enough to review.

Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/freebsd/syscall_nr.h | 515 ------------------------------------------
 bsd-user/syscall_defs.h       |  18 +-
 2 files changed, 1 insertion(+), 532 deletions(-)

diff --git a/bsd-user/freebsd/syscall_nr.h b/bsd-user/freebsd/syscall_nr.h
deleted file mode 100644
index 7f73a6d0f1..0000000000
--- a/bsd-user/freebsd/syscall_nr.h
+++ /dev/null
@@ -1,515 +0,0 @@
-/*
- * System call numbers.
- *
- * DO NOT EDIT-- this file is automatically @generated.
- * $FreeBSD$
- */
-
-#define TARGET_FREEBSD_NR_syscall       0
-#define TARGET_FREEBSD_NR_exit  1
-#define TARGET_FREEBSD_NR_fork  2
-#define TARGET_FREEBSD_NR_read  3
-#define TARGET_FREEBSD_NR_write 4
-#define TARGET_FREEBSD_NR_open  5
-#define TARGET_FREEBSD_NR_close 6
-#define TARGET_FREEBSD_NR_wait4 7
-                                /* 8 is old creat */
-#define TARGET_FREEBSD_NR_link  9
-#define TARGET_FREEBSD_NR_unlink        10
-                                /* 11 is obsolete execv */
-#define TARGET_FREEBSD_NR_chdir 12
-#define TARGET_FREEBSD_NR_fchdir        13
-#define TARGET_FREEBSD_NR_freebsd11_mknod       14
-#define TARGET_FREEBSD_NR_chmod 15
-#define TARGET_FREEBSD_NR_chown 16
-#define TARGET_FREEBSD_NR_break 17
-                                /* 18 is freebsd4 getfsstat */
-                                /* 19 is old lseek */
-#define TARGET_FREEBSD_NR_getpid        20
-#define TARGET_FREEBSD_NR_mount 21
-#define TARGET_FREEBSD_NR_unmount       22
-#define TARGET_FREEBSD_NR_setuid        23
-#define TARGET_FREEBSD_NR_getuid        24
-#define TARGET_FREEBSD_NR_geteuid       25
-#define TARGET_FREEBSD_NR_ptrace        26
-#define TARGET_FREEBSD_NR_recvmsg       27
-#define TARGET_FREEBSD_NR_sendmsg       28
-#define TARGET_FREEBSD_NR_recvfrom      29
-#define TARGET_FREEBSD_NR_accept        30
-#define TARGET_FREEBSD_NR_getpeername   31
-#define TARGET_FREEBSD_NR_getsockname   32
-#define TARGET_FREEBSD_NR_access        33
-#define TARGET_FREEBSD_NR_chflags       34
-#define TARGET_FREEBSD_NR_fchflags      35
-#define TARGET_FREEBSD_NR_sync  36
-#define TARGET_FREEBSD_NR_kill  37
-                                /* 38 is old stat */
-#define TARGET_FREEBSD_NR_getppid       39
-                                /* 40 is old lstat */
-#define TARGET_FREEBSD_NR_dup   41
-#define TARGET_FREEBSD_NR_freebsd10_pipe        42
-#define TARGET_FREEBSD_NR_getegid       43
-#define TARGET_FREEBSD_NR_profil        44
-#define TARGET_FREEBSD_NR_ktrace        45
-                                /* 46 is old sigaction */
-#define TARGET_FREEBSD_NR_getgid        47
-                                /* 48 is old sigprocmask */
-#define TARGET_FREEBSD_NR_getlogin      49
-#define TARGET_FREEBSD_NR_setlogin      50
-#define TARGET_FREEBSD_NR_acct  51
-                                /* 52 is old sigpending */
-#define TARGET_FREEBSD_NR_sigaltstack   53
-#define TARGET_FREEBSD_NR_ioctl 54
-#define TARGET_FREEBSD_NR_reboot        55
-#define TARGET_FREEBSD_NR_revoke        56
-#define TARGET_FREEBSD_NR_symlink       57
-#define TARGET_FREEBSD_NR_readlink      58
-#define TARGET_FREEBSD_NR_execve        59
-#define TARGET_FREEBSD_NR_umask 60
-#define TARGET_FREEBSD_NR_chroot        61
-                                /* 62 is old fstat */
-                                /* 63 is old getkerninfo */
-                                /* 64 is old getpagesize */
-#define TARGET_FREEBSD_NR_msync 65
-#define TARGET_FREEBSD_NR_vfork 66
-                                /* 67 is obsolete vread */
-                                /* 68 is obsolete vwrite */
-#define TARGET_FREEBSD_NR_sbrk  69
-#define TARGET_FREEBSD_NR_sstk  70
-                                /* 71 is old mmap */
-#define TARGET_FREEBSD_NR_freebsd11_vadvise     72
-#define TARGET_FREEBSD_NR_munmap        73
-#define TARGET_FREEBSD_NR_mprotect      74
-#define TARGET_FREEBSD_NR_madvise       75
-                                /* 76 is obsolete vhangup */
-                                /* 77 is obsolete vlimit */
-#define TARGET_FREEBSD_NR_mincore       78
-#define TARGET_FREEBSD_NR_getgroups     79
-#define TARGET_FREEBSD_NR_setgroups     80
-#define TARGET_FREEBSD_NR_getpgrp       81
-#define TARGET_FREEBSD_NR_setpgid       82
-#define TARGET_FREEBSD_NR_setitimer     83
-                                /* 84 is old wait */
-#define TARGET_FREEBSD_NR_swapon        85
-#define TARGET_FREEBSD_NR_getitimer     86
-                                /* 87 is old gethostname */
-                                /* 88 is old sethostname */
-#define TARGET_FREEBSD_NR_getdtablesize 89
-#define TARGET_FREEBSD_NR_dup2  90
-#define TARGET_FREEBSD_NR_fcntl 92
-#define TARGET_FREEBSD_NR_select        93
-#define TARGET_FREEBSD_NR_fsync 95
-#define TARGET_FREEBSD_NR_setpriority   96
-#define TARGET_FREEBSD_NR_socket        97
-#define TARGET_FREEBSD_NR_connect       98
-                                /* 99 is old accept */
-#define TARGET_FREEBSD_NR_getpriority   100
-                                /* 101 is old send */
-                                /* 102 is old recv */
-                                /* 103 is old sigreturn */
-#define TARGET_FREEBSD_NR_bind  104
-#define TARGET_FREEBSD_NR_setsockopt    105
-#define TARGET_FREEBSD_NR_listen        106
-                                /* 107 is obsolete vtimes */
-                                /* 108 is old sigvec */
-                                /* 109 is old sigblock */
-                                /* 110 is old sigsetmask */
-                                /* 111 is old sigsuspend */
-                                /* 112 is old sigstack */
-                                /* 113 is old recvmsg */
-                                /* 114 is old sendmsg */
-                                /* 115 is obsolete vtrace */
-#define TARGET_FREEBSD_NR_gettimeofday  116
-#define TARGET_FREEBSD_NR_getrusage     117
-#define TARGET_FREEBSD_NR_getsockopt    118
-#define TARGET_FREEBSD_NR_readv 120
-#define TARGET_FREEBSD_NR_writev        121
-#define TARGET_FREEBSD_NR_settimeofday  122
-#define TARGET_FREEBSD_NR_fchown        123
-#define TARGET_FREEBSD_NR_fchmod        124
-                                /* 125 is old recvfrom */
-#define TARGET_FREEBSD_NR_setreuid      126
-#define TARGET_FREEBSD_NR_setregid      127
-#define TARGET_FREEBSD_NR_rename        128
-                                /* 129 is old truncate */
-                                /* 130 is old ftruncate */
-#define TARGET_FREEBSD_NR_flock 131
-#define TARGET_FREEBSD_NR_mkfifo        132
-#define TARGET_FREEBSD_NR_sendto        133
-#define TARGET_FREEBSD_NR_shutdown      134
-#define TARGET_FREEBSD_NR_socketpair    135
-#define TARGET_FREEBSD_NR_mkdir 136
-#define TARGET_FREEBSD_NR_rmdir 137
-#define TARGET_FREEBSD_NR_utimes        138
-                                /* 139 is obsolete 4.2 sigreturn */
-#define TARGET_FREEBSD_NR_adjtime       140
-                                /* 141 is old getpeername */
-                                /* 142 is old gethostid */
-                                /* 143 is old sethostid */
-                                /* 144 is old getrlimit */
-                                /* 145 is old setrlimit */
-                                /* 146 is old killpg */
-#define TARGET_FREEBSD_NR_setsid        147
-#define TARGET_FREEBSD_NR_quotactl      148
-                                /* 149 is old quota */
-                                /* 150 is old getsockname */
-#define TARGET_FREEBSD_NR_nlm_syscall   154
-#define TARGET_FREEBSD_NR_nfssvc        155
-                                /* 156 is old getdirentries */
-                                /* 157 is freebsd4 statfs */
-                                /* 158 is freebsd4 fstatfs */
-#define TARGET_FREEBSD_NR_lgetfh        160
-#define TARGET_FREEBSD_NR_getfh 161
-                                /* 162 is freebsd4 getdomainname */
-                                /* 163 is freebsd4 setdomainname */
-                                /* 164 is freebsd4 uname */
-#define TARGET_FREEBSD_NR_sysarch       165
-#define TARGET_FREEBSD_NR_rtprio        166
-#define TARGET_FREEBSD_NR_semsys        169
-#define TARGET_FREEBSD_NR_msgsys        170
-#define TARGET_FREEBSD_NR_shmsys        171
-                                /* 173 is freebsd6 pread */
-                                /* 174 is freebsd6 pwrite */
-#define TARGET_FREEBSD_NR_setfib        175
-#define TARGET_FREEBSD_NR_ntp_adjtime   176
-#define TARGET_FREEBSD_NR_setgid        181
-#define TARGET_FREEBSD_NR_setegid       182
-#define TARGET_FREEBSD_NR_seteuid       183
-                                /* 184 is obsolete lfs_bmapv */
-                                /* 185 is obsolete lfs_markv */
-                                /* 186 is obsolete lfs_segclean */
-                                /* 187 is obsolete lfs_segwait */
-#define TARGET_FREEBSD_NR_freebsd11_stat        188
-#define TARGET_FREEBSD_NR_freebsd11_fstat       189
-#define TARGET_FREEBSD_NR_freebsd11_lstat       190
-#define TARGET_FREEBSD_NR_pathconf      191
-#define TARGET_FREEBSD_NR_fpathconf     192
-#define TARGET_FREEBSD_NR_getrlimit     194
-#define TARGET_FREEBSD_NR_setrlimit     195
-#define TARGET_FREEBSD_NR_freebsd11_getdirentries       196
-                                /* 197 is freebsd6 mmap */
-#define TARGET_FREEBSD_NR___syscall     198
-                                /* 199 is freebsd6 lseek */
-                                /* 200 is freebsd6 truncate */
-                                /* 201 is freebsd6 ftruncate */
-#define TARGET_FREEBSD_NR___sysctl      202
-#define TARGET_FREEBSD_NR_mlock 203
-#define TARGET_FREEBSD_NR_munlock       204
-#define TARGET_FREEBSD_NR_undelete      205
-#define TARGET_FREEBSD_NR_futimes       206
-#define TARGET_FREEBSD_NR_getpgid       207
-#define TARGET_FREEBSD_NR_poll  209
-#define TARGET_FREEBSD_NR_freebsd7___semctl     220
-#define TARGET_FREEBSD_NR_semget        221
-#define TARGET_FREEBSD_NR_semop 222
-                                /* 223 is obsolete semconfig */
-#define TARGET_FREEBSD_NR_freebsd7_msgctl       224
-#define TARGET_FREEBSD_NR_msgget        225
-#define TARGET_FREEBSD_NR_msgsnd        226
-#define TARGET_FREEBSD_NR_msgrcv        227
-#define TARGET_FREEBSD_NR_shmat 228
-#define TARGET_FREEBSD_NR_freebsd7_shmctl       229
-#define TARGET_FREEBSD_NR_shmdt 230
-#define TARGET_FREEBSD_NR_shmget        231
-#define TARGET_FREEBSD_NR_clock_gettime 232
-#define TARGET_FREEBSD_NR_clock_settime 233
-#define TARGET_FREEBSD_NR_clock_getres  234
-#define TARGET_FREEBSD_NR_ktimer_create 235
-#define TARGET_FREEBSD_NR_ktimer_delete 236
-#define TARGET_FREEBSD_NR_ktimer_settime        237
-#define TARGET_FREEBSD_NR_ktimer_gettime        238
-#define TARGET_FREEBSD_NR_ktimer_getoverrun     239
-#define TARGET_FREEBSD_NR_nanosleep     240
-#define TARGET_FREEBSD_NR_ffclock_getcounter    241
-#define TARGET_FREEBSD_NR_ffclock_setestimate   242
-#define TARGET_FREEBSD_NR_ffclock_getestimate   243
-#define TARGET_FREEBSD_NR_clock_nanosleep       244
-#define TARGET_FREEBSD_NR_clock_getcpuclockid2  247
-#define TARGET_FREEBSD_NR_ntp_gettime   248
-#define TARGET_FREEBSD_NR_minherit      250
-#define TARGET_FREEBSD_NR_rfork 251
-                                /* 252 is obsolete openbsd_poll */
-#define TARGET_FREEBSD_NR_issetugid     253
-#define TARGET_FREEBSD_NR_lchown        254
-#define TARGET_FREEBSD_NR_aio_read      255
-#define TARGET_FREEBSD_NR_aio_write     256
-#define TARGET_FREEBSD_NR_lio_listio    257
-#define TARGET_FREEBSD_NR_freebsd11_getdents    272
-#define TARGET_FREEBSD_NR_lchmod        274
-                                /* 275 is obsolete netbsd_lchown */
-#define TARGET_FREEBSD_NR_lutimes       276
-                                /* 277 is obsolete netbsd_msync */
-#define TARGET_FREEBSD_NR_freebsd11_nstat       278
-#define TARGET_FREEBSD_NR_freebsd11_nfstat      279
-#define TARGET_FREEBSD_NR_freebsd11_nlstat      280
-#define TARGET_FREEBSD_NR_preadv        289
-#define TARGET_FREEBSD_NR_pwritev       290
-                                /* 297 is freebsd4 fhstatfs */
-#define TARGET_FREEBSD_NR_fhopen        298
-#define TARGET_FREEBSD_NR_freebsd11_fhstat      299
-#define TARGET_FREEBSD_NR_modnext       300
-#define TARGET_FREEBSD_NR_modstat       301
-#define TARGET_FREEBSD_NR_modfnext      302
-#define TARGET_FREEBSD_NR_modfind       303
-#define TARGET_FREEBSD_NR_kldload       304
-#define TARGET_FREEBSD_NR_kldunload     305
-#define TARGET_FREEBSD_NR_kldfind       306
-#define TARGET_FREEBSD_NR_kldnext       307
-#define TARGET_FREEBSD_NR_kldstat       308
-#define TARGET_FREEBSD_NR_kldfirstmod   309
-#define TARGET_FREEBSD_NR_getsid        310
-#define TARGET_FREEBSD_NR_setresuid     311
-#define TARGET_FREEBSD_NR_setresgid     312
-                                /* 313 is obsolete signanosleep */
-#define TARGET_FREEBSD_NR_aio_return    314
-#define TARGET_FREEBSD_NR_aio_suspend   315
-#define TARGET_FREEBSD_NR_aio_cancel    316
-#define TARGET_FREEBSD_NR_aio_error     317
-                                /* 318 is freebsd6 aio_read */
-                                /* 319 is freebsd6 aio_write */
-                                /* 320 is freebsd6 lio_listio */
-#define TARGET_FREEBSD_NR_yield 321
-                                /* 322 is obsolete thr_sleep */
-                                /* 323 is obsolete thr_wakeup */
-#define TARGET_FREEBSD_NR_mlockall      324
-#define TARGET_FREEBSD_NR_munlockall    325
-#define TARGET_FREEBSD_NR___getcwd      326
-#define TARGET_FREEBSD_NR_sched_setparam        327
-#define TARGET_FREEBSD_NR_sched_getparam        328
-#define TARGET_FREEBSD_NR_sched_setscheduler    329
-#define TARGET_FREEBSD_NR_sched_getscheduler    330
-#define TARGET_FREEBSD_NR_sched_yield   331
-#define TARGET_FREEBSD_NR_sched_get_priority_max        332
-#define TARGET_FREEBSD_NR_sched_get_priority_min        333
-#define TARGET_FREEBSD_NR_sched_rr_get_interval 334
-#define TARGET_FREEBSD_NR_utrace        335
-                                /* 336 is freebsd4 sendfile */
-#define TARGET_FREEBSD_NR_kldsym        337
-#define TARGET_FREEBSD_NR_jail  338
-#define TARGET_FREEBSD_NR_nnpfs_syscall 339
-#define TARGET_FREEBSD_NR_sigprocmask   340
-#define TARGET_FREEBSD_NR_sigsuspend    341
-                                /* 342 is freebsd4 sigaction */
-#define TARGET_FREEBSD_NR_sigpending    343
-                                /* 344 is freebsd4 sigreturn */
-#define TARGET_FREEBSD_NR_sigtimedwait  345
-#define TARGET_FREEBSD_NR_sigwaitinfo   346
-#define TARGET_FREEBSD_NR___acl_get_file        347
-#define TARGET_FREEBSD_NR___acl_set_file        348
-#define TARGET_FREEBSD_NR___acl_get_fd  349
-#define TARGET_FREEBSD_NR___acl_set_fd  350
-#define TARGET_FREEBSD_NR___acl_delete_file     351
-#define TARGET_FREEBSD_NR___acl_delete_fd       352
-#define TARGET_FREEBSD_NR___acl_aclcheck_file   353
-#define TARGET_FREEBSD_NR___acl_aclcheck_fd     354
-#define TARGET_FREEBSD_NR_extattrctl    355
-#define TARGET_FREEBSD_NR_extattr_set_file      356
-#define TARGET_FREEBSD_NR_extattr_get_file      357
-#define TARGET_FREEBSD_NR_extattr_delete_file   358
-#define TARGET_FREEBSD_NR_aio_waitcomplete      359
-#define TARGET_FREEBSD_NR_getresuid     360
-#define TARGET_FREEBSD_NR_getresgid     361
-#define TARGET_FREEBSD_NR_kqueue        362
-#define TARGET_FREEBSD_NR_freebsd11_kevent      363
-                                /* 364 is obsolete __cap_get_proc */
-                                /* 365 is obsolete __cap_set_proc */
-                                /* 366 is obsolete __cap_get_fd */
-                                /* 367 is obsolete __cap_get_file */
-                                /* 368 is obsolete __cap_set_fd */
-                                /* 369 is obsolete __cap_set_file */
-#define TARGET_FREEBSD_NR_extattr_set_fd        371
-#define TARGET_FREEBSD_NR_extattr_get_fd        372
-#define TARGET_FREEBSD_NR_extattr_delete_fd     373
-#define TARGET_FREEBSD_NR___setugid     374
-                                /* 375 is obsolete nfsclnt */
-#define TARGET_FREEBSD_NR_eaccess       376
-#define TARGET_FREEBSD_NR_afs3_syscall  377
-#define TARGET_FREEBSD_NR_nmount        378
-                                /* 379 is obsolete kse_exit */
-                                /* 380 is obsolete kse_wakeup */
-                                /* 381 is obsolete kse_create */
-                                /* 382 is obsolete kse_thr_interrupt */
-                                /* 383 is obsolete kse_release */
-#define TARGET_FREEBSD_NR___mac_get_proc        384
-#define TARGET_FREEBSD_NR___mac_set_proc        385
-#define TARGET_FREEBSD_NR___mac_get_fd  386
-#define TARGET_FREEBSD_NR___mac_get_file        387
-#define TARGET_FREEBSD_NR___mac_set_fd  388
-#define TARGET_FREEBSD_NR___mac_set_file        389
-#define TARGET_FREEBSD_NR_kenv  390
-#define TARGET_FREEBSD_NR_lchflags      391
-#define TARGET_FREEBSD_NR_uuidgen       392
-#define TARGET_FREEBSD_NR_sendfile      393
-#define TARGET_FREEBSD_NR_mac_syscall   394
-#define TARGET_FREEBSD_NR_freebsd11_getfsstat   395
-#define TARGET_FREEBSD_NR_freebsd11_statfs      396
-#define TARGET_FREEBSD_NR_freebsd11_fstatfs     397
-#define TARGET_FREEBSD_NR_freebsd11_fhstatfs    398
-#define TARGET_FREEBSD_NR_ksem_close    400
-#define TARGET_FREEBSD_NR_ksem_post     401
-#define TARGET_FREEBSD_NR_ksem_wait     402
-#define TARGET_FREEBSD_NR_ksem_trywait  403
-#define TARGET_FREEBSD_NR_ksem_init     404
-#define TARGET_FREEBSD_NR_ksem_open     405
-#define TARGET_FREEBSD_NR_ksem_unlink   406
-#define TARGET_FREEBSD_NR_ksem_getvalue 407
-#define TARGET_FREEBSD_NR_ksem_destroy  408
-#define TARGET_FREEBSD_NR___mac_get_pid 409
-#define TARGET_FREEBSD_NR___mac_get_link        410
-#define TARGET_FREEBSD_NR___mac_set_link        411
-#define TARGET_FREEBSD_NR_extattr_set_link      412
-#define TARGET_FREEBSD_NR_extattr_get_link      413
-#define TARGET_FREEBSD_NR_extattr_delete_link   414
-#define TARGET_FREEBSD_NR___mac_execve  415
-#define TARGET_FREEBSD_NR_sigaction     416
-#define TARGET_FREEBSD_NR_sigreturn     417
-#define TARGET_FREEBSD_NR_getcontext    421
-#define TARGET_FREEBSD_NR_setcontext    422
-#define TARGET_FREEBSD_NR_swapcontext   423
-#define TARGET_FREEBSD_NR_swapoff       424
-#define TARGET_FREEBSD_NR___acl_get_link        425
-#define TARGET_FREEBSD_NR___acl_set_link        426
-#define TARGET_FREEBSD_NR___acl_delete_link     427
-#define TARGET_FREEBSD_NR___acl_aclcheck_link   428
-#define TARGET_FREEBSD_NR_sigwait       429
-#define TARGET_FREEBSD_NR_thr_create    430
-#define TARGET_FREEBSD_NR_thr_exit      431
-#define TARGET_FREEBSD_NR_thr_self      432
-#define TARGET_FREEBSD_NR_thr_kill      433
-#define TARGET_FREEBSD_NR_jail_attach   436
-#define TARGET_FREEBSD_NR_extattr_list_fd       437
-#define TARGET_FREEBSD_NR_extattr_list_file     438
-#define TARGET_FREEBSD_NR_extattr_list_link     439
-                                /* 440 is obsolete kse_switchin */
-#define TARGET_FREEBSD_NR_ksem_timedwait        441
-#define TARGET_FREEBSD_NR_thr_suspend   442
-#define TARGET_FREEBSD_NR_thr_wake      443
-#define TARGET_FREEBSD_NR_kldunloadf    444
-#define TARGET_FREEBSD_NR_audit 445
-#define TARGET_FREEBSD_NR_auditon       446
-#define TARGET_FREEBSD_NR_getauid       447
-#define TARGET_FREEBSD_NR_setauid       448
-#define TARGET_FREEBSD_NR_getaudit      449
-#define TARGET_FREEBSD_NR_setaudit      450
-#define TARGET_FREEBSD_NR_getaudit_addr 451
-#define TARGET_FREEBSD_NR_setaudit_addr 452
-#define TARGET_FREEBSD_NR_auditctl      453
-#define TARGET_FREEBSD_NR__umtx_op      454
-#define TARGET_FREEBSD_NR_thr_new       455
-#define TARGET_FREEBSD_NR_sigqueue      456
-#define TARGET_FREEBSD_NR_kmq_open      457
-#define TARGET_FREEBSD_NR_kmq_setattr   458
-#define TARGET_FREEBSD_NR_kmq_timedreceive      459
-#define TARGET_FREEBSD_NR_kmq_timedsend 460
-#define TARGET_FREEBSD_NR_kmq_notify    461
-#define TARGET_FREEBSD_NR_kmq_unlink    462
-#define TARGET_FREEBSD_NR_abort2        463
-#define TARGET_FREEBSD_NR_thr_set_name  464
-#define TARGET_FREEBSD_NR_aio_fsync     465
-#define TARGET_FREEBSD_NR_rtprio_thread 466
-#define TARGET_FREEBSD_NR_sctp_peeloff  471
-#define TARGET_FREEBSD_NR_sctp_generic_sendmsg  472
-#define TARGET_FREEBSD_NR_sctp_generic_sendmsg_iov      473
-#define TARGET_FREEBSD_NR_sctp_generic_recvmsg  474
-#define TARGET_FREEBSD_NR_pread 475
-#define TARGET_FREEBSD_NR_pwrite        476
-#define TARGET_FREEBSD_NR_mmap  477
-#define TARGET_FREEBSD_NR_lseek 478
-#define TARGET_FREEBSD_NR_truncate      479
-#define TARGET_FREEBSD_NR_ftruncate     480
-#define TARGET_FREEBSD_NR_thr_kill2     481
-#define TARGET_FREEBSD_NR_freebsd12_shm_open    482
-#define TARGET_FREEBSD_NR_shm_unlink    483
-#define TARGET_FREEBSD_NR_cpuset        484
-#define TARGET_FREEBSD_NR_cpuset_setid  485
-#define TARGET_FREEBSD_NR_cpuset_getid  486
-#define TARGET_FREEBSD_NR_cpuset_getaffinity    487
-#define TARGET_FREEBSD_NR_cpuset_setaffinity    488
-#define TARGET_FREEBSD_NR_faccessat     489
-#define TARGET_FREEBSD_NR_fchmodat      490
-#define TARGET_FREEBSD_NR_fchownat      491
-#define TARGET_FREEBSD_NR_fexecve       492
-#define TARGET_FREEBSD_NR_freebsd11_fstatat     493
-#define TARGET_FREEBSD_NR_futimesat     494
-#define TARGET_FREEBSD_NR_linkat        495
-#define TARGET_FREEBSD_NR_mkdirat       496
-#define TARGET_FREEBSD_NR_mkfifoat      497
-#define TARGET_FREEBSD_NR_freebsd11_mknodat     498
-#define TARGET_FREEBSD_NR_openat        499
-#define TARGET_FREEBSD_NR_readlinkat    500
-#define TARGET_FREEBSD_NR_renameat      501
-#define TARGET_FREEBSD_NR_symlinkat     502
-#define TARGET_FREEBSD_NR_unlinkat      503
-#define TARGET_FREEBSD_NR_posix_openpt  504
-#define TARGET_FREEBSD_NR_gssd_syscall  505
-#define TARGET_FREEBSD_NR_jail_get      506
-#define TARGET_FREEBSD_NR_jail_set      507
-#define TARGET_FREEBSD_NR_jail_remove   508
-#define TARGET_FREEBSD_NR_freebsd12_closefrom   509
-#define TARGET_FREEBSD_NR___semctl      510
-#define TARGET_FREEBSD_NR_msgctl        511
-#define TARGET_FREEBSD_NR_shmctl        512
-#define TARGET_FREEBSD_NR_lpathconf     513
-                                /* 514 is obsolete cap_new */
-#define TARGET_FREEBSD_NR___cap_rights_get      515
-#define TARGET_FREEBSD_NR_cap_enter     516
-#define TARGET_FREEBSD_NR_cap_getmode   517
-#define TARGET_FREEBSD_NR_pdfork        518
-#define TARGET_FREEBSD_NR_pdkill        519
-#define TARGET_FREEBSD_NR_pdgetpid      520
-#define TARGET_FREEBSD_NR_pselect       522
-#define TARGET_FREEBSD_NR_getloginclass 523
-#define TARGET_FREEBSD_NR_setloginclass 524
-#define TARGET_FREEBSD_NR_rctl_get_racct        525
-#define TARGET_FREEBSD_NR_rctl_get_rules        526
-#define TARGET_FREEBSD_NR_rctl_get_limits       527
-#define TARGET_FREEBSD_NR_rctl_add_rule 528
-#define TARGET_FREEBSD_NR_rctl_remove_rule      529
-#define TARGET_FREEBSD_NR_posix_fallocate       530
-#define TARGET_FREEBSD_NR_posix_fadvise 531
-#define TARGET_FREEBSD_NR_wait6 532
-#define TARGET_FREEBSD_NR_cap_rights_limit      533
-#define TARGET_FREEBSD_NR_cap_ioctls_limit      534
-#define TARGET_FREEBSD_NR_cap_ioctls_get        535
-#define TARGET_FREEBSD_NR_cap_fcntls_limit      536
-#define TARGET_FREEBSD_NR_cap_fcntls_get        537
-#define TARGET_FREEBSD_NR_bindat        538
-#define TARGET_FREEBSD_NR_connectat     539
-#define TARGET_FREEBSD_NR_chflagsat     540
-#define TARGET_FREEBSD_NR_accept4       541
-#define TARGET_FREEBSD_NR_pipe2 542
-#define TARGET_FREEBSD_NR_aio_mlock     543
-#define TARGET_FREEBSD_NR_procctl       544
-#define TARGET_FREEBSD_NR_ppoll 545
-#define TARGET_FREEBSD_NR_futimens      546
-#define TARGET_FREEBSD_NR_utimensat     547
-                                /* 548 is obsolete numa_getaffinity */
-                                /* 549 is obsolete numa_setaffinity */
-#define TARGET_FREEBSD_NR_fdatasync     550
-#define TARGET_FREEBSD_NR_fstat 551
-#define TARGET_FREEBSD_NR_fstatat       552
-#define TARGET_FREEBSD_NR_fhstat        553
-#define TARGET_FREEBSD_NR_getdirentries 554
-#define TARGET_FREEBSD_NR_statfs        555
-#define TARGET_FREEBSD_NR_fstatfs       556
-#define TARGET_FREEBSD_NR_getfsstat     557
-#define TARGET_FREEBSD_NR_fhstatfs      558
-#define TARGET_FREEBSD_NR_mknodat       559
-#define TARGET_FREEBSD_NR_kevent        560
-#define TARGET_FREEBSD_NR_cpuset_getdomain      561
-#define TARGET_FREEBSD_NR_cpuset_setdomain      562
-#define TARGET_FREEBSD_NR_getrandom     563
-#define TARGET_FREEBSD_NR_getfhat       564
-#define TARGET_FREEBSD_NR_fhlink        565
-#define TARGET_FREEBSD_NR_fhlinkat      566
-#define TARGET_FREEBSD_NR_fhreadlink    567
-#define TARGET_FREEBSD_NR_funlinkat     568
-#define TARGET_FREEBSD_NR_copy_file_range       569
-#define TARGET_FREEBSD_NR___sysctlbyname        570
-#define TARGET_FREEBSD_NR_shm_open2     571
-#define TARGET_FREEBSD_NR_shm_rename    572
-#define TARGET_FREEBSD_NR_sigfastblock  573
-#define TARGET_FREEBSD_NR___realpathat  574
-#define TARGET_FREEBSD_NR_close_range   575
-#define TARGET_FREEBSD_NR_rpctls_syscall        576
-#define TARGET_FREEBSD_NR_MAXSYSCALL    577
diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h
index 4dbd90c2f1..30b0270faa 100644
--- a/bsd-user/syscall_defs.h
+++ b/bsd-user/syscall_defs.h
@@ -25,29 +25,13 @@
 
 #include "errno_defs.h"
 
-#include "freebsd/syscall_nr.h"
+#include "os-syscalls.h"
 
 /*
  * machine/_types.h
  * or x86/_types.h
  */
 
-/*
- * time_t seems to be very inconsistly defined for the different *BSD's...
- *
- * FreeBSD uses a 64bits time_t except on i386
- * so we have to add a special case here.
- *
- * On NetBSD time_t is always defined as an int64_t.  On OpenBSD time_t
- * is always defined as an int.
- *
- */
-#if (!defined(TARGET_I386))
-typedef int64_t target_time_t;
-#else
-typedef int32_t target_time_t;
-#endif
-
 struct target_iovec {
     abi_long iov_base;   /* Starting address */
     abi_long iov_len;   /* Number of bytes */

-- 
2.52.0



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

* Re: [PATCH 3/5] bsd-user: Conditionally use old system calls
  2026-04-13 15:31 ` [PATCH 3/5] bsd-user: Conditionally use old system calls Warner Losh
@ 2026-04-13 22:12   ` Philippe Mathieu-Daudé
  2026-04-14  8:13   ` Daniel P. Berrangé
  1 sibling, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-13 22:12 UTC (permalink / raw)
  To: Warner Losh, qemu-devel
  Cc: Kyle Evans, Paolo Bonzini, Marc-André Lureau,
	Daniel P. Berrangé

On 13/4/26 17:31, Warner Losh wrote:
> sbrk and sstk have been deprecated in FreeBSD for a while now, only
> support them if the version of FreeBSD we're compiling on does. They've
> returned not supported for a while anyway, so no net change.
> 
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>   bsd-user/bsd-mem.h            | 2 ++
>   bsd-user/freebsd/os-syscall.c | 4 ++++
>   bsd-user/freebsd/strace.list  | 4 ++++
>   3 files changed, 10 insertions(+)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


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

* Re: [PATCH 1/5] bsd-user: Add syscall header generator for FreeBSD
  2026-04-13 15:31 ` [PATCH 1/5] bsd-user: Add syscall header generator for FreeBSD Warner Losh
@ 2026-04-13 22:20   ` Philippe Mathieu-Daudé
  2026-04-14  2:44     ` Warner Losh
  0 siblings, 1 reply; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-13 22:20 UTC (permalink / raw)
  To: Warner Losh, qemu-devel
  Cc: Kyle Evans, Paolo Bonzini, Marc-André Lureau,
	Daniel P. Berrangé

On 13/4/26 17:31, Warner Losh wrote:
> Generate the syscall numbers from the installed header that has them.
> Ideally, we'd use FreeBSD's lua infra for this, but that requires that
> we have those files installed, and they aren't quite the same across
> supported versions yet, so use this simple, but effective hack.
> 
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>   bsd-user/freebsd/syscallhdr.sh | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/bsd-user/freebsd/syscallhdr.sh b/bsd-user/freebsd/syscallhdr.sh
> new file mode 100644
> index 0000000000..fa38500775
> --- /dev/null
> +++ b/bsd-user/freebsd/syscallhdr.sh
> @@ -0,0 +1,9 @@
> +#!/bin/sh
> +# Copyright (c) 2026 Warner Losh <imp@bsdimp.com>
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +
> +in="$1"
> +out="$2"
> +bsd="$3"
> +

echo '/* This file is autogenerated by syscallhdr.sh, do not edit. */' > 
$out
echo '/* SPDX-License-Identifier: GPL-2.0-or-later */' >> $out

> +awk -v bsd="$3" '{sub("SYS_", "TARGET_" bsd "_NR_", $0); print;}' < $in > $out

   ... >> $out

With the header changes:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



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

* Re: [PATCH 2/5] bsd-user: Generate the system call numbers in meson build.
  2026-04-13 15:31 ` [PATCH 2/5] bsd-user: Generate the system call numbers in meson build Warner Losh
@ 2026-04-13 22:22   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-13 22:22 UTC (permalink / raw)
  To: Warner Losh, qemu-devel
  Cc: Kyle Evans, Paolo Bonzini, Marc-André Lureau,
	Daniel P. Berrangé

On 13/4/26 17:31, Warner Losh wrote:
> Build glue to generate system call numbers with the meson build.
> 
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>   bsd-user/freebsd/meson.build | 4 ++++
>   meson.build                  | 2 ++
>   2 files changed, 6 insertions(+)

Squash with previous patch? Anyhow,

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


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

* Re: [PATCH 1/5] bsd-user: Add syscall header generator for FreeBSD
  2026-04-13 22:20   ` Philippe Mathieu-Daudé
@ 2026-04-14  2:44     ` Warner Losh
  2026-04-14  9:16       ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 13+ messages in thread
From: Warner Losh @ 2026-04-14  2:44 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Kyle Evans, Paolo Bonzini, Marc-André Lureau,
	Daniel P. Berrangé

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

On Mon, Apr 13, 2026 at 4:21 PM Philippe Mathieu-Daudé <philmd@linaro.org>
wrote:

> On 13/4/26 17:31, Warner Losh wrote:
> > Generate the syscall numbers from the installed header that has them.
> > Ideally, we'd use FreeBSD's lua infra for this, but that requires that
> > we have those files installed, and they aren't quite the same across
> > supported versions yet, so use this simple, but effective hack.
> >
> > Signed-off-by: Warner Losh <imp@bsdimp.com>
> > ---
> >   bsd-user/freebsd/syscallhdr.sh | 9 +++++++++
> >   1 file changed, 9 insertions(+)
> >
> > diff --git a/bsd-user/freebsd/syscallhdr.sh
> b/bsd-user/freebsd/syscallhdr.sh
> > new file mode 100644
> > index 0000000000..fa38500775
> > --- /dev/null
> > +++ b/bsd-user/freebsd/syscallhdr.sh
> > @@ -0,0 +1,9 @@
> > +#!/bin/sh
> > +# Copyright (c) 2026 Warner Losh <imp@bsdimp.com>
> > +# SPDX-License-Identifier: GPL-2.0-or-later
> > +
> > +in="$1"
> > +out="$2"
> > +bsd="$3"
> > +
>

Hey, thanks for the review.


> echo '/* This file is autogenerated by syscallhdr.sh, do not edit. */' >

$out
> echo '/* SPDX-License-Identifier: GPL-2.0-or-later */' >> $out
>

These aren't needed. The generated file starts off:
/*
 * System call numbers.
 *
 * DO NOT EDIT-- this file is automatically @generated.
 */
...
we're just doing sed -e s/SYS/TARGET_FREEBSD_NR/g on
that file (though awk is mildly more convenient). No need to add
a license, since it's already in the public domain, and you don't
need a license to do anything you want to public domain material
(including incorporating it into a GPL'd work). Since the generated
file isn't committed to the repo, there's no style checker to appease.

Warner

> +awk -v bsd="$3" '{sub("SYS_", "TARGET_" bsd "_NR_", $0); print;}' < $in
> > $out
>
>    ... >> $out
>
> With the header changes:
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>

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

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

* Re: [PATCH 3/5] bsd-user: Conditionally use old system calls
  2026-04-13 15:31 ` [PATCH 3/5] bsd-user: Conditionally use old system calls Warner Losh
  2026-04-13 22:12   ` Philippe Mathieu-Daudé
@ 2026-04-14  8:13   ` Daniel P. Berrangé
  2026-04-14 13:56     ` Warner Losh
  1 sibling, 1 reply; 13+ messages in thread
From: Daniel P. Berrangé @ 2026-04-14  8:13 UTC (permalink / raw)
  To: Warner Losh
  Cc: qemu-devel, Kyle Evans, Paolo Bonzini, Marc-André Lureau,
	Philippe Mathieu-Daudé

On Mon, Apr 13, 2026 at 09:31:45AM -0600, Warner Losh wrote:
> sbrk and sstk have been deprecated in FreeBSD for a while now, only
> support them if the version of FreeBSD we're compiling on does. They've
> returned not supported for a while anyway, so no net change.

What versions of FreeBSD still have these syscalls ?

Per out policy we only aim to support the 2 most recent major
versions of distros:

  https://www.qemu.org/docs/master/about/build-platforms.html

So for FreeBSD that means 14.x and 15.x series are all that you
need to retain code support for. Any code for older versions
can be entirely dropped at any convenient time.

> 
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>  bsd-user/bsd-mem.h            | 2 ++
>  bsd-user/freebsd/os-syscall.c | 4 ++++
>  bsd-user/freebsd/strace.list  | 4 ++++
>  3 files changed, 10 insertions(+)
> 
> diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h
> index a118e57260..a20b703053 100644
> --- a/bsd-user/bsd-mem.h
> +++ b/bsd-user/bsd-mem.h
> @@ -440,6 +440,7 @@ static inline abi_long do_bsd_vadvise(void)
>      return -TARGET_EINVAL;
>  }
>  
> +#ifdef TARGET_FREEBSD_NR_sbrk
>  static inline abi_long do_bsd_sbrk(void)
>  {
>      /* see sys_sbrk() in vm_mmap.c */
> @@ -451,5 +452,6 @@ static inline abi_long do_bsd_sstk(void)
>      /* see sys_sstk() in vm_mmap.c */
>      return -TARGET_EOPNOTSUPP;
>  }
> +#endif
>  
>  #endif /* BSD_USER_BSD_MEM_H */
> diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c
> index 85e5db19a3..ff6cbfc481 100644
> --- a/bsd-user/freebsd/os-syscall.c
> +++ b/bsd-user/freebsd/os-syscall.c
> @@ -918,13 +918,17 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1,
>          ret = do_bsd_vadvise();
>          break;
>  
> +#ifdef TARGET_FREEBSD_NR_sbrk
>      case TARGET_FREEBSD_NR_sbrk:
>          ret = do_bsd_sbrk();
>          break;
> +#endif
>  
> +#ifdef TARGET_FREEBSD_NR_sstk
>      case TARGET_FREEBSD_NR_sstk:
>          ret = do_bsd_sstk();
>          break;
> +#endif
>  
>          /*
>           * Misc
> diff --git a/bsd-user/freebsd/strace.list b/bsd-user/freebsd/strace.list
> index 275d2dbe27..d7f61f480e 100644
> --- a/bsd-user/freebsd/strace.list
> +++ b/bsd-user/freebsd/strace.list
> @@ -194,7 +194,9 @@
>  { TARGET_FREEBSD_NR_rfork, "rfork", NULL, NULL, NULL },
>  { TARGET_FREEBSD_NR_rmdir, "rmdir", NULL, NULL, NULL },
>  { TARGET_FREEBSD_NR_rtprio_thread, "rtprio_thread", "%s(%d, %d, %p)", NULL, NULL },
> +#ifdef TARGET_FREEBSD_NR_sbrk
>  { TARGET_FREEBSD_NR_sbrk, "sbrk", NULL, NULL, NULL },
> +#endif
>  { TARGET_FREEBSD_NR_sched_get_priority_max, "sched_get_priority_max", NULL, NULL, NULL },
>  { TARGET_FREEBSD_NR_sched_get_priority_min, "sched_get_priority_min", NULL, NULL, NULL },
>  { TARGET_FREEBSD_NR_sched_yield, "sched_yield", NULL, NULL, NULL },
> @@ -234,7 +236,9 @@
>  { TARGET_FREEBSD_NR_sigsuspend, "sigsuspend", NULL, NULL, NULL },
>  { TARGET_FREEBSD_NR_socket, "socket", "%s(%d,%d,%d)", NULL, NULL },
>  { TARGET_FREEBSD_NR_socketpair, "socketpair", NULL, NULL, NULL },
> +#ifdef TARGET_FREEBSD_NR_sstk
>  { TARGET_FREEBSD_NR_sstk, "sstk", NULL, NULL, NULL },
> +#endif
>  { TARGET_FREEBSD_NR_freebsd11_stat, "freebsd11_stat", "%s(\"%s\",%p)", NULL, NULL },
>  { TARGET_FREEBSD_NR_freebsd11_statfs, "freebsd11_statfs", "%s(\"%s\",%p)", NULL, NULL },
>  { TARGET_FREEBSD_NR_symlink, "symlink", "%s(\"%s\",\"%s\")", NULL, NULL },
> 
> -- 
> 2.52.0
> 

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



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

* Re: [PATCH 1/5] bsd-user: Add syscall header generator for FreeBSD
  2026-04-14  2:44     ` Warner Losh
@ 2026-04-14  9:16       ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-14  9:16 UTC (permalink / raw)
  To: Warner Losh
  Cc: qemu-devel, Kyle Evans, Paolo Bonzini, Marc-André Lureau,
	Daniel P. Berrangé

On 14/4/26 04:44, Warner Losh wrote:
> 
> 
> On Mon, Apr 13, 2026 at 4:21 PM Philippe Mathieu-Daudé 
> <philmd@linaro.org <mailto:philmd@linaro.org>> wrote:
> 
>     On 13/4/26 17:31, Warner Losh wrote:
>      > Generate the syscall numbers from the installed header that has them.
>      > Ideally, we'd use FreeBSD's lua infra for this, but that requires
>     that
>      > we have those files installed, and they aren't quite the same across
>      > supported versions yet, so use this simple, but effective hack.
>      >
>      > Signed-off-by: Warner Losh <imp@bsdimp.com <mailto:imp@bsdimp.com>>
>      > ---
>      >   bsd-user/freebsd/syscallhdr.sh | 9 +++++++++
>      >   1 file changed, 9 insertions(+)
>      >
>      > diff --git a/bsd-user/freebsd/syscallhdr.sh b/bsd-user/freebsd/
>     syscallhdr.sh
>      > new file mode 100644
>      > index 0000000000..fa38500775
>      > --- /dev/null
>      > +++ b/bsd-user/freebsd/syscallhdr.sh
>      > @@ -0,0 +1,9 @@
>      > +#!/bin/sh
>      > +# Copyright (c) 2026 Warner Losh <imp@bsdimp.com
>     <mailto:imp@bsdimp.com>>
>      > +# SPDX-License-Identifier: GPL-2.0-or-later
>      > +
>      > +in="$1"
>      > +out="$2"
>      > +bsd="$3"
>      > +
> 
> 
> Hey, thanks for the review.
> 
>     echo '/* This file is autogenerated by syscallhdr.sh, do not edit. */' >
> 
>     $out
>     echo '/* SPDX-License-Identifier: GPL-2.0-or-later */' >> $out
> 
> 
> These aren't needed. The generated file starts off:
> /*
>   * System call numbers.
>   *
>   * DO NOT EDIT-- this file is automatically @generated.
>   */
> ...
> we're just doing sed -e s/SYS/TARGET_FREEBSD_NR/g on
> that file (though awk is mildly more convenient). No need to add
> a license, since it's already in the public domain, and you don't
> need a license to do anything you want to public domain material
> (including incorporating it into a GPL'd work). Since the generated
> file isn't committed to the repo, there's no style checker to appease.

Ah great, thanks for clarifying! R-b stands.

> 
> Warner


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

* Re: [PATCH 3/5] bsd-user: Conditionally use old system calls
  2026-04-14  8:13   ` Daniel P. Berrangé
@ 2026-04-14 13:56     ` Warner Losh
  0 siblings, 0 replies; 13+ messages in thread
From: Warner Losh @ 2026-04-14 13:56 UTC (permalink / raw)
  To: Daniel P. Berrangé
  Cc: qemu-devel, Kyle Evans, Paolo Bonzini, Marc-André Lureau,
	Philippe Mathieu-Daudé

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

On Tue, Apr 14, 2026 at 2:13 AM Daniel P. Berrangé <berrange@redhat.com>
wrote:

> On Mon, Apr 13, 2026 at 09:31:45AM -0600, Warner Losh wrote:
> > sbrk and sstk have been deprecated in FreeBSD for a while now, only
> > support them if the version of FreeBSD we're compiling on does. They've
> > returned not supported for a while anyway, so no net change.
>
> What versions of FreeBSD still have these syscalls ?
>

None. They were marked OBSOL in 4.4BSD. I don't even know why
there was code to implement them in the first place.

In fact, digging deeper, 4.3-Reno returns not supported. 4.3-Tahoe had
them stubbed out as blank (no error, but did nothing), like 4.3BSD and
4.2BSD did before it. It wasn't in 4.1BSD.


> Per out policy we only aim to support the 2 most recent major
> versions of distros:
>
>   https://www.qemu.org/docs/master/about/build-platforms.html
>
> So for FreeBSD that means 14.x and 15.x series are all that you
> need to retain code support for. Any code for older versions
> can be entirely dropped at any convenient time.
>

True. I'll do that since it is clearly an echo of the past of what might
have been, that never, ever was. I just #ifdef'd them because I wasn't
sure, but now I am...

Warner


> >
> > Signed-off-by: Warner Losh <imp@bsdimp.com>
> > ---
> >  bsd-user/bsd-mem.h            | 2 ++
> >  bsd-user/freebsd/os-syscall.c | 4 ++++
> >  bsd-user/freebsd/strace.list  | 4 ++++
> >  3 files changed, 10 insertions(+)
> >
> > diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h
> > index a118e57260..a20b703053 100644
> > --- a/bsd-user/bsd-mem.h
> > +++ b/bsd-user/bsd-mem.h
> > @@ -440,6 +440,7 @@ static inline abi_long do_bsd_vadvise(void)
> >      return -TARGET_EINVAL;
> >  }
> >
> > +#ifdef TARGET_FREEBSD_NR_sbrk
> >  static inline abi_long do_bsd_sbrk(void)
> >  {
> >      /* see sys_sbrk() in vm_mmap.c */
> > @@ -451,5 +452,6 @@ static inline abi_long do_bsd_sstk(void)
> >      /* see sys_sstk() in vm_mmap.c */
> >      return -TARGET_EOPNOTSUPP;
> >  }
> > +#endif
> >
> >  #endif /* BSD_USER_BSD_MEM_H */
> > diff --git a/bsd-user/freebsd/os-syscall.c
> b/bsd-user/freebsd/os-syscall.c
> > index 85e5db19a3..ff6cbfc481 100644
> > --- a/bsd-user/freebsd/os-syscall.c
> > +++ b/bsd-user/freebsd/os-syscall.c
> > @@ -918,13 +918,17 @@ static abi_long freebsd_syscall(void *cpu_env, int
> num, abi_long arg1,
> >          ret = do_bsd_vadvise();
> >          break;
> >
> > +#ifdef TARGET_FREEBSD_NR_sbrk
> >      case TARGET_FREEBSD_NR_sbrk:
> >          ret = do_bsd_sbrk();
> >          break;
> > +#endif
> >
> > +#ifdef TARGET_FREEBSD_NR_sstk
> >      case TARGET_FREEBSD_NR_sstk:
> >          ret = do_bsd_sstk();
> >          break;
> > +#endif
> >
> >          /*
> >           * Misc
> > diff --git a/bsd-user/freebsd/strace.list b/bsd-user/freebsd/strace.list
> > index 275d2dbe27..d7f61f480e 100644
> > --- a/bsd-user/freebsd/strace.list
> > +++ b/bsd-user/freebsd/strace.list
> > @@ -194,7 +194,9 @@
> >  { TARGET_FREEBSD_NR_rfork, "rfork", NULL, NULL, NULL },
> >  { TARGET_FREEBSD_NR_rmdir, "rmdir", NULL, NULL, NULL },
> >  { TARGET_FREEBSD_NR_rtprio_thread, "rtprio_thread", "%s(%d, %d, %p)",
> NULL, NULL },
> > +#ifdef TARGET_FREEBSD_NR_sbrk
> >  { TARGET_FREEBSD_NR_sbrk, "sbrk", NULL, NULL, NULL },
> > +#endif
> >  { TARGET_FREEBSD_NR_sched_get_priority_max, "sched_get_priority_max",
> NULL, NULL, NULL },
> >  { TARGET_FREEBSD_NR_sched_get_priority_min, "sched_get_priority_min",
> NULL, NULL, NULL },
> >  { TARGET_FREEBSD_NR_sched_yield, "sched_yield", NULL, NULL, NULL },
> > @@ -234,7 +236,9 @@
> >  { TARGET_FREEBSD_NR_sigsuspend, "sigsuspend", NULL, NULL, NULL },
> >  { TARGET_FREEBSD_NR_socket, "socket", "%s(%d,%d,%d)", NULL, NULL },
> >  { TARGET_FREEBSD_NR_socketpair, "socketpair", NULL, NULL, NULL },
> > +#ifdef TARGET_FREEBSD_NR_sstk
> >  { TARGET_FREEBSD_NR_sstk, "sstk", NULL, NULL, NULL },
> > +#endif
> >  { TARGET_FREEBSD_NR_freebsd11_stat, "freebsd11_stat", "%s(\"%s\",%p)",
> NULL, NULL },
> >  { TARGET_FREEBSD_NR_freebsd11_statfs, "freebsd11_statfs",
> "%s(\"%s\",%p)", NULL, NULL },
> >  { TARGET_FREEBSD_NR_symlink, "symlink", "%s(\"%s\",\"%s\")", NULL, NULL
> },
> >
> > --
> > 2.52.0
> >
>
> With regards,
> Daniel
> --
> |: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
> |: https://libvirt.org          ~~          https://entangle-photo.org :|
> |: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
>
>

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

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

end of thread, other threads:[~2026-04-14 13:57 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-13 15:31 [PATCH 0/5] bsd-user: Generate system call numbers Warner Losh
2026-04-13 15:31 ` [PATCH 1/5] bsd-user: Add syscall header generator for FreeBSD Warner Losh
2026-04-13 22:20   ` Philippe Mathieu-Daudé
2026-04-14  2:44     ` Warner Losh
2026-04-14  9:16       ` Philippe Mathieu-Daudé
2026-04-13 15:31 ` [PATCH 2/5] bsd-user: Generate the system call numbers in meson build Warner Losh
2026-04-13 22:22   ` Philippe Mathieu-Daudé
2026-04-13 15:31 ` [PATCH 3/5] bsd-user: Conditionally use old system calls Warner Losh
2026-04-13 22:12   ` Philippe Mathieu-Daudé
2026-04-14  8:13   ` Daniel P. Berrangé
2026-04-14 13:56     ` Warner Losh
2026-04-13 15:31 ` [PATCH 4/5] bsd-user: Create os-syscall.h Warner Losh
2026-04-13 15:31 ` [PATCH 5/5] bsd-user: Switch to generated syscall_nr.h 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.