freebsd.git
5 years agoudp: assign flowid to udp sockets round-robin
mmacy [Wed, 23 May 2018 20:50:09 +0000 (20:50 +0000)]
udp: assign flowid to udp sockets round-robin

On a 2x8x2 SKL this increases measured throughput with 64
netperf -H $DUT -t UDP_STREAM -- -m 1

from 590kpps to 1.1Mpps
before:
https://people.freebsd.org/~mmacy/2018.05.11/udpsender.svg
after:
https://people.freebsd.org/~mmacy/2018.05.11/udpsender2.svg

5 years agoCentralize USB device mode bus power reporting, and add
trasz [Wed, 23 May 2018 20:06:04 +0000 (20:06 +0000)]
Centralize USB device mode bus power reporting, and add
hw.usb.template_power sysctl to control it.

Reviewed by: hselasky@ (earlier version)
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

5 years agopmc: bump PMC major version to reflect ABI breakage and make warning not require...
mmacy [Wed, 23 May 2018 19:55:47 +0000 (19:55 +0000)]
pmc: bump PMC major version to reflect ABI breakage and make warning not require verbose

5 years agoAdding myself to committers-src.dot and calendar.freebsd
luporl [Wed, 23 May 2018 19:17:17 +0000 (19:17 +0000)]
Adding myself to committers-src.dot and calendar.freebsd

Approved by: jhibbits (mentor)

5 years agoarm64: rockchip: Add proper armclock support
manu [Wed, 23 May 2018 19:07:03 +0000 (19:07 +0000)]
arm64: rockchip: Add proper armclock support

The core clock (armclk) on RockChip SoC is special.
It can derive it's clock from many PLLs but RockChip recommand to do it
from "apll" on old SoC and "npll" on new SoC. The reason for choosing npll
is that it's have less jitter and is more close to the arm core on the SoC.
r333314 added the core clock as a composite clock but due to it's specials
property we need to deal with it differently.
A new rk_clk_armclk type is added for this and it supports only the "npll"
as we don't run on old RockChip SoC that only have the "apll".
It will always reparent to "npll" and set the frequency according to a rate
table that is known to be good.
For now we set the "npll" to the desired frequency and just set the core clk
divider to 1 as its parent it just used for the core clk.

5 years agoNote that PT_SETSTEP is auto-cleared.
kib [Wed, 23 May 2018 17:55:30 +0000 (17:55 +0000)]
Note that PT_SETSTEP is auto-cleared.

Wording and reviewed by: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential revision: https://reviews.freebsd.org/D15054

5 years agohwppmc: set threadid in callchain records - second part of r334108
mmacy [Wed, 23 May 2018 17:44:29 +0000 (17:44 +0000)]
hwppmc: set threadid in callchain records - second part of r334108

5 years agoUPDATING: note that the pmc callchain ABI has changed
mmacy [Wed, 23 May 2018 17:30:23 +0000 (17:30 +0000)]
UPDATING: note that the pmc callchain ABI has changed

5 years agohwpmc: add thread id field to callchain and context switch records to allow filtering
mmacy [Wed, 23 May 2018 17:25:00 +0000 (17:25 +0000)]
hwpmc: add thread id field to callchain and context switch records to allow filtering
on thread in post-processing.

To generate stacks for just ${THREADID}:

pmcstat -R ${PREFIX}.pmcstat -L ${THREADID} -z100 -G ${PREFIX}.stacks

Sponsored by: Limelight Networks

5 years agoRemove references to the LIBC_SCCS and SYSLIBC_SCCS C macros.
jhb [Wed, 23 May 2018 17:05:12 +0000 (17:05 +0000)]
Remove references to the LIBC_SCCS and SYSLIBC_SCCS C macros.

This language dates back to when libthr was libc_r that included its own
syscalls and replaced libc entirely.  It hasn't been relevant for a long
time.

5 years agoUse __SCCSID() for SCCS IDs.
jhb [Wed, 23 May 2018 17:02:12 +0000 (17:02 +0000)]
Use __SCCSID() for SCCS IDs.

- Define NO__SCCSID in CFLAGS to preserve existing behavior of omitting
  SCCS IDs by default.
- While here, fix the $FreeBSD$ in pw_util.c to use __FBSDID.

5 years agoRevert r334090.
markj [Wed, 23 May 2018 17:01:28 +0000 (17:01 +0000)]
Revert r334090.

It causes the 32bit compat build of libmd to fail with:

libmd/rmd160c.c:86:9: error: 'ripemd160_block' macro redefined
#define ripemd160_block ripemd160_block_x86
        ^
libmd/ripemd.h:122:9: note: previous definition is here
#define ripemd160_block         _libmd_ripemd160_block

