History log of /freebsd-current/sys/compat/linux/linux_misc.h
Revision Date Author Comments
# 6d849754 28-May-2024 Son Phan Trung <phantrungson17@gmail.com>

linux: implement PR_CHILD_SET_SUBREAPER

Reviewed by: imp, dchagin
Pull Request: https://github.com/freebsd/freebsd-src/pull/1260


# 95ee2897 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/


# bbe017e0 04-Aug-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Add a dedicated ioprio system calls

On Linux these system calls have an effect only when used in conjuction
with an I/O scheduler that supports I/O priorities. If no I/O scheduler
has been set for a thread, then by defaut the I/O priority will follow
the CPU nice value. Due to FreeBSD lack of I/O scheduler facilities, the
default Linux behavior is implemented.

Ubuntu 23.04 debootstrap requires Linux ionice which depends on these
syscalls.

Differential Revision: https://reviews.freebsd.org/D41153
MFC after: 1 month


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# e2028292 14-Feb-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Cleanup sys/sysctl.h from linux_misc.h

Leftover after c5156c77 (r374538).

MFC after: 2 weeks


# 390c9ea0 15-May-2022 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Add AT_MINSIGSTKSZ to arm64 port

MFC after: 2 weeks


# b7df7b98 31-Mar-2022 Dmitry Chagin <dchagin@FreeBSD.org>

linprocfs: Add /proc/self/oom_score_adj.

To avoid annoyng messages from LTP test suites add the simple
implementation of /proc/self/oom_score_adj which is do nothing.

Reviewed by: emaste
Differential revision: https://reviews.freebsd.org/D34710
MFC after: 2 weeks


# be1e4a0b 31-Mar-2022 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Return ENOSYS for unsupported P_PIDFD waitid idtype.

Reviewed by: emaste
Differential revision: https://reviews.freebsd.org/D31559
MFC after: 2 weeks


# 99454d3e 28-Jan-2022 Edward Tomasz Napierala <trasz@FreeBSD.org>

linux: Provide dummy seccomp(2)

Don't emit messages; this isn't any different from a Linux kernel
built without OPTIONS_SECCOMP, so the userspace already needs to know
how to deal with it. This is also similar with how we handle seccomp
in linux_prctl().

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D33808


# 9caeb82e 20-Jan-2022 Edward Tomasz Napierala <trasz@FreeBSD.org>

Revert "linux: Provide dummy seccomp(2)"

This reverts commit 56981629f91fcdd358ccb41081ff6dcc2edac12f.

Wrong patch; fails to build on i386.


# 56981629 25-Jan-2022 Edward Tomasz Napierala <trasz@FreeBSD.org>

linux: Provide dummy seccomp(2)

Don't emit warnings; this isn't any different from a Linux kernel
built without OPTIONS_SECCOMP, so the userspace already needs to know
how to deal with it. This is also similar with how we handle seccomp
in linux_prctl().

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D33808


# 0bf8d5d5 09-Nov-2021 Edward Tomasz Napierala <trasz@FreeBSD.org>

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


# a90ff3c4 07-Nov-2021 Edward Tomasz Napierala <trasz@FreeBSD.org>

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


# 17913b0b 12-Aug-2021 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Implement clone3 system call.

clone3 system call is used by glibc-2.34.

Differential revision: https://reviews.freebsd.org/D31475
MFC after: 2 weeks


# 0a4b664a 12-Aug-2021 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Add struct clone_args for future clone3 system call.

In preparation for clone3 system call add struct clone_args and use it in
clone implementation.
Move all of clone related bits to the newly created linux_fork.h header.

Differential revision: https://reviews.freebsd.org/D31474
MFC after: 2 weeks


# c1da89fe 21-Jun-2021 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Retire linux_kplatform.

Assuming we can't run on i486, i586 class cpu, retire linux_kplatform var
and use hardcoded 'machine' value in linux_newuname().

I have added linux_kplatform for consistency with linux_platform which is
placed in to vdso to avoid excess copyout it on stack for AT_PLATFORM at
exec time.

This is the first stage of Linuxulator's vdso revision.

Reviewed by: trasz, imp
Differential Revision: https://reviews.freebsd.org/D30774
MFC after: 2 weeks


# ca6e1fa3 12-Apr-2021 Edward Tomasz Napierala <trasz@FreeBSD.org>

linux: adjust ordering of Linux auxv and add dummy AT_HWCAP2

This should be a no-op; the purpose of this is to reduce
a spurious difference between Linuxulator and Linux, to make
debugging core dumps slightly easier.

Note that AT_HWCAP2 we pass to Linux binaries is always 0,
instead of being equal to 'cpu_feature2'. This matches what
I've observed under Ubuntu Focal VM.

Reviewed By: chuck, dchagin
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D29609


