Commit Graph

21107 Commits

Author SHA1 Message Date
Stefan Eßer
a67cc94327 Apply fix for ld80 and ld128 submitted by Steve Kargl:
- Micro-optimization: use sincosl(x) instead of a call to cosl(x) and
  a call to sinl(x).  Argument reduction is done once not twice.

- Use a long double constant instead of an invalid double constant.

- Spell scale2 correctly

He could not test ld128, so that patch is untested.

Submitted by:	sgk at troutmask.apl.washington.edu (Steve Kargl)
2020-09-20 05:28:31 +00:00
Kirk McKusick
85ee267a3e Update the libufs cgget() and cgput() interfaces to have a similar
API to the sbget() and sbput() interfaces. Specifically they take
a file descriptor pointer rather than the struct uufsd *disk pointer
used by the libufs cgread() and cgwrite() interfaces. Update fsck_ffs
to use these revised interfaces.

No functional changes intended.

Sponsored by: Netflix
2020-09-19 22:48:30 +00:00
Alan Somers
9ad1d357e0 fix integer underflow in getgrnam_r and getpwnam_r
Sometimes nscd(8) will return a 1-byte buffer for a nonexistent entry. This
triggered an integer underflow in grp_unmarshal_func, causing getgrnam_r to
return ERANGE instead of 0.

Fix the user's buffer size check, and add a correct check for a too-small
nscd buffer.

PR:		248932
Event:		September 2020 Bugathon
Reviewed by:	markj
MFC after:	2 weeks
Sponsored by:	Axcient
Differential Revision: https://reviews.freebsd.org/D26204
2020-09-19 19:08:27 +00:00
Kyle Evans
fe815331bb build: provide a default WARNS for all in-tree builds
The current default is provided in various Makefile.inc in some top-level
directories and covers a good portion of the tree, but doesn't cover parts
of the build a little deeper (e.g. libcasper).

Provide a default in src.sys.mk and set WARNS to it in bsd.sys.mk if that
variable is defined. This lets us relatively cleanly provide a default WARNS
no matter where you're building in the src tree without breaking things
outside of the tree.

Crunchgen has been updated as a bootstrap tool to work on this change
because it needs r365605 at a minimum to succeed. The cleanup necessary to
successfully walk over this change on WITHOUT_CLEAN builds has been added.

There is a supplemental project to this to list all of the warnings that are
encountered when the environment has WARNS=6 NO_WERROR=yes:
https://warns.kevans.dev -- this project will hopefully eventually go away
in favor of CI doing a much better job than it.

Reviewed by:	emaste, brooks, ngie (all earlier version)
Reviewed by:	emaste, arichardson (depend-cleanup.sh change)
Differential Revision:	https://reviews.freebsd.org/D26455
2020-09-18 17:17:46 +00:00
Alex Richardson
c5ef56ea61 Remove unnecessary include "../Makefile.inc"
This is already pulled in by bsd.init.mk.

Reported By:	kevans
2020-09-18 14:05:31 +00:00
Mark Johnston
3d1098617b Fix error checking in shm_create_largepage().
Reviewed by:	alc, kib
Reported by:	Coverity
MFC with:	r365524
Differential Revision:	https://reviews.freebsd.org/D26464
2020-09-18 12:30:15 +00:00
Alex Richardson
72f97a2d09 libarchive: fix mismatch between library and test configuration
I was investigating libarchive test failures on CheriBSD and it turns out
we get a reproducible SIGBUS for test_archive_m5, etc. Debugging this shows
that libarchive and the tests disagree when it comes to the definition of
archive_md5_ctx: libarchive assumes it's the OpenSSL type whereas the test
use the libmd type. The latter is not necessarily aligned enough to store
a pointer (16 bytes for CHERI RISC-V), so we were crashing when storing
EVP_MD_CTX* to an 8-byte-aligned archive_md5_ctx.

To avoid problems like this in the future, factor out the common compiler
flags into a Makefile.inc and include that from the tests Makefile.

Reviewed By:	lwhsu
Differential Revision: https://reviews.freebsd.org/D26469
2020-09-18 11:22:34 +00:00
Eric van Gyzen
acde2586c9 Fix additional memory leak in process_mapfile
Additional Coverity detected memory leak fix.

Submitted by:	bret_ketchum@dell.com
Reported by:	Coverity
Reviewed by:	cem, emaste
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D26462
2020-09-17 18:24:51 +00:00
Dimitry Andric
16d6b3b3da Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
release/11.x llvmorg-11.0.0-rc2-91-g6e042866c30.