5 years agoepoch: allow for conditionally asserting that the epoch context fields
mmacy [Wed, 23 May 2018 17:00:05 +0000 (17:00 +0000)]
epoch: allow for conditionally asserting that the epoch context fields
are unused by zeroing on INVARIANTS builds

5 years agoSupport IBRS for i386.
kib [Wed, 23 May 2018 16:31:46 +0000 (16:31 +0000)]
Support IBRS for i386.

Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D15522

5 years agoSwitch calendar installs to use FILES and SYMLINKS instead of bare install(1)
brd [Wed, 23 May 2018 16:28:31 +0000 (16:28 +0000)]
Switch calendar installs to use FILES and SYMLINKS instead of bare install(1)

Also explicitly list each file to install so we don't silently add or miss
some.

Approved by: bapt (mentor)

5 years agoAdd GET_STACK_USAGE() for arm64.
markj [Wed, 23 May 2018 15:43:35 +0000 (15:43 +0000)]
Add GET_STACK_USAGE() for arm64.

Its absence meant that GEOM direct dispatch was disabled (the service
routines check the current thread's stack usage to determine whether
to hand off the request to a dedicated thread), and this change is
sufficient to enable direct dispatch by default.

Reviewed by: allanjude
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D15527

5 years agoDocument the return value of sbuf_bcat(9).
markj [Wed, 23 May 2018 15:26:56 +0000 (15:26 +0000)]
Document the return value of sbuf_bcat(9).

MFC after: 1 week

5 years agoAdd ready polling after PHY reset on VIA SATA controllers.
mav [Wed, 23 May 2018 15:22:58 +0000 (15:22 +0000)]
Add ready polling after PHY reset on VIA SATA controllers.

According to PR there are cases of controller hang if soft reset is
sent before device report ready status after the hard reset.

I don't think this patch is perfect, but it was reported as working
by the submitter, and I have neither the old hardware nor interest to
test some improved version, so just done some style cleaning.

PR: 183294
Submitted by: alexandre.martins@netasq.com
MFC after: 1 month

5 years agoAdding myself share/misc/committers-src.dot.
leitao [Wed, 23 May 2018 14:19:06 +0000 (14:19 +0000)]
Adding myself share/misc/committers-src.dot.

5 years agodevd: Move variable declaration to header
eadler [Wed, 23 May 2018 13:48:16 +0000 (13:48 +0000)]
devd: Move variable declaration to header

Reminder by: imp

5 years agoImprove MAC address uniqueness on if_epair(4).
pizzamig [Wed, 23 May 2018 13:10:57 +0000 (13:10 +0000)]
Improve MAC address uniqueness on if_epair(4).

As reported in PR184149, it can happen that epair devices can have the same
MAC address.
This solution is based on a 32-bit hash, obtained combining the if_index of
the a interface and the hostid.
If the hostid is zero, a random number is used.

PR: 184149
Reviewed by: wollman, eugen
Approved by: cognet
Differential Revision: https://reviews.freebsd.org/D15329

5 years agokldstat: align size to the right
eadler [Wed, 23 May 2018 12:10:16 +0000 (12:10 +0000)]
kldstat: align size to the right

This makes it easier to compare numbers directly.

PR: 215747
Submitted by: "Alexander von Gernler" <grunk@pestilenz.org>

5 years agomd5: perform compare case-insenstive
eadler [Wed, 23 May 2018 11:45:46 +0000 (11:45 +0000)]
md5: perform compare case-insenstive

md5 generates a md5 hash lowercase, but it might be provided in
uppercase. Allow this.

PR: 205598
Reported by: ohauer
MFC After: 2 weeks

5 years agolibmd: build with WARNS=1
eadler [Wed, 23 May 2018 11:20:16 +0000 (11:20 +0000)]
libmd: build with WARNS=1

- build with WARNS=1. This works without any changes
- remove two unused variables noticed at WARNS=2

5 years agodumpon: point to better kernel debug symbols.
eadler [Wed, 23 May 2018 10:45:32 +0000 (10:45 +0000)]
dumpon: point to better kernel debug symbols.

The objdir is temporary, and the current example points to GENERIC.
Instead point to the installed location of the debug symbols that are
supposed to match the kernel you are using.

PR: 223993
Submitted by: Trond.Endrestol@ximalas.info

5 years agotimedef: Update Czech timedef
eadler [Wed, 23 May 2018 10:39:02 +0000 (10:39 +0000)]
timedef: Update Czech timedef

This changes date format from 2015/05/12 to 05.12.2015.

PR: 200591
Submitted by: grafnetter@dekanat.mff.cuni.cz

5 years agoRemove incorrect owepreempt assertion added in r334062
mjg [Wed, 23 May 2018 10:13:17 +0000 (10:13 +0000)]
Remove incorrect owepreempt assertion added in r334062

