History log of /freebsd-current/sys/amd64/amd64/bpf_jit_machdep.c
Revision Date Author Comments
# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 82c174a3 30-Oct-2020 Mateusz Guzik <mjg@FreeBSD.org>

malloc: delegate M_EXEC handling to dedicacted routines

It is almost never needed and adds an avoidable branch.

While here do minior clean ups in preparation for larger changes.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D27019


# 0766f278 13-Jun-2018 Jonathan T. Looney <jtl@FreeBSD.org>

Make UMA and malloc(9) return non-executable memory in most cases.

Most kernel memory that is allocated after boot does not need to be
executable. There are a few exceptions. For example, kernel modules
do need executable memory, but they don't use UMA or malloc(9). The
BPF JIT compiler also needs executable memory and did use malloc(9)
until r317072.

(Note that a side effect of r316767 was that the "small allocation"
path in UMA on amd64 already returned non-executable memory. This
meant that some calls to malloc(9) or the UMA zone(9) allocator could
return executable memory, while others could return non-executable
memory. This change makes the behavior consistent.)

This change makes malloc(9) return non-executable memory unless the new
M_EXEC flag is specified. After this change, the UMA zone(9) allocator
will always return non-executable memory, and a KASSERT will catch
attempts to use the M_EXEC flag to allocate executable memory using
uma_zalloc() or its variants.

Allocations that do need executable memory have various choices. They
may use the M_EXEC flag to malloc(9), or they may use a different VM
interfact to obtain executable pages.

Now that malloc(9) again allows executable allocations, this change also
reverts most of r317072.

PR: 228927
Reviewed by: alc, kib, markj, jhb (previous version)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D15691


# ac2fffa4 21-Jan-2018 Pedro F. Giffuni <pfg@FreeBSD.org>

Revert r327828, r327949, r327953, r328016-r328026, r328041:
Uses of mallocarray(9).

The use of mallocarray(9) has rocketed the required swap to build FreeBSD.
This is likely caused by the allocation size attributes which put extra pressure
on the compiler.

Given that most of these checks are superfluous we have to choose better
where to use mallocarray(9). We still have more uses of mallocarray(9) but
hopefully this is enough to bring swap usage to a reasonable level.

Reported by: wosch
PR: 225197


# 74641f0b 15-Jan-2018 Pedro F. Giffuni <pfg@FreeBSD.org>

x86: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

X-Differential revision: https://reviews.freebsd.org/D13837


# 51369649 20-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 3-Clause license.

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.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.


# af197328 17-Apr-2017 Jung-uk Kim <jkim@FreeBSD.org>

Use kmem_malloc() instead of malloc(9) for the native amd64 filter.

r316767 broke the BPF JIT compiler for amd64 because malloc()'d space is no
longer executable.

Discussed with: kib, alc


# e329e330 17-Apr-2017 Jung-uk Kim <jkim@FreeBSD.org>

Move declarations for a machine-dependent function to the header file.


# 69d410ee 21-Oct-2016 Jung-uk Kim <jkim@FreeBSD.org>

Implement BPF_MOD and BPF_XOR instructions.

These two ALU instructions first appeared on Linux. Then, libpcap adopted
and made them available since 1.6.2. Now more platforms including NetBSD
have them in kernel. So do we.
--이 줄 이하는 자동으로 제거됩니다--


# 730b3be3 21-Oct-2016 Jung-uk Kim <jkim@FreeBSD.org>

Redude code for conditional jumps.


# 99e3ae68 21-Oct-2016 Jung-uk Kim <jkim@FreeBSD.org>

Fix compiler warnings for user land.


# eedc7fd9 26-Oct-2013 Gleb Smirnoff <glebius@FreeBSD.org>

Provide includes that are needed in these files, and before were read
in implicitly via if.h -> if_var.h pollution.

Sponsored by: Netflix
Sponsored by: Nginx, Inc.


# 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.


# b8341230 22-Apr-2010 Jung-uk Kim <jkim@FreeBSD.org>

If a conditional jump instruction has the same jt and jf, do not perform
the test and jump unconditionally.


# 26b8a1c9 23-Nov-2009 Jung-uk Kim <jkim@FreeBSD.org>

- Add more aggressive BPF JIT optimization. This is in more favor of i386
while the previous commit was more amd64-centric.
- Use calloc(3) instead of malloc(3)/memset(3) in user land[1].

Submitted by: ed[1]


# 35012a1e 20-Nov-2009 Jung-uk Kim <jkim@FreeBSD.org>

