All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] A few preliminary bsd-user patches
@ 2020-12-18 20:54 imp
  2020-12-18 20:54 ` [PATCH 1/4] bsd-user: regenerate FreeBSD's system call numbers imp
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: imp @ 2020-12-18 20:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: Warner Losh

From: Warner Losh <imp@freebsd.org>

Here's the first round of bsd-user patches. There's on the order of 280 that
we've done, but that's too much to review all at once. In addition, 3.1 release
was the last rebase point that we've been successful with for a number of reasons
unrelated to qemu. Now that those have been resolved, we have a new push under way
to push things forward, but wanted to upstream as many of the patches as we can
directly to qemu's head to lighten the load of carrying all these.

This first small series updates the system call lists, moves things around to
make it easier to support divergence in the BSD world, and adjusts to the new
meson build. It's also designed to help me learn how to land such a large set
upstream.

These patches have passed through several hands, with different tweaks over the
years so have an unusually large number of signed-off-by lines that are the
result of this refinement process where several hands have touched the patches
in the last 7 years.

Sean Bruno (1):
  tcg: Additional Trap type for FreeBSD

Stacey Son (1):
  bsd-user: move strace OS/arch dependent code to host/arch dirs

Warner Losh (2):
  bsd-user: regenerate FreeBSD's system call numbers
  bsd-user: Update strace.list for FreeBSD's latest syscalls

 accel/tcg/user-exec.c                  |   8 +-
 bsd-user/arm/target_arch_sysarch.h     |  78 +++
 bsd-user/arm/target_syscall.h          |  36 ++
 bsd-user/freebsd/os-strace.h           |  29 ++
 bsd-user/freebsd/strace.list           |  65 ++-
 bsd-user/freebsd/syscall_nr.h          | 695 ++++++++++++++-----------
 bsd-user/i386/target_arch_sysarch.h    |  77 +++
 bsd-user/i386/target_syscall.h         |  19 +
 bsd-user/mips/target_arch_sysarch.h    |  69 +++
 bsd-user/mips/target_syscall.h         |  52 ++
 bsd-user/mips64/target_arch_sysarch.h  |  69 +++
 bsd-user/mips64/target_syscall.h       |  53 ++
 bsd-user/netbsd/os-strace.h            |   1 +
 bsd-user/openbsd/os-strace.h           |   1 +
 bsd-user/sparc/target_arch_sysarch.h   |  52 ++
 bsd-user/sparc/target_syscall.h        |  24 +-
 bsd-user/sparc64/target_arch_sysarch.h |  52 ++
 bsd-user/sparc64/target_syscall.h      |  24 +-
 bsd-user/strace.c                      |  11 +
 bsd-user/x86_64/target_arch_sysarch.h  |  76 +++
 bsd-user/x86_64/target_syscall.h       |  21 +-
 meson.build                            |   1 +
 22 files changed, 1186 insertions(+), 327 deletions(-)
 create mode 100644 bsd-user/arm/target_arch_sysarch.h
 create mode 100644 bsd-user/arm/target_syscall.h
 create mode 100644 bsd-user/freebsd/os-strace.h
 create mode 100644 bsd-user/i386/target_arch_sysarch.h
 create mode 100644 bsd-user/mips/target_arch_sysarch.h
 create mode 100644 bsd-user/mips/target_syscall.h
 create mode 100644 bsd-user/mips64/target_arch_sysarch.h
 create mode 100644 bsd-user/mips64/target_syscall.h
 create mode 100644 bsd-user/netbsd/os-strace.h
 create mode 100644 bsd-user/openbsd/os-strace.h
 create mode 100644 bsd-user/sparc/target_arch_sysarch.h
 create mode 100644 bsd-user/sparc64/target_arch_sysarch.h
 create mode 100644 bsd-user/x86_64/target_arch_sysarch.h

-- 
2.22.1



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

* [PATCH 1/4] bsd-user: regenerate FreeBSD's system call numbers
  2020-12-18 20:54 [PATCH 0/4] A few preliminary bsd-user patches imp
@ 2020-12-18 20:54 ` imp
  2020-12-18 20:54 ` [PATCH 2/4] tcg: Additional Trap type for FreeBSD imp
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: imp @ 2020-12-18 20:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: Warner Losh

From: Warner Losh <imp@freebsd.org>

Recreate the FreeBSD system call numbers from current sys/syscall.h. Since this
isn't guaranteed to be on all systems, continue the practice of generating it
with some variation on:
	sed -e s/SYS_/TARGET_NR_/ < $FREEBSD_SRC/sys/syscall.h > syscall_nr.h
until a more comprehensive system can be put in place.

Signed-off-by: Warner Losh <imp@FreeBSD.org>
---
 bsd-user/freebsd/syscall_nr.h | 695 +++++++++++++++++++---------------
 1 file changed, 380 insertions(+), 315 deletions(-)

diff --git a/bsd-user/freebsd/syscall_nr.h b/bsd-user/freebsd/syscall_nr.h
index d849024792..7f73a6d0f1 100644
--- a/bsd-user/freebsd/syscall_nr.h
+++ b/bsd-user/freebsd/syscall_nr.h
@@ -1,11 +1,11 @@
 /*
  * System call numbers.
  *
- * created from FreeBSD: releng/9.1/sys/kern/syscalls.master 229723
- * 2012-01-06 19:29:16Z jhb
+ * DO NOT EDIT-- this file is automatically @generated.
+ * $FreeBSD$
  */
 
-#define TARGET_FREEBSD_NR_syscall   0
+#define TARGET_FREEBSD_NR_syscall       0
 #define TARGET_FREEBSD_NR_exit  1
 #define TARGET_FREEBSD_NR_fork  2
 #define TARGET_FREEBSD_NR_read  3
@@ -13,438 +13,503 @@
 #define TARGET_FREEBSD_NR_open  5
 #define TARGET_FREEBSD_NR_close 6
 #define TARGET_FREEBSD_NR_wait4 7
-                /* 8 is old creat */
+                                /* 8 is old creat */
 #define TARGET_FREEBSD_NR_link  9
-#define TARGET_FREEBSD_NR_unlink    10
-                /* 11 is obsolete execv */
+#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_mknod 14
+#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
-#define TARGET_FREEBSD_NR_freebsd4_getfsstat    18
-                /* 19 is old lseek */
-#define TARGET_FREEBSD_NR_getpid    20
+                                /* 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_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_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 */
+                                /* 38 is old stat */
+#define TARGET_FREEBSD_NR_getppid       39
+                                /* 40 is old lstat */
 #define TARGET_FREEBSD_NR_dup   41
-#define TARGET_FREEBSD_NR_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_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 */
+                                /* 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_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_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 */
+                                /* 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_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 */
+                                /* 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_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_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 */
+                                /* 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_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_getrusage     117
 #define TARGET_FREEBSD_NR_getsockopt    118
 #define TARGET_FREEBSD_NR_readv 120
-#define TARGET_FREEBSD_NR_writev    121
+#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_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_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_killpg    146 /* COMPAT */
-#define TARGET_FREEBSD_NR_setsid    147
-#define TARGET_FREEBSD_NR_quotactl  148
-                /* 149 is old quota */
-                /* 150 is old getsockname */
+#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 */
-#define TARGET_FREEBSD_NR_freebsd4_statfs   157
-#define TARGET_FREEBSD_NR_freebsd4_fstatfs  158
-#define TARGET_FREEBSD_NR_lgetfh    160
+#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
-#define TARGET_FREEBSD_NR_freebsd4_getdomainname    162
-#define TARGET_FREEBSD_NR_freebsd4_setdomainname    163
-#define TARGET_FREEBSD_NR_freebsd4_uname    164
-#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
-#define TARGET_FREEBSD_NR_freebsd6_pread    173
-#define TARGET_FREEBSD_NR_freebsd6_pwrite   174
-#define TARGET_FREEBSD_NR_setfib    175
+                                /* 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
-#define TARGET_FREEBSD_NR_stat  188
-#define TARGET_FREEBSD_NR_fstat 189
-#define TARGET_FREEBSD_NR_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_getdirentries 196
-#define TARGET_FREEBSD_NR_freebsd6_mmap 197
-#define TARGET_FREEBSD_NR___syscall 198
-#define TARGET_FREEBSD_NR_freebsd6_lseek    199
-#define TARGET_FREEBSD_NR_freebsd6_truncate 200
-#define TARGET_FREEBSD_NR_freebsd6_ftruncate    201
-#define TARGET_FREEBSD_NR___sysctl  202
+#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_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_freebsd7___semctl     220
+#define TARGET_FREEBSD_NR_semget        221
 #define TARGET_FREEBSD_NR_semop 222
-#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
+                                /* 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_freebsd7_shmctl       229
 #define TARGET_FREEBSD_NR_shmdt 230
-#define TARGET_FREEBSD_NR_shmget    231
+#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_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_minherit      250
 #define TARGET_FREEBSD_NR_rfork 251
-#define TARGET_FREEBSD_NR_openbsd_poll  252
-#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
+                                /* 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_getdents  272
-#define TARGET_FREEBSD_NR_lchmod    274
-#define TARGET_FREEBSD_NR_netbsd_lchown 275
-#define TARGET_FREEBSD_NR_lutimes   276
-#define TARGET_FREEBSD_NR_netbsd_msync  277
-#define TARGET_FREEBSD_NR_nstat 278
-#define TARGET_FREEBSD_NR_nfstat    279
-#define TARGET_FREEBSD_NR_nlstat    280
-#define TARGET_FREEBSD_NR_preadv    289
-#define TARGET_FREEBSD_NR_pwritev   290
-#define TARGET_FREEBSD_NR_freebsd4_fhstatfs 297
-#define TARGET_FREEBSD_NR_fhopen    298
-#define TARGET_FREEBSD_NR_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_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_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
-#define TARGET_FREEBSD_NR_oaio_read 318
-#define TARGET_FREEBSD_NR_oaio_write    319
-#define TARGET_FREEBSD_NR_olio_listio   320
+#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
+                                /* 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___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_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
-#define TARGET_FREEBSD_NR_freebsd4_sendfile 336
-#define TARGET_FREEBSD_NR_kldsym    337
+#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
-#define TARGET_FREEBSD_NR_freebsd4_sigaction    342
+                                /* 342 is freebsd4 sigaction */
 #define TARGET_FREEBSD_NR_sigpending    343
-#define TARGET_FREEBSD_NR_freebsd4_sigreturn    344
+                                /* 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_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_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___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_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_kevent    363
-#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
-#define TARGET_FREEBSD_NR_eaccess   376
+#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
-#define TARGET_FREEBSD_NR___mac_get_proc    384
-#define TARGET_FREEBSD_NR___mac_set_proc    385
+#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_get_file        387
 #define TARGET_FREEBSD_NR___mac_set_fd  388
-#define TARGET_FREEBSD_NR___mac_set_file    389
+#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_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_getfsstat 395
-#define TARGET_FREEBSD_NR_statfs    396
-#define TARGET_FREEBSD_NR_fstatfs   397
-#define TARGET_FREEBSD_NR_fhstatfs  398
+#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_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_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___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_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_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_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__umtx_lock    434
-#define TARGET_FREEBSD_NR__umtx_unlock  435
+#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
-#define TARGET_FREEBSD_NR_ksem_timedwait    441
+#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_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_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_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_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_abort2        463
 #define TARGET_FREEBSD_NR_thr_set_name  464
-#define TARGET_FREEBSD_NR_aio_fsync 465
+#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_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_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_shm_open  482
+#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        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_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_mknodat   498
-#define TARGET_FREEBSD_NR_openat    499
+#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_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_get      506
+#define TARGET_FREEBSD_NR_jail_set      507
 #define TARGET_FREEBSD_NR_jail_remove   508
-#define TARGET_FREEBSD_NR_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
-#define TARGET_FREEBSD_NR_cap_new   514
-#define TARGET_FREEBSD_NR_cap_getrights 515
-#define TARGET_FREEBSD_NR_cap_enter 516
+#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_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_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_rctl_remove_rule      529
+#define TARGET_FREEBSD_NR_posix_fallocate       530
 #define TARGET_FREEBSD_NR_posix_fadvise 531
-#define TARGET_FREEBSD_NR_MAXSYSCALL    532
+#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
-- 
2.22.1



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

* [PATCH 2/4] tcg: Additional Trap type for FreeBSD
  2020-12-18 20:54 [PATCH 0/4] A few preliminary bsd-user patches imp
  2020-12-18 20:54 ` [PATCH 1/4] bsd-user: regenerate FreeBSD's system call numbers imp