MFC after:	6 weeks
X-MFC-With:	r364284
2020-09-16 16:58:29 +00:00
Andrew Turner
2a6803de1c Use MACHINE_CPUARCH when checking for arm64
Use MACHINE_CPUARCH with arm64 (aarch64) when we build code that could run
on any 64-bit Arm instruction set. This will simplify checks in downstream
consumers targeting prototype instruction sets.

The only place we check for MACHINE_ARCH == aarch64 is when building the
device tree blobs. As these are targeting current generation ISAs.

Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D26370
2020-09-14 16:12:28 +00:00
Edward Tomasz Napierala
2ccf8a827c Skip armv7 bectl tests on CI; they deadlock (""KSTACK_PAGES is 2").
PR:		249229
Sponsored by:	DARPA
2020-09-14 10:35:39 +00:00
Kyle Evans
ecebb3cc1d Only set WARNS if not defined
This would allow interested parties to do experimental runs with an
environment set appropriately to raise all the warnings throughout the
build; e.g. env WARNS=6 NO_WERROR=yes buildworld.

Not currently touching the numerous instances in ^/tools.

MFC after:	1 week
2020-09-11 13:28:37 +00:00
Kyle Evans
8b8cf4ece6 memfd_create: simplify HUGETLB support a little bit
This also fixes a minor issue that was missed in the initial review; the
layout of the MFD_HUGE_* flags is actually not 1:1 bit:flag -- it instead
borrowed the Linux convention of how this is laid out since it was
originally implemented on Linux, the top 6 bits represent the shift required
for the requested page size.

This allows us to remove the flag <-> pgsize mapping table and simplify the
logic just prior to validation of the requested page size.

While we're here, fix two small nits:

- HUGETLB memfd shouldn't exhibit the SHM_GROW_ON_WRITE behavior. We can
  only grow largepage shm by appropriately aligned (i.e. requested pagesize)
  sizes, so it can't work in the typical/sane fashion. Furthermore, Linux
  does the same, so let's be compatible.

- We don't allow MFD_HUGETLB without specifying a pagesize, so no need to
  check for that later.

Reviewed by:	kib (slightly earlier version)
2020-09-11 02:02:15 +00:00
Kyle Evans
9bf2b80ca6 memfd_create: fix return values
Literally returning EINVAL from a function designed to return an fd makes
for interesting scenarios.

I cannot assign enough pointy hats to cover this one.
2020-09-10 21:25:16 +00:00
Kyle Evans
944174e7bf Fix memfd_create tests after r365524
r365524 did accidentally invert this check that sets SHM_LARGEPAGE, leading
non-hugetlb memfd as unconfigured largepage shm and thus test failures when
we try to ftruncate or write to them.

PR:		249236
Discussed with:	kib
2020-09-10 17:23:30 +00:00
Dimitry Andric
18ed63b8f1 Follow-up r364753 by only using arm's stdatomic.c implementation, as it
already covers the functions in compiler-rt's atomic.c, leading to
conflicts when linking.

PR:		230888
MFC after:	3 days
X-MFC-With:	r364753
2020-09-10 16:47:12 +00:00
Alex Richardson
e17ebfd3b7 Remove -I flag for include path that doesn't exist
Found this while trying to get macOS bootstrap to work again after OpenZFS merge.

Reviewed By:	#zfs, freqlabs
Differential Revision: https://reviews.freebsd.org/D26192
2020-09-10 15:37:07 +00:00
Konstantin Belousov
3ef55e8f25 Add shm_create_largepage(3) helper for creation and configuration of
largepage shm objects.

And since we can, add memfd_create(MFD_HUGETLB) support, hopefully
close enough to the Linux feature.

Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D24652
2020-09-09 22:20:36 +00:00
Konstantin Belousov
1352798db3 Fix compilation of libsysdecode after r365522, should have been part of it.
Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D24652
2020-09-09 22:18:44 +00:00
Dimitry Andric
c90cb43503 Follow-up r364753 by enabling compiler-rt's atomic implementation only
for clang, as it uses clang specific builtins, and does not compile
correctly with gcc. Note that gcc packages usually come with their own
libatomic, providing these primitives.

PR:		230888
MFC after:	3 days
X-MFC-With:	r364753
2020-09-09 20:48:57 +00:00
Kyle Evans
69112cca60 getlogin_r: fix the type of len
getlogin_r is specified by POSIX to to take a size_t len, not int. Fix our
version to do the same, bump the symbol version due to ABI change and
provide compat.

This was reported to break compilation of Ruby 2.8.

Some discussion about the necessity of the ABI compat did take place in the
review. While many 64-bit platforms would likely be passing it in a 64-bit
register and zero-extended and thus, not notice ABI breakage, some do
sign-extend (e.g. mips).

PR:		247102
Submitted by:	Bertram Scharpf <software@bertram-scharpf.de> (original)
Submitted by:	cem (ABI compat)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D26335
2020-09-09 18:07:13 +00:00
Kyle Evans
0e907c045b libc tests: dynthr_mod: fix some WARNS issues
This is being addressed as part of a side-patch I'm working on that builds
all the things with WARNS=6, instead of relying on it being supplied in just
shallow parts of the build with higher-level Makefile.inc.

Provide a prototype for mod_main and annotate the thread function argument
as unused.

MFC after:	1 week
2020-09-09 02:45:47 +00:00
Kyle Evans
5593499d4a libc/resolv: attempt to fix the test under WARNS=6
In a side-change that I'm working on to start defaulting src builds to
WARNS=6 where WARNS isn't otherwise specified, GCC6 (and clang, to a lesser
extent) pointed out a number of issues with the resolv tests:

- Global method variable that gets shadowed in run_tests()
- Signed/unsigned comparison between i in run_tests() and hosts->sl_cur

The shadowed variable looks like it might actually be bogus as written, as
we pass it to RUN_TESTS -> run_tests, but other parts use the global method
instead. This change is mainly geared towards correcting that by removing
the global and plumbing the method through from run_tests -> run into the
new thread.

For the signed/unsigned comparison, there's no compelling reason to not just
switch i/nthreads/nhosts to size_t.

The review also included a change to the load() function that was better
addressed by jhb in r365302.

Reviewed by:	ngie, pstef
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D24844
2020-09-09 02:42:21 +00:00
Brandon Bergren
328b5f2570 [PowerPC] Implement VDSO timebase access on powerpc*
Implement the remaining pieces needed to allow userland timestamp reading.

Rewritten based on an intial essay into the problem by Justin Hibbits.
(Copyright changed to my own on his request.)

Tested on ppc64 (POWER9 Talos II), powerpcspe (e500v2 RB800), and
powerpc (g4 PowerBook).

Reviewed by:	jhibbits (in irc)
Sponsored by:	Tag1 Consulting, Inc.
Differential Revision:	https://reviews.freebsd.org/D26347
2020-09-08 03:00:31 +00:00
Dimitry Andric
86b019c29a Follow-up r365371 by removing sentences which indicate the state of the
MK_MALLOC_PRODUCTION option on -CURRENT.

Also, for the sake of backwards compatibility, support the old way of
enabling 'production malloc', e.g. by adding a define in make.conf(5).

MFC after:	1 week
X-MFC-With:	r365371
2020-09-06 09:08:06 +00:00
Dimitry Andric
7d4374f65f Turn MALLOC_PRODUCTION into a regular src.conf(5) option
For historical reasons, defining MALLOC_PRODUCTION in /etc/make.conf has
been used to turn off potentially expensive debug checks and statistics
gathering in the implementation of malloc(3).

It seems more consistent to turn this into a regular src.conf(5) option,
e.g. WITH_MALLOC_PRODUCTION / WITHOUT_MALLOC_PRODUCTION. This can then
be toggled similar to any other source build option, and turned on or
off by default for e.g. stable branches.

Reviewed by:	imp, #manpages
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D26337
2020-09-05 23:30:17 +00:00
Matt Macy
eac7052fde ZFS: MFV 2.0-rc1-gfd20a8
- fixes jail delegation
- fixes raw kstat unsupported complaints
- exposes dbgmsg, dbuf, and checksum benchmark stats
- restore rename -u support
2020-09-04 22:25:14 +00:00
Matt Macy
adfd5c1bd9 Another missed move 2020-09-04 21:55:35 +00:00
Matt Macy
431004027d Update vendor openzfs to fd20a8 2020-09-04 21:31:58 +00:00
Dimitry Andric
a2a9ef4beb Add a few more files to libllvm, which are required when doing sanitized
builds, for example with -fsanitize=undefined.

MFC after:	6 weeks
X-MFC-With:	r364284
2020-09-03 18:27:13 +00:00
John Baldwin
2afeaad315 Various fixes to the load() function.
- Use getline() instead of fgetln().  This ensures the returned string
  is always null-terminated without losing the last character if the
  last line in a file doesn't have a newline.  Also, while fgetln says
  the returned buffer can be modified, that doesn't actually seem safe
  as the current implementation means you are modifying stdio's
  internal buffer.