# 3b57ddb0 18-Mar-2021 John Baldwin <jhb@FreeBSD.org>

Rename linux_set_upcall_kse() to linux_set_upcall().

This matches the rename of cpu_set_upcall_kse() in
5c2cf818454375536fda522ba83cf67c50929e6b.

Reviewed by: kib, emaste
MFC after: 1 week
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D29295


# ec2700e0 12-Jan-2021 Edward Tomasz Napierala <trasz@FreeBSD.org>

linux: mute the "unsupported prctl option 23" warnings

Make the PR_CAPBSET_READ prctl(2) return EINVAL without logging
any warnings; this is way too noisy with Focal.

Sponsored by: The FreeBSD Foundation


# eaa5afce 02-Nov-2020 Conrad Meyer <cem@FreeBSD.org>

linux(4) prctl(2): Implement PR_[GS]ET_DUMPABLE

Proxy the flag to the roughly analogous FreeBSD procctl 'TRACE'.

TRACE-disabled processes are not coredumped, and Linux !DUMPABLE processes
can not be ptraced. There are some additional semantics around ownership of
files in the /proc/[pid] pseudo-filesystem, which we do not attempt to
emulate correctly at this time.

Reviewed by: markj (earlier version)
Differential Revision: https://reviews.freebsd.org/D27015


# 76dfd556 30-Oct-2020 Conrad Meyer <cem@FreeBSD.org>

linux(4): Add missing clone(2) flags


# 62b1382f 24-Oct-2020 Edward Tomasz Napierala <trasz@FreeBSD.org>

Further improve prctl(2) debug.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D26916


# 1c748137 22-Oct-2020 Edward Tomasz Napierala <trasz@FreeBSD.org>

Improve prctl(2) debug.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D26899


# 139c0978 16-Oct-2020 Edward Tomasz Napierala <trasz@FreeBSD.org>

Make linux getrlimit(2) and prlimit(2) return something reasonable
for linux-specific limits. Fixes prlimit (util-linux-2.31.1-0.4ubuntu3.7).

Reviewed by: emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D26777


# 1a180032 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

compat: clean up empty lines in .c and .h files


# f8b9b299 01-Mar-2020 Tijl Coosemans <tijl@FreeBSD.org>

linuxulator: Map scheduler priorities to Linux priorities.

On Linux the valid range of priorities for the SCHED_FIFO and SCHED_RR
scheduling policies is [1,99]. For SCHED_OTHER the single valid priority is
0. On FreeBSD it is [0,31] for all policies. Programs are supposed to
query the valid range using sched_get_priority_(min|max), but of course some
programs assume the Linux values are valid.

This commit adds a tunable compat.linux.map_sched_prio. When enabled
sched_get_priority_(min|max) return the Linux values and sched_setscheduler
and sched_(get|set)param translate between FreeBSD and Linux values.

Because there are more Linux levels than FreeBSD levels, multiple Linux
levels map to a single FreeBSD level, which means pre-emption might not
happen as it does on Linux, so the tunable allows to disable this behaviour.
It is enabled by default because I think it is unlikely that anyone runs
real-time software under Linux emulation on FreeBSD that critically relies
on correct pre-emption.

This fixes FMOD, a commercial sound library used by several games.

PR: 240043
Tested by: Alex S <iwtcex@gmail.com>
Reviewed by: dchagin
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D23790


# ee0fe82e 29-Dec-2019 Edward Tomasz Napierala <trasz@FreeBSD.org>

Implement Linux syslog(2) syscall; just enough to make Linux dmesg(8)
utility work.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D22465


# d49fb289 18-May-2019 Edward Tomasz Napierala <trasz@FreeBSD.org>

Implement PTRACE_O_TRACESYSGOOD. This makes Linux strace(1) work.

Reviewed by: dchagin
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20200


# c5156c77 13-May-2019 Dmitry Chagin <dchagin@FreeBSD.org>

Linuxulator depends on a fundamental kernel settings such as SMP. Many
of them listed in opt_global.h which is not generated while building
modules outside of a kernel and such modules never match real cofigured
kernel.

So, we should prevent our users from building obviously defective modules.

Therefore, remove the root cause of the building of modules outside of a
kernel - the possibility of building modules with DEBUG or KTR flags.
And remove all of DEBUG printfs as it is incomplete and in threaded
programms not informative, also a half of system call does not have DEBUG
printf. For debuging Linux programms we have dtrace, ktr and ktrace ability.

PR: 222861
Reviewed by: trasz
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20178


# b1ed95fd 23-Mar-2018 Ed Maste <emaste@FreeBSD.org>

Rationalize license text on Linuxolator files

Many licenses on Linuxolator files contained small variations from the
standard FreeBSD license text. To avoid license proliferation switch to
the standard 2-Clause FreeBSD license for those files where I have
permission from each of the listed copyright holders.