@ 2020-12-18 20:54 ` imp
  2020-12-18 23:12   ` Warner Losh
  2020-12-18 20:54 ` [PATCH 3/4] bsd-user: move strace OS/arch dependent code to host/arch dirs imp
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: imp @ 2020-12-18 20:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: Juergen Lock, Sean Bruno, Warner Losh

From: Sean Bruno <sbruno@freebsd.org>

FreeBSD can generate a trap 0xc as well as 0xe when writing to a
read-only page.

Signed-off-by: Juergen Lock <nox@FreeBSD.org>
[imp rewored commit message for clarity]
Signed-off-by: Warner Losh <imp@FreeBSD.org>
---
 accel/tcg/user-exec.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
index 4ebe25461a..1f5befa9f9 100644
--- a/accel/tcg/user-exec.c
+++ b/accel/tcg/user-exec.c
@@ -343,7 +343,13 @@ int cpu_signal_handler(int host_signum, void *pinfo,
 
     pc = PC_sig(uc);
     return handle_cpu_signal(pc, info,
-                             TRAP_sig(uc) == 0xe ? (ERROR_sig(uc) >> 1) & 1 : 0,
+#if defined(__FreeBSD__) || defined(__DragonFly__)
+                             (TRAP_sig(uc) == 0xe ||
+                              TRAP_sig(uc) == 0xc) ?
+#else
+                             TRAP_sig(uc) == 0xe ?
+#endif
+                             (ERROR_sig(uc) >> 1) & 1 : 0,
                              &MASK_sig(uc));
 }
 
-- 
2.22.1



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

* [PATCH 3/4] bsd-user: move strace OS/arch dependent code to host/arch dirs
  2020-12-18 20:54 [PATCH 0/4] A few preliminary bsd-user patches imp
  2020-12-18 20:54 ` [PATCH 1/4] bsd-user: regenerate FreeBSD's system call numbers imp
  2020-12-18 20:54 ` [PATCH 2/4] tcg: Additional Trap type for FreeBSD imp
@ 2020-12-18 20:54 ` imp
  2020-12-18 20:54 ` [PATCH 4/4] bsd-user: Update strace.list for FreeBSD's latest syscalls imp
  2021-01-05  2:27 ` [PATCH 0/4] A few preliminary bsd-user patches Warner Losh
  4 siblings, 0 replies; 8+ messages in thread
From: imp @ 2020-12-18 20:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: Sean Bruno, Warner Losh, Stacey Son

From: Stacey Son <sson@FreeBSD.org>

This change moves host OS and arch dependent code for the sysarch
system call related to the -strace functionality into the
appropriate host OS and target arch directories.

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Sean Bruno <sburno@FreeBSD.org>
[ imp integrated minor build fixes from sbruno ]
Signed-off-by: Warner Losh <imp@FreeBSD.org>
---
 bsd-user/arm/target_arch_sysarch.h     | 78 ++++++++++++++++++++++++++
 bsd-user/arm/target_syscall.h          | 36 ++++++++++++
 bsd-user/freebsd/os-strace.h           | 29 ++++++++++
 bsd-user/freebsd/strace.list           |  3 +-
 bsd-user/i386/target_arch_sysarch.h    | 77 +++++++++++++++++++++++++
 bsd-user/i386/target_syscall.h         | 19 +++++++
 bsd-user/mips/target_arch_sysarch.h    | 69 +++++++++++++++++++++++
 bsd-user/mips/target_syscall.h         | 52 +++++++++++++++++
 bsd-user/mips64/target_arch_sysarch.h  | 69 +++++++++++++++++++++++
 bsd-user/mips64/target_syscall.h       | 53 +++++++++++++++++
 bsd-user/netbsd/os-strace.h            |  1 +
 bsd-user/openbsd/os-strace.h           |  1 +
 bsd-user/sparc/target_arch_sysarch.h   | 52 +++++++++++++++++
 bsd-user/sparc/target_syscall.h        | 24 +++++++-
 bsd-user/sparc64/target_arch_sysarch.h | 52 +++++++++++++++++
 bsd-user/sparc64/target_syscall.h      | 24 +++++++-
 bsd-user/strace.c                      | 11 ++++
 bsd-user/x86_64/target_arch_sysarch.h  | 76 +++++++++++++++++++++++++
 bsd-user/x86_64/target_syscall.h       | 21 ++++++-
 meson.build                            |  1 +
 20 files changed, 744 insertions(+), 4 deletions(-)
 create mode 100644 bsd-user/arm/target_arch_sysarch.h
 create mode 100644 bsd-user/arm/target_syscall.h
 create mode 100644 bsd-user/freebsd/os-strace.h
 create mode 100644 bsd-user/i386/target_arch_sysarch.h
 create mode 100644 bsd-user/mips/target_arch_sysarch.h
 create mode 100644 bsd-user/mips/target_syscall.h
 create mode 100644 bsd-user/mips64/target_arch_sysarch.h
 create mode 100644 bsd-user/mips64/target_syscall.h
 create mode 100644 bsd-user/netbsd/os-strace.h
 create mode 100644 bsd-user/openbsd/os-strace.h
 create mode 100644 bsd-user/sparc/target_arch_sysarch.h
 create mode 100644 bsd-user/sparc64/target_arch_sysarch.h
 create mode 100644 bsd-user/x86_64/target_arch_sysarch.h

diff --git a/bsd-user/arm/target_arch_sysarch.h b/bsd-user/arm/target_arch_sysarch.h
new file mode 100644
index 0000000000..632a5cd453
--- /dev/null
+++ b/bsd-user/arm/target_arch_sysarch.h
@@ -0,0 +1,78 @@
+/*
+ *  arm sysarch() system call emulation
+ *
+ *  Copyright (c) 2013 Stacey D. Son
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef BSD_USER_ARCH_SYSARCH_H_
+#define BSD_USER_ARCH_SYSARCH_H_
+
+#include "target_syscall.h"
+#include "target_arch.h"
+
+static inline abi_long do_freebsd_arch_sysarch(CPUARMState *env, int op,
+        abi_ulong parms)
+{
+    int ret = 0;
+
+    switch (op) {
+    case TARGET_FREEBSD_ARM_SYNC_ICACHE:
+    case TARGET_FREEBSD_ARM_DRAIN_WRITEBUF:
+        break;
+
+    case TARGET_FREEBSD_ARM_SET_TP:
+        target_cpu_set_tls(env, parms);
+        break;
+
+    case TARGET_FREEBSD_ARM_GET_TP:
+        ret = target_cpu_get_tls(env);
+        break;
+
+    default:
+        ret = -TARGET_EINVAL;
+        break;
+    }
+    return ret;
+}
+
+static inline void do_freebsd_arch_print_sysarch(
+        const struct syscallname *name, abi_long arg1, abi_long arg2,
+        abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
+{
+
+    switch (arg1) {
+    case TARGET_FREEBSD_ARM_SYNC_ICACHE:
+        gemu_log("%s(ARM_SYNC_ICACHE, ...)", name->name);
+        break;
+
+    case TARGET_FREEBSD_ARM_DRAIN_WRITEBUF:
+        gemu_log("%s(ARM_DRAIN_WRITEBUF, ...)", name->name);
+        break;
+
+    case TARGET_FREEBSD_ARM_SET_TP:
+        gemu_log("%s(ARM_SET_TP, 0x" TARGET_ABI_FMT_lx ")", name->name, arg2);
+        break;
+
+    case TARGET_FREEBSD_ARM_GET_TP:
+        gemu_log("%s(ARM_GET_TP, 0x" TARGET_ABI_FMT_lx ")", name->name, arg2);
+        break;
+
+    default:
+        gemu_log("UNKNOWN OP: %d, " TARGET_ABI_FMT_lx ")", (int)arg1, arg2);
+    }
+}
+
+#endif /*!BSD_USER_ARCH_SYSARCH_H_ */
diff --git a/bsd-user/arm/target_syscall.h b/bsd-user/arm/target_syscall.h
new file mode 100644
index 0000000000..ef4b37f017
--- /dev/null
+++ b/bsd-user/arm/target_syscall.h
@@ -0,0 +1,36 @@
+#ifndef BSD_USER_ARCH_SYSCALL_H_
+#define BSD_USER_ARCH_SYSCALL_H_
+
+struct target_pt_regs {
+    abi_long uregs[17];
+};
+
+#define ARM_cpsr    uregs[16]
+#define ARM_pc      uregs[15]
+#define ARM_lr      uregs[14]
+#define ARM_sp      uregs[13]
+#define ARM_ip      uregs[12]
+#define ARM_fp      uregs[11]
+#define ARM_r10     uregs[10]
+#define ARM_r9      uregs[9]
+#define ARM_r8      uregs[8]
+#define ARM_r7      uregs[7]
+#define ARM_r6      uregs[6]
+#define ARM_r5      uregs[5]
+#define ARM_r4      uregs[4]
+#define ARM_r3      uregs[3]
+#define ARM_r2      uregs[2]
+#define ARM_r1      uregs[1]
+#define ARM_r0      uregs[0]
+
+#define ARM_SYSCALL_BASE    0 /* XXX: FreeBSD only */
+
+#define TARGET_FREEBSD_ARM_SYNC_ICACHE      0
+#define TARGET_FREEBSD_ARM_DRAIN_WRITEBUF   1
+#define TARGET_FREEBSD_ARM_SET_TP       2
+#define TARGET_FREEBSD_ARM_GET_TP       3
+
+#define TARGET_HW_MACHINE       "arm"
+#define TARGET_HW_MACHINE_ARCH  "armv6"
+
+#endif /* !BSD_USER_ARCH_SYSCALL_H_ */
diff --git a/bsd-user/freebsd/os-strace.h b/bsd-user/freebsd/os-strace.h
new file mode 100644
index 0000000000..a222f093b5
--- /dev/null
+++ b/bsd-user/freebsd/os-strace.h
@@ -0,0 +1,29 @@
+/*
+ *  FreeBSD dependent strace print functions
+ *
+ *  Copyright (c) 2013 Stacey D. Son
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "target_arch_sysarch.h"    /* architecture dependent functions */
+
+
+static inline void do_os_print_sysarch(const struct syscallname *name,
+        abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4,
+        abi_long arg5, abi_long arg6)
+{
+    /* This is arch dependent */
+    do_freebsd_arch_print_sysarch(name, arg1, arg2, arg3, arg4, arg5, arg6);
+}
diff --git a/bsd-user/freebsd/strace.list b/bsd-user/freebsd/strace.list
index 2800a2d4eb..d8f2eb66a6 100644
--- a/bsd-user/freebsd/strace.list
+++ b/bsd-user/freebsd/strace.list
@@ -28,6 +28,7 @@
 { TARGET_FREEBSD_NR___acl_set_fd, "__acl_set_fd", "%s(%d, %d, %#x)", NULL, NULL },
 { TARGET_FREEBSD_NR___acl_set_file, "__acl_set_file", "%s(\"%s\", %d, %#x)", NULL, NULL },
 { TARGET_FREEBSD_NR___acl_set_link, "__acl_set_link", "%s(\"%s\", %d, %#x)", NULL, NULL },