- Remove a spurious if before an ATF_REQUIRE that was clearly supposed
  to be non-optional.

- Remove a pointless compare of 'ptr' against '\0' (really NULL) that
  duplicated the middle condition in the for().

- Once a comment is found, skip the rest of the line, not just the
  current word.

Reviewed by:	kevans
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D26278
2020-09-03 14:50:15 +00:00
Stephen J. Kiernan
2d012dff57 Avoid issues with STAGING by using LIBUCL_DIR for the source directory
variable name instead of LIBUCL (which would otherwise end up with the
staging directory used instead of the wanted source directory.)

Reviewed by:	sjg
Obtained from:	Juniper Networks, Inc.
2020-09-03 03:48:42 +00:00
John Baldwin
4d135bbd7f libifconfig now depends on libm due to usage of log10().
ld.bfd in particular requires -lm to come after libifconfig on the
command line when linking rescue.

Reviewed by:	freqlabs, adrian
Differential Revision:	https://reviews.freebsd.org/D26258
2020-09-02 22:10:08 +00:00
John Baldwin
875e04d716 Pass a valid mode with O_CREATE to open(2).
CheriABI is pickier about the arguments to open(2) and crashes with a
fault if a mode isn't passed to an open() when O_CREATE is specified.

Reported by:	CHERI
Reviewed by:	brooks
Obtained from:	CheriBSD
MFC after:	2 weeks
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D26281
2020-09-02 21:17:54 +00:00
John Baldwin
97bdc65f27 Don't assume objects in program sections have a size of a pointer.
The size of the object at 'addr' is unknown and might be smaller than
the size of a pointer (e.g. some x86 instructions are smaller than a
pointer).  Instead, just check that the address is in the bounds of
the program header.

Reported by:	CHERI (indirectly)
Reviewed by:	kib, brooks
Obtained from:	CheriBSD
MFC after:	1 week
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D26279
2020-09-02 20:43:08 +00:00
John Baldwin
1a4531bc98 Compute the correct size of the string to move forward.
Previously this was counting the amount of spare room at the start of
the buffer that the string needed to move forward and passing that as
the number of bytes to copy to memmove rather than the length of the
string to be copied.

In the strfmon test in the test suite this caused the memmove to
overflow the allocated buffer by one byte which CHERI caught.

Reported by:	CHERI
Reviewed by:	kevans
Obtained from:	CheriBSD
MFC after:	1 week
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D26280
2020-09-02 20:04:26 +00:00
Li-Wen Hsu
0932ee9fa0 Temporarily skip tests panic i386 kernel in CI
lib.libbe.be_create.libbe_create
sbin.bectl.bectl_test.bectl_create

PR:		249055
Sponsored by:	The FreeBSD Foundation
2020-09-02 19:18:27 +00:00
Mark Johnston
847ab36bf2 Include the psind in data returned by mincore(2).
Currently we use a single bit to indicate whether the virtual page is
part of a superpage.  To support a forthcoming implementation of
non-transparent 1GB superpages, it is useful to provide more detailed
information about large page sizes.

The change converts MINCORE_SUPER into a mask for MINCORE_PSIND(psind)
values, indicating a mapping of size psind, where psind is an index into
the pagesizes array returned by getpagesizes(3), which in turn comes
from the hw.pagesizes sysctl.  MINCORE_PSIND(1) is equal to the old
value of MINCORE_SUPER.

For now, two bits are used to record the page size, permitting values
of MAXPAGESIZES up to 4.

Reviewed by:	alc, kib
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D26238
2020-09-02 18:16:43 +00:00
John Baldwin
ff38047b0c Fix a buffer overrun.
getln() returns 'len' valid characters.  line[len] is out of bounds.

Reported by:	CHERI
Reviewed by:	brooks
Obtained from:	CheriBSD
MFC after:	2 weeks
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D26197
2020-09-01 16:20:42 +00:00
Vincenzo Maffione
4c067f3842 lib: libnetmap: add missing copyright headers
MFC after:	2 weeks
2020-09-01 06:06:32 +00:00
John Baldwin
d10af81d2d Fix the build of scandir_b with GCC.
Use explicit typedefs for block thunk structures as in r264143.

Reviewed by:	kib, adrian
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D26256
2020-08-31 21:55:25 +00:00
Eric van Gyzen
4644463cac libpmc: Fix memory leak in process_mapfile
Coverity detected memory leak fix.