Yet another preemption request hitting between the counter being 0
and the check being reached will result in the flag no longer being
set.

Note the situation was already present prior to r334062 and is harmless.

Reported by: pho
Reviewed by: kib

5 years agodevd: Unbreak build
eadler [Wed, 23 May 2018 10:03:09 +0000 (10:03 +0000)]
devd: Unbreak build

I'm not quite sure why this wasn't caught before. Most likely due to
some generated file not being properly cleaned.

Fix build by just hiding the warnings that `-i` was supposed to fix.

Tested with clang, gcc9, gcc7

5 years agompsutil: correct style
eadler [Wed, 23 May 2018 09:46:21 +0000 (09:46 +0000)]
mpsutil: correct style

Reported by: bapt

5 years agopthread_rwlock_unlock(3) returns 0 if successful, otherwise an error number
araujo [Wed, 23 May 2018 09:34:51 +0000 (09:34 +0000)]
pthread_rwlock_unlock(3) returns 0 if successful, otherwise an error number
will be returned to indicate the error, so I'm applying an assert(3) to do
a sanity check of the return value.

Reported by: Coverity CID: 1391235, 1193654 and 1193651
Reviewed by: grehan
MFC after: 4 weeks.
Sponsored by: iXsystems Inc.
Differential Revision: https://reviews.freebsd.org/D15533

5 years agocut: Fix out of boundary write on illegal list argument
eadler [Wed, 23 May 2018 09:16:20 +0000 (09:16 +0000)]
cut: Fix out of boundary write on illegal list argument

It is possible to trigger an out of boundary write in cut if an invalid
range with autostart has been supplied.

PR: 227330
Submitted by: tobias@stoeckmann.org

5 years agoAdd missing file for WITH{OUT}_BSDINSTAL
eadler [Wed, 23 May 2018 09:02:31 +0000 (09:02 +0000)]
Add missing file for WITH{OUT}_BSDINSTAL

PR: 227805
Submitted by: Dmitry Wagin <dmitry.wagin@ya.ru>

5 years agobsd.sys.mk: add -Wmain to WARNS=1
eadler [Wed, 23 May 2018 08:35:55 +0000 (08:35 +0000)]
bsd.sys.mk: add -Wmain to WARNS=1

Even in very low "WARNS" conditions, 'main' ought to be reasonable.

5 years agobsd.sys.mk: add links and update a bit
eadler [Wed, 23 May 2018 07:54:58 +0000 (07:54 +0000)]
bsd.sys.mk: add links and update a bit

- add links to more modern resources
- remove 'k&r' which is unused in FreeBSD
- remove stray comment

5 years agodevd: allow build to complete using g++
eadler [Wed, 23 May 2018 07:44:50 +0000 (07:44 +0000)]
devd: allow build to complete using g++

5 years agodevd: compile at WARNS=6
eadler [Wed, 23 May 2018 07:39:05 +0000 (07:39 +0000)]
devd: compile at WARNS=6

Verified with "make universe TARGETS='amd64 arm arm64 i386 sparc64'"

5 years agodevd: correct two warnings
eadler [Wed, 23 May 2018 07:39:02 +0000 (07:39 +0000)]
devd: correct two warnings

- catching a polymorphic type by value
- "output between 16 and 95 bytes into a destination of size 80"

5 years agomrsas(4): Remove unneed extra arg from MR_LdBlockSizeGet().
eadler [Wed, 23 May 2018 07:39:00 +0000 (07:39 +0000)]
mrsas(4): Remove unneed extra arg from MR_LdBlockSizeGet().

Obtained From: DragonFly (482292f9859e1ceae4f35343c0a8eac4c4486d1)

5 years agompsutil: add missing braces
eadler [Wed, 23 May 2018 07:38:58 +0000 (07:38 +0000)]
mpsutil: add missing braces

Obtained from: DragonFly (c5d53f11a9510c5c79e196857a1200925fffacc8)

5 years agoBump FreeBSD_version after r333813
mmacy [Wed, 23 May 2018 06:15:55 +0000 (06:15 +0000)]
Bump FreeBSD_version after r333813

5 years agoREADME: Reduce the textdump; describe the project
eadler [Wed, 23 May 2018 04:09:01 +0000 (04:09 +0000)]
README: Reduce the textdump; describe the project

Rework the README to make it a little easier for new users. This is the
first file many will see when persuing the FreeBSD source code so

- remove some of the text describes how to build. This is better covered
in the linked documentation.
- add a small blurb for what FreeBSD is. Some users might find this
document through features such as github search so they may not even
know what the project is

generally, gear this file for the new, accidental, or casual user rather
than towards someone seeking fuller documentation.

5 years agoAdd the text '@generated' to src.conf.5
eadler [Wed, 23 May 2018 03:41:22 +0000 (03:41 +0000)]
Add the text '@generated' to src.conf.5

