Commit Graph

242945 Commits

Author SHA1 Message Date
Ian Lepore
d4828bcfc7 Add support for setting the aging/frequency-offset register via sysctl.
The 2127 and 2129 chips support a frequency tuning value in the range of
-7 through +8 PPM; add a sysctl handler to read and set the value.
2019-07-21 17:14:39 +00:00
Alan Cox
f606d835de With the introduction of software dirty bit emulation for managed mappings,
we should test ATTR_SW_DBM, not ATTR_AP_RW, to determine whether to set
PGA_WRITEABLE.  In effect, we are currently setting PGA_WRITEABLE based on
whether the dirty bit is preset, not whether the mapping is writeable.
Correct this mistake.

Reviewed by:	markj
X-MFC with:	r350004
Differential Revision:	https://reviews.freebsd.org/D21013
2019-07-21 17:00:19 +00:00
Mark Johnston
89e9665b8d Link fileargs_lstat.3.
Sponsored by:	The FreeBSD Foundation
2019-07-21 16:35:49 +00:00
Konstantin Belousov
1004039858 Fix userspace build after r350199.
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2019-07-21 16:24:40 +00:00
Konstantin Belousov
f1cf2b9dcb Check and avoid overflow when incrementing fp->f_count in
fget_unlocked() and fhold().

On sufficiently large machine, f_count can be legitimately very large,
e.g. malicious code can dup same fd up to the per-process
filedescriptors limit, and then fork as much as it can.
On some smaller machine, I see
	kern.maxfilesperproc: 939132
	kern.maxprocperuid: 34203
which already overflows u_int.  More, the malicious code can create
transient references by sending fds over unix sockets.

I realized that this check is missed after reading
https://secfault-security.com/blog/FreeBSD-SA-1902.fd.html