Submitted by:	bret_ketchum@dell.com
Reported by:	Coverity
Reviewed by:	cem
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D26230
2020-08-31 16:07:40 +00:00
Vincenzo Maffione
5c4f8d801c lib: add libnetmap
This changeset introduces the new libnetmap library for writing
netmap applications.
Before libnetmap, applications could either use the kernel API
directly (e.g. NIOCREGIF/NIOCCTRL) or the simple header-only-library
netmap_user.h (e.g. nm_open(), nm_close(), nm_mmap() etc.)

The new library offers more functionalities than netmap_user.h:
  - Support for complex netmap options, such as external memory
    allocators or per-buffer offsets. This opens the way to future
    extensions.
  - More flexibility in the netmap port bind options, such as
    non-numeric names for pipes, or the ability to specify the netmap
    allocator that must be used for a given port.
  - Automatic tracking of the netmap memory regions in use across the
    open ports.

At the moment there is no man page, but the libnetmap.h header file
has in-depth documentation.

Reviewed by:	hrs
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D26171
2020-08-28 20:03:54 +00:00
Eric van Gyzen
a2e194654f memstat_kvm_uma: fix reading of uma_zone_domain structures
Coverity flagged the scaling by sizeof(uzd).  That is the type
of the pointer, so the scaling was already done by pointer arithmetic.
However, this was also passing a stack frame pointer to kvm_read,
so it was doubly wrong.

Move ZDOM_GET into the !_KERNEL section and use it in libmemstat.

Reported by:	Coverity
Reviewed by:	markj
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D26213
2020-08-28 19:50:40 +00:00
Matt Macy
93ddd0259d update vendor openzfs to a00c61 (2.0-rc1) 2020-08-28 18:41:28 +00:00
Alex Richardson
18de62a94a Move libsqlite3 to the top of the SUBDIR list
In parallel builds, this should allow sqlite to start building earlier and
increase parallelism when building lib/. Looking at htop output during
buildworld/tinderbox, there are long phases where only one CPU is active
optimizing the massive sqlite3.c file since the build of libsqlite3 is
started quite late.

Reviewed By:	emaste
Differential Revision: https://reviews.freebsd.org/D26169
2020-08-26 09:19:49 +00:00
Dimitry Andric
cc0b883028 After r364423, which ensures the callbacks that dl_iterate_phdr(3)
performs are protected by an exclusive lock, even for statically linked
programs, it is safe to re-enable libunwind's FrameHeaderCache, which I
temporarily disabled in r364263.

Meanwhile upstream has also used the _LIBUNWIND_USE_FRAME_HEADER_CACHE
for this purpose, so the only thing needed is to add this as a
compile-time command line flag.

While here, reformat the CFLAGS lines a little bit.

MFC after:	6 weeks
X-MFC-With:	r364284, r364423
2020-08-25 20:07:11 +00:00
Dimitry Andric
0709bb1f41 After r364753, there should be no need to suppress -Watomic-alignment
warnings anymore for compiler-rt's atomic.c. This occurred because the
IS_LOCK_FREE_8 macro was not correctly defined to 0 for mips, and this
caused the compiler to emit a runtime call to __atomic_is_lock_free(),
and that triggers the warning.

MFC after:	2 weeks
X-MFC-With:	r364753
2020-08-25 19:57:11 +00:00
Kyle Evans
5e6a7bc6c1 libbe: lift the WARNS post-OpenZFS merge
sys/ccompile.h no longer uses #pragma ident, so we no longer need to worry
about unknown pragmas.

I fixed one WARNS issue in r363409 by annotating be_is_auto_snapshot_name's
lbh parameter __unused, then upstreamed the following changes to OpenZFS
that rode in with the merge:
- zfs_path_to_zhandle now takes a const char *path rather than a char *path,
  since it won't be mutating the string it receives and I had no reason to
  believe it will need to in the future. [OpenZFS PR #10605]
- Annotated some unused parameters on definitions inlined into headers as
  such. [OpenZFS PR #10606]
2020-08-25 18:16:40 +00:00
Alex Richardson
0c54932d50 Fix -Wundef warnings when building liblua
We need to define the LUA_FLOAT_INT64 macro even if we don't use it (copied
from stand/luaconf.h). While touching luaconf.h.dist also sync it with the
the 5.3.5 release version (matches the one in lib/liblua).

Reviewed By:	kevans
Differential Revision: https://reviews.freebsd.org/D25977
2020-08-25 13:30:34 +00:00