This is a cross-tool approach to identifying generated code. Some tools,
notably phabricator, handle this marker specially.  See
https://reviews.freebsd.org/differential/diff/42870/ for such an
example.

5 years agoWhoops, forgot to add this file in r334070.
wollman [Wed, 23 May 2018 02:54:28 +0000 (02:54 +0000)]
Whoops, forgot to add this file in r334070.

PR: 164049

5 years agoMove unsigned limits to a separate table/recognizer and display them
wollman [Wed, 23 May 2018 02:51:56 +0000 (02:51 +0000)]
Move unsigned limits to a separate table/recognizer and display them
using the appropriate (unsigned) format specification.  This prevents
integer overflow when ULLONG_MAX and (on some architectures) ULONG_MAX
are used to initialize an intmax_t and then displayed as the signed
value -1.  (A different approach was suggested in the bug report,
which I did not use.)  If other limits are defined to be unsigned,
they could be moved here.

PR: 164049
Reported by: Marcus Reid

5 years agokern_sendit: use pre-initialized rights
mmacy [Wed, 23 May 2018 01:48:09 +0000 (01:48 +0000)]
kern_sendit: use pre-initialized rights

5 years agoImport libxo-0.9.0:
phil [Wed, 23 May 2018 01:20:31 +0000 (01:20 +0000)]
Import libxo-0.9.0:
- Add xo_format_is_numeric() with improved logic to decide if format
  strings are numeric, so json output quotes them
- Convert docs to sphinx/rst
- update tests

Includes fix for PR 221676:
https://github.com/Juniper/libxo/commit/27d3021cc3cc8cfbe9ddee5930cd7a9afea8f68f#diff-5a0d468963477f7daedb8308c219dd80

PR:  221676
MFC after: 5 days

5 years agoTag libxo 0.9.0
phil [Wed, 23 May 2018 01:12:39 +0000 (01:12 +0000)]
Tag libxo 0.9.0

5 years agoImport libxo 0.9.0
phil [Wed, 23 May 2018 01:12:17 +0000 (01:12 +0000)]
Import libxo 0.9.0

5 years agoImplement initial MMC partitions support for MMCCAM.
kibab [Tue, 22 May 2018 22:16:49 +0000 (22:16 +0000)]
Implement initial MMC partitions support for MMCCAM.

For MMC cards, add partitions found on the card as separate disk(9) devices.
Don't do anything with RPMB partition for now.
Lots of code is copied almost 1:1 from the mmcsd.c in the old stack,
credits Marius Strobl (marius@FreeBSD.org)

Reviewed by: marius
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D12762

5 years agoFix UP build.
kib [Tue, 22 May 2018 20:50:19 +0000 (20:50 +0000)]
Fix UP build.

Reported by: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoif_muge: only attach to LAN7800 Chip ID
emaste [Tue, 22 May 2018 20:00:56 +0000 (20:00 +0000)]
if_muge: only attach to LAN7800 Chip ID

This driver was developed for the LAN7800 and the register-compatible
LAN7515 (found on Raspberry Pi 3B+) and has only been tested on those
devices.

Sponsored by: The FreeBSD Foundation

5 years agoMove preemption handling out of critical_exit.
mjg [Tue, 22 May 2018 19:24:57 +0000 (19:24 +0000)]
Move preemption handling out of critical_exit.

In preperataion for making the enter/exit pair inline.

Reviewed by: kib

5 years agoAdd new PIDs for Audio, CDCE, MTP, and Mass Storage, from
trasz [Tue, 22 May 2018 19:11:06 +0000 (19:11 +0000)]
Add new PIDs for Audio, CDCE, MTP, and Mass Storage, from
https://github.com/obdev/v-usb/blob/master/usbdrv/USB-IDs-for-free.txt.

Big thanks to Christian Starkjohann for allocating those.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

5 years agoFix the definition of td_startzero after r333466.
markj [Tue, 22 May 2018 16:33:09 +0000 (16:33 +0000)]
Fix the definition of td_startzero after r333466.

5 years agoFix MMCCAM scanning for new cards.
kibab [Tue, 22 May 2018 16:32:34 +0000 (16:32 +0000)]
Fix MMCCAM scanning for new cards.

r326645 used an incorrect argument for xpt_path_inq().

Reviewed by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D15521

5 years agocxgbe(4): Only valid filters are expected to have a valid tid.
np [Tue, 22 May 2018 16:23:14 +0000 (16:23 +0000)]
cxgbe(4): Only valid filters are expected to have a valid tid.

5 years agoEnsure that "m" is initialized in vm_page_alloc_freelist_domain().
markj [Tue, 22 May 2018 16:19:48 +0000 (16:19 +0000)]
Ensure that "m" is initialized in vm_page_alloc_freelist_domain().

