Commit Graph

4000 Commits

Author SHA1 Message Date
Brooks Davis
aef154d3f2 freebsd32: use __socklen_t consistently
Reviewed by:	kevans
2021-11-17 20:12:26 +00:00
Brooks Davis
738ec2ed66 freebsd32: tag RESERVED syscalls
This reduces diffs when generating freebsd32 files from the default
ABI's syscalls.master.

Reviewed by:	kevans
2021-11-17 20:12:26 +00:00
Brooks Davis
a016320dfb freebsd32: rename 32-bit compat pads to _pad
Some 32-bit architectures pass 64-bit values in aligned
register pairs (a0,a1), (a2,a3) etc.  In freebsd32 we add these pads
explicitly from compat code.  We also sometimes add pads in the default
ABI.  Differentiate the two by making the freebsd32 ones int _pad.
In a future commit the 32-bit ones will be automatically generated.

Reviewed by:	kevans
2021-11-17 20:12:26 +00:00
Brooks Davis
158dcd7395 freebsd32: have sigqueue take a void *
This matches the default ABI and we work around issues with
union sigval by extracting the bottom 32-bits in a manual handler.

Reviewed by:	kevans
2021-11-17 20:12:26 +00:00
Brooks Davis
2b9d052d3e freebsd32: fix getfsstat sign extension bugs
Add freebsd32 versions of getfsstat and freebsd11_getfsstat so that
bufsize is properly sign-extended if a negative value is passed.
Reject negative values before passing to kern_getfsstat as a size_t.

Reviewed by:	kevans
2021-11-17 20:12:26 +00:00
Brooks Davis
f19e3fd206 freebsd32: signed long corrections
Syscalls that take signed longs need to treat the 32-bit versions as
signed int so that sign extension happens correctly.  Improve
decleration quality and add a few minimal syscall implementations.

Reviewed by:	kevans
2021-11-17 20:12:26 +00:00
Brooks Davis
d257e57d18 freebsd32: add missing pads to preadv and pwritev
Reviewed by:	kevans
2021-11-17 20:12:25 +00:00
Brooks Davis
f089a2f3d1 freebsd32: add stubs for ofreebsd32_(send|recv)msg
The upcoming change to generate freebsd32 generated files from
sys/kern/syscalls.master doesn't have a way to handle disabling
this one without disabling the non-COMPAT counterpart so just add
a stub for now.

Reviewed by:	kevans
2021-11-17 20:12:25 +00:00
Brooks Davis
e02f64d9b8 freebsd32: add real abort2
Previously, the code would copy twice as many pointers as specified
and print pairs of them a single 64-bit pointer.

abort2 doesn't return so make the return type void

freebsd32_abort2 is in it's own file with a 2-clause BSD license
based on a discussion with Wojciech many years ago.

Reviewed by:	kevans
2021-11-17 20:12:25 +00:00
Brooks Davis
e3e811a3f8 freebsd32: add feed foward clock syscalls
These are required when supporting i386 because time_t is 32-bit which
reduces struct bintime to 12-bytes when combined with the fact that 64-bit
integers only requiring 32-bit alignment on i386.  Reusing the default
ABI version resulted in 4-byte overreads or overwrites to userspace.

Reviewed by:	kevans
2021-11-17 20:12:25 +00:00
Brooks Davis
7bd795650f freebsd32: enable trivial syscalls
These syscalls require no translation.  They were simply missing
from compat/freebsd32/syscalls.master.

Reviewed by:	kevans
2021-11-17 20:12:25 +00:00
Brooks Davis
91301e6ea5 freebsd32: don't implement kldsym
Previously we fell back to sys_kldsym, but because we'd always
mismatch on the version field we'd return EINVAL.  A freebsd32
implementation is impossible with the current ABI as there simply
isn't space to store a kernel virtual address in a uint32_t.

Reviewed by:	kevans
2021-11-17 20:12:25 +00:00
Brooks Davis
25fec55b86 freebsd32: remove freebsd11_freebsd32_getdents
It's exactly the same as freebsd11_getdents.

Reviewed by:	kevans
2021-11-17 20:12:25 +00:00
Brooks Davis
1de34945f4 freebsd32: remove redundent osig*() implementations
ofreebsd32_sigprocmask, ofreebsd32_sigblock, ofreebsd32_sigsetmask,
and ofreebsd32_sigsuspend were all duplicates of the default ABI
versions and there are no type concerns as all arguments are the
same.

Reviewed by:	kevans
2021-11-17 20:12:25 +00:00
Brooks Davis
dbb47e9264 freebsd32: remove freebsd32_recvfrom
The freebsd32_recvfrom() serves no purpose as no arguments require
translation.  The prototype was mis-declared and the implementation
contained (relatively harmless) errors.