Approved by: rdivacky, marcel
MFC after: 1 week
Sponsored by: The FreeBSD Foundation


# 7f2d13d6 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys/compat: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.


# b1ba0846 18-Mar-2017 Dmitry Chagin <dchagin@FreeBSD.org>

Implement getrandom() syscall.
Note. GRND_RANDOM option is not supported for now.

MFC after: 1 month


# c1f156d4 23-Feb-2017 Dmitry Chagin <dchagin@FreeBSD.org>

Right clock defines specified in linux_timer.h.
Get rid of spirious clock defines from linux_misc.h.

MFC after: 1 week


# 5743aa47 10-Apr-2016 Dmitry Chagin <dchagin@FreeBSD.org>

More complete implementation of /proc/self/limits.
Fix the way the code accesses process limits struct - pointed out by mjg@.

PR: 207386
Reviewed by: no objection form des@
MFC after: 3 weeks


# 19d8b461 24-May-2015 Dmitry Chagin <dchagin@FreeBSD.org>

Add utimensat() system call.

The patch developed by Jilles Tjoelker and Andrew Wilcox and
adopted for lemul branch by me.


# 3e89b641 24-May-2015 Dmitry Chagin <dchagin@FreeBSD.org>

Put the correct value for the abi_nfdbits parameter of kern_select() for
all supported Linuxulators.

Differential Revision: https://reviews.freebsd.org/D1093
Reviewed by: trasz


# 4048f59c 24-May-2015 Dmitry Chagin <dchagin@FreeBSD.org>

Add AT_RANDOM and AT_EXECFN auxiliary vector entries which are used by
glibc. At list since glibc version 2.16 using AT_RANDOM is mandatory.

Differential Revision: https://reviews.freebsd.org/D1080


# 67d39748 24-May-2015 Dmitry Chagin <dchagin@FreeBSD.org>

Introduce a new module linux_common.ko which is intended for the
following primary purposes:

1. Remove the dependency of linsysfs and linprocfs modules from linux.ko,
which will be architecture specific on amd64.

2. Incorporate into linux_common.ko general code for platforms on which
we'll support two Linuxulator modules (for both instruction set - 32 & 64 bit).

3. Move malloc(9) declaration to linux_common.ko, to enable getting memory
usage statistics properly.

Currently linux_common.ko incorporates a code from linux_mib.c and linux_util.c
and linprocfs, linsysfs and linux kernel modules depend on linux_common.ko.

Temporarily remove dtrace garbage from linux_mib.c and linux_util.c

Differential Revision: https://reviews.freebsd.org/D1072
In collaboration with: Vassilis Laganakos.

Reviewed by: trasz


# 0020bdf1 24-May-2015 Dmitry Chagin <dchagin@FreeBSD.org>

Put linux_platform into the vdso to avoid copying it onto the stack at
every exec.

Differential Revision: https://reviews.freebsd.org/D1062
Reviewed by: trasz


# bdc37934 24-May-2015 Dmitry Chagin <dchagin@FreeBSD.org>

Implement vdso - virtual dynamic shared object. Through vdso Linux
exposes functions from kernel with proper DWARF CFI information so that
it becomes easier to unwind through them.
Using vdso is a mandatory for a thread cancelation && cleanup
on a modern glibc.

Differential Revision: https://reviews.freebsd.org/D1060


# c3978c7b 24-May-2015 Dmitry Chagin <dchagin@FreeBSD.org>

Implement prlimit64() system call.

Differential Revision: https://reviews.freebsd.org/D1050
Reviewed by: emaste, trasz


# e5fe4ccf 24-May-2015 Dmitry Chagin <dchagin@FreeBSD.org>

Implement waitid() system call.

Differential Revision: https://reviews.freebsd.org/D1046


# a7ae3c55 24-May-2015 Dmitry Chagin <dchagin@FreeBSD.org>

Add a function for converting wait options.

Differential Revision: https://reviews.freebsd.org/D1045
Reviewed by: trasz


# 86bda7a0 24-May-2015 Dmitry Chagin <dchagin@FreeBSD.org>

Remove a now unused define.

Differential Revision: https://reviews.freebsd.org/D1043
Reviewed by: trasz


# 81338031 24-May-2015 Dmitry Chagin <dchagin@FreeBSD.org>

Switch linuxulator to use the native 1:1 threads.

The reasons:
1. Get rid of the stubs/quirks with process dethreading,
process reparent when the process group leader exits and close
to this problems on wait(), waitpid(), etc.
2. Reuse our kernel code instead of writing excessive thread
managment routines in Linuxulator.

Implementation details:

1. The thread is created via kern_thr_new() in the clone() call with
the CLONE_THREAD parameter. Thus, everything else is a process.
2. The test that the process has a threads is done via P_HADTHREADS
bit p_flag of struct proc.
3. Per thread emulator state data structure is now located in the
struct thread and freed in the thread_dtor() hook.
Mandatory holdig of the p_mtx required when referencing emuldata
from the other threads.
4. PID mangling has changed. Now Linux pid is the native tid
and Linux tgid is the native pid, with the exception of the first
thread in the process where tid and pid are one and the same.

Ugliness:

In case when the Linux thread is the initial thread in the thread
group thread id is equal to the process id. Glibc depends on this
magic (assert in pthread_getattr_np.c). So for system calls that
take thread id as a parameter we should use the special method
to reference struct thread.

Differential Revision: https://reviews.freebsd.org/D1039


# 6289b482 21-Apr-2015 Edward Tomasz Napierala <trasz@FreeBSD.org>

Modify kern___getcwd() to take max pathlen limit as an additional
argument. This will be used for the Linux emulation layer - for Linux,
PATH_MAX is 4096 and not 1024.

Differential Revision: https://reviews.freebsd.org/D2335
Reviewed by: kib@
MFC after: 1 month
Sponsored by: The FreeBSD Foundation


# d825ce0a 29-Jan-2013 John Baldwin <jhb@FreeBSD.org>

Reduce duplication between i386/linux/linux.h and amd64/linux32/linux.h
by moving bits that are MI out into headers in compat/linux.

Reviewed by: Chagin Dmitry dmitry | gmail
MFC after: 2 weeks


# 605da56b 26-Mar-2011 Andriy Gapon <avg@FreeBSD.org>

linux compat: improve and fix sendmsg/recvmsg compatibility

- implement baseic stubs for capget, capset, prctl PR_GET_KEEPCAPS
and prctl PR_SET_KEEPCAPS.
- add SCM_CREDS support to sendmsg and recvmsg
- modify sendmsg to ignore control messages if not using UNIX
domain sockets

This should allow linux pulse audio daemon and client work on FreeBSD
and interoperate with native counter-parts modulo the differences in
pulseaudio versions.

PR: kern/149168
Submitted by: John Wehle <john@feith.com>
Reviewed by: netchild
MFC after: 2 weeks


# adc7ece0 28-Jan-2011 Dmitry Chagin <dchagin@FreeBSD.org>

Implement a variation of the linux_common_wait() which should
be used by linuxolator itself.

Move linux_wait4() to MD path as it requires native struct
rusage translation to struct l_rusage on linux32/amd64.

MFC after: 1 Month.


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 1ca16454 10-May-2009 Dmitry Chagin <dchagin@FreeBSD.org>

Rework r189362, r191883.
The frequency of the statistics clock is given by stathz.
Use stathz if it is available, otherwise use hz.

Pointed out by: bde

Approved by: kib (mentor)


# 2ee8325f 05-Mar-2009 John Baldwin <jhb@FreeBSD.org>

A better fix for handling different FPU initial control words for different
ABIs:
- Store the FPU initial control word in the pcb for each thread.
- When first using the FPU, load the initial control word after restoring
the clean state if it is not the standard control word.
- Provide a correct control word for Linux/i386 binaries under
FreeBSD/amd64.
- Adjust the control word returned for fpugetregs()/npxgetregs() when a
thread hasn't used the FPU yet to reflect the real initial control
word for the current ABI.
- The Linux/i386 ABI for FreeBSD/i386 now properly sets the right control
word instead of trashing whatever the current state of the FPU is.

Reviewed by: bde


# 4d7c2e8a 03-Mar-2009 Dmitry Chagin <dchagin@FreeBSD.org>

Add AT_PLATFORM, AT_HWCAP and AT_CLKTCK auxiliary vector entries which
are used by glibc. This silents the message "2.4+ kernel w/o ELF notes?"
from some programs at start, among them are top and pkill.

Do the assignment of the vector entries in elf_linux_fixup()
as it is done in glibc.

Fix some minor style issues.

Submitted by: Marcin Cieslak <saper at SYSTEM PL>
Approved by: kib (mentor)
MFC after: 1 week


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# cbd2c621 22-Feb-2008 Konstantin Belousov <kib@FreeBSD.org>

Sanitize arguments to linux_mremap().
Check that only MREMAP_FIXED and MREMAP_MAYMOVE flags are specified.
Check for the page alignment of the addr argument.

Submitted by: rdivacky
MFC after: 1 week


# ef95cfea 31-Dec-2006 Alexander Leidinger <netchild@FreeBSD.org>

MFp4:
- semi-automatic style fixes
- spelling fixes in comments
- add some comments


# 955d762a 28-Oct-2006 Alexander Leidinger <netchild@FreeBSD.org>

MFP4:
Implement prctl().

Submitted by: rdivacky
Tested with: LTP