While here, remove a superfluous comment.

Coverity CID: 1383559
MFC after: 3 days

5 years agoHandle reserved memory with the no-map property.
andrew [Tue, 22 May 2018 16:03:41 +0000 (16:03 +0000)]
Handle reserved memory with the no-map property.

We shouldn't be mapping this memory, so we need to find it so it
can be excluded from the phys_avail map.

Reviewed by: manu
Obtained from: ABT Systems Ltd
Sponsored by: Turing Robotic Industries
Differential Revision: https://reviews.freebsd.org/D15518

5 years agoInitialize the dumper struct before calling set_dumper().
markj [Tue, 22 May 2018 16:01:56 +0000 (16:01 +0000)]
Initialize the dumper struct before calling set_dumper().

Fields owned by the generic code were being left uninitialized,
causing problems in clear_dumper() if an error occurred.

Coverity CID: 1391200
X-MFC with: r333283

5 years agoAdd a SPD cache to speed up lookups.
fabient [Tue, 22 May 2018 15:54:25 +0000 (15:54 +0000)]
Add a SPD cache to speed up lookups.

When large SPDs are used, we face two problems:

- too many CPU cycles are spent during the linear searches in the SPD
  for each packet
- too much contention on multi socket systems, since we use a single
  shared lock.

Main changes:

- added the sysctl tree 'net.key.spdcache' to control the SPD cache
  (disabled by default).
- cache the sp indexes that are used to perform SP lookups.
- use a range of dedicated mutexes to protect the cache lines.

Submitted by: Emeric Poupon <emeric.poupon@stormshield.eu>
Reviewed by: ae
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D15050

5 years agoUse __SCCSID for SCCS IDs in libkvm sources.
jhb [Tue, 22 May 2018 15:52:22 +0000 (15:52 +0000)]
Use __SCCSID for SCCS IDs in libkvm sources.

Rather than using #ifdef's around a static char array, use the
existing helper macro from <sys/cdefs.h> for SCCS IDs.  To
preserve existing behavior, add -DNO__SCCSID to CFLAGS to not
include SCCS IDs in the built library by default.

Reviewed by: brooks, dab (older version)
Reviewed by: rgrimes
Differential Revision: https://reviews.freebsd.org/D15459

5 years agoRevert r334035 for now. It breaks the boot on some boards as er expect to
andrew [Tue, 22 May 2018 15:52:11 +0000 (15:52 +0000)]
Revert r334035 for now. It breaks the boot on some boards as er expect to
be able to read UEFI RuntimeData memory via the DMAP region.

5 years agoTypo.
markj [Tue, 22 May 2018 15:49:23 +0000 (15:49 +0000)]
Typo.

Reported by: rgrimes, vangyzen
X-MFC with: r334050

5 years agoFlush caches before initiating a microcode update on Intel CPUs.
markj [Tue, 22 May 2018 15:38:51 +0000 (15:38 +0000)]
Flush caches before initiating a microcode update on Intel CPUs.

This apparently works around issues with updates of certain Broadwell
CPUs.

Reviewed by: emaste, kib, sbruno
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D15520

5 years agoSimplify lagg_input().
markj [Tue, 22 May 2018 15:35:38 +0000 (15:35 +0000)]
Simplify lagg_input().

No functional change intended.

MFC after: 2 weeks

5 years agosx: fixup a braino in r334024
mjg [Tue, 22 May 2018 15:13:25 +0000 (15:13 +0000)]
sx: fixup a braino in r334024

If a thread waiting on sx dropped Giant it would not be properly
reacquired on exit from the routine, later resulting in panics
indicating Giant is not held (when it should be).

The bug was not present in the original patch sent to pho, I wittingly
added it just prior to the commit and only smoke-tested it.

Reported by: pho

5 years agointel-ucode-split: add -n flag to skip creating output files
emaste [Tue, 22 May 2018 14:35:33 +0000 (14:35 +0000)]
intel-ucode-split: add -n flag to skip creating output files

Sponsored by: The FreeBSD Foundation

5 years agoPass the array length into regions_to_avail.
andrew [Tue, 22 May 2018 14:26:58 +0000 (14:26 +0000)]
Pass the array length into regions_to_avail.

On arm64 we will need to get the phys_avail array from before the kernel
is excluded to create teh DMAP region. In preperation for this pass in the
array length into regions_to_avail.

5 years agoUse local unique labels inside most often used macros.
kib [Tue, 22 May 2018 13:45:40 +0000 (13:45 +0000)]
Use local unique labels inside most often used macros.

Discussed with: bde
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agobus_dma(9): Correct arm64 BUS_DMA_COHERENT implementation note
manu [Tue, 22 May 2018 13:45:24 +0000 (13:45 +0000)]
bus_dma(9): Correct arm64 BUS_DMA_COHERENT implementation note