Reviewed by:	kevans
2021-11-17 20:12:24 +00:00
Brooks Davis
ad58266704 freebsd32: remove redundant no-arg syscalls
pipe requires no special handling.

ofreebsd32_sigpending did differ from osigpending in that it acted
on the siglist rather than the sigqueue, but this appears to be an
oversight in 3fbdb3c215.

ogetpagesize could theoretically have ABI-dependent results, but in
practice does not. If it does it would be easy handle in the central
implementation and be the least of the problems in changing the value of
PAGE_SIZE.

Reviewed by:	kevans
2021-11-17 20:12:24 +00:00
Brooks Davis
5b5a48c787 freebsd32: simplify memrange translation
Assume we've been passed a valid argument and use _IOC_NEWTYPE to
translate the command as we do elsewhere.

Reviewed by:	kevans
2021-11-17 20:12:24 +00:00
Brooks Davis
ab3ccb7583 freebsd32: rename fstat() stat buffer argument
Reviewed by:	kevans
2021-11-17 20:12:24 +00:00
Brooks Davis
b35c2bca9f freebsd32: rename struct wrusage32 to struct __wrusage32
This matches struct __wrusage

Reviewed by:	kevans
2021-11-17 20:12:24 +00:00
Brooks Davis
0ebea13928 freebsd32: include __ in semctl names
This mirrors sys/kern/syscall.master and will simplify generation
of freebsd32 files.

Reviewed by:	kevans
2021-11-17 20:12:24 +00:00
Brooks Davis
d35a771660 freebsd32: sync _umtx_op args with default ABI
Reviewed by:	kevans
2021-11-17 20:12:24 +00:00
Brooks Davis
f1a1411089 freebsd32: rename fstat argument to match default abi
Reviewed by:	kevans
2021-11-17 20:12:24 +00:00
Brooks Davis
3b0cd7e503 freebsd32: rename old SysV IPC types
Move the 32 from ...32_old to ..._old32 to aid automatic generation.

Reviewed by:	kevans
2021-11-17 20:12:23 +00:00
Brooks Davis
5d0d686940 freebsd32: struct kld32_file_stat -> struct kld_file_stat32
Follow common convention and put the `32` on the end of the struct
name.  This is a step toward generating freebsd32 syscall files
from sys/kern/syscalls.master.

Reviewed by:	kevans
2021-11-17 20:12:23 +00:00
Brooks Davis
e5b0997650 freebsd32: add a union semun_old32
Use this for COMPAT7 support.  In practice it's the same as
union semun32 since the pointers become uint32_t's the it's more
symetric and is the logical thing to generate from semun_old.

Reviewed by:	kevans
2021-11-17 20:12:23 +00:00
Brooks Davis
6dcd7db176 freebsd32: fix type size of pointer array args
Make pointers to arrays of pointers `uint32_t *` so the sizes of the
array elements are correct.  In an ideal world we'd use something
like __ptr32 annotations instead.

Reviewed by:	kevans
2021-11-17 20:12:23 +00:00
Brooks Davis
465b80c04a freebsd32: thread IDs are int32_t
Thread IDs are of type long which means int32_t on 32-bit systems.
While this detail is handled without compat functions, expose it
here as code to generate prototypes from the default syscalls.master
will do so.

Reviewed by:	kevans
2021-11-17 20:12:23 +00:00
Brooks Davis
2e89f95d6a freebsd32: fix types on statfs syscalls
Rename struct statfs32 to struct ostatfs32 to mirror struct ostatfs.
These structs are use for COMPAT4 support.  Stop using struct statfs32
for modern implementations as struct statfs uses fixed-width types
and it the same on all architectures.

Reviewed by:	kevans
2021-11-17 20:12:23 +00:00
Brooks Davis
381f6804ec freebsd32: fix type of olstat arg
Reviewed by:	kevans
2021-11-17 20:12:23 +00:00
Brooks Davis
9946c920a4 freebsd32: wait6 and procctl take idtype_t
Reviewed by:	kevans
2021-11-17 20:12:23 +00:00
Brooks Davis
ddae7b9aaa freebsd32: use size_t where the default ABI does
While the caller will never pass a larger value, we can use size_t
due to it being unsigned.

Reviewed by:	kevans
2021-11-17 20:12:23 +00:00
Brooks Davis
70c9698f40 freebsd32: match ioctl type to default ABI
The command is a u_long and unsigned integers do not require special
handling. The data argument isn't a special structure, just use char *.

Reviewed by:	kevans
2021-11-17 20:12:22 +00:00
Brooks Davis
8ba369ed74 freebsd32: [gs]etitimer's which arg is an int
Reviewed by:	kevans
2021-11-17 20:12:22 +00:00
Brooks Davis
a944d28d0e freebsd32: sprinkle in missing consts
A number of syscalls have missing consts on their arguments relative to
the default syscalls.master.