+{ TARGET_FREEBSD_NR___getcwd, "__getcwd", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR___semctl, "__semctl", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR___syscall, "__syscall", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR___sysctl, "__sysctl", NULL, print_sysctl, NULL },
@@ -209,7 +210,7 @@
 { TARGET_FREEBSD_NR_statfs, "statfs", "%s(\"%s\",%p)", NULL, NULL },
 { TARGET_FREEBSD_NR_symlink, "symlink", "%s(\"%s\",\"%s\")", NULL, NULL },
 { TARGET_FREEBSD_NR_sync, "sync", NULL, NULL, NULL },
-{ TARGET_FREEBSD_NR_sysarch, "sysarch", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_sysarch, "sysarch", NULL, print_sysarch, NULL },
 { TARGET_FREEBSD_NR_syscall, "syscall", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_thr_create, "thr_create", "%s(%#x, %#x, %d)", NULL, NULL },
 { TARGET_FREEBSD_NR_thr_exit, "thr_exit", "%s(%#x)", NULL, NULL },
diff --git a/bsd-user/i386/target_arch_sysarch.h b/bsd-user/i386/target_arch_sysarch.h
new file mode 100644
index 0000000000..e9ab98ec32
--- /dev/null
+++ b/bsd-user/i386/target_arch_sysarch.h
@@ -0,0 +1,77 @@
+/*
+ *  i386 sysarch system call emulation
+ *
+ *  Copyright (c) 2013 Stacey D. Son
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef BSD_USER_ARCH_SYSARCH_H_
+#define BSD_USER_ARCH_SYSARCH_H_
+
+#include "target_syscall.h"
+
+static inline abi_long do_freebsd_arch_sysarch(CPUX86State *env, int op,
+        abi_ulong parms)
+{
+    abi_long ret = 0;
+    abi_ulong val;
+    int idx;
+
+    switch (op) {
+    case TARGET_FREEBSD_I386_SET_GSBASE:
+    case TARGET_FREEBSD_I386_SET_FSBASE:
+        if (op == TARGET_FREEBSD_I386_SET_GSBASE) {
+            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;
+
+    case TARGET_FREEBSD_I386_GET_GSBASE:
+    case TARGET_FREEBSD_I386_GET_FSBASE:
+        if (op == TARGET_FREEBSD_I386_GET_GSBASE) {
+            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;
+}
+
+static inline void do_freebsd_arch_print_sysarch(
+        const struct syscallname *name, abi_long arg1, abi_long arg2,
+        abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
+{
+
+    gemu_log("%s(%d, " TARGET_ABI_FMT_lx ", " TARGET_ABI_FMT_lx ", "
+        TARGET_ABI_FMT_lx ")", name->name, (int)arg1, arg2, arg3, arg4);
+}
+
+#endif /* !BSD_USER_ARCH_SYSARCH_H_ */
diff --git a/bsd-user/i386/target_syscall.h b/bsd-user/i386/target_syscall.h
index 8f201386af..940c687a52 100644
--- a/bsd-user/i386/target_syscall.h
+++ b/bsd-user/i386/target_syscall.h
@@ -1,3 +1,20 @@
+/*
+ *  i386 system call definitions
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
 #ifndef TARGET_SYSCALL_H
 #define TARGET_SYSCALL_H
 
@@ -161,5 +178,7 @@ struct target_vm86plus_struct {
 
 
 #define UNAME_MACHINE "i386"
+#define TARGET_HW_MACHINE UNAME_MACHINE
+#define TARGET_HW_MACHINE_ARCH UNAME_MACHINE
 
 #endif /* TARGET_SYSCALL_H */
diff --git a/bsd-user/mips/target_arch_sysarch.h b/bsd-user/mips/target_arch_sysarch.h
new file mode 100644
index 0000000000..6da803a408
--- /dev/null
+++ b/bsd-user/mips/target_arch_sysarch.h
@@ -0,0 +1,69 @@
+/*
+ *  mips sysarch() system call emulation
+ *
+ *  Copyright (c) 2013 Stacey D. Son
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef BSD_USER_ARCH_SYSARCH_H_
+#define BSD_USER_ARCH_SYSARCH_H_
+
+#include "target_syscall.h"
+#include "target_arch.h"
+
+static inline abi_long do_freebsd_arch_sysarch(CPUMIPSState *env, int op,
+        abi_ulong parms)
+{
+    int ret = 0;
+
+    switch (op) {
+    case TARGET_MIPS_SET_TLS:
+        target_cpu_set_tls(env, parms);
+        break;
+
+    case TARGET_MIPS_GET_TLS:
+        if (put_user(target_cpu_get_tls(env), parms, abi_ulong)) {
+            ret = -TARGET_EFAULT;
+        }
+        break;
+
+    default:
+        ret = -TARGET_EINVAL;
+        break;
+    }
+
+    return ret;
+}
+
+static inline void do_freebsd_arch_print_sysarch(
+        const struct syscallname *name, abi_long arg1, abi_long arg2,
+        abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
+{
+
+    switch (arg1) {
+    case TARGET_MIPS_SET_TLS:
+        gemu_log("%s(SET_TLS, 0x" TARGET_ABI_FMT_lx ")", name->name, arg2);
+        break;
+
+    case TARGET_MIPS_GET_TLS:
+        gemu_log("%s(GET_TLS, 0x" TARGET_ABI_FMT_lx ")", name->name, arg2);
+        break;
+
+    default:
+        gemu_log("UNKNOWN OP: %d, " TARGET_ABI_FMT_lx ")", (int)arg1, arg2);
+    }
+}
+
+#endif /*!BSD_USER_ARCH_SYSARCH_H_ */
diff --git a/bsd-user/mips/target_syscall.h b/bsd-user/mips/target_syscall.h
new file mode 100644
index 0000000000..aacc6ddf9f
--- /dev/null
+++ b/bsd-user/mips/target_syscall.h
@@ -0,0 +1,52 @@
+/*
+ *  mips system call definitions
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _MIPS_SYSCALL_H_
+#define _MIPS_SYSCALL_H_
+
+/*
+ * struct target_pt_regs defines the way the registers are stored on the stack
+ * during a system call.
+ */
+
+struct target_pt_regs {
+    /* Saved main processor registers. */
+    abi_ulong regs[32];
+
+    /* Saved special registers. */
+    abi_ulong cp0_status;
+    abi_ulong lo;
+    abi_ulong hi;
+    abi_ulong cp0_badvaddr;
+    abi_ulong cp0_cause;
+    abi_ulong cp0_epc;
+};
+
+#if defined(TARGET_WORDS_BIGENDIAN)
+#define UNAME_MACHINE "mips"
+#else
+#define UNAME_MACHINE "mipsel"
+#endif
+
+#define TARGET_HW_MACHINE       "mips"
+#define TARGET_HW_MACHINE_ARCH   UNAME_MACHINE
+
+/* sysarch() commands */
+#define TARGET_MIPS_SET_TLS     1
+#define TARGET_MIPS_GET_TLS     2
+
+#endif /* !_MIPS_SYSCALL_H_ */
diff --git a/bsd-user/mips64/target_arch_sysarch.h b/bsd-user/mips64/target_arch_sysarch.h
new file mode 100644
index 0000000000..e6f9c00d5f
--- /dev/null
+++ b/bsd-user/mips64/target_arch_sysarch.h
@@ -0,0 +1,69 @@
+/*
+ *  mips64 sysarch() system call emulation
+ *
+ *  Copyright (c) 2013 Stacey D. Son
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef BSD_USER_ARCH_SYSARCH_H_
+#define BSD_USER_ARCH_SYSARCH_H_
+
+#include "target_syscall.h"
+#include "target_arch.h"
+
+static inline abi_long do_freebsd_arch_sysarch(CPUMIPSState *env, int op,
+        abi_ulong parms)
+{
+    int ret = 0;
+
+    switch (op) {
+    case TARGET_MIPS_SET_TLS:
+        target_cpu_set_tls(env, parms);
+        break;
+
+    case TARGET_MIPS_GET_TLS:
+        if (put_user(target_cpu_get_tls(env), parms, abi_ulong)) {
+            ret = -TARGET_EFAULT;
+        }
+        break;
+
+    default:
+        ret = -TARGET_EINVAL;
+        break;
+    }
+
+    return ret;
+}
+
+static inline void do_freebsd_arch_print_sysarch(
+        const struct syscallname *name, abi_long arg1, abi_long arg2,
+        abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
+{
+
+    switch (arg1) {
+    case TARGET_MIPS_SET_TLS:
+        gemu_log("%s(SET_TLS, 0x" TARGET_ABI_FMT_lx ")", name->name, arg2);
+        break;
+
+    case TARGET_MIPS_GET_TLS:
+        gemu_log("%s(GET_TLS, 0x" TARGET_ABI_FMT_lx ")", name->name, arg2);
+        break;
+
+    default:
+        gemu_log("UNKNOWN OP: %d, " TARGET_ABI_FMT_lx ")", (int)arg1, arg2);
+    }
+}
+
+#endif /*!BSD_USER_ARCH_SYSARCH_H_ */
diff --git a/bsd-user/mips64/target_syscall.h b/bsd-user/mips64/target_syscall.h
new file mode 100644
index 0000000000..bf4c598b13
--- /dev/null
+++ b/bsd-user/mips64/target_syscall.h
@@ -0,0 +1,53 @@
+/*
+ *  mips64 system call definitions
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _MIPS64_SYSCALL_H_
+#define _MIPS64_SYSCALL_H_
+
+/*
+ * struct target_pt_regs defines the way the registers are stored on the stack
+ * during a system call.
+ */
+
+struct target_pt_regs {
+    /* Saved main processor registers. */
+    abi_ulong regs[32];
+
+    /* Saved special registers. */
+    abi_ulong cp0_status;
+    abi_ulong lo;
+    abi_ulong hi;
+    abi_ulong cp0_badvaddr;
+    abi_ulong cp0_cause;
+    abi_ulong cp0_epc;
+};
+
+
+#if defined(TARGET_WORDS_BIGENDIAN)
+#define UNAME_MACHINE "mips64"
+#else
+#define UNAME_MACHINE "mips64el"
+#endif
+
+#define TARGET_HW_MACHINE       "mips"
+#define TARGET_HW_MACHINE_ARCH  UNAME_MACHINE
+
+/* sysarch() commands */
+#define TARGET_MIPS_SET_TLS     1
+#define TARGET_MIPS_GET_TLS     2
+
+#endif /* !_MIPS64_SYSCALL_H_ */
diff --git a/bsd-user/netbsd/os-strace.h b/bsd-user/netbsd/os-strace.h
new file mode 100644
index 0000000000..70cf51d63a
--- /dev/null
+++ b/bsd-user/netbsd/os-strace.h
@@ -0,0 +1 @@
+/* XXX NetBSD dependent strace print functions */
diff --git a/bsd-user/openbsd/os-strace.h b/bsd-user/openbsd/os-strace.h
new file mode 100644
index 0000000000..9161390433
--- /dev/null
+++ b/bsd-user/openbsd/os-strace.h
@@ -0,0 +1 @@
+/* XXX OpenBSD dependent strace print functions */
diff --git a/bsd-user/sparc/target_arch_sysarch.h b/bsd-user/sparc/target_arch_sysarch.h
new file mode 100644
index 0000000000..d0b85ef6bb
--- /dev/null
+++ b/bsd-user/sparc/target_arch_sysarch.h
@@ -0,0 +1,52 @@
+/*
+ *  SPARC sysarch() system call emulation
+ *
+ *  Copyright (c) 2013 Stacey D. Son
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef BSD_USER_ARCH_SYSARCH_H_
+#define BSD_USER_ARCH_SYSARCH_H_
+
+#include "target_syscall.h"
+
+static inline abi_long do_freebsd_arch_sysarch(void *env, int op,
+        abi_ulong parms)
+{
+    int ret = 0;
+
+    switch (op) {
+    case TARGET_SPARC_SIGTRAMP_INSTALL:
+        /* XXX not currently handled */
+    case TARGET_SPARC_UTRAP_INSTALL:
+        /* XXX not currently handled */
+    default:
+        ret = -TARGET_EINVAL;
+        break;
+    }
+
+    return ret;
+}
+
+static inline void do_freebsd_arch_print_sysarch(
+        const struct syscallname *name, abi_long arg1, abi_long arg2,
+        abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
+{
+
+    gemu_log("%s(%d, " TARGET_ABI_FMT_lx ", " TARGET_ABI_FMT_lx ", "
+        TARGET_ABI_FMT_lx ")", name->name, (int)arg1, arg2, arg3, arg4);
+}
+
+#endif /*!BSD_USER_ARCH_SYSARCH_H_ */
diff --git a/bsd-user/sparc/target_syscall.h b/bsd-user/sparc/target_syscall.h
index dfdf9f82f5..151284754b 100644
--- a/bsd-user/sparc/target_syscall.h
+++ b/bsd-user/sparc/target_syscall.h
@@ -1,3 +1,20 @@
+/*
+ *  sparc dependent system call definitions
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
 #ifndef TARGET_SYSCALL_H
 #define TARGET_SYSCALL_H
 
@@ -9,6 +26,11 @@ struct target_pt_regs {
 	abi_ulong u_regs[16];
 };
 
-#define UNAME_MACHINE "sun4"
+#define UNAME_MACHINE           "sun4"
+#define TARGET_HW_MACHINE       "sparc"
+#define TARGET_HW_MACHINE_ARCH  "sparc"
+
+#define TARGET_SPARC_UTRAP_INSTALL      1
+#define TARGET_SPARC_SIGTRAMP_INSTALL   2
 
 #endif /* TARGET_SYSCALL_H */
diff --git a/bsd-user/sparc64/target_arch_sysarch.h b/bsd-user/sparc64/target_arch_sysarch.h
new file mode 100644
index 0000000000..e6f17c1504
--- /dev/null
+++ b/bsd-user/sparc64/target_arch_sysarch.h
@@ -0,0 +1,52 @@
+/*
+ *  SPARC64 sysarch() system call emulation
+ *
+ *  Copyright (c) 2013 Stacey D. Son
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef BSD_USER_ARCH_SYSARCH_H_
+#define BSD_USER_ARCH_SYSARCH_H_
+
+#include "target_syscall.h"
+
+static inline abi_long do_freebsd_arch_sysarch(void *env, int op,
+        abi_ulong parms)
+{
+    int ret = 0;
+
+    switch (op) {
+    case TARGET_SPARC_SIGTRAMP_INSTALL:
+        /* XXX not currently handled */
+    case TARGET_SPARC_UTRAP_INSTALL:
+        /* XXX not currently handled */
+    default:
+        ret = -TARGET_EINVAL;
+        break;
+    }
+
+    return ret;
+}
+
+static inline void do_freebsd_arch_print_sysarch(
+        const struct syscallname *name, abi_long arg1, abi_long arg2,
+        abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
+{
+
+    gemu_log("%s(%d, " TARGET_ABI_FMT_lx ", " TARGET_ABI_FMT_lx ", "
+        TARGET_ABI_FMT_lx ")", name->name, (int)arg1, arg2, arg3, arg4);
+}
+
+#endif /*!BSD_USER_ARCH_SYSARCH_H_ */
diff --git a/bsd-user/sparc64/target_syscall.h b/bsd-user/sparc64/target_syscall.h
index 3a9f4c2ef9..b7d986a76d 100644
--- a/bsd-user/sparc64/target_syscall.h
+++ b/bsd-user/sparc64/target_syscall.h
@@ -1,3 +1,20 @@
+/*
+ *  sparc64 dependent system call definitions
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
 #ifndef TARGET_SYSCALL_H
 #define TARGET_SYSCALL_H
 
@@ -10,6 +27,11 @@ struct target_pt_regs {
 	abi_ulong fprs;
 };
 
-#define UNAME_MACHINE "sun4u"
+#define UNAME_MACHINE           "sun4u"
+#define TARGET_HW_MACHINE       "sparc"
+#define TARGET_HW_MACHINE_ARCH  "sparc64"
+
+#define TARGET_SPARC_UTRAP_INSTALL      1
+#define TARGET_SPARC_SIGTRAMP_INSTALL   2
 
 #endif /* TARGET_SYSCALL_H */
diff --git a/bsd-user/strace.c b/bsd-user/strace.c
index fa66fe1ee2..2c3b59caf0 100644
--- a/bsd-user/strace.c
+++ b/bsd-user/strace.c
@@ -20,9 +20,12 @@
 #include <sys/select.h>
 #include <sys/syscall.h>
 #include <sys/ioccom.h>
+#include <ctype.h>
 
 #include "qemu.h"
 
+#include "os-strace.h"  /* OS dependent strace print functions */
+
 int do_strace;
 
 /*
@@ -104,6 +107,14 @@ static void print_ioctl(const struct syscallname *name,
             arg3);
 }
 
+static void print_sysarch(const struct syscallname *name, abi_long arg1,
+        abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5,
+        abi_long arg6)
+{
+    /* This is os dependent. */
+    do_os_print_sysarch(name, arg1, arg2, arg3, arg4, arg5, arg6);
+}
+
 /*
  * Variants for the return value output function
  */