BUS_DMA_COHERENT isn't supported in bus_dmamap_create but bus_dma_tag_create.
Document it properly.

Submitted by: andrew

5 years agoFix double-load of %cr3 and double-copy of the stack frame for the
kib [Tue, 22 May 2018 13:30:56 +0000 (13:30 +0000)]
Fix double-load of %cr3 and double-copy of the stack frame for the
kernel entry from userspace vm86.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoRestore the ability to keep states after parent rule deletion.
ae [Tue, 22 May 2018 13:28:05 +0000 (13:28 +0000)]
Restore the ability to keep states after parent rule deletion.

This feature is disabled by default and was removed when dynamic states
implementation changed to be lockless. Now it is reimplemented with small
differences - when dyn_keep_states sysctl variable is enabled,
dyn_match_ipv[46]_state() function doesn't match child states of deleted
rule. And thus they are keept alive until expired. ipfw_dyn_lookup_state()
function does check that state was not orphaned, and if so, it returns
pointer to default_rule and its position in the rules map. The main visible
difference is that orphaned states still have the same rule number that
they have before parent rule deleted, because now a state has many fields
related to rule and changing them all atomically to point to default_rule
seems hard enough.

Reported by: <lantw44 at gmail.com>
MFC after: 2 days

5 years agoEnable IBRS when entering an interrupt handler from usermode.
kib [Tue, 22 May 2018 13:25:15 +0000 (13:25 +0000)]
Enable IBRS when entering an interrupt handler from usermode.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoOnly set realmem based on memory where the EXFLAG_NOALLOC is unset. This
andrew [Tue, 22 May 2018 13:21:44 +0000 (13:21 +0000)]
Only set realmem based on memory where the EXFLAG_NOALLOC is unset. This
will allow us to query the maps at any time without disturbing this value.

Obtained from: ABT Systems Ltd
Sponsored by: Turing Robotic Industries

5 years agoOn ThunderX2 we need to be careful to only map the memory the firmware
andrew [Tue, 22 May 2018 11:26:41 +0000 (11:26 +0000)]
On ThunderX2 we need to be careful to only map the memory the firmware
lists in the EFI memory map. As such we need to reduce the mappings to
restrict them to not be the full 1G block. For now reduce this to a 2M
block, however this may be further restricted to be 4k page aligned as
other SoCs may require.

This allows ThunderX2 to boot reliably to userspace without performing
any speculative memory accesses to invalid physical memory.

Sponsored by: DARPA, AFRL

5 years agobus_dma(9): arm64 implementation notes
manu [Tue, 22 May 2018 11:17:45 +0000 (11:17 +0000)]
bus_dma(9): arm64 implementation notes

Indicate that BUS_DMA_COHERENT is supported for bus_dmamem_alloc and
bus_dmamem_create in the arm64 implementation.

5 years agoStop using the DMAP region to map ACPI memory.
andrew [Tue, 22 May 2018 11:16:45 +0000 (11:16 +0000)]
Stop using the DMAP region to map ACPI memory.

On some arm64 boards we need to access memory in ACPI tables that is not
mapped in the DMAP region. To handle this create the needed mappings in
pmap_mapbios in the KVA space.

Submitted by: Michal Stanek (mst@semihalf.com)
Sponsored by: Cavium
Differential Revision: https://reviews.freebsd.org/D15059

5 years agoSwitch arm64 to use the same physmem code as 32-bit arm.
andrew [Tue, 22 May 2018 11:07:04 +0000 (11:07 +0000)]
Switch arm64 to use the same physmem code as 32-bit arm.

The main advantage of this is to allow us to exclude memory from being
used by the kernel. This may be from the memreserve property, or ranges
marked as no-map under the reserved-memory node.

More work is still needed to remove the physmap array. This is still used
for creating the DMAP region, however other patches need to be committed
before we can remove this.

Obtained from: ABT Systems Ltd
Sponsored by: Turing Robotic Industries

5 years agoImplement printf(3) family %m format string extension.
kib [Tue, 22 May 2018 11:05:40 +0000 (11:05 +0000)]
Implement printf(3) family %m format string extension.

Reviewed by: ed, dim (code only)
Sponsored by: Mellanox Technologies
MFC after: 1 week

5 years agoAllow the 32-bit arm physmem code to work on arm64.
andrew [Tue, 22 May 2018 10:31:06 +0000 (10:31 +0000)]
Allow the 32-bit arm physmem code to work on arm64.

This will help simplify the arm64 code and allow us to properly exclude
memory that should never be mapped.

Obtained from: ABT Systems Ltd
Sponsored by: Turing Robotic Industries