Also, use timespec32 and timeval32 where appropriate.

No functional change.

Reviewed by:	kevans
2021-11-17 20:12:22 +00:00
Brooks Davis
43227e4c83 freebsd32: prototype gssd_syscall()
Nothing about the interface should prevent this from working so
go ahead and prototype it for consistency.

Reviewed by:	kevans
2021-11-17 20:12:22 +00:00
Brooks Davis
6de7c05379 freebsd32: name the ucontext struct __ucontext32
This matches the default ABI's struct __ucontext.

Reviewed by:	kevans
2021-11-17 20:12:22 +00:00
Brooks Davis
5fdbd21d08 freebsd32: rename freebsd4_freebsd32_sigreturn arg
Rename struct freebsd4_freebsd32_ucontext to struct freebsd4_ucontext32
allowing conversion from the default ABI's struct freebsd4_ucontext
by appending "32".  This has no practical effect as this type does not
actually exist.

Give freebsd4_freebsd32_sigreturn an ANSI C prototype.

Reviewed by:	kevans
2021-11-17 20:12:22 +00:00
Brooks Davis
85d1d2a675 syscalls: use struct siginfo rather than siginfo_t
This allows freebsd32 to use struct siginfo32 with an automatable
conversion.

Reviewed by:	kevans
2021-11-17 20:12:22 +00:00
Brooks Davis
9df4e7e2e9 syscalls: regen 2021-11-15 18:34:28 +00:00
Brooks Davis
01ce7fca44 ommap: fix signed len and pos arguments
4.3 BSD's mmap took an int len and long pos.  Reject negative lengths
and in freebsd32 sign-extend pos correctly rather than mis-handling
negative positions as large positive ones.

Reviewed by:	kib
2021-11-15 18:34:28 +00:00
Brooks Davis
3f8ced5bce syscalls: regen 2021-11-15 18:34:27 +00:00
Brooks Davis
8e4a3add99 struct kevent_freebsd11 -> struct freebsd11_kevent
Rename to match the naming of syscalls and allow 32 to be appended
without making an ugly name like kevent_freebsd1132.

While here, make the kevent changelist argument const.

Reviewed by:	kib
2021-11-15 18:34:27 +00:00
Mark Johnston
1fb99e97e9 bus: Make BUS_TRANSLATE_RESOURCE behave more like other bus methods
- Return an errno value upon failure, instead of 1.
- Provide a bus_translate_resource() wrapper.
- Implement the generic version, which traverses the hierarchy until a
  bus driver with a non-trivial implementation is found, in subr_bus.c
  like other similar default implementations.
- Make ofw_pcib_translate_resource() return an error if a matching PCI
  address range is not found.
- Make generic_pcie_translate_resource_common() return an int instead of
  a bool.  Fix up callers.

No functional change intended.

Reviewed by:	imp, jhb
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32855
2021-11-15 13:01:30 -05:00
Edward Tomasz Napierala
06d5ef0aad linux: Drop some unnecessary includes
Drop some unnecessary includes from Linuxulator ptrace
and coredump code.  No functional changes.

Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D32925
2021-11-13 03:26:32 +00:00
Konstantin Belousov
439c3d9563 Regen 2021-11-10 21:18:54 +02:00
Konstantin Belousov
77b2c2f814 Add sched_getcpu()
for compatibility with Linux.

Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D32901
2021-11-10 21:18:54 +02:00
Edward Tomasz Napierala
0bf8d5d5f4 linux: Replace ifdefs in ptrace with per-architecture callbacks
It's a cleanup; no (intended) functional changes.

Sponsored By:	EPSRC
Reviewed By:	kib
Differential Revision:	https://reviews.freebsd.org/D32888
2021-11-09 11:59:17 +00:00
Edward Tomasz Napierala
a90ff3c4bc linux: Add ptrace(2) support on arm64
This moves linux_ptrace.c from sys/amd64/linux/ to sys/compat/linux/,
making it possible to use it on architectures other than amd64.
It also enables Linux ptrace(2) on arm64.

Relnotes:	yes
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D32868
2021-11-07 08:39:24 +00:00
Edward Tomasz Napierala
91be6286e2 linprocfs: Fix formatting of Uid and Gid lines
The separator here should be tabs, not spaces.  This fixes a warning
from chromium-browser on Bionic:

[1022/162248.137612:ERROR:process_info_linux.cc(107)] format error: unrecognized Uid format

Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D32612
2021-11-03 08:40:55 +00:00
Hans Petter Selasky
2390a1441e LinuxKPI: Add sysctl(8) knob to control verbosity of WARN_ON's.
The purpose of this change is to reduce the amount of dmesg(8) noise when
VT switching after a panic.

Submitted by:	Greg V <greg@unrelenting.technology>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D30174
Sponsored by:	NVIDIA Networking
2021-11-02 16:53:34 +01:00