diff --git a/bsd-user/x86_64/target_arch_sysarch.h b/bsd-user/x86_64/target_arch_sysarch.h
new file mode 100644
index 0000000000..5c36fc0752
--- /dev/null
+++ b/bsd-user/x86_64/target_arch_sysarch.h
@@ -0,0 +1,76 @@
+/*
+ *  x86_64 sysarch() syscall emulation
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef BSD_USER_ARCH_SYSARCH_H_
+#define BSD_USER_ARCH_SYSARCH_H_
+
+#include "target_syscall.h"
+
+static inline abi_long do_freebsd_arch_sysarch(CPUX86State *env, int op,
+        abi_ulong parms)
+{
+    abi_long ret = 0;
+    abi_ulong val;
+    int idx;
+
+    switch (op) {
+    case TARGET_FREEBSD_AMD64_SET_GSBASE:
+    case TARGET_FREEBSD_AMD64_SET_FSBASE:
+        if (op == TARGET_FREEBSD_AMD64_SET_GSBASE) {
+            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;
+
+    case TARGET_FREEBSD_AMD64_GET_GSBASE:
+    case TARGET_FREEBSD_AMD64_GET_FSBASE:
+        if (op == TARGET_FREEBSD_AMD64_GET_GSBASE) {
+            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;
+}
+
+static inline void do_freebsd_arch_print_sysarch(
+        const struct syscallname *name, abi_long arg1, abi_long arg2,
+        abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
+{
+
+    gemu_log("%s(%d, " TARGET_ABI_FMT_lx ", " TARGET_ABI_FMT_lx ", "
+        TARGET_ABI_FMT_lx ")", name->name, (int)arg1, arg2, arg3, arg4);
+}
+
+#endif /*! BSD_USER_ARCH_SYSARCH_H_ */
diff --git a/bsd-user/x86_64/target_syscall.h b/bsd-user/x86_64/target_syscall.h
index a5d779884f..a8e6274b76 100644
--- a/bsd-user/x86_64/target_syscall.h
+++ b/bsd-user/x86_64/target_syscall.h
@@ -1,3 +1,20 @@
+/*
+ *  x86_64 system call definitions
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
 #ifndef TARGET_SYSCALL_H
 #define TARGET_SYSCALL_H
 
@@ -111,7 +128,9 @@ struct target_msqid64_ds {
 #define TARGET_FREEBSD_AMD64_SET_GSBASE	131
 
 
-#define UNAME_MACHINE "x86_64"
+#define UNAME_MACHINE           "x86_64"
+#define TARGET_HW_MACHINE       "amd64"
+#define TARGET_HW_MACHINE_ARCH  "amd64"
 
 #define TARGET_ARCH_SET_GS 0x1001
 #define TARGET_ARCH_SET_FS 0x1002
diff --git a/meson.build b/meson.build
index 372576f82c..55a73a0895 100644
--- a/meson.build
+++ b/meson.build
@@ -1800,6 +1800,7 @@ foreach target : target_dirs
       target_inc += include_directories('linux-user/host/' / config_host['ARCH'])
     else
       base_dir = 'bsd-user'
+      target_inc += include_directories('bsd-user/freebsd')
     endif
     target_inc += include_directories(
       base_dir,
-- 
2.22.1



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

* [PATCH 4/4] bsd-user: Update strace.list for FreeBSD's latest syscalls
  2020-12-18 20:54 [PATCH 0/4] A few preliminary bsd-user patches imp
                   ` (2 preceding siblings ...)
  2020-12-18 20:54 ` [PATCH 3/4] bsd-user: move strace OS/arch dependent code to host/arch dirs imp
@ 2020-12-18 20:54 ` imp
  2021-01-05  2:27 ` [PATCH 0/4] A few preliminary bsd-user patches Warner Losh
  4 siblings, 0 replies; 8+ messages in thread
From: imp @ 2020-12-18 20:54 UTC (permalink / raw)
  To: qemu-devel
  Cc: Stacey Son, Warner Losh, Alexander Kabaev, Jung-uk Kim,
	Sean Bruno, Warner Losh, Mikaël Urankar

From: Warner Losh <wlosh@netflix.com>

Update strace.list to include all of FreeBSD's syscalls up through svn
r331280.

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Sean Bruno <sburno@FreeBSD.org>
Signed-off-by: Alexander Kabaev <kan@FreeBSD.org>
Signed-off-by: Jung-uk Kim <jkim@FreeBSD.org>
Author: Michal Meloun <mmel@FreeBSD.org>
Signed-off-by: Mikaël Urankar <mikael.urankar@gmail.com>
[imp moved this change to early in the sequence]
Signed-off-by: Warner Losh <imp@FreeBSD.org>
---
 bsd-user/freebsd/strace.list | 62 ++++++++++++++++++++++++++++++++----
 1 file changed, 55 insertions(+), 7 deletions(-)

diff --git a/bsd-user/freebsd/strace.list b/bsd-user/freebsd/strace.list
index d8f2eb66a6..b01b5f36e8 100644
--- a/bsd-user/freebsd/strace.list
+++ b/bsd-user/freebsd/strace.list
@@ -33,14 +33,32 @@
 { 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 },
 { TARGET_FREEBSD_NR_acct, "acct", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_adjtime, "adjtime", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_bind, "bind", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_bindat, "bindat", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_break, "break", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_cap_enter, "cap_enter", NULL, NULL, NULL },
+{ 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 },
 { TARGET_FREEBSD_NR_chdir, "chdir", "%s(\"%s\")", NULL, NULL },
 { TARGET_FREEBSD_NR_chflags, "chflags", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_chflagsat, "chflagsat", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_chmod, "chmod", "%s(\"%s\",%#o)", NULL, NULL },
 { TARGET_FREEBSD_NR_chown, "chown", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_chroot, "chroot", NULL, NULL, NULL },
@@ -49,6 +67,9 @@
 { TARGET_FREEBSD_NR_clock_settime, "clock_settime", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_close, "close", "%s(%d)", NULL, NULL },
 { TARGET_FREEBSD_NR_connect, "connect", "%s(%d,%#x,%d)", NULL, NULL },
+{ TARGET_FREEBSD_NR_connectat, "connectat", "%s(%d,%d,%#x,%d)", NULL, NULL },
+{ TARGET_FREEBSD_NR_cpuset_getdomain, "cpuset_getdomain", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_cpuset_setdomain, "cpuset_setdomain", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_dup, "dup", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_dup2, "dup2", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_eaccess, "eaccess", "%s(\"%s\",%#x)", NULL, NULL },
@@ -62,7 +83,7 @@
 { TARGET_FREEBSD_NR_extattr_get_file, "extattr_get_file", "%s(\"%s\", %d, \"%s\", %#x, %d)", NULL, NULL },
 { TARGET_FREEBSD_NR_extattr_get_file, "extattr_get_link", "%s(\"%s\", %d, \"%s\", %#x, %d)", NULL, NULL },
 { TARGET_FREEBSD_NR_extattr_list_fd, "extattr_list_fd", "%s(%d, %d, %#x, %d)", NULL, NULL },
-{ TARGET_FREEBSD_NR_extattr_list_file, "extattr_list_file", "%s(\"%s\", %d, %#x, %d)", NULL, NULL },
+{ TARGET_FREEBSD_NR_extattr_list_file, "extattr_list_file", "%s(\"%s\", %#x, %d)", NULL, NULL },
 { TARGET_FREEBSD_NR_extattr_list_link, "extattr_list_link", "%s(\"%s\", %d, %#x, %d)", NULL, NULL },
 { TARGET_FREEBSD_NR_extattr_set_fd, "extattr_set_fd", "%s(%d, %d, \"%s\", %#x, %d)", NULL, NULL },
 { TARGET_FREEBSD_NR_extattr_set_file, "extattr_set_file", "%s(\"%s\", %d, \"%s\", %#x, %d)", NULL, NULL },
@@ -72,26 +93,34 @@
 { TARGET_FREEBSD_NR_fchmod, "fchmod", "%s(%d,%#o)", NULL, NULL },
 { TARGET_FREEBSD_NR_fchown, "fchown", "%s(%d,%d,%d)", NULL, NULL },
 { TARGET_FREEBSD_NR_fcntl, "fcntl", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_fdatasync, "fdatasync", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_fexecve, "fexecve", NULL, print_execve, NULL },
 { TARGET_FREEBSD_NR_fhopen, "fhopen", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_fhstat, "fhstat", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_fhstatfs, "fhstatfs", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_freebsd11_fhstat, "freebsd11_fhstat", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_freebsd11_fhstatfs, "freebsd11_fhstatfs", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_flock, "flock", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_fork, "fork", "%s()", NULL, NULL },
 { TARGET_FREEBSD_NR_fpathconf, "fpathconf", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_fstat, "fstat", "%s(%d,%#x)", NULL, NULL },
 { TARGET_FREEBSD_NR_fstatat, "fstatat", "%s(%d,\"%s\", %#x, %d)", NULL, NULL },
 { TARGET_FREEBSD_NR_fstatfs, "fstatfs", "%s(%d,%#x)", NULL, NULL },
+{ TARGET_FREEBSD_NR_freebsd11_fstat, "freebsd11_fstat", "%s(%d,%#x)", NULL, NULL },
+{ TARGET_FREEBSD_NR_freebsd11_fstatat, "freebsd11_fstatat", "%s(%d,\"%s\", %#x, %d)", NULL, NULL },
+{ TARGET_FREEBSD_NR_freebsd11_fstatfs, "freebsd11_fstatfs", "%s(%d,%#x)", NULL, NULL },
 { TARGET_FREEBSD_NR_fsync, "fsync", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_ftruncate, "ftruncate", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_futimens, "futimens", "%s(%d,%p)", NULL, NULL },
 { TARGET_FREEBSD_NR_futimes, "futimes", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_getcontext, "getcontext", "%s(%#x)", NULL, NULL },
 { TARGET_FREEBSD_NR_getdirentries, "getdirentries", NULL, NULL, NULL },
-{ TARGET_FREEBSD_NR_freebsd6_mmap, "freebsd6_mmap", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_freebsd11_getdirentries, "freebsd11_getdirentries", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_getegid, "getegid", "%s()", NULL, NULL },
 { TARGET_FREEBSD_NR_geteuid, "geteuid", "%s()", NULL, NULL },
 { TARGET_FREEBSD_NR_getfh, "getfh", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_getfsstat, "getfsstat", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_freebsd11_getfsstat, "freebsd11_getfsstat", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_getgid, "getgid", "%s()", NULL, NULL },
 { TARGET_FREEBSD_NR_getgroups, "getgroups", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_getitimer, "getitimer", NULL, NULL, NULL },
@@ -102,6 +131,7 @@
 { TARGET_FREEBSD_NR_getpid, "getpid", "%s()", NULL, NULL },
 { TARGET_FREEBSD_NR_getppid, "getppid", "%s()", NULL, NULL },
 { TARGET_FREEBSD_NR_getpriority, "getpriority", "%s(%#x,%#x)", NULL, NULL },
+{ TARGET_FREEBSD_NR_getrandom, "getrandom", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_getresgid, "getresgid", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_getresuid, "getresuid", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_getrlimit, "getrlimit", NULL, NULL, NULL },
@@ -113,8 +143,12 @@
 { TARGET_FREEBSD_NR_getuid, "getuid", "%s()", NULL, NULL },
 { TARGET_FREEBSD_NR_ioctl, "ioctl", NULL, print_ioctl, NULL },
 { TARGET_FREEBSD_NR_issetugid, "issetugid", "%s()", NULL, NULL },
+{ 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 },
@@ -122,13 +156,15 @@
 { TARGET_FREEBSD_NR_listen, "listen", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_lpathconf, "lpathconf", "%s(\"%s\", %d)", NULL, NULL },
 { TARGET_FREEBSD_NR_lseek, "lseek", NULL, NULL, NULL },
-{ TARGET_FREEBSD_NR_lstat, "lstat", "%s(\"%s\",%p)", NULL, NULL },
+{ TARGET_FREEBSD_NR_freebsd11_lstat, "freebsd11_lstat", "%s(\"%s\",%p)", NULL, NULL },
 { TARGET_FREEBSD_NR_madvise, "madvise", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_mincore, "mincore", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_minherit, "minherit", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_mkdir, "mkdir", "%s(\"%s\",%#o)", NULL, NULL },
 { TARGET_FREEBSD_NR_mkfifo, "mkfifo", NULL, NULL, NULL },
-{ TARGET_FREEBSD_NR_mknod, "mknod", "%s(\"%s\",%#o,%#x)", NULL, NULL },
+{ TARGET_FREEBSD_NR_mknodat, "mknodat", "%s(%d, \"%s\",%#o,%#x)", NULL, NULL },
+{ TARGET_FREEBSD_NR_freebsd11_mknod, "freebsd11_mknod", "%s(\"%s\",%#o,%#x)", NULL, NULL },
+{ TARGET_FREEBSD_NR_freebsd11_mknodat, "freebsd11_mknodat", "%s(%d, \"%s\",%#o,%#x)", NULL, NULL },
 { TARGET_FREEBSD_NR_mlock, "mlock", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_mlockall, "mlockall", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_mmap, "mmap", NULL, NULL, print_syscall_ret_addr },
@@ -147,8 +183,10 @@
 { TARGET_FREEBSD_NR_open, "open", "%s(\"%s\",%#x,%#o)", NULL, NULL },
 { TARGET_FREEBSD_NR_openat, "openat", "%s(%d, \"%s\",%#x,%#o)", NULL, NULL },
 { TARGET_FREEBSD_NR_pathconf, "pathconf", "%s(\"%s\", %d)", NULL, NULL },
-{ TARGET_FREEBSD_NR_pipe, "pipe", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_freebsd10_pipe, "freebsd10_pipe", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_pipe2, "pipe2", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_poll, "poll", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_posix_fallocate, "posix_fallocate", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_pread, "pread", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_preadv, "preadv", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_profil, "profil", NULL, NULL, NULL },
@@ -168,6 +206,8 @@
 { TARGET_FREEBSD_NR_rmdir, "rmdir", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_rtprio_thread, "rtprio_thread", "%s(%d, %d, %p)", NULL, NULL },
 { TARGET_FREEBSD_NR_sbrk, "sbrk", NULL, NULL, NULL },
+{ 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 },
 { TARGET_FREEBSD_NR_select, "select", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_semget, "semget", NULL, NULL, NULL },
@@ -206,12 +246,17 @@
 { TARGET_FREEBSD_NR_socket, "socket", "%s(%d,%d,%d)", NULL, NULL },
 { TARGET_FREEBSD_NR_socketpair, "socketpair", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_sstk, "sstk", NULL, NULL, NULL },
-{ TARGET_FREEBSD_NR_stat, "stat", "%s(\"%s\",%p)", NULL, NULL },
-{ TARGET_FREEBSD_NR_statfs, "statfs", "%s(\"%s\",%p)", NULL, NULL },
+{ 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 },
 { TARGET_FREEBSD_NR_sync, "sync", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_sysarch, "sysarch", NULL, print_sysarch, NULL },
 { TARGET_FREEBSD_NR_syscall, "syscall", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_ktimer_create, "timer_create" , NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_ktimer_delete, "timer_delete" , NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_ktimer_settime, "timer_settime" , NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_ktimer_gettime, "timer_gettime" , NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_ktimer_getoverrun, "timer_getoverrun" , NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_thr_create, "thr_create", "%s(%#x, %#x, %d)", NULL, NULL },
 { TARGET_FREEBSD_NR_thr_exit, "thr_exit", "%s(%#x)", NULL, NULL },
 { TARGET_FREEBSD_NR_thr_kill, "thr_kill", "%s(%d, %#x)", NULL, NULL },
@@ -226,7 +271,10 @@
 { TARGET_FREEBSD_NR_unlink, "unlink", "%s(\"%s\")", NULL, NULL },
 { TARGET_FREEBSD_NR_unmount, "unmount", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_utimes, "utimes", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_utimensat, "utimensat", "%s(%d,%s,%p,%#x)", NULL, NULL },
 { TARGET_FREEBSD_NR_vfork, "vfork", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_wait4, "wait4", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_wait6, "wait6", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_write, "write", "%s(%d,%#x,%d)", NULL, NULL },
 { TARGET_FREEBSD_NR_writev, "writev", "%s(%d,%p,%#x)", NULL, NULL },
+{ TARGET_FREEBSD_NR_posix_openpt, "posix_openpt", "%s(%d)", NULL, NULL },
-- 
2.22.1



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

* Re: [PATCH 2/4] tcg: Additional Trap type for FreeBSD
  2020-12-18 20:54 ` [PATCH 2/4] tcg: Additional Trap type for FreeBSD imp
@ 2020-12-18 23:12   ` Warner Losh
  0 siblings, 0 replies; 8+ messages in thread
From: Warner Losh @ 2020-12-18 23:12 UTC (permalink / raw)
  To: Warner Losh; +Cc: Juergen Lock, Sean Bruno, QEMU Developers

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

On Fri, Dec 18, 2020 at 1:55 PM <imp@freebsd.org> wrote:

> From: Sean Bruno <sbruno@freebsd.org>
>
> FreeBSD can generate a trap 0xc as well as 0xe when writing to a
> read-only page.
>
> Signed-off-by: Juergen Lock <nox@FreeBSD.org>
> [imp rewored commit message for clarity]
> Signed-off-by: Warner Losh <imp@FreeBSD.org>
> ---
>  accel/tcg/user-exec.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
> index 4ebe25461a..1f5befa9f9 100644
> --- a/accel/tcg/user-exec.c
> +++ b/accel/tcg/user-exec.c
> @@ -343,7 +343,13 @@ int cpu_signal_handler(int host_signum, void *pinfo,
>
>      pc = PC_sig(uc);
>      return handle_cpu_signal(pc, info,
> -                             TRAP_sig(uc) == 0xe ? (ERROR_sig(uc) >> 1) &
> 1 : 0,
> +#if defined(__FreeBSD__) || defined(__DragonFly__)
> +                             (TRAP_sig(uc) == 0xe ||
> +                              TRAP_sig(uc) == 0xc) ?
> +#else
> +                             TRAP_sig(uc) == 0xe ?
> +#endif
> +                             (ERROR_sig(uc) >> 1) & 1 : 0,
>

I'd like to withdraw this patch. After I posted it I talked to our x86
expert and he's convinced it's bogus.

We'll run without it for a while and see if we need to revisit this or not.
But for now, please don't consider this change.

Warner


>                               &MASK_sig(uc));
>  }
>
> --
> 2.22.1
>
>

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

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

* Re: [PATCH 0/4] A few preliminary bsd-user patches
  2020-12-18 20:54 [PATCH 0/4] A few preliminary bsd-user patches imp
                   ` (3 preceding siblings ...)
  2020-12-18 20:54 ` [PATCH 4/4] bsd-user: Update strace.list for FreeBSD's latest syscalls imp
@ 2021-01-05  2:27 ` Warner Losh
  4 siblings, 0 replies; 8+ messages in thread
From: Warner Losh @ 2021-01-05  2:27 UTC (permalink / raw)
  To: Warner Losh; +Cc: QEMU Developers

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

On Fri, Dec 18, 2020 at 1:55 PM <imp@freebsd.org> wrote:

> From: Warner Losh <imp@freebsd.org>
>
> Here's the first round of bsd-user patches. There's on the order of 280
> that
> we've done, but that's too much to review all at once. In addition, 3.1
> release
> was the last rebase point that we've been successful with for a number of
> reasons
> unrelated to qemu. Now that those have been resolved, we have a new push
> under way
> to push things forward, but wanted to upstream as many of the patches as
> we can
> directly to qemu's head to lighten the load of carrying all these.
>
> This first small series updates the system call lists, moves things around
> to
> make it easier to support divergence in the BSD world, and adjusts to the
> new
> meson build. It's also designed to help me learn how to land such a large
> set
> upstream.
>
> These patches have passed through several hands, with different tweaks
> over the
> years so have an unusually large number of signed-off-by lines that are the
> result of this refinement process where several hands have touched the
> patches
> in the last 7 years.
>
> Sean Bruno (1):
>   tcg: Additional Trap type for FreeBSD
>
> Stacey Son (1):
>   bsd-user: move strace OS/arch dependent code to host/arch dirs
>
> Warner Losh (2):
>   bsd-user: regenerate FreeBSD's system call numbers
>   bsd-user: Update strace.list for FreeBSD's latest syscalls
>
>  accel/tcg/user-exec.c                  |   8 +-
>  bsd-user/arm/target_arch_sysarch.h     |  78 +++
>  bsd-user/arm/target_syscall.h          |  36 ++
>  bsd-user/freebsd/os-strace.h           |  29 ++
>  bsd-user/freebsd/strace.list           |  65 ++-
>  bsd-user/freebsd/syscall_nr.h          | 695 ++++++++++++++-----------
>  bsd-user/i386/target_arch_sysarch.h    |  77 +++
>  bsd-user/i386/target_syscall.h         |  19 +
>  bsd-user/mips/target_arch_sysarch.h    |  69 +++
>  bsd-user/mips/target_syscall.h         |  52 ++
>  bsd-user/mips64/target_arch_sysarch.h  |  69 +++
>  bsd-user/mips64/target_syscall.h       |  53 ++
>  bsd-user/netbsd/os-strace.h            |   1 +
>  bsd-user/openbsd/os-strace.h           |   1 +
>  bsd-user/sparc/target_arch_sysarch.h   |  52 ++
>  bsd-user/sparc/target_syscall.h        |  24 +-
>  bsd-user/sparc64/target_arch_sysarch.h |  52 ++
>  bsd-user/sparc64/target_syscall.h      |  24 +-
>  bsd-user/strace.c                      |  11 +
>  bsd-user/x86_64/target_arch_sysarch.h  |  76 +++
>  bsd-user/x86_64/target_syscall.h       |  21 +-
>  meson.build                            |   1 +
>  22 files changed, 1186 insertions(+), 327 deletions(-)
>  create mode 100644 bsd-user/arm/target_arch_sysarch.h
>  create mode 100644 bsd-user/arm/target_syscall.h
>  create mode 100644 bsd-user/freebsd/os-strace.h
>  create mode 100644 bsd-user/i386/target_arch_sysarch.h
>  create mode 100644 bsd-user/mips/target_arch_sysarch.h
>  create mode 100644 bsd-user/mips/target_syscall.h
>  create mode 100644 bsd-user/mips64/target_arch_sysarch.h
>  create mode 100644 bsd-user/mips64/target_syscall.h
>  create mode 100644 bsd-user/netbsd/os-strace.h
>  create mode 100644 bsd-user/openbsd/os-strace.h
>  create mode 100644 bsd-user/sparc/target_arch_sysarch.h
>  create mode 100644 bsd-user/sparc64/target_arch_sysarch.h
>  create mode 100644 bsd-user/x86_64/target_arch_sysarch.h
>

ping?

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

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

* [PATCH 3/4] bsd-user: move strace OS/arch dependent code to host/arch dirs
  2020-12-18 20:52 imp
@ 2020-12-18 20:52 ` imp
  0 siblings, 0 replies; 8+ messages in thread
From: imp @ 2020-12-18 20:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: Sean Bruno, Warner Losh, Stacey Son

From: Stacey Son <sson@FreeBSD.org>

This change moves host OS and arch dependent code for the sysarch
system call related to the -strace functionality into the
appropriate host OS and target arch directories.

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Sean Bruno <sburno@FreeBSD.org>
[ imp integrated minor build fixes from sbruno ]
Signed-off-by: Warner Losh <imp@FreeBSD.org>
---
 bsd-user/arm/target_arch_sysarch.h     | 78 ++++++++++++++++++++++++++
 bsd-user/arm/target_syscall.h          | 36 ++++++++++++
 bsd-user/freebsd/os-strace.h           | 29 ++++++++++
 bsd-user/freebsd/strace.list           |  3 +-
 bsd-user/i386/target_arch_sysarch.h    | 77 +++++++++++++++++++++++++
 bsd-user/i386/target_syscall.h         | 19 +++++++
 bsd-user/mips/target_arch_sysarch.h    | 69 +++++++++++++++++++++++
 bsd-user/mips/target_syscall.h         | 52 +++++++++++++++++
 bsd-user/mips64/target_arch_sysarch.h  | 69 +++++++++++++++++++++++
 bsd-user/mips64/target_syscall.h       | 53 +++++++++++++++++
 bsd-user/netbsd/os-strace.h            |  1 +
 bsd-user/openbsd/os-strace.h           |  1 +
 bsd-user/sparc/target_arch_sysarch.h   | 52 +++++++++++++++++
 bsd-user/sparc/target_syscall.h        | 24 +++++++-
 bsd-user/sparc64/target_arch_sysarch.h | 52 +++++++++++++++++
 bsd-user/sparc64/target_syscall.h      | 24 +++++++-
 bsd-user/strace.c                      | 11 ++++
 bsd-user/x86_64/target_arch_sysarch.h  | 76 +++++++++++++++++++++++++
 bsd-user/x86_64/target_syscall.h       | 21 ++++++-
 meson.build                            |  1 +
 20 files changed, 744 insertions(+), 4 deletions(-)
 create mode 100644 bsd-user/arm/target_arch_sysarch.h
 create mode 100644 bsd-user/arm/target_syscall.h
 create mode 100644 bsd-user/freebsd/os-strace.h
 create mode 100644 bsd-user/i386/target_arch_sysarch.h
 create mode 100644 bsd-user/mips/target_arch_sysarch.h
 create mode 100644 bsd-user/mips/target_syscall.h
 create mode 100644 bsd-user/mips64/target_arch_sysarch.h
 create mode 100644 bsd-user/mips64/target_syscall.h
 create mode 100644 bsd-user/netbsd/os-strace.h
 create mode 100644 bsd-user/openbsd/os-strace.h
 create mode 100644 bsd-user/sparc/target_arch_sysarch.h
 create mode 100644 bsd-user/sparc64/target_arch_sysarch.h
 create mode 100644 bsd-user/x86_64/target_arch_sysarch.h

diff --git a/bsd-user/arm/target_arch_sysarch.h b/bsd-user/arm/target_arch_sysarch.h
new file mode 100644
index 0000000000..632a5cd453
--- /dev/null
+++ b/bsd-user/arm/target_arch_sysarch.h
@@ -0,0 +1,78 @@
+/*
+ *  arm sysarch() system call emulation
+ *
+ *  Copyright (c) 2013 Stacey D. Son
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef BSD_USER_ARCH_SYSARCH_H_
+#define BSD_USER_ARCH_SYSARCH_H_
+
+#include "target_syscall.h"
+#include "target_arch.h"
+
+static inline abi_long do_freebsd_arch_sysarch(CPUARMState *env, int op,
+        abi_ulong parms)
+{
+    int ret = 0;
+
+    switch (op) {
+    case TARGET_FREEBSD_ARM_SYNC_ICACHE:
+    case TARGET_FREEBSD_ARM_DRAIN_WRITEBUF:
+        break;
+
+    case TARGET_FREEBSD_ARM_SET_TP:
+        target_cpu_set_tls(env, parms);
+        break;
+
+    case TARGET_FREEBSD_ARM_GET_TP:
+        ret = target_cpu_get_tls(env);
+        break;
+
+    default:
+        ret = -TARGET_EINVAL;
+        break;
+    }
+    return ret;
+}
+
+static inline void do_freebsd_arch_print_sysarch(
+        const struct syscallname *name, abi_long arg1, abi_long arg2,
+        abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
+{
+
+    switch (arg1) {
+    case TARGET_FREEBSD_ARM_SYNC_ICACHE:
+        gemu_log("%s(ARM_SYNC_ICACHE, ...)", name->name);
+        break;
+
+    case TARGET_FREEBSD_ARM_DRAIN_WRITEBUF:
+        gemu_log("%s(ARM_DRAIN_WRITEBUF, ...)", name->name);
+        break;
+
+    case TARGET_FREEBSD_ARM_SET_TP:
+        gemu_log("%s(ARM_SET_TP, 0x" TARGET_ABI_FMT_lx ")", name->name, arg2);
+        break;
+
+    case TARGET_FREEBSD_ARM_GET_TP:
+        gemu_log("%s(ARM_GET_TP, 0x" TARGET_ABI_FMT_lx ")", name->name, arg2);
+        break;
+
+    default:
+        gemu_log("UNKNOWN OP: %d, " TARGET_ABI_FMT_lx ")", (int)arg1, arg2);
+    }
+}
+
+#endif /*!BSD_USER_ARCH_SYSARCH_H_ */
diff --git a/bsd-user/arm/target_syscall.h b/bsd-user/arm/target_syscall.h
new file mode 100644
index 0000000000..ef4b37f017
--- /dev/null
+++ b/bsd-user/arm/target_syscall.h
@@ -0,0 +1,36 @@
+#ifndef BSD_USER_ARCH_SYSCALL_H_
+#define BSD_USER_ARCH_SYSCALL_H_
+
+struct target_pt_regs {
+    abi_long uregs[17];
+};
+
+#define ARM_cpsr    uregs[16]
+#define ARM_pc      uregs[15]
+#define ARM_lr      uregs[14]
+#define ARM_sp      uregs[13]
+#define ARM_ip      uregs[12]
+#define ARM_fp      uregs[11]
+#define ARM_r10     uregs[10]
+#define ARM_r9      uregs[9]
+#define ARM_r8      uregs[8]
+#define ARM_r7      uregs[7]
+#define ARM_r6      uregs[6]
+#define ARM_r5      uregs[5]
+#define ARM_r4      uregs[4]
+#define ARM_r3      uregs[3]
+#define ARM_r2      uregs[2]
+#define ARM_r1      uregs[1]
+#define ARM_r0      uregs[0]
+
+#define ARM_SYSCALL_BASE    0 /* XXX: FreeBSD only */
+
+#define TARGET_FREEBSD_ARM_SYNC_ICACHE      0
+#define TARGET_FREEBSD_ARM_DRAIN_WRITEBUF   1
+#define TARGET_FREEBSD_ARM_SET_TP       2
+#define TARGET_FREEBSD_ARM_GET_TP       3
+
+#define TARGET_HW_MACHINE       "arm"
+#define TARGET_HW_MACHINE_ARCH  "armv6"
+
+#endif /* !BSD_USER_ARCH_SYSCALL_H_ */
diff --git a/bsd-user/freebsd/os-strace.h b/bsd-user/freebsd/os-strace.h
new file mode 100644
index 0000000000..a222f093b5
--- /dev/null
+++ b/bsd-user/freebsd/os-strace.h
@@ -0,0 +1,29 @@
+/*
+ *  FreeBSD dependent strace print functions
+ *
+ *  Copyright (c) 2013 Stacey D. Son
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "target_arch_sysarch.h"    /* architecture dependent functions */
+
+
+static inline void do_os_print_sysarch(const struct syscallname *name,
+        abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4,
+        abi_long arg5, abi_long arg6)
+{
+    /* This is arch dependent */
+    do_freebsd_arch_print_sysarch(name, arg1, arg2, arg3, arg4, arg5, arg6);
+}
diff --git a/bsd-user/freebsd/strace.list b/bsd-user/freebsd/strace.list
index 2800a2d4eb..d8f2eb66a6 100644
--- a/bsd-user/freebsd/strace.list
+++ b/bsd-user/freebsd/strace.list
@@ -28,6 +28,7 @@
 { TARGET_FREEBSD_NR___acl_set_fd, "__acl_set_fd", "%s(%d, %d, %#x)", NULL, NULL },
 { TARGET_FREEBSD_NR___acl_set_file, "__acl_set_file", "%s(\"%s\", %d, %#x)", NULL, NULL },
 { TARGET_FREEBSD_NR___acl_set_link, "__acl_set_link", "%s(\"%s\", %d, %#x)", NULL, NULL },