5 years agoCoalesce adjacent physical mappings.
andrew [Tue, 22 May 2018 10:14:20 +0000 (10:14 +0000)]
Coalesce adjacent physical mappings.

This reduces the overhead when we have many small mappings, e.g. on some
EFI systems. This is to help use this code on arm64 where we may have a
large number of entries from the EFI firmware.

Obtained from: ABT Systems Ltd
Sponsored by: Turing Robotic Industries
Differential Revision: https://reviews.freebsd.org/D15477

5 years agoxen-blkback: do not use state 3 (XenbusStateInitialised)
royger [Tue, 22 May 2018 08:51:16 +0000 (08:51 +0000)]
xen-blkback: do not use state 3 (XenbusStateInitialised)

Linux will not connect to a backend that's in state 3
(XenbusStateInitialised), it needs to be in state 2
(XenbusStateInitWait) for Linux to attempt to connect to the backend.

The protocol seems to suggest that the backend should indeed wait in
state 2 for the frontend to connect, which makes state 3 unusable for
disk backends.

Also make sure blkback will connect to the frontend if the frontend
reaches state 3 (XenbusStateInitialised) before blkback has processed
the results from the hotplug script (Submitted by Nathan Friess).

MFC after: 1 week

5 years agoReduce sdt-related branch-fest in mi_switch.
mjg [Tue, 22 May 2018 08:27:33 +0000 (08:27 +0000)]
Reduce sdt-related branch-fest in mi_switch.

The code was evaluating flags before resorting to checking if dtrace is
enabled. This was inducing forward jumps in the common case.

5 years agotop(1): increase size of 'status' buffer
eadler [Tue, 22 May 2018 07:56:58 +0000 (07:56 +0000)]
top(1): increase size of 'status' buffer

This corrects a warning issues by gcc9:
/srv/src/freebsd/head/usr.bin/top/machine.c:988:22: warning: '%5zu'
directive writing between 5 and 20 bytes into a
 region of size 15 [-Wformat-overflow=]
     sprintf(status, "?%5zu", state);

5 years agosx: port over writer starvation prevention measures from rwlock
mjg [Tue, 22 May 2018 07:20:22 +0000 (07:20 +0000)]
sx: port over writer starvation prevention measures from rwlock

A constant stream of readers could completely starve writers and this is not
a hypothetical scenario.

The 'poll2_threads' test from the will-it-scale suite reliably starves writers
even with concurrency < 10 threads.

The problem was run into and diagnosed by dillon@backplane.com

There was next to no change in lock contention profile during -j 128 pkg build,
despite an sx lock being at the top.

Tested by: pho

5 years agorw: decrease writer starvation
mjg [Tue, 22 May 2018 07:16:39 +0000 (07:16 +0000)]
rw: decrease writer starvation

Writers waiting on readers to finish can set the RW_LOCK_WRITE_SPINNER
bit. This prevents most new readers from coming on. However, the last
reader to unlock also clears the bit which means new readers can sneak
in and the cycle starts over.

Change the code to keep the bit after last unlock.

Note that starvation potential is still there: no matter how many write
spinners are there, there is one bit. After the writer unlocks, the lock
is free to get raided by readers again. It is good enough for the time
being.

The real fix would include counting writers.

This runs into a caveat: the writer which set the bit may now be preempted.
In order to get rid of the problem all attempts to set the bit are preceeded
with critical_enter.

The bit gets cleared when the thread which set it goes to sleep. This way
an invariant holds that if the bit is set, someone is actively spinning and
will grab the lock soon. In particular this means that readers which find
the lock in this transient state can safely spin until the lock finds itself
an owner (i.e. they don't need to block nor speculate how long to spin
speculatively).

Tested by: pho

5 years agoConform to Berne Convention.
cy [Tue, 22 May 2018 06:22:58 +0000 (06:22 +0000)]
Conform to Berne Convention.

MFC after: 3 days

5 years agoRevert: r334016
araujo [Tue, 22 May 2018 06:02:11 +0000 (06:02 +0000)]
Revert: r334016
Revert for now this change, it in somehow breaks init_pci.

5 years agopmc: annotate locking for po_ssnext in pmc_owner
mmacy [Tue, 22 May 2018 05:49:40 +0000 (05:49 +0000)]
pmc: annotate locking for po_ssnext in pmc_owner

5 years agoInclude atkbdc header where there are declared the prototype functions
araujo [Tue, 22 May 2018 05:21:53 +0000 (05:21 +0000)]
Include atkbdc header where there are declared the prototype functions
atkbdc_event and atkbdc_init.

MFC after: 4 weeks.
Sponsored by: iXsystems Inc.

5 years agofix i386 builds after r334005 and r334009
mmacy [Tue, 22 May 2018 05:09:33 +0000 (05:09 +0000)]
fix i386 builds after r334005 and r334009