Reviewed by:	markj (previous version), mjg
Tested by:	pho (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D20947
2019-07-21 15:07:12 +00:00
Rene Ladan
349c868322 Mark Felder has stepped down from portmgr and ports-secteam 2019-07-21 11:07:39 +00:00
Alan Cox
1a4cb969d1 Introduce pmap_store(), and use it to replace pmap_load_store() in places
where the page table entry was previously invalid.  (Note that I did not
replace pmap_load_store() when it was followed by a TLB invalidation, even
if we are not using the return value from pmap_load_store().)

Correct an error in pmap_enter().  A test for determining when to set
PGA_WRITEABLE was always true, even if the mapping was read only.

In pmap_enter_l2(), when replacing an empty kernel page table page by a
superpage mapping, clear the old l2 entry and issue a TLB invalidation.  My
reading of the ARM architecture manual leads me to believe that the TLB
could hold an intermediate entry referencing the empty kernel page table
page even though it contains no valid mappings.

Replace a couple direct uses of atomic_clear_64() by the new
pmap_clear_bits().

In a couple comments, replace the term "paging-structure caches", which is
an Intel-specific term for the caches that hold intermediate entries in the
page table, with wording that is more consistent with the ARM architecture
manual.

Reviewed by:	markj
X-MFC after:	r350004
Differential Revision:	https://reviews.freebsd.org/D20998
2019-07-21 03:26:26 +00:00
Justin Hibbits
b982c7ee20 powerpc: Remove an unnecessary #ifdef guard from slb.c
slb.c is only compiled for powerpc64, so no need for the #ifdef in this block.
2019-07-21 03:19:54 +00:00
Kirk McKusick
967d9fa3bb Treat any inode with bad content as unknown (i.e., ask if it should
be cleared).

Sponsored by: Netflix
2019-07-20 21:39:32 +00:00
Kirk McKusick
3bd88193c6 When running with journaled soft updates, some updated inodes were not
having their check hashes recomputed which resulted in spurious inode
check-hash errors when the system came back up after a crash.

Reported by:  Alan Somers
Sponsored by: Netflix
2019-07-20 21:20:40 +00:00
Ian Lepore
2444018f7d Rewrite the nxprtc chip init to extend battery life by using power-saving
features offered by the chips.

For 2127 and 2129 chips, fix the detection of when chip-init is needed.  The
chip config needs to be reset whenever power was lost, but the logic was
wrong for 212x chips (it only worked for 8523).  Now the "oscillator
stopped" bit rather than the power manager mode is used to detect startup
after powerfail.

For all chips, disable the clock output pin.

For chips that have a timestamp/tamper-monitor feature, turn off monitoring
of the timestamp trigger pin.

The 8523, 2127, and 2129 chips have a "power manager" feature that offers
several options.  We've been using the default mode which enables
everything.  Now the code sets the power manager options to

 - direct-switch (when Vdd < Vbat, without extra threshold check)
 - no battery monitor
 - no external powerfail monitor

This reduces the current draw while running on battery from 1930nA to 880nA,
which should roughly double the lifespan of the battery under load.

Because battery checking is a nice thing to have, the code now does a check
at startup, and then once a day after that, instead of checking continuously
(but only actually reporting at startup).  The battery check is now done by
setting the power manager back to default mode, sleeping briefly while it
makes a voltage measurement, then switching back to power-saving mode.
2019-07-20 21:10:27 +00:00
Conrad Meyer
2826da432c motd: Generate from template to /var/run
Update login(1), its manual pages, similar utilities, and motd.5 to refer to
the new location.

Suggested by:	delphij@ (re: r349256)
Reviewed by:	bcr (manpages), delphij
Differential Revision:	https://reviews.freebsd.org/D20721
2019-07-20 20:56:31 +00:00
Doug Moore
6d5685c762 In trimming on startup, invoke swapon before closing the fd used for
trimming so that a geli device isn't detached before swapon is
invoked.

Submitted by: sigsys_gmail.com
Discussed with: alc
Approved by: markj (mentor)
Differential Revision:	https://reviews.freebsd.org/D21006
2019-07-20 20:47:07 +00:00
Mark Johnston
b16e57a6c9 Rename vm_page_{import,release}() to vm_page_zone_{import,release}().
I would like to use the name vm_page_release() for a different purpose,
and vm_page_{import,release}() are local to vm_page.c.

Reviewed by:	kib
MFC after:	1 week
2019-07-20 18:25:41 +00:00
Justin Hibbits
cafceaebea powerpc/SPE: Enable SPV bit for EFSCFD instruction emulation
EFSCFD (floating point single convert from double) emulation requires saving
the high word of the register, which uses SPE instructions.  Enable the SPE
to avoid an SPV Unavailable exception.

MFC after:	1 week
2019-07-20 18:22:01 +00:00
Emmanuel Vadot
ad6521c24f dtso: allwinner: Add an overlay for H3 i2c0
Most of the H3 boards don't enable i2c as it is unused.
Add an overlay so it's easier for user to use i2c device.
2019-07-20 17:42:46 +00:00
John Baldwin
72a52ef8c4 expand_number(3) parses suffixes, not prefixes.
While here, tidy the opening sentence a bit.

MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D20791
2019-07-20 16:03:54 +00:00
John Baldwin
87c39157c6 Improve the precision of bhyve's vPIT.
Use 'struct bintime' instead of 'sbintime_t' to manage times in vPIT
to postpone rounding to final results rather than intermediate
results.  In tests performed by Joyent, this reduced the error measured
by Linux guests by 59 ppm.

Smart OS bug:	https://smartos.org/bugview/OS-6923
Submitted by:	Patrick Mooney
Reviewed by:	rgrimes
Obtained from:	SmartOS / Joyent
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D20335
2019-07-20 15:59:49 +00:00
Dimitry Andric
87c8ef55c3 Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.1 final release r366581.  The only functional change is a fix for a
mismerge of upstream r360816, which properly restores the r2 register
when unwinding on PowerPC64 (See https://reviews.freebsd.org/D20337).

Relnotes:	yes
PR:		236062
MFC after:	3 days
X-MFC-With:	r349004
2019-07-20 15:26:21 +00:00
Dimitry Andric
17fbc4a4fc Vendor import of LLVM libunwind 8.0.1 release r366581:
https://llvm.org/svn/llvm-project/libunwind/tags/RELEASE_801/final@366581
2019-07-20 14:44:33 +00:00
Dimitry Andric
13847ea563 Vendor import of clang 8.0.1 release r366581:
https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_801/final@366581
2019-07-20 14:44:17 +00:00
Emmanuel Vadot
d5fdfa2c8a arm64: Implement HWCAP
Add HWCAP support for arm64.
defines are the same as in Linux and a userland program can use
elf_aux_info to get the data.
We only save the common denominator for all cores in case the
big and little cluster have different support (this is known to
exists even if we don't support those SoCs in FreeBSD)

Differential Revision:	https://reviews.freebsd.org/D17137
2019-07-20 14:29:11 +00:00
Ganbold Tsagaankhuu
b24594e544 Add emmc support for Rockchip RK3399 SoC.
Tested on NanoPC-T4 board.

Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D20156
2019-07-20 02:53:06 +00:00
Ganbold Tsagaankhuu
ea01660f1c Add driver for Rockchip RK3399 eMMC PHY.
Tested on NanoPC-T4 board.

Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D20840
2019-07-20 02:03:31 +00:00
Brooks Davis
cba2a593da Avoid copying too much from the input string.
This avoids reading past the end of the static strings.  On a system
with bounds checking these tests fault.

Reviewed by:	asomers
Obtained from:	CheriBSD
MFC after:	1 week
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D21004
2019-07-19 23:58:30 +00:00
Brooks Davis
c5d2d5a1ef Make setting mips endian and ABI less verbose.
Allow ABI to be over ridden to allow (with other changes) programs to be
built targeting ABIs other than the default.  This is used in CheriBSD.

Reviewed by:	imp
Obtained from:	CheriBSD
MFC after:	1 week
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D21001
2019-07-19 23:39:21 +00:00
Brooks Davis
0ccd9d15a8 Remove an unneeded temporary variable in two functions.
There is no need to convert an intptr_t to a long just to cast it to a
(void *).

Obtained from:	CheriBSD
MFC after:	1 week
Sponsored by:	DARPA, AFRL
2019-07-19 23:10:43 +00:00
Brooks Davis
b16d667545 Use the __DECONST macro rather than hand rolling it.
Obtained from:	CheriBSD
MFC after:	1 week
Sponsored by:	DARPA, AFRL
2019-07-19 22:54:09 +00:00
Konstantin Belousov
47c3450e50 Fix leak of memory and file refs with sendmsg(2) over unix domain sockets.
When sendmsg(2) sucessfully internalized one SCM_RIGHTS control
message, but failed to process some other control message later, both
file references and filedescent memory needs to be freed. This was not
done, only mbuf chain was freed.

Noted, test case written, reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D21000
2019-07-19 20:51:39 +00:00
Doug Moore
312df2c1dd Define vm_map_entry_in_transition to handle an in-transition map
entry, combining code currently in vm_map_unwire and
vm_map_wire_locked into a single function, called by each of them for
entries in transition.

Discussed with: kib, markj
Reviewed by: alc
Approved by: kib, markj (mentors, implicit)
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D20833
2019-07-19 20:47:35 +00:00
Warner Losh
fddfaafd65 Remove RELEASE_CRUNCH here
If someone wants to subset, they can set MK_ICONV=no. We no longer use it for
the release.
2019-07-19 20:04:31 +00:00
Warner Losh
435e57a1b9 Remove RELEASE_CRUNCH in example
RELEASE_CRUNCH is no longer relevant.
2019-07-19 20:04:26 +00:00
Warner Losh
bb0e923848 Remove obsolete RELEASE_CRUNCH
Remove documentation of RELEASE_CRUNCH here. It's obsolete and no longer a good
example.
2019-07-19 20:04:21 +00:00
Warner Losh
51d357cbb3 Remove RELEASE_CRUNCH
RELEASE_CRUNCH isn't used for releases any more. If someone wants to subset,
then they can set MK_JAIL=no instead.
2019-07-19 20:04:13 +00:00
Alexander Motin
c1264e76cd Properly report ACS revisions alike to kernel.
MFC after:	2 weeks
2019-07-19 20:02:01 +00:00
Alexander Motin
89b35a5274 Add Accessible Max Address Configuration support to camcontrol.
AMA replaced HPA in ACS-3 specification.  It allows to limit size of the
disk alike to HPA, but declares inaccessible data as indeterminate.  One
of its practical use cases is to under-provision SATA SSDs for better
reliability and performance.

While there, fix HPA Security detection/reporting.

MFC after:	2 weeks
Relnotes:	yes
Sponsored by:	iXsystems, Inc.
2019-07-19 19:15:08 +00:00
Brooks Davis
4ca9bcd650 Restore WARNS?=1 here. I missed that libexec/bootpd/bootpgw existed. 2019-07-19 18:47:13 +00:00
Warner Losh
5e83c2ffaa Keep track of the number of commands that exhaust their retry limit.
While we print failure messages on the console, sometimes logs are lost or
overwhelmed. Keeping a count of how many times we've failed retriable commands
helps get a magnitude of the problem.
2019-07-19 18:39:24 +00:00
Warner Losh
c37fc318c4 Keep track of the number of retried commands.
Retried commands can indicate a performance degredation of an nvme drive. Keep
track of the number of retries and report it out via sysctl, just like number of
commands an interrupts.
2019-07-19 18:39:18 +00:00
Warner Losh
710becdd96 Remove pre-FreeBSD 7.0 compatibility. 2019-07-19 18:38:47 +00:00
Brooks Davis
df7a21a703 Chain Makefile.inc's so default are inherited as expected.
Remove unneeded or duplicate variables.

No functional change.

Obtained from:	CheriBSD
MFC after:	1 week
Sponsored by:	DARPA, AFRL
2019-07-19 17:52:23 +00:00
Warner Losh
eec0e91e05 Add comments about KERN_OPT here. 2019-07-19 17:48:29 +00:00
Emmanuel Vadot
1d6d0a43ce pkgbase: move man pages from runtime-manual to runtime
We don't split the other man pages in their own package so do the same for runtime.

Reviewed by:	bapt, gjb
Differential Revision:	https://reviews.freebsd.org/D20962
2019-07-19 15:12:20 +00:00
Emmanuel Vadot
5c5ed48a03 bsd.confs.mk: Test the correct value for the destination package
Reviewed by:	bapt, gjb
Differential Revision:	https://reviews.freebsd.org/D20961
2019-07-19 15:11:32 +00:00
Emmanuel Vadot
be6a4fc664 pkgbase: Add a FreeBSD-dpv package
Move the dpv related files from FreeBSD-runtime to a new package named
FreeBSD-dpv
The only consumer is bsdinstall which is already in it's own package.

Reviewed by:	bapt, gjb
Differential Revision:	https://reviews.freebsd.org/D20960
2019-07-19 15:10:53 +00:00
Emmanuel Vadot
9553ea80a8 pkgbase: Add a FreeBSD-bluetooth package
Move the bluetooth related files from FreeBSD-runtime to a new package named
FreeBSD-bluetooth
The FreeBSD runtime is only intended to have everything for a working
FreeBSD installation and bluetooth isn't needed for that.

Reviewed by:	bapt, gjb
Differential Revision:	https://reviews.freebsd.org/D20959
2019-07-19 15:10:03 +00:00
Emmanuel Vadot
1ba153e085 pkgbase: Add a FreeBSD-hostapd package
Move the hostapd related files from FreeBSD-runtime to a new package n
FreeBSD-hostapd
The FreeBSD runtime is only intended to have everything for a working
FreeBSD installation and hostapd isn't needed for that.

Reviewed by:	bapt, gjb
Differential Revision:	https://reviews.freebsd.org/D20958
2019-07-19 15:09:00 +00:00
Emmanuel Vadot
d4335dcc83 pkgbase: Add a FreeBSD-wpa package
Move the wpa related files from FreeBSD-runtime to a new package named
FreeBSD-wpa
The FreeBSD runtime is only intended to have everything for a working
FreeBSD installation and wpa isn't needed for that.

Reviewed by:    bapt, gjb
Differential Revision:  https://reviews.freebsd.org/D20957
2019-07-19 15:07:30 +00:00
Warner Losh
1071b50a65 Use sysctl + CTLRWTUN for hw.nvme.verbose_cmd_dump.
Also convert it to a bool. While the rest of the driver isn't yet bool clean,
this will help.

Reviewed by: cem@
Differential Revision: https://reviews.freebsd.org/D20988
2019-07-19 00:32:56 +00:00
Bryan Drewery
000a2e7040 Rework some multi-output target dependency handling.
This reworks my last commit in r301285 to more closely match what was in
r241298 (but reverted in r294878).

This is addressing "missing .meta file" rebuilds but also ensuring that
files are always generated when needed in each case.

Note that this is not a complete rework of the problem areas identified
in r301285 as most are "good enough" right now as the new pattern
is too verbose. It's only worth making this current change where headers
may be generated in the INCS list; where missing .meta file rebuilds are
spotted.

--- Technical details follow ---

Several attempts to deal with this problem of multi-output targets, with and
without META MODE, were explained in r241298, r294878, and r301285.

The general problem is with multi-output targets such as:
        foo.c foo.h:
                touch foo.c foo.h
        foo.c foo.h:
                touch foo.c
                touch foo.h
        foo.c foo.h: foo.in
                ./generator ${.ALLSRC}

This pattern is problematic in jobs mode as both files end up being
built concurrently and leads to races. With META MODE it is worse
as both targets end up rebuilding if they lack a .meta file. So the
generator is force built twice even though it is only needed once.
There are also problems in that 'make foo.h' may be ran before 'make foo.c';
The order of make generating the targets is not guaranteed.

An older attempted workaround to this (discussed in r294878) was:
        foo.h: foo.c
        foo.c: foo.in
                ./generator ${.ALLSRC}
This appears fine except that if foo.h is missing and foo.c exists then
foo.h will never be regenerated. This pattern is close to the solution
in this commit though:

        foo.h: foo.c .NOMETA
        .if !exists(foo.h)
        foo.c: .PHONY .META
        .endif
        foo.c: foo.in
                ./generator ${.ALLSRC}

There's 2 differences here:
1. foo.h will never expect to have a .meta file since the foo.c target
   will generate both and own the .meta file.
2. If foo.h does not exist then it needs to force foo.c to be rebuilt
   with .PHONY. That normally disables META MODE though so .META is
   given to tell bmake we do really expect a .meta file.

This pattern cannot work with implicit suffix rules since the .c and .h files
may be generated at different times (buildincludes vs depend/all).

Sponsored by:	Dell EMC
MFC after:	2 weeks
2019-07-19 00:15:25 +00:00