+{ TARGET_FREEBSD_NR___getcwd, "__getcwd", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR___semctl, "__semctl", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR___syscall, "__syscall", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR___sysctl, "__sysctl", NULL, print_sysctl, NULL },
@@ -209,7 +210,7 @@
 { TARGET_FREEBSD_NR_statfs, "statfs", "%s(\"%s\",%p)", NULL, NULL },
 { TARGET_FREEBSD_NR_symlink, "symlink", "%s(\"%s\",\"%s\")", NULL, NULL },
 { TARGET_FREEBSD_NR_sync, "sync", NULL, NULL, NULL },
-{ TARGET_FREEBSD_NR_sysarch, "sysarch", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_sysarch, "sysarch", NULL, print_sysarch, NULL },
 { TARGET_FREEBSD_NR_syscall, "syscall", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR_thr_create, "thr_create", "%s(%#x, %#x, %d)", NULL, NULL },
 { TARGET_FREEBSD_NR_thr_exit, "thr_exit", "%s(%#x)", NULL, NULL },
diff --git a/bsd-user/i386/target_arch_sysarch.h b/bsd-user/i386/target_arch_sysarch.h
new file mode 100644
index 0000000000..e9ab98ec32
--- /dev/null
+++ b/bsd-user/i386/target_arch_sysarch.h
@@ -0,0 +1,77 @@
+/*
+ *  i386 sysarch system call emulation
+ *
+ *  Copyright (c) 2013 Stacey D. Son
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef BSD_USER_ARCH_SYSARCH_H_
+#define BSD_USER_ARCH_SYSARCH_H_
+
+#include "target_syscall.h"
+
+static inline abi_long do_freebsd_arch_sysarch(CPUX86State *env, int op,
+        abi_ulong parms)
+{
+    abi_long ret = 0;
+    abi_ulong val;
+    int idx;
+
+    switch (op) {
+    case TARGET_FREEBSD_I386_SET_GSBASE:
+    case TARGET_FREEBSD_I386_SET_FSBASE:
+        if (op == TARGET_FREEBSD_I386_SET_GSBASE) {
+            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;
+
+    case TARGET_FREEBSD_I386_GET_GSBASE:
+    case TARGET_FREEBSD_I386_GET_FSBASE:
+        if (op == TARGET_FREEBSD_I386_GET_GSBASE) {
+            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;
+}
+
+static inline void do_freebsd_arch_print_sysarch(
+        const struct syscallname *name, abi_long arg1, abi_long arg2,
+        abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
+{
+
+    gemu_log("%s(%d, " TARGET_ABI_FMT_lx ", " TARGET_ABI_FMT_lx ", "
+        TARGET_ABI_FMT_lx ")", name->name, (int)arg1, arg2, arg3, arg4);
+}
+
+#endif /* !BSD_USER_ARCH_SYSARCH_H_ */
diff --git a/bsd-user/i386/target_syscall.h b/bsd-user/i386/target_syscall.h
index 8f201386af..940c687a52 100644
--- a/bsd-user/i386/target_syscall.h
+++ b/bsd-user/i386/target_syscall.h
@@ -1,3 +1,20 @@
+/*
+ *  i386 system call definitions
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
 #ifndef TARGET_SYSCALL_H
 #define TARGET_SYSCALL_H
 
@@ -161,5 +178,7 @@ struct target_vm86plus_struct {
 
 
 #define UNAME_MACHINE "i386"
+#define TARGET_HW_MACHINE UNAME_MACHINE
+#define TARGET_HW_MACHINE_ARCH UNAME_MACHINE
 
 #endif /* TARGET_SYSCALL_H */
diff --git a/bsd-user/mips/target_arch_sysarch.h b/bsd-user/mips/target_arch_sysarch.h
new file mode 100644
index 0000000000..6da803a408
--- /dev/null
+++ b/bsd-user/mips/target_arch_sysarch.h
@@ -0,0 +1,69 @@
+/*
+ *  mips sysarch() system call emulation
+ *
+ *  Copyright (c) 2013 Stacey D. Son
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef BSD_USER_ARCH_SYSARCH_H_
+#define BSD_USER_ARCH_SYSARCH_H_
+
+#include "target_syscall.h"
+#include "target_arch.h"
+
+static inline abi_long do_freebsd_arch_sysarch(CPUMIPSState *env, int op,
+        abi_ulong parms)
+{
+    int ret = 0;
+
+    switch (op) {
+    case TARGET_MIPS_SET_TLS:
+        target_cpu_set_tls(env, parms);
+        break;
+
+    case TARGET_MIPS_GET_TLS:
+        if (put_user(target_cpu_get_tls(env), parms, abi_ulong)) {
+            ret = -TARGET_EFAULT;
+        }
+        break;
+
+    default:
+        ret = -TARGET_EINVAL;
+        break;
+    }
+
+    return ret;
+}
+
+static inline void do_freebsd_arch_print_sysarch(
+        const struct syscallname *name, abi_long arg1, abi_long arg2,
+        abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
+{
+
+    switch (arg1) {
+    case TARGET_MIPS_SET_TLS:
+        gemu_log("%s(SET_TLS, 0x" TARGET_ABI_FMT_lx ")", name->name, arg2);
+        break;
+
+    case TARGET_MIPS_GET_TLS:
+        gemu_log("%s(GET_TLS, 0x" TARGET_ABI_FMT_lx ")", name->name, arg2);
+        break;
+
+    default:
+        gemu_log("UNKNOWN OP: %d, " TARGET_ABI_FMT_lx ")", (int)arg1, arg2);
+    }
+}
+
+#endif /*!BSD_USER_ARCH_SYSARCH_H_ */
diff --git a/bsd-user/mips/target_syscall.h b/bsd-user/mips/target_syscall.h
new file mode 100644
index 0000000000..aacc6ddf9f
--- /dev/null
+++ b/bsd-user/mips/target_syscall.h
@@ -0,0 +1,52 @@
+/*
+ *  mips system call definitions
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _MIPS_SYSCALL_H_
+#define _MIPS_SYSCALL_H_
+
+/*
+ * struct target_pt_regs defines the way the registers are stored on the stack
+ * during a system call.
+ */
+
+struct target_pt_regs {
+    /* Saved main processor registers. */
+    abi_ulong regs[32];
+
+    /* Saved special registers. */
+    abi_ulong cp0_status;
+    abi_ulong lo;
+    abi_ulong hi;
+    abi_ulong cp0_badvaddr;
+    abi_ulong cp0_cause;
+    abi_ulong cp0_epc;
+};
+
+#if defined(TARGET_WORDS_BIGENDIAN)
+#define UNAME_MACHINE "mips"
+#else
+#define UNAME_MACHINE "mipsel"
+#endif
+
+#define TARGET_HW_MACHINE       "mips"
+#define TARGET_HW_MACHINE_ARCH   UNAME_MACHINE
+
+/* sysarch() commands */
+#define TARGET_MIPS_SET_TLS     1
+#define TARGET_MIPS_GET_TLS     2
+
+#endif /* !_MIPS_SYSCALL_H_ */
diff --git a/bsd-user/mips64/target_arch_sysarch.h b/bsd-user/mips64/target_arch_sysarch.h
new file mode 100644
index 0000000000..e6f9c00d5f
--- /dev/null
+++ b/bsd-user/mips64/target_arch_sysarch.h
@@ -0,0 +1,69 @@
+/*
+ *  mips64 sysarch() system call emulation
+ *
+ *  Copyright (c) 2013 Stacey D. Son
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef BSD_USER_ARCH_SYSARCH_H_
+#define BSD_USER_ARCH_SYSARCH_H_
+
+#include "target_syscall.h"
+#include "target_arch.h"
+
+static inline abi_long do_freebsd_arch_sysarch(CPUMIPSState *env, int op,
+        abi_ulong parms)
+{
+    int ret = 0;
+
+    switch (op) {
+    case TARGET_MIPS_SET_TLS:
+        target_cpu_set_tls(env, parms);
+        break;
+
+    case TARGET_MIPS_GET_TLS:
+        if (put_user(target_cpu_get_tls(env), parms, abi_ulong)) {
+            ret = -TARGET_EFAULT;
+        }
+        break;
+
+    default:
+        ret = -TARGET_EINVAL;
+        break;
+    }
+
+    return ret;
+}
+
+static inline void do_freebsd_arch_print_sysarch(
+        const struct syscallname *name, abi_long arg1, abi_long arg2,
+        abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
+{
+
+    switch (arg1) {
+    case TARGET_MIPS_SET_TLS:
+        gemu_log("%s(SET_TLS, 0x" TARGET_ABI_FMT_lx ")", name->name, arg2);
+        break;
+
+    case TARGET_MIPS_GET_TLS:
+        gemu_log("%s(GET_TLS, 0x" TARGET_ABI_FMT_lx ")", name->name, arg2);
+        break;
+
+    default:
+        gemu_log("UNKNOWN OP: %d, " TARGET_ABI_FMT_lx ")", (int)arg1, arg2);
+    }
+}
+
+#endif /*!BSD_USER_ARCH_SYSARCH_H_ */
diff --git a/bsd-user/mips64/target_syscall.h b/bsd-user/mips64/target_syscall.h
new file mode 100644
index 0000000000..bf4c598b13
--- /dev/null
+++ b/bsd-user/mips64/target_syscall.h
@@ -0,0 +1,53 @@
+/*
+ *  mips64 system call definitions
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _MIPS64_SYSCALL_H_
+#define _MIPS64_SYSCALL_H_
+
+/*
+ * struct target_pt_regs defines the way the registers are stored on the stack
+ * during a system call.
+ */
+
+struct target_pt_regs {
+    /* Saved main processor registers. */
+    abi_ulong regs[32];
+
+    /* Saved special registers. */
+    abi_ulong cp0_status;
+    abi_ulong lo;
+    abi_ulong hi;
+    abi_ulong cp0_badvaddr;
+    abi_ulong cp0_cause;
+    abi_ulong cp0_epc;
+};
+
+
+#if defined(TARGET_WORDS_BIGENDIAN)
+#define UNAME_MACHINE "mips64"
+#else
+#define UNAME_MACHINE "mips64el"
+#endif
+
+#define TARGET_HW_MACHINE       "mips"
+#define TARGET_HW_MACHINE_ARCH  UNAME_MACHINE
+
+/* sysarch() commands */
+#define TARGET_MIPS_SET_TLS     1
+#define TARGET_MIPS_GET_TLS     2
+
+#endif /* !_MIPS64_SYSCALL_H_ */
diff --git a/bsd-user/netbsd/os-strace.h b/bsd-user/netbsd/os-strace.h
new file mode 100644
index 0000000000..70cf51d63a
--- /dev/null
+++ b/bsd-user/netbsd/os-strace.h
@@ -0,0 +1 @@
+/* XXX NetBSD dependent strace print functions */
diff --git a/bsd-user/openbsd/os-strace.h b/bsd-user/openbsd/os-strace.h
new file mode 100644
index 0000000000..9161390433
--- /dev/null
+++ b/bsd-user/openbsd/os-strace.h
@@ -0,0 +1 @@
+/* XXX OpenBSD dependent strace print functions */
diff --git a/bsd-user/sparc/target_arch_sysarch.h b/bsd-user/sparc/target_arch_sysarch.h
new file mode 100644
index 0000000000..d0b85ef6bb
--- /dev/null
+++ b/bsd-user/sparc/target_arch_sysarch.h
@@ -0,0 +1,52 @@
+/*
+ *  SPARC sysarch() system call emulation
+ *
+ *  Copyright (c) 2013 Stacey D. Son
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef BSD_USER_ARCH_SYSARCH_H_
+#define BSD_USER_ARCH_SYSARCH_H_
+
+#include "target_syscall.h"
+
+static inline abi_long do_freebsd_arch_sysarch(void *env, int op,
+        abi_ulong parms)
+{
+    int ret = 0;
+
+    switch (op) {
+    case TARGET_SPARC_SIGTRAMP_INSTALL:
+        /* XXX not currently handled */
+    case TARGET_SPARC_UTRAP_INSTALL:
+        /* XXX not currently handled */
+    default:
+        ret = -TARGET_EINVAL;
+        break;
+    }
+
+    return ret;
+}
+
+static inline void do_freebsd_arch_print_sysarch(
+        const struct syscallname *name, abi_long arg1, abi_long arg2,
+        abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
+{
+
+    gemu_log("%s(%d, " TARGET_ABI_FMT_lx ", " TARGET_ABI_FMT_lx ", "
+        TARGET_ABI_FMT_lx ")", name->name, (int)arg1, arg2, arg3, arg4);
+}
+
+#endif /*!BSD_USER_ARCH_SYSARCH_H_ */
diff --git a/bsd-user/sparc/target_syscall.h b/bsd-user/sparc/target_syscall.h
index dfdf9f82f5..151284754b 100644
--- a/bsd-user/sparc/target_syscall.h
+++ b/bsd-user/sparc/target_syscall.h
@@ -1,3 +1,20 @@
+/*
+ *  sparc dependent system call definitions
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
 #ifndef TARGET_SYSCALL_H
 #define TARGET_SYSCALL_H
 
@@ -9,6 +26,11 @@ struct target_pt_regs {
 	abi_ulong u_regs[16];
 };
 
-#define UNAME_MACHINE "sun4"
+#define UNAME_MACHINE           "sun4"
+#define TARGET_HW_MACHINE       "sparc"
+#define TARGET_HW_MACHINE_ARCH  "sparc"
+
+#define TARGET_SPARC_UTRAP_INSTALL      1
+#define TARGET_SPARC_SIGTRAMP_INSTALL   2
 
 #endif /* TARGET_SYSCALL_H */
diff --git a/bsd-user/sparc64/target_arch_sysarch.h b/bsd-user/sparc64/target_arch_sysarch.h
new file mode 100644
index 0000000000..e6f17c1504
--- /dev/null
+++ b/bsd-user/sparc64/target_arch_sysarch.h
@@ -0,0 +1,52 @@
+/*
+ *  SPARC64 sysarch() system call emulation
+ *
+ *  Copyright (c) 2013 Stacey D. Son
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef BSD_USER_ARCH_SYSARCH_H_
+#define BSD_USER_ARCH_SYSARCH_H_
+
+#include "target_syscall.h"
+
+static inline abi_long do_freebsd_arch_sysarch(void *env, int op,
+        abi_ulong parms)
+{
+    int ret = 0;
+
+    switch (op) {
+    case TARGET_SPARC_SIGTRAMP_INSTALL:
+        /* XXX not currently handled */
+    case TARGET_SPARC_UTRAP_INSTALL:
+        /* XXX not currently handled */
+    default:
+        ret = -TARGET_EINVAL;
+        break;
+    }
+
+    return ret;
+}
+
+static inline void do_freebsd_arch_print_sysarch(
+        const struct syscallname *name, abi_long arg1, abi_long arg2,
+        abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
+{
+
+    gemu_log("%s(%d, " TARGET_ABI_FMT_lx ", " TARGET_ABI_FMT_lx ", "
+        TARGET_ABI_FMT_lx ")", name->name, (int)arg1, arg2, arg3, arg4);
+}
+
+#endif /*!BSD_USER_ARCH_SYSARCH_H_ */
diff --git a/bsd-user/sparc64/target_syscall.h b/bsd-user/sparc64/target_syscall.h
index 3a9f4c2ef9..b7d986a76d 100644
--- a/bsd-user/sparc64/target_syscall.h
+++ b/bsd-user/sparc64/target_syscall.h
@@ -1,3 +1,20 @@
+/*
+ *  sparc64 dependent system call definitions
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
 #ifndef TARGET_SYSCALL_H
 #define TARGET_SYSCALL_H
 
@@ -10,6 +27,11 @@ struct target_pt_regs {
 	abi_ulong fprs;
 };
 
-#define UNAME_MACHINE "sun4u"
+#define UNAME_MACHINE           "sun4u"
+#define TARGET_HW_MACHINE       "sparc"
+#define TARGET_HW_MACHINE_ARCH  "sparc64"
+
+#define TARGET_SPARC_UTRAP_INSTALL      1
+#define TARGET_SPARC_SIGTRAMP_INSTALL   2
 
 #endif /* TARGET_SYSCALL_H */
diff --git a/bsd-user/strace.c b/bsd-user/strace.c
index fa66fe1ee2..2c3b59caf0 100644
--- a/bsd-user/strace.c
+++ b/bsd-user/strace.c
@@ -20,9 +20,12 @@
 #include <sys/select.h>
 #include <sys/syscall.h>
 #include <sys/ioccom.h>
+#include <ctype.h>
 
 #include "qemu.h"
 
+#include "os-strace.h"  /* OS dependent strace print functions */
+
 int do_strace;
 
 /*
@@ -104,6 +107,14 @@ static void print_ioctl(const struct syscallname *name,
             arg3);
 }
 
+static void print_sysarch(const struct syscallname *name, abi_long arg1,
+        abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5,
+        abi_long arg6)
+{
+    /* This is os dependent. */
+    do_os_print_sysarch(name, arg1, arg2, arg3, arg4, arg5, arg6);
+}
+
 /*
  * Variants for the return value output function
  */
diff --git a/bsd-user/x86_64/target_arch_sysarch.h b/bsd-user/x86_64/target_arch_sysarch.h
new file mode 100644
index 0000000000..5c36fc0752
--- /dev/null
+++ b/bsd-user/x86_64/target_arch_sysarch.h
@@ -0,0 +1,76 @@
+/*
+ *  x86_64 sysarch() syscall emulation
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef BSD_USER_ARCH_SYSARCH_H_
+#define BSD_USER_ARCH_SYSARCH_H_
+
+#include "target_syscall.h"
+
+static inline abi_long do_freebsd_arch_sysarch(CPUX86State *env, int op,
+        abi_ulong parms)
+{
+    abi_long ret = 0;
+    abi_ulong val;
+    int idx;
+
+    switch (op) {
+    case TARGET_FREEBSD_AMD64_SET_GSBASE:
+    case TARGET_FREEBSD_AMD64_SET_FSBASE:
+        if (op == TARGET_FREEBSD_AMD64_SET_GSBASE) {
+            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;
+
+    case TARGET_FREEBSD_AMD64_GET_GSBASE:
+    case TARGET_FREEBSD_AMD64_GET_FSBASE:
+        if (op == TARGET_FREEBSD_AMD64_GET_GSBASE) {
+            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;
+}
+
+static inline void do_freebsd_arch_print_sysarch(
+        const struct syscallname *name, abi_long arg1, abi_long arg2,
+        abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
+{
+
+    gemu_log("%s(%d, " TARGET_ABI_FMT_lx ", " TARGET_ABI_FMT_lx ", "
+        TARGET_ABI_FMT_lx ")", name->name, (int)arg1, arg2, arg3, arg4);
+}
+
+#endif /*! BSD_USER_ARCH_SYSARCH_H_ */
diff --git a/bsd-user/x86_64/target_syscall.h b/bsd-user/x86_64/target_syscall.h
index a5d779884f..a8e6274b76 100644
--- a/bsd-user/x86_64/target_syscall.h
+++ b/bsd-user/x86_64/target_syscall.h
@@ -1,3 +1,20 @@
+/*
+ *  x86_64 system call definitions
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
 #ifndef TARGET_SYSCALL_H
 #define TARGET_SYSCALL_H
 
@@ -111,7 +128,9 @@ struct target_msqid64_ds {
 #define TARGET_FREEBSD_AMD64_SET_GSBASE	131
 
 
-#define UNAME_MACHINE "x86_64"
+#define UNAME_MACHINE           "x86_64"
+#define TARGET_HW_MACHINE       "amd64"
+#define TARGET_HW_MACHINE_ARCH  "amd64"
 
 #define TARGET_ARCH_SET_GS 0x1001
 #define TARGET_ARCH_SET_FS 0x1002
diff --git a/meson.build b/meson.build
index 372576f82c..55a73a0895 100644
--- a/meson.build
+++ b/meson.build
@@ -1800,6 +1800,7 @@ foreach target : target_dirs
       target_inc += include_directories('linux-user/host/' / config_host['ARCH'])
     else
       base_dir = 'bsd-user'
+      target_inc += include_directories('bsd-user/freebsd')
     endif
     target_inc += include_directories(
       base_dir,
-- 
2.22.1



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

end of thread, other threads:[~2021-01-05  2:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-18 20:54 [PATCH 0/4] A few preliminary bsd-user patches imp
2020-12-18 20:54 ` [PATCH 1/4] bsd-user: regenerate FreeBSD's system call numbers imp
2020-12-18 20:54 ` [PATCH 2/4] tcg: Additional Trap type for FreeBSD imp
2020-12-18 23:12   ` Warner Losh
2020-12-18 20:54 ` [PATCH 3/4] bsd-user: move strace OS/arch dependent code to host/arch dirs imp
2020-12-18 20:54 ` [PATCH 4/4] bsd-user: Update strace.list for FreeBSD's latest syscalls imp
2021-01-05  2:27 ` [PATCH 0/4] A few preliminary bsd-user patches Warner Losh
  -- strict thread matches above, loose matches on Subject: below --
2020-12-18 20:52 imp
2020-12-18 20:52 ` [PATCH 3/4] bsd-user: move strace OS/arch dependent code to host/arch dirs imp

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.