Add an experimental and rudimentary JIT optimizer to reduce unncessary
overhead from short BPF filter programs such as "get the first 96 bytes".


# c12b965f 20-Nov-2009 Jung-uk Kim <jkim@FreeBSD.org>

General style cleanup, no functional change.


# 5ecf7736 20-Nov-2009 Jung-uk Kim <jkim@FreeBSD.org>

- Allocate scratch memory on stack instead of pre-allocating it with
the filter as we do from bpf_filter()[1].
- Revert experimental use of contigmalloc(9)/contigfree(9). It has no
performance benefit over malloc(9)/free(9)[2].

Requested by: rwatson[1]
Pointed out by: rwatson, jhb, alc[2]


# 986689c2 19-Nov-2009 Jung-uk Kim <jkim@FreeBSD.org>

Fix tinderbox build for i386 and sync amd64 with it.


# ae4fdab8 18-Nov-2009 Jung-uk Kim <jkim@FreeBSD.org>

- Change internal function bpf_jit_compile() to return allocated size of
the generated binary and remove page size limitation for userland.
- Use contigmalloc(9)/contigfree(9) instead of malloc(9)/free(9) to make
sure the generated binary aligns properly and make it physically contiguous.


# 366652f9 18-Nov-2009 Jung-uk Kim <jkim@FreeBSD.org>

- Make BPF JIT compiler working again in userland. We are limiting size of
generated native binary to page size for now.
- Update copyright date and fix some style nits.


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

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


# a2b12e3b 26-Aug-2008 Jung-uk Kim <jkim@FreeBSD.org>

Move empty filter handling to MI source.

MFC after: 3 days


# f471e569 25-Aug-2008 Jung-uk Kim <jkim@FreeBSD.org>

Fix a typo in copyrights.


# 69e08c86 18-Aug-2008 Jung-uk Kim <jkim@FreeBSD.org>

Correctly check unsignedness of all BPF_LD|BPF_IND instructions.
This is roughly from sys/net/bpf_filter.c r1.12 and r1.14.


# 3bfea868 18-Aug-2008 Jung-uk Kim <jkim@FreeBSD.org>

- Make these files compilable on user land.
- Update copyrights and fix style(9).


# 8c4d5bbc 13-Aug-2008 Jung-uk Kim <jkim@FreeBSD.org>

Use int32_t/int16_t instead of int/short as sys/net/bpf_filter.c does.


# f40611e2 13-Aug-2008 Jung-uk Kim <jkim@FreeBSD.org>

- Remove unnecessary jump instruction(s) when offset(s) is/are zero(s).
- Constantly use conditional jumps for unsigned integers.


# 095130bf 12-Aug-2008 Jung-uk Kim <jkim@FreeBSD.org>

Update copyrights and fix style(9).


# 059485d0 12-Aug-2008 Jung-uk Kim <jkim@FreeBSD.org>

Replace all stack usages with registers and remove unused macros.


# b86977a5 24-Jun-2008 Jung-uk Kim <jkim@FreeBSD.org>

Emit opcodes closer to GNU as(1) generated codes and micro-optimize.


# 292f013c 23-Jun-2008 Jung-uk Kim <jkim@FreeBSD.org>

Rehash and clean up BPF JIT compiler macros to match AT&T notations.


# dccb7faf 03-Jan-2006 Jung-uk Kim <jkim@FreeBSD.org>

- Explicitly validate an empty filter to match bpf_filter() comment[1].
- Do not use BPF JIT compiler for an empty filter.

[1] Pointed out by: darrenr


# 6a96c483 06-Dec-2005 Jung-uk Kim <jkim@FreeBSD.org>

s/M_WAITOK/M_NOWAIT/ while mutex is held.

Pointed out by: csjp


# 23a8fc28 05-Dec-2005 Jung-uk Kim <jkim@FreeBSD.org>

- Micro-optimize `mov $0, %edx' -> `xor %edx, %edx'.
- Correct amd64 macro style (no functional change).


# ae275efc 05-Dec-2005 Jung-uk Kim <jkim@FreeBSD.org>

Add experimental BPF Just-In-Time compiler for amd64 and i386.

Use the following kernel configuration option to enable:

options BPF_JITTER

If you want to use bpf_filter() instead (e. g., debugging), do:

sysctl net.bpf.jitter.enable=0

to turn it off.

Currently BIOCSETWF and bpf_mtap2() are unsupported, and bpf_mtap() is
partially supported because 1) no need, 2) avoid expensive m_copydata(9).

Obtained from: WinPcap 3.1 (for i386)