r334005: add pc_ibpb_set as it is now referenced by common code
(although presumably not needed on i386 since it has been there
since the first spectre mitigation work on amd64)

r334009: there is no amd64 rflags -> i386 eflags

5 years agopmcstat: add option to not decode the leaf function in top mode
mmacy [Tue, 22 May 2018 04:45:46 +0000 (04:45 +0000)]
pmcstat: add option to not decode the leaf function in top mode

-I will allow the user to see the hot instruction in question
as opposed getting the name of the function

5 years agoWe must free the variable str.
araujo [Tue, 22 May 2018 04:08:08 +0000 (04:08 +0000)]
We must free the variable str.

Spotted by: clang's static analyzer
Submitted by: Tom Rix <trix_juniper.net>
Reviewed by: grehan
MFC after: 4 weeks
Sponsored by: iXsystems Inc.
Differential Revision: https://reviews.freebsd.org/D10009

5 years agoAdd an IPMI attachment for PowerNV systems
jhibbits [Tue, 22 May 2018 03:57:32 +0000 (03:57 +0000)]
Add an IPMI attachment for PowerNV systems

IPMI access on PowerNV systems is done through the OPAL firmware.  This adds a
simple attachment for communicating with the FSP/BMC on these machines.  This
has been tested on a Talos POWER9 workstation, only in the bootup phase, noting
the successful attachment messages:

...
ipmi0: IPMI device rev. 0, firmware rev. 2.00, version 2.0, device support mask 0
ipmi0: Number of channels 2
...

The ipmi device has not been added to GENERIC64, but may be after further
testing.  It may also eventually be added to the ipmi module at that point.

5 years agoAdd a comment explaining the need of a global temporary variable
jhibbits [Tue, 22 May 2018 03:24:16 +0000 (03:24 +0000)]
Add a comment explaining the need of a global temporary variable

cpu_xirr is used only as a temporary location for the OPAL call in
PIC_DISPATCH().

Requested by: nwhitehorn

5 years agoBasic OPAL sensor support for POWER9 platforms
jhibbits [Tue, 22 May 2018 02:42:53 +0000 (02:42 +0000)]
Basic OPAL sensor support for POWER9 platforms

Summary:
PowerNV architectures (in the test case POWER9) export sensors via the device
tree, which are accessed via OPAL calls.  This adds sysctl nodes for each
device in a generic fashion.  New sysctl nodes are:

dev.opal_sensor.N.sensor
dev.opal_sensor.N.sensor_min
dev.opal_sensor.N.sensor_max
dev.opal_sensor.N.type
dev.opal_sensor.N.label

These are rooted at a parent attachment under opal, called opalsens.  This does
not add support for the "sensor groups" defined in the device tree.

Reviewed by: breno.leitao_gmail.com
Differential Revision: https://reviews.freebsd.org/D15362

5 years agotop(1): unbreak build with gcc7; fix varargs
eadler [Tue, 22 May 2018 02:13:04 +0000 (02:13 +0000)]
top(1): unbreak build with gcc7; fix varargs

- use correct function for varargs argument
- allow build to complete with gcc7 at current WARNS

Reported by: jhibbits, ian

5 years agoCleanups related to debug exceptions on x86.
jhb [Tue, 22 May 2018 00:45:00 +0000 (00:45 +0000)]
Cleanups related to debug exceptions on x86.

- Add constants for fields in DR6 and the reserved fields in DR7.  Use
  these constants instead of magic numbers in most places that use DR6
  and DR7.
- Refer to T_TRCTRAP as "debug exception" rather than a "trace trap"
  as it is not just for trace exceptions.
- Always read DR6 for debug exceptions and only clear TF in the flags
  register for user exceptions where DR6.BS is set.
- Clear DR6 before returning from a debug exception handler as
  recommended by the SDM dating all the way back to the 386.  This
  allows debuggers to determine the cause of each exception.  For
  kernel traps, clear DR6 in the T_TRCTRAP case and pass DR6 by value
  to other parts of the handler (namely, user_dbreg_trap()).  For user
  traps, wait until after trapsignal to clear DR6 so that userland
  debuggers can read DR6 via PT_GETDBREGS while the thread is stopped
  in trapsignal().

Reviewed by: kib, rgrimes
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D15189

5 years agosh: Split CNL syntax category to avoid a check on state[level].syntax
jilles [Mon, 21 May 2018 21:52:48 +0000 (21:52 +0000)]
sh: Split CNL syntax category to avoid a check on state[level].syntax

No functional change is intended.

5 years agodevd: Always install devmatch.conf
manu [Mon, 21 May 2018 21:44:47 +0000 (21:44 +0000)]
devd: Always install devmatch.conf

It allows devd to run devmatch to find the correct driver based on pnp info.

No Objection from:    imp