64007b00 brooks Nov. 22, 2021, 10:36 p.m.
On 32-bit architectures, 64-bit arguments are passed in pairs of
registers. On non-x86 architectures these arguments must be in evenly
aligned registers which necessiciates inserting a pad register into the
argument list. This has historically been supported by adding ifdefs
around padded and unpadded syscall defintions in syscalls.master.

In order to enable generation of 32-bit support files from the base
syscalls.master, pull this support in to makesyscalls.lua enabled by
adding pair_64bit to abi_flags.

The changes to sys_proto.h simply add #ifdef PAD64_REQUIRED
around pad arguments in struct <syscall>_args. In systrace_args(),
replace static syscall index values with post-incremented indexs
allowing a simple ifdef around the argument. Under -O1 or higher
code generation is identical. systrace_entry_setargdesc() is a bit
more complicated as we switch on argument indices.  Solve this
with some use of define/undef pairs to compute the correct indices.

Reviewed by:	kevans
cgit
79634eb9 brooks Nov. 22, 2021, 10:36 p.m.
When the config variable abi_intptr_t is not "", transform arrays of
pointers to arrays of abi_intptr_t.

Reviewed by:	kevans
cgit
0a4e1644 brooks Nov. 22, 2021, 10:36 p.m.
Replace long-derived types with their abi equivalent where
required by the target ABI. There are two cases:
 - All pointers to types that go from 64-bit to 32-bit between the
   default ABI and the target ABI.
 - Signed arguments that go from 64-bit to 32-bit (these require
   sign-extension before passing to general kernel ABIs).

This adds four new config variables: abi_long, semid_t, abi_size_t,
and abi_u_long which default to long, size_t, and u_long respectively.

Reviewed by:	kevans
cgit
b85fb390 brooks Nov. 22, 2021, 10:36 p.m.
Translate instances of intptr_t to the config value abi_intptr_t
(defaults to "intptr_t").  Used in CheriABI to translate intptr_t
to intcap_t for hybrid kernels.

Reviewed by:	kevans
cgit
f0cfbffc brooks Nov. 22, 2021, 10:36 p.m.
37b425bd brooks Nov. 22, 2021, 10:36 p.m.
Match intptr_t arguments as pointers.  Currently this is a no-op
change to systrace_args.c.

Reviewed by:	kevans
cgit
3f8f46a0 brooks Nov. 22, 2021, 10:36 p.m.
When the string %%ABI_HEADERS%% is found in syscalls.master, replace
it with the contents of the abi_headers config variable.  This allows
an ABI-specific syscalls.conf to add lines like:

	#include <compat/freebsd32/freebsd32.h>

when working from a shared syscalls.master.

Reviewed by:	kevans
cgit
ed8a4423 brooks Nov. 22, 2021, 10:36 p.m.
Limitations in lua patterns means we need to be able to match more
than one possible expression.

Reviewed by:	kevans
cgit
818aa954 brooks Nov. 22, 2021, 10:36 p.m.
Reviewed by:	kevans
cgit
5203efea brooks Nov. 22, 2021, 10:36 p.m.
This supported a hack we used in CheriBSD which has been removed.

Reviewed by:	kevans
cgit
97fdcfca brooks Nov. 22, 2021, 10:36 p.m.
Reviewed by:	kib
cgit
bcd07aaa brooks Nov. 22, 2021, 10:36 p.m.
6eefabd4 brooks Nov. 22, 2021, 10:36 p.m.
Optionally return errors when truncating dev_t, ino_t, and nlink_t.
In the interest of code reuse, use freebsd11_cvtstat() to perform the
truncation and error handling and then convert the resulting struct
freebsd11_stat to struct nstat.

Add missing freebsd32 compat syscalls. These syscalls require
translation because struct nstat contains four instances of struct
timespec which in turn contains a time_t and a long.

Reviewed by:	kib
cgit
8460d3e9 brooks Nov. 22, 2021, 10:36 p.m.
151ddfec brooks Nov. 22, 2021, 10:36 p.m.
This aligns with the default ABI's configuration.

Reviewed by:	